1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

AudioProcessorGraph: Fix MIDI channel bug and graph execution modification

MIDI only plugins are no longer provided valid audio buffers
Graph nodes are only executed when they have active connections
This commit is contained in:
Oli 2022-03-22 11:52:47 +00:00
parent 15bdae16b2
commit b918fd3159
3 changed files with 21 additions and 2 deletions

View file

@ -79,7 +79,7 @@ public:
void processBlock (AudioBuffer<float>& buffer, MidiBuffer& midi) override
{
// the audio buffer in a midi effect will have zero channels!
// A pure MIDI plugin shouldn't be provided any audio data
jassert (buffer.getNumChannels() == 0);
// however we use the buffer to get timing information

View file

@ -268,7 +268,16 @@ private:
for (int i = 0; i < totalChans; ++i)
audioChannels[i] = c.audioBuffers[audioChannelsToUse.getUnchecked (i)];
AudioBuffer<FloatType> buffer (audioChannels, totalChans, c.numSamples);
auto numAudioChannels = [this]
{
if (const auto* proc = node->getProcessor())
if (proc->getTotalNumInputChannels() == 0 && proc->getTotalNumOutputChannels() == 0)
return 0;
return totalChans;
}();
AudioBuffer<FloatType> buffer (audioChannels, numAudioChannels, c.numSamples);
const ScopedLock lock (processor.getCallbackLock());

View file

@ -155,17 +155,27 @@ public:
void prepare (double newSampleRate, int newBlockSize, AudioProcessorGraph*, ProcessingPrecision);
void unprepare();
bool hasNoConnections() const noexcept { return inputs.isEmpty() && outputs.isEmpty(); }
template <typename Sample>
void processBlock (AudioBuffer<Sample>& audio, MidiBuffer& midi)
{
if (hasNoConnections())
return;
const ScopedLock lock (processorLock);
processor->processBlock (audio, midi);
}
template <typename Sample>
void processBlockBypassed (AudioBuffer<Sample>& audio, MidiBuffer& midi)
{
if (hasNoConnections())
return;
const ScopedLock lock (processorLock);
processor->processBlockBypassed (audio, midi);
}