From d61fc1e871f5df78afa1211ffa1175fdd9c2c077 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 15 Nov 2021 12:27:32 -0700 Subject: [PATCH] triggerbox: add passthru property to control input passthrough (monitoring) --- libs/ardour/ardour/triggerbox.h | 5 +++++ libs/ardour/triggerbox.cc | 27 +++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ardour/triggerbox.h b/libs/ardour/ardour/triggerbox.h index 1647853d52..d6a4c52a78 100644 --- a/libs/ardour/ardour/triggerbox.h +++ b/libs/ardour/ardour/triggerbox.h @@ -431,6 +431,9 @@ class LIBARDOUR_API TriggerBox : public Processor void add_midi_sidechain (std::string const & name); + bool pass_thru() const { return _pass_thru; } + void set_pass_thru (bool yn); + void request_reload (int32_t slot, void*); void request_use (int32_t slot, Trigger&); @@ -475,6 +478,7 @@ class LIBARDOUR_API TriggerBox : public Processor Trigger* up_next; Trigger* currently_playing; std::atomic _stop_all; + std::atomic _pass_thru; boost::shared_ptr _sidechain; @@ -546,6 +550,7 @@ class LIBARDOUR_API TriggerBox : public Processor namespace Properties { LIBARDOUR_API extern PBD::PropertyDescriptor use_follow; LIBARDOUR_API extern PBD::PropertyDescriptor running; + LIBARDOUR_API extern PBD::PropertyDescriptor passthru; LIBARDOUR_API extern PBD::PropertyDescriptor legato; LIBARDOUR_API extern PBD::PropertyDescriptor quantization; LIBARDOUR_API extern PBD::PropertyDescriptor launch_style; diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index ba030e018c..a539682caf 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -44,6 +44,7 @@ namespace ARDOUR { namespace Properties { PBD::PropertyDescriptor use_follow; PBD::PropertyDescriptor running; + PBD::PropertyDescriptor passthru; PBD::PropertyDescriptor legato; PBD::PropertyDescriptor quantization; PBD::PropertyDescriptor launch_style; @@ -1321,8 +1322,10 @@ MIDITrigger::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sam void Trigger::make_property_quarks () { - Properties::muted.property_id = g_quark_from_static_string (X_("running")); + Properties::running.property_id = g_quark_from_static_string (X_("running")); DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for running = %1\n", Properties::running.property_id)); + Properties::passthru.property_id = g_quark_from_static_string (X_("passthru")); + DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for passthru = %1\n", Properties::passthru.property_id)); Properties::legato.property_id = g_quark_from_static_string (X_("legato")); DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for legato = %1\n", Properties::legato.property_id)); Properties::use_follow.property_id = g_quark_from_static_string (X_("use-follow")); @@ -1376,6 +1379,7 @@ TriggerBox::TriggerBox (Session& s, DataType dt) , up_next (0) , currently_playing (0) , _stop_all (false) + , _pass_thru (false) , requests (1024) { @@ -1747,6 +1751,13 @@ TriggerBox::process_midi_trigger_requests (BufferSet& bufs) } } +void +TriggerBox::set_pass_thru (bool yn) +{ + _pass_thru = yn; + PropertyChanged (Properties::passthru); +} + void TriggerBox::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_sample, double speed, pframes_t nframes, bool result_required) { @@ -1827,7 +1838,19 @@ TriggerBox::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp Temporal::TempoMap::SharedPtr tmap (Temporal::TempoMap::use()); const double bpm = tmap->quarters_per_minute_at (start); uint64_t max_chans = 0; - bool first = false; + + /* if passthru is set, active triggers should always + * ::accumulate_from() rather than ::read_from(). If false, then the + * first active trigger uses ::read_from() and later ones will use + * ::accumulate_from() + * + * Note that this is based on a now mostly (entirely?) unused idea of + * allowing more than one trigger to operate at a time. Nevertheless + * the logic is still correct even if there is only ever 1 active + * trigger. + */ + + bool first = (_pass_thru ? true : false); /* see if there's another trigger explicitly queued that has legato set. */