Having trouble with AudioProcessorGraph


#1

Hey all, I feel like i’m missing something really obvious, but i’m playing around with playing back an AudioProcessorGraph via an AudioProcessorPlayer, but I’m having trouble getting it to work.

To the input processor seems to receiving input from the device callback correctly, but the output processor is getting all 0s in its call to processAudio().
The code snippet below is what i’m working with:

#include "../JuceLibraryCode/JuceHeader.h"

int main (int argc, char* argv[])
{
  AudioDeviceManager deviceManager;

  int numInputChannels = 2;
  int numOutputChannels = 2;

  deviceManager.initialise(numInputChannels, numOutputChannels, 0, true);

  AudioProcessorPlayer player;
  AudioProcessorGraph graph;

  AudioProcessorGraph::AudioGraphIOProcessor inputProc(AudioProcessorGraph::AudioGraphIOProcessor::audioInputNode);
  AudioProcessorGraph::AudioGraphIOProcessor outputProc(AudioProcessorGraph::AudioGraphIOProcessor::audioOutputNode);

  const AudioProcessorGraph::Node* inputNode = graph.addNode(&inputProc);
  const AudioProcessorGraph::Node* outputNode = graph.addNode(&outputProc);

  graph.addConnection(inputNode->nodeId, 0, outputNode->nodeId, 0);
  graph.addConnection(inputNode->nodeId, 1, outputNode->nodeId, 1);

  player.setProcessor(&graph);
  deviceManager.addAudioCallback(&player);

  while (true) {}
  return 0;
}

#2

a) Don’t use raw pointers for a reference counted object

b) See my post in this thread

c) Are you using the AudioAppComponent class ?

Rail


#3

Hey thanks for the reply. I replaced the raw pointers with
AudioProcessorGraph::Node::Ptr’s as per your feedback, but still no dice.

I am not using the AudioAppComponent class. The only source file in the
project is what I posted. I’m just just doing a console app for now,
trying to figure out the bare minimum amount of code required to get a
graph playing back as a device callback


#4

Looked into this a bit further. It looks like the the problem is that the calls to graph.addConnection fail because of this check in AudioProcessorGraph::canConnect:

    if (source == nullptr
         || (sourceChannelIndex != midiChannelIndex && sourceChannelIndex >= source->processor->getTotalNumOutputChannels())
         || (sourceChannelIndex == midiChannelIndex && ! source->processor->producesMidi()))
        return false;

and this fails because source->processor->getNumChannels() is returning 0. I’m having a hard time figuring out what I need to do to create AudioGraphIOProcessors with the correct # of output channels. I’d really appreciate a nudge in the right direction.

Thanks!


#5

Same here. Did you figure it out?


#6

If you are simply connecting the input and output nodes then you might be opening an audio device that you are not expecting. Maybe an audio device with zero input channels.