[chuck-users] all pass filters (Michael Heuer)

Perry Cook prc at CS.Princeton.EDU
Wed Nov 25 13:29:32 EST 2015

ChucK definitely has all you need!  ChucK is “DSP Complete”
(like Turing Complete for computational engines/languages),
because since ChucK allows for single-sample connections 
and manipulations, then we don’t provide lots of flavors of
things.  You can build from primitives.  Like a RISC computer.
Some things you mentioned are available:

First and 2nd order AllPass are available via the PoleZero (1st) and 
BiQuad (2nd) UGens.  You just need to set the coefficients explicitly.

Tapped Delay lines can be implemented using multiple Delay elements.
Yea it wastes some memory, but not too much, and works just great:

// Taps.ck     Tapped Delay via separate delays
//       by Perry R. Cook, 2015
//   Caution about adc => dac!!! Use headphones
Delay taps[10];
Pan2 pans[10];
for (int i; i < 10; i++)  {
    adc => taps[i] => pans[i] => dac;
    Math.random2f(-1.0,1.0) => pans[i].pan; // stereo early reflections
    Math.random2(20,200) => int tapMs;      // random path lengths
    tapMs :: ms => taps[i].max => taps[i].delay;
    10.0/tapMs => taps[i].gain;                  // 1/distance gain
10*second => now;

AllPass CombFilter can be accomplished with a single delay line and
one Gain connecting input to mix with output, and another Gain mixing 
output back into input.  You might want to be cautious about the extra 
sample gained when feeding back, but for long delays, it doesn’t really 
make much difference.  If you strictly want a true allpass comb, then 
one extra sample of delay from inlet to your main delay, feeding the 
fbGain back into the 2nd delay line rather than the first, should take 
care of it.  For reverb purposes, this super simple AllPassComb might do:

//  Simple AllPassComb.ck    by Perry R. Cook, 2015
//   NOTE:  this has one sample different delay forward vs. back
//        Easily fixed, but really doesn’t much matter for long enough delays
public class AllPassComb extends Chubgraph  {
    inlet => Delay dl => outlet;
    outlet => Gain fb => dl;
    inlet => Gain ff => outlet;
    0.5 => coeff;
    50::ms => delay;
    fun float coeff(float c)  { 
        -c => fb.gain;
        c => ff.gain;
        return c;
    fun float coeff()  { return fb.gain(); }
    fun dur delay(dur d) { d => dl.max => dl.delay; }
//  Noise n => AllPassComb ap => dac;
adc => AllPassComb ap => dac;  // caution here, use headphones!!!
10*second => now;


More information about the chuck-users mailing list