Expand description
synfx-dsp Real Time Audio Synthesis and Effect DSP algorithms and utility functions for Rust.
Most of the algorithms and implementations in this library have been implemented for HexoDSP and used in HexoSynth. I factored them out, because they seem useful in other contexts too, for instance the synfx-dsp-jit crate.
I collected most of the algorithms in this crate from various GPLv3 compatible sources. They also were partially translated from multiple different C++ projects. I tried to document the source and source license diligently in the comments of this crate. I apologize if any attribution is missing and would welcome patches or reports.
Feel free to use these algorithms and utilities. Help, patches and additions are appreciated if they comply with the GPL-3.0-or-later license and don’t break the test suite in HexoDSP.
Attention: HexoDSP comes with a large test suite that also covers these algorithms. And that is the one that also has to pass if these algorithms are touched. The flip side is, that these implementations are actually covered by a test suite.
Macros
Returns the name of the distortion selected by the dist_type parameter of the apply_distortion
function.
Structs
An all-pass filter based on a delay line.
2nd order IIR filter implemented in normalized Direct Form I.
Signal change detector that emits a trigger when the input signal changed.
Trigger signal detector with custom range.
Dattorro plate reverb implementation.
This is a delay buffer/line with linear and cubic interpolation.
Implements oversampling with a ratio of N and a 4 times cascade of Butterworth lowpass filters (~48dB?).
This is a band-limited oscillator based on the PolyBlep technique.
A ramped value changer, with a configurable time to reach the target value.
Random number generator based on xoroshiro128.
Requires two internal state variables.
You may prefer SplitMix64 or Rng which only use one u64 as state.
Random number generator based on SplitMix64. Requires two internal state variables. You may prefer SplitMix64 or Rng.
A slew rate limiter, with a configurable time per 1.0 increase.
A splitmix64 random number generator.
An LFO with a variable reverse point, which can go from reverse Saw, to Tri and to Saw, depending on the reverse point.
Trigger signal generator for HexoDSP nodes.
Trigger signal detector for HexoDSP.
Generates a phase signal from a trigger/gate input signal.
Vector Phase Shaping Oscillator.
The parameters d and v control the shape of the sinus
wave. This leads to interesting modulation properties of those
control values.
Constants
The threshold, once reached, will cause a trigger event and signals a logical ‘1’. Anything below this is a logical ‘0’.
The lower threshold for the schmidt trigger to reset.
! Contains various utilities for trigger signals in a modular synthesizer.
Traits
Functions
Linear crossfade.
Linear crossfade with clipping the v2 result.
Constant power crossfade.
Linear (f32) crossfade with driving the v2 result through a tanh().
Exponential crossfade.
Logarithmic crossfade.
Hermite / Cubic interpolation of a buffer full of samples at the given index. len is the buffer length to consider and wrap the index into. And fract is the fractional part of the index.
Signal distortion by Bram de Jong.
Foldback Signal distortion
A faster implementation of cosine. It’s not that much faster than Rust’s built in cosine function. But YMMV.
A faster implementation of sine. It’s not that much faster than Rust’s built in sine function. But YMMV.
Initializes [WHITE_NOISE_TAB]
Apply linear interpolation between the value a and b.
Apply 64bit linear interpolation between the value a and b.
Given the mutable state generates the next pseudo random number.
Converts a midi note (0 to 128) to a frequency
Process a very simple one pole 6dB high pass filter. Useful in various applications.
Process a very simple one pole 6dB low pass filter. Useful in various applications, from usage in a synthesizer to damping stuff in a reverb/delay.
Process a very simple one pole 6dB high pass filter in TPT form. Useful in various applications.
Process a very simple one pole 6dB low pass filter in TPT form. Useful in various applications, from usage in a synthesizer to damping stuff in a reverb/delay.
Process a HAL Chamberlin filter with two delays/state variables that is 12dB. The filter does internal oversampling with very simple decimation to rise the stability for cutoff frequency up to 16kHz.
This function processes a Simper SVF with 12dB. It’s a much newer algorithm for filtering and provides easy to calculate multiple outputs.
This function implements a simple Stilson/Moog low pass filter with 24dB. It provides only a low pass output.
A pow like shape function for exponential envelopes.
It’s a bit faster than calling the pow function of Rust.
Maps any u64 to a f64 in the open interval [0.0, 1.0).