Syntax of the Orchestra

The Csound orchestra (.orc) or the <CsInstruments> section of a csd file, contains:

The orchestra header, instrument blocks, and UDOs contain Orchestra statements. An orchestra statement in Csound has the format:

      label:   result opcode argument1, argument2, ... ;comments

The label is optional and identifies the basic statement that follows as the potential target of a go-to operation (see Program Flow Control). A label has no effect on the statement per se.

Depending on their function, some opcodes produce no output, so they have no result value. Others take no arguments and only produce a result.

Every orchestra statement must be on a single line, however long lines can be wrapped to a new line using the '\' character. This character indicates that the next line is part of the current one, this way you can split a line for easier reading, like this:

a2  oscbnk kcps, 1.0, kfmd1, 0.0, 40, 203, 0.1, 0.2, kamfr, kamfr2, 148,  \
           0, 0, 0, 0, 0, 0, -1,                                          \
           kfnum, 3, 4

Comments are optional and are for the purpose of letting the user document his orchestra code. Comments begin with a semicolon (;) or // and extend to the end of the line. Comments can optionally be in C-style, spanning multiple lines like this:

/* Anything in here --------
   is a comment which can span
   several lines ---------  */

The remainder (result, opcode, and arguments) form the basic statement. This also is optional, i.e. a line may have only a label or comment or be entirely blank. If present, the basic statement must be complete on one line, and is terminated by a carriage return and line feed.

The opcode determines the operation to be performed; it usually takes some number of input values (or arguments, with a maximum value of about 800); and it usually has a result field variable to which it sends output values at some fixed rate. There are four possible rates:

  1. once only, at orchestra setup time (effectively a permanent assignment)

  2. once at the beginning of each note (at initialization (init) time: i-rate)

  3. once every performance-time control loop (perf-time control rate, or k-rate)

  4. once each sound sample of every control loop (perf-time audio rate, or a-rate)

Orchestra Header Statements

The Orchestra Header contains global information that applies to all instruments and defines aspects of Csound output. It is sometimes referred to as instr 0, because it behaves as an instrument, but without k- or a-rate processing (i.e. only opcodes and instructions that work at i-rate are allowed).

An orchestra header statement operates once only, at orchestra setup time. It is most commonly an assignment of some value to a global reserved symbol , e.g. sr = 20000. All orchestra header statements belong to a pseudo instrument 0, an init pass of which is run prior to all other instruments at score time 0. Any ordinary statement can serve as an orchestra header statement, eg. gifreq = cpspch(8.09) provided it is an init-time only operation. Statements that are normally placed in an orchestra header are:

For example, a Csound header may look like:

xxsr = 44100
kr = 4410
ksmps = 10
nchnls = 2
0dbfs = 1

massign 1, 10