Unwanted Clicking in Shepards Tone Patch

Hi,
I’m in the process of creating a Shepard’s tone patch. I’m aware that Eli Fieldsteel and others have done this, but I wanted to do it myself as an exercise for learning sc. My version seems to work well enough, except for small clicks whenever the cycle restarts. Patch is below. Any guidance would be greatly appreciated!

SynthDef.new(\Shepard, {
arg speed = 0.2, fund = 300;
var lowMidFreq, highMidFreq, lowMidAmp, highMidAmp, lowMid, highMid, sig;
lowMidFreq = fund*(LFSaw.ar(speed, 1).range(0.5,1));
highMidFreq = fund*(LFSaw.ar(speed, 1).range(1,2));
lowMidAmp = LFSaw.ar(speed, 1).range(0, 1)* AmpComp.ar(lowMidFreq);
highMidAmp = LFSaw.ar(speed, 1).range(1, 0)* AmpComp.ar(highMidFreq);
lowMid = SinOsc.ar(lowMidFreq)*lowMidAmp;
highMid = SinOsc.ar(highMidFreq)*highMidAmp;
sig = ((lowMid+highMid)/3)!2;
Out.ar(0, sig);
}).add;)

I’ve also tried subbing out LFSaw for SawDPW and a version that uses Impulse and Phasor. With LFSaw the clicks are not present at first but slowly creep in and become worse and worse. With SawDPW, the clicks are less audible, but are always there. With Phasor the clicks are always there and even worse than LFSaw. Changing the rate to LFSaw.kr and AmpComp.kr, and low-passing the Amplitude functions also both make things worse.

In a Shepard tone, each sine component fades in from silence over half the duration, and fades back to silence in the other half. Your amplitudes rise over the full duration and then jump instantly to silence. That will cause clicks.

At the moment when the sine frequency resets, the amplitude should be 0 both before and after the transition.

hjh

1 Like

Ah I guess I misunderstood the effect. I am still wondering why it does not click at first but then begins to click after several cycles. Any guesses?