The Patchbay_

Csound Cheat Sheet

Csound's structure in brief — the CSD file layout, the orchestra header, how instruments are written, and the score statements that drive them.

CSD file structure

<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>
; orchestra here
</CsInstruments>
<CsScore>
; score here
</CsScore>
</CsoundSynthesizer>
A complete .csd file: options, orchestra, score
-odacOutput to the audio device (-o out.wav writes a file)

Orchestra header

sr = 44100Audio sample rate
ksmps = 32Samples per control period
nchnls = 2Number of output channels
0dbfs = 1Full-scale amplitude — makes 1.0 the maximum

Variable rates (the prefix matters)

asiga-rate: audio, updated every sample
kampk-rate: control, updated every ksmps samples
ifni-rate: set once at note initialisation
gkvalPrefix with g for a global variable

Instruments

instr 1
  asig oscili 0.6, 440
  outs asig, asig
endin
An instrument: opcode outputs on the left, inputs on the right
ares oscili xamp, xcps[, ifn, iphs]The oscili signature — interpolating oscillator
out asig / outs aL, aRSend to the output (mono / stereo)
p4, p5Parameters passed in from the score's i-statement

Common opcodes

oscil, oscili, poscilTable oscillators (poscil is precise)
linen, madsr, expsegEnvelopes
moogladder, butterlp, resonFilters
reverbsc, freeverbReverbs
diskin2, loscilPlay back a sound file / sample

Score statements

i 1 0 2Play instrument 1, start at 0 s, last 2 s
i 1 0 2 440 0.5Extra fields arrive as p4, p5 …
f1 0 128 10 1Build function table 1: GEN10, a sine wave
eEnd the score
t 0 120Set the tempo to 120 BPM

Csound — Veteran synthesis & DSP language. · Csound in the tool directory →

← All cheat sheets