[chuck-users] changing a value with a function

Atte André Jensen atte.jensen at gmail.com
Fri Nov 2 12:07:54 EDT 2007


Hi

I'm trying to change a value of something (in this case BPF.freq with a 
function. I'd like to write a function that can be sporked on just aout 
any value, but I can't figure out how.

Below changer() works, but only works on filters freq parameter. 
changer2() obviously doesn't work. Can something like this be done? 
Could the parameter for a ugen be passed by reference?

SndBuf s => BPF f => dac;
s.read("beat.wav");
10 => f.Q;
4200 => f.freq;
5 => f.gain;
function void loop(SndBuf s){
     while(true){
         0 => s.pos;
         s.samples()::samp => now;
     }
}
function void changer(FilterBasic f){
     while(true){
         Std.rand2f(200,1000) => f.freq;
         400::ms => now;
     }
}
function void changer2(float value){
     while(true){
         Std.rand2f(200,1000) => value;
         400::ms => now;
     }
}
spork ~ loop(s);
spork ~ changer(f);
//spork ~ changer2(f.freq);
1::week => now;

-- 
peace, love & harmony
Atte

http://atte.dk       | http://myspace.com/attejensen
http://anagrammer.dk | http://modlys.dk


More information about the chuck-users mailing list