event "scorechar", kinsnum, kdelay, kdur, [, kp4] [, kp5] [, ...]
event "scorechar", "insname", kdelay, kdur, [, kp4] [, kp5] [, ...]
"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.
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.
Here is an example of the event opcode. It uses the files event.orc and event.sco.
Example 1. Example of the event opcode.
/* event.orc */
; Initialize the global variables.
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1
; Instrument #1 - an oscillator with a high note.
instr 1
; Create a trigger and set its initial value to 1.
ktrigger init 1
; If the trigger is equal to 0, continue playing.
; If not, schedule another event.
if (ktrigger == 0) goto contin
; 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 = 0
contin:
a1 oscils 10000, 440, 1
out a1
endin
; Instrument #2 - an oscillator with a low note.
instr 2
a1 oscils 10000, 220, 1
out a1
endin
/* event.orc */
/* event.sco */
; Make sure the score plays for two seconds.
f 0 2
; Play Instrument #1 for a half-second.
i 1 0 0.5
e
/* event.sco */
Here is an example of the event opcode using a named instrument. It uses the files event_named.orc and event_named.sco.
Example 2. Example of the event opcode using a named instrument.
/* event_named.orc */
; Initialize the global variables.
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1
; Instrument #1 - an oscillator with a high note.
instr 1
; Create a trigger and set its initial value to 1.
ktrigger init 1
; If the trigger is equal to 0, continue playing.
; If not, schedule another event.
if (ktrigger == 0) goto contin
; 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 = 0
contin:
a1 oscils 10000, 440, 1
out a1
endin
; Instrument "low_note" - an oscillator with a low note.
instr low_note
a1 oscils 10000, 220, 1
out a1
endin
/* event_named.orc */
/* event_named.sco */
; Make sure the score plays for two seconds.
f 0 2
; Play Instrument #1 for a half-second.
i 1 0 0.5
e
/* event_named.sco */