Write a CLAP plugin in Rust, get self-contained AU and VST3 plugins for free! Supports Windows, Linux, and macOS (universal binary x86_64 + arm64)
This repository demonstrates a Rust-based approach to audio plugin development that starts with the CLAP plugin format and extends to VST3 and AU formats using the clap-wrapper project. The resulting plugins are self-contained thanks to a static linking approach.
The clack crate is used to provide safe Rust wrappers for the CLAP API without adding an opinionated plugin framework.
Uniquely, this example demonstrates exporting multiple plug-ins from a single binary! To support AU, clap-wrapper's AUv2 plugin factory extension is used.
Bindings for the clap-wrapper extensions are provided in clap-wrapper-extensions. I hope for them to be included in clack directly to reduce the required boilerplate for plugins.
This example exposes two variations of a simple gain plugin:
- Gain Halver: Multiplies signal with 0.5
- Gain Doubler: Multiplies signal with 2.0
- Rust toolchain (2021 edition or later)
- CMake (3.15 or later)
- C++ compiler with C++17 support
The project uses the xtask pattern to simplify building:
# Build debug version
cargo xtask build gain-example
# Build release version
cargo xtask build gain-example --release
# Build and install release version to user's plugin directories (macOS/Linux only)
cargo xtask build gain-example --release --install
See the xtask README for more detailed commands and options.
- The Rust code is compiled into a static library that exports a non-standard
rust_clap_entry
symbol - A small C++ shim re-exports this symbol as the standard CLAP entry point
- clap-wrapper builds self-contained plugins for CLAP, VST3, and AU formats
To adapt this example for your own plugin:
- Rename/duplicate the
gain-example
plugin directory - Modify the implementations in
audio_thread.rs
andmain_thread.rs
- Update the plugin descriptors in
lib.rs
- Update bundle IDs and other metadata in build commands
- @Prokopyl for providing Rust bindings for the clap-wrapper's extensions
- SG60/rust-clap-wrapper-thick for their pioneering work
MIT OR Apache-2.0