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;
  • I think I fixed it. Double check it and make sure none of the '<' or '>' are missing. For future reference: meta.music.stackexchange.com/questions/240/… – Dom Sep 27 '14 at 20:17
  • @Dom, thanks! I just hit the pre button on the toolbar, I wasn't aware of this syntax. Thanks for the link :) – Roland Bouman Sep 27 '14 at 20:20
  • 1
    @WheatWilliams sorry - I should've added a reference. It's a programming language for sound synthesis. Added link in question. – Roland Bouman Sep 27 '14 at 21:52
  • 1
    Have you tried asking this on StackOverflow? There's a chuck tag there with 20 followers, perhaps you'll have more luck! – Chris Oct 18 '14 at 23:18
  • 1
    This is just a guess since I don't know anything about chuck, but it could be that the "click" you are hearing is actually an artifact of the physical speakers being unable to keep up with sudden changes. Is there a way you can incorporate some kind of really short crossfade when the frequency is supposed to reset? – meustrus Jan 14 '15 at 21:16

The issue with the click is at the beginning of a cycle your speakers are making a large amplitude jump. The easiest way to alleviate this sort of issue is to write some sort of central mixing code that keeps track of the volume of the whole system. You will also want to write your keep in such a way that volume never jumps values, but always makes a smooth assent. Most like

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.