Index | Next Week | Previous Week |
if (something is greater than, equal to or less than something else) goto somewhere
the conditional part is an expression using the following operators:
> greater than < less than == equal to >= greater than or equal to <= less than or equal to != not equal to
This statement is placed in parentheses ( ) following the if. After the statement, there is a goto followed by a label. The goto can operate at a-time(goto), k-time (kgoto) or i-time (igoto). The label can be any word consisting of lower case letters. The label must appear somewhere else in the instrument definition followed by a colon -- this marks the place to which the program jumps whenever the condition is true. When the condition is true the code between the if--goto and the label are skipped.
if (p3 >= 1.0) goto longnote ; the code for a short note goes in here ------- longnote: ; the code for a long note goes in here ------
Conditional statements can be used to provide several different envelopes for an instrument. For example, if you wanted 3 different envelopes within a single instrument, you could set a parameter in the score to tell the instrument which envelope to use. Once you have jumped to a label and processed the appropriate lines of code, you must make sure your jump passed the other envelope definitions with another goto, kgoto, or igoto expression.
(a value of 1, 2 or 3 is passed from the score in p7) if (p7 == 1) kgoto envelope1 if (p7 == 2) kgoto envelope 2 if (p7 == 3) kgoto envelope 3 envelope1: k1 linseg 0, p3 *.5, 1, p3*.5, 0 ; up then down kgoto mainpart envelope2: k1 linseg 1, p3 *.5, 0, p3*.5, 1 ; down then up kgoto mainpart ; jump to audio part envelope3: k1 linseg 1, p3, 0 ; down in p3 kgoto mainpart ; this is redundant mainpart: asig oscil p4 * k1, cpspch(p5), 1; ; main oscillator outs asig, asig ; output to file
f1 0 16 -2 9 1 3 5 2 8 7 10 2 0 4 3 5 7 11 8 f2 0 8 -2 .01 .04 .03 .05 .00 .06 .02 .07
(uses f-2 containing .00 .03 .05 .02 .06 .07 .04 .01) k1 phasor 2 ; speed of phasor is 2 cps kptch table k1* 8, 2 ; read table f-2 with phasor asig oscil p4, cpspch(p5+kptch), 1 ; oscillator
kptc oscil1 0, 1, 3, 2 ; read function 2 in 3 seconds asig oscil p4, cpspch(p5+kptch), 1 ; oscillator
Index | Next Week | Previous Week |