# iOS PluginHost Type

**URL:** <https://forum.juce.com/t/ios-pluginhost-type/54802>\
**Category:** MacOSX and iOS\
**Created:** [January 31, 2023, 10:13am UTC](https://forum.juce.com/t/ios-pluginhost-type/54802 "2023-01-31T10:13:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![onereddog](https://avatars.discourse-cdn.com/v4/letter/o/dbc845/32.png) [@onereddog](https://forum.juce.com/u/onereddog)\
**Post date:** [January 31, 2023, 10:13am UTC](https://forum.juce.com/t/ios-pluginhost-type/54802/1 "2023-01-31T10:13:17Z")

</div>

Hey

Is there an iOS equivalent for detecting PluginHost type? For example, I’m looking at doing this to remove the input bus for when running GarageBand AUv3; when the input bus is present there’s no audio output.

```auto
AudioProcessor::BusesProperties MorpheneAudioProcessor::makeBusProperties() {
    auto pluginHost = PluginHostType();

    if (pluginHost.isGarageBand()) {
        return AudioProcessor::BusesProperties().withOutput("Output", juce::AudioChannelSet::stereo(), true);
    } else {
        return AudioProcessor::BusesProperties()
            .withOutput("Output", juce::AudioChannelSet::stereo(), true)
            .withInput("Sidechain", juce::AudioChannelSet::stereo(), true);
    }
}

```

thanks  
pete

---

<div class="post-metadata">

**Author:** ![reuk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/reuk/32/21494_2.png) [@reuk](https://forum.juce.com/u/reuk)\
**Post date:** [January 31, 2023, 11:49am UTC](https://forum.juce.com/t/ios-pluginhost-type/54802/2 "2023-01-31T11:49:50Z")

</div>

As far as I can tell, AUv3 doesn’t provide an API to detect the host’s name or identifier. Maybe I’m looking in the wrong place - if there is such an API, then we can investigate adding support for it.

---

<div class="post-metadata">

**Author:** ![onereddog](https://avatars.discourse-cdn.com/v4/letter/o/dbc845/32.png) [@onereddog](https://forum.juce.com/u/onereddog)\
**Post date:** [February 1, 2023, 11:31am UTC](https://forum.juce.com/t/ios-pluginhost-type/54802/3 "2023-02-01T11:31:47Z")

</div>

Yeah, I can’t find a way of doing that either via the AUv3 API. Probably because it’s running in a separate process to the host. Makes it very tricky…

However, I think I have done a massive hack to make it work. Essentially, in the `juce_AUv3_Wrapper.mm` the method `loadView` calls the AudioProcessor constructor. [fr810](https://forum.juce.com/u/fr810) mentioned elsewhere you can debug this by adding a sleep() and attaching the Xcode debugger. Brilliant trick to figure out the call graph.

So, I separated out the AudioProcessor construction and set UIView so that `loadView` just creates a blank view (on the main thread, as expected).

But what we really need is `createAudioUnitWithComponentDescription` where we know the componentType. Then we can pass that type into the AudioProcessor constructor and make the appropriate buses.

In this case if it’s `aumu` only provide an output bus, while `aumf` create input and output. It seems GarageBand iOS can’t deal with an aumu with input and output and obviously our plugin can’t remove buses.

Unfortunately, createAU happens on it’s own thread. Therefore, my final hack looks like this:

```auto
- (AUAudioUnit *) createAudioUnitWithComponentDescription: (AudioComponentDescription) desc error: (NSError **) error {
    WaitableEvent loadEvent;
    cpp->createAudioProcessor(&loadEvent, desc.componentType);
    loadEvent.wait(-1);
    return cpp->createAudioUnit (desc, error);
}

```

With the corresponding hacks to pass the componentType into the createFilter into my AudioProcessor. It might be possible to further separate the UIView stuff from the bottom of the original `loadView`. Somehow they’re related to having an AudioProcessor which has an Editor which has an AU bus layout but my brain’s fried.

This works. I’m still testing this, but so far so good. Fingers crossed…
