13
0

triggerbox: MIDITriggers get 16 patch changes, 1 per channel

These can be set, fetched and queried but at this point they do nothing
This commit is contained in:
Paul Davis 2022-02-02 12:45:57 -07:00
parent 603d1f1f57
commit 6175af002c
2 changed files with 66 additions and 0 deletions

View File

@ -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<MidiBuffer::TimeType> const &);
Evoral::PatchChange<MidiBuffer::TimeType> 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<MidiModel> model;
Evoral::PatchChange<MidiBuffer::TimeType> _patch_change[16];
int load_data (boost::shared_ptr<MidiRegion>);
void compute_and_set_length ();
void _startup (Temporal::BBT_Offset const &);
@ -798,6 +808,7 @@ namespace Properties {
LIBARDOUR_API extern PBD::PropertyDescriptor<uint32_t> currently_playing;
LIBARDOUR_API extern PBD::PropertyDescriptor<bool> stretchable;
LIBARDOUR_API extern PBD::PropertyDescriptor<bool> cue_isolated;
LIBARDOUR_API extern PBD::PropertyDescriptor<bool> patch_change; /* type not important */
LIBARDOUR_API extern PBD::PropertyDescriptor<bool> tempo_meter; /* only used to transmit changes, not storage */
}

View File

@ -64,6 +64,7 @@ namespace ARDOUR {
PBD::PropertyDescriptor<bool> cue_isolated;
PBD::PropertyDescriptor<Trigger::StretchMode> stretch_mode;
PBD::PropertyDescriptor<bool> tempo_meter; /* only to transmit updates, not storage */
PBD::PropertyDescriptor<bool> patch_change; /* only to transmit updates, not storage */
}
}
@ -1709,6 +1710,54 @@ MIDITrigger::~MIDITrigger ()
{
}
void
MIDITrigger::set_patch_change (Evoral::PatchChange<MidiBuffer::TimeType> 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<MidiBuffer::TimeType> 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);