A Format Only Code

#1

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?

0 Likes

#2

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.

0 Likes

#3

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.

0 Likes

#4

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

#5

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

^ like @Xenakios said

0 Likes

#6

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

0 Likes

#7

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

#8

@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.

0 Likes

#9

@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.

0 Likes

#10

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?

0 Likes

#11

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

1 Like

#12

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

0 Likes