Opcodes

Opcodes do things. They are the brains of each and every Csound instrument. What they do is usually described by their name. reverb for example applies a reverb to an audio signal while random generates random numbers. Opcodes, like variables, can be a, k, or i-rate.

In their most common form, opcodes are given input arguments and output a result. The rate at which an opcode operates is determined by the output variable name. Outputs always appear to the left of an opcode name, while inputs always appear to the right of the opcode name. The typical syntax for most opcodes in Csound is give as

aOutput opcode input1, input2, input3, ...

Note that aOutput is the output variable. It can be called anything you like, but it must begin with an a, k or i, depending on the opcode.While most opcodes in Csound have outputs as well as inputs, some opcodes only have inputs, while others only have outputs. It should also be noted that not every opcode can operate at a, k and i rate. The simplest way to see what rates are supported by what opcode is by looking at the Csound reference manual.

Lines of opcodes can be connected to create a signal graph which describs the flow of the signal from one place to another. We can see in the next code example how the signal generated by myOcopde1 is being fed into the first input of myOpcode2, whose output is passed to the first input of myOpode3. Remember that the result of each opcode's calculations are passed to its output parameter, which is located to the right of the opcode. These output variables can then be used anywhere else in the current instrument block.

instr 1
a1 myOpcode1 
a2 myOpcode2 a1
a3 myOpcode3 a2
endin

Csound features almost 1500 opcodes, making it one of the world's most extensive audio programming languages.