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 !)
This commit is contained in:
Paul Davis 2022-08-09 12:33:37 -06:00
parent bedb94e534
commit 1c59a2dff0
2 changed files with 9 additions and 18 deletions

View file

@ -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());

View file

@ -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;
}
}