audio

@audio/filter-comb1.2.0

Comb filter

Comb filter — feedforward (FIR) and feedback (IIR)

Status
calibrated
Updated
Family
filter, 16 packages under it
Plugin
comb, effect, streaming, 3 parameters
Category
effects
Licence
MIT
Dependencies
none
Downloads
2,335 last month
Tests
at least 129 in audiojs/filter's CI, passed at 878f618,

Listen

// "Local Forecast" by Kevin MacLeod (incompetech.com), CC BY 4.0, incompetech.com/music/royalty-free/faq.html
audio('/samples/music/modern/local-forecast.mp3').comb()

// "Local Forecast" by Kevin MacLeod (incompetech.com), CC BY 4.0, incompetech.com/music/royalty-free/faq.html

Parameters

  • effect
  • streaming
  • tail
delay
10 ms
0.05 to 100 ms
gain
0.5
−0.99 to 0.99
type
feedforward, feedback
import comb from '@audio/filter-comb'

Adds a delayed copy of the signal to itself — notches and peaks at harmonics of fs/Df_s / D.

Feedforward: H(z)=1+g⋅z−DH(z) = 1 + g \cdot z^{-D} — dips at f=(2k+1)fs2Df = \frac{(2k+1) f_s}{2D}, depth depends on gg: a true null only at ∣g∣=1|g|=1; the default g=0.5g=0.5 gives a −6 dB-6\,\text{dB} dip, not a notch
Feedback: H(z)=11−g⋅z−DH(z) = \dfrac{1}{1 - g \cdot z^{-D}} — peaks at f=k⋅fsDf = \frac{k \cdot f_s}{D}

comb(buffer, { delay: 100, gain: 0.6, type: 'feedback' })
Param Default
delay — required, delay length in samples (D)
gain 0.5 feedforward/feedback coefficient g
type 'feedforward' 'feedforward' (FIR, dips) or 'feedback' (IIR, peaks)

Pass the same params object on every call — the ring buffer and write pointer persist across blocks:

let params = { delay: 100, gain: 0.6, type: 'feedback' }
for (let buf of stream) comb(buf, params)

The delay is live, read as @audio/effect's delay lines read theirs: a delay between two samples is read between them, and a new one glides across the call from where the last call ended, the read no faster than double speed and no slower than half. A delay longer than the ring holds makes a new ring, empty; the /audio processor makes its ring for the longest delay, 100 ms, so its delay moves without one. Its gain is smoothed (20 ms) and glided sample by sample: a host's ramp of it is one line, the same however the host cuts its calls (it hands each call the value at its first frame, so the line is played 32 frames late); held, it is the value itself. A new type still switches in one sample: feedforward keeps its input in the line and feedback its output, so a fade would need the feedback recursion running at all times.

Use when: flanging, chorus (with modulated delay), Karplus-Strong string synthesis, room mode modeling.


Part of @audio/filter — the filter family umbrella. This README is generated from the umbrella docs.

MIT © audiojs