How to get access to an instance of AudioDeviceManager when running as a Standalone Plugin

I understand that plugins don’t have access to audio device manager when running under a host program, but what about standalone plugins? Is there a way to get access the to audio device manager when running as a standalone app?

Thanks!

1 Like

Hi,

unfortunately I haven’t found a way to do that either. For me it seems to be rather nested in the AudioProcessor instance, and not directly accessible.
However, I’ve asked basically the same question here - with no answer yet, but I also posted a (rather dirty, but working) hack to set up your audio device manually:

Hope that helps in any way!

Cheers,
Lukas

1 Like

in your editor Component you can obtain a pointer to the StandaloneFilterWindow that contains it:

StandaloneFilterWindow* w = findParentComponentOfClass <StandaloneFilterWindow>();

With that (always better to check that w is not nullptr before accessing it), you have access to its device manager:

AudioDeviceManager& manager = w->getDeviceManager();

(For clarity, all types are mentioned explicitly, but in production code I strongly recommend replacing them with auto)

1 Like

Hi yfede,

I am getting “Unknown type name StandaloneFilterWindow” error when trying to use StandaloneFilterWindow. It doesn’t seem like the “StandaloneFilterWindow” class was included in the JUCE header by default. Did you have to include it from somewhere separately?

Thanks!

It’s in “juce_StandaloneFilterWindow.h” and I expected it to be already included if you have the juce_audio_plugin_client module but apparently it isn’t.

By having a second look at the docs, it seems you can obtain the AudioDeviceManager for your stand-alone this other way:

StandalonePluginHolder* standalone = StandalonePluginHolder::getInstance();

if (standalone != nullptr)
    AudioDeviceManager& manager = standalone->deviceManager;
1 Like

I tried that as well, but it seems StandalonePluginHolder is also an internal JUCE class, and can’t be accessed by developers.

Including “juce_StandaloneFilterWindow.h” worked for me, thx.
The only thing, in order to make it work I needed to include a bunch of other libraries first, which I wouldn’t have included otherwise:

  • juce_audio_processors
  • juce_audio_plugin_client
  • juce_audio_utils
  • and, as mentioned, the single header file: juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h

Edit:
I was also enable to manually change my Audio Device Manager settings afterwards, without changing ANY of the JUCE header files.

    pluginHolder = StandalonePluginHolder::getInstance();

    AudioDeviceManager::AudioDeviceSetup anotherSetup = pluginHolder->deviceManager.getAudioDeviceSetup();

    anotherSetup.sampleRate = 48000;
    anotherSetup.bufferSize = 128;

    pluginHolder->deviceManager.initialise(2,
                             2,
                             nullptr,
                             true,
                             "",
                             new AudioDeviceManager::AudioDeviceSetup(anotherSetup));

In this example I only changed the sample rate and the buffer size, but basically you can change any value in the AudioDeviceSetup struct.
I put this code into the constructor of my PluginEditor, and it worked like a charm. However, you should also be able to put it elsewhere, as long as the device initialization of the PluginProcessor is done beforehand.

2 Likes

Ah so sorry. The fact that I found StandalonePluginHolder in the doc, made me assume that it was available for public use.

(Which, in all honesty, is a quite reasonable assumption IMHO, so if it’s only for internal use, perhaps the JUCE team could remove it from the doc or make the class available)

1 Like