AudioProcessorGraph help

hi, I’d like to understand ho to make AudioProcessorGraph to work… Actually I can’t hear any sound…

this is my constructor:

    AudioProcessorGraph::Node::Ptr inputNodePtr = graph.addNode(std::move(input));
    AudioProcessorGraph::Node::Ptr processor1Ptr = graph.addNode(std::move(processor1));
    AudioProcessorGraph::Node::Ptr outputNodePtr = graph.addNode(std::move(output));

    graph.addConnection({ { inputNodePtr->nodeID, 0 }, { processor1Ptr->nodeID, 0 } });
    graph.addConnection({ { inputNodePtr->nodeID, 1 }, { processor1Ptr->nodeID, 1 } });
    
    graph.addConnection({ { processor1Ptr->nodeID, 0 }, { outputNodePtr->nodeID, 0 } });
    graph.addConnection({ { processor1Ptr->nodeID, 1 }, { outputNodePtr->nodeID, 1 } });

this is my prepareToPlay

    graph.setPlayConfigDetails(getMainBusNumInputChannels(), getMainBusNumOutputChannels(), sampleRate, samplesPerBlock);
    graph.setProcessingPrecision(getProcessingPrecision());
    graph.prepareToPlay(sampleRate, samplesPerBlock);

and this my processBlock

    juce::ScopedNoDenormals noDenormals;
    auto totalNumInputChannels  = getTotalNumInputChannels();
    auto totalNumOutputChannels = getTotalNumOutputChannels();

    for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
        buffer.clear (i, 0, buffer.getNumSamples());

    graph.processBlock(buffer, midiMessages);

I read about the AudioProcessorPlayer, but I’m in a plugin… Is that needed Anyway??

Ok, just fixed coping what’s inside the constructor in prepareToPlay… I don’t understand the motivation… maybe someone could explain me…

I haven’t tested this out, but I suspect that the input + output nodes don’t have any channels until you call setPlayConfigDetails on the graph, or set the bus layout in some other way.

2 Likes

M… It makes sense, but the graph don’t store something like “preferred connections” to arise them when needed? Like this in bigger project it seems a bit difficult to manage…