# Build Hazel Loom in Csound

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

Hazel Loom in Csound follows the sound-shaping ideas of the [Ableton Meld version](/tutorials/hazel-loom/), 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 drifting triangle cluster

Set `giStage init 1` in the full script. Use five triangle voices spread across ±42 cents, with independent sine drift of ±3.38 cents. Their different phases and slow rates make the held spectrum beat. Use engine gain −10 dB, amplitude attack 1.03 s, decay 2.43 s to −4 dB and release 2.26 s. A −8 dB instrument gain and 50% velocity response follow mild smooth drive. Spacing and motion are explicit Csound choices for the source macros.

| Csound control | Value |
| --- | --- |
| Triangle offsets | −42, −21, 0, +21, +42 cents |
| Drift | ±3.38 cents; 0.12 + abs(offset) × 0.005 Hz |
| A contour | 1.03 / 2.43 / −4 dB / 2.26 s |
| Engine / instrument gain | −10 / −8 dB |

<audio controls preload="none" aria-label="Csound Hazel Loom 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 slower octave and stereo filtering

Set `giStage init 2` in the full script. Enable the octave-up sine at −22 dB and +3.125 cents. Give it an independent 1.10 s attack, 4 s decay to −6 dB and 2.20 s release. Filter the triangle channels at 1550 Hz with Q 1.2; reverse the voice weights across the channels, bias A slightly left and B right. The octave enters later than the main cluster and can remain after its release. This interprets Basic Shapes and SVF rather than scanning the original engines.

| Csound control | Value |
| --- | --- |
| A lowpass | 1550 Hz, Q 1.2 |
| B pitch / level | 2 × note frequency, +3.125 cents / −22 dB |
| B contour | 1.10 / 4.00 / −6 dB / 2.20 s |
| Stereo voice weights | 0.8/0.7/0.5/0.3/0.2, reversed right; sum / 2.5 |

<audio controls preload="none" aria-label="Csound Hazel Loom 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 filtered stereo echoes

Set `giStage init 3` in the full script. Use 340 ms left and 470 ms right, 30% feedback and 22% wet. Inject the centered input on the left and cross-feed the filtered echoes so later repeats alternate sides. Filter each echo around 1700 Hz, with a 3-octave interval between highpass and lowpass cutoffs. A shared 0.18 Hz sine moves times by ±2% and the filter center by ±0.04 octaves. 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 | 340 / 470 ms |
| Feedback / wet | 30% / 22% |
| Routing | Crossed, left input |
| Filter center / width | 1700 Hz / 3 octaves |
| Time LFO | 0.18 Hz, ±2% |

<audio controls preload="none" aria-label="Csound Hazel Loom 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 30 ms predelay into `reverbsc`, with feedback 0.8233, 3200 Hz damping and 20% wet mix. Predelay leaves the initial articulation in front; feedback prolongs the tail, while damping darkens repeated circulation. The source room decay setting is 3.6 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 | 3.6 s (not a measured Csound decay) |
| Predelay / feedback | 30 ms / 0.8233 |
| Damping / wet | 3200 Hz / 20% |
| Room side multiplier | 1 |
| Room input cuts | Off |

<audio controls preload="none" aria-label="Csound Hazel Loom 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 9.12 dB gain after the effects. Scale the side signal by 1, preserving the center. Highpass only the side at 160 Hz to focus the lowest frequencies. 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 | 9.12 dB |
| Width | 1 × side |
| Bass side cutoff | 160 Hz |
| DC removal | Order 2048 |

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

## Full Csound script

This document contains the complete Hazel Loom 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.9284056
giSine ftgen 0, 0, 16384, 10, 1
gaLeft init 0
gaRight init 0

instr 1
  iHz = cpsmidinn(p4)
  iVelocity = limit(p5, 0, 1)
  kDrift0 oscili 3.38, 0.32999999999999996, giSine, 0.0
  aV0 vco2 ampdb(-10), iHz*pow(2,(-42.0+kDrift0)/1200), 12, 0.5, 0.0
  kDrift1 oscili 3.38, 0.22499999999999998, giSine, 0.18
  aV1 vco2 ampdb(-10), iHz*pow(2,(-21.0+kDrift1)/1200), 12, 0.5, 0.18
  kDrift2 oscili 3.38, 0.12, giSine, 0.36
  aV2 vco2 ampdb(-10), iHz*pow(2,(0+kDrift2)/1200), 12, 0.5, 0.36
  kDrift3 oscili 3.38, 0.22499999999999998, giSine, 0.54
  aV3 vco2 ampdb(-10), iHz*pow(2,(21.0+kDrift3)/1200), 12, 0.5, 0.54
  kDrift4 oscili 3.38, 0.32999999999999996, giSine, 0.72
  aV4 vco2 ampdb(-10), iHz*pow(2,(42.0+kDrift4)/1200), 12, 0.5, 0.72
  kA linsegr 0, 1.03, 1, 2.43, 0.6309573444801932, 2.26, 0
  aL = (aV0+aV1+aV2+aV3+aV4)/5*kA
  aR = aL
  if giStage >= 2 then
  kB linsegr 0, 1.1, 1, 4, 0.5011872336272722, 2.2, 0
  aB oscili ampdb(-22), iHz*2*pow(2,3.125/1200), giSine, 0
  aB = aB*kB
  aL = (aV0*0.8+aV1*0.7+aV2*0.5+aV3*0.3+aV4*0.2)/2.5*kA
  aR = (aV0*0.2+aV1*0.3+aV2*0.5+aV3*0.7+aV4*0.8)/2.5*kA
  aL lowpass2 aL, 1550.0, 1.2
  aR lowpass2 aR, 1550.0, 1.2
  aL = aL+aB*0.6
  aR = aR*0.85+aB*0.8
  endif
  aL = tanh(aL*1.1)/1.1*ampdb(-8)*(0.5+0.5*iVelocity)
  aR = tanh(aR*1.1)/1.1*ampdb(-8)*(0.5+0.5*iVelocity)
  gaLeft = gaLeft+aL
  gaRight = gaRight+aR
endin
instr 90
  aL = gaLeft
  aR = gaRight
  if giStage >= 3 then
    aDelFbL init 0
    aDelFbR init 0
    kDelMotion oscili 1, 0.18, giSine
    aDelTimeL interp 340.0*(1+0.02*kDelMotion)
    aDelTimeR interp 470.0*(1-0.02*kDelMotion)
    aDelSendL = (aL+aR)*0.5
    aDelSendR = 0
    aEchoL vdelay3 aDelSendL+aDelFbR*0.3, aDelTimeL, 2200
    aEchoR vdelay3 aDelSendR+aDelFbL*0.3, aDelTimeR, 2200
    kDelCenter = 1700.0*pow(2, 0.04*kDelMotion)
    aEchoL butterhp aEchoL, kDelCenter/pow(2, 1.5)
    aEchoL butterlp aEchoL, min(18000,kDelCenter*pow(2, 1.5))
    aEchoR butterhp aEchoR, kDelCenter/pow(2, 1.5)
    aEchoR butterlp aEchoR, min(18000,kDelCenter*pow(2, 1.5))
    aDelFbL = aEchoL
    aDelFbR = aEchoR
    aL = aL*0.78+aEchoL*0.22
    aR = aR*0.78+aEchoR*0.22
  endif
  if giStage >= 4 then
    aRoomInL = aL
    aRoomPreL delay aRoomInL, 0.03
    aRoomInR = aR
    aRoomPreR delay aRoomInR, 0.03
    aRoomL, aRoomR reverbsc aRoomPreL, aRoomPreR, 0.8233, 3200.0, sr, 0.4
    aRoomMid = (aRoomL+aRoomR)*0.5
    aRoomSide = (aRoomL-aRoomR)*0.5*1
    aL = aL*0.8+(aRoomMid+aRoomSide)*0.2
    aR = aR*0.8+(aRoomMid-aRoomSide)*0.2
  endif
  if giStage >= 5 then
    aEndMid = (aL+aR)*0.5
    aEndSide = (aL-aR)*0.5*1.0
    aEndSide butterhp aEndSide, 160.0
    aL = (aEndMid+aEndSide)*ampdb(9.12)
    aL dcblock2 aL, 2048
    aR = (aEndMid-aEndSide)*ampdb(9.12)
    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 4 48 0.8
i 1 7.26 4 55 0.9
i 1 14.52 4 60 0.72
i 90 0 34.78
e
</CsScore>
</CsoundSynthesizer>
```

[Read on playgrid.cc](https://playgrid.cc/tutorials/hazel-loom/csound/)
