No matching definitions.

signal/filter

src/signal/filter.tur
defn

low-pass

(low-pass [alpha :float])

first-order IIR low-pass filter Signal Function.

alphasmoothing 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))
defn

high-pass

(high-pass [alpha :float])

first-order IIR high-pass filter Signal Function.

alphasmoothing 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))
defn

one-pole-lp

(one-pole-lp [sample-rate :float freq :float])

one-pole low-pass with its cutoff given in Hz.

sample-ratethe rate the result will be sampled at, in Hz
freqcutoff in Hz

SF Sample Sample (stateful).

((one-pole-lp 48000.0 500.0) input)
defn

one-pole-hp

(one-pole-hp [sample-rate :float freq :float])

one-pole high-pass with its cutoff given in Hz.

sample-ratethe rate the result will be sampled at, in Hz
freqcutoff in Hz

SF Sample Sample (stateful).

((one-pole-hp 48000.0 80.0) input)
defn

dc-block

(dc-block [sample-rate :float freq :float])

remove a constant offset: y = x - x[n-1] + r * y[n-1].

sample-ratethe rate the result will be sampled at, in Hz
freqcorner frequency in Hz

SF Sample Sample (stateful).

((dc-block 48000.0 10.0) ((sawtooth 110.0) (constant 0.0)))
defn

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
defn

biquad-lp

(biquad-lp [sample-rate :float freq :float q :float])

resonant second-order low-pass, 12 dB/oct.

sample-ratethe rate the result will be sampled at, in Hz
freqcutoff in Hz
qresonance; 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)
defn

biquad-hp

(biquad-hp [sample-rate :float freq :float q :float])

resonant second-order high-pass, 12 dB/oct.

sample-ratethe rate the result will be sampled at, in Hz
freqcutoff in Hz
qresonance; 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)
defn

biquad-bp

(biquad-bp [sample-rate :float freq :float q :float])

second-order band-pass, 0 dB at the center frequency.

sample-ratethe rate the result will be sampled at, in Hz
freqcenter frequency in Hz
qcenter / bandwidth; higher is narrower

SF Sample Sample (stateful).

((biquad-bp 48000.0 1000.0 4.0) noise)
defn

biquad-notch

(biquad-notch [sample-rate :float freq :float q :float])

second-order band-reject: zero gain at `freq`.

sample-ratethe rate the result will be sampled at, in Hz
freqthe frequency to remove, in Hz
qcenter / 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
defn

biquad-allpass

(biquad-allpass [sample-rate :float freq :float q :float])

second-order allpass: unit gain, phase turns 360 deg.

sample-ratethe rate the result will be sampled at, in Hz
freqwhere the phase passes -180 deg, in Hz
qhow 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)
defn

biquad-peak

(biquad-peak [sample-rate :float freq :float q :float gain-db :float])

peaking EQ: boost or cut `gain-db` around `freq`.

sample-ratethe rate the result will be sampled at, in Hz
freqcenter frequency in Hz
qcenter / bandwidth
gain-dbgain 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
defn

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-ratethe rate the result will be sampled at, in Hz
freqshelf midpoint in Hz (half the gain, in dB, is reached here)
qshelf steepness; 0.7071 gives the steepest without overshoot
gain-dbgain at DC

SF Sample Sample (stateful). Unity gain at Nyquist.

((biquad-low-shelf 48000.0 200.0 0.7071 -6.0) input)
defn

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-ratethe rate the result will be sampled at, in Hz
freqshelf midpoint in Hz
qshelf steepness; 0.7071 gives the steepest without overshoot
gain-dbgain at Nyquist

SF Sample Sample (stateful). Unity gain at DC.

((biquad-high-shelf 48000.0 6000.0 0.7071 3.0) input)
defn

svf-lp

(svf-lp [sample-rate :float ^fat cutoff : (fn [float])

state-variable low-pass, 12 dB/oct, cutoff driven by a signal.

sample-ratethe rate the result will be sampled at, in Hz
cutoffSignal of the cutoff in Hz
qresonance; 0.7071 is maximally flat, higher rings

SF Sample Sample (stateful).

((svf-lp 48000.0 (constant 800.0) 2.0) saw)
defn

svf-hp

(svf-hp [sample-rate :float ^fat cutoff : (fn [float])

state-variable high-pass, 12 dB/oct, cutoff driven by a signal.

sample-ratethe rate the result will be sampled at, in Hz
cutoffSignal of the cutoff in Hz
qresonance

SF Sample Sample (stateful).

((svf-hp 48000.0 (constant 200.0) 0.7071) input)
defn

svf-bp

(svf-bp [sample-rate :float ^fat cutoff : (fn [float])

state-variable band-pass, unity gain at the center frequency.

sample-ratethe rate the result will be sampled at, in Hz
cutoffSignal of the center frequency in Hz
qcenter / bandwidth; higher is narrower

SF Sample Sample (stateful).

((svf-bp 48000.0 sweep 8.0) noise)
defn

svf-notch

(svf-notch [sample-rate :float ^fat cutoff : (fn [float])

state-variable band-reject, cutoff driven by a signal.

sample-ratethe rate the result will be sampled at, in Hz
cutoffSignal of the rejected frequency in Hz
qcenter / bandwidth; higher is narrower

SF Sample Sample (stateful).

((svf-notch 48000.0 (constant 1000.0) 2.0) input)
defn

ladder

(ladder [sample-rate :float ^fat cutoff : (fn [float])

4-pole (24 dB/oct) resonant low-pass, Moog-style topology.

sample-ratethe rate the result will be sampled at, in Hz
cutoffSignal of the cutoff in Hz
resonancefeedback 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.