Remove frame conversion for MidiRegionView::note_in_region_range(), speed up tempo...
authornick_m <mainsbridge@gmail.com>
Sat, 18 Jun 2016 13:24:05 +0000 (23:24 +1000)
committernick_m <mainsbridge@gmail.com>
Sat, 9 Jul 2016 16:18:36 +0000 (02:18 +1000)
gtk2_ardour/midi_region_view.cc
libs/ardour/ardour/midi_region.h
libs/ardour/midi_region.cc

index 5c460cdf483d43675fbc3454e4c9ff2aaa414dcc..fea3857a905410cc0189edf1ae92e3ca22888a63 100644 (file)
@@ -1670,12 +1670,9 @@ MidiRegionView::start_playing_midi_chord (vector<boost::shared_ptr<NoteType> > n
 bool
 MidiRegionView::note_in_region_range (const boost::shared_ptr<NoteType> note, bool& visible) const
 {
-       /* This is imprecise due to all the conversion conversion involved, so only
-          hide notes if they seem to start more than one tick before the start. */
-       const framecnt_t tick_frames       = Evoral::Beats::tick().to_ticks(trackview.session()->frame_rate());
-       const framepos_t note_start_frames = source_beats_to_region_frames (note->time());
-       const bool       outside           = ((note_start_frames <= -tick_frames) ||
-                                             (note_start_frames >= _region->length()));
+       const boost::shared_ptr<ARDOUR::MidiRegion> midi_reg = midi_region();
+       const bool outside = (note->time() < midi_reg->start_beats() ||
+                             note->time() > midi_reg->start_beats() + midi_reg->length_beats());
 
        visible = (note->note() >= midi_stream_view()->lowest_note()) &&
                (note->note() <= midi_stream_view()->highest_note());
index 9de79a9513e3b40c11a38dccb684295f5ac7fc21..21d6c13ade5fca7da322fb9700e3f60ca9ae5a36 100644 (file)
@@ -102,6 +102,7 @@ class LIBARDOUR_API MidiRegion : public Region
 
        void fix_negative_start ();
        Evoral::Beats start_beats () {return _start_beats.val(); }
+       Evoral::Beats length_beats () {return _length_beats.val(); }
   protected:
 
        virtual bool can_trim_start_before_source_start () const {
index 035c17c9de3e90f42a036a57a5ed9614e38e39c9..ce473c162d0f73fc43414b9b5f1b9491e1fe1098 100644 (file)
@@ -197,16 +197,25 @@ MidiRegion::set_length_internal (framecnt_t len, const int32_t& sub_num)
 void
 MidiRegion::update_after_tempo_map_change (bool /* send */)
 {
+       const framepos_t old_pos = _position;
+       const framepos_t old_length = _length;
+       const framepos_t old_start = _start;
+
        Region::update_after_tempo_map_change (false);
 
        /* _start has now been updated. */
        _length = _session.tempo_map().frame_at_beat (beat() + _length_beats.val().to_double()) - _position;
 
        PropertyChange s_and_l;
-       s_and_l.add (Properties::start);
-       s_and_l.add (Properties::length);
-       s_and_l.add (Properties::length_beats);
-       s_and_l.add (Properties::position);
+       if (old_start != _start) {
+               s_and_l.add (Properties::start);
+       }
+       if (old_length != _length) {
+               s_and_l.add (Properties::length);
+       }
+       if (old_pos != _position) {
+               s_and_l.add (Properties::position);
+       }
 
        send_change (s_and_l);
 }