Csound Csound-dev Csound-tekno Search About

[Csnd] calling an instrument many times

Date2013-10-29 17:15
FromStefan Thomas
Subject[Csnd] calling an instrument many times
Dear community,
I would like to call an instrument with event_i many times, with different parameters.
The following code works, but only, when imax = 1 (imax is the condition for ending the loop).
When imax is bigger than 1 I hear just northing. I don't get an error message!
I don't see any mistakes in the following code:
<CsoundSynthesizer>
<CsOptions>
-odac -m0d
</CsOptions>
; ==============================================
<CsInstruments>

sr    =    44100
ksmps     =     100
nchnls    =    2
0dbfs    =    1
gisine ftgen 0,0,2^13, 10, 1
instr 1   
    iamp        = 0.1
    iein        = 0.01
    irel        = 0.1
    idur        = 1
    imax        = 3
    loop:
    index         = 0
    icps        = 440*cent(100*index)
    insnum         = 100 + 0.1*(index+1)
    ibeg        = index*idur
    event_i "i", insnum, ibeg, idur,iamp,icps,iein,irel
    loop_lt  index, 1, imax, loop
   
endin

instr 100
    idur    = p3
    iamp     = p4
    icps    = p5
    iein    = p6
    irel    = p7
    aenv    linseg 0,iein,1,p3-iein-irel,1,irel,0
    aout     poscil iamp*aenv, icps, gisine
    outs aout, aout
endin

</CsInstruments>
; ==============================================
<CsScore>

i1 0 30
</CsScore>
</CsoundSynthesizer>