1ddba77c28
Adapted from musiikki/codename-206, where the same script guards a single plugin. It matters more here: renaming is the first thing anyone does with a template, and identity is duplicated across Cargo.toml, bundler.toml, src/lib.rs and the docs with nothing keeping them in agreement. A half-finished rename builds a bundle under one name while the docs and deploy script look for another. Changes from the codename-206 original: - Checks for files this repo does not ship (deploy.ps1) report as `skip` rather than FAIL, and start enforcing once the file appears. - STALE ships pre-seeded with this template's own placeholders, and each entry is skipped while it is still part of a canonical value. That makes renaming self-checking: entries arm themselves as you change the value they belong to, with no bookkeeping. Substring rather than equality, because placeholders nest — "your-domain" lives inside the canonical CLAP_ID. - Covers identity this template carries that codename-206's did not: VENDOR, EMAIL, the Cargo homepage feeding Plugin::URL, that the `env!` indirection is still in place, and the README's bundle command. - Asserts CLAP_ID is reverse-DNS safe. A stray capital or space there is not a compile error, it is a silent identity change between machines. Two placeholder spellings had to move to avoid false positives, since a checker that cries wolf trains you to ignore it: bundler.toml's comment contained the literal "Plugin Name", and the CLAP_ID TODO spelled the placeholder a third way that matched neither the constant nor the STALE list. The TODO now illustrates the form instead of repeating a placeholder. .gitattributes pins *.sh to LF so core.autocrlf=true on Windows cannot check the script out with a CRLF shebang that dash rejects. Verified three ways: clean template passes, a partial rename names every drifted file, and a complete rename passes and still compiles. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WHt4DykxXaQnyaJfyS8KCn
125 lines
4.5 KiB
Markdown
125 lines
4.5 KiB
Markdown
# NIH-plug Template
|
|
|
|
Minimal scaffold for new [NIH-plug](https://github.com/robbert-vdh/nih-plug) audio plugins (Rust + CLAP/VST3 + egui).
|
|
|
|
Based on patterns from [`musiikki/codename-206`](http://192.168.2.199:3005/musiikki/codename-206).
|
|
|
|
## Quick Start
|
|
|
|
```bash
|
|
# Clone this repo as your starting point
|
|
git clone http://192.168.2.199:3005/musiikki/nih-plug-template my-plugin
|
|
cd my-plugin
|
|
|
|
# Edit: src/lib.rs, Cargo.toml, bundler.toml — replace placeholder values
|
|
# See musiikki/codename-206 for a real-world example of how to fill these in
|
|
|
|
# Then verify the rename landed everywhere
|
|
sh check-branding.sh
|
|
```
|
|
|
|
## Renaming
|
|
|
|
Branding is duplicated across `Cargo.toml`, `bundler.toml`, `src/lib.rs` and the docs,
|
|
and nothing makes those agree — so a half-finished rename builds a bundle under one name
|
|
while the docs and deploy script look for another.
|
|
|
|
`check-branding.sh` declares the identity once at the top and asserts every copy matches:
|
|
|
|
```bash
|
|
sh check-branding.sh # exit 0 = consistent, 1 = drift found
|
|
```
|
|
|
|
To rename: edit the canonical block at the top of the script, run it, and fix everything
|
|
it reports. The placeholder spellings are pre-seeded into its `STALE` list, and each one
|
|
arms itself as soon as you change the matching canonical value — so leftovers surface
|
|
without you having to track them. It also asserts `VST3_CLASS_ID` is exactly 16 bytes and
|
|
that `CLAP_ID` is reverse-DNS safe, both of which are otherwise a compile error or a
|
|
silent identity change between machines.
|
|
|
|
Checks for files the template doesn't ship (e.g. a `deploy.ps1`) report as `skip` and
|
|
start enforcing once you add them.
|
|
|
|
## Build
|
|
|
|
```bash
|
|
# Install Rust via rustup: https://rustup.rs
|
|
# No VST3 SDK needed — NIH-plug bundles its own bindings.
|
|
|
|
# Build + bundle the CLAP (default)
|
|
cargo xtask bundle nih_plug_template --release
|
|
|
|
# Add the VST3 as well — see the licensing note below before you do this
|
|
cargo xtask bundle nih_plug_template --release --features vst3
|
|
```
|
|
|
|
**Output:** `target/bundled/<name>.clap` (and `<name>.vst3` with `--features vst3`), where
|
|
`<name>` is the `name` set in `bundler.toml` — **not** the crate name. Out of the box that
|
|
means `target/bundled/Plugin Name.clap`.
|
|
|
|
On Linux the egui editor needs the GUI development headers:
|
|
|
|
```bash
|
|
sudo apt install pkg-config libgl-dev libx11-dev libxcursor-dev libxcb1-dev \
|
|
libxcb-icccm4-dev libxcb-dri2-0-dev libx11-xcb-dev libxkbcommon-dev libxkbcommon-x11-dev
|
|
```
|
|
|
|
## Deploy
|
|
|
|
### FL Studio
|
|
|
|
Build with `--features vst3` first if you want the VST3 (see the licensing note below).
|
|
|
|
FL Studio scans `C:\Program Files\Common Files\VST3` by default, **ignores directory junctions**
|
|
(so a symlinked bundle is invisible to its scanner), and caches failed scans.
|
|
|
|
1. Copy the `.vst3` bundle to a folder FL scans (e.g. `C:\Program Files\Common Files\VST3`).
|
|
2. Copy the `.clap` bundle to a folder FL scans (e.g. `C:\Program Files\Common Files\CLAP`).
|
|
3. In FL Studio: **Options → Manage plugins → tick "Rescan previously failed plugins" → Find installed plugins**, then search for your plugin name (set in `bundler.toml`).
|
|
|
|
### Linux
|
|
|
|
```bash
|
|
# CLAP
|
|
cp -r "target/bundled/Plugin Name.clap" ~/.clap/
|
|
|
|
# VST3 (only exists if you built with --features vst3)
|
|
cp -r "target/bundled/Plugin Name.vst3" ~/.vst3/
|
|
|
|
# Or globally:
|
|
# sudo cp -r "target/bundled/Plugin Name.clap" /usr/lib/clap/
|
|
# sudo cp -r "target/bundled/Plugin Name.vst3" /usr/lib/vst3/
|
|
```
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
Cargo.toml # Package deps + the opt-in `vst3` feature — NIH-plug pinned to codename-206's rev
|
|
bundler.toml # Bundle name for `cargo xtask bundle`
|
|
src/lib.rs # Plugin skeleton — params, DSP, and egui editor, with one example gain param
|
|
xtask/ # Bundler xtask (cargo xtask bundle)
|
|
.cargo/config.toml # xtask alias
|
|
check-branding.sh # Asserts the plugin's identity strings agree everywhere (see Renaming)
|
|
.gitattributes # Pins *.sh to LF so Windows checkouts keep a valid shebang
|
|
```
|
|
|
|
## License
|
|
|
|
Apache-2.0
|
|
|
|
## VST3 Licensing Note
|
|
|
|
NIH-plug's VST3 bindings (`vst3-sys`) are GPLv3. Linking them makes the resulting binary
|
|
GPLv3 regardless of what `Cargo.toml` declares, so **VST3 is behind an opt-in `vst3` feature
|
|
and this template builds CLAP only by default.** That keeps the default build consistent with
|
|
the Apache-2.0 licence in `Cargo.toml`/`LICENSE`.
|
|
|
|
If you want to ship a VST3:
|
|
|
|
1. Build with `--features vst3`.
|
|
2. Relicense your plugin as GPLv3 (or obtain a commercial Steinberg licence) and update
|
|
`Cargo.toml`, `LICENSE`, and the SPDX headers in `src/`.
|
|
3. Accept Steinberg's VST3 SDK licence.
|
|
|
|
CLAP has no such restriction.
|