# Build Faded Circuit Keys in SuperCollider

A stock-unit SuperCollider interpretation of [the Ableton sound](/tutorials/faded-circuit-keys/) and its [Csound version](/tutorials/faded-circuit-keys/csound/). Each stage changes the source or its effect chain; oscillator, filter, modal and room algorithms differ across platforms.

[Starting settings](STARTING_STATE.md) · [Complete settings](ALL_PARAMETERS.md). The full runnable script ends this guide.

## Step 1 — Shape the wobbling sustained source

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. Blend 86% saw with 14% triangle at +3 dB as an interpretation of Shark Tooth Shape 0.14. Add ±5.2 cents at 1.25 Hz and a slower ±2.4-cent drift. The amplitude holds full sustain after a 1 ms attack, with 8.5 s release. A separate filter contour takes 8.5 s to fall to zero and 18 s to release; it moves the fully tracked 800 Hz lowpass by 1.05 octaves.

| SuperCollider control | Value |
| --- | --- |
| Shape | 86% saw + 14% triangle, +3 dB |
| Pitch motion | ±5.2 cents at 1.25 Hz; ±2.4 cents at 0.13 Hz |
| Amplitude | 1 ms attack, full sustain, 8.5 s release |
| Filter contour | 1 ms / 8.5 s / zero / 18 s |
| Filter / instrument | 800 Hz base, full tracking, 1.05 octave depth; −12 dB |

<audio controls preload="none" aria-label="SuperCollider Faded Circuit Keys after step 1"><source src="audio/steps/step-01.webm" type="audio/webm"></audio>

[Sound after step 1 — WebM/Opus](audio/steps/step-01.webm)

## Step 2 — Blend a narrower middle band

Set `~soundStage = 2` in the full script. Pass a branch through two cascaded 650 Hz bandpasses, each with 650/0.6 Hz bandwidth, then mix 30% of that branch with 70% direct signal. The cascade interprets the source 24 dB bandpass and 8% resonance using a different filter network. Its fixed center colors different pitches differently.

| SuperCollider control | Value |
| --- | --- |
| Bandpass | Two Butterworth stages, 650 Hz; bandwidth 1083.33 Hz |
| Wet mix | 30% |

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.

<audio controls preload="none" aria-label="SuperCollider Faded Circuit Keys after step 2"><source src="audio/steps/step-02.webm" type="audio/webm"></audio>

[Sound after step 2 — WebM/Opus](audio/steps/step-02.webm)

## Step 3 — Add a restrained digital texture

Set `~soundStage = 3` in the full script. Hold incoming samples at 24000 Hz and round their amplitudes to 9 signed bits, then blend 35% 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 |
| --- | --- |
| Hold rate | 24000 Hz |
| Signed bits / wet | 9 / 35% |

<audio controls preload="none" aria-label="SuperCollider Faded Circuit Keys after step 3"><source src="audio/steps/step-03.webm" type="audio/webm"></audio>

[Sound after step 3 — WebM/Opus](audio/steps/step-03.webm)

## Step 4 — Surround the tone with a damped 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.935902 and damping is 0.8125. 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.935902 |
| Damping | 0.8125 |
| Predelay | 8 ms |
| External room wet | 22% |

| SuperCollider control | Value |
| --- | --- |
| Room side multiplier | 1 |
| Room input cuts | Off |

<audio controls preload="none" aria-label="SuperCollider Faded Circuit Keys after step 4"><source src="audio/steps/step-04.webm" type="audio/webm"></audio>

[Sound after step 4 — WebM/Opus](audio/steps/step-04.webm)

## Downloads and settings

[Finished sound — WebM/Opus](audio/Faded-Circuit-Keys.webm) · [Complete settings](ALL_PARAMETERS.md) · [Ableton version](/tutorials/faded-circuit-keys/) · [Csound version](/tutorials/faded-circuit-keys/csound/)

## Full SuperCollider script

The complete Faded Circuit Keys 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.

```supercollider
(
~soundStage = 4;
~soundOutputScale = 1.046207;
~soundRelease = 18;
~soundNames = (motion: \pgFadedCircuitKeysMotion, voice: \pgFadedCircuitKeysVoice, effects: \pgFadedCircuitKeysEffects);
~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(\pgFadedCircuitKeysMotion, { |out=0| Out.kr(out, DC.kr(0)) }),
    SynthDef(\pgFadedCircuitKeysVoice, { |out=0, midi=60, velocity=0.8, gate=1, startMidi=60|
        var stage = ~soundStage;
    var aL = 0, aR = 0, aSaw = 0, aSource = 0, aTri = 0, iHz = 0, iVelocity = 0, kAmp = 0;
    var kCut = 0, kDrift = 0, kFilter = 0, kHz = 0, kWobble = 0;
    iHz = (midi).midicps;
    iVelocity = (velocity).clip(0, 1);
    kWobble = (SinOsc.kr(1.25, 0 * 2pi) * 5.2);
    kDrift = (SinOsc.kr(0.13, 0.2 * 2pi) * 2.4);
    kHz = (iHz * (2 ** ((kWobble + kDrift) / 1200)));
    aSaw = (Saw.ar(kHz) * (3).dbamp);
    aTri = (~pgTriangle.(kHz, 0) * (3).dbamp);
    aSource = ((aSaw * 0.86) + (aTri * 0.14));
    kFilter = EnvGen.kr(Env([0, 1, 0, 0], [0.001, 8.5, 18], \lin, releaseNode: 2), gate);
    kCut = ((800 * (2 ** ((1.05 * kFilter) + ((midi - 60) / 12))))).clip(30, 18000);
    aSource = MoogFF.ar(aSource, (kCut).clip(20, 18000), (0 * 4).clip(0, 3.95));
    aSource = HPF.ar(aSource, (10).clip(20, 18000));
    kAmp = EnvGen.kr(Env([0, 1, 1, 0], [0.001, 3.85, 8.5], \lin, releaseNode: 2), gate);
    aL = (((aSource * kAmp) * ((0 - 12)).dbamp) * (0.5 + (0.5 * iVelocity)));
    aR = aL;
    Out.ar(out, [aL, aR]);
        EnvGen.kr(Env.asr(0.0001, 1, 18), gate, doneAction: 2);
    }),
    SynthDef(\pgFadedCircuitKeysEffects, { |in=0, out=0|
        var stage = ~soundStage;
        var outputScale = ~soundOutputScale;
        var input = In.ar(in, 2);
    var aBandL = 0, aBandR = 0, aDigitalClock = 0, aHeldL = 0, aHeldR = 0, aL = 0, aQuantL = 0, aQuantR = 0;
    var aR = 0, aRoomInL = 0, aRoomInR = 0, aRoomL = 0, aRoomMid = 0, aRoomPreL = 0, aRoomPreR = 0, aRoomR = 0;
    var aRoomSide = 0, room24 = 0;
    aL = input[0];
    aR = input[1];
    if((stage >= 2)) {
    aBandL = BPF.ar(aL, (650).clip(20, 18000), ((650 / 0.6) / 650).clip(0.001, 4));
    aBandR = BPF.ar(aR, (650).clip(20, 18000), ((650 / 0.6) / 650).clip(0.001, 4));
    aBandL = BPF.ar(aBandL, (650).clip(20, 18000), ((650 / 0.6) / 650).clip(0.001, 4));
    aBandR = BPF.ar(aBandR, (650).clip(20, 18000), ((650 / 0.6) / 650).clip(0.001, 4));
    aL = ((aL * 0.7) + (aBandL * 0.3));
    aR = ((aR * 0.7) + (aBandR * 0.3));
    };
    if((stage >= 3)) {
    aDigitalClock = (Impulse.ar(1 / 4.1666666666666665e-05) * 1);
    aHeldL = Latch.ar(aL, aDigitalClock);
    aQuantL = (((aHeldL * 256)).round / 256);
    aL = ((aL * 0.65) + (aQuantL * 0.35));
    aHeldR = Latch.ar(aR, aDigitalClock);
    aQuantR = (((aHeldR * 256)).round / 256);
    aR = ((aR * 0.65) + (aQuantR * 0.35));
    };
    if((stage >= 4)) {
    aRoomInL = aL;
    aRoomPreL = DelayN.ar(aRoomInL, 0.008, 0.008);
    aRoomInR = aR;
    aRoomPreR = DelayN.ar(aRoomInR, 0.008, 0.008);
    room24 = FreeVerb2.ar(aRoomPreL, aRoomPreR, 1, 0.935902, 0.8125);
    aRoomL = room24[0];
    aRoomR = room24[1];
    aRoomMid = ((aRoomL + aRoomR) * 0.5);
    aRoomSide = (((aRoomL - aRoomR) * 0.5) * 1);
    aL = ((aL * 0.78) + ((aRoomMid + aRoomSide) * 0.22));
    aR = ((aR * 0.78) + ((aRoomMid - aRoomSide) * 0.22));
    };
    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]);
        "Faded Circuit Keys 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.() };
)
```

[Read on playgrid.cc](https://playgrid.cc/tutorials/faded-circuit-keys/supercollider/)
