From 6175af002c544bd359d0f9347f8060a9b2aee5f9 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 2 Feb 2022 12:45:57 -0700 Subject: [PATCH] triggerbox: MIDITriggers get 16 patch changes, 1 per channel These can be set, fetched and queried but at this point they do nothing --- libs/ardour/ardour/triggerbox.h | 11 +++++++ libs/ardour/triggerbox.cc | 55 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/libs/ardour/ardour/triggerbox.h b/libs/ardour/ardour/triggerbox.h index ef7cef7a2a..583e4c244d 100644 --- a/libs/ardour/ardour/triggerbox.h +++ b/libs/ardour/ardour/triggerbox.h @@ -40,6 +40,8 @@ #include "temporal/bbt_time.h" #include "temporal/tempo.h" +#include "evoral/PatchChange.h" + #include "ardour/midi_model.h" #include "ardour/midi_state_tracker.h" #include "ardour/processor.h" @@ -493,6 +495,12 @@ class LIBARDOUR_API MIDITrigger : public Trigger { SegmentDescriptor get_segment_descriptor () const; void set_expected_end_sample (Temporal::TempoMap::SharedPtr const &, Temporal::BBT_Time const &, samplepos_t); + void set_patch_change (Evoral::PatchChange const &); + Evoral::PatchChange const & patch_change (uint8_t) const; + void unset_patch_change (uint8_t channel); + void unset_all_patch_changes (); + bool patch_change_set (uint8_t channel) const; + protected: void retrigger (); @@ -511,6 +519,8 @@ class LIBARDOUR_API MIDITrigger : public Trigger { MidiModel::const_iterator iter; boost::shared_ptr model; + Evoral::PatchChange _patch_change[16]; + int load_data (boost::shared_ptr); void compute_and_set_length (); void _startup (Temporal::BBT_Offset const &); @@ -798,6 +808,7 @@ namespace Properties { LIBARDOUR_API extern PBD::PropertyDescriptor currently_playing; LIBARDOUR_API extern PBD::PropertyDescriptor stretchable; LIBARDOUR_API extern PBD::PropertyDescriptor cue_isolated; + LIBARDOUR_API extern PBD::PropertyDescriptor patch_change; /* type not important */ LIBARDOUR_API extern PBD::PropertyDescriptor tempo_meter; /* only used to transmit changes, not storage */ } diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index 04de41f9b4..cd30549fcb 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -64,6 +64,7 @@ namespace ARDOUR { PBD::PropertyDescriptor cue_isolated; PBD::PropertyDescriptor stretch_mode; PBD::PropertyDescriptor tempo_meter; /* only to transmit updates, not storage */ + PBD::PropertyDescriptor patch_change; /* only to transmit updates, not storage */ } } @@ -1709,6 +1710,54 @@ MIDITrigger::~MIDITrigger () { } +void +MIDITrigger::set_patch_change (Evoral::PatchChange const & pc) +{ + assert (pc.is_set()); + _patch_change[pc.channel()] = pc; + PropertyChanged (Properties::patch_change); +} + +void +MIDITrigger::unset_all_patch_changes () +{ + bool changed = false; + + for (uint8_t chn = 0; chn < 16; ++chn) { + changed |= _patch_change[chn].is_set(); + _patch_change[chn].unset (); + } + + if (changed) { + PropertyChanged (Properties::patch_change); + } +} + +void +MIDITrigger::unset_patch_change (uint8_t channel) +{ + assert (channel < 16); + if (_patch_change[channel].is_set()) { + _patch_change[channel].unset (); + PropertyChanged (Properties::patch_change); + } +} + +bool +MIDITrigger::patch_change_set (uint8_t channel) const +{ + assert (channel < 16); + return _patch_change[channel].is_set(); +} + +Evoral::PatchChange const & +MIDITrigger::patch_change (uint8_t channel) const +{ + assert (channel < 16); + return _patch_change[channel]; +} + + bool MIDITrigger::probably_oneshot () const { @@ -1837,6 +1886,10 @@ MIDITrigger::set_state (const XMLNode& node, int version) /* XXX need to deal with bar offsets */ _start_offset = Temporal::BBT_Offset (0, b.get_beats(), b.get_ticks()); + XMLNode* patch_child = node.child (X_("PatchChanges")); + + if (patch_child) { + } return 0; } @@ -2137,6 +2190,8 @@ Trigger::make_property_quarks () DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for cue_isolated = %1\n", Properties::cue_isolated.property_id)); Properties::stretch_mode.property_id = g_quark_from_static_string (X_("stretch_mode")); DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for stretch_mode = %1\n", Properties::stretch_mode.property_id)); + Properties::patch_change.property_id = g_quark_from_static_string (X_("patch_change")); + DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for patch_change = %1\n", Properties::patch_change.property_id)); } Temporal::BBT_Offset TriggerBox::_assumed_trigger_duration (4, 0, 0);