playgrid.ccRead tutorial

Tutorial 103 / SuperCollider

Build Pewter Loom in SuperCollider

Build Pewter Loom in SuperCollider with subtractive bass, explicit envelopes and the sound-shaping chain explained in the guide.

4 stepsSubtractive BassSuperCollider

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

Build the first oscillator and touch 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 in the full script. Use saw at -6 dB with pulse width 50% when applicable. The contour has 0.005 s attack, 0.799 s exponential decay to 0.65 sustain and 0.114 s release. Multiply by velocity^2.5; this explicit power curve interprets the source velocity response. Keep the signal centered before adding effects.

SuperCollider control Value
Source Saw, -6.0 dB; width not used
Amplitude A/D/S/R 0.005 / 0.799 / 0.65 / 0.114
Amplifier / instrument -6.0 dB / -6.0 dB
Velocity power 2.5

Sound after step 1 — WebM/Opus

Next: Add the second oscillator and resonant contour →

Step 02 / 4

Add the second oscillator and resonant contour

Set ~soundStage = 2 in the full script. Add rect at -12 dB, tuned by 0 octaves. Use a Low-pass 24dB/oct interpretation with 455 Hz base cutoff, 3.2 octave envelope depth and 0.5 octave-per-octave pitch tracking. The contour opens then settles quickly while the amplitude remains. Smooth input drive interprets Sym1; the ladder or second-order lowpass is a different circuit. The 1.7 Hz LFO, where enabled, restarts per note rather than running freely.

SuperCollider control Value
Second source Rect; -12 dB; width 25 %
Filter base / source resonance 455 Hz / 0.52
Filter A/D/S/R 0.005 / 0.21 / 0.08 / 0.13
Envelope / key / LFO depth 3.2 / 0.5 / 0.12 octaves
LFO rate 1.7 Hz
Filter input shape tanh(input × 1.4) / 1.4

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 +3 dB drive with 70% shaped signal and -3 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 3 / -3 dB
Shaped mix 70%
Input DC removal LeakDC, coefficient 0.995

Sound after step 3 — WebM/Opus

Next: Set the final width and gain →

Step 04 / 4

Set the final width and gain

Set ~soundStage = 4 in the full script. Use 3.05 dB gain after the effects. Average the channels for identical mono outputs. Apply LeakDC DC removal with coefficient 0.995. The fixed ~soundOutputScale gain follows the complete effect chain at every stage. The effects Synth reads the stereo bus after the note group, and continues through note releases.

SuperCollider control Value
Final gain 3.05 dB
Width Mono
Bass side cutoff Off
DC removal LeakDC, coefficient 0.995

Sound after step 4 — WebM/Opus

Audio & settings ↓

Audio & settings

Audio recordings and settings for this tutorial.

Full SuperCollider script

The complete Pewter Loom 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 = 1.961568;
~soundRelease = 0.13;
~soundNames = (motion: \pgPewterLoomMotion, voice: \pgPewterLoomVoice, effects: \pgPewterLoomEffects);

~soundDefs = [
    SynthDef(\pgPewterLoomMotion, { |out=0| Out.kr(out, DC.kr(0)) }),
    SynthDef(\pgPewterLoomVoice, { |out=0, midi=60, velocity=0.8, gate=1, startMidi=60|
        var stage = ~soundStage;
    var aAmp = 0, aAmpDecay = 0, aAmpGate = 0, aL = 0, aR = 0, aSecond = 0, aSource = 0, iHz = 0;
    var iVelocity = 0, kCut = 0, kFilter = 0, kFilterDecay = 0, kFilterGate = 0, kLFO = 0;
    iHz = (midi).midicps;
    iVelocity = (velocity).clip(0, 1);
    aSource = (Saw.ar(iHz) * ((0 - 6.0)).dbamp);
    if((stage >= 2)) {
    aSecond = (Pulse.ar((iHz * (2 ** (0 + (0 / 1200)))), 0.25) * ((0 - 12.0)).dbamp);
    aSource = (aSource + aSecond);
    kFilterGate = EnvGen.kr(Env([0, 1, 1], [0.005, 1], \lin));
    kFilterDecay = EnvGen.kr(Env([1, 1, 0.08, 0.000001], [0.005, 0.21, 0.13], \exp, releaseNode: 2), gate);
    kFilter = (kFilterGate * kFilterDecay);
    kLFO = (SinOsc.kr(1.7, 0 * 2pi) * 1);
    kCut = ((455.0 * (2 ** (((3.2 * kFilter) + ((0.5 * (midi - 60)) / 12)) + (0.12 * kLFO))))).clip(30, 18000);
    aSource = (((aSource * 1.4)).tanh / 1.4);
    aSource = MoogFF.ar(aSource, (kCut).clip(20, 18000), (0.52 * 4).clip(0, 3.95));
    };
    aAmpGate = EnvGen.ar(Env([0, 1, 1], [0.005, 1], \lin));
    aAmpDecay = EnvGen.ar(Env([1, 1, 0.65, 0.000001], [0.005, 0.799, 0.114], \exp, releaseNode: 2), gate);
    aAmp = (aAmpGate * aAmpDecay);
    aL = (((aSource * aAmp) * ((0 - 12.0)).dbamp) * (iVelocity ** 2.5));
    aR = aL;
    Out.ar(out, [aL, aR]);
        EnvGen.kr(Env.asr(0.0001, 1, 0.13), gate, doneAction: 2);
    }),
    SynthDef(\pgPewterLoomEffects, { |in=0, out=0|
        var stage = ~soundStage;
        var outputScale = ~soundOutputScale;
        var input = In.ar(in, 2);
    var aCleanL = 0, aCleanR = 0, aEndMid = 0, aEndSide = 0, aL = 0, aR = 0, aShapeL = 0, aShapeR = 0;
    aL = input[0];
    aR = input[1];
    if((stage >= 3)) {
    aCleanL = LeakDC.ar(aL, 0.995);
    aShapeL = ((((aCleanL * 3) * (3.0).dbamp)).tanh / 3);
    aL = (((aCleanL * 0.30000000000000004) + (aShapeL * 0.7)) * ((0 - 3.0)).dbamp);
    aCleanR = LeakDC.ar(aR, 0.995);
    aShapeR = ((((aCleanR * 3) * (3.0).dbamp)).tanh / 3);
    aR = (((aCleanR * 0.30000000000000004) + (aShapeR * 0.7)) * ((0 - 3.0)).dbamp);
    };
    if((stage >= 4)) {
    aEndMid = ((aL + aR) * 0.5);
    aEndSide = (((aL - aR) * 0.5) * 0);
    aL = ((aEndMid + aEndSide) * (3.05).dbamp);
    aL = LeakDC.ar(aL, 0.995);
    aR = ((aEndMid - aEndSide) * (3.05).dbamp);
    aR = LeakDC.ar(aR, 0.995);
    };
    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]);
        "Pewter Loom 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.() };
)