// title: Doppler Pitch Shift // author: kennethflak // description: // A first attempt to port a doppler pitch shifter following this tutorial: https://www.youtube.com/watch?v=uyzY_ZP54pA to SuperCollider from Max. // code: // made for circular speakers. Change number of speakers to match your setup. ~numSpeakers = 2; ( SynthDef(\dopplerPithchShift, { var sig, env, phasor, buf, hanning, window, phasorfreq, phase, iphase, ratio, numDelays=8, delaywindow=0.1; hanning = Signal.hanningWindow(512).asWavetable; buf = LocalBuf.newFrom(hanning); phasorfreq = ((\ratio.kr(1) - 1 ) * -1) / delaywindow; window = numDelays.collect{|i| phase = i.linlin(0, numDelays+1, 0, 2pi); Osc.kr(buf, phasorfreq, phase) ; }; env = EnvGen.kr(Env.asr(\attack.kr(0.01), 1, \release.kr(0.01)), gate: \gate.kr(1), doneAction: \da.kr(2)); phasor = numDelays.collect {|i| iphase = i.linlin(0, numDelays+1, 1, 3).mod(2); LFSaw.ar(phasorfreq, iphase).range(0, 1) * delaywindow; }; sig = In.ar(\in.kr(2)); sig = numDelays.collect{|i| DelayC.ar(sig, 0.4, delaytime: phasor[i]) * window[i]}; sig = sig.sum; sig = sig * \amp.kr(1, 0.1) * env; sig = PanAz.ar(~numSpeakers, sig, \pan.kr(0), width: \width.kr(2)); Out.ar(\out.kr(0), sig); }).add; ) // test d = Synth(\dopplerPithchShift, [\in, 2, \amp, 4, \ratio, -12.midiratio]); d.set(\ratio, 12.midiratio); d.free;