playgrid.ccRead tutorial

Tutorial 036 / SuperCollider

Build Copper Circuit in SuperCollider

Build Copper Circuit in SuperCollider with resonant bass, explicit envelopes and the sound-shaping chain explained in the guide.

4 stepsResonant 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 centered saw bass

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 a band-limited saw at −6 dB and the note's MIDI pitch, with no unison or glide. Keep the source centered.

Multiply the 5 ms gate by an exponential contour with 480 ms decay, 0.65 sustain and 130 ms release to a quiet positive floor. The decay holds its peak during the opening 5 ms gate. Apply −6 dB amplifier gain and −6 dB instrument gain, then scale by velocity^2.5. That explicit touch curve makes quiet notes substantially softer; it is an interpretation of Analog's response. The example uses separate, non-overlapping notes rather than a mono-legato priority system.

Sound after step 1 — WebM/Opus

Next: Blend a pulse and animate the resonant filter →

Step 02 / 4

Blend a pulse and animate the resonant filter

Set ~soundStage = 2. Add a pulse at the same pitch, width 0.38 and gain −12 dB. Both oscillators feed a softly driven 24 dB/octave ladder lowpass.

Build a filter contour with 5 ms attack, 210 ms exponential decay to 0.08 and 130 ms release. Use a 1.7 Hz sine LFO for smaller movement around that contour.

The envelope opens the filter by up to 3.20 octaves; tracking adds 0.50 octaves per keyboard octave around MIDI 60. The LFO adds ±0.12 octaves, giving held notes a smaller recurring motion after the initial opening. Resonance 0.52 emphasizes the moving cutoff. The input shaping interprets Sym1 drive; all these mappings use explicit SuperCollider values rather than an exact Analog circuit model. The LFO restarts with each played note in this version.

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: Drive the bass with rounded saturation →

Step 03 / 4

Drive the bass with rounded saturation

Set ~soundStage = 3. Remove DC, shape the shared source bus with tanh(input × 3 × (4).dbamp) / 3, and blend 70% shaped with 30% clean signal. Apply −3 dB after that blend.

The +4 dB drive adds upper harmonics to the filtered body. Dividing by 3 keeps the transfer curve's small-signal scale before the drive boost. The source curve is Analog Clip; this smooth SuperCollider curve serves the same tone-shaping role with a different transfer function. The clean blend keeps the bass's direct contour audible.

Sound after step 3 — WebM/Opus

Next: Finish with mono output and DC removal →

Step 04 / 4

Finish with mono output and DC removal

Set ~soundStage = 4. Average the two output channels, raise that mono signal by +3.65 dB, and apply LeakDC before sending identical samples to both channels.

The source and saturation were already centered, so mono conversion does not newly narrow this particular signal. The audible changes at this stage are the output gain and final DC removal. There are no delay or reverb tails; after the note's 130 ms release, the bass leaves space cleanly. Clear the shared voice bus at the end of the output instrument.

Sound after step 4 — WebM/Opus

Audio & settings ↓

Audio & settings

Audio recordings and settings for this tutorial.

Full SuperCollider script

The complete Copper Circuit 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.729209;
~soundRelease = 0.13;
~soundNames = (motion: \pgCopperCircuitMotion, voice: \pgCopperCircuitVoice, effects: \pgCopperCircuitEffects);

~soundDefs = [
    SynthDef(\pgCopperCircuitMotion, { |out=0| Out.kr(out, DC.kr(0)) }),
    SynthDef(\pgCopperCircuitVoice, { |out=0, midi=60, velocity=0.8, gate=1, startMidi=60|
        var stage = ~soundStage;
    var aAmp = 0, aAttack = 0, aDecay = 0, aDrive = 0, aPulse = 0, aSaw = 0, aSource = 0, iHz = 0;
    var iVelocity = 0, kAttack = 0, kCutoff = 0, kDecay = 0, kFilter = 0, kMotion = 0;
    iHz = (midi).midicps;
    iVelocity = (velocity).clip(0, 1);
    aSaw = (Saw.ar(iHz) * ((0 - 6)).dbamp);
    aSource = aSaw;
    if((stage >= 2)) {
    aPulse = (Pulse.ar(iHz, 0.38) * ((0 - 12)).dbamp);
    aSource = (aSource + aPulse);
    kAttack = EnvGen.kr(Env([0, 1, 1], [0.005, 1], \lin));
    kDecay = EnvGen.kr(Env([1, 1, 0.08, 0.000001], [0.005, 0.210, 0.130], \exp, releaseNode: 2), gate);
    kFilter = (kAttack * kDecay);
    kMotion = (SinOsc.kr(1.7, 0 * 2pi) * 1);
    kCutoff = ((270 * (2 ** (((3.20 * kFilter) + ((0.50 * (midi - 60)) / 12)) + (0.12 * kMotion))))).clip(30, 18000);
    aDrive = (((aSource * 1.6)).tanh / 1.6);
    aSource = MoogFF.ar(aDrive, (kCutoff).clip(20, 18000), (0.52 * 4).clip(0, 3.95));
    };
    aAttack = EnvGen.ar(Env([0, 1, 1], [0.005, 1], \lin));
    aDecay = EnvGen.ar(Env([1, 1, 0.65, 0.000001], [0.005, 0.480, 0.130], \exp, releaseNode: 2), gate);
    aAmp = ((((aAttack * aDecay) * ((0 - 6)).dbamp) * ((0 - 6)).dbamp) * (iVelocity ** 2.5));
    Out.ar(out, [(aSource * aAmp), (aSource * aAmp)]);
        EnvGen.kr(Env.asr(0.0001, 1, 0.13), gate, doneAction: 2);
    }),
    SynthDef(\pgCopperCircuitEffects, { |in=0, out=0|
        var stage = ~soundStage;
        var outputScale = ~soundOutputScale;
        var input = In.ar(in, 2);
    var aClean = 0, aDry = 0, aLeft = 0, aMono = 0, aOut = 0, aRight = 0, aShape = 0;
    aDry = input[0];
    if((stage >= 3)) {
    aClean = LeakDC.ar(aDry, 0.995);
    aShape = ((((aClean * 3) * (4).dbamp)).tanh / 3);
    aDry = (((aClean * 0.30) + (aShape * 0.70)) * ((0 - 3)).dbamp);
    };
    aLeft = aDry;
    aRight = aDry;
    if((stage >= 4)) {
    aMono = ((aLeft + aRight) * 0.5);
    aOut = LeakDC.ar((aMono * (3.65).dbamp), 0.995);
    aLeft = aOut;
    aRight = aOut;
    };
    Out.ar(out, [(aLeft * outputScale), (aRight * 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]);
        "Copper Circuit 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.() };
)