Expand description
Audio plugins: a plugin takes a weirdnet_media::waveform::Waveform and typed parameters and returns a new waveform or an error.
PluginandParamSpec: what a plugin is and which parameters it takes (kind, range, default, unit).ParamValues: the values for one use of a plugin.ParamSpecs validate and resolve them (defaults filled in, unknown names and out-of-range values rejected), so a plugin only ever sees complete, valid values.Registry: plugins by id.Registry::with_builtinshasweirdnet.gain,weirdnet.levels,weirdnet.frequencies,weirdnet.durationandweirdnet.pitch.apply_chain: runsPluginInstances in order; the error says which step failed.chain_cache_keyis the BLAKE3 key a cache uses for the result: source content, plugin ids and versions, resolved parameter values; bypassed steps do not count.
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(®istry, &input, &chain)?;
let cache_key = chain_cache_key(®istry, &waveform_hash(&input), &chain)?;
assert_eq!(output.frames(), input.frames());
assert_eq!(cache_key.len(), 32);Every built-in’s defaults are an identity, so a freshly added plugin changes nothing until a parameter moves. Hosting third-party plugin formats is out of scope.
Modules§
- builtin
- The built-in plugins. Each one’s default values leave in-range audio unchanged.
Structs§
- Param
Spec - A parameter a plugin takes.
- Param
Values - Values for one use of a plugin, by parameter name. Missing names mean the default.
- Plugin
Instance - One use of a plugin in a chain.
- Registry
- Plugins by id.
Enums§
- Chain
Error - Why a chain failed, and where.
- Param
Kind - The type of a parameter.
- Param
Value - One parameter’s value.
- Plugin
Error - Why a plugin could not process a waveform.
Traits§
- Plugin
- An audio effect. Implementations are pure: the same input and values give the same output, which is what lets results be cached.
Functions§
- apply_
chain - Runs
chainoverinput, in order, skipping bypassed instances. An empty chain returns a clone of the input. - chain_
cache_ key - The key a cache uses for “
sourcethroughchain”. - waveform_
hash - The BLAKE3 hash of a waveform’s content (sample rate, channels and every sample’s bits). Use it as the
sourceofchain_cache_keyfor audio that has no content hash of its own.