Browse Source

VST3 Wrapper: Fixed an issue where JUCE would overwrite audio data into an input buffer provided by VST3 hosts

tags/2021-05-28
hogliux 8 years ago
parent
commit
b449c346ad
1 changed files with 39 additions and 55 deletions
  1. +39
    -55
      modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp

+ 39
- 55
modules/juce_audio_plugin_client/VST3/juce_VST3_Wrapper.cpp View File

@@ -2009,7 +2009,7 @@ private:
template <typename FloatType>
void processAudio (Vst::ProcessData& data, Array<FloatType*>& channelList)
{
int totalInputChans = 0;
int totalInputChans = 0, totalOutputChans = 0;
bool tmpBufferNeedsClearing = false;
const int plugInInputChannels = pluginInstance->getTotalNumInputChannels();
@@ -2029,31 +2029,40 @@ private:
break;
{
const int n = jmax (vstInputs, getNumAudioBuses (true));
const int n = jmax (vstOutputs, getNumAudioBuses (false));
for (int bus = 0; bus < n && totalInputChans < plugInInputChannels; ++bus)
for (int bus = 0; bus < n && totalOutputChans < plugInOutputChannels; ++bus)
{
if (bus < vstInputs)
if (bus < vstOutputs)
{
if (FloatType** const busChannels = getPointerForAudioBus<FloatType> (data.inputs[bus]))
if (FloatType** const busChannels = getPointerForAudioBus<FloatType> (data.outputs[bus]))
{
const int numChans = jmin ((int) data.inputs[bus].numChannels, plugInInputChannels - totalInputChans);
const int numChans = jmin ((int) data.outputs[bus].numChannels, plugInOutputChannels - totalOutputChans);
for (int i = 0; i < numChans; ++i)
if (busChannels[i] != nullptr)
channelList.set (totalInputChans++, busChannels[i]);
{
auto dst = busChannels[i];
if (dst != nullptr)
{
if (totalOutputChans >= plugInInputChannels)
FloatVectorOperations::clear (dst, (int) data.numSamples);
channelList.set (totalOutputChans++, busChannels[i]);
}
}
}
}
else
{
const int numChans = jmin (pluginInstance->getChannelCountOfBus (true, bus), plugInInputChannels - totalInputChans);
const int numChans = jmin (pluginInstance->getChannelCountOfBus (false, bus), plugInOutputChannels - totalOutputChans);
for (int i = 0; i < numChans; ++i)
{
if (FloatType* tmpBuffer = getTmpBufferForChannel<FloatType> (totalInputChans, data.numSamples))
if (FloatType* tmpBuffer = getTmpBufferForChannel<FloatType> (totalOutputChans, data.numSamples))\
{
tmpBufferNeedsClearing = true;
channelList.set (totalInputChans++, tmpBuffer);
channelList.set (totalOutputChans++, tmpBuffer);
}
else
return;
@@ -2062,49 +2071,47 @@ private:
}
}
int totalOutputChans = 0;
{
const int n = jmax (vstOutputs, getNumAudioBuses (false));
const int n = jmax (vstInputs, getNumAudioBuses (true));
for (int bus = 0; bus < n && totalOutputChans < plugInOutputChannels; ++bus)
for (int bus = 0; bus < n && totalInputChans < plugInInputChannels; ++bus)
{
if (bus < vstOutputs)
if (bus < vstInputs)
{
if (FloatType** const busChannels = getPointerForAudioBus<FloatType> (data.outputs[bus]))
if (FloatType** const busChannels = getPointerForAudioBus<FloatType> (data.inputs[bus]))
{
const int numChans = jmin ((int) data.outputs[bus].numChannels, plugInOutputChannels - totalOutputChans);
const int numChans = jmin ((int) data.inputs[bus].numChannels, plugInInputChannels - totalInputChans);
for (int i = 0; i < numChans; ++i)
{
if (busChannels[i] != nullptr)
{
if (totalOutputChans >= totalInputChans)
if (totalInputChans >= totalOutputChans)
channelList.set (totalInputChans, busChannels[i]);
else
{
FloatVectorOperations::clear (busChannels[i], data.numSamples);
channelList.set (totalOutputChans, busChannels[i]);
}
auto* dst = channelList.getReference (totalInputChans);
auto* src = busChannels[i];
++totalOutputChans;
if (dst != src)
FloatVectorOperations::copy (dst, src, (int) data.numSamples);
}
}
++totalInputChans;
}
}
}
else
{
const int numChans = jmin (pluginInstance->getChannelCountOfBus (false, bus), plugInOutputChannels - totalOutputChans);
const int numChans = jmin (pluginInstance->getChannelCountOfBus (true, bus), plugInInputChannels - totalInputChans);
for (int i = 0; i < numChans; ++i)
{
if (FloatType* tmpBuffer = getTmpBufferForChannel<FloatType> (totalOutputChans, data.numSamples))
if (FloatType* tmpBuffer = getTmpBufferForChannel<FloatType> (totalInputChans, data.numSamples))
{
if (totalOutputChans >= totalInputChans)
{
tmpBufferNeedsClearing = true;
channelList.set (totalOutputChans, tmpBuffer);
}
++totalOutputChans;
tmpBufferNeedsClearing = true;
channelList.set (totalInputChans++, tmpBuffer);
}
else
return;
@@ -2167,29 +2174,6 @@ private:
jassert (midiBuffer.getNumEvents() <= numMidiEventsComingIn);
#endif
}
if (data.outputs != nullptr)
{
int outChanIndex = 0;
for (int bus = 0; bus < data.numOutputs; ++bus)
{
if (FloatType** const busChannels = getPointerForAudioBus<FloatType> (data.outputs[bus]))
{
const int numChans = (int) data.outputs[bus].numChannels;
for (int i = 0; i < numChans; ++i)
{
if (outChanIndex < totalInputChans && busChannels[i] != nullptr)
FloatVectorOperations::copy (busChannels[i], buffer.getReadPointer (outChanIndex), (int) data.numSamples);
else if (outChanIndex >= totalOutputChans && busChannels[i] != nullptr)
FloatVectorOperations::clear (busChannels[i], (int) data.numSamples);
++outChanIndex;
}
}
}
}
}
//==============================================================================


Loading…
Cancel
Save