# Dynamic Multibus Plugins

**URL:** <https://forum.juce.com/t/dynamic-multibus-plugins/20313>\
**Category:** General JUCE discussion\
**Created:** [December 19, 2016, 5:36pm UTC](https://forum.juce.com/t/dynamic-multibus-plugins/20313 "2016-12-19T17:36:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![harryg](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/harryg/32/7_2.png) [@harryg](https://forum.juce.com/u/harryg)\
**Post date:** [December 19, 2016, 5:36pm UTC](https://forum.juce.com/t/dynamic-multibus-plugins/20313/1 "2016-12-19T17:36:10Z")

</div>

Hi @fabian,

I am working on a plugin with dynamic buses and Multibus API with named buses.  
I really like the new Multibus API.  
But it seems to me that changing the number of buses during runtime is not possible with bus names.

I can change the bus layout with

- `AudioProcessor::setBusesLayout`, which applies my new `BusesLayout`, but without bus names, as it includes only `AudioChannelSet`s
- `AudioProcessor::addBus`, which also does not include bus names (`removeBus` of course is fine)

So it seems to me that bus names can only be included in the constructor - the only place where I can include `BusesProperties` - but not during runtime…

To solve it, I’d like to propose two changes:

- add a new method `AudioProcessor::setBusesProperties` similar to `setBusesLayout` (and internally similar to `initialise`, just that buses need to be cleared before)
- make `AudioProcessor::createBus` public - tried that and it works fine for me

What do you think? Or am I mislead?

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [December 19, 2016, 8:21pm UTC](https://forum.juce.com/t/dynamic-multibus-plugins/20313/2 "2016-12-19T20:21:20Z")

</div>

> [@harryg](#):
>
> But it seems to me that changing the number of buses during runtime is not possible with bus names.

Yes it is, but it’s a passive: the host gives your plugin a callback and asks for the name of a newly created bus. See the [canApplyBusCountChange](https://www.juce.com/doc/classAudioProcessor#a4dd0f8e893a9c295cd2b5eea2d92a6c5) callback. You’ll need to supply the bus name via the third parameter.

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [December 19, 2016, 8:27pm UTC](https://forum.juce.com/t/dynamic-multibus-plugins/20313/3 "2016-12-19T20:27:08Z")

</div>

I’ve recently posted an example on how to use this method to wrap another plug-in: [4.3.0 Some AU plugins have wrong I/O Count](https://forum.juce.com/t/4-3-0-some-au-plugins-have-wrong-i-o-count/20036/4?u=fabian)

---

<div class="post-metadata">

**Author:** ![harryg](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/harryg/32/7_2.png) [@harryg](https://forum.juce.com/u/harryg)\
**Post date:** [December 22, 2016, 10:11pm UTC](https://forum.juce.com/t/dynamic-multibus-plugins/20313/4 "2016-12-22T22:11:56Z")

</div>

Hi Fabian,

thanks for these hints and for the quick reply!  
Unfortunately priorities have changed and I could not try it out yet.  
Will let you know once I tried, but probably after christmas time…

Wish you some nice and peaceful days!

Harald

---

<div class="post-metadata">

**Author:** ![harryg](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/harryg/32/7_2.png) [@harryg](https://forum.juce.com/u/harryg)\
**Post date:** [January 9, 2017, 9:11pm UTC](https://forum.juce.com/t/dynamic-multibus-plugins/20313/5 "2017-01-09T21:11:12Z")

</div>

Hi @fabian,

thanks again for your hints.  
I had the same conceptual problem trying to sync back to the host as @Nikolai in the other thread, where you clarified that “the plug-in is mostly at the mercy of the host when it comes to bus layouts”.  
So I entirely reworked my stuff to “mercy of the host” and it works fine so far!

But: I still have an issue with the Bus names.  
What I wanted is e.g. multiple playback buses and one recording bus.  
(in fact I am working on a multi file player and recorder for the JUCE plugin host, which I could contribute to the project later, as discussed [here](https://forum.juce.com/t/add-audio-file-player-node-for-plugin-host-example/17125/11)).

One filter node is the recorder and one is the player (playing n files + playback of the recorder file).  
So in the player I always wanted to give the last bus a name like “Rec…” if there is a recorder node.  
So something like “Play1”, “Play2”, “Play3”, "Rec"  
But the `canApplyBusCountChange` callback only gives me the last added bus.  
If a bus is added, I cannot rename the second last, which is “Rec”.  
So I would get something like “Play1”, “Play2”, “Play3”, “Rec”, “Play4”.

Removing the last bus to rename it seems not possible within `canApplyBusCountChange` as it would lead to a recursion.  
As the Rec bus also can be removed (by removing that filter node), it is also not a solution to put it at the first place.  
For now, I just enumerate all output buses… not too nice, but everything works so far.

Any idea on how to rename existing buses (within `canApplyBusCountChange`) or how to “insert” a new bus before the last one - or any other idea?  
Thanks for any hint… maybe this could be of interest for other use cases also.

---

<div class="post-metadata">

**Author:** ![fr810](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/fr810/32/841_2.png) [@fr810](https://forum.juce.com/u/fr810)\
**Post date:** [January 12, 2017, 10:35am UTC](https://forum.juce.com/t/dynamic-multibus-plugins/20313/6 "2017-01-12T10:35:15Z")

</div>

Hmmm… I don’t think this is possible. I’ve modelled the multi-bus API closely around what plug-in formats support and what the majority of hosts allow you to do. The problem is that Cubase/Logic etc. do not probe bus names again when a bus is added or removed (apart from the bus being added).

Therefore, I could add this functionality to the API but hardly any DAWs would reflect this. I think this is just a limitation of DAWs at the moment.

I’ve been thinking about how to add playback+recording filter nodes to the ‘audio plugin host’. It’s probably easiest of you can only create the node when selecting the file you want to play or select the destination and format of the recording. This way, you know the format of the playback/recording nodes before you create them. This simplifies the implementations of these nodes.

---

<div class="post-metadata">

**Author:** ![harryg](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/harryg/32/7_2.png) [@harryg](https://forum.juce.com/u/harryg)\
**Post date:** [January 12, 2017, 11:17am UTC](https://forum.juce.com/t/dynamic-multibus-plugins/20313/7 "2017-01-12T11:17:45Z")

</div>

Thanks, that makes sense.  
In my case, as it is only used within the JUCE plugin host, I could use a non-DAW-compliant solution.  
Still it is of no interest to anyone else, so it might not make sense to invest any effort.

I did my solution with two nodes, one playback and one recording.  
Only the playback has a UI and controls the recorder, which is a kind of slave node, connected with a `SharedResourcePointer`.

It already worked fine and I just reworked it for multibus now.  
Will offer you the code for contribution soon. Some doc and cleanup is still needed.

---

<div class="post-metadata">

**Author:** ![harryg](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/harryg/32/7_2.png) [@harryg](https://forum.juce.com/u/harryg)\
**Post date:** [January 26, 2017, 3:27pm UTC](https://forum.juce.com/t/dynamic-multibus-plugins/20313/8 "2017-01-26T15:27:32Z")

</div>

Hi, I finally published a first version of the audio plugin host extended with a multi file audio player and a recorder.  
See new thread: [https://forum.juce.com/t/audio-plugin-host-with-multi-file-audio-player-and-recorder](https://forum.juce.com/t/audio-plugin-host-with-multi-file-audio-player-and-recorder)
