How robbert-vdh/nih-plug works
Project type and purpose
This is a multi-crate Rust “monorepo” that provides:
– An API-agnostic audio plugin framework (core library)
– A derive-macro crate for declarative parameter definitions
– Adapters for Rust GUI toolkits (egui, iced, VIZIA)
– A cargo subcommand (xtask) for building/bundling plugins
– A collection of example and production audio plugins
It targets both DAWs (via VST3 and CLAP) and standalone executables (JACK, CPAL).
File structure
– Top-level crates:
• src/ → core framework (audio processing, params, wrappers)
• nih_plug_derive/ → proc-macro crate generating Params trait impls
• nih_plug_egui/, _iced/, _vizia/ → GUI adapter crates for each toolkit
• cargo_nih_plug/ → cargo subcommand plugin installer
• nih_plug_xtask/ → “xtask” CLI for bundling and cross-compiling
• plugins/ → real and example plugin crates
– Build & CI: .github/workflows, Cargo.toml workspace, bundler.toml
– Wrappers: under src/wrapper, split by target (clap, vst3, standalone backends)
README for insights
– Core features (VST3/CLAP export macros, standalone binary CLI, param system, background-tasks)
– Supported toolkits (egui, iced, VIZIA)
– Build instructions (cargo xtask bundle)
– Example plugins to learn from
1. Cargo Workspace & Build System
2. Core Framework Crate (“nih_plug” library)
• Audio processing modules (buffer iterators, FFT adapters)
• Parameter system (Params trait, smoothers, persistence)
• Background-task runner
• MIDI & note-expression handling
• Wrapper layer(s) for VST3 / CLAP / standalone (CPAL, JACK, dummy)
3. Proc-Macro Crate (nih_plug_derive)
4. GUI Adapter Crates
• nih_plug_egui → Egui widgets & editor glue
• nih_plug_iced → Iced widgets & editor glue
• nih_plug_vizia → VIZIA widgets & styling
5. XTask Bundler & Cargo Subcommand
• cargo_nih_plug → installs as cargo nih-plug
• nih_plug_xtask → cargo xtask bundle logic, detects formats & targets
6. Plugin Crates
• plugins/examples/...
• plugins/[buffr_glitch, crisp, ...]
7. External Systems
• Host DAWs (via VST3, CLAP)
• Audio backends (JACK, CPAL)
• Filesystem / CLI
– Plugin Crates → depend on → Core Framework Crate & Proc-Macro Crate
– Proc-Macro Crate → code-generation → Core Framework & Plugin Crates
– Plugin Crates + GUI Adapter Crates → optional UI panels → Core Framework
– XTask Bundler → reads Cargo.toml + plugin targets → drives → build system → outputs plugin bundles
– Core Framework Wrappers → expose C ABI → consumed by → DAW hosts (VST3/CLAP)
– Standalone Wrapper → links CPAL/JACK → runs as CLI binary
c. Architectural patterns & design principles
– Modular, layered architecture: macro layer, core library layer, adapter layer, application layer
– Plugin-pattern: user code implements Plugin trait, exported via nih_export_<api>! macros
– Proc-macros for zero-boilerplate parameter derivation
– Separation of concerns: audio processing vs. GUI vs. hosting vs. bundling
d. Technologies & frameworks
– Rust & Cargo workspace
– Proc-macro (nih_plug_derive)
– VST3-sys (GPLv3), CLAP
– CPAL, JACK (standalone)
– GUI: egui, iced, VIZIA
– CLI: structopt or clap (in xtask)