playgrid.ccRead tutorial

Tutorial 007 / SuperCollider

Build Lo-Fi Bell in SuperCollider

Build Lo-Fi Bell in SuperCollider with triangle bell, explicit envelopes and the sound-shaping chain explained in the guide.

4 stepsTriangle BellSuperCollider

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

Tune the three bell components

Select ~soundStage = 1 and evaluate the full script at the end of this guide. Wait for the instrument-ready message before playing. The triangle source is an explicit odd-harmonic sine sum through partial 31, with components at or above 22 kHz muted.

Set ~soundStage = 1 in the full script. Use triangles at +28 st/+30 cents and +30 st/−15 cents, at −21 and −24 dB. Add a sine one octave below the played pitch at −6 dB. Those unequal high intervals against the low foundation establish the bell character. The sine sub omits the source 12% tone coloration. Use 1 ms attack, 4.3 s decay to −38 dB and 350 ms release.

SuperCollider control Value
High tones +28 st +30 cents / +30 st −15 cents
Levels −21 / −24 / sub −6 dB
Sub Sine, octave down
Amplitude 1 ms / 4.3 s / −38 dB / 350 ms
Instrument / touch −7 dB / 50%

Sound after step 1 — WebM/Opus

Next: Round the high tones with a fixed filter →

Step 02 / 4

Round the high tones with a fixed filter

Set ~soundStage = 2 in the full script. Use a 1650 Hz ladder lowpass at 0.34 resonance, with no note tracking or envelope movement. Higher bell components become softer as they rise beyond the fixed cutoff. This replaces PRD with a different resonant response.

SuperCollider control Value
Lowpass 1650 Hz, resonance 0.34
Tracking / modulation Off

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: Surround the tone with a damped room →

Step 03 / 4

Surround the tone with a damped room

Set ~soundStage = 3 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.454262 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.454262
Damping 0.71875
Predelay 8 ms
External room wet 44%
SuperCollider control Value
Room side multiplier 1
Room input cuts Off

Sound after step 3 — WebM/Opus

Next: Add panning and digital grain →

Step 04 / 4

Add panning and digital grain

Set ~soundStage = 4 in the full script. Move the left and right gains oppositely at 1 Hz by ±22%. This moves the bell and preceding room together. The simple complementary gain model interprets Auto Pan without its additional shape controls. Hold incoming samples at 16000 Hz and round their amplitudes to 12 signed bits, then blend 40% of that branch with the direct tone. The held samples add staircase texture and the rounding roughens quieter portions. This simple clocked quantizer interprets Redux without its proprietary jitter or shaping behavior. No pre- or post-filter is added.

SuperCollider control Value
Panning 1 Hz sine; ±22% opposite channel gain
Hold rate 16000 Hz
Signed bits / wet 12 / 40%

Sound after step 4 — WebM/Opus

Audio & settings ↓

Audio & settings

Audio recordings and settings for this tutorial.

Full SuperCollider script

The complete Lo-Fi Bell 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.786586;
~soundRelease = 0.35;
~soundNames = (motion: \pgLoFiBellMotion, voice: \pgLoFiBellVoice, effects: \pgLoFiBellEffects);
~pgWave = { |freq, amplitude=1, phase=0, partials=#[1]|
    Mix(partials.collect { |weight, i|
        var harmonic = freq * (i + 1);
        SinOsc.ar(harmonic.clip(0.01, 22000), phase * 2pi * (i + 1)) * weight * (harmonic < 22000)
    }) * amplitude;
};
~pgTriangle = { |freq, phase=0|
    var partials = Array.fill(31, { |i|
        var n = i + 1;
        if(n.odd) { ((-1) ** ((n - 1) / 2)) * 8 / (pi.squared * n.squared) } { 0 }
    });
    ~pgWave.(freq, 1, phase, partials);
};
~soundDefs = [
    SynthDef(\pgLoFiBellMotion, { |out=0| Out.kr(out, DC.kr(0)) }),
    SynthDef(\pgLoFiBellVoice, { |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, aSub = 0, iHz = 0, iVelocity = 0;
    var kAmp = 0;
    iHz = (midi).midicps;
    iVelocity = (velocity).clip(0, 1);
    aA = (~pgTriangle.((iHz * (2 ** ((28 / 12) + (30 / 1200)))), 0) * ((0 - 21)).dbamp);
    aB = (~pgTriangle.((iHz * (2 ** ((30 / 12) - (15 / 1200)))), 0) * ((0 - 24)).dbamp);
    aSub = (SinOsc.ar((iHz * 0.5), 0 * 2pi) * ((0 - 6)).dbamp);
    aSource = ((aA + aB) + aSub);
    if((stage >= 2)) {
    aSource = MoogFF.ar(aSource, (1650).clip(20, 18000), (0.34 * 4).clip(0, 3.95));
    };
    kAmp = EnvGen.kr(Env([0, 1, 0.012589254117941675, 0], [0.001, 4.3, 0.35], \lin, releaseNode: 2), gate);
    aL = (((aSource * kAmp) * ((0 - 7)).dbamp) * (0.5 + (0.5 * iVelocity)));
    aR = aL;
    Out.ar(out, [aL, aR]);
        EnvGen.kr(Env.asr(0.0001, 1, 0.35), gate, doneAction: 2);
    }),
    SynthDef(\pgLoFiBellEffects, { |in=0, out=0|
        var stage = ~soundStage;
        var outputScale = ~soundOutputScale;
        var input = In.ar(in, 2);
    var aDigitalClock = 0, aHeldL = 0, aHeldR = 0, aL = 0, aQuantL = 0, aQuantR = 0, aR = 0, aRoomInL = 0;
    var aRoomInR = 0, aRoomL = 0, aRoomMid = 0, aRoomPreL = 0, aRoomPreR = 0, aRoomR = 0, aRoomSide = 0, kPan = 0;
    var room7 = 0;
    aL = input[0];
    aR = input[1];
    if((stage >= 3)) {
    aRoomInL = aL;
    aRoomPreL = DelayN.ar(aRoomInL, 0.008, 0.008);
    aRoomInR = aR;
    aRoomPreR = DelayN.ar(aRoomInR, 0.008, 0.008);
    room7 = FreeVerb2.ar(aRoomPreL, aRoomPreR, 1, 0.454262, 0.71875);
    aRoomL = room7[0];
    aRoomR = room7[1];
    aRoomMid = ((aRoomL + aRoomR) * 0.5);
    aRoomSide = (((aRoomL - aRoomR) * 0.5) * 1);
    aL = ((aL * 0.56) + ((aRoomMid + aRoomSide) * 0.44));
    aR = ((aR * 0.56) + ((aRoomMid - aRoomSide) * 0.44));
    };
    if((stage >= 4)) {
    kPan = (SinOsc.kr(1, 0 * 2pi) * 0.22);
    aL = (aL * (1 + kPan));
    aR = (aR * (1 - kPan));
    aDigitalClock = (Impulse.ar(1 / 6.25e-05) * 1);
    aHeldL = Latch.ar(aL, aDigitalClock);
    aQuantL = (((aHeldL * 2048)).round / 2048);
    aL = ((aL * 0.6) + (aQuantL * 0.4));
    aHeldR = Latch.ar(aR, aDigitalClock);
    aQuantR = (((aHeldR * 2048)).round / 2048);
    aR = ((aR * 0.6) + (aQuantR * 0.4));
    };
    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]);
        "Lo-Fi Bell 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.() };
)