«Doppler Pitch Shift» by kennethflak

on 05 Nov'20 09:09 in effectdopplerpitch shift

A first attempt to port a doppler pitch shifter following this tutorial: https://www.youtube.com/watch?v=uyzY_ZP54pA to SuperCollider from Max.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// 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;
raw 1232 chars (focus & ctrl+a+c to copy)
reception
comments