playgrid.ccRead tutorial

Tutorial 022 / SuperCollider

Build Apricot Pulse in SuperCollider

Build Apricot Pulse in SuperCollider with pulse keys, explicit envelopes and the sound-shaping chain explained in the guide.

5 stepsPulse KeysSuperCollider

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 / 5

Build the pulse-key amplitude contour

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. Use Pulse.ar with a fixed pulse width of 0.32 and oscillator gain −7 dB. The unequal duty cycle supplies a hollow but bright harmonic shape.

Multiply the gate and exponential envelope. The gate rises over 5 ms; after that opening interval, the decay falls toward 0.15 over 1.40 s. Note-off starts a 420 ms exponential release to a quiet positive floor. Apply −6 dB amplifier gain and −7 dB instrument gain, then multiply by velocity squared. This explicit touch curve interprets Analog's velocity response rather than copying its internal scaling. The pulse remains centered, with no unison or glide.

Sound after step 1 — WebM/Opus

Next: Add an octave sine and a closing resonant lowpass →

Step 02 / 5

Add an octave sine and a closing resonant lowpass

Set ~soundStage = 2. Add a sine one octave above the pulse at −22 dB, then send both sources into the same 24 dB/octave ladder lowpass.

Build kFilter from a 5 ms attack gate and an exponential decay to 0.08 over 320 ms, with a 250 ms release. Interpreting depth 2.30 as octaves gives a bright initial opening that closes much faster than the amplitude. Key tracking is 0.70 octaves per keyboard octave around MIDI 60. The soft input curve and resonance 0.16 interpret Analog's Sym1 and resonance controls. The ladder is a different filter design, so its response is not identical to Analog's.

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: Give the keys a light stereo chorus →

Step 03 / 5

Give the keys a light stereo chorus

Set ~soundStage = 3. Highpass only the chorus input at 180 Hz; keep the direct pulse body full-band. Modulate two delay taps around 12 ms by ±2.4 ms, with opposite motion at 0.32 Hz.

Mix 82% direct and 18% chorus in each channel. The moving taps give sustained portions a slight stereo pitch shimmer, while the input highpass reduces low-end blur. The 2.4 ms excursion is a SuperCollider choice for the source Amount 12%; it is not a literal percentage-to-time conversion.

Sound after step 3 — WebM/Opus

Next: Place the keys in a compact room →

Step 04 / 5

Place the keys in a compact room

Set ~soundStage = 4 and evaluate the full block. Feed the preceding signal into FreeVerb2, using its fully wet output and the dry/wet routing shown in the script. The room continues after individual note envelopes release. Predelay separates the initial articulation from the diffuse tail; the external wet mix controls how far that tail moves forward.

The SuperCollider room value is 0.639344 and damping is 0.71875. These dimensionless settings are choices for this algorithm, rather than equivalent values for Ableton decay or Csound feedback and damping. More damping darkens the circulating highs. Any input filters and mid/side width changes in this stage retain their own explicit settings in the full script.

SuperCollider room control Value
FreeVerb2 internal mix 1, wet output only
Room 0.639344
Damping 0.71875
Predelay 12 ms
External room wet 17%

Sound after step 4 — WebM/Opus

Next: Set the final gain and remove DC →

Step 05 / 5

Set the final gain and remove DC

Set ~soundStage = 5. Apply +4.80 dB and LeakDC to each output channel. Keep the chorus and room's stereo image unchanged; no bass narrowing is added.

The gain follows both effects, so it raises the short pulse body and the diffuse tail together. The shared effects Synth continues through note releases. The finished keys have a sharp harmonic opening, a softer sustained body and a light stereo halo.

Sound after step 5 — WebM/Opus

Audio & settings ↓

Audio & settings

Audio recordings and settings for this tutorial.

Full SuperCollider script

The complete Apricot Pulse instrument uses stock SuperCollider units. Set ~soundStage from 1 to 5 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 = 5;
~soundOutputScale = 1.086293;
~soundRelease = 0.42;
~soundNames = (motion: \pgApricotPulseMotion, voice: \pgApricotPulseVoice, effects: \pgApricotPulseEffects);

~soundDefs = [
    SynthDef(\pgApricotPulseMotion, { |out=0| Out.kr(out, DC.kr(0)) }),
    SynthDef(\pgApricotPulseVoice, { |out=0, midi=60, velocity=0.8, gate=1, startMidi=60|
        var stage = ~soundStage;
    var aAmp = 0, aAttack = 0, aDecay = 0, aDrive = 0, aOctave = 0, aPulse = 0, aSource = 0, iHz = 0;
    var iVelocity = 0, kAttack = 0, kCutoff = 0, kDecay = 0, kFilter = 0;
    iHz = (midi).midicps;
    iVelocity = (velocity).clip(0, 1);
    aPulse = (Pulse.ar(iHz, 0.32) * ((0 - 7)).dbamp);
    aSource = aPulse;
    if((stage >= 2)) {
    aOctave = (SinOsc.ar((iHz * 2), 0 * 2pi) * ((0 - 22)).dbamp);
    aSource = (aSource + aOctave);
    kAttack = EnvGen.kr(Env([0, 1, 1], [0.005, 1], \lin));
    kDecay = EnvGen.kr(Env([1, 1, 0.08, 0.000001], [0.005, 0.320, 0.250], \exp, releaseNode: 2), gate);
    kFilter = (kAttack * kDecay);
    kCutoff = ((950 * (2 ** ((2.30 * kFilter) + ((0.70 * (midi - 60)) / 12))))).clip(30, 18000);
    aDrive = (((aSource * 1.3)).tanh / 1.3);
    aSource = MoogFF.ar(aDrive, (kCutoff).clip(20, 18000), (0.16 * 4).clip(0, 3.95));
    };
    aAttack = EnvGen.ar(Env([0, 1, 1], [0.005, 1], \lin));
    aDecay = EnvGen.ar(Env([1, 1, 0.15, 0.000001], [0.005, 1.40, 0.420], \exp, releaseNode: 2), gate);
    aAmp = ((((aAttack * aDecay) * ((0 - 6)).dbamp) * ((0 - 7)).dbamp) * (iVelocity ** 2));
    Out.ar(out, [(aSource * aAmp), (aSource * aAmp)]);
        EnvGen.kr(Env.asr(0.0001, 1, 0.42), gate, doneAction: 2);
    }),
    SynthDef(\pgApricotPulseEffects, { |in=0, out=0|
        var stage = ~soundStage;
        var outputScale = ~soundOutputScale;
        var input = In.ar(in, 2);
    var aChorusL = 0, aChorusR = 0, aHigh = 0, aLeft = 0, aMixL = 0, aMixR = 0, aPreL = 0, aPreR = 0;
    var aRight = 0, aRoomL = 0, aRoomR = 0, aTimeL = 0, aTimeR = 0, kMotion = 0, room17 = 0;
    aLeft = input[0];
    aRight = input[0];
    if((stage >= 3)) {
    aHigh = HPF.ar(input[0], (180).clip(20, 18000));
    kMotion = (SinOsc.kr(0.32, 0 * 2pi) * 1);
    aTimeL = K2A.ar((12 + (2.4 * kMotion)));
    aTimeR = K2A.ar((12 - (2.4 * kMotion)));
    aChorusL = DelayC.ar(aHigh, 40 / 1000, (aTimeL / 1000).clip(0.00002, 40 / 1000));
    aChorusR = DelayC.ar(aHigh, 40 / 1000, (aTimeR / 1000).clip(0.00002, 40 / 1000));
    aLeft = ((input[0] * 0.82) + (aChorusL * 0.18));
    aRight = ((input[0] * 0.82) + (aChorusR * 0.18));
    };
    aMixL = aLeft;
    aMixR = aRight;
    if((stage >= 4)) {
    aPreL = DelayN.ar(aLeft, 0.012, 0.012);
    aPreR = DelayN.ar(aRight, 0.012, 0.012);
    room17 = FreeVerb2.ar(aPreL, aPreR, 1, 0.639344, 0.71875);
    aRoomL = room17[0];
    aRoomR = room17[1];
    aMixL = ((aLeft * 0.83) + (aRoomL * 0.17));
    aMixR = ((aRight * 0.83) + (aRoomR * 0.17));
    };
    if((stage >= 5)) {
    aMixL = LeakDC.ar((aMixL * (4.80).dbamp), 0.995);
    aMixR = LeakDC.ar((aMixR * (4.80).dbamp), 0.995);
    };
    Out.ar(out, [(aMixL * outputScale), (aMixR * 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]);
        "Apricot Pulse 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.() };
)