Tootorials

Learning Csound takes time and patience. In this section you will find a set of "tootorials" which will introduce you to the capabilities and the processes of working with Csound.

Toot 1

In the Csound language, the words are called opcodes. Opcodes are instructions that Csound understands and performs actions with. This manual contains a long list of opcodes in alphabetical order in the Reference Section.

Opcodes can produce results and receive parameters. The output of an opcode will always be to the left, while the inputs or parameters will be to the right.

This first csd file, called toot1.csd contains a single instrument which uses the oscil opcode to play a 440Hz sine wave (defined by f1 in the score) at an amplitude of 10000.

[Tip] Tip

If you are using the Csound Editor Activity, remember that you can open csd files directly from the File Menu. You can also copy and paste from this page, but you must paste the orchestra section and the score section separately. To do this, select the text between the <CsInstruments> and </CsInstruments> tags, without including them. Then press CTRL-C, to copy to the clipboard. Switch to the Csound Editor Activity and click on the Instrument panel, then press CTRL-V. To paste the score section, do the same for all text contained between the <CsScore> and </CsScore> tags, and paste it on the Editor's Score panel.

The opcode oscil produces an oscillation which is stored in variable a1. That is the output or result of the opcode as it is to the left. On the right we have the parameters the opcode uses to determine it output. In the case of oscil, we need to specify the amplitude of oscillation, which is the first parameter, the frequency of oscillation, which is the second one, and the shape or waveform of the oscillation.

The shape of the oscillation is created not in the orchestra, but in the score section. The shape is stored in the computer's memory using what Csound calls an f-table, which is created using an f statement. There are many different shapes you can create using the different GEN routines provided by Csound.

The oscillation produced by the oscil opcode is made audible by the out opcode. Notice that this opcode doesn't have any outputs. Its output is actually the sound you hear!

In the Orchestra section of a csd file we define the instruments, but no instrument sounds if it is not played. To play an instrument, the i statement in the score must be used.

<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>

instr 1

  a1 oscil 10000, 440, 1

  out a1

endin

</CsInstruments>
<CsScore>

f1	0	4096	10	1	; use GEN10 to compute a sine wave

;ins	strt	dur

i1	0	4

e					; indicates the end of the score

</CsScore>
</CsoundSynthesizer>