PLOrk fall2006/Works/Cows Out To Pasture/combfilter.ck

From CSWiki
Revision as of 22:08, 2 October 2006 by Ssalazar (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

public class CombFilter { UGen @ in; UGen @ out; DelayA d; Pan2 split1, split2; Gain g, g2, g3, master; int active;

fun void init() { adc @=> in; blackhole @=> out; 0 => active;

0 => master.gain;

// set parameters 5::ms => d.delay; 0.05 => g.gain; 0.05 => g2.gain; 0.95 => g3.gain;

in => out; }

fun void connect( UGen @ i, UGen @ o ) { off(); in =< out; i @=> in; o @=> out; in => out; }

fun void on() { if( !active ) { in =< out; in => split1; split1.left => g => d => split2; split2.left => master => out; // feed forward split1.right => g2 => master => out; // feed back split2.right => g3 => d; 1 => active; } }

fun void off() { if( active ) { in =< split1; split1.left =< g =< d =< split2; split2.left =< master =< out; split1.right =< g2 =< master =< out; split2.right =< g3 =< d; in => out; 0 => active; } }

fun float freq( float f ) { (1/f)::second => d.delay; return f; }

fun float freq() { return 1::second/d.delay(); }

fun float gain( float g ) { g => master.gain; }

fun float gain() { return master.gain(); } };