diff --git a/source/backend/CarlaStandalone.cpp b/source/backend/CarlaStandalone.cpp index 9ec2ef73e..7671a9ace 100644 --- a/source/backend/CarlaStandalone.cpp +++ b/source/backend/CarlaStandalone.cpp @@ -2148,6 +2148,7 @@ void carla_set_panning(uint pluginId, float value) void carla_set_ctrl_channel(uint pluginId, int8_t channel) { CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,); + CARLA_SAFE_ASSERT_RETURN(channel >= -1 && channel < MAX_MIDI_CHANNELS,); carla_debug("carla_set_ctrl_channel(%i, %i)", pluginId, channel); if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) @@ -2179,7 +2180,7 @@ void carla_set_parameter_value(uint pluginId, uint32_t parameterId, float value) void carla_set_parameter_midi_channel(uint pluginId, uint32_t parameterId, uint8_t channel) { CARLA_SAFE_ASSERT_RETURN(gStandalone.engine != nullptr,); - CARLA_SAFE_ASSERT_RETURN(channel >= MAX_MIDI_CHANNELS,); + CARLA_SAFE_ASSERT_RETURN(channel < MAX_MIDI_CHANNELS,); carla_debug("carla_set_parameter_midi_channel(%i, %i, %i)", pluginId, parameterId, channel); if (CarlaPlugin* const plugin = gStandalone.engine->getPlugin(pluginId)) diff --git a/source/utils/CarlaStateUtils.cpp b/source/utils/CarlaStateUtils.cpp index 86d480e1b..e23d1ee9c 100644 --- a/source/utils/CarlaStateUtils.cpp +++ b/source/utils/CarlaStateUtils.cpp @@ -264,9 +264,12 @@ bool StateSave::fillFromXmlElement(const XmlElement* const xmlElement) } else if (tag.equalsIgnoreCase("controlchannel") || tag.equalsIgnoreCase("control-channel")) { - const int value(text.getIntValue()); - if (value >= 1 && value <= MAX_MIDI_CHANNELS) - ctrlChannel = static_cast(value-1); + if (! text.startsWithIgnoreCase("n")) + { + const int value(text.getIntValue()); + if (value >= 1 && value <= MAX_MIDI_CHANNELS) + ctrlChannel = static_cast(value-1); + } } // -------------------------------------------------------