# Hosting Plugins

**URL:** <https://forum.juce.com/t/hosting-plugins/44560>\
**Category:** General JUCE discussion\
**Created:** [February 20, 2021, 7:17pm UTC](https://forum.juce.com/t/hosting-plugins/44560 "2021-02-20T19:17:54Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![eyal23](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eyal23/32/9496_2.png) [@eyal23](https://forum.juce.com/u/eyal23)\
**Post date:** [February 20, 2021, 7:17pm UTC](https://forum.juce.com/t/hosting-plugins/44560/1 "2021-02-20T19:17:55Z")

</div>

I’m trying to host plugins on my daw so that users will be able to add them to tracks and edit them on a separate window.  
after some research on the forum, docs, and the PluginHost provided by JUCE, I understood that it’s something to do with the AudioProcessor, and the AudioProcessorEditor. but I’m not really sure how to use them.  
so a point in the right direction would be really appreciated.

EDIT: I know what’s the purpose of AudioProcessor, but don’t know how to use it for plugin hosting.

---

<div class="post-metadata">

**Author:** ![rMidi](https://avatars.discourse-cdn.com/v4/letter/r/ee59a6/32.png) [@rMidi](https://forum.juce.com/u/rMidi)\
**Post date:** [February 20, 2021, 8:12pm UTC](https://forum.juce.com/t/hosting-plugins/44560/2 "2021-02-20T20:12:58Z")

</div>

Are you writing a DAW type of thing? Not a plug in?

---

<div class="post-metadata">

**Author:** ![eyal23](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eyal23/32/9496_2.png) [@eyal23](https://forum.juce.com/u/eyal23)\
**Post date:** [February 20, 2021, 8:34pm UTC](https://forum.juce.com/t/hosting-plugins/44560/3 "2021-02-20T20:34:35Z")

</div>

yep, a daw

---

<div class="post-metadata">

**Author:** ![rMidi](https://avatars.discourse-cdn.com/v4/letter/r/ee59a6/32.png) [@rMidi](https://forum.juce.com/u/rMidi)\
**Post date:** [February 20, 2021, 8:43pm UTC](https://forum.juce.com/t/hosting-plugins/44560/4 "2021-02-20T20:43:04Z")

</div>

Operating system?  
IDE?

---

<div class="post-metadata">

**Author:** ![eyal23](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eyal23/32/9496_2.png) [@eyal23](https://forum.juce.com/u/eyal23)\
**Post date:** [February 20, 2021, 8:46pm UTC](https://forum.juce.com/t/hosting-plugins/44560/5 "2021-02-20T20:46:00Z")

</div>

I’m not entirely sure what you mean.  
The Daw is aimed towards windows.  
the IDE that I’m using is vs (not sure why it’s important though…).

EDIT: by the way I only intend on supporting vst3 formated plugins.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [February 20, 2021, 8:54pm UTC](https://forum.juce.com/t/hosting-plugins/44560/6 "2021-02-20T20:54:22Z")

</div>

First have a look at [PluginDirectoryScanner](https://docs.juce.com/develop/classPluginDirectoryScanner.html) to find installed plugins.

Then [AudioPluginFormat](https://docs.juce.com/develop/classAudioPluginFormat.html) is used to create an instance of a plugin using [createPluginFromDescription()](https://docs.juce.com/develop/classAudioPluginFormat.html#a3c91c3bc0001ffabda2e050e7d9c53b1)

With those pointers I would look again into the AudioPluginHost as reference.

The returned [AudioPluginInstance](https://docs.juce.com/develop/classAudioPluginInstance.html) is an AudioProcessor but you don’t see the juce code. It is an AudioProcessor seen through the plugin API like VST3 or AU or AAX.

Good luck

---

<div class="post-metadata">

**Author:** ![rMidi](https://avatars.discourse-cdn.com/v4/letter/r/ee59a6/32.png) [@rMidi](https://forum.juce.com/u/rMidi)\
**Post date:** [February 20, 2021, 8:55pm UTC](https://forum.juce.com/t/hosting-plugins/44560/7 "2021-02-20T20:55:49Z")

</div>

I am assuming Windows 10 x64.  
The IDE matters due to nuances with debugging code.

Do you have any of your DAW written?  
Are you asking how to load a plug in? (Specifically a VST3).

---

<div class="post-metadata">

**Author:** ![eyal23](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eyal23/32/9496_2.png) [@eyal23](https://forum.juce.com/u/eyal23)\
**Post date:** [February 20, 2021, 8:56pm UTC](https://forum.juce.com/t/hosting-plugins/44560/8 "2021-02-20T20:56:24Z")

</div>

I’ve already completed the scanning for plugins part with the help of the PluginDirectoryScanner. I just need to figure out the “hosting” part.

---

<div class="post-metadata">

**Author:** ![eyal23](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eyal23/32/9496_2.png) [@eyal23](https://forum.juce.com/u/eyal23)\
**Post date:** [February 20, 2021, 8:58pm UTC](https://forum.juce.com/t/hosting-plugins/44560/9 "2021-02-20T20:58:18Z")

</div>

yeah, have been working on it for the last 4 months

 ![Screenshot (3)](https://us1.discourse-cdn.com/flex026/uploads/juce/original/2X/4/4c428212f474f5740154ffe04c00a058354f661b.png)

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [February 20, 2021, 8:58pm UTC](https://forum.juce.com/t/hosting-plugins/44560/10 "2021-02-20T20:58:52Z")

</div>

You use the PluginDescription that your scanning returned to create an instance of the plugin.  
Then you need to prepare the AudioProcessor by calling prepareToPlay() and then you can process the audio using the processBlock() method.

Can you be more specific where your problem is?

---

<div class="post-metadata">

**Author:** ![rMidi](https://avatars.discourse-cdn.com/v4/letter/r/ee59a6/32.png) [@rMidi](https://forum.juce.com/u/rMidi)\
**Post date:** [February 20, 2021, 9:00pm UTC](https://forum.juce.com/t/hosting-plugins/44560/11 "2021-02-20T21:00:21Z")

</div>

I’ll let Danial take over!

---

<div class="post-metadata">

**Author:** ![eyal23](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eyal23/32/9496_2.png) [@eyal23](https://forum.juce.com/u/eyal23)\
**Post date:** [February 20, 2021, 9:07pm UTC](https://forum.juce.com/t/hosting-plugins/44560/12 "2021-02-20T21:07:49Z")

</div>

I think I have 2 problems/questions:

1. Is the “instance of the plugin” the AudioPluginInstance class? and if so, can I connect it to an AudioProcessorGraph so the plugins would be chained one after the other?

2. How can I get the AudioProcessorEditor of the plugin?

sorry if I’m not really understandable, I’m not a native English speaker…

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [February 20, 2021, 9:24pm UTC](https://forum.juce.com/t/hosting-plugins/44560/13 "2021-02-20T21:24:09Z")

</div>

No problem at all, you came quite clearly 🙂

1. The plugin is stateful, so everywhere you want to use that plugin, you need an instance.

You can use the AudioProcessorGraph. I would only do that if you want that type of host like the AudioPluginHost, where you connect the different plugins in random orders.

If you want a Cubase style chain of plugins, I would simply use a  
`std::vector<std::unique_ptr<juce::AudioPluginInstance>>`

When you playback I guess you use some AudioSources at the moment. What you need to do is to get an `AudioBuffer<float>` with the audio data and a MidiBuffer (you can use an empty one to begin with, until you get to use instruments). Now you can sequentially call processBlock on all instances:

```auto
// in getNextAudioBlock()
auto proxy = juce::AudioBuffer<float>(info.buffer->getArrayOfWritePointers(), info.buffer->getNumChannels(), info.startSample, info.numSamples);
juce::MidiBuffer midi;

// todo: set current autimation values (optional)

// todo set position on juce::AudioPlayhead (optional)

for (auto& plugin : plugins)
    plugin->processBlock (proxy, midi);

```

1. If you need an editor, you create a window (Component and addToDesktop() and setVisible (true)) and give it the child the AudioProcessorEditor by calling  
plugin-\>createEditor();  
Remember, AudioPluginInstance inherits AudioProcessor, so the createEditor is available. Only methods from your specific AudioProcessors are not available.

Hope that helps

---

<div class="post-metadata">

**Author:** ![eyal23](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eyal23/32/9496_2.png) [@eyal23](https://forum.juce.com/u/eyal23)\
**Post date:** [February 20, 2021, 9:32pm UTC](https://forum.juce.com/t/hosting-plugins/44560/14 "2021-02-20T21:32:48Z")

</div>

I couldn’t ask for a better explanation than this.  
I update on how it goes 👌

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [February 20, 2021, 9:38pm UTC](https://forum.juce.com/t/hosting-plugins/44560/15 "2021-02-20T21:38:17Z")

</div>

Great. Btw. I forgot, we didn’t talk about channel counts and such stuff. In my host I fixed all for now to stereo, but you should actually probe isChannelLayoutSupported() with the setup you want to set, and finally call [setBusesLayout()](https://docs.juce.com/develop/classAudioProcessor.html#acd92c2d343de66816b290015cd15517f).

---

<div class="post-metadata">

**Author:** ![eyal23](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eyal23/32/9496_2.png) [@eyal23](https://forum.juce.com/u/eyal23)\
**Post date:** [February 21, 2021, 1:17pm UTC](https://forum.juce.com/t/hosting-plugins/44560/16 "2021-02-21T13:17:09Z")

</div>

I’m most likely going to fix it to stereo too.  
another question. Does the plugin’s parameters state is saved automatically? or do I need to manage it via XML or something?

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [February 21, 2021, 1:25pm UTC](https://forum.juce.com/t/hosting-plugins/44560/17 "2021-02-21T13:25:30Z")

</div>

You need to save it yourself by calling getStateInformation() on the plugin instance. You get a binary blob returned in a juce::MemoryBlock, that you can embed into your project.  
If your project is in XML or a juce::ValueTree, most people would use base64 encoding.  
Base64 has some overhead but can easily be converted back and forth.

And when loading a session you set that binary blob back using setStateInformation.

---

<div class="post-metadata">

**Author:** ![rMidi](https://avatars.discourse-cdn.com/v4/letter/r/ee59a6/32.png) [@rMidi](https://forum.juce.com/u/rMidi)\
**Post date:** [February 21, 2021, 5:08pm UTC](https://forum.juce.com/t/hosting-plugins/44560/18 "2021-02-21T17:08:45Z")

</div>

eyal23, Daniel.  
When you get around to actually enabling all of the buses from a plugin within your DAW please take a look at [this post](https://forum.juce.com/t/cannot-get-output-sound-from-plugin-other-than-bus-0/44559)

I poke at my issue every once in a while but then get so frustrated I go back to coding other things. I am sure it is something simple I am missing.

Yes, most plugins only expose a single stereo bus, but other programs like virtual drum kits (SSD4, SSD5 anything ToonTracks) and Orchestral suites (IkMultiMedia Philharmonik 2, Spitfire,…) have 16-24 stereo buses (32-48 ‘channels’) and a few mono auxes.
