playgrid.ccRead tutorial

Tutorial 012 / Csound

Build Random Filter Keys in Csound

Build Random Filter Keys in Csound with random filter keys synthesis, explicit contours and the sound-shaping chain explained in the guide.

4 stepsRandom Filter KeysCsound 6

Listen to the finished sound

Download WEBM ↓

Follow the synthesis steps in order. Use the audio examples and device settings alongside the instructions.

Step 01 / 4

Build the two-octave resonant body

Set giStage init 1 in the full script. Blend two saws at −6 dB each: one at the note plus two cents, the other an octave down. Add an octave-down sine at −15 dB. A 300 Hz tracked ladder lowpass uses resonance 0.67 and +3 dB smooth drive. The amplitude has 57 ms attack, decay and release with −2.3 dB sustain; instrument gain is −19 dB with 50% touch response.

Csound control Value
Saw / sub −6/−6 dB saws; octave-down sine −15 dB
Filter 300 Hz, full tracking, 0.67 resonance, +3 dB drive
Amplitude 57 ms / 57 ms / −2.3 dB / 57 ms
Instrument −19 dB

Sound after step 1 — WebM/Opus

Next: Jump between random filter states →

Step 02 / 4

Jump between random filter states

Set giStage init 2 in the full script. A sample-and-hold random value changes at 2.67 Hz. Use it for ±1 octave of cutoff and ±3 dB of input drive. Positive values brighten and push the resonant filter, while negative values darken it. Each note has its own random generator; the exact source noise waveform and modulation scale differ.

Csound control Value
Random rate 2.67 Hz
Cutoff / drive movement ±1 octave / ±3 dB

Sound after step 2 — WebM/Opus

Next: Add filtered stereo echoes →

Step 03 / 4

Add filtered stereo echoes

Set giStage init 3 in the full script. Use 750 ms left and 775 ms right, 25% feedback and 30% wet. Feed each channel back into itself, keeping the unequal timing paths independent. Filter each echo around 900 Hz, with a 7-octave interval between highpass and lowpass cutoffs. 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 750 / 775 ms
Feedback / wet 25% / 30%
Routing Independent channels
Filter center / width 900 Hz / 7 octaves
Time LFO 0 Hz, ±0%

Sound after step 3 — WebM/Opus

Next: Surround the tone with a damped room →

Step 04 / 4

Surround the tone with a damped room

Set giStage init 4 in the full script. Feed the preceding signal through 5 ms predelay into reverbsc, with feedback 0.9512, 1800 Hz damping and 15% wet mix. Predelay leaves the initial articulation in front; feedback prolongs the tail, while damping darkens repeated circulation. The source room decay setting is 14 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 14 s (not a measured Csound decay)
Predelay / feedback 5 ms / 0.9512
Damping / wet 1800 Hz / 15%
Room side multiplier 1
Room input cuts Off

Sound after step 4 — WebM/Opus

Audio & settings ↓

Audio & settings

Audio recordings and settings for this tutorial.

Full Csound script

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

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

giStage init 4
giOutputScale init 4.070113
giSine ftgen 0, 0, 16384, 10, 1
gaLeft init 0
gaRight init 0
seed 37
instr 1
  iHz = cpsmidinn(p4)
  iVelocity = limit(p5, 0, 1)
  aSaw1 vco2 ampdb(-6),iHz*pow(2,2/1200),0
  aSaw2 vco2 ampdb(-6),iHz*0.5,0
  aSub oscili ampdb(-15),iHz*0.5,giSine
  aSource = aSaw1+aSaw2+aSub
  kRandom = 0
  if giStage >= 2 then
    kNew randomh -1,1,2.67
    kRandom = kNew
  endif
  kCut = limit(300*pow(2,(p4-60)/12+kRandom),30,18000)
  aDrive = tanh(aSource*ampdb(3+3*kRandom))
  aSource moogladder aDrive,kCut,0.67
  kAmp linsegr 0, 0.057, 1, 0.057, 0.7673614893618189, 0.057, 0
  aL = aSource*kAmp*ampdb(-19)*(0.5+0.5*iVelocity)
  aR = aL
  gaLeft = gaLeft+aL
  gaRight = gaRight+aR
endin
instr 90
  aL = gaLeft
  aR = gaRight
  if giStage >= 3 then
    aDelFbL init 0
    aDelFbR init 0
    kDelMotion = 0
    aDelTimeL interp 750.0*(1+0*kDelMotion)
    aDelTimeR interp 775.0*(1-0*kDelMotion)
    aDelSendL = aL
    aDelSendR = aR
    aEchoL vdelay3 aDelSendL+aDelFbL*0.25, aDelTimeL, 2200
    aEchoR vdelay3 aDelSendR+aDelFbR*0.25, aDelTimeR, 2200
    kDelCenter = 900*pow(2, 0*kDelMotion)
    aEchoL butterhp aEchoL, kDelCenter/pow(2, 3.5)
    aEchoL butterlp aEchoL, min(18000,kDelCenter*pow(2, 3.5))
    aEchoR butterhp aEchoR, kDelCenter/pow(2, 3.5)
    aEchoR butterlp aEchoR, min(18000,kDelCenter*pow(2, 3.5))
    aDelFbL = aEchoL
    aDelFbR = aEchoR
    aL = aL*0.7+aEchoL*0.3
    aR = aR*0.7+aEchoR*0.3
  endif
  if giStage >= 4 then
    aRoomInL = aL
    aRoomPreL delay aRoomInL, 0.005
    aRoomInR = aR
    aRoomPreR delay aRoomInR, 0.005
    aRoomL, aRoomR reverbsc aRoomPreL, aRoomPreR, 0.9512, 1800, sr, 0.4
    aRoomMid = (aRoomL+aRoomR)*0.5
    aRoomSide = (aRoomL-aRoomR)*0.5*1
    aL = aL*0.85+(aRoomMid+aRoomSide)*0.15
    aR = aR*0.85+(aRoomMid-aRoomSide)*0.15
  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 3 2 55 0.85
i 1 6 2 60 0.7
i 90 0 40.057
e
</CsScore>
</CsoundSynthesizer>