# Build Faded Circuit Keys in Csound

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

Faded Circuit Keys in Csound follows the sound-shaping ideas of the [Ableton Drift version](/tutorials/faded-circuit-keys/), 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 — Shape the wobbling sustained source

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

| Csound 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="Csound 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 `giStage init 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.

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

<audio controls preload="none" aria-label="Csound 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 `giStage init 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.

| Csound control | Value |
| --- | --- |
| Hold rate | 24000 Hz |
| Signed bits / wet | 9 / 35% |

<audio controls preload="none" aria-label="Csound 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 `giStage init 4` in the full script. Feed the preceding signal through 8 ms predelay into `reverbsc`, with feedback 0.9209, 3000 Hz damping and 22% wet mix. Predelay leaves the initial articulation in front; feedback prolongs the tail, while damping darkens repeated circulation. The source room decay setting is 8.5 seconds, but Csound feedback is not a decay-time control: this is an interpretation of that space, with different diffusion and modulation. 

| Csound control | Value |
| --- | --- |
| Source decay target | 8.5 s (not a measured Csound decay) |
| Predelay / feedback | 8 ms / 0.9209 |
| Damping / wet | 3000 Hz / 22% |
| Room side multiplier | 1 |
| Room input cuts | Off |

<audio controls preload="none" aria-label="Csound 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/)

## Full Csound script

This document contains the complete Faded Circuit Keys 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 0.6459676
giSine ftgen 0, 0, 16384, 10, 1
gaLeft init 0
gaRight init 0

instr 1
  iHz = cpsmidinn(p4)
  iVelocity = limit(p5, 0, 1)
  kWobble oscili 5.2,1.25,giSine
  kDrift oscili 2.4,0.13,giSine,0.2
  kHz = iHz*pow(2,(kWobble+kDrift)/1200)
  aSaw vco2 ampdb(3),kHz,0
  aTri vco2 ampdb(3),kHz,12
  aSource = aSaw*0.86+aTri*0.14
  kFilter linsegr 0, 0.001, 1, 8.5, 0, 18, 0
  kCut = limit(800*pow(2,1.05*kFilter+(p4-60)/12),30,18000)
  aSource moogladder aSource,kCut,0
  aSource butterhp aSource,10
  kAmp linsegr 0, 0.001, 1, 3.85, 1, 8.5, 0
  aL = aSource*kAmp*ampdb(-12)*(0.5+0.5*iVelocity)
  aR = aL
  gaLeft = gaLeft+aL
  gaRight = gaRight+aR
endin
instr 90
  aL = gaLeft
  aR = gaRight
  if giStage >= 2 then
    aBandL butterbp aL,650,650/0.6
    aBandR butterbp aR,650,650/0.6
    aBandL butterbp aBandL,650,650/0.6
    aBandR butterbp aBandR,650,650/0.6
    aL = aL*0.7+aBandL*0.3
    aR = aR*0.7+aBandR*0.3
  endif
  if giStage >= 3 then
    aDigitalClock mpulse 1, 4.1666666666666665e-05
    aHeldL samphold aL, aDigitalClock
    aQuantL = round(aHeldL*256)/256
    aL = aL*0.65+aQuantL*0.35
    aHeldR samphold aR, aDigitalClock
    aQuantR = round(aHeldR*256)/256
    aR = aR*0.65+aQuantR*0.35
  endif
  if giStage >= 4 then
    aRoomInL = aL
    aRoomPreL delay aRoomInL, 0.008
    aRoomInR = aR
    aRoomPreR delay aRoomInR, 0.008
    aRoomL, aRoomR reverbsc aRoomPreL, aRoomPreR, 0.9209, 3000, sr, 0.4
    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
  endif
  outs aL*giOutputScale, aR*giOutputScale
  clear gaLeft, gaRight
endin
</CsInstruments>
<CsScore>
; p3 held seconds, p4 MIDI pitch, p5 velocity
i 1 0 2 48 0.75
i 1 5 2 55 0.85
i 1 10 2 60 0.7
i 90 0 53
e
</CsScore>
</CsoundSynthesizer>
```

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