QUICK-REF - CsoundManual - Top of this section - Previous - Contents - Index - Next 

A Beginning Tutorial

The Score File

The purpose of the score is to tell the instruments when to play and with what parameter values. The score has a different syntax from that of the orchestra, but similarly permits one statement per line and comments after a semicolon. The first character of a score statement is an opcode, determining an action request; the remaining data consists of numeric parameter fields (pfields) to be used by that action.

Suppose we want a sine-tone generator to play a pentatonic scale starting at C-sharp above middle-C, with notes of 1/2 second duration. We would create the following score:

     ;  a sine wave function table
     f1 0 256 10 1
     ;  a pentatonic scale
     i1   0    .5   0.   8.01
     i1  .5    .    .    8.03
     i1 1.0    .    .    8.06
     i1 1.5    .    .    8.08
     i1 2.0    .    .    8.10
The first statement creates a stored sine table. The protocol for generating wave tables is simple but powerful. Lines with opcode f interpret their parameter fields as follows:
     p1 - function table number being created
     p2 - creation time, or time at which the table becomes readable
     p3 - table size (number of points), which must be a power of two or one greater
     p4 - generating subroutine, chosen from a prescribed list.
Here the value 10 in p4 indicates a request for subroutine GEN10 to fill the table. GEN10 mixes harmonic sinusoids in phase, with relative strengths of consecutive partials given by the succeeding parameter fields. Our score requests just a single sinusoid. An alternative statement:
     f1 0 256 10 1 0 3
would produce one cycle of a waveform with a third harmonic three times as strong as the first.

The i statements, or note statements, will invoke the p1 instrument at time p2, then turn it off after p3 seconds; it will pass all of its p-fields to that instrument. Individual score parameters are separated by any number of spaces or tabs; neat formatting of parameters in columns is nice but unnecessary. The dots in p-fields 3 and 4 of the last four notes invoke a carry feature, in which values are simply copied from the immediately preceding note of the same instrument. A score normally ends with an e statement.

The unit of time in a Csound score is the beat. In the absence of a Tempo statement, one beat takes one second. To double the speed of the pentatonic scale in the above score, we could either modify p2 and p3 for all the notes in the score, or simply insert the line

     t 0 120
to specify a tempo of 120 beats per minute from beat 0.

Two more points should be noted. First, neither the f-statements nor the i-statements need be typed in time order; Csound will sort the score automatically before use. Second, it is permissible to play more than one note at a time with a single instrument. To play the same notes as a three-second pentatonic chord we would create the following:

     ;    a sine wave function
     f1   0  256   10    1
     ;    five notes at once
     i1   0    3    0    8.01
     i1   0    .    .    8.03
     i1   0    .    .    8.06
     i1   0    .    .    8.08
     i1   0    .    .    8.10
Now go into the editor once more and create your own score file. Name it "intro.sco". Tne next section will describe how to invoke a Csound orchestra to perform a Csound score.

QUICK-REF - CsoundManual - Top of this section - Previous - Contents - Index - Next 
HTML Csound Manual - © Jean Piché & Peter J. Nix, 1994-97