Cabbage Logo
Back to Cabbage Site

Print event_i as a score

Hi, does anyone know how to print the score generated by an event_i inside a loop_it?

I managed to get this:

instr 2: p2 = 0.000 p3 = 4.000 p4 = 0.500 p5 = 100.000
instr 2: p2 = 2.000 p3 = 4.000 p4 = 0.500 p5 = 150.000
instr 2: p2 = 4.000 p3 = 4.000 p4 = 0.500 p5 = 200.000
instr 2: p2 = 6.000 p3 = 4.000 p4 = 0.500 p5 = 250.000
instr 2: p2 = 8.000 p3 = 4.000 p4 = 0.500 p5 = 300.000

but I’d like to have this:

i2 0 4 0.5 100
i2 2 4 0.5 150
i2 4 4 0.5 200
i2 6 4 0.5 250
i2 8 4 0.5 300

<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>

sr = 44100
ksmps = 32
nchnls = 1
0dbfs  = 1
;-----------------------------------------------
instr 1 ;master instrument
;-----------------------------------------------
ininstr = 5 ;number of called instances
indx = 0
ifreq = 100
istart = 0

loop:

event_i "i", 2, istart, p3, .5, ifreq

ifreq= ifreq + 50
istart= istart + 2

loop_lt indx, 1, ininstr, loop

endin

;---------------------------------------------
instr 2
;---------------------------------------------
print p2,p3,p4,p5 ;I'm looking for another solution
asig  poscil p4, p5, 1

kenv  linseg 0, p3*.5, 1, p3*.5,0

      outs asig*kenv

endin

</CsInstruments>
<CsScore>
f1	0	4096	10	1   

i1 0 4
e

</CsScore>
</CsoundSynthesizer>

You’ll need to print the score yourself. The handiest way is to use a printks, or prints opcodes. I can prepare an example for you in a week or so. Right now I’m stuck in north Donegal with an absolutely terrible network connection!

Try using prints, as shown in the code below:

instr 2
   ;---------------------------------------------
   ;print p2,p3,p4,p5 ;I'm looking for another solution
   prints "i2 %f %f %f %f", 2, p3, p4, p5 
   asig  poscil p4, p5, 1
   kenv  linseg 0, p3*.5, 1, p3*.5,0
   outs asig*kenv
endin

Thanks Rory!
It works!