diff --git a/extras/audio plugins/wrapper/formats/VST/juce_VstWrapper.cpp b/extras/audio plugins/wrapper/formats/VST/juce_VstWrapper.cpp index 49db35fad6..5f1d5693a0 100644 --- a/extras/audio plugins/wrapper/formats/VST/juce_VstWrapper.cpp +++ b/extras/audio plugins/wrapper/formats/VST/juce_VstWrapper.cpp @@ -618,6 +618,27 @@ public: } else { + if (! hasCreatedTempChannels) + { + // do this just once when we start processing.. + hasCreatedTempChannels = true; + + // if some output channels are disabled, some hosts supply the same buffer + // for multiple channels - this buggers up our method of copying the + // inputs over the outputs, so we need to create unique temp buffers in this case.. + for (int i = 0; i < numOut; ++i) + { + for (int j = i; --j >= 0;) + { + if (outputs[j] == outputs[i] && outputs[i] != 0) + { + tempChannels.set (i, juce_malloc (sizeof (float) * blockSize * 2)); + break; + } + } + } + } + { int i; for (i = 0; i < numOut; ++i) @@ -718,12 +739,6 @@ public: deleteTempChannels(); - // any inputs where the output channel is disabled will need our own internal dummy - // buffer, because we can't rely on the host to supply different buffers for each channel - for (int i = 0; i < JucePlugin_MaxNumOutputChannels; ++i) - if (! isOutputConnected2 (i)) - tempChannels.set (i, juce_malloc (sizeof (float) * blockSize * 2)); - filter->prepareToPlay (rate, blockSize); midiEvents.clear(); @@ -1338,6 +1353,7 @@ private: int diffW, diffH; float** channels; VoidArray tempChannels; // see note in processReplacing() + bool hasCreatedTempChannels; void deleteTempChannels() { @@ -1349,6 +1365,8 @@ private: if (filter != 0) tempChannels.insertMultiple (0, 0, filter->getNumInputChannels() + filter->getNumOutputChannels()); + + hasCreatedTempChannels = false; } void ensureOutgoingEventSize (int numEvents) @@ -1384,17 +1402,6 @@ private: return host; } - // this is a dupe of the method in AudioEffect, because some SDKs - // don't seem to include it.. - bool isOutputConnected2 (VstInt32 output) - { - VstInt32 ret = 0; - if (audioMaster) - ret = (VstInt32) audioMaster (&cEffect, audioMasterPinConnected, output, 1, 0, 0); - - return ret ? false : true; - } - #if JUCE_MAC WindowRef hostWindow; #elif JUCE_LINUX