Crates.io | heron-sound |
lib.rs | heron-sound |
version | 1.0.0 |
source | src |
created_at | 2024-02-10 00:44:31.111108 |
updated_at | 2024-02-10 00:44:31.111108 |
description | Core DSP library for Heron Sounds plugins |
homepage | https://github.com/heronsounds/heron-sound.git |
repository | https://github.com/heronsounds/heron-sound.git |
max_upload_size | |
id | 1134547 |
size | 124,369 |
heron-sound
is a library of DSP utilities used in Heron Sounds audio plugins.
Currently supports the following DSP components:
As well as a variety of utilities to support the above.
To help develop DSP components, we provide two basic traits,
Gen and Proc.
Gen
is for components that generate some value from their internal state
without any explicit input,
while Proc
is for processors that take some input value and produce an output.
The inputs and outputs may be samples, gains, or more complex types,
but should not be user-modifiable parameters.
To pass in user-modifiable parameters,
both traits have a Spec
associated type
which is passed by shared reference at processing time and evaluated,
along with the processor's internal state,
to produce an output.
For example, an envelope follower can be implemented as a Proc that takes an input sample and returns a bool indicating whether the envelope is engaged or not:
struct EnvFollower {
engaged: bool,
counter: u32,
}
struct EnvFollowerSpec {
threshold: f64,
hold_time: u32,
}
impl Proc<f64, bool> for EnvFollower {
type Spec = EnvFollowerSpec;
fn proc(&mut self, spec: &Self::Spec, sample: f64) -> bool {
// implementation omitted
}
}
Its internal state keeps track of whether it's currently engaged and for how long,
and its associated Spec
type keeps track of the amplitude threshold and hold time,
both of which can be set by the user.
At processing time, it checks whether the input sample's amplitude is above the threshold,
increments its internal counter and checks it against the user-set hold time,
and computes a boolean value to return.
To see how this is implemented in practice,
take a look at
EnvFollower and EnvFollowerSpec.
Most of the code in this library consists of implementations of Gen
and Proc
,
but we also include some miscellaneous utils in the util mod.
The components in this library are implemented according to the following constraints:
As well as a few more relaxed constraints:
f64
as the default float typeIn general, we put code in this library as soon as we can find a way to make it generic enough to be useful for more than one type of plugin (and write adequate tests for it). Expect the functionality to expand as we clean up application-specific code and make it more modular.
The following additions are in the works, but not fully tested or cleaned up: