# Build Hammered Room Keys in Csound

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

Hammered Room Keys in Csound follows the sound-shaping ideas of the [Ableton Wavetable version](/tutorials/hammered-room-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 — Build the struck three-register body

Set `giStage init 1` in the full script. Use a pulse one octave above the note at −7 cents/−6 dB, a triangle two octaves above at −15 dB, and a quiet pulse at the played pitch at −27 dB. These fixed shapes interpret Basic Shapes positions and the colored sub rather than scan the original tables. The amplitude rises in 1 ms, decays over 1.4 s to −42 dB and releases over 250 ms.

| Csound control | Value |
| --- | --- |
| Main source | Pulse, octave up, −7 cents, −6 dB |
| Upper / low layer | Triangle +24 st at −15 dB / pulse at −27 dB |
| Amplitude | 1 ms / 1.4 s / −42 dB / 250 ms |
| Instrument / touch | −3 dB / 50% |

<audio controls preload="none" aria-label="Csound Hammered Room 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 — Close the strike filter quickly

Set `giStage init 2` in the full script. Apply a 1100 Hz ladder lowpass with +3 dB input drive and 0.062 resonance. Track pitch fully and open cutoff by 0.5 octaves under a 1 ms / 250 ms / zero / 100 ms contour. The fast spectral fall is independent of the longer amplitude decay.

| Csound control | Value |
| --- | --- |
| Cutoff / resonance | 1100 Hz base / 0.062 |
| Envelope / key tracking | 0.5 octaves / full |
| Filter contour | 1 ms / 250 ms / zero / 100 ms |

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

Set `giStage init 3` in the full script. Use +22 dB drive with 50% shaped signal and -21 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. A final tanh stage also interprets Soft Clip on the output.

| Csound control | Value |
| --- | --- |
| Drive / output | 22 / -21 dB |
| Shaped mix | 50% |
| Input DC removal | Off |
| Post clip | tanh |

<audio controls preload="none" aria-label="Csound Hammered Room 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 | 0.8 |
| Room input cuts | Off |

<audio controls preload="none" aria-label="Csound Hammered Room 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/Hammered-Room-Keys.webm) · [Complete settings](ALL_PARAMETERS.md) · [Ableton version](/tutorials/hammered-room-keys/)

## Full Csound script

This document contains the complete Hammered Room 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 1.390174
giSine ftgen 0, 0, 16384, 10, 1
gaLeft init 0
gaRight init 0

instr 1
  iHz = cpsmidinn(p4)
  iVelocity = limit(p5, 0, 1)
  aA vco2 ampdb(-6), iHz*pow(2,1-7/1200), 2, 0.5, 0
  aB vco2 ampdb(-15), iHz*4, 12, 0.5, 0
  aSub vco2 ampdb(-27), iHz, 2, 0.5, 0
  aSource = aA+aB+aSub
  if giStage >= 2 then
  kFilter linsegr 0, 0.001, 1, 0.25, 0, 0.1, 0
  kCut = limit(1100*pow(2,.5*kFilter+(p4-60)/12),30,18000)
  aSource moogladder aSource*ampdb(3),kCut,0.062
  endif
  kAmp linsegr 0, 0.001, 1, 1.4, 0.007943282347242814, 0.25, 0
  aL = aSource*kAmp*ampdb(-3)*(0.5+0.5*iVelocity)
  aR = aL
  gaLeft = gaLeft+aL
  gaRight = gaRight+aR
endin
instr 90
  aL = gaLeft
  aR = gaRight
  if giStage >= 3 then
    aCleanL = aL
    aShapeL = tanh(aCleanL*3*ampdb(22))/3
    aL = (aCleanL*0.5+aShapeL*0.5)*ampdb(-21)
    aCleanR = aR
    aShapeR = tanh(aCleanR*3*ampdb(22))/3
    aR = (aCleanR*0.5+aShapeR*0.5)*ampdb(-21)

    aL = tanh(aL)
    aR = tanh(aR)
  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*0.8
    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 1.5 48 0.8
i 1 2.75 1.5 55 0.9
i 1 5.5 1.5 60 0.72
i 90 0 30.25
e
</CsScore>
</CsoundSynthesizer>
```

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