JSFX - CookDSP version 0.5 documentation



COMB

Reverberates an input signal with a colored frequency response.

Description

Comb creates a comb filter with peaks in the spectrum located at all multiples of 1 / delay time. This kind of filter is often used in simple digital reverb implementations.
It must be used with a variable name as prefix (object oriented).

Initializer

comb(delay, feed)

Initializes acomb filter with frequency as the inverse of the delay time delay, in seconds, and feedback feed, between 0 and 1.

Methods

comb_set_delay(delay)

Sets a new delay time, in seconds.

comb_set_feed(feed)

Sets a new feedback factor, between 0 and 1.

comb_do(signal)

Processes one samples of an input signal signal and outputs the filtered sample.

Example

desc:Schroeder Reverb 2

import cookdsp.jsfx-inc

slider1:3500<500,10000>Lowpass Cutoff
slider2:0.2<0,1>Balance Dry/Wet

@init
// Left ch. comb filters        Right ch. comb filters
c1L.comb(0.0297, 0.65);         c1R.comb(0.0277, 0.65);
c2L.comb(0.0371, 0.51);         c2R.comb(0.0393, 0.51);
c3L.comb(0.0411, 0.5);          c3R.comb(0.0409, 0.5);
c4L.comb(0.0137, 0.73);         c4R.comb(0.0155, 0.73);
// Left ch. allpass filters     Right ch. allpass filters
a1L.allpass(0.005, 0.75);       a1R.allpass(0.00507, 0.75);
a2L.allpass(0.0117, 0.61);      a2R.allpass(0.0123, 0.61);
// Left ch. lowpass filter      Right ch. lowpass filter
lpL.lop(3500);                  lpR.lop(3500);

@slider
lpL.lop_set_freq(slider1);
lpR.lop_set_freq(slider1);

@sample
// Left ch. comb filters        Right ch. comb filters
sig1L = c1L.comb_do(spl0);      sig1R = c1R.comb_do(spl1);
sig2L = c2L.comb_do(spl0);      sig2R = c2R.comb_do(spl1);
sig3L = c3L.comb_do(spl0);      sig3R = c3R.comb_do(spl1);
sig4L = c4L.comb_do(spl0);      sig4R = c4R.comb_do(spl1);
// Comb filters summation
sumL = spl0 + sig1L + sig2L + sig3L + sig4L;
sumR = spl1 + sig1R + sig2R + sig3R + sig4R;
// Left ch. allpass filters     Right ch. allpass filters
all1L = a1L.allpass_do(sumL);   all1R = a1R.allpass_do(sumR);
all2L = a2L.allpass_do(all1L);  all2R = a2R.allpass_do(all1R);
// Left ch. lowpass filter      Right ch. lowpass filter
sigL = lpL.lop_do(all2L) * .2;  sigR = lpR.lop_do(all2R) * .2;
// Balance and output
spl0 = spl0 + (sigL - spl0) * slider2;
spl1 = spl1 + (sigR - spl1) * slider2;

Download example : cookdsp_comb

See the source file : filters.jsfx-inc

(c) Olivier BĂ©langer, 2020