Which indexes to use in AudioProcessorGraph::addConnection?

Discuss issues relating to audio plugins

Which indexes to use in AudioProcessorGraph::addConnection?

Postby Richard Shepherd » Fri Jun 01, 2012 5:24 pm

How do I use AudioProcessorGraph::addConnection?

I've successfully made a working graph of: midi-input -> VST-instrument -> audio-output

I now want to add an effect: midi-input -> VST-instrument -> effect -> audio-output

When I connect the instrument-node to the effect-node, which source and destination channel indexes should I use? I suppose that it depends on the plugins themselves and how many output and input channels they each have. But how do I find this out, and then get the channel-indexes for them?

I can see that the AudioProcessor class has getNumInputChannels() and getNumOutputChannels(). Should I use these? And if I do, how do I get the channel indexes for them? For example:
- The instrument has midi input and stereo output
- The effect has stereo input and stereo output

What are the indexes for the instrument's output? What are the indexes for the effect's inputs and outputs? Is it the case that addConnection is always connecting the source node's outputs to the destination node's inputs, and the indexes are just zero-based indexes up to the number of channels? So for stereo connections would it always be:
graph.addConnection(sourceID, 0, destinationID, 0)
graph.addConnection(sourceID, 1, destinationID, 1)

Sorry if this is a stupid question... but it's confusing me at the moment!

thanks,
Richard
User avatar
Richard Shepherd
JUCE Weenie
 
Posts: 8
Joined: Sun May 20, 2012 5:55 pm

Re: Which indexes to use in AudioProcessorGraph::addConnecti

Postby jrlanglois » Fri Jun 01, 2012 6:10 pm

If you're creating connections related to MIDI, the source and destination channels are to be juce::AudioProcessorGraph::midiChannelIndex - always.

For audio on the other hand, the "channel-indexes" associate as follows: 0 for Left channel, 1 for Right channel, and so on. How you want to go about connecting stuff together is up to you... You can certainly utilize juce::AudioProcessor::getNumInputChannels() and juce::AudioProcessor::getNumOutputChannels() if you wanted to.

When I connect the instrument-node to the effect-node, which source and destination channel indexes should I use?

You've multiple options, but you could use whatever the minimum number of channels there are between the nodes, and go from there. (ie: Connect src left channel to dest left channel, etc...) If you try to create a connection that isn't logical, such as where the channel index is beyond what either source and destination processor supports, the juce::AudioProcessorGraph::addConnection() method will just return false.
[Visual Studio 2012] [Xcode 4.6] [x64 Ubuntu 12.10 - NetBeans 7.3]
[latest JUCE tip] [My JUCE Fork] [FriendlyBinaryBuilder]
User avatar
jrlanglois
JUCE UberWeenie
 
Posts: 573
Joined: Fri Aug 12, 2011 5:54 pm
Location: Ottawa, Ontario, Canada

Re: Which indexes to use in AudioProcessorGraph::addConnecti

Postby Richard Shepherd » Mon Jun 04, 2012 10:15 am

Thank you... I've got my instrument and effect nicely connected up now!

The thing that I had been confused about was whether there were separate indexes for input and output channels. For example, I had wondered whether input-left=0, input-right=1, output-left=2, output-right=3 or something like that.

But addConnection is being more helpful than that, and is hooking up the zero-based outputs from the source to the zero-based inputs on the destination. I had thought that things were more confusing than they were.
User avatar
Richard Shepherd
JUCE Weenie
 
Posts: 8
Joined: Sun May 20, 2012 5:55 pm


Return to Audio Plugins

Who is online

Users browsing this forum: No registered users and 1 guest