# Build Pearl Well in Csound

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

Pearl Well in Csound follows the sound-shaping ideas of the [Ableton Analog version](/tutorials/pearl-well/), 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 first oscillator and touch contour

Set `giStage init 1` in the full script. Use saw at -6 dB with pulse width 50% when applicable. The contour has 0.005 s attack, 0.75 s exponential decay to 0.65 sustain and 0.114 s release. Multiply by velocity^2.5; this explicit power curve interprets the source velocity response. Keep the signal centered before adding effects.

| Csound control | Value |
| --- | --- |
| Source | Saw, -6.0 dB; width not used |
| Amplitude A/D/S/R | 0.005 / 0.75 / 0.65 / 0.114 |
| Amplifier / instrument | -6.0 dB / -6.0 dB |
| Velocity power | 2.5 |

<audio controls preload="none" aria-label="Csound Pearl Well 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 second oscillator and resonant contour

Set `giStage init 2` in the full script. Add rect at -12 dB, tuned by 0 octaves. Use a Low-pass 24dB/oct interpretation with 209 Hz base cutoff, 3.2 octave envelope depth and 0.5 octave-per-octave pitch tracking. The contour opens then settles quickly while the amplitude remains. Smooth input drive interprets Sym1; the ladder or second-order lowpass is a different circuit. The 1.7 Hz LFO, where enabled, restarts per score note rather than running freely.

| Csound control | Value |
| --- | --- |
| Second source | Rect; -12 dB; width 45 % |
| Filter base / resonance | 209 Hz / 0.52 |
| Filter A/D/S/R | 0.005 / 0.21 / 0.08 / 0.13 |
| Envelope / key / LFO depth | 3.2 / 0.5 / 0.12 octaves |
| LFO rate | 1.7 Hz |
| Filter input shape | tanh(input × 1.4) / 1.4 |

<audio controls preload="none" aria-label="Csound Pearl Well 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 +3.5 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 | 3.5 / -3 dB |
| Shaped mix | 70% |
| Input DC removal | Order 2048 |

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

Set `giStage init 4` in the full script. Use 2.27 dB gain after the effects. Average the channels for identical mono outputs. 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 | 2.27 dB |
| Width | Mono |
| Bass side cutoff | Off |
| DC removal | Order 2048 |

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

## Full Csound script

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

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

giStage init 4
giOutputScale init 1.800778
giSine ftgen 0, 0, 16384, 10, 1
gaLeft init 0
gaRight init 0

instr 1
  iHz = cpsmidinn(p4)
  iVelocity = limit(p5, 0, 1)
  aSource vco2 ampdb(-6.0), iHz, 0, 0.5, 0
  if giStage >= 2 then
  aSecond vco2 ampdb(-12.0), iHz*pow(2,0+0/1200), 2, 0.45, 0
  aSource = aSource+aSecond
  kFilterGate linseg 0, 0.005, 1, 1, 1
  kFilterDecay expsegr 1, 0.005, 1, 0.21, 0.08, 0.13, 0.000001
  kFilter = kFilterGate*kFilterDecay
  kLFO oscili 1, 1.7, giSine
  kCut = limit(209.0*pow(2,3.2*kFilter+0.5*(p4-60)/12+0.12*kLFO),30,18000)
  aSource = tanh(aSource*1.4)/1.4
  aSource moogladder aSource, kCut, 0.52
  endif
  aAmpGate linseg 0, 0.005, 1, 1, 1
  aAmpDecay expsegr 1, 0.005, 1, 0.75, 0.65, 0.114, 0.000001
  aAmp = aAmpGate*aAmpDecay
  aL = aSource*aAmp*ampdb(-12.0)*iVelocity^2.5
  aR = aL
  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(3.5))/3
    aL = (aCleanL*0.30000000000000004+aShapeL*0.7)*ampdb(-3.0)
    aCleanR dcblock2 aR, 2048
    aShapeR = tanh(aCleanR*3*ampdb(3.5))/3
    aR = (aCleanR*0.30000000000000004+aShapeR*0.7)*ampdb(-3.0)
  endif
  if giStage >= 4 then
    aEndMid = (aL+aR)*0.5
    aEndSide = (aL-aR)*0.5*0
    aL = (aEndMid+aEndSide)*ampdb(2.27)
    aL dcblock2 aL, 2048
    aR = (aEndMid-aEndSide)*ampdb(2.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 36 0.85
i 1 1.5 0.8 43 0.95
i 1 3 0.8 40 0.8
i 90 0 15.93
e
</CsScore>
</CsoundSynthesizer>
```

[Read on playgrid.cc](https://playgrid.cc/tutorials/pearl-well/csound/)
