AU Type Generator Plugin

Hi all,

I’m developing an audio plugin that gets a live stream audio data from the (internal) network, feeds the plugin’s buffer and as a result the plugin outputs the audio. This way the plugin “generates” audio and doesn’t need any midi/audio input from the DAW.
Audio Unit does account for this case - it’s kAudioUnitType_Generator . For the VST3 plugin i couldn’t find such equivalent so I generate the plugin as an “Instrument”.

Now the problem:
In order for the plugin to pass the validation I need to set:

  • for the AU JucePlugin_WantsMidiInput 0
  • for the VST3 JucePlugin_WantsMidiInput 1

The plugin is compiled ONCE into a static library so making conditional ifs in the AppConfig.h won’t help:

#ifndef JucePlugin_Build_VST3
#define JucePlugin_WantsMidiInput 0
#endif

I run out of ideas how to keep the project clean and simple, especially when using CLI for building vst3 and au. I would like to avoid having 2 Projucer projects just because of this one change.

Is there a way to add a rule to clean the generated .a lib after each target when building all targets?

The define is only used in a callback function. You can use wrapperType there instead of the define…

EDIT: sorry, I might have forgotten the AU base classes, not sure if this helps then…

I’d suggest: move to CMake, where you can define multiple targets with different static library configs quite a bit easier than in .jucer.

Is the SharedLibraryCode compiled multiple times in juce cmake?
I doubt it, but don’t know

@Daniel the runtime option using wrapperType doesn’t work for AU for me unfortunately.

Right now as a workaround I think I will need to build targets separately, changing this one define as a prrebuild task.
It’d be great if such defines could be separated for different targets. Or at least to make a special case for audio unit type kAudioUnitType_Generator to automatically disable any inputs…

nice one, thanks! That could be a solution when me and my team once decide to drop Projucer and use cmake which makes a lot of sense in such situations…:wink:

I see, you are not using juceaide.
It’s an option…

I asked ChatGPT to just go ahead and build an example, and well … it looks usable, at least:

cmake_minimum_required(VERSION 3.15)

# Define project
project(MyJUCEProject)

# Include JUCE
include(FetchContent)
FetchContent_Declare(
    JUCE
    GIT_REPOSITORY https://github.com/juce-framework/JUCE.git
    GIT_TAG 8.0.0 # Replace with the appropriate version
)
FetchContent_MakeAvailable(JUCE)

# Define JUCE options
set(JUCE_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(JUCE_ENABLE_MODULE_SOURCE_GROUPS ON CACHE BOOL "" FORCE)

# Add SharedLibraryCode as an object library
add_library(SharedLibraryCode OBJECT
    src/SharedLibraryCode.cpp
)

target_include_directories(SharedLibraryCode
    PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
)

# Define the AU target
add_library(MyPlugin_AU MODULE
    src/MainComponent.cpp
)

# Link JUCE modules to the AU target
target_link_libraries(MyPlugin_AU PRIVATE
    juce::juce_gui_basics
    juce::juce_audio_processors
)

# Link the shared library code to the AU target
target_sources(MyPlugin_AU PRIVATE
    $<TARGET_OBJECTS:SharedLibraryCode>
)

# Define compile-time configuration for AU
target_compile_definitions(MyPlugin_AU PRIVATE
    JucePlugin_WantsMidiInput=0
    JucePlugin_Build_AU=1
    JucePlugin_Build_VST3=0
)

# Define the VST3 target
add_library(MyPlugin_VST3 MODULE
    src/MainComponent.cpp
)

# Link JUCE modules to the VST3 target
target_link_libraries(MyPlugin_VST3 PRIVATE
    juce::juce_gui_basics
    juce::juce_audio_processors
)

# Link the shared library code to the VST3 target
target_sources(MyPlugin_VST3 PRIVATE
    $<TARGET_OBJECTS:SharedLibraryCode>
)

# Define compile-time configuration for VST3
target_compile_definitions(MyPlugin_VST3 PRIVATE
    JucePlugin_WantsMidiInput=1
    JucePlugin_Build_AU=0
    JucePlugin_Build_VST3=1
)

# Set target properties (optional)
set_target_properties(MyPlugin_AU PROPERTIES
    CXX_STANDARD 17
    RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/AU
)

set_target_properties(MyPlugin_VST3 PROPERTIES
    CXX_STANDARD 17
    RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/VST3
)

And in case you’re putting off moving from .jucer to CMake, I can tell you with recent experience that ChatGPT can convert .jucer files to CMakeLists.txt with a fairly decent amount of success … ymmv (Haven’t seen your .jucer) but I am yet to find a .jucer file I can’t convert to CMakeList.txt this way, smoothly and rapidly …