From 15f0e4dbbfd813d47d412ca8ac7c3fac5342c093 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 27 Jan 2022 11:36:04 -0700 Subject: [PATCH] triggerbox: fix cue playback and recording Somewhat alarmed that gcc (at least) allows if (cue_recording ...) to be used just like if (_cue_recording) even though the former is a class method and the latter is a class member. --- libs/ardour/ardour/session.h | 2 +- libs/ardour/session_process.cc | 5 ++++- libs/ardour/triggerbox.cc | 9 +++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 2b7287d5f7..67d5735496 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1354,7 +1354,7 @@ public: PBD::TimingStats dsp_stats[NTT]; - int32_t first_cue_within (samplepos_t s, samplepos_t e); + int32_t first_cue_within (samplepos_t s, samplepos_t e, bool& was_recorded); void cue_bang (int32_t); protected: diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc index cea969e3b1..cb923e9e3c 100644 --- a/libs/ardour/session_process.cc +++ b/libs/ardour/session_process.cc @@ -1628,10 +1628,12 @@ Session::sync_cues_from_list (Locations::LocationList const & locs) } int32_t -Session::first_cue_within (samplepos_t s, samplepos_t e) +Session::first_cue_within (samplepos_t s, samplepos_t e, bool& was_recorded) { int32_t active_cue = _active_cue.load (); + was_recorded = false; + if (active_cue >= 0) { return active_cue; } @@ -1645,6 +1647,7 @@ Session::first_cue_within (samplepos_t s, samplepos_t e) if (si != _cue_events.end()) { if (si->time < e) { + was_recorded = true; return si->cue; } } diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index 69f8d32d8e..80bada4620 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -2692,10 +2692,11 @@ TriggerBox::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp _sidechain->run (bufs, start_sample, end_sample, speed, nframes, true); } - if (!_cue_recording) { - int32_t cue_bang = _session.first_cue_within (start_sample, end_sample); - if (cue_bang >= 0) { - std::cerr << " CUE BANG " << cue_bang << std::endl; + bool was_recorded; + int32_t cue_bang = _session.first_cue_within (start_sample, end_sample, was_recorded); + + if (cue_bang >= 0) { + if (!_cue_recording || !was_recorded) { _active_scene = cue_bang; } }