# Build Coral Crown in Csound

[SuperCollider version](/tutorials/coral-crown/supercollider/): the same sound interpreted with stock SuperCollider synthesis units.

Coral Crown in Csound follows the sound-shaping ideas of the [Ableton Wavetable version](/tutorials/coral-crown/), using the explicit oscillators, contours and effects below.

[Starting settings](STARTING_STATE.md) · [Complete settings](ALL_PARAMETERS.md). The complete script follows the final step and related sounds.

## Step 1 — Build the detuned source and amplitude contour

Set `giStage init 1` in the full script. Use 3 band-limited saw voices at -9 dB each, spread by 6 cents between adjacent voices. Reverse the stereo weights across the channels. The amplitude opens in 0.0044 seconds, decays over 0.582 seconds to 0.630957, and releases over 0.186 seconds. Basic Shapes is represented by this explicit waveform; Shimmer, where present, becomes slow independent pitch drift rather than the original unison engine.

| Csound control | Value |
| --- | --- |
| Sources | 3 × saw, -9 dB |
| Adjacent pitch spacing | 6 cents |
| Amp A/D/S/R | 0.0044 s / 0.582 s / 0.630957 / 0.186 s |
| Instrument gain | -6 dB |
| Velocity multiplier | 0.4 + 0.6 × velocity |

<audio controls preload="none" aria-label="Csound Coral Crown 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 the second source and animate the filters

Set `giStage init 2` in the full script. Add a triangle layer at -13 dB, 0 semitones and 5 cents. Add the quieter octave-down sine sub. The notch center starts from 772 Hz and moves by -0.8 octaves under the second envelope. A positive depth opens the spectral ceiling; a negative depth moves the notch downward. The serial second filter keeps the specified high or low edge under control. Exact wavetable morphing, Warp/Fold and free-running source modulation are not implemented; the code below defines the chosen static spectra and note-local drift.

| Csound control | Value |
| --- | --- |
| Secondary layer | triangle, -13 dB; 0 st; 5 cents |
| Filter 1 | Notch, 772 Hz base, -0.8 octave depth |
| Filter contour | 0.02 / 1.1 / 0.2 / 0.3 |
| Filter 2 | Lowpass at 6.80 kHz |
| Pulse width | Not used |

<audio controls preload="none" aria-label="Csound Coral Crown 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 — Round the signal with saturation

Set `giStage init 3` in the full script. Use +2.4 dB drive with 70% shaped signal and -3 dB output trim. The smooth curve is `tanh(input × 3 × ampdb(drive)) / 3`; the other portion stays clean. Louder peaks enter its curved region more strongly, adding harmonics and rounding the envelope. This interprets the source saturation curve rather than implementing its proprietary transfer function.

| Csound control | Value |
| --- | --- |
| Drive / output | 2.4 / -3 dB |
| Shaped mix | 70% |
| Input DC removal | Order 2048 |

<audio controls preload="none" aria-label="Csound Coral Crown 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 stereo echoes

Set `giStage init 4` in the full script. Use 267 ms left and 267 ms right, 24% feedback and 18% wet. Inject the centered input on the left and cross-feed the filtered echoes so later repeats alternate sides. Filter each echo around 1800 Hz, with a 3.5-octave interval between highpass and lowpass cutoffs. Feedback values are updated once per 16-sample block, adding that small delay to the recirculating path. Held notes leave older colors behind the current tone.

| Csound control | Value |
| --- | --- |
| Times | 267 / 267 ms |
| Feedback / wet | 24% / 18% |
| Routing | Crossed, left input |
| Filter center / width | 1800 Hz / 3.5 octaves |
| Time LFO | 0 Hz, ±0% |

<audio controls preload="none" aria-label="Csound Coral Crown 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 — Set the final width and gain

Set `giStage init 5` in the full script. Use 5.27 dB gain after the effects. Scale the side signal by 1, preserving the center. Apply order-2048 DC removal, using a longer window to limit low-note loss. The fixed output-scale control at the end of instrument 90 remains a separate Csound gain setting. Clear the shared note buses only after processing them; effect memories continue carrying their own tails.

| Csound control | Value |
| --- | --- |
| Final gain | 5.27 dB |
| Width | 1 × side |
| Bass side cutoff | Off |
| DC removal | Order 2048 |

<audio controls preload="none" aria-label="Csound Coral Crown 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/coral-crown.webm) · [Complete settings](ALL_PARAMETERS.md) · [Ableton version](/tutorials/coral-crown/)

## Full Csound script

This document contains the complete Coral Crown source, shared effects and example score. `giStage` selects the cumulative stages from 1 to 5; 5 is the finished sound.

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

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

instr 1
  iHz = cpsmidinn(p4)
  iVelocity = limit(p5, 0, 1)
  kJ0 oscili 0, 0.1, giSine, 0.0
  aV0 vco2 ampdb(-9.0), iHz*pow(2,(-6.0+kJ0)/1200), 0, 0.5, 0.0
  if giStage >= 2 then
  aW0 vco2 ampdb(-13.0), iHz*pow(2,0/12+(-1.0)/1200), 12, 0.25, 0.0
  aV0 = aV0+aW0
  endif
  kJ1 oscili 0, 0.13, giSine, 0.3333333333333333
  aV1 vco2 ampdb(-9.0), iHz*pow(2,(0.0+kJ1)/1200), 0, 0.5, 0.3333333333333333
  if giStage >= 2 then
  aW1 vco2 ampdb(-13.0), iHz*pow(2,0/12+(5.0)/1200), 12, 0.25, 0.3333333333333333
  aV1 = aV1+aW1
  endif
  kJ2 oscili 0, 0.16, giSine, 0.6666666666666666
  aV2 vco2 ampdb(-9.0), iHz*pow(2,(6.0+kJ2)/1200), 0, 0.5, 0.6666666666666666
  if giStage >= 2 then
  aW2 vco2 ampdb(-13.0), iHz*pow(2,0/12+(11.0)/1200), 12, 0.25, 0.6666666666666666
  aV2 = aV2+aW2
  endif
  aL = (aV0*0.8+aV1*0.5+aV2*0.20000000000000007)/1.5
  aR = (aV0*0.2+aV1*0.5+aV2*0.8)/1.5
  if giStage >= 2 then
  aSub oscili ampdb(-18.0), iHz*0.5, giSine, 0
  aL = aL+aSub
  aR = aR+aSub
  endif
  if giStage >= 2 then
  kFilter linsegr 0, 0.02, 1, 1.1, 0.2, 0.3, 0
  kCut = limit(772.0*pow(2,-0.8*kFilter+0.0*(p4-60)/12),30,18000)
  aL butterbr aL, kCut, kCut/1.2
  aL butterlp aL, 6800.0
  aR butterbr aR, kCut, kCut/1.2
  aR butterlp aR, 6800.0
  endif
  kAmp linsegr 0, 0.0044, 1, 0.582, 0.6309573444801932, 0.186, 0
  kGain = kAmp*ampdb(-6.0)*(0.4+0.6*iVelocity)
  aL = aL*kGain
  aR = aR*kGain
  gaLeft = gaLeft+aL
  gaRight = gaRight+aR
endin
instr 90
  aL = gaLeft
  aR = gaRight
  if giStage >= 3 then
    aCleanL dcblock2 aL, 2048
    aShapeL = tanh(aCleanL*3*ampdb(2.4))/3
    aL = (aCleanL*0.30000000000000004+aShapeL*0.7)*ampdb(-3.0)
    aCleanR dcblock2 aR, 2048
    aShapeR = tanh(aCleanR*3*ampdb(2.4))/3
    aR = (aCleanR*0.30000000000000004+aShapeR*0.7)*ampdb(-3.0)
  endif
  if giStage >= 4 then
    aDelFbL init 0
    aDelFbR init 0
    kDelMotion = 0
    aDelTimeL interp 267.0*(1+0.0*kDelMotion)
    aDelTimeR interp 267.0*(1-0.0*kDelMotion)
    aDelSendL = (aL+aR)*0.5
    aDelSendR = 0
    aEchoL vdelay3 aDelSendL+aDelFbR*0.24, aDelTimeL, 2200
    aEchoR vdelay3 aDelSendR+aDelFbL*0.24, aDelTimeR, 2200
    kDelCenter = 1800.0*pow(2, 0.0*kDelMotion)
    aEchoL butterhp aEchoL, kDelCenter/pow(2, 1.75)
    aEchoL butterlp aEchoL, min(18000,kDelCenter*pow(2, 1.75))
    aEchoR butterhp aEchoR, kDelCenter/pow(2, 1.75)
    aEchoR butterlp aEchoR, min(18000,kDelCenter*pow(2, 1.75))
    aDelFbL = aEchoL
    aDelFbR = aEchoR
    aL = aL*0.8200000000000001+aEchoL*0.18
    aR = aR*0.8200000000000001+aEchoR*0.18
  endif
  if giStage >= 5 then
    aEndMid = (aL+aR)*0.5
    aEndSide = (aL-aR)*0.5*1.0
    aL = (aEndMid+aEndSide)*ampdb(5.27)
    aL dcblock2 aL, 2048
    aR = (aEndMid-aEndSide)*ampdb(5.27)
    aR dcblock2 aR, 2048
  endif
  outs aL*giOutputScale, aR*giOutputScale
  clear gaLeft, gaRight
endin
</CsInstruments>
<CsScore>
; p3 held seconds, p4 MIDI pitch, p5 velocity
i 1 0 0.8 48 0.8
i 1 2.1 0.8 55 0.9
i 1 4.2 0.8 60 0.72
i 90 0 20.3
e
</CsScore>
</CsoundSynthesizer>
```

[Read on playgrid.cc](https://playgrid.cc/tutorials/coral-crown/csound/)
