Bug in AudioProcessorGraph


#1

Hi

I have found a minor issue in the AudioProcessorGraph. It can be reproduced in the Plug-In Host by making the following connections:

If you play a sound on channel 0 all output channels will be silent…
Tested with master: 81ff3a8

The issue seems to happen because the output node does not have any output channels, only inputs, which will cause faulty assumptions about how buffers can be reused.

See line 557 in juce_AudioProcessorGraph.cpp (createRenderingOpsForNode)

if (inputChan < numOuts)
    markBufferAsContaining (bufIndex, node.nodeId, inputChan);

Because numOuts is zero for the output node the buffer will not be marked which will cause the same buffer to be reused in the next call to getFreeBuffer.

I have made a fix that works but it might not be the cleanest…
It basically lies about the number of output channels if it is the output node:

createRenderingOpsForNode:

if (AudioProcessorGraph::AudioGraphIOProcessor* const ioProc
    = dynamic_cast<AudioProcessorGraph::AudioGraphIOProcessor*> (&processor))
    if (ioProc->isOutput())
        numOuts = processor.getNumInputChannels();

The test to set totalLatency also needs to be changed (was based on numOuts == 0 before). Test was a bit dangerous anyways because you could have a case where another node had zero outputs…

// Update total latency if this is the output node
if (AudioProcessorGraph::AudioGraphIOProcessor* const ioProc
    = dynamic_cast<AudioProcessorGraph::AudioGraphIOProcessor*> (&processor))
        if (ioProc->isOutput())
            totalLatency = maxLatency;

There is probably a nicer way to fix this but I don’t feel that I understand the code enough to find it…


#2

Hi there,
it’s similar to another bug I found a while ago:


#3

Any thoughts on this?