diff --git a/libs/ardour/ardour/triggerbox.h b/libs/ardour/ardour/triggerbox.h index 6441649bdf..4efea5153c 100644 --- a/libs/ardour/ardour/triggerbox.h +++ b/libs/ardour/ardour/triggerbox.h @@ -815,6 +815,7 @@ namespace Properties { 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 channel_map; /* 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 7ab1ba465f..813061bd73 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -65,6 +65,7 @@ namespace ARDOUR { PBD::PropertyDescriptor stretch_mode; PBD::PropertyDescriptor tempo_meter; /* only to transmit updates, not storage */ PBD::PropertyDescriptor patch_change; /* only to transmit updates, not storage */ + PBD::PropertyDescriptor channel_map; /* only to transmit updates, not storage */ } } @@ -1720,10 +1721,15 @@ MIDITrigger::set_channel_map (int channel, int target) if (channel < 0 || channel >= 16) { return; } + if (target < 0 || target >= 16) { return; } - _channel_map[channel] = target; + + if (_channel_map[channel] != target) { + _channel_map[channel] = target; + PropertyChanged (Properties::channel_map); + } } void @@ -1732,7 +1738,11 @@ MIDITrigger::unset_channel_map (int channel) if (channel < 0 || channel >= 16) { return; } - _channel_map[channel] = -1; + + if (_channel_map[channel] >= 0) { + _channel_map[channel] = -1; + PropertyChanged (Properties::channel_map); + } } int @@ -1938,6 +1948,21 @@ MIDITrigger::get_state (void) node.add_child_nocopy (*patches_node); } + std::string cmstr; + + for (int chn = 0; chn < 16; ++chn) { + char buf[4]; + + if (chn > 0) { + cmstr += ','; + } + + snprintf (buf, sizeof (buf), "%d", _channel_map[chn]); + cmstr += buf; + } + + node.set_property (X_("channel-map"), cmstr); + return node; } @@ -1971,6 +1996,23 @@ MIDITrigger::set_state (const XMLNode& node, int version) } } + std::string cmstr; + + if (node.get_property (X_("channel-map"), cmstr)) { + std::stringstream ss (cmstr); + char comma; + for (int chn = 0; chn < 16; ++chn) { + ss >> _channel_map[chn]; + if (!ss) { + break; + } + ss >> comma; + if (!ss) { + break; + } + } + } + return 0; } @@ -2284,6 +2326,8 @@ Trigger::make_property_quarks () 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)); + Properties::channel_map.property_id = g_quark_from_static_string (X_("channel_map")); + DEBUG_TRACE (DEBUG::Properties, string_compose ("quark for channel_map = %1\n", Properties::channel_map.property_id)); } Temporal::BBT_Offset TriggerBox::_assumed_trigger_duration (4, 0, 0);