A Format Only Code

Hi Guys,

I want to add a code part for only AU. I’m looking for a #define for it but couldn’t find it. For example;

#if AU_COMPILE
    _button.setEnabled(false);
#endif

Do you know a #define for that?

Projucer is setting the following defines:

  • JucePlugin_Build_VST
  • JucePlugin_Build_VST3
  • JucePlugin_Build_AU
  • JucePlugin_Build_AUv3
  • JucePlugin_Build_RTAS
  • JucePlugin_Build_AAX
  • JucePlugin_Build_Standalone
  • JucePlugin_Build_Unity
  • JUCE_SHARED_CODE

I hope this helps.

Hi @McMartin, thanks for the reply. I’ve already tried that JucePlugin_Build_AU but it’s not for only AU. It’s set to 1 and when VST is compiling, the code is also reachable.

If you check for the define in the “shared code” portions of your project, it doesn’t help. The shared code is built only once and all the defines are active. But you can do a runtime check for the currently running plugin format with the AudioProcessor::wrapperType member.

1 Like

The code is compiled for all formats. You want to check the AudioProcessor.wrapperType at runtime.

^ like @Xenakios said

Thanks very much guys (@Xenakios, @daniel), it solves the issue.

As already mentioned the check needs to be done at runtime because the code ends up in a shared library. However for completeness it’s worth mentioning that there is a way to have a file compiled for one format only. You have to create a JUCE module and then in the same way that you can create cpp files that compile for specific platforms (see here for details https://github.com/WeAreROLI/JUCE/blob/master/modules/JUCE%20Module%20Format.txt#L50) you can use the following filename suffixes to compile for the specific formats…

_AAX
_AU
_AUv3
_RTAS
_Standalone
_Unity
_VST2
_VST3

I actually quite like turning all project source code into a JUCE module - the advantage being that if you use the Projucer you don’t have to open the Projucer to manually add source files and the organisation of the files on disk is automatically reflected in the project.

2 Likes

@anthony-nicholls thanks for bringing up that feature! However, the way you phrased it is a bit misleading. Projucer also filters user files based on these suffixes, so you don’t have to create a JUCE module, but it might be more convenient indeed.

1 Like

@McMartin, that’s news to me (good news!). It’s been a while since I’ve done this, probably well over a year so maybe something has changed in that time but I’m sure we tried doing this with regular source files added to the Projucer and it only worked for those in the modules at the time.

Now, I have another problem which I don’t think there is a solution. I need to separate AAX and Audio Suite. There is no different WrapperType for those. Do you know a solution for that?

PluginHostType:: isInAAXAudioSuite() https://docs.juce.com/master/classPluginHostType.html#a26e85e84aa44fe7b0386cca3c0105014

1 Like

Thank you @anthony-nicholls, I didn’t know that we can even know the host, that’s a great feature.

Note that isInAAXAudioSuite() returns false during createPluginFilter(), because the processor being created hasn’t yet been added to JuceAAX_Processor::activeProcessors array.