Skip to content

Commit

Permalink
Fix dssi_get_midi_controller_for_port (needs port offset)
Browse files Browse the repository at this point in the history
  • Loading branch information
falkTX committed May 9, 2017
1 parent bb29962 commit f644f30
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
25 changes: 25 additions & 0 deletions distrho/src/DistrhoPluginInternal.hpp
Expand Up @@ -43,6 +43,7 @@ struct Plugin::PrivateData {
#endif

uint32_t parameterCount;
uint32_t parameterOffset;
Parameter* parameters;

#if DISTRHO_PLUGIN_WANT_PROGRAMS
Expand Down Expand Up @@ -73,6 +74,7 @@ struct Plugin::PrivateData {
audioPorts(nullptr),
#endif
parameterCount(0),
parameterOffset(0),
parameters(nullptr),
#if DISTRHO_PLUGIN_WANT_PROGRAMS
programCount(0),
Expand All @@ -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
Expand Down Expand Up @@ -283,6 +301,13 @@ class PluginExporter
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);
Expand Down
7 changes: 6 additions & 1 deletion distrho/src/DistrhoPluginLADSPA+DSSI.cpp
Expand Up @@ -331,7 +331,12 @@ class PluginLadspaDssi

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;
Expand Down

0 comments on commit f644f30

Please sign in to comment.