I'm trying to create a Risset glissando (https://en.wikipedia.org/wiki/Shepard_tone) with chuck (http://chuck.cs.princeton.edu/). The problem is, I keep hearing a very annoying click when the sounds start a new cycle. I tried to get rid of it by not using the extremes of the gain range but it doesn't seem to help. Does anybody have an idea how I get rid of the click? Here's my code:
//low sinsus wave
SinOsc s1 => Gain g1 => dac;
//high sinus wave
SinOsc s2 => Gain g2 => dac;
//a C at 110hz
110.0 => float c;
//octave (2 times our C)
(2 * c) => float o;
//f is our glissando frequency
c => float f;
//g is the gain factor (volume).
f / c => float g;
//gain is from 0..1, gSpace is how much we'll use to vary the gain.
0.8 => float gSpace => float gSpace1 => float gSpace2;
//the amount of gain that define our extremes.
(1-gSpace)/2 => float gMargin;
while (true) {
//increment the frequency (glissando)
f * 1.01 => f;
//if frequency reaches the octave, reset to intial C
if (f >= o) {
<<<"reset" >>>;
c => f;
}
//calculate gain factor. g now varies from 0 to gSpace
((f / c) - 1) * gSpace => g;
//gain for the low sinus wave. Gets louder as frequency increases
gMargin + g => gSpace1;
gSpace1 => g1.gain;
//gain for the hi sinus wave. Gets quieter as frequency increases
gMargin + gSpace - g => gSpace2;
gSpace2 => g2.gain;
//change frequency of low sinus
f => s1.sfreq;
//hi sinus is one octave above low sinus
f*2 => s2.sfreq;
//debug info
<<<"1: ", f, " - ", gSpace1, "; 2: ", 2*f, " - ", gSpace2 >>>;
//make sound
0.1::second => now;
}