[FR] createPluginFilter (bool)


Okay - I’m not sure if y’all would go for this… :slight_smile:

Since my Standalone has to have a different set of Bus properties than my non-standalone version…

In juce_PluginUtilities.cpp

/** Somewhere in the codebase of your plugin, you need to implement this function
    and make it return a new instance of the filter subclass that you're building.
 extern AudioProcessor* JUCE_CALLTYPE createPluginFilter (bool);


 AudioProcessor* JUCE_API JUCE_CALLTYPE createPluginFilterOfType (AudioProcessor::WrapperType type)
    AudioProcessor::setTypeOfNextNewPlugin (type);
    AudioProcessor* const pluginInstance = createPluginFilter (type == AudioProcessor::WrapperType::wrapperType_Standalone);
    AudioProcessor::setTypeOfNextNewPlugin (AudioProcessor::wrapperType_Undefined);

    // your createPluginFilter() method must return an object!
    jassert (pluginInstance != nullptr && pluginInstance->wrapperType == type);

    return pluginInstance;

Then in my processor class have two constructors:

  MyAudioProcessor (bool bStandalone);

and change:

 // This creates new instances of the plugin..
  AudioProcessor* JUCE_CALLTYPE createPluginFilter (bool bStandalone = false)
     if (bStandalone)
         return new CPlayerAudioProcessor (bStandalone);

     return new CPlayerAudioProcessor();

I can now have a separate ctor for Standalone and non-Standalone…

MyAudioProcessor:: MyAudioProcessor (bool bStandalone) : AudioProcessor (BusesProperties().withOutput ("Out", AudioChannelSet::discreteChannels (16), true) )

MyAudioProcessor:: MyAudioProcessor() : AudioProcessor (BusesProperties()                                                                 
                                                             .withOutput ("Out 1-2",   AudioChannelSet::stereo(), true)
                                                             .withOutput ("Out 3-4",   AudioChannelSet::stereo(), false)
                                                             .withOutput ("Out 5-6",   AudioChannelSet::stereo(), false)
                                                             .withOutput ("Out 7-8",   AudioChannelSet::stereo(), false)
                                                             .withOutput ("Out 9-10",  AudioChannelSet::stereo(), false)
                                                             .withOutput ("Out 11-12", AudioChannelSet::stereo(), false)
                                                             .withOutput ("Out 13-14", AudioChannelSet::stereo(), false)
                                                             .withOutput ("Out 15-16", AudioChannelSet::stereo(), false)



Getnumsamples() comes back 2048 but inspecting the data shows only 512 samples

Uhm, can’t you have two different constructors for your MyAudioProcessor and just call the appropriate one inside createPluginFilter() depending on what’s returned by JUCEApplicationBase::isStandaloneApp() ?


Damn… I guess I was overthinking it :slight_smile:

 AudioProcessor* JUCE_CALLTYPE createPluginFilter()
     if (JUCEApplicationBase::isStandaloneApp())
         return new CPlayerAudioProcessor (true);

     return new CPlayerAudioProcessor();

Works fine!