From 1c59a2dff086270813c2b410043e170f4be3d257 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 9 Aug 2022 12:33:37 -0600 Subject: [PATCH] triggerbox/route: a cleaner method of ensuring trigger alignment This change still runs the triggerbox during latency-preroll, but as with the disk reader, the transport speed argument is set to zero. The triggerbox notices this and behaves appropriately (I think !) --- libs/ardour/route.cc | 21 +++++---------------- libs/ardour/triggerbox.cc | 6 ++++-- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index a524119381..ea578e57c7 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -510,7 +510,7 @@ Route::process_output_buffers (BufferSet& bufs, } double pspeed = speed; - if ((!run_disk_reader && (*i) == _disk_reader) || (!run_disk_writer && (*i) == _disk_writer)) { + if ((!run_disk_reader && (((*i) == _disk_reader) || ((*i) == _triggerbox))) || (!run_disk_writer && (*i) == _disk_writer)) { /* run with speed 0, no-roll */ pspeed = 0; } @@ -537,21 +537,10 @@ Route::process_output_buffers (BufferSet& bufs, } } - /* run_disk_reader being false means we are still inside - * latency_preroll, and during this time we do not want to run - * the triggerbox at all. The disk reader looks at the speed - * (pspeed) that was reset to zero as a indication of how it - * should behave. The triggerbox is not speed-sensitive in the - * same way, so we need a more explicit test here to avoid - * running it. - */ - - if (run_disk_reader || ((*i) != _triggerbox) || speed == 0) { - if (speed < 0) { - (*i)->run (bufs, start_sample + latency, end_sample + latency, pspeed, nframes, *i != _processors.back()); - } else { - (*i)->run (bufs, start_sample - latency, end_sample - latency, pspeed, nframes, *i != _processors.back()); - } + if (speed < 0) { + (*i)->run (bufs, start_sample + latency, end_sample + latency, pspeed, nframes, *i != _processors.back()); + } else { + (*i)->run (bufs, start_sample - latency, end_sample - latency, pspeed, nframes, *i != _processors.back()); } bufs.set_count ((*i)->output_streams()); diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index e6643e6f90..c8f836065c 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -3924,7 +3924,7 @@ TriggerBox::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp /* transport must be active for triggers */ if (!_locate_armed) { - if (!_session.transport_state_rolling() && !allstop) { + if (speed == 0.0 && !allstop) { if (_currently_playing->state() != Trigger::WaitingToStart) { std::cerr <<"transport not rolling and trigger in state " << enum_2_string (_currently_playing->state()) << std::endl; } @@ -3941,12 +3941,14 @@ TriggerBox::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp played the trigger/slot from the start. */ - if (_session.transport_state_rolling()) { + if (speed != 0.0) { if (tracker && bufs.count().n_midi()) { tracker->flush (bufs.get_midi (0), 0, true); } _locate_armed = false; + std::cerr << "speed-non-zero, ready to roll after locate\n"; } else { + std::cerr << "speed zero, waiting to do something\n"; return; } }