# Build Clover Prism in Csound

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

Clover Prism is an evolving synth with a tightly spaced triangle cluster, a 392 ms entrance and a quieter octave bloom. The main engine releases faster than the octave layer, so the tail changes color after note-off. This Csound version interprets the [Ableton Meld sound](/tutorials/clover-prism/) using explicit oscillators and effect controls.

Signal flow: **triangle cluster + octave sine → separate filters and envelopes → mild drive → filtered cross-feedback delay → hall → bass narrowing and gain**.

[Starting settings](STARTING_STATE.md) · [Complete settings](ALL_PARAMETERS.md). The full script appears at the end of the guide.

## Step 1 — Shape a drifting triangle cluster

Use the `SwarmVoice` opcode and note instrument from the full script with `giStage init 1`. Each voice is a band-limited triangle from `vco2` mode 12. Mix five voices at −12.0, −6.0, 0, +6.0 and +12.0 cents; divide their sum by five so adding voices does not multiply the source level.

```csound
kDrift oscili 1.2, 0.12+abs(iCents)*0.005, giSine, iPhase
kHz = iHz*pow(2, (iCents+kDrift)/1200)
aTone vco2 1, kHz, 12, 0.5, iPhase
```

Each oscillator drifts by ±1.2 cents at a slightly different slow rate. Those rates and the fixed pitch spacing make sustained notes beat and change color. The triangle cluster is an interpretation of Swarm Triangle: its detuning and drift values are explicit Csound choices, not a conversion of Meld's Motion and Spacing macros.

The ±12-cent cluster keeps its pitch center tighter than the wider Cinder Orbit cluster. Set engine A's linear envelope to 392 ms attack, 2.05 s decay, −4 dB sustain and 1.20 s release. Apply −10 dB engine gain and −8 dB instrument gain, with velocity scaling `0.5 + 0.5 × velocity`. The mild `tanh(signal × 1.1) / 1.1` drive rounds peaks before instrument gain. At this stage both output channels carry the same cluster, so movement comes from beating rather than stereo spread.

<audio controls preload="none" aria-label="Csound Clover Prism 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 bloom and stereo filtering

Set `giStage init 2`. Offset engine A by −3.125 cents and engine B by +3.125 cents, on top of B's octave-up tuning. These small opposing offsets interpret the source's spread behavior.

For the cluster, use left weights 0.8, 0.7, 0.5, 0.3 and 0.2, with reversed weights on the right. Divide each sum by 2.5. Apply `lowpass2` at 1720 Hz with Q 1.2 to each channel, then multiply A's right channel by 0.85 for a slight left bias. This resonance is a Csound choice, not the numeric Meld Q value.

```csound
kEnvB linsegr 0, 1.10, 1, 4.00, ampdb(-6), 2.20, 0
aB oscili kEnvB*ampdb(-22), iHz*2*pow(2, 3.125/1200), giSine, 0.17
aB butterlp aB, 3600
aBL, aBR pan2 aB, 0.625
```

Engine B is a sine with 1.10 s attack, 4 s decay, −6 dB sustain and 2.20 s release, followed by a 3600 Hz lowpass. Its −22 dB gain makes the octave layer quieter than A. Panning B to 0.625 places it slightly right, opposite A's bias. Add both engines before the mild drive. Long notes reveal B arriving after A, while the filtered triangles retain a soft, beating body.

<audio controls preload="none" aria-label="Csound Clover Prism 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 moving, filtered cross-feedback echoes

Set `giStage init 3`. In instrument 90, use delay times centered on 340 ms left and 470 ms right. A shared 0.18 Hz LFO moves them by ±2%, in opposite directions. `interp` smooths the delay-time signal to audio rate.

```csound
aDelayL interp 340*(1+0.02*kMotion)
aDelayR interp 470*(1-0.02*kMotion)
aEchoL vdelay3 aDryL+aFeedbackR*0.30, aDelayL, 1000
aEchoR vdelay3 aDryR+aFeedbackL*0.30, aDelayR, 1000
```

Filter both delayed outputs before assigning the feedback signals. Use a moving center `1700 × 2^(0.04 × LFO)` Hz, with a highpass at center / 2^1.5 and lowpass at center × 2^1.5. This interprets the source's delay filter as a three-octave passband. The filter motion is subtle; repeated echoes gradually lose lows and highs.

Cross-feed each filtered echo to the opposite delay at 30%, then mix 78% dry and 22% wet. The unequal paths and crossed repeats make the tail wander across the stereo field. The feedback assignment adds one control block to each feedback trip. This timing difference and the modulation scaling are Csound-specific interpretations of the source's ping-pong delay.

<audio controls preload="none" aria-label="Csound Clover Prism 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 a damped hall after the echoes

Set `giStage init 4`. Feed the entire delay mix into a 30 ms predelay and then `reverbsc` with feedback 0.80 and damping at 3200 Hz.

```csound
aPreL delay aDryL, 0.030
aPreR delay aDryR, 0.030
aHallL, aHallR reverbsc aPreL, aPreR, 0.80, 3200
aMixL = aDryL*0.80+aHallL*0.20
aMixR = aDryR*0.80+aHallR*0.20
```

The 20% wet mix surrounds the separate repeats with a softer continuous tail. Predelay preserves the front of each swell; damping makes the hall darker as it fades. Its feedback setting interprets the source's 2.81 s room character, without claiming the same decay time, diffusion or room size.

<audio controls preload="none" aria-label="Csound Clover Prism 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 — Focus the bass and apply the output gain

Set `giStage init 5` for the finished sound. Convert the delay-and-hall mix to mid/side and highpass only the side at 160 Hz. Reconstruct both channels, apply +9.13 dB and remove DC.

```csound
aMid = (aMixL+aMixR)*0.5
aSide = (aMixL-aMixR)*0.5
aSide butterhp aSide, 160
aMixL dcblock2 (aMid+aSide)*ampdb(9.13), 2048
aMixR dcblock2 (aMid-aSide)*ampdb(9.13), 2048
```

Reducing low side energy gives the moving upper image a more stable bass center. The output gain follows every effect, so it raises the body and tails together. Instrument 90 clears both note buses after processing; its delay and reverb memories continue carrying the existing tail. The finished tone has a soft triangle body, a slower octave sheen and a wide, moving upper tail.

<audio controls preload="none" aria-label="Csound Clover Prism 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/clover-prism.webm) · [Complete settings](ALL_PARAMETERS.md) · [Ableton implementation](/tutorials/clover-prism/)

## Full Csound script

The complete Clover Prism instrument includes a moving triangle cluster, an independently swelling octave layer, filtered stereo echoes, a hall and bass narrowing. Set `giStage` from 1 to 5 to hear the cumulative stages; 5 is the finished sound. Instrument 1 takes held seconds in p3, MIDI pitch in p4 and velocity from 0 to 1 in p5. Instrument 90 carries the shared effects through note releases and echo tails.

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

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

; Independent drifting triangle oscillators interpret the swarm character.
opcode SwarmVoice, a, iii
  iHz, iCents, iPhase xin
  kDrift oscili 1.2, 0.12+abs(iCents)*0.005, giSine, iPhase
  kHz = iHz*pow(2, (iCents+kDrift)/1200)
  aTone vco2 1, kHz, 12, 0.5, iPhase
  xout aTone
endop

instr 1
  iHz = cpsmidinn(p4)
  iVelocity = limit(p5, 0, 1)
  iACents = 0
  if giStage >= 2 then
    iACents = -3.125
  endif
  iBase = iHz*pow(2, iACents/1200)
  a1 SwarmVoice iBase, -12.0, 0.05
  a2 SwarmVoice iBase, -6.0, 0.23
  a3 SwarmVoice iBase, 0, 0.41
  a4 SwarmVoice iBase, 6.0, 0.62
  a5 SwarmVoice iBase, 12.0, 0.84
  kEnvA linsegr 0, 0.392, 1, 2.05, ampdb(-4), 1.20, 0
  aAL = (a1+a2+a3+a4+a5)/5
  aAR = aAL
  aBL init 0
  aBR init 0
  if giStage >= 2 then
    ; Distribute the swarm across the image, then soften each channel.
    aAL = (a1*0.8+a2*0.7+a3*0.5+a4*0.3+a5*0.2)/2.5
    aAR = (a1*0.2+a2*0.3+a3*0.5+a4*0.7+a5*0.8)/2.5
    aAL lowpass2 aAL, 1720, 1.2
    aAR lowpass2 aAR, 1720, 1.2
    aAR = aAR*0.85
    kEnvB linsegr 0, 1.10, 1, 4.00, ampdb(-6), 2.20, 0
    aB oscili kEnvB*ampdb(-22), iHz*2*pow(2, 3.125/1200), giSine, 0.17
    aB butterlp aB, 3600
    aBL, aBR pan2 aB, 0.625
  endif
  aAL = aAL*kEnvA*ampdb(-10)
  aAR = aAR*kEnvA*ampdb(-10)
  kGain = (0.5+0.5*iVelocity)*ampdb(-8)
  ; Mild smooth drive interprets Meld's 5% drive setting.
  aOutL = tanh((aAL+aBL)*1.1)/1.1*kGain
  aOutR = tanh((aAR+aBR)*1.1)/1.1*kGain
  gaLeft = gaLeft+aOutL
  gaRight = gaRight+aOutR
endin

instr 90
  aDryL = gaLeft
  aDryR = gaRight
  aFeedbackL init 0
  aFeedbackR init 0
  if giStage >= 3 then
    ; Free-running modulation is shared by every note.
    kMotion oscili 1, 0.18, giSine
    aDelayL interp 340*(1+0.02*kMotion)
    aDelayR interp 470*(1-0.02*kMotion)
    aEchoL vdelay3 aDryL+aFeedbackR*0.30, aDelayL, 1000
    aEchoR vdelay3 aDryR+aFeedbackL*0.30, aDelayR, 1000
    kCenter = 1700*pow(2, 0.04*kMotion)
    ; A three-octave passband interprets the delay's Width control.
    aEchoL butterhp aEchoL, kCenter/pow(2, 1.5)
    aEchoL butterlp aEchoL, kCenter*pow(2, 1.5)
    aEchoR butterhp aEchoR, kCenter/pow(2, 1.5)
    aEchoR butterlp aEchoR, kCenter*pow(2, 1.5)
    aFeedbackL = aEchoL
    aFeedbackR = aEchoR
    aDryL = aDryL*0.78+aEchoL*0.22
    aDryR = aDryR*0.78+aEchoR*0.22
  endif
  aMixL = aDryL
  aMixR = aDryR
  if giStage >= 4 then
    aPreL delay aDryL, 0.030
    aPreR delay aDryR, 0.030
    aHallL, aHallR reverbsc aPreL, aPreR, 0.80, 3200
    aMixL = aDryL*0.80+aHallL*0.20
    aMixR = aDryR*0.80+aHallR*0.20
  endif
  if giStage >= 5 then
    aMid = (aMixL+aMixR)*0.5
    aSide = (aMixL-aMixR)*0.5
    aSide butterhp aSide, 160
    aMixL dcblock2 (aMid+aSide)*ampdb(9.13), 2048
    aMixR dcblock2 (aMid-aSide)*ampdb(9.13), 2048
  endif
  outs aMixL, aMixR
  clear gaLeft, gaRight
endin
</CsInstruments>
<CsScore>
; Held tones let the delayed octave bloom and moving echoes become audible.
;       start hold MIDI velocity
i 1     0     4    48    0.70
i 1     0     4    55    0.70
i 1     0     4    60    0.70
i 1     6.5   4    53    0.82
i 1     6.5   4    60    0.82
i 1     6.5   4    64    0.82
i 90    0     22
e
</CsScore>
</CsoundSynthesizer>
```

[Read on playgrid.cc](https://playgrid.cc/tutorials/clover-prism/csound/)
