playgrid.ccRead tutorial

Tutorial 103 / Csound

Build Pewter Loom in Csound

Build Pewter Loom in Csound with subtractive bass synthesis, explicit contours and the sound-shaping chain explained in the guide.

4 stepsSubtractive BassCsound 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 first oscillator and touch contour

Set giStage init 1 in the full script. Use saw at -6 dB with pulse width 50% when applicable. The contour has 0.005 s attack, 0.799 s exponential decay to 0.65 sustain and 0.114 s release. Multiply by velocity^2.5; this explicit power curve interprets the source velocity response. Keep the signal centered before adding effects.

Csound control Value
Source Saw, -6.0 dB; width not used
Amplitude A/D/S/R 0.005 / 0.799 / 0.65 / 0.114
Amplifier / instrument -6.0 dB / -6.0 dB
Velocity power 2.5

Sound after step 1 — WebM/Opus

Next: Add the second oscillator and resonant contour →

Step 02 / 4

Add the second oscillator and resonant contour

Set giStage init 2 in the full script. Add rect at -12 dB, tuned by 0 octaves. Use a Low-pass 24dB/oct interpretation with 455 Hz base cutoff, 3.2 octave envelope depth and 0.5 octave-per-octave pitch tracking. The contour opens then settles quickly while the amplitude remains. Smooth input drive interprets Sym1; the ladder or second-order lowpass is a different circuit. The 1.7 Hz LFO, where enabled, restarts per score note rather than running freely.

Csound control Value
Second source Rect; -12 dB; width 25 %
Filter base / resonance 455 Hz / 0.52
Filter A/D/S/R 0.005 / 0.21 / 0.08 / 0.13
Envelope / key / LFO depth 3.2 / 0.5 / 0.12 octaves
LFO rate 1.7 Hz
Filter input shape tanh(input × 1.4) / 1.4

Sound after step 2 — WebM/Opus

Next: Round the signal with saturation →

Step 03 / 4

Round the signal with saturation

Set giStage init 3 in the full script. Use +3 dB drive with 70% shaped signal and -3 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.

Csound control Value
Drive / output 3 / -3 dB
Shaped mix 70%
Input DC removal Order 2048

Sound after step 3 — WebM/Opus

Next: Set the final width and gain →

Step 04 / 4

Set the final width and gain

Set giStage init 4 in the full script. Use 3.05 dB gain after the effects. Average the channels for identical mono outputs. 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 3.05 dB
Width Mono
Bass side cutoff Off
DC removal Order 2048

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 Pewter Loom 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 1.593511
giSine ftgen 0, 0, 16384, 10, 1
gaLeft init 0
gaRight init 0

instr 1
  iHz = cpsmidinn(p4)
  iVelocity = limit(p5, 0, 1)
  aSource vco2 ampdb(-6.0), iHz, 0, 0.5, 0
  if giStage >= 2 then
  aSecond vco2 ampdb(-12.0), iHz*pow(2,0+0/1200), 2, 0.25, 0
  aSource = aSource+aSecond
  kFilterGate linseg 0, 0.005, 1, 1, 1
  kFilterDecay expsegr 1, 0.005, 1, 0.21, 0.08, 0.13, 0.000001
  kFilter = kFilterGate*kFilterDecay
  kLFO oscili 1, 1.7, giSine
  kCut = limit(455.0*pow(2,3.2*kFilter+0.5*(p4-60)/12+0.12*kLFO),30,18000)
  aSource = tanh(aSource*1.4)/1.4
  aSource moogladder aSource, kCut, 0.52
  endif
  aAmpGate linseg 0, 0.005, 1, 1, 1
  aAmpDecay expsegr 1, 0.005, 1, 0.799, 0.65, 0.114, 0.000001
  aAmp = aAmpGate*aAmpDecay
  aL = aSource*aAmp*ampdb(-12.0)*iVelocity^2.5
  aR = aL
  gaLeft = gaLeft+aL
  gaRight = gaRight+aR
endin
instr 90
  aL = gaLeft
  aR = gaRight
  if giStage >= 3 then
    aCleanL dcblock2 aL, 2048
    aShapeL = tanh(aCleanL*3*ampdb(3.0))/3
    aL = (aCleanL*0.30000000000000004+aShapeL*0.7)*ampdb(-3.0)
    aCleanR dcblock2 aR, 2048
    aShapeR = tanh(aCleanR*3*ampdb(3.0))/3
    aR = (aCleanR*0.30000000000000004+aShapeR*0.7)*ampdb(-3.0)
  endif
  if giStage >= 4 then
    aEndMid = (aL+aR)*0.5
    aEndSide = (aL-aR)*0.5*0
    aL = (aEndMid+aEndSide)*ampdb(3.05)
    aL dcblock2 aL, 2048
    aR = (aEndMid-aEndSide)*ampdb(3.05)
    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 0.8 36 0.85
i 1 1.5 0.8 43 0.95
i 1 3 0.8 40 0.8
i 90 0 15.93
e
</CsScore>
</CsoundSynthesizer>