Skip to content

Commit

Permalink
Fix crash & assertion when running multi-bus plug-ins in Cakewalk
Browse files Browse the repository at this point in the history
  • Loading branch information
fr810 authored and fr810 committed Apr 21, 2016
1 parent 1675f82 commit 0d1f621
Showing 1 changed file with 34 additions and 28 deletions.
62 changes: 34 additions & 28 deletions modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp
Expand Up @@ -1632,10 +1632,6 @@ class JuceVST3Component : public Vst::IComponent,
MidiEventList::toMidiBuffer (midiBuffer, *data.inputEvents);
#endif

#if JUCE_DEBUG && ! JucePlugin_ProducesMidiOutput
const int numMidiEventsComingIn = midiBuffer.getNumEvents();
#endif

if (getHostType().isWavelab())
{
const int numInputChans = (data.inputs != nullptr && data.inputs[0].channelBuffers32 != nullptr) ? (int) data.inputs[0].numChannels : 0;
Expand All @@ -1653,22 +1649,6 @@ class JuceVST3Component : public Vst::IComponent,
#if JucePlugin_ProducesMidiOutput
if (data.outputEvents != nullptr)
MidiEventList::toEventList (*data.outputEvents, midiBuffer);
#elif JUCE_DEBUG
/* This assertion is caused when you've added some events to the
midiMessages array in your processBlock() method, which usually means
that you're trying to send them somewhere. But in this case they're
getting thrown away.
If your plugin does want to send MIDI messages, you'll need to set
the JucePlugin_ProducesMidiOutput macro to 1 in your
JucePluginCharacteristics.h file.
If you don't want to produce any MIDI output, then you should clear the
midiMessages array at the end of your processBlock() method, to
indicate that you don't want any of the events to be passed through
to the output.
*/
jassert (midiBuffer.getNumEvents() <= numMidiEventsComingIn);
#endif

return kResultTrue;
Expand Down Expand Up @@ -1722,7 +1702,8 @@ class JuceVST3Component : public Vst::IComponent,
const int numChans = jmin ((int) data.inputs[bus].numChannels, plugInInputChannels - totalInputChans);

for (int i = 0; i < numChans; ++i)
channelList.set (totalInputChans++, busChannels[i]);
if (busChannels[i] != nullptr)
channelList.set (totalInputChans++, busChannels[i]);
}
}
}
Expand All @@ -1739,13 +1720,16 @@ class JuceVST3Component : public Vst::IComponent,

for (int i = 0; i < numChans; ++i)
{
if (totalOutputChans >= totalInputChans)
if (busChannels[i] != nullptr)
{
FloatVectorOperations::clear (busChannels[i], data.numSamples);
channelList.set (totalOutputChans, busChannels[i]);
}
if (totalOutputChans >= totalInputChans)
{
FloatVectorOperations::clear (busChannels[i], data.numSamples);
channelList.set (totalOutputChans, busChannels[i]);
}

++totalOutputChans;
++totalOutputChans;
}
}
}
}
Expand All @@ -1764,6 +1748,10 @@ class JuceVST3Component : public Vst::IComponent,
if (data.inputParameterChanges != nullptr)
processParameterChanges (*data.inputParameterChanges);

#if JUCE_DEBUG && ! JucePlugin_ProducesMidiOutput
const int numMidiEventsComingIn = midiBuffer.getNumEvents ();
#endif

if (pluginInstance->isSuspended())
{
buffer.clear();
Expand All @@ -1779,6 +1767,24 @@ class JuceVST3Component : public Vst::IComponent,
pluginInstance->processBlock (buffer, midiBuffer);
}
}

#if JUCE_DEBUG && (! JucePlugin_ProducesMidiOutput)
/* This assertion is caused when you've added some events to the
midiMessages array in your processBlock() method, which usually means
that you're trying to send them somewhere. But in this case they're
getting thrown away.
If your plugin does want to send MIDI messages, you'll need to set
the JucePlugin_ProducesMidiOutput macro to 1 in your
JucePluginCharacteristics.h file.
If you don't want to produce any MIDI output, then you should clear the
midiMessages array at the end of your processBlock() method, to
indicate that you don't want any of the events to be passed through
to the output.
*/
jassert (midiBuffer.getNumEvents() <= numMidiEventsComingIn);
#endif
}

if (data.outputs != nullptr)
Expand All @@ -1793,9 +1799,9 @@ class JuceVST3Component : public Vst::IComponent,

for (int i = 0; i < numChans; ++i)
{
if (outChanIndex < totalInputChans)
if (outChanIndex < totalInputChans && busChannels[i] != nullptr)
FloatVectorOperations::copy (busChannels[i], buffer.getReadPointer (outChanIndex), (int) data.numSamples);
else if (outChanIndex >= totalOutputChans)
else if (outChanIndex >= totalOutputChans && busChannels[i] != nullptr)
FloatVectorOperations::clear (busChannels[i], (int) data.numSamples);

++outChanIndex;
Expand Down

0 comments on commit 0d1f621

Please sign in to comment.