Event

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Event

jhearon
Event is triggered with rand durations o.k., but can't seem to get them to
print from instr 2.  Ever only prints the last kvalue (gkdur).  Trying to
figure out what I'm doing wrong.  Sorry if this ex. is a little convoluted.  
Basically using Sensekey to fire event, but using a kloop to send successive
event durations.

regards,
Jim Hearon

<CsoundSynthesizer>
<CsOptions>
csound -s -d -odac -b4096 -B4096

</CsOptions>
<CsInstruments>

sr = 44100
kr = 4410
ksmps = 10
nchnls = 2

gkdur init 0
;----------------------------------
        instr 1 ;event control

  reset:

kcnt init 0
kbegin init 0
kpitch init 200

;keys '1' is ON, and '2' is OFF
kdata1 sensekey; gets an input from sensekey

if (kdata1 == 49) then
  restart:
  if (kcnt < 3) then
        again:
        gkdur rand 6, 1.1
  gkdur = (abs(int(gkdur)))
                if (gkdur == 0) then
                kgoto again
                endif
        ;printk2 gkdur
        event "i", 2, kbegin, gkdur, kpitch, gkdur
        kbegin = kbegin + gkdur
        kpitch = kpitch + 100
        kcnt = kcnt + 1
        kgoto restart
   endif

kdata1 = 0
kcnt = 0
kgoto reset
endif

if (kdata1 ==50) then
kdata1 = 0
printks "bye\\n", 1
reinit reset
;kgoto contin2
endif

contin2:
        endin

;----------------------
        instr 2
;printks "inst2 dur = %f\\n", 1, gkdur
printk2 gkdur
a3      linseg  0, p5*.55, 1, p5*.2, 1, p5*.25, 0
  a1 oscil 5000, p4, 1
  outs a1 * a3,a1 * a3
        endin

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

i1 0 40

</CsScore>
</CsoundSynthesizer>


--
Send bugs reports to this list.
To unsubscribe, send email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Event

Istvan Varga
James Hearon wrote:

> Event is triggered with rand durations o.k., but can't seem to get them
> to print from instr 2.  Ever only prints the last kvalue (gkdur).  

This is normal because the note triggered by event only starts to
perform in the next control period, and by that time the last value
of gkdur has already been written. If you print p3 instead, then
the correct duration will be printed.
--
Send bugs reports to this list.
To unsubscribe, send email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Event

Iain Duncan


Istvan Varga wrote:

> James Hearon wrote:
>
>> Event is triggered with rand durations o.k., but can't seem to get
>> them to print from instr 2.  Ever only prints the last kvalue (gkdur).  
>
>
> This is normal because the note triggered by event only starts to
> perform in the next control period, and by that time the last value
> of gkdur has already been written. If you print p3 instead, then
> the correct duration will be printed.

I think the above explanation should be added to the manual entry for
event. I didn't know about the next kpass thing, that is useful info.

Iain
--
Send bugs reports to this list.
To unsubscribe, send email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Event

Istvan Varga
Iain Duncan wrote:

> I think the above explanation should be added to the manual entry for
> event. I didn't know about the next kpass thing, that is useful info.

If you use event_i (runs at init time) with a zero start time instead
of event, then "i" events will not have the one kperiod latency (but
will still be initialized after any of the normal score notes), and
ftables are created immediately (you can already use them with the next
opcode).
Note that "f" events triggered with the original k-rate event opcode
will create the table in the init pass of the next control period, but
after the initialization of score notes.
--
Send bugs reports to this list.
To unsubscribe, send email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Event

Iain Duncan

>> I think the above explanation should be added to the manual entry for
>> event. I didn't know about the next kpass thing, that is useful info.
>
>
> If you use event_i (runs at init time) with a zero start time instead
> of event, then "i" events will not have the one kperiod latency (but
> will still be initialized after any of the normal score notes), and
> ftables are created immediately (you can already use them with the next
> opcode).
> Note that "f" events triggered with the original k-rate event opcode
> will create the table in the init pass of the next control period, but
> after the initialization of score notes.

And that one too! Thanks Istvan.
--
Send bugs reports to this list.
To unsubscribe, send email to [hidden email]