signal/filter
low-pass
(low-pass [alpha :float])
first-order IIR low-pass filter Signal Function.
| alpha | smoothing coefficient in (0, 1); lower = more smoothing. |
SF Sample Sample. Each instance owns its own state cell, so the same `(low-pass alpha)` SF is stateful from the moment it is applied to an input signal.
((low-pass 0.3) (sine 440.0 0.0))
high-pass
(high-pass [alpha :float])
first-order IIR high-pass filter Signal Function.
| alpha | smoothing coefficient of the internal low-pass tap | |
| (matches `low-pass`'s convention). |
SF Sample Sample emitting `x - low_pass(x)` per sample.
((high-pass 0.3) (sawtooth 110.0))
one-pole-lp
(one-pole-lp [sample-rate :float freq :float])
one-pole low-pass with its cutoff given in Hz.
| sample-rate | the rate the result will be sampled at, in Hz | |
| freq | cutoff in Hz |
SF Sample Sample (stateful).
((one-pole-lp 48000.0 500.0) input)
one-pole-hp
(one-pole-hp [sample-rate :float freq :float])
one-pole high-pass with its cutoff given in Hz.
| sample-rate | the rate the result will be sampled at, in Hz | |
| freq | cutoff in Hz |
SF Sample Sample (stateful).
((one-pole-hp 48000.0 80.0) input)
dc-block
(dc-block [sample-rate :float freq :float])
remove a constant offset: y = x - x[n-1] + r * y[n-1].
| sample-rate | the rate the result will be sampled at, in Hz | |
| freq | corner frequency in Hz |
SF Sample Sample (stateful).
((dc-block 48000.0 10.0) ((sawtooth 110.0) (constant 0.0)))
biquad
(biquad [b0 :float b1 :float b2 :float a1 :float a2 :float])
second-order section from raw, a0-normalized coefficients.
| b0 b1 b2 -- feedforward coefficients | ||
| a1 a2 -- feedback coefficients (a0 = 1) |
SF Sample Sample (stateful).
((biquad 0.5 0.5 0.0 0.0 0.0) input) ;; two-tap average
biquad-lp
(biquad-lp [sample-rate :float freq :float q :float])
resonant second-order low-pass, 12 dB/oct.
| sample-rate | the rate the result will be sampled at, in Hz | |
| freq | cutoff in Hz | |
| q | resonance; 0.7071 is maximally flat (Butterworth) |
SF Sample Sample (stateful). Unity gain at DC; gain q at `freq`.
((biquad-lp 48000.0 1200.0 0.7071) input)
biquad-hp
(biquad-hp [sample-rate :float freq :float q :float])
resonant second-order high-pass, 12 dB/oct.
| sample-rate | the rate the result will be sampled at, in Hz | |
| freq | cutoff in Hz | |
| q | resonance; 0.7071 is maximally flat |
SF Sample Sample (stateful). Zero gain at DC; unity at Nyquist.
((biquad-hp 48000.0 80.0 0.7071) input)
biquad-bp
(biquad-bp [sample-rate :float freq :float q :float])
second-order band-pass, 0 dB at the center frequency.
| sample-rate | the rate the result will be sampled at, in Hz | |
| freq | center frequency in Hz | |
| q | center / bandwidth; higher is narrower |
SF Sample Sample (stateful).
((biquad-bp 48000.0 1000.0 4.0) noise)
biquad-notch
(biquad-notch [sample-rate :float freq :float q :float])
second-order band-reject: zero gain at `freq`.
| sample-rate | the rate the result will be sampled at, in Hz | |
| freq | the frequency to remove, in Hz | |
| q | center / bandwidth; higher is narrower |
SF Sample Sample (stateful). Unity gain at DC and Nyquist.
((biquad-notch 48000.0 60.0 10.0) input) ;; remove mains hum
biquad-allpass
(biquad-allpass [sample-rate :float freq :float q :float])
second-order allpass: unit gain, phase turns 360 deg.
| sample-rate | the rate the result will be sampled at, in Hz | |
| freq | where the phase passes -180 deg, in Hz | |
| q | how fast the phase turns around `freq` |
SF Sample Sample (stateful). The building block of a phaser.
((biquad-allpass 48000.0 800.0 0.7071) input)
biquad-peak
(biquad-peak [sample-rate :float freq :float q :float gain-db :float])
peaking EQ: boost or cut `gain-db` around `freq`.
| sample-rate | the rate the result will be sampled at, in Hz | |
| freq | center frequency in Hz | |
| q | center / bandwidth | |
| gain-db | gain at `freq`; negative cuts. 0 is a pass-through. |
SF Sample Sample (stateful). Unity gain far from `freq`.
((biquad-peak 48000.0 3000.0 1.0 6.0) input) ;; +6 dB presence
biquad-low-shelf
(biquad-low-shelf [sample-rate :float freq :float q :float gain-db :float])
boost or cut everything below `freq` by `gain-db`.
| sample-rate | the rate the result will be sampled at, in Hz | |
| freq | shelf midpoint in Hz (half the gain, in dB, is reached here) | |
| q | shelf steepness; 0.7071 gives the steepest without overshoot | |
| gain-db | gain at DC |
SF Sample Sample (stateful). Unity gain at Nyquist.
((biquad-low-shelf 48000.0 200.0 0.7071 -6.0) input)
biquad-high-shelf
(biquad-high-shelf [sample-rate :float freq :float q :float gain-db :float])
boost or cut everything above `freq` by `gain-db`.
| sample-rate | the rate the result will be sampled at, in Hz | |
| freq | shelf midpoint in Hz | |
| q | shelf steepness; 0.7071 gives the steepest without overshoot | |
| gain-db | gain at Nyquist |
SF Sample Sample (stateful). Unity gain at DC.
((biquad-high-shelf 48000.0 6000.0 0.7071 3.0) input)
svf-lp
(svf-lp [sample-rate :float ^fat cutoff : (fn [float])
state-variable low-pass, 12 dB/oct, cutoff driven by a signal.
| sample-rate | the rate the result will be sampled at, in Hz | |
| cutoff | Signal of the cutoff in Hz | |
| q | resonance; 0.7071 is maximally flat, higher rings |
SF Sample Sample (stateful).
((svf-lp 48000.0 (constant 800.0) 2.0) saw)
svf-hp
(svf-hp [sample-rate :float ^fat cutoff : (fn [float])
state-variable high-pass, 12 dB/oct, cutoff driven by a signal.
| sample-rate | the rate the result will be sampled at, in Hz | |
| cutoff | Signal of the cutoff in Hz | |
| q | resonance |
SF Sample Sample (stateful).
((svf-hp 48000.0 (constant 200.0) 0.7071) input)
svf-bp
(svf-bp [sample-rate :float ^fat cutoff : (fn [float])
state-variable band-pass, unity gain at the center frequency.
| sample-rate | the rate the result will be sampled at, in Hz | |
| cutoff | Signal of the center frequency in Hz | |
| q | center / bandwidth; higher is narrower |
SF Sample Sample (stateful).
((svf-bp 48000.0 sweep 8.0) noise)
svf-notch
(svf-notch [sample-rate :float ^fat cutoff : (fn [float])
state-variable band-reject, cutoff driven by a signal.
| sample-rate | the rate the result will be sampled at, in Hz | |
| cutoff | Signal of the rejected frequency in Hz | |
| q | center / bandwidth; higher is narrower |
SF Sample Sample (stateful).
((svf-notch 48000.0 (constant 1000.0) 2.0) input)
ladder
(ladder [sample-rate :float ^fat cutoff : (fn [float])
4-pole (24 dB/oct) resonant low-pass, Moog-style topology.
| sample-rate | the rate the result will be sampled at, in Hz | |
| cutoff | Signal of the cutoff in Hz | |
| resonance | feedback amount, clamped to [0, 1] |
SF Sample Sample (stateful).
((ladder 48000.0 (constant 1000.0) 0.5) saw)
Internal definitions
__filter_alloc_state-- allocate a zero-initialized double cell.__filter_lp_step-- low-pass EMA step.__filter_hp_step-- high-pass step.__filter_onepole_alpha-- EMA coefficient for a cutoff in Hz.__filter_dc_step-- DC blocker: y = x - x[n-1] + r * y[n-1].__biquad_coeffs-- compute a normalized RBJ coefficient cell.__biquad_raw_coeffs-- a coefficient cell from caller-supplied values.__biquad_step-- one transposed-direct-form-II step.__biquad_sf-- wrap a coefficient cell as an SF; each application owns state.__svf_step-- one SVF step with the cutoff read for this sample.__svf_sf-- shared body of the svf-* constructors.__ladder_step-- one step of the 4-pole ladder.