[chuck-users] chuck neophyte trying to remove clicks via Envelope patch

Ryan Wieghard ryan.wieghard at gmail.com
Tue Nov 24 20:02:48 EST 2009


Hello chucKsters,

I am trying to write a simple program that reassigns four sine oscillator's
pitch and volume at each iteration through a while(true) loop.
I decided i didn't want the clicks at the beginning of each note attack, so
I thought that I could remove them by just adding an envelope
to ramp up to the gain value for each event. After trying different values
for the Envelope time and rate, I can't seem to figure out
how to remove the clicks. I apologize as this is probably something obvious
that I am blind to in my myopic state. My intuition is
that if I increased the rate of the envelope the ramp up to 1 would be
smoother and then my speakers wouldn't click. However I am
unsure how to adjust the rate as I don't know what range it would be in.

Sorry for my n00bishness

Ryan.

SinOsc s1 => Envelope e=> dac;
SinOsc s2 => e => dac;
SinOsc s3 => e=> dac;
SinOsc s4 => e=> dac;

//....

 while( true )
 {
  .1 => float t =>e.time;

  //reassign gain

  Std.rand2f(0,1) => float g;
  g => s1.gain;
  g => s2.gain;
  g => s3.gain;
  g => s4.gain;

  //reassign pitch

  Std.mtof(instrumentSet1[Std.rand2(0,6)]) => s1.freq;
  Std.mtof(instrumentSet1[Std.rand2(0,6)]) => s2.freq;
  Std.mtof(instrumentSet1[Std.rand2(0,6)]) => s3.freq;
  Std.mtof(instrumentSet1[Std.rand2(0,6)]) => s4.freq;

  //Advance time by 1 samp
  e.keyOn();
  1000::ms => now;
  e.keyOff();
}


-- 
"Le savant n’étudie pas la nature parce que cela est utile ; il l’étudie
parce qu’il y prend plaisir et il y prend plaisir parce qu’elle est belle."
- Henri Poincaré
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20091124/58571085/attachment.html>


More information about the chuck-users mailing list