# Build Amber Lantern in SuperCollider

A stock-unit SuperCollider interpretation of [the Ableton sound](/tutorials/amber-lantern/) and its [Csound version](/tutorials/amber-lantern/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 — Build a lightly spread saw lead

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. Mix three band-limited saws at −5, 0 and +5 cents, each at −9 dB. The saw units use their native startup phase; the added triangle layers use phases 0.11, 0.39 and 0.72 cycles. Weight the voices 0.8/0.5/0.2 on the left and reverse those weights on the right; divide each channel sum by 1.5.

Use a linear amplitude envelope with 4.40 ms attack, 643 ms decay, −4 dB sustain and 191 ms release. Instrument gain is −6 dB, and touch scales amplitude by `0.4 + 0.6 × velocity`. This contour gives a quick lead onset and a short fade without making every note a click.

`EnvGen` smooths pitch toward each new target with a 40 ms half-time, starting from the preceding note's pitch. The note helper remembers the previous target; this simple pitch memory does not implement Live's mono-legato priority. The saws interpret Basic Shapes at position 66%, rather than scan its actual wavetable.

<audio controls preload="none" aria-label="SuperCollider Amber Lantern 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 — Add the upper color, sub and moving notch

Set `~soundStage = 2`. Each unison voice gains a triangle at −13 dB and +5 cents. This triangle is an explicit interpretation of the second Basic Shapes position. Add a centered sine sub at −18 dB, one octave below the note.


Apply the same notch on the right, then lowpass each channel at `6800 × 2^(0.35 × velocity)` Hz, limited to 18000 Hz. The negative 0.8-octave envelope sweep hollows the lead during its early body; the lowpass limits the upper edge. Its velocity route brightens stronger notes. These octave depths and notch bandwidth interpret the source matrix and resonance values. Mod-wheel and pitch-bend routes are not mapped.

<audio controls preload="none" aria-label="SuperCollider Amber Lantern 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 — Thicken the lead with smooth clipping

Set `~soundStage = 3`. Remove DC before the shared nonlinear stage. Use `tanh(input × 3 × (3.1).dbamp) / 3` at 70% wet, blended with 30% clean signal, then trim the result by −3 dB.

The +3.1 dB drive pushes louder peaks farther into the rounded part of the curve. The factor 3 sets its sensitivity; dividing by 3 preserves the curve's small-signal scale before drive. This is a smooth interpretation of Analog Clip, not its exact transfer curve. Processing the shared note bus lets overlapping releases affect the drive together.

<audio controls preload="none" aria-label="SuperCollider Amber Lantern 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 — Add filtered ping-pong repeats

Set `~soundStage = 4`. Send the mean of the two dry channels into a 267 ms left delay. Feed 24% of each filtered echo into the opposite delay; the right side first receives the left echo rather than a second copy of the original input.


Highpass and lowpass each echo around an 1800 Hz center, at center / 2^1.75 and center × 2^1.75. This interprets Width 3.50 as a 3.5-octave passband. Mix 82% direct and 18% wet. The first echo is left, and subsequent feedback traversals alternate sides. Each feedback traversal also includes one server processing block. No delay-time or filter LFO is active.

<audio controls preload="none" aria-label="SuperCollider Amber Lantern 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)

## Step 5 — Balance the finished stereo lead

Set `~soundStage = 5`. Apply +5.80 dB to each output channel and remove DC using `LeakDC`. Keep the existing stereo difference; there is no bass narrowing or mono conversion in this version.

The gain raises both the lead and its repeats. The shared effect Synth runs after the voice group. The finished sound has a fast, hollowed lead body with a centered sub and short, alternating echoes.

<audio controls preload="none" aria-label="SuperCollider Amber Lantern after step 5"><source src="audio/steps/step-05.webm" type="audio/webm"></audio>

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

## Downloads and settings

[Finished sound — WebM/Opus](audio/amber-lantern.webm) · [Complete settings](ALL_PARAMETERS.md) · [Ableton version](/tutorials/amber-lantern/) · [Csound version](/tutorials/amber-lantern/csound/)

## Full SuperCollider script

The complete Amber Lantern 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.

```supercollider
(
~soundStage = 5;
~soundOutputScale = 0.8337458;
~soundRelease = 0.3;
~soundNames = (motion: \pgAmberLanternMotion, voice: \pgAmberLanternVoice, effects: \pgAmberLanternEffects);
~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);
};
~pgLantern = { |freq, cents, phase, stage|
    var hz = freq * (2 ** (cents / 1200));
    var tone = Saw.ar(hz) * -9.dbamp;
    if(stage >= 2) { tone = tone + (~pgTriangle.(hz * (2 ** (5 / 1200)), phase) * -13.dbamp) };
    tone;
};
~soundDefs = [
    SynthDef(\pgAmberLanternMotion, { |out=0| Out.kr(out, DC.kr(0)) }),
    SynthDef(\pgAmberLanternVoice, { |out=0, midi=60, velocity=0.8, gate=1, startMidi=60|
        var stage = ~soundStage;
    var a1 = 0, a2 = 0, a3 = 0, aLeft = 0, aRight = 0, aSub = 0, iHz = 0, iStart = 0;
    var iVelocity = 0, kAmp = 0, kCeiling = 0, kFilter = 0, kGain = 0, kHz = 0, kNotch = 0;
    iHz = (midi).midicps;
    iVelocity = (velocity).clip(0, 1);
    iStart = startMidi.midicps;
    kHz = (iHz + ((iStart - iHz) * EnvGen.kr(Env([1, 0.000001], [0.040 * 1000000.log / 2.log], \exp))));
    a1 = ~pgLantern.(kHz, (0 - 5), 0.11, stage);
    a2 = ~pgLantern.(kHz, 0, 0.39, stage);
    a3 = ~pgLantern.(kHz, 5, 0.72, stage);
    aLeft = ((((a1 * 0.8) + (a2 * 0.5)) + (a3 * 0.2)) / 1.5);
    aRight = ((((a1 * 0.2) + (a2 * 0.5)) + (a3 * 0.8)) / 1.5);
    if((stage >= 2)) {
    aSub = (SinOsc.ar((kHz * 0.5), 0 * 2pi) * ((0 - 18)).dbamp);
    aLeft = (aLeft + aSub);
    aRight = (aRight + aSub);
    kFilter = EnvGen.kr(Env([0, 1, 0.20, 0], [0.020, 1.10, 0.300], \lin, releaseNode: 2), gate);
    kNotch = ((1090 * (2 ** ((0 - 0.8) * kFilter)))).clip(30, 18000);
    aLeft = BRF.ar(aLeft, (kNotch).clip(20, 18000), ((kNotch / 1.2) / kNotch).clip(0.001, 4));
    aRight = BRF.ar(aRight, (kNotch).clip(20, 18000), ((kNotch / 1.2) / kNotch).clip(0.001, 4));
    kCeiling = ((6800 * (2 ** (0.35 * iVelocity)))).clip(30, 18000);
    aLeft = LPF.ar(aLeft, (kCeiling).clip(20, 18000));
    aRight = LPF.ar(aRight, (kCeiling).clip(20, 18000));
    };
    kAmp = EnvGen.kr(Env([0, 1, ((0 - 4)).dbamp, 0], [0.0044, 0.643, 0.191], \lin, releaseNode: 2), gate);
    kGain = ((kAmp * ((0 - 6)).dbamp) * (0.4 + (0.6 * iVelocity)));
    Out.ar(out, [(aLeft * kGain), (aRight * kGain)]);
        EnvGen.kr(Env.asr(0.0001, 1, 0.3), gate, doneAction: 2);
    }),
    SynthDef(\pgAmberLanternEffects, { |in=0, out=0|
        var stage = ~soundStage;
        var outputScale = ~soundOutputScale;
        var input = In.ar(in, 2);
    var feedback = LocalIn.ar(2);
    var aCleanL = 0, aCleanR = 0, aDryL = 0, aDryR = 0, aEchoL = 0, aEchoR = 0, aFeedbackL = 0, aFeedbackR = 0;
    var aOutL = 0, aOutR = 0, aSend = 0, aShapeL = 0, aShapeR = 0;
    aDryL = input[0];
    aDryR = input[1];
    aFeedbackL = feedback[0];
    aFeedbackR = feedback[1];
    if((stage >= 3)) {
    aCleanL = LeakDC.ar(aDryL, 0.995);
    aCleanR = LeakDC.ar(aDryR, 0.995);
    aShapeL = ((((aCleanL * 3) * (3.1).dbamp)).tanh / 3);
    aShapeR = ((((aCleanR * 3) * (3.1).dbamp)).tanh / 3);
    aDryL = (((aCleanL * 0.30) + (aShapeL * 0.70)) * ((0 - 3)).dbamp);
    aDryR = (((aCleanR * 0.30) + (aShapeR * 0.70)) * ((0 - 3)).dbamp);
    };
    aOutL = aDryL;
    aOutR = aDryR;
    if((stage >= 4)) {
    aSend = ((aDryL + aDryR) * 0.5);
    aEchoL = DelayC.ar((aSend + (aFeedbackR * 0.24)), 1000 / 1000, (267 / 1000).clip(0.00002, 1000 / 1000));
    aEchoR = DelayC.ar((aFeedbackL * 0.24), 1000 / 1000, (267 / 1000).clip(0.00002, 1000 / 1000));
    aEchoL = HPF.ar(aEchoL, ((1800 / (2 ** 1.75))).clip(20, 18000));
    aEchoL = LPF.ar(aEchoL, ((1800 * (2 ** 1.75))).clip(20, 18000));
    aEchoR = HPF.ar(aEchoR, ((1800 / (2 ** 1.75))).clip(20, 18000));
    aEchoR = LPF.ar(aEchoR, ((1800 * (2 ** 1.75))).clip(20, 18000));
    aFeedbackL = aEchoL;
    aFeedbackR = aEchoR;
    aOutL = ((aDryL * 0.82) + (aEchoL * 0.18));
    aOutR = ((aDryR * 0.82) + (aEchoR * 0.18));
    };
    if((stage >= 5)) {
    aOutL = LeakDC.ar((aOutL * (5.80).dbamp), 0.995);
    aOutR = LeakDC.ar((aOutR * (5.80).dbamp), 0.995);
    };
    LocalOut.ar([aFeedbackL, aFeedbackR].collect { |channel| channel + DC.ar(0) });
    Out.ar(out, [(aOutL * outputScale), (aOutR * 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]);
        "Amber Lantern 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/amber-lantern/supercollider/)
