weirdnet-audio-plugin 0.1.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
//! Audio plugins: a plugin takes a [`weirdnet_media::waveform::Waveform`] and typed parameters and returns a new waveform or an error.
//!
//! * [`Plugin`] and [`ParamSpec`]: what a plugin is and which parameters it takes (kind, range, default, unit).
//! * [`ParamValues`]: the values for one use of a plugin. [`ParamSpec`]s 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_builtins`] has `weirdnet.gain`, `weirdnet.levels` and `weirdnet.frequencies`.
//! * [`apply_chain`]: runs [`PluginInstance`]s in order; the error says which step failed. [`chain_cache_key`] is 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(&registry, &input, &chain)?;
//! let cache_key = chain_cache_key(&registry, &waveform_hash(&input), &chain)?;
//! assert_eq!(output.frames(), input.frames());
//! assert_eq!(cache_key.len(), 32);
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! 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.

mod chain;
mod error;
mod params;
mod plugin;

pub mod builtin;

pub use chain::{ChainError, PluginInstance, apply_chain, chain_cache_key, waveform_hash};
pub use error::PluginError;
pub use params::{ParamKind, ParamSpec, ParamValue, ParamValues};
pub use plugin::{Plugin, Registry};