![]() |
VCV Rack API
v1
|
Digital signal processing routines. More...
Classes | |
struct | AppleRingBuffer |
A cyclic buffer which maintains a valid linear array of size S by sliding along a larger block of size N. More... | |
struct | BooleanTrigger |
Detects when a boolean changes from false to true. More... | |
struct | ClockDivider |
struct | ComplexFFT |
Complex-valued FFT context. More... | |
struct | Decimator |
Downsamples by an integer factor. More... | |
struct | DoubleRingBuffer |
A cyclic buffer which maintains a valid linear array of size S by keeping a copy of the buffer in adjacent memory. More... | |
struct | Frame |
Useful for storing arrays of samples in ring buffers and casting them to float* to be used by interleaved processors, like SampleRateConverter. More... | |
struct | IIRFilter |
Digital IIR filter processor. More... | |
struct | MidiGenerator |
Converts gates and CV to MIDI messages. More... | |
struct | MinBlepGenerator |
struct | PulseGenerator |
When triggered, holds a high value for a specified time before going low again. More... | |
struct | RealFFT |
Real-valued FFT context. More... | |
struct | RealTimeConvolver |
struct | RingBuffer |
A simple cyclic buffer. More... | |
struct | SampleRateConverter |
Resamples by a fixed rational factor. More... | |
struct | TBiquadFilter |
struct | TExponentialFilter |
Applies exponential smoothing to a signal with the ODE \( \frac{dy}{dt} = x \lambda \). More... | |
struct | TExponentialSlewLimiter |
struct | Timer |
struct | TPeakFilter |
Like ExponentialFilter but jumps immediately to higher values. More... | |
struct | TRCFilter |
The simplest possible analog filter using an Euler solver. More... | |
struct | TSchmittTrigger |
Turns HIGH when value reaches 1.f, turns LOW when value reaches 0.f. More... | |
struct | TSchmittTrigger< float > |
struct | TSlewLimiter |
struct | Upsampler |
Upsamples by an integer factor. More... | |
struct | VuMeter |
Deprecated. More... | |
struct | VuMeter2 |
Models a VU meter with smoothing. More... | |
Typedefs | |
typedef TSchmittTrigger | SchmittTrigger |
typedef TRCFilter | RCFilter |
typedef TExponentialFilter | ExponentialFilter |
typedef TPeakFilter | PeakFilter |
typedef TSlewLimiter | SlewLimiter |
typedef TExponentialSlewLimiter | ExponentialSlewLimiter |
typedef TBiquadFilter | BiquadFilter |
Functions | |
template<typename T > | |
T | approxExp2Floor (T x, T *xf) |
Returns 2^floor(x), assuming that x >= 0. More... | |
template<> | |
simd::float_4 | approxExp2Floor (simd::float_4 x, simd::float_4 *xf) |
template<> | |
float | approxExp2Floor (float x, float *xf) |
template<typename T > | |
T | approxExp2_taylor5 (T x) |
Returns 2^x, assuming that x >= 0. More... | |
float | sinc (float x) |
The normalized sinc function See https://en.wikipedia.org/wiki/Sinc_function. More... | |
template<typename T > | |
T | sinc (T x) |
template<typename T > | |
T | amplitudeToDb (T amp) |
template<typename T > | |
T | dbToAmplitude (T db) |
template<typename T > | |
T | quadraticBipolar (T x) |
template<typename T > | |
T | cubic (T x) |
template<typename T > | |
T | quarticBipolar (T x) |
template<typename T > | |
T | quintic (T x) |
template<typename T > | |
T | sqrtBipolar (T x) |
template<typename T > | |
T | exponentialBipolar (T b, T x) |
This is pretty much a scaled sinh. More... | |
float | convolveNaive (const float *in, const float *kernel, int len) |
Performs a direct sum convolution. More... | |
void | boxcarLowpassIR (float *out, int len, float cutoff=0.5f) |
Computes the impulse response of a boxcar lowpass filter. More... | |
void | minBlepImpulse (int z, int o, float *output) |
Computes the minimum-phase bandlimited step (MinBLEP) z: number of zero-crossings o: oversample factor output: must be length 2 * z * o . More... | |
template<typename T , typename F > | |
void | stepEuler (T t, T dt, T x[], int len, F f) |
The callback function f in each of these stepping functions must have the signature. More... | |
template<typename T , typename F > | |
void | stepRK2 (T t, T dt, T x[], int len, F f) |
Solves an ODE system using the 2nd order Runge-Kutta method. More... | |
template<typename T , typename F > | |
void | stepRK4 (T t, T dt, T x[], int len, F f) |
Solves an ODE system using the 4th order Runge-Kutta method. More... | |
template<typename T > | |
T | hann (T p) |
Hann window function. More... | |
void | hannWindow (float *x, int len) |
Multiplies the Hann window by a signal x of length len in-place. More... | |
template<typename T > | |
T | blackman (T alpha, T p) |
Blackman window function. More... | |
void | blackmanWindow (float alpha, float *x, int len) |
template<typename T > | |
T | blackmanNuttall (T p) |
Blackman-Nuttall window function. More... | |
void | blackmanNuttallWindow (float *x, int len) |
template<typename T > | |
T | blackmanHarris (T p) |
Blackman-Harris window function. More... | |
void | blackmanHarrisWindow (float *x, int len) |
Variables | |
DEPRECATED typedef VuMeter | VUMeter |
static const float | FREQ_C4 = 261.6256f |
static const float | FREQ_A4 = 440.0000f |
static const float | FREQ_SEMITONE = 1.0594630943592953f |
Digital signal processing routines.
typedef TRCFilter rack::dsp::RCFilter |
typedef TPeakFilter rack::dsp::PeakFilter |
typedef TSlewLimiter rack::dsp::SlewLimiter |
typedef TBiquadFilter rack::dsp::BiquadFilter |
T rack::dsp::approxExp2Floor | ( | T | x, |
T * | xf | ||
) |
Returns 2^floor(x), assuming that x >= 0.
If xf
is non-NULL, it is set to the fractional part of x.
|
inline |
|
inline |
T rack::dsp::approxExp2_taylor5 | ( | T | x | ) |
Returns 2^x, assuming that x >= 0.
Maximum 0.00024% error. For float, roughly 3x faster than std::pow(2.f, x)
. For float_4, roughly 2x faster than simd::pow(2.f, x)
.
If negative powers are needed, you may use a lower bound and rescale.
approxExp2(x + 20) / 1048576
|
inline |
The normalized sinc function See https://en.wikipedia.org/wiki/Sinc_function.
T rack::dsp::sinc | ( | T | x | ) |
T rack::dsp::amplitudeToDb | ( | T | amp | ) |
T rack::dsp::dbToAmplitude | ( | T | db | ) |
T rack::dsp::quadraticBipolar | ( | T | x | ) |
T rack::dsp::cubic | ( | T | x | ) |
T rack::dsp::quarticBipolar | ( | T | x | ) |
T rack::dsp::quintic | ( | T | x | ) |
T rack::dsp::sqrtBipolar | ( | T | x | ) |
T rack::dsp::exponentialBipolar | ( | T | b, |
T | x | ||
) |
This is pretty much a scaled sinh.
Slow. Not recommended for parameter scaling.
|
inline |
Performs a direct sum convolution.
|
inline |
Computes the impulse response of a boxcar lowpass filter.
void rack::dsp::minBlepImpulse | ( | int | z, |
int | o, | ||
float * | output | ||
) |
Computes the minimum-phase bandlimited step (MinBLEP) z: number of zero-crossings o: oversample factor output: must be length 2 * z * o
.
void rack::dsp::stepEuler | ( | T | t, |
T | dt, | ||
T | x[], | ||
int | len, | ||
F | f | ||
) |
The callback function f
in each of these stepping functions must have the signature.
void f(T t, const T x[], T dxdt[])
A capturing lambda is ideal for this. For example, the following solves the system x''(t) = -x(t) using a fixed timestep of 0.01 and initial conditions x(0) = 1, x'(0) = 0.
float x[2] = {1.f, 0.f}; float dt = 0.01f; for (float t = 0.f; t < 1.f; t += dt) { rack::ode::stepRK4(t, dt, x, 2, [&](float t, const float x[], float dxdt[]) { dxdt[0] = x[1]; dxdt[1] = -x[0]; }); printf("%f\n", x[0]); }
Solves an ODE system using the 1st order Euler method
void rack::dsp::stepRK2 | ( | T | t, |
T | dt, | ||
T | x[], | ||
int | len, | ||
F | f | ||
) |
Solves an ODE system using the 2nd order Runge-Kutta method.
void rack::dsp::stepRK4 | ( | T | t, |
T | dt, | ||
T | x[], | ||
int | len, | ||
F | f | ||
) |
Solves an ODE system using the 4th order Runge-Kutta method.
|
inline |
Hann window function.
p: proportion from [0, 1], usually i / (len - 1)
https://en.wikipedia.org/wiki/Window_function#Hann_and_Hamming_windows
|
inline |
Multiplies the Hann window by a signal x
of length len
in-place.
|
inline |
Blackman window function.
https://en.wikipedia.org/wiki/Window_function#Blackman_window A typical alpha value is 0.16.
|
inline |
|
inline |
Blackman-Nuttall window function.
https://en.wikipedia.org/wiki/Window_function#Blackman%E2%80%93Nuttall_window
|
inline |
|
inline |
Blackman-Harris window function.
https://en.wikipedia.org/wiki/Window_function#Blackman%E2%80%93Harris_window
|
inline |
DEPRECATED typedef VuMeter rack::dsp::VUMeter |
|
static |
|
static |
|
static |