fix unconditional note resolution during DiskReader::realtime_locate()
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 7 Nov 2019 05:12:40 +0000 (22:12 -0700)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 7 Nov 2019 05:12:40 +0000 (22:12 -0700)
When looping, we do not want to resolve notes at the end of the loop via ::realtime_locate() -
::get_midi_playback() has already taken care of this. But when not looping, we need this. So,
add an argument to tell all interested parties whether the locate is for a loop end or not

libs/ardour/disk_reader.cc
libs/ardour/midi_state_tracker.cc
libs/ardour/plugin.cc
libs/ardour/rt_midibuffer.cc
libs/ardour/transport_fsm.cc

index 919fdd86696135e695ffca33676bfef4d3c31d9f..7c1f7231c188e95669675f7e42bb6dd942703c5d 100644 (file)
@@ -169,8 +169,11 @@ void
 DiskReader::realtime_locate (bool for_loop_end)
 {
        if (!for_loop_end) {
+               std::cerr << name() << "DO note resolve on locate for loop\n";
                boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack>(_track);
                _tracker.resolve_notes (mt->immediate_events(), 0);
+       } else {
+               std::cerr << name() << "skip note resolve on locate for loop\n";
        }
 }
 
index ecc860fa9272381a64df66c2fefbe89cc7cfe9bb..c4a892316eb7db91bb94b6af94132905b41dd456 100644 (file)
@@ -119,6 +119,8 @@ MidiStateTracker::resolve_notes (MidiBuffer &dst, samplepos_t time)
                return;
        }
 
+       PBD::stacktrace (std::cerr, 20);
+
        for (int channel = 0; channel < 16; ++channel) {
                for (int note = 0; note < 128; ++note) {
                        while (_active_notes[note + 128 * channel]) {
index 5d77b375bcddbe8cabb44c225fa51c53548100fd..0539d5a8cf15a486057ad90b42f4ce2f9cd1f1a4 100644 (file)
@@ -391,9 +391,13 @@ Plugin::realtime_handle_transport_stopped ()
 }
 
 void
-Plugin::realtime_locate (bool)
+Plugin::realtime_locate (bool for_loop_end)
 {
-       resolve_midi ();
+       std::cerr << name() << " RL fle = " << for_loop_end << std::endl;
+
+       //if (!for_loop_end) {
+               resolve_midi ();
+//}
 }
 
 void
index 3a60c9e93f96804c5060ed708966813b2c30d021..c67e81c1aedee689bc7f7bb3af2cf0cdf494ed90 100644 (file)
@@ -180,9 +180,10 @@ RTMidiBuffer::read (MidiBuffer& dst, samplepos_t start, samplepos_t end, MidiSta
 
 #ifndef NDEBUG
        TimeType unadjusted_time;
+       Item* last = iend; --last;
 #endif
 
-       DEBUG_TRACE (DEBUG::MidiRingBuffer, string_compose ("read from %1 .. %2 .. initial index = %3 (time = %4) (range in list of  %7 %5..%6)\n", start, end, item - _data, item->timestamp, _data->timestamp, iend->timestamp, _size));
+       DEBUG_TRACE (DEBUG::MidiRingBuffer, string_compose ("read from %1 .. %2 .. initial index = %3 (time = %4) (range in list of  %7 %5..%6)\n", start, end, item - _data, item->timestamp, _data->timestamp, last->timestamp, _size));
 
        while ((item < iend) && (item->timestamp < end)) {
 
index 1bba909622d7a3f52725bb1f7335433e5e69ac57..8ec572854cc142787b8bc96b93585de203f0c5bb 100644 (file)
@@ -419,7 +419,7 @@ void
 TransportFSM::locate_for_loop (Event const & l)
 {
        assert (l.type == Locate);
-       DEBUG_TRACE (DEBUG::TFSMEvents, "locate_for_loop\n");
+       DEBUG_TRACE (DEBUG::TFSMEvents, string_compose ("locate_for_loop, wl = %1\n", l.with_loop));
        current_roll_after_locate_status = l.with_roll;
        api->locate (l.target, l.with_roll, l.with_flush, l.with_loop, l.force);
 }