Quick start
This guide will help you create and run your first Csound program. In just a few minutes, you’ll be generating sound and understanding the basics of Csound’s architecture.Make sure you have installed Csound before proceeding.
Your first Csound program
Let’s start with a simple “Hello World” example that generates a sine wave tone.Add the basic structure
A Csound program has three main sections:Let’s break this down:CsOptions: Command-line options for Csound
hello.csd
-o dacoutputs audio to your speakers in real-time
sr = 44100: Sample rate (44.1 kHz)ksmps = 32: Control rate (samples per control period)nchnls = 2: Number of output channels (stereo)0dbfs = 1: 0 dB full scale = 1.0 (amplitude reference)instr 1: Defines instrument number 1oscil: Oscillator opcode generating a sine waveouts: Outputs to stereo channels
i 1 0 2: Play instrument 1, starting at time 0, for duration 2 secondse: End of score
Understanding Csound architecture
Csound uses a modular architecture with two main components:Orchestra
The orchestra (CsInstruments) contains your instrument definitions. Think of it as your synthesizer design.
Score
The score (CsScore) controls when instruments play and what parameters they receive. Think of it as your sequencer.
Signal types
Csound uses different variable prefixes to indicate signal types:- i-rate (i-variables): Initialized once at note start
- k-rate (k-variables): Control rate, updated every
ksmpssamples - a-rate (a-variables): Audio rate, updated every sample
- S-rate (S-variables): String variables
A more interesting example
Let’s create a simple plucked string instrument using the example from the Csound source:Score notation
The score uses a simple text format:Instrument statements (i-statements)
- i: Instrument statement
- name/number: Instrument identifier (can be number or string)
- start: Start time in seconds
- duration: Duration in seconds
- p4, p5, …: Additional parameters passed to the instrument
Function tables (f-statements)
- f: Function table statement
- number: Table number for reference
- start: Creation time (usually 0)
- size: Table size (usually power of 2)
- GEN: Generator routine number
- args: Arguments for the generator
GEN10 creates a waveform using sine wave harmonics. f 1 0 16384 10 1 creates a simple sine wave.Real-time vs. rendering
Csound can output audio in two ways:- Real-time output
- Render to file
Play audio through your speakers immediately:The
-o dac option sends output to your audio device (DAC = Digital-to-Analog Converter).Common opcodes to explore
Here are some essential opcodes to experiment with:oscil / oscili
Basic oscillators for generating waveforms (sine, saw, square, etc.)
pluck
Karplus-Strong plucked string algorithm
reverb / freeverb
Add reverb and spatial effects
moog
Moog-style low-pass filter
delay / delayr/delayw
Create echo and delay effects
lfo
Low-frequency oscillator for modulation
Useful command-line options
Next steps
Now that you’ve created your first Csound programs:Explore opcodes
Browse the Csound Reference Manual for thousands of opcodes
Learn the API
Embed Csound in your own applications
Join the community
Connect with other Csound users and developers
Study examples
Check the examples directory in the Csound source repository