# AudioGraphIOProcessor with the new bus system

**URL:** <https://forum.juce.com/t/audiographioprocessor-with-the-new-bus-system/17084>\
**Category:** Audio Plugins\
**Created:** [April 4, 2016, 10:23am UTC](https://forum.juce.com/t/audiographioprocessor-with-the-new-bus-system/17084 "2016-04-04T10:23:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![siedschl](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@siedschl](https://forum.juce.com/u/siedschl)\
**Post date:** [April 4, 2016, 10:23am UTC](https://forum.juce.com/t/audiographioprocessor-with-the-new-bus-system/17084/1 "2016-04-04T10:23:31Z")

</div>

When writing a synth plugin that consists of a series of submodules chained together in an AudioProcessorGraph, with an AudioGraphIOProcessor::audioInputNode at the beginning and an AudioGraphIOProcessor::audioOutputNode, I'm running into the issue that those in- and output nodes fall back to the AudioProcessor constructor for setting up their bus arrangements. If I look at the AudioProcessor constructor:

```
#ifdef JucePlugin_PreferredChannelConfigurations
    const short channelConfigs[][2] = { JucePlugin_PreferredChannelConfigurations };
   #else
    const short channelConfigs[][2] = { {2, 2} };
   #endif

 #if ! JucePlugin_IsMidiEffect
   #if ! JucePlugin_IsSynth
    busArrangement.inputBuses.add (AudioProcessorBus ("Input", AudioChannelSet::canonicalChannelSet (channelConfigs[0][0])));
   #endif
    busArrangement.outputBuses.add (AudioProcessorBus ("Output", AudioChannelSet::canonicalChannelSet (channelConfigs[0][1])));

  #ifdef JucePlugin_PreferredChannelConfigurations
   #if ! JucePlugin_IsSynth
    AudioProcessor::setPreferredBusArrangement (true, 0, AudioChannelSet::stereo());
   #endif
    AudioProcessor::setPreferredBusArrangement (false, 0, AudioChannelSet::stereo());
  #endif
 #endif
    updateSpeakerFormatStrings();
```

all the defines will come from the "parent" audio processor plugin, so if that is a synth, for instance, there will be no input bus for the AudioGraphIOProcessor::audioOutput module (although it would need one, obviously). It seems to me that those modules should now take care for their own bus setup in their constructors?

---

<div class="post-metadata">

**Author:** ![railjonrogut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/railjonrogut/32/505_2.png) [@railjonrogut](https://forum.juce.com/u/railjonrogut)\
**Post date:** [April 4, 2016, 10:37am UTC](https://forum.juce.com/t/audiographioprocessor-with-the-new-bus-system/17084/2 "2016-04-04T10:37:32Z")

</div>

I’ve reported issues with the AudioProcessorGraph in the ultimate MultiBus thread. You may want to check that out.

Rail

---

<div class="post-metadata">

**Author:** ![siedschl](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@siedschl](https://forum.juce.com/u/siedschl)\
**Post date:** [April 4, 2016, 12:11pm UTC](https://forum.juce.com/t/audiographioprocessor-with-the-new-bus-system/17084/3 "2016-04-04T12:11:51Z")

</div>

Not sure which thread you mean exactly... I haven't seen this specific issue discussed yet, although I could have overlooked something of course.

---

<div class="post-metadata">

**Author:** ![kunitoki](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kunitoki/32/15_2.png) [@kunitoki](https://forum.juce.com/u/kunitoki)\
**Post date:** [April 4, 2016, 2:47pm UTC](https://forum.juce.com/t/audiographioprocessor-with-the-new-bus-system/17084/4 "2016-04-04T14:47:33Z")

</div>

this is bullshit... why in 2016 do we go back to the stone age with this nonsensical macro fluff&nbsp;inside a basic audio foundation class&nbsp;? this smells badly sorry

---

<div class="post-metadata">

**Author:** ![railjonrogut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/railjonrogut/32/505_2.png) [@railjonrogut](https://forum.juce.com/u/railjonrogut)\
**Post date:** [April 5, 2016, 7:26am UTC](https://forum.juce.com/t/audiographioprocessor-with-the-new-bus-system/17084/5 "2016-04-05T07:26:53Z")

</div>

[https://forum.juce.com/t/the-ultimate-juce-4-1-multibus-guide](https://forum.juce.com/t/the-ultimate-juce-4-1-multibus-guide)

See post #19

(Edit: [(DEPRECATED) The ultimate JUCE 4.1 MultiBus Guide](http://forum.juce.com/t/the-ultimate-juce-4-1-multibus-guide/16755/18))

Rail

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [April 5, 2016, 8:22am UTC](https://forum.juce.com/t/audiographioprocessor-with-the-new-bus-system/17084/6 "2016-04-05T08:22:15Z")

</div>

The "macro fluff" is just our internal hacks&nbsp;for backwards-compatibility with people's existing code. If you're writing a new plugin there's no reason to use any macros.

---

<div class="post-metadata">

**Author:** ![siedschl](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@siedschl](https://forum.juce.com/u/siedschl)\
**Post date:** [April 5, 2016, 8:32am UTC](https://forum.juce.com/t/audiographioprocessor-with-the-new-bus-system/17084/7 "2016-04-05T08:32:00Z")

</div>

True for the channel configurations, but I'm not using them anymore. The JucePlugin\_IsMidiEffect and JucePlugin\_IsSynth macros are what can potentially cause trouble for audio processors consisting of several sub-audio processors (if one doesn't take care of the buses for those sub-processors in their constructors, which is what I'm suggesting for the IO processors).  
&nbsp;

---

<div class="post-metadata">

**Author:** ![siedschl](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@siedschl](https://forum.juce.com/u/siedschl)\
**Post date:** [April 5, 2016, 8:32am UTC](https://forum.juce.com/t/audiographioprocessor-with-the-new-bus-system/17084/8 "2016-04-05T08:32:00Z")

</div>

\* double post \*

---

<div class="post-metadata">

**Author:** ![siedschl](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@siedschl](https://forum.juce.com/u/siedschl)\
**Post date:** [April 26, 2016, 9:57am UTC](https://forum.juce.com/t/audiographioprocessor-with-the-new-bus-system/17084/9 "2016-04-26T09:57:07Z")

</div>

So this is still an issue in 4.2.1. For now, I’ve added these lines to the constructor of the AudioGraphIOProcessor:

```
AudioProcessorGraph::AudioGraphIOProcessor::AudioGraphIOProcessor (const IODeviceType deviceType)
    : type (deviceType), graph (nullptr)
{
    int numIns = busArrangement.getTotalNumInputChannels();
    int numOuts = busArrangement.getTotalNumOutputChannels();
    busArrangement.inputBuses.clear();
    busArrangement.outputBuses.clear();
    if (type == audioOutputNode)
        busArrangement.inputBuses.add (AudioProcessorBus ("Input", AudioChannelSet::canonicalChannelSet(numOuts) ));
    if (type == audioInputNode)
        busArrangement.outputBuses.add (AudioProcessorBus ("Output", AudioChannelSet::canonicalChannelSet(numIns) ));
}
```
