35 releases (7 breaking)
Uses new Rust 2024
| new 0.57.1 | Jun 8, 2026 |
|---|---|
| 0.56.0 | Jun 6, 2026 |
| 0.1.2 |
|
#7 in #truce
1,089 downloads per month
Used in 22 crates
(20 directly)
81KB
1.5K
SLoC
truce-params
Parameter system for the truce audio plugin framework.
Overview
Provides the types and utilities for declaring, smoothing, and formatting
plugin parameters. Parameters are the primary interface between a plugin and
its host -- they drive automation, presets, and UI controls. Use this crate's
types inside your Params struct, then derive with #[derive(Params)].
Key types
FloatParam-- continuous floating-point parameter (with smoother)IntParam-- discrete integer parameter. Pick this overFloatParamwheneverrange = "discrete(...)"describes the parameter - the type expresses intent and skips the unused smoother state.BoolParam-- on/off toggle parameterEnumParam-- parameter backed by a Rust enum (via#[derive(ParamEnum)])ParamRange-- defines value ranges and mapping curves (linear, logarithmic, discrete)Smoother/SmoothingStyle-- per-sample parameter smoothing to avoid zipper noiseParamInfo-- metadata (name, unit label, flags) for host communicationFloat/Sample-- sealed traits overf32/f64that carry the cross-precision math methods (to_f32,to_f64,from_f32,from_f64, plusexp,log10,powf).SampleisFloat + Default + Send + Sync + 'static- the audio buffer element bound.FloatParamReadF32/FloatParamReadF64-- precision-routed read traits. The prelude brings one of them into scope as_;param.read()then returnsf32orf64directly without per-call-site annotation.
Example
#[derive(Params)]
struct MyParams {
#[param(name = "Gain", range = "linear(-60.0, 0.0)", unit = "dB",
smooth = "exp(5)")]
gain: FloatParam,
#[param(name = "Semitones", range = "discrete(-12, 12)", unit = "st")]
semitones: IntParam, // discrete-integer params use IntParam, not FloatParam
#[param(name = "Mode")]
mode: EnumParam<FilterMode>,
}
Dependencies
~96KB