weirdnet-audio-plugin 0.3.0

Audio plugins for Weirdnet: the Plugin trait, typed parameters, a registry, chain processing with a content-hash cache key, and the built-ins gain, levels and frequencies.
Documentation
# weirdnet-audio-plugin

[![crates.io](https://img.shields.io/crates/v/weirdnet-audio-plugin.svg)](https://crates.io/crates/weirdnet-audio-plugin)
[![docs.rs](https://docs.rs/weirdnet-audio-plugin/badge.svg)](https://docs.rs/weirdnet-audio-plugin)

Audio plugins for [Weirdnet](https://net.weirdbrains.com) by [Weird Brains](https://weirdbrains.com): a plugin takes a [`Waveform`](https://docs.rs/weirdnet-media/latest/weirdnet_media/waveform/struct.Waveform.html) from [weirdnet-media](https://crates.io/crates/weirdnet-media) and typed parameters, and returns a new waveform. Plugins are pure, so a result can be cached under a key that means what it says.

- `Plugin`, `ParamSpec`, `ParamValues`: a plugin declares its parameters (float with a range and unit, bool, or a choice, each with a default). `ParamValues::resolve` fills defaults and rejects unknown names, wrong kinds and out-of-range values, so `process` only sees complete, valid values.
- `Registry`: plugins by id. `Registry::with_builtins()` has the three built-ins; apps `register` their own.
- `apply_chain` runs `PluginInstance`s in order (a step can be bypassed); the error says which step failed.
- `chain_cache_key` is a BLAKE3 key over the source (`waveform_hash`), each active step's plugin id and `version`, and its resolved parameters. Spelled-out defaults and bypassed steps do not change it; the order, any parameter and a plugin version do. Its value for a fixed input is pinned by a test, so a key saved in a project stays valid.
- Built-ins, each an identity at its defaults: `weirdnet.gain` (`gain_db`, `invert`), `weirdnet.levels` (peak or RMS normalise, a peak ceiling, constant-power pan) `weirdnet.frequencies` (low, high, band-pass or peaking filter from [weirdnet-dsp](https://crates.io/crates/weirdnet-dsp)), `weirdnet.pitch` (semitones and cents; keeps the length with the stretch library, or resamples) and `weirdnet.duration` (change the length only: `stretch` keeps the pitch, `trim` cuts with a fade; stretch is the crate feature `stretch`, on by default, and needs clang and libclang to build).

```toml
[dependencies]
weirdnet-audio-plugin = "0.1"
weirdnet-media = "0.2"
```

```rust
use weirdnet_audio_plugin::{ParamValues, PluginInstance, Registry, apply_chain, chain_cache_key, waveform_hash};
use weirdnet_media::waveform::Waveform;

let registry = Registry::with_builtins();
let input = Waveform::tone(48_000, 440.0, 4_800, 0.5)?;
let chain = [
    PluginInstance::new("weirdnet.frequencies", ParamValues::new().with_choice("type", "low").with_float("cutoff_hz", 800.0)),
    PluginInstance::new("weirdnet.gain", ParamValues::new().with_float("gain_db", -6.0)),
];
let output = apply_chain(&registry, &input, &chain)?;
let cache_key = chain_cache_key(&registry, &waveform_hash(&input), &chain)?;
```

The `apply_chain` example runs a chain over a WAV file: `cargo run --example apply_chain -- --demo out.wav gain:gain_db=-6 frequencies:type=low,cutoff_hz=800 levels:target=peak,target_db=-1`.

Hosting third-party plugin formats is out of scope.

Rust 1.99 or newer, edition 2024. [BSD-3-Clause](LICENSE), Copyright (c) 2026, [Weird Brains LLC](https://weirdbrains.com).