From b65f18a56e0ef7b4e9be10e7c94c48357cc3a68d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 1 Nov 2021 09:14:02 -0600 Subject: [PATCH] triggerbox: basics of scene triggering --- libs/ardour/ardour/triggerbox.h | 7 +++++++ libs/ardour/triggerbox.cc | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/libs/ardour/ardour/triggerbox.h b/libs/ardour/ardour/triggerbox.h index 072ca87528..9bbbc75d58 100644 --- a/libs/ardour/ardour/triggerbox.h +++ b/libs/ardour/ardour/triggerbox.h @@ -381,6 +381,11 @@ class LIBARDOUR_API TriggerBox : public Processor static int first_midi_note() { return _first_midi_note; } static void set_first_midi_note (int n); + static void maybe_find_scene_bang (); + static void clear_scene_bang (); + static void scene_bang (uint32_t scene_number); + static void scene_unbang (uint32_t scene_number); + private: static Temporal::BBT_Offset _assumed_trigger_duration; @@ -421,6 +426,8 @@ class LIBARDOUR_API TriggerBox : public Processor static const uint64_t default_triggers_per_box; static int _first_midi_note; static TriggerMidiMapMode _midi_map_mode; + static std::atomic _pending_scene; + static std::atomic _active_scene; }; namespace Properties { diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index bf604224ab..ba95c4e6e2 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -1322,6 +1322,8 @@ Temporal::BBT_Offset TriggerBox::_assumed_trigger_duration (4, 0, 0); //TriggerBox::TriggerMidiMapMode TriggerBox::_midi_map_mode (TriggerBox::AbletonPush); TriggerBox::TriggerMidiMapMode TriggerBox::_midi_map_mode (TriggerBox::SequentialNote); int TriggerBox::_first_midi_note = 60; +std::atomic TriggerBox::_pending_scene (-1); +std::atomic TriggerBox::_active_scene (-1); TriggerBox::TriggerBox (Session& s, DataType dt) : Processor (s, _("TriggerBox"), Temporal::BeatTime) @@ -1352,6 +1354,33 @@ TriggerBox::TriggerBox (Session& s, DataType dt) Config->ParameterChanged.connect_same_thread (*this, boost::bind (&TriggerBox::parameter_changed, this, _1)); } +void +TriggerBox::scene_bang (uint32_t n) +{ + _pending_scene = n; +} + +void +TriggerBox::scene_unbang (uint32_t n) +{ +} + +void +TriggerBox::maybe_find_scene_bang () +{ + uint32_t pending = _pending_scene.exchange (-1); + + if (pending >= 0) { + _active_scene = pending; + } +} + +void +TriggerBox::clear_scene_bang () +{ + (void) _active_scene.exchange (-1); +} + void TriggerBox::clear_implicit () {