diff --git a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp index b59e9e6bfed5..745df8d1c1c4 100644 --- a/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp +++ b/modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp @@ -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; @@ -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; @@ -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]); } } } @@ -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; + } } } } @@ -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(); @@ -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) @@ -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;