Browse Source

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.
pull/17/head
falkTX 8 years ago
parent
commit
cda831ffcd
3 changed files with 35 additions and 3 deletions
  1. +12
    -2
      distrho/DistrhoPlugin.hpp
  2. +7
    -0
      distrho/src/DistrhoPluginInternal.hpp
  3. +16
    -1
      distrho/src/DistrhoPluginLADSPA+DSSI.cpp

+ 12
- 2
distrho/DistrhoPlugin.hpp View File

@@ -289,6 +289,14 @@ struct Parameter {
*/ */
ParameterRanges ranges; 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. Default constructor for a null parameter.
*/ */
@@ -297,7 +305,8 @@ struct Parameter {
name(), name(),
symbol(), symbol(),
unit(), unit(),
ranges() {}
ranges(),
midiCC(0) {}


/** /**
Constructor using custom values. Constructor using custom values.
@@ -307,7 +316,8 @@ struct Parameter {
name(n), name(n),
symbol(s), symbol(s),
unit(u), unit(u),
ranges(def, min, max) {}
ranges(def, min, max),
midiCC(0) {}
}; };


/** /**


+ 7
- 0
distrho/src/DistrhoPluginInternal.hpp View File

@@ -323,6 +323,13 @@ public:
return fData->parameters[index].ranges; 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 float getParameterValue(const uint32_t index) const
{ {
DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr, 0.0f); DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr, 0.0f);


+ 16
- 1
distrho/src/DistrhoPluginLADSPA+DSSI.cpp View File

@@ -328,6 +328,16 @@ public:
} }
} }
# endif # 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 #endif


// ------------------------------------------------------------------- // -------------------------------------------------------------------
@@ -434,6 +444,11 @@ static void dssi_select_program(LADSPA_Handle instance, ulong bank, ulong progra
} }
# endif # 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 # if DISTRHO_PLUGIN_WANT_MIDI_INPUT
static void dssi_run_synth(LADSPA_Handle instance, ulong sampleCount, snd_seq_event_t* events, ulong eventCount) 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, /* get_program */ nullptr,
/* select_program */ nullptr, /* select_program */ nullptr,
# endif # endif
/* get_midi_controller_for_port */ nullptr,
dssi_get_midi_controller_for_port,
# if DISTRHO_PLUGIN_WANT_MIDI_INPUT # if DISTRHO_PLUGIN_WANT_MIDI_INPUT
dssi_run_synth, dssi_run_synth,
# else # else


Loading…
Cancel
Save