Marotte
Joined: Dec 03, 2007 Posts: 2 Location: Tibet
|
Posted: Mon Dec 10, 2007 1:52 pm Post subject:
ChucK exploration |
|
|
Hi,
So I post my second chuck piece, I made a silly FM synth :
Code: |
second / samp => float samplerate;
<<< "Samplerate :",samplerate >>>;
145. => float tempo;
minute / tempo => dur beat;
4 * beat => dur tick;
class MathFX
{
Dyno limiter; limiter.limit();
SinOsc o; o.gain (0);
120. => o.freq;
o => limiter => dac;
fun void play ()
{
<<< "Fun play () started" >>>;
o.freq () => float initialfreq;
// KEY ON ...
while (o.gain() < .999)
{
o.gain () + .001 => o.gain; // Find how to make an exponential attack, linear for now.
samp => now;
<<< o.gain () >>>;
}
// Do something...
.0 => float x;
Math.rand2f (.25,12) => float len;
while (x < len)
{
.0072 + x + (Math.rand2f(.001,.01)*x)=> x;
<<< x,o.freq (),o.gain () >>>;
40 + Math.rand2(18,36) * Math.exp(Math.exp(Math.sin(3*x))-Math.sqrt(x/16)) => o.freq;
6::ms + .04*x::ms => now;
}
//////
// KEY OFF...
while (o.gain() > 0.01)
{
o.gain () - (Math.exp(.007*o.gain())-1) => o.gain;
samp => now;
<<< o.gain () >>>;
}
initialfreq => o.freq;
<<< "Fun play () finished" >>>;
}
}
MathFX fx1;
while (1)
{
fx1.play();
while (now % beat > samp) samp => now; // Wait next beat :)
}
|
I find very interesting in chuck that you can modulate anything just anyway you want Adding randomness for fun this is useful I think.
I did not use ADSR this time because I discovered something anoying with them : Let's say you have SinOsc o => ADSR env => dac;
If you "env.keyOn();" then modulate o frequency, when you "env.keyOff ()", o frequency automatically return to the initial freq to do the release
In addition, the poor attack stuff I made is totally dumb,because freq modulation only start then attack is finished, the constant initial osc freq is used during attack...
Cheer's
Stef |
|