Skip to content

eventi

Generates a score event from an instrument.

📝 Note

Up to Csound 6, this opcode was called event_i.

Syntax

eventi("scorechar", iinsnum, idelay, idur, [, ip4] [, ip5] [, ...])
eventi("scorechar", "insname", idelay, idur, [, ip4] [, ip5] [, ...])
event_i "scorechar", iinsnum, idelay, idur, [, ip4] [, ip5] [, ...]
event_i "scorechar", "insname", idelay, idur, [, ip4] [, ip5] [, ...]

Initialization

“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.

iinsnum -- The instrument to use for the event. This corresponds to the first p-field, p1, in a score statement.

idelay -- When (in seconds) the event will occur from the current performance time. This corresponds to the second p-field, p2, in a score statement.

idur -- How long (in seconds) the event will happen. This corresponds to the third p-field, p3, in a score statement.

ip4, ip5, ... (optional) -- Parameters representing additional p-field in a score statement. It starts with the fourth p-field, p4.

Performance

The event is added to the queue at initialisation time.

📝 Note

Note that the eventi opcode cannot accept string p-fields. If you need to pass strings when instantiating an instrument, use the scoreline or scorelinei opcode.

Examples

Here is an example of the eventi opcode. It uses the file eventi.csd.

Example of the eventi opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac     ;;;RT audio out
;-iadc    ;;;uncomment -iadc if RT audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o event_i.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs  = 1

seed(0)
sine@global:i = ftgen(0, 0, 2^10, 10, 1)

instr 1 ;master instrument
  ninstr:i = 10 ;number of called instances
  ndx:i = 0
loop:
  Pan:i = random(0, 1)
  freq:i = random(100, 1000)
  amp:i = 1/ninstr
  eventi("i", 10, 0, p3, amp, freq, Pan)
  looplt(ndx, 1, ninstr, loop)
endin

instr 10
  print(p4, p5, p6)
  Peak:i = random(0, 1) ;where is the envelope peak
  sig:a = poscil3(p4, p5, sine)
  env:a = transeg(0, p3*Peak, 6, 1, p3-p3*Peak, -6, 0)
  aL, aR = pan2(sig*env, p6)
  out(aL, aR)
endin

</CsInstruments>
<CsScore>
i1 0 10
i1 8 10
i1 16 15
e
</CsScore>
</CsoundSynthesizer>

Here is an example of the event_i opcode. It uses the file event_i.csd.

Example of the event_i opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac     ;;;RT audio out
;-iadc    ;;;uncomment -iadc if RT audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o event_i.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 2
0dbfs  = 1

seed 0
gisine ftgen 0, 0, 2^10, 10, 1

instr 1 ;master instrument

ininstr = 10 ;number of called instances
indx = 0
loop:
ipan  random 0, 1
ifreq random 100, 1000
iamp  = 1/ininstr
event_i "i", 10, 0, p3, iamp, ifreq, ipan
loop_lt indx, 1, ininstr, loop

endin

instr 10

      print p4, p5, p6
ipeak random 0, 1 ;where is the envelope peak
asig  poscil3 p4, p5, gisine
aenv  transeg 0, p3*ipeak, 6, 1, p3-p3*ipeak, -6, 0
aL,aR pan2 asig*aenv, p6
      outs aL, aR

endin

</CsInstruments>
<CsScore>
i1 0 10
i1 8 10
i1 16 15
e
</CsScore>
</CsoundSynthesizer>

See also

Instrument Invocation

Credits

Written by Istvan Varga.

New in Csound5