{
   "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.",
   "ancestor_list" : [],
   "author" : "kennethflak",
   "name" : "Doppler Pitch Shift",
   "is_private" : null,
   "id" : "1-5ef",
   "code" : "// made for circular speakers. Change number of speakers to match your setup.\r\n~numSpeakers = 2;\r\n(\r\nSynthDef(\\dopplerPithchShift, {\r\n    var sig, env, phasor, buf, hanning, window, phasorfreq, phase, iphase, ratio, numDelays=8, delaywindow=0.1;\r\n    hanning = Signal.hanningWindow(512).asWavetable;\r\n    buf = LocalBuf.newFrom(hanning);\r\n    phasorfreq = ((\\ratio.kr(1) - 1 ) * -1) / delaywindow;\r\n    window = numDelays.collect{|i|\r\n        phase = i.linlin(0, numDelays+1, 0, 2pi);\r\n        Osc.kr(buf, phasorfreq, phase) ;\r\n    };\r\n    env = EnvGen.kr(Env.asr(\\attack.kr(0.01), 1, \\release.kr(0.01)), gate: \\gate.kr(1), doneAction: \\da.kr(2));\r\n    phasor = numDelays.collect {|i|\r\n        iphase = i.linlin(0, numDelays+1, 1, 3).mod(2);\r\n        LFSaw.ar(phasorfreq, iphase).range(0, 1) * delaywindow;\r\n    };\r\n    sig = In.ar(\\in.kr(2));\r\n    sig = numDelays.collect{|i| DelayC.ar(sig, 0.4, delaytime: phasor[i]) * window[i]};\r\n    sig = sig.sum;\r\n    sig = sig * \\amp.kr(1, 0.1) * env;\r\n    sig = PanAz.ar(~numSpeakers, sig, \\pan.kr(0), width: \\width.kr(2));\r\n    Out.ar(\\out.kr(0), sig);\r\n}).add;\r\n)\r\n\r\n// test\r\nd = Synth(\\dopplerPithchShift, [\\in, 2, \\amp, 4, \\ratio, -12.midiratio]);\r\nd.set(\\ratio, 12.midiratio);\r\nd.free;",
   "labels" : [
      "effect",
      "doppler",
      "pitch shift"
   ]
}
