Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single merged plugin build #9

Merged
merged 4 commits into from
Jan 31, 2025

Conversation

martinfinke
Copy link

@martinfinke martinfinke commented Dec 8, 2024

Hello! First off, thank you so much for this project. I tried to do the same thing over the last couple of days, and then found this. Great work 👍

How about building a single binary target that contains all the plug-in formats in one file? You get a file/bundle that's a valid VST3, CLAP and AUv2 plugin, all in one. Just rename it to .component, .vst3 or .clap and put it in the correct folder.

It needs less config and saves build time (one build instead of three). Because the files are 100% identical, you only have to codesign once, and upload once to Apple for notarization.
If you ship a .pkg installer, you can put only the .vst3 bundle in the installer, and then copy it over to AUv2 and CLAP using a post-install script on the user's machine.

SonicCharge MicroTonic does this. The pkg Installer has a script that just copies one plugin over to the other formats. It really uses 100% the same plist with the same bundle ID across all plugin formats. The VST3's plist even contains all the AUv2 AudioComponents stuff. It seems fine.

I also added a configure_info_plist CMake function that's used by both the Standalone App and Plugin target. With the @MY_VARIABLE@ syntax in the plist you can use any CMake variable directly, without passing it to set_target_properties.

I hope this is helpful 🙂
I haven't been able to get the build working on Windows yet, but have tested AUv2, VST3 and CLAP on macOS.

I briefly looked at #4. Giving the structs of different backends all the same name CplugHostContext is probably not compatible with this PR (ODR violation).

By the way, ChatGPT really tried to generate the ASCII art PLUGIN heading. 😆

@@ -1322,9 +1322,9 @@ OSStatus ComponentBase_AP_Close(AUv2Plugin* auv2)
return noErr;
}

__attribute__((visibility("default"))) void* GetPluginFactory(const AudioComponentDescription* inDesc)
Copy link
Author

@martinfinke martinfinke Dec 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VST3 also uses the name GetPluginFactory, so I renamed this to avoid clashing. I've changed the factoryFunction in Info.plist.in to match.

# The properties:
set(MACOSX_BUNDLE_TAGS "<string>Synthesizer</string>") # Predefined tags are: Bass, Delay, Distortion, Drums, Dynamics, Dynamics Processor, Effects, Equalizer, Filter, Format Converter, Guitar, Imaging, MIDI, Mixer, Offline Effect, Output, Panner, Pitch, Reverb, Sampler, Synthesizer, Time Effect, Vocal. But you can use others.
set(MACOSX_BUNDLE_TYPE "aumu") # "aufx" for Effect, "augn" for Generator, "aumu" for Instrument, "aufm" for Music Effect.
set(MACOSX_BUNDLE_SUBTYPE "Xmpl") # For AU and GarageBand 10.3 compatibility, the first letter must be upper-case, the others lower-case.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source: JUCE's Projucer

Screenshot 2024-12-08 at 21 58 32

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find! Thanks I didn't know about this


endif() # APPLE
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_BINARY_DIR}/${PRODUCT_NAME}.clap" "${CMAKE_BINARY_DIR}/${PRODUCT_NAME}.vst3"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we simply copy the .clap over to .vst3 and .component.

@martinfinke martinfinke marked this pull request as ready for review December 8, 2024 20:04
<key>CFBundleIconFile</key>
<string>@MACOSX_BUNDLE_ICON_FILE@</string>
<key>CFBundleIdentifier</key>
<string>@bundle_identifier@</string>
Copy link
Author

@martinfinke martinfinke Dec 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lower-case because it's a parameter to the configure_info_plist function. This way, the standalone app can have a different bundle ID from the plugin.

<key>CFBundleShortVersionString</key>
<string>@PROJECT_VERSION@</string>
<key>CFBundlePackageType</key>
<string>@bundle_type@</string>
Copy link
Author

@martinfinke martinfinke Dec 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This becomes APPL for the standalone app, and BNDL for the plugin.

@Tremus
Copy link
Owner

Tremus commented Jan 14, 2025

Hey @martinfinke thanks a lot for this. I absolutely love seeing git diffs with more red than green.

Simplifying the build process and combining all formats into one sounds pretty good to me.

It would be great if CPLUG could build both single targets and all targets, whichever the user prefers. I took a quick look through your commits, and I think both are possible with your changes. Good work!

@Tremus Tremus merged commit 315d157 into Tremus:develop Jan 31, 2025
@martinfinke
Copy link
Author

Nice, thanks for merging!
I've also been working on AUv3 and VST2. If you're interested, I can share my code for those. But I won't be able to make a full PR for them, because I'm not using CMake and did the AUv3 build setup directly in Xcode.

@Tremus
Copy link
Owner

Tremus commented Feb 5, 2025

Thanks for your contributions! It definitely cleaned up a lot of the build script. I'd like to think of ways to simplify things more.

I'd love to take a peek at your AUv3 code. What would you say is the benefit of v3 over v2? Does Logic do a better job at fully supporting v3 than v2? (I hope so).

As for VST2, well CPLUGs VST3 wrapper already works fine (for synths*) in plenty of popular hosts, so I don't think there's a big gain there. There's also the VST2 licensing problem, which I'd like to avoid.

@martinfinke
Copy link
Author

martinfinke commented Feb 5, 2025

What would you say is the benefit of v3 over v2? Does Logic do a better job at fully supporting v3 than v2? (I hope so).
I did it for iOS, where AUv3 is the only supported format (no AUv2). And then the same code just builds for Mac.

Here's what I have so far: cplug_auv3.m.zip. It's not very well tested. The AUv3 API is pretty confusing, so hopefully it can be a starting point, or reference on how e.g. buffer handling is done.

Or you could just use AUAudioUnitV2Bridge instead, to make an AUv3 from CPLUG's existing AUv2. Steinberg also has something. I didn't try them, I prefer to see what's going on..

As for VST2, well CPLUGs VST3 wrapper already works fine (for synths*) in plenty of popular hosts, so I don't think there's a big gain there. There's also the VST2 licensing problem, which I'd like to avoid.

I agree: Not much gain for the average case, especially for new projects. So best to not include it in an open-source project like this, especially with the licensing (you can't just put aeffect.h in the repo).

@Tremus
Copy link
Owner

Tremus commented Feb 6, 2025

Great thanks for sharing that AUv3 code! This is a helpful starting point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants