Browse Source

Fix dssi_get_midi_controller_for_port (needs port offset)

pull/20/merge
falkTX 6 years ago
parent
commit
f644f303c5
2 changed files with 31 additions and 1 deletions
  1. +25
    -0
      distrho/src/DistrhoPluginInternal.hpp
  2. +6
    -1
      distrho/src/DistrhoPluginLADSPA+DSSI.cpp

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

@@ -43,6 +43,7 @@ struct Plugin::PrivateData {
#endif

uint32_t parameterCount;
uint32_t parameterOffset;
Parameter* parameters;

#if DISTRHO_PLUGIN_WANT_PROGRAMS
@@ -73,6 +74,7 @@ struct Plugin::PrivateData {
audioPorts(nullptr),
#endif
parameterCount(0),
parameterOffset(0),
parameters(nullptr),
#if DISTRHO_PLUGIN_WANT_PROGRAMS
programCount(0),
@@ -91,6 +93,22 @@ struct Plugin::PrivateData {
{
DISTRHO_SAFE_ASSERT(bufferSize != 0);
DISTRHO_SAFE_ASSERT(d_isNotZero(sampleRate));

#if defined(DISTRHO_PLUGIN_TARGET_DSSI) || defined(DISTRHO_PLUGIN_TARGET_LV2)
parameterOffset += DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS;
# if DISTRHO_PLUGIN_WANT_LATENCY
parameterOffset += 1;
# endif
#endif

#ifdef DISTRHO_PLUGIN_TARGET_LV2
# if (DISTRHO_PLUGIN_IS_SYNTH || DISTRHO_PLUGIN_WANT_TIMEPOS || DISTRHO_PLUGIN_WANT_STATE)
parameterOffset += 1;
# if DISTRHO_PLUGIN_WANT_STATE
parameterOffset += 1;
# endif
# endif
#endif
}

~PrivateData() noexcept
@@ -283,6 +301,13 @@ public:
return fData->parameterCount;
}

uint32_t getParameterOffset() const noexcept
{
DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr, 0);

return fData->parameterOffset;
}

uint32_t getParameterHints(const uint32_t index) const noexcept
{
DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr && index < fData->parameterCount, 0x0);


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

@@ -331,7 +331,12 @@ public:

int dssi_get_midi_controller_for_port(const ulong port) noexcept
{
const uint8_t midiCC = fPlugin.getParameterMidiCC(port);
const uint32_t parameterOffset = fPlugin.getParameterOffset();

if (port > parameterOffset)
return DSSI_NONE;

const uint8_t midiCC = fPlugin.getParameterMidiCC(port-parameterOffset);

if (midiCC == 0 || midiCC == 32 || midiCC >= 0x78)
return DSSI_NONE;


Loading…
Cancel
Save