playgrid.ccRead tutorial

Tutorial 021 / Csound

Build Amber Lantern in Csound

Build Amber Lantern in Csound with detuned saw and triangle voices, a sine sub, moving notch filtering, saturation and ping-pong delay.

5 stepsNotch LeadCsound 6

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 / 5

Build a lightly spread saw lead

Set giStage init 1 in the full script. Mix three band-limited saws at −5, 0 and +5 cents, each at −9 dB. Their initial phases are 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.

portk smooths pitch toward each new target with a 40 ms half-time, starting from the preceding note's pitch. The score uses sequential notes; 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.

Sound after step 1 — WebM/Opus

Next: Add the upper color, sub and moving notch →

Step 02 / 5

Add the upper color, sub and moving notch

Set giStage init 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.

kFilter linsegr 0, 0.020, 1, 1.10, 0.20, 0.300, 0
kNotch = limit(1090*pow(2, -0.8*kFilter), 30, 18000)
aLeft butterbr aLeft, kNotch, kNotch/1.2

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.

Sound after step 2 — WebM/Opus

Next: Thicken the lead with smooth clipping →

Step 03 / 5

Thicken the lead with smooth clipping

Set giStage init 3. Remove DC before the shared nonlinear stage. Use tanh(input × 3 × ampdb(3.1)) / 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.

Sound after step 3 — WebM/Opus

Next: Add filtered ping-pong repeats →

Step 04 / 5

Add filtered ping-pong repeats

Set giStage init 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.

aEchoL vdelay3 aSend+aFeedbackR*0.24, 267, 1000
aEchoR vdelay3 aFeedbackL*0.24, 267, 1000

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 16-sample control block. No delay-time or filter LFO is active.

Sound after step 4 — WebM/Opus

Next: Balance the finished stereo lead →

Step 05 / 5

Balance the finished stereo lead

Set giStage init 5. Apply +5.80 dB to each output channel and remove DC using dcblock2. 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. Clear the shared input buses after processing so previous note samples do not accumulate. The finished sound has a fast, hollowed lead body with a centered sub and short, alternating echoes.

Sound after step 5 — WebM/Opus

Audio & settings ↓

Audio & settings

Audio recordings and settings for this tutorial.

Full Csound script

The complete Amber Lantern instrument and shared effects. giStage selects cumulative stages 1–5; 5 is the finished sound. Instrument 1 takes held seconds, MIDI pitch and velocity in p3–p5. Instrument 90 carries the output and any effect tails.

<CsoundSynthesizer>
<CsOptions>
-odac -d
</CsOptions>
<CsInstruments>
sr = 48000
ksmps = 16
nchnls = 2
0dbfs = 1

giStage init 5
giSine ftgen 0, 0, 16384, 10, 1
gaLeft init 0
gaRight init 0
giLastHz init 0

opcode LanternVoice, a, kii
  kHz, iCents, iPhase xin
  kVoiceHz = kHz*pow(2, iCents/1200)
  aSaw vco2 ampdb(-9), kVoiceHz, 0, 0.5, iPhase
  aSum = aSaw
  if giStage >= 2 then
    aTriangle vco2 ampdb(-13), kVoiceHz*pow(2, 5/1200), 12, 0.5, iPhase
    aSum = aSum+aTriangle
  endif
  xout aSum
endop

instr 1
  iHz = cpsmidinn(p4)
  iVelocity = limit(p5, 0, 1)
  iStart = giLastHz
  if iStart <= 0 then
    iStart = iHz
  endif
  giLastHz = iHz
  ; The previous target supplies a short glide between score notes.
  kHz portk iHz, 0.040, iStart
  a1 LanternVoice kHz, -5, 0.11
  a2 LanternVoice kHz, 0, 0.39
  a3 LanternVoice kHz, 5, 0.72
  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 giStage >= 2 then
    aSub oscili ampdb(-18), kHz*0.5, giSine
    aLeft = aLeft+aSub
    aRight = aRight+aSub
    kFilter linsegr 0, 0.020, 1, 1.10, 0.20, 0.300, 0
    kNotch = limit(1090*pow(2, -0.8*kFilter), 30, 18000)
    aLeft butterbr aLeft, kNotch, kNotch/1.2
    aRight butterbr aRight, kNotch, kNotch/1.2
    kCeiling = limit(6800*pow(2, 0.35*iVelocity), 30, 18000)
    aLeft butterlp aLeft, kCeiling
    aRight butterlp aRight, kCeiling
  endif
  kAmp linsegr 0, 0.0044, 1, 0.643, ampdb(-4), 0.191, 0
  kGain = kAmp*ampdb(-6)*(0.4+0.6*iVelocity)
  gaLeft = gaLeft+aLeft*kGain
  gaRight = gaRight+aRight*kGain
endin

instr 90
  aDryL = gaLeft
  aDryR = gaRight
  aFeedbackL init 0
  aFeedbackR init 0
  if giStage >= 3 then
    aCleanL dcblock2 aDryL, 2048
    aCleanR dcblock2 aDryR, 2048
    aShapeL = tanh(aCleanL*3*ampdb(3.1))/3
    aShapeR = tanh(aCleanR*3*ampdb(3.1))/3
    aDryL = (aCleanL*0.30+aShapeL*0.70)*ampdb(-3)
    aDryR = (aCleanR*0.30+aShapeR*0.70)*ampdb(-3)
  endif
  aOutL = aDryL
  aOutR = aDryR
  if giStage >= 4 then
    ; Inject the centered input on the left; echoes cross to the right.
    aSend = (aDryL+aDryR)*0.5
    aEchoL vdelay3 aSend+aFeedbackR*0.24, 267, 1000
    aEchoR vdelay3 aFeedbackL*0.24, 267, 1000
    aEchoL butterhp aEchoL, 1800/pow(2, 1.75)
    aEchoL butterlp aEchoL, 1800*pow(2, 1.75)
    aEchoR butterhp aEchoR, 1800/pow(2, 1.75)
    aEchoR butterlp aEchoR, 1800*pow(2, 1.75)
    aFeedbackL = aEchoL
    aFeedbackR = aEchoR
    aOutL = aDryL*0.82+aEchoL*0.18
    aOutR = aDryR*0.82+aEchoR*0.18
  endif
  if giStage >= 5 then
    aOutL dcblock2 aOutL*ampdb(5.80), 2048
    aOutR dcblock2 aOutR*ampdb(5.80), 2048
  endif
  outs aOutL, aOutR
  clear gaLeft, gaRight
endin
</CsInstruments>
<CsScore>
i 1 0.0 0.65 60 0.72
i 1 1.1 0.65 64 0.84
i 1 2.2 0.65 67 0.90
i 1 3.3 0.65 62 0.76
i 1 4.4 0.85 60 0.85
i 90 0 10
e
</CsScore>
</CsoundSynthesizer>