“scorechar” -- A string (in double-quotes) representing the first p-field in a score statement. This is usually “e”, “f”, or “i”.
“insname” -- A string (in double-quotes) representing a named instrument.
Performance
kinsnum -- The instrument to use for the event. This corresponds to the first p-field, p1, in a score statement.
kdelay -- When (in seconds) the event will occur from the current performance time. This corresponds to the second p-field, p2, in a score statement.
kdur -- How long (in seconds) the event will happen. This corresponds to the third p-field, p3, in a score statement.
kp4, kp5, ... (optional) -- Parameters representing additional p-field in a score statement. It starts with the fourth p-field, p4.
Note
Note that the event opcode cannot accept string p-fields. If you need to pass strings when instantiating an instrument, use the scoreline or scoreline_i opcode.
Examples
Here is an example of the event opcode. It uses the file event.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 event.wav -W ;;; for file output any platform</CsOptions><CsInstruments>; Initialize the global variables.sr=44100kr=4410ksmps=10nchnls=1; Instrument #1 - an oscillator with a high note.instr1; Create a trigger and set its initial value to 1.ktriggerinit1; If the trigger is equal to 0, continue playing.; If not, schedule another event.if(ktrigger==0)gotocontin; kscoreop="i", an i-statement.; kinsnum=2, play Instrument #2.; kwhen=1, start at 1 second.; kdur=0.5, play for a half-second.event"i",2,1,0.5; Make sure the event isn't triggered again.ktrigger=0contin:a1oscils10000,440,1outa1endin; Instrument #2 - an oscillator with a low note.instr2a1oscils10000,220,1outa1endin</CsInstruments><CsScore>; Make sure the score plays for two seconds.f02; Play Instrument #1 for a half-second.i100.5e</CsScore></CsoundSynthesizer>
Here is an example of the event opcode using a named instrument. It uses the file event_named.csd.
Example of the event opcode using a named instrument.
<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 event_named.wav -W ;;; for file output any platform</CsOptions><CsInstruments>; Initialize the global variables.sr=44100kr=4410ksmps=10nchnls=1; Instrument #1 - an oscillator with a high note.instr1; Create a trigger and set its initial value to 1.ktriggerinit1; If the trigger is equal to 0, continue playing.; If not, schedule another event.if(ktrigger==0)gotocontin; kscoreop="i", an i-statement.; kinsnum="low_note", instrument named "low_note".; kwhen=1, start at 1 second.; kdur=0.5, play for a half-second.event"i","low_note",1,0.5; Make sure the event isn't triggered again.ktrigger=0contin:a1oscils10000,440,1outa1endin; Instrument "low_note" - an oscillator with a low note.instrlow_notea1oscils10000,220,1outa1endin</CsInstruments><CsScore>; Make sure the score plays for two seconds.f02; Play Instrument #1 for a half-second.i100.5e</CsScore></CsoundSynthesizer>