[chuck-users] Code that DOES modulate filter cutoff with ADSR
Loscha
loscha at gmail.com
Sun Jun 3 06:50:11 EDT 2007
My answer is kind of a hack, but, it's working quite well.
Use a Step waveform set to 1 at all times, have THAT 1 divided by the ADSR
for the filter, then, my above code works like a charm!
You could also, for example, spork off a different function that randomly
triggered the filter's ADSR independently from the amplitude's ADSR, giving
you all sorts of trance techno type patterns.
Hope this helps you out, Josh, and other users.
-Edward
// Filter Wooby Wooby Woo
BlitSaw bs;
LPF lpf;
ADSR amp;
ADSR filt;
Gain fg;
amp.set( 1::ms, 350::ms, .2, 500::ms );
filt.set( 15::ms, 550::ms, 0, 400::ms );
Step s;
s => filt;
// 1 => s.value;
1 => s.next;
bs => amp => lpf => dac;
filt => fg => blackhole;
10 => fg.gain;
500 => lpf.freq;
2 => lpf.Q;
spork ~ filteradsr ();
for (int l; l < 32; l++)
{
<<<"L;",l,"">>>;
spork ~ playanote ( Std.rand2(30,60) );
800::ms => now;
}
fun void playanote (int nnum)
{
int mstodie;
<<<"\n\n",nnum,"">>>;
nnum => Std.mtof => bs.freq;
<<<"On","">>>;
amp.keyOn();
filt.keyOn();
Std.rand2(150,300) => mstodie;
mstodie * 1::ms => now;
<<<"Off","">>>;
amp.keyOff();
filt.keyOff();
}
fun void filteradsr ()
{
while (true)
{
float currfilt;
filt.last() * 800 + 250 => currfilt;
currfilt => lpf.freq;
//if (maybe) <<<filt.last(),currfilt>>>;
1::ms => now;
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20070603/9732083d/attachment.htm
More information about the chuck-users
mailing list