Toot 6

The first character in a score statement is an opcode, determining an action request; the remaining data consists of numeric parameter fields (p-fields) to be used by that action. So far we have been dealing with two different opcodes in our score: f and i. i statements, or note statements, invoke the p1 instrument at time p2 and turn it off after p3 seconds; all remaining p-fields are passed to the instrument.

On the other hand, f statements, or lines with an opcode of f, invoke function-drawing subroutines called GENS. In Csound there are many GENS which fill tables in a variety of ways. For example, GEN01 transfers data from a soundfile; GEN07 allows you to construct functions from segments of straight lines; and GEN10, which we've been using in our scores so far, generates composite waveforms made up of a weighted sum of simple sinusoids. We have named the function "f1," invoked it at time 0, defined it to contain 512 points, and instructed GEN10 to fill that table with a single sinusoid whose amplitude is 1. GEN10 can in fact be used to approximate a variety of other waveforms, as illustrated by the following:

  f 1 0 2048 10 1                                         ; Sine
  f 2 0 2048 10 1 0.5 0.3 0.25 0.2 0.167 0.14 0.125 .111  ; Sawtooth
  f 3 0 2048 10 1 0   0.3 0    0.2 0     0.14 0     .111  ; Square
  f 4 0 2048 10 1 1   1   1    0.7 0.5   0.3  0.1         ; Pulse

For the opcode f, the first four p-fields are interpreted as follows:

In the instrument and score below, we have added three additional functions to the score, and modified the orchestra so that the instrument can call them via p11. The csd file is toot6.csd.

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

    instr 6

  ifunc     =         p11                                ; select the basic waveform
  irel      =         0.01                               ; set vibrato release time
  idel1     =         p3 * p10                           ; calculate initial delay (% of dur)
  isus      =         p3 - (idel1 + irel)                ; calculate remaining duration

  iamp      =         ampdb(p4)
  iscale    =         iamp * .333                        ; p4=amp
  inote     =         cpspch(p5)                         ; p5=freq

  k3        linseg    0, idel1, p9, isus, p9, irel, 0    ; p6=attack time
  k2        oscil     k3, p8, 1                          ; p7=release time
  k1        linen     iscale, p6, p3, p7                 ; p8=vib rate

  a3        oscil     k1, inote*.999+k2, ifunc           ; p9=vib depth
  a2        oscil     k1, inote*1.001+k2, ifunc          ; p10=vib delay (0-1)
  a1        oscil     k1, inote+k2, ifunc

  out       a1+a2+a3

    endin

</CsInstruments>
<CsScore>

f1   0    2048 10   1                                                                ; Sine

f2   0    2048 10   1    0.5  0.3  0.25 0.2  0.167     0.14      0.125     .111      ; Sawtooth

f3   0    2048 10   1    0    0.3  0    0.2  0         0.14      0         .111      ; Square

f4   0    2048 10   1    1    1    1    0.7  0.5       0.3       0.1                 ; Pulse



;ins strt dur  amp       frq       atk       rel       vbrt vbdpt     vibdl     waveform

i6   0     2   86        8.00      .03       .7        6    9         .8        1

i6   3     2   86        8.02      .03       .7        6    9         .8        2

i6   6     2   86        8.04      .03       .7        6    9         .8        3

i6   9     3   86        8.05      .03       .7        6    9         .8

</CsScore>
</CsoundSynthesizer>