Tom Says: Safe code is boring code! Why??
Previous page:
Daily Crap 2009-12-08
Next page:
Daily Crap 2009-12-15
ChucK distortion patch, mark II: max slew rate. Heck yes.
fun void distort(UGen source, UGen dest) {
source => blackhole;
Impulse i => dest;
0 => float last;
.1 => float max_slew;
while(1::samp => now) {
// make roundy
source.last() => float in => float out;
if(in >= 1) 2./3. => out;
else if(in <= -1) -2./3. => out;
else in - (in*in*in)/3. => out;
if(Math.fabs(out - last) > max_slew) {
if(out < last) last - max_slew => out;
else last + max_slew => out;
}
out * 3./2. => i.next;
}
}
adc => Delay d;
10 => adc.gain;
1::second => d.max => d.delay;
distort(d, dac);Posted Dec 10, 2009, in the morning.