During the p-time passes only, conditionally transfer control to the statement labeled by label.
Syntax
ckgoto(condition,label)
ckgotocondition,label
where label is in the same instrument block and is not an expression, and where condition uses one of the Relational operators (<, =, <=, ==, !=) (and = for convenience, see also under Conditional Values).
Examples
Here is an example of the ckgoto opcode. It uses the file ckgoto-modern.csd.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform; Audio out Audio in No messages-odac
-d
; -iadc ;;;RT audio I/O; For Non-realtime ouput leave only the line below:; -o ckgoto.wav -W ;;; for file output any platform</CsOptions><CsInstruments>; Initialize the global variables.sr=44100kr=4410ksmps=10nchnls=1; Instrument #1.instr1; Change kval linearly from 0 to 2 over; the period set by the third p-field.val:k=line(0,p3,2); If kval is greater than or equal to 1 then play the high note.; If not then play the low note.ckgoto(val>=1,highnote)kgoto(lownote)highnote:freq:k=880goto(playit)lownote:freq=440playit:; Print the values of kval and kfreq.printks("val = %f, freq = %f\\n",1,val,freq)out(poscil(10000,freq))endin</CsInstruments><CsScore>; Play Instrument #1 for two seconds.i102e</CsScore></CsoundSynthesizer>
Here is an example of the ckgoto opcode. It uses the file ckgoto.csd.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform; Audio out Audio in No messages-odac -iadc -d ;;;RT audio I/O; For Non-realtime ouput leave only the line below:; -o ckgoto.wav -W ;;; for file output any platform</CsOptions><CsInstruments>; Initialize the global variables.sr=44100kr=4410ksmps=10nchnls=1; Instrument #1.instr1; Change kval linearly from 0 to 2 over; the period set by the third p-field.kvalline0,p3,2; If kval is greater than or equal to 1 then play the high note.; If not then play the low note.ckgoto(kval>=1),highnotekgotolownotehighnote:kfreq=880gotoplayitlownote:kfreq=440gotoplayitplayit:; Print the values of kval and kfreq.printks"kval = %f, kfreq = %f\\n",1,kval,kfreqa1oscil10000,kfreq,1outa1endin</CsInstruments><CsScore>; Table: a simple sine wave.f1032768101; Play Instrument #1 for two seconds.i102e</CsScore></CsoundSynthesizer>