playgrid.ccRead tutorial

Tutorial 005 / SuperCollider

Build Resonant Pulse Lead in SuperCollider

Build Resonant Pulse Lead in SuperCollider with resonant pulse lead, explicit envelopes and the sound-shaping chain explained in the guide.

4 stepsResonant Pulse LeadSuperCollider

Listen to the finished sound

Download WEBM ↓

Follow the synthesis steps in order. Use the audio examples and device settings alongside the instructions.

Step 01 / 4

Combine the two narrow pulses

Select ~soundStage = 1 and evaluate the full script at the end of this guide. Wait for the instrument-ready message before playing.

Set ~soundStage = 1 in the full script. Use two 25% pulse waves at −6 dB each, with the second two cents flat as an explicit detuning choice. Amplifier and global gains are −6 dB each. The amplitude opens over 8 ms, holds full sustain and releases over 80 ms. The independently retriggered note model omits the source last-note-priority legato and controller-driven vibrato.

SuperCollider control Value
Pulse pair Width 0.25 each; −6 dB each; second −2 cents
Amplitude 8 ms attack; full sustain; 80 ms release
Amplifier / instrument −6 / −6 dB

Sound after step 1 — WebM/Opus

Next: Open the dark resonant filter briefly →

Step 02 / 4

Open the dark resonant filter briefly

Set ~soundStage = 2 in the full script. Use a 220 Hz ladder lowpass with resonance 0.40 and full key tracking. A 5 ms / 143 ms / 0.48 / 143 ms exponential contour moves cutoff by 2.6 octaves. Its short brightness change occurs while the amplitude remains held, giving a pronounced articulation on detached notes.

SuperCollider control Value
Cutoff 220 × 2^(2.6 × envelope + (note−60)/12) Hz
Resonance 0.40
Filter contour 5 ms / 143 ms / 0.48 / 143 ms

For MoogFF, multiply the stated source resonance amount by four to obtain its 0–4 gain argument (limited to 3.95). The complete script gives this gain expression beside each cutoff.

Sound after step 2 — WebM/Opus

Next: Round the signal with saturation →

Step 03 / 4

Round the signal with saturation

Set ~soundStage = 3 in the full script. Use +33 dB drive with 78% shaped signal and -14 dB output trim. The smooth curve is tanh(input × 3 × drive.dbamp) / 3; the other portion stays clean. Louder peaks enter its curved region more strongly, adding harmonics and rounding the envelope. This interprets the source saturation curve rather than implementing its proprietary transfer function.

SuperCollider control Value
Drive / output 33 / -14 dB
Shaped mix 78%
Input DC removal LeakDC, coefficient 0.995

Sound after step 3 — WebM/Opus

Next: Add slow comb movement and echoes →

Step 04 / 4

Add slow comb movement and echoes

Set ~soundStage = 4 in the full script. Sweep opposite delay taps around 1.5 ms by ±0.81 ms at 0.06 Hz. Feedback 78% strengthens the moving comb peaks; 12% wet leaves the lead in front. The explicit short-delay network interprets Phaser-Flanger, with an extra control-block latency in its feedback path. Slowly held notes reveal the sweep. Use 650 ms left and 650 ms right, 21% feedback and 7% wet. Inject the centered input on the left and cross-feed the filtered echoes so later repeats alternate sides. Filter each echo around 632.456 Hz, with a 5.96578-octave interval between highpass and lowpass cutoffs. Feedback values are updated once per server processing block, adding that small delay to the recirculating path. Held notes leave older colors behind the current tone.

SuperCollider control Value
Center / depth 1.5 / ±0.81 ms
Rate / feedback / wet 0.06 Hz / 78% / 12%
Times 650 / 650 ms
Feedback / wet 21% / 7%
Routing Crossed, left input
Filter center / width 632.456 Hz / 5.96578 octaves
Time LFO 0 Hz, ±0%

Sound after step 4 — WebM/Opus

Audio & settings ↓

Audio & settings

Audio recordings and settings for this tutorial.

Full SuperCollider script

The complete Resonant Pulse Lead instrument uses stock SuperCollider units. Set ~soundStage from 1 to 4 and evaluate the entire block again to select a cumulative stage. Wait for the ready message; ~soundNote.(60, 0.8, 1) plays MIDI 60 at velocity 0.8 with a one-second held duration. Held duration controls when release begins, while each source's decay and modulation continue independently. ~soundStop.() frees the active instrument and its effects. This block replaces the previously installed PlayGrid instrument in the same interpreter.

(
~soundStage = 4;
~soundOutputScale = 2.15634;
~soundRelease = 0.143;
~soundNames = (motion: \pgResonantPulseLeadMotion, voice: \pgResonantPulseLeadVoice, effects: \pgResonantPulseLeadEffects);

~soundDefs = [
    SynthDef(\pgResonantPulseLeadMotion, { |out=0| Out.kr(out, DC.kr(0)) }),
    SynthDef(\pgResonantPulseLeadVoice, { |out=0, midi=60, velocity=0.8, gate=1, startMidi=60|
        var stage = ~soundStage;
    var aA = 0, aB = 0, aL = 0, aR = 0, aSource = 0, iHz = 0, iVelocity = 0, kAmp = 0;
    var kAmpDecay = 0, kAmpGate = 0, kCut = 0, kFilter = 0, kFilterDecay = 0, kFilterGate = 0;
    iHz = (midi).midicps;
    iVelocity = (velocity).clip(0, 1);
    aA = (Pulse.ar(iHz, 0.25) * ((0 - 6)).dbamp);
    aB = (Pulse.ar((iHz * (2 ** ((0 - 2) / 1200))), 0.25) * ((0 - 6)).dbamp);
    aSource = (aA + aB);
    if((stage >= 2)) {
    kFilterGate = EnvGen.kr(Env([0, 1, 1], [0.005, 1], \lin));
    kFilterDecay = EnvGen.kr(Env([1, 1, 0.48, 0.000001], [0.005, 0.143, 0.143], \exp, releaseNode: 2), gate);
    kFilter = (kFilterGate * kFilterDecay);
    kCut = ((220 * (2 ** ((2.6 * kFilter) + ((midi - 60) / 12))))).clip(30, 18000);
    aSource = MoogFF.ar(aSource, (kCut).clip(20, 18000), (0.40 * 4).clip(0, 3.95));
    };
    kAmpGate = EnvGen.kr(Env([0, 1, 1], [0.008, 1], \lin));
    kAmpDecay = EnvGen.kr(Env([1, 1, 1, 0.000001], [0.008, 0.08, 0.08], \exp, releaseNode: 2), gate);
    kAmp = (kAmpGate * kAmpDecay);
    aL = ((aSource * kAmp) * ((0 - 12)).dbamp);
    aR = aL;
    Out.ar(out, [aL, aR]);
        EnvGen.kr(Env.asr(0.0001, 1, 0.143), gate, doneAction: 2);
    }),
    SynthDef(\pgResonantPulseLeadEffects, { |in=0, out=0|
        var stage = ~soundStage;
        var outputScale = ~soundOutputScale;
        var input = In.ar(in, 2);
    var feedback = LocalIn.ar(4);
    var aCleanL = 0, aCleanR = 0, aDelFbL = 0, aDelFbR = 0, aDelSendL = 0, aDelSendR = 0, aDelTimeL = 0, aDelTimeR = 0;
    var aEchoL = 0, aEchoR = 0, aFlFbL = 0, aFlFbR = 0, aFlL = 0, aFlR = 0, aFlTimeL = 0, aFlTimeR = 0;
    var aL = 0, aR = 0, aShapeL = 0, aShapeR = 0, kDelCenter = 0, kDelMotion = 0, kFl = 0;
    aL = input[0];
    aR = input[1];
    if((stage >= 3)) {
    aCleanL = LeakDC.ar(aL, 0.995);
    aShapeL = ((((aCleanL * 3) * (33).dbamp)).tanh / 3);
    aL = (((aCleanL * 0.21999999999999997) + (aShapeL * 0.78)) * ((0 - 14)).dbamp);
    aCleanR = LeakDC.ar(aR, 0.995);
    aShapeR = ((((aCleanR * 3) * (33).dbamp)).tanh / 3);
    aR = (((aCleanR * 0.21999999999999997) + (aShapeR * 0.78)) * ((0 - 14)).dbamp);
    };
    if((stage >= 4)) {
    aFlFbL = feedback[0];
    aFlFbR = feedback[1];
    kFl = (SinOsc.kr(0.06, 0 * 2pi) * 1);
    aFlTimeL = K2A.ar((1.5 + (0.81 * kFl)));
    aFlTimeR = K2A.ar((1.5 - (0.81 * kFl)));
    aFlL = DelayC.ar((aL + (aFlFbL * 0.78)), 20 / 1000, (aFlTimeL / 1000).clip(0.00002, 20 / 1000));
    aFlR = DelayC.ar((aR + (aFlFbR * 0.78)), 20 / 1000, (aFlTimeR / 1000).clip(0.00002, 20 / 1000));
    aFlFbL = aFlL;
    aFlFbR = aFlR;
    aL = ((aL * 0.88) + (aFlL * 0.12));
    aR = ((aR * 0.88) + (aFlR * 0.12));
    aDelFbL = feedback[2];
    aDelFbR = feedback[3];
    kDelMotion = 0;
    aDelTimeL = K2A.ar((650.0 * (1 + (0 * kDelMotion))));
    aDelTimeR = K2A.ar((650.0 * (1 - (0 * kDelMotion))));
    aDelSendL = ((aL + aR) * 0.5);
    aDelSendR = 0;
    aEchoL = DelayC.ar((aDelSendL + (aDelFbR * 0.21)), 2200 / 1000, (aDelTimeL / 1000).clip(0.00002, 2200 / 1000));
    aEchoR = DelayC.ar((aDelSendR + (aDelFbL * 0.21)), 2200 / 1000, (aDelTimeR / 1000).clip(0.00002, 2200 / 1000));
    kDelCenter = (632.4555320336759 * (2 ** (0 * kDelMotion)));
    aEchoL = HPF.ar(aEchoL, ((kDelCenter / (2 ** 2.9828921423310435))).clip(20, 18000));
    aEchoL = LPF.ar(aEchoL, ((18000).min((kDelCenter * (2 ** 2.9828921423310435)))).clip(20, 18000));
    aEchoR = HPF.ar(aEchoR, ((kDelCenter / (2 ** 2.9828921423310435))).clip(20, 18000));
    aEchoR = LPF.ar(aEchoR, ((18000).min((kDelCenter * (2 ** 2.9828921423310435)))).clip(20, 18000));
    aDelFbL = aEchoL;
    aDelFbR = aEchoR;
    aL = ((aL * 0.9299999999999999) + (aEchoL * 0.07));
    aR = ((aR * 0.9299999999999999) + (aEchoR * 0.07));
    };
    LocalOut.ar([aFlFbL, aFlFbR, aDelFbL, aDelFbR].collect { |channel| channel + DC.ar(0) });
    Out.ar(out, [((aL * 1) * outputScale), ((aR * 1) * outputScale)]);
    })
];
~soundStop = {
    if(~cirrusGroup.notNil) { ~cirrusGroup.free; ~cirrusGroup = nil };
    if(~cirrusAudio.notNil) { ~cirrusAudio.free; ~cirrusAudio = nil };
    if(~cirrusMotion.notNil) { ~cirrusMotion.free; ~cirrusMotion = nil };
    if(~pgGroup.notNil) { ~pgGroup.free; ~pgGroup = nil };
    if(~pgAudio.notNil) { ~pgAudio.free; ~pgAudio = nil };
    if(~pgMotion.notNil) { ~pgMotion.free; ~pgMotion = nil };
};
~soundInstall = {
    s.waitForBoot {
        ~soundStop.();
        ~soundDefs.do { |definition| definition.add };
        s.sync;
        ~pgAudio = Bus.audio(s, 2);
        ~pgMotion = Bus.control(s, 1);
        ~pgGroup = Group.head(s);
        ~pgLastMidi = 60;
        Synth.head(~pgGroup, ~soundNames.motion, [\out, ~pgMotion]);
        ~pgVoices = Group.tail(~pgGroup);
        Synth.tail(~pgGroup, ~soundNames.effects, [\in, ~pgAudio]);
        "Resonant Pulse Lead ready".postln;
    };
};
~soundNote = { |midi=60, velocity=0.8, hold=1|
    var note = Synth.head(~pgVoices, ~soundNames.voice, [
        \out, ~pgAudio, \midi, midi, \velocity, velocity.clip(0, 1),
        \startMidi, ~pgLastMidi
    ]);
    ~pgLastMidi = midi;
    SystemClock.sched(hold, { note.set(\gate, 0); nil });
    note;
};
if(~soundOffline != true) { ~soundInstall.() };
)