Csound Csound-dev Csound-tekno Search About

[Csnd] Scheduling events using timek - why doesn't this work?

Date2018-11-02 19:40
Fromcybilsopsin
Subject[Csnd] Scheduling events using timek - why doesn't this work?
The code below should trigger instr 999 to play a half-second tone at 3.0
seconds into the performance.

Why doesn't it work?






sr = 44100
ksmps = 128
nchnls = 2
0dbfs = 1.0
alwayson 1

gk_clock_kcy init 0

instr 1
gk_clock_kcy timek
if (gk_clock_kcy==(kr*3)) then
ktrig999 = 1
endif
schedkwhen ktrig999, 0, 100, 999, 0, .5
ktrig999 = 0
endin

instr 999
ares oscil 1, 440
outs ares, ares
endin



f0 10






-----
***cybilopsin***
"We are all guilty of crime, the great crime of not living life to the full." - Henry Miller
--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2018-11-02 22:56
FromMauro Giubileo
SubjectRe: [Csnd] Scheduling events using timek - why doesn't this work?

The problem in your code is that "gk_clock_kcy == (kr*3)" will never happen.

The reason is that in your example kr is not integer, but the value returned by timek is an integer.

It will work if you use instead: "gk_clock_kcy == (round(kr) * 3)".


Regards,
Mauro


Il 2018-11-02 20:40 cybilsopsin ha scritto:

The code below should trigger instr 999 to play a half-second tone at 3.0
seconds into the performance.

Why doesn't it work?

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

sr = 44100
ksmps = 128
nchnls = 2
0dbfs = 1.0
alwayson 1

gk_clock_kcy init 0

instr 1
gk_clock_kcy timek
if (gk_clock_kcy==(kr*3)) then
ktrig999 = 1
endif
schedkwhen ktrig999, 0, 100, 999, 0, .5
ktrig999 = 0
endin

instr 999
ares oscil 1, 440
outs ares, ares
endin

</CsInstruments>
<CsScore>
f0 10

</CsScore>
</CsoundSynthesizer>



-----
***cybilopsin***
"We are all guilty of crime, the great crime of not living life to the full." - Henry Miller
--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here