JUCE Plugin Integration Overview
bbx_audio provides a complete solution for writing audio plugin DSP in Rust while using JUCE for the UI and plugin framework.
Architecture
JUCE AudioProcessor (C++)
|
v
+-----------+
| bbx::Graph| <-- RAII C++ wrapper
+-----------+
|
v (C FFI calls)
+------------+
| bbx_ffi.h | <-- Generated C header
+------------+
|
v
+-------------+
| PluginGraph | <-- Your Rust DSP (implements PluginDsp)
+-------------+
|
v
+------------+
| DSP Blocks | <-- Gain, Panner, Filters, etc.
+------------+
Key Components
Rust Side
PluginDsptrait - Defines the interface your DSP must implementbbx_plugin_ffi!macro - Generates all C FFI exports automatically- Parameter system - Define parameters in JSON or Rust, generate indices for both languages
C++ Side
bbx_ffi.h- C header with FFI function declarations and error codesbbx_graph.h- Header-only C++ RAII wrapper class- Parameter indices - Generated
#defineconstants matching Rust indices
Quick Start Checklist
For experienced developers, here's the minimal setup:
- Add Corrosion submodule:
git submodule add https://github.com/corrosion-rs/corrosion.git vendor/corrosion - Create
dsp/Cargo.tomlwithbbx_plugindependency andcrate-type = ["staticlib"] - Copy
bbx_ffi.handbbx_graph.htodsp/include/ - Implement
PluginDsptrait and callbbx_plugin_ffi!(YourType) - Add Corrosion to CMakeLists.txt and link
dspto your plugin target - Use
bbx::Graphin your AudioProcessor
For detailed guidance, follow the integration steps below.
Integration Steps
- Project Setup - Directory structure and prerequisites
- Rust Crate Configuration - Set up
Cargo.tomland FFI headers - CMake with Corrosion - Configure the build system
- Implementing PluginDsp - Write your DSP processing chain
- Parameter System - Define and manage plugin parameters
- AudioProcessor Integration - Connect to JUCE
- Complete Example - Full working reference
Reference Documentation:
- FFI Integration - C FFI layer details
- C FFI Header Reference - Complete
bbx_ffi.hdocumentation - C++ RAII Wrapper - Using
bbx::Graphin JUCE
Benefits
- Type Safety: Rust's type system prevents memory bugs in DSP code
- Performance: Zero-cost abstractions with no runtime overhead
- Separation: Clean boundary between DSP logic and UI/framework code
- Testability: DSP can be tested independently of the plugin framework
- Portability: Same DSP code works with any C++-compatible framework
Limitations
- Build Complexity: Requires Rust toolchain in addition to C++ build
- Debug Boundaries: Debugging across FFI requires care
- No Hot Reload: DSP changes require full rebuild and plugin reload