commit cda831ffcd5f4fe6138e86e5fab70d81f4cf3a18
parent e0a6ebf25188be6c3b88d7458c16646784420b90
Author: falkTX <falktx@gmail.com>
Date: Sat, 30 Jul 2016 17:40:33 +0200
Add 'midiCC' hint to Parameter, use in as DSSI code already
This provides the initial work for #12.
We need to export this info for LV2s as well.
Diffstat:
3 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/distrho/DistrhoPlugin.hpp b/distrho/DistrhoPlugin.hpp
@@ -290,6 +290,14 @@ struct Parameter {
ParameterRanges ranges;
/**
+ MIDI CC to use by default on this parameter.@n
+ A value of 0 or 32 (bank change) is considered invalid.@n
+ Must also be less or equal to 120.
+ @note This value is only a hint! Hosts might map it automatically or completely ignore it.
+ */
+ uint8_t midiCC;
+
+ /**
Default constructor for a null parameter.
*/
Parameter() noexcept
@@ -297,7 +305,8 @@ struct Parameter {
name(),
symbol(),
unit(),
- ranges() {}
+ ranges(),
+ midiCC(0) {}
/**
Constructor using custom values.
@@ -307,7 +316,8 @@ struct Parameter {
name(n),
symbol(s),
unit(u),
- ranges(def, min, max) {}
+ ranges(def, min, max),
+ midiCC(0) {}
};
/**
diff --git a/distrho/src/DistrhoPluginInternal.hpp b/distrho/src/DistrhoPluginInternal.hpp
@@ -323,6 +323,13 @@ public:
return fData->parameters[index].ranges;
}
+ uint8_t getParameterMidiCC(const uint32_t index) const noexcept
+ {
+ DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr && index < fData->parameterCount, 0);
+
+ return fData->parameters[index].midiCC;
+ }
+
float getParameterValue(const uint32_t index) const
{
DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr, 0.0f);
diff --git a/distrho/src/DistrhoPluginLADSPA+DSSI.cpp b/distrho/src/DistrhoPluginLADSPA+DSSI.cpp
@@ -328,6 +328,16 @@ public:
}
}
# endif
+
+ int dssi_get_midi_controller_for_port(const ulong port) noexcept
+ {
+ const uint8_t midiCC = fPlugin.getParameterMidiCC(port);
+
+ if (midiCC == 0 || midiCC == 32 || midiCC >= 0x78)
+ return DSSI_NONE;
+
+ return DSSI_CC(midiCC);
+ }
#endif
// -------------------------------------------------------------------
@@ -434,6 +444,11 @@ static void dssi_select_program(LADSPA_Handle instance, ulong bank, ulong progra
}
# endif
+static int dssi_get_midi_controller_for_port(LADSPA_Handle instance, ulong port)
+{
+ return instancePtr->dssi_get_midi_controller_for_port(port);
+}
+
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
static void dssi_run_synth(LADSPA_Handle instance, ulong sampleCount, snd_seq_event_t* events, ulong eventCount)
{
@@ -488,7 +503,7 @@ static DSSI_Descriptor sDssiDescriptor = {
/* get_program */ nullptr,
/* select_program */ nullptr,
# endif
- /* get_midi_controller_for_port */ nullptr,
+ dssi_get_midi_controller_for_port,
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT
dssi_run_synth,
# else