Csound Csound-dev Csound-tekno Search About

schedkwhen/schedwhen not working as expected?

Date2016-11-05 18:21
FromRichard
Subjectschedkwhen/schedwhen not working as expected?
I am trying to 'buffer' some score events in a k rate loop and 
schedkwhen or schedwhen. But what I get is not what I expected.
In the following csd the schedkwhen code triggers instrument 10 
immediately, not 1 second apart as I would expect.
If I comment out the schedkwhen and use the schedwhen, instrument 10 is 
only called once...

Richard



-nm0


ksmps = 32


instr 1
kCycle timeinstk
printks "kCycle = %d\n", 0, kCycle
kIndex = 0
while kIndex < 10 do
     ;schedkwhen ktrigger, kmintim, kmaxnum, kinsnum, kwhen, kdur
     schedkwhen kIndex, 0, 1, 10, kIndex, 1
     ;schedwhen ktrigger, kinsnum, kwhen, kdur
     ;schedwhen kIndex, 10, kIndex, 1
     kIndex += 1
od
   ;stop after first control cycle
if kCycle == 1 then
   turnoff
endif
endin

instr 10
     print p2,p3
endin



i 1 0 10
e



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

Date2016-11-05 19:43
FromJohn ff
SubjectRe: schedkwhen/schedwhen not working as expected?
Ido not see the point of the loop.  kindex run 0 to 9 on each k-cycle which feels odd.  But perhaps I misunderstand what you want.

Sent from TypeApp
On 5 Nov 2016, at 18:22, Richard <zappfinger@GMAIL.COM> wrote:
I am trying to 'buffer' some score events in a k rate loop and 
schedkwhen or schedwhen. But what I get is not what I expected.
In the following csd the schedkwhen code triggers instrument 10
immediately, not 1 second apart as I would expect.
If I comment out the schedkwhen and use the schedwhen, instrument 10 is
only called once...

Richard

<CsoundSynthesizer>
<CsOptions>
-nm0
</CsOptions>
<CsInstruments>
ksmps = 32


instr 1
kCycle timeinstk
printks "kCycle = %d\n", 0, kCycle
kIndex = 0
while kIndex < 10 do
;schedkwhen ktrigger, kmintim, kmaxnum, kinsnum, kwhen, kdur
schedkwhen kIndex, 0, 1, 10, kIndex, 1
;schedwhen ktrigger, kinsnum, kwhen, kdur
;schedwhen kIndex, 10, kIndex, 1
kIndex += 1
od
;stop after first control cycle
if kCycle == 1 then
turnoff
endif
endin

instr 10
print p2,p3
endin

</CsInstruments>
<CsScore>
i 1 0 10
e
</CsScore>
</CsoundSynthesizer>

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

Date2016-11-05 19:57
FromRichard
SubjectRe: schedkwhen/schedwhen not working as expected?

The idea is that I have some events that need to be triggered. I get them from a file or database.
Like a drum sequence:


...
i 10           0.000000           0.125034    98    36
i 10           0.000000           0.125034    98    42
i 10           0.250000           0.125034    98    36
i 10           0.250000           0.125034    98    42
i 10           0.500000           0.125034    98    40
...

So the sched(k)when arguments will vary greatly. This was just a test if sched(k)when could be just for that.
The idea was that if I could buffer these events with sched(k)when in a k rate loop, they would be executed at the 'kwhen' time, but that does not seem to happen.

Richard


On 05/11/16 20:43, John ff wrote:
Ido not see the point of the loop.  kindex run 0 to 9 on each k-cycle which feels odd.  But perhaps I misunderstand what you want.

Sent from TypeApp
On 5 Nov 2016, at 18:22, Richard <zappfinger@GMAIL.COM> wrote:
I am trying to 'buffer' some score events in a k rate loop and 
schedkwhen or schedwhen. But what I get is not what I expected.
In the following csd the schedkwhen code triggers instrument 10 
immediately, not 1 second apart as I would expect.
If I comment out the schedkwhen and use the schedwhen, instrument 10 is 
only called once...

Richard

<CsoundSynthesizer>
<CsOptions>
-nm0
</CsOptions>
<CsInstruments>
ksmps = 32


instr 1
kCycle timeinstk
printks "kCycle = %d\n", 0, kCycle
kIndex = 0
while kIndex < 10 do
     ;schedkwhen ktrigger, kmintim, kmaxnum, kinsnum, kwhen, kdur
     schedkwhen kIndex, 0, 1, 10, kIndex, 1
     ;schedwhen ktrigger, kinsnum, kwhen, kdur
     ;schedwhen kIndex, 10, kIndex, 1
     kIndex += 1
od
   ;stop after first control cycle
if kCycle == 1 then
   turnoff
endif
endin

instr 10
     print
p2,p3
endin

</CsInstruments>
<CsScore>
i 1 0 10
e
</CsScore>
</CsoundSynthesizer>

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


Date2016-11-05 20:58
Fromjpff
SubjectRe: schedkwhen/schedwhen not working as expected?
Still trying to understand

First schedwhen is at i time so can only generate 1 instance; in effect it 
is not in the loop

So in the example given kIndex as values 0, 1, 2, ...8, 9
so trigger is set 9 times. So the only ting left that confuses me is you 
set the number of i10 to 1 which seems not to be the case

?On the other and it works for me

SECTION 1:
kCycle = 1
instr 10:  p2 = 1.000  p3 = 1.000
instr 10:  p2 = 2.000  p3 = 1.000
instr 10:  p2 = 3.000  p3 = 1.000
instr 10:  p2 = 4.000  p3 = 1.000
instr 10:  p2 = 5.000  p3 = 1.000
instr 10:  p2 = 6.000  p3 = 1.000
instr 10:  p2 = 7.000  p3 = 1.000
instr 10:  p2 = 8.000  p3 = 1.000
instr 10:  p2 = 9.000  p3 = 1.000

On Sat, 5 Nov 2016, Richard wrote:

> I am trying to 'buffer' some score events in a k rate loop and schedkwhen or 
> schedwhen. But what I get is not what I expected.
> In the following csd the schedkwhen code triggers instrument 10 immediately, 
> not 1 second apart as I would expect.
> If I comment out the schedkwhen and use the schedwhen, instrument 10 is only 
> called once...
>
> Richard
>
> 
> 
> -nm0
> 
> 
> ksmps = 32
>
>
> instr 1
> kCycle timeinstk
> printks "kCycle = %d\n", 0, kCycle
> kIndex = 0
> while kIndex < 10 do
>    ;schedkwhen ktrigger, kmintim, kmaxnum, kinsnum, kwhen, kdur
>    schedkwhen kIndex, 0, 1, 10, kIndex, 1
>    ;schedwhen ktrigger, kinsnum, kwhen, kdur
>    ;schedwhen kIndex, 10, kIndex, 1
>    kIndex += 1
> od
>  ;stop after first control cycle
> if kCycle == 1 then
>  turnoff
> endif
> endin
>
> instr 10
>    print p2,p3
> endin
>
> 
> 
> i 1 0 10
> e
> 
> 
>
> 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
>

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

Date2016-11-05 21:01
Fromjpff
SubjectRe: schedkwhen/schedwhen not working as expected?
Of course there is only zero instances of i10 running so the limit is not 
breached

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

Date2016-11-05 22:12
FromRichard
SubjectRe: schedkwhen/schedwhen not working as expected?
"So the only ting left that confuses me is you set the number of i10 to 
1 which seems not to be the case"

I use:

     ;schedkwhen ktrigger, kmintim, kmaxnum, kinsnum, kwhen, kdur
     schedkwhen kIndex, 0, 1, 10, kIndex, 1

So kinsnum = 10, kwhen (p2)= 0, 1, 2, etc, kdur (p3)= 1

I also get this output:

instr 10:  p2 = 1.000  p3 = 1.000
instr 10:  p2 = 2.000  p3 = 1.000
instr 10:  p2 = 3.000  p3 = 1.000
instr 10:  p2 = 4.000  p3 = 1.000
instr 10:  p2 = 5.000  p3 = 1.000
instr 10:  p2 = 6.000  p3 = 1.000
instr 10:  p2 = 7.000  p3 = 1.000
instr 10:  p2 = 8.000  p3 = 1.000
instr 10:  p2 = 9.000  p3 = 1.000

But as you see form the output, it happens at once. I would expect each 
line to be one second apart, since kwen (p2) = 1, 2, 3 , etc

Richard
On 05/11/16 21:58, jpff wrote:
> So the only ting left that confuses me is you set the number of i10 to 
> 1 which seems not to be the case 

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

Date2016-11-05 23:42
Fromjpff
SubjectRe: schedkwhen/schedwhen not working as expected?
What make you think they are not 1sec apart?

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

Date2016-11-06 08:21
FromRichard
SubjectRe: schedkwhen/schedwhen not working as expected?
Because the text output appeared at once. But now I've changed a bit and 
it seems to work now.
Below is the new csd, that also outputs sound. There are some 
differences with the previous version:
-odac is used now
previous version only had ksmps =32, no sr and kr
sound is output now



-nm0
-odac


sr = 44100
kr = 44100
ksmps = 1
nchnls = 1

instr 1
     kCycle timeinstk
     printks "kCycle = %d\n", 0, kCycle
     kIndex = 0
     while kIndex < 10 do
         ;schedkwhen ktrigger, kmintim, kmaxnum, kinsnum, kwhen, kdur
         schedkwhen kIndex, 0, 1, 10, kIndex, 1
         kIndex += 1
     od
       ;stop after first control cycle
     if kCycle == 1 then
           turnoff
     endif
endin

instr 10
     print p2,p3
     a1 oscils 10000, 220+10*p2, 1
       out a1
endin



i 1 0 10
e





On 06/11/16 00:42, jpff wrote:
> What make you think they are not 1sec apart?
>
> 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

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

Date2016-11-06 14:45
Fromjpff
SubjectRe: schedkwhen/schedwhen not working as expected?
The text arrrved immediately as you were not geerating realtime audio so 
time could run ahead.

Do you yeally need sr=kr?

On Sun, 6 Nov 2016, Richard wrote:

> Because the text output appeared at once. But now I've changed a bit and it 
> seems to work now.
> Below is the new csd, that also outputs sound. There are some differences 
> with the previous version:
> -odac is used now
> previous version only had ksmps =32, no sr and kr
> sound is output now
>
> 
> 
> -nm0
> -odac
> 
> 
> sr = 44100
> kr = 44100
> ksmps = 1
> nchnls = 1
>
> instr 1
>    kCycle timeinstk
>    printks "kCycle = %d\n", 0, kCycle
>    kIndex = 0
>    while kIndex < 10 do
>        ;schedkwhen ktrigger, kmintim, kmaxnum, kinsnum, kwhen, kdur
>        schedkwhen kIndex, 0, 1, 10, kIndex, 1
>        kIndex += 1
>    od
>      ;stop after first control cycle
>    if kCycle == 1 then
>          turnoff
>    endif
> endin
>
> instr 10
>    print p2,p3
>    a1 oscils 10000, 220+10*p2, 1
>      out a1
> endin
>
> 
> 
> i 1 0 10
> e
> 
> 
>
>
>
> On 06/11/16 00:42, jpff wrote:
>> What make you think they are not 1sec apart?
>> 
>> 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
>
> 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
>

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

Date2016-11-06 14:51
FromRichard
SubjectRe: schedkwhen/schedwhen not working as expected?
No that was just copy and paste from an example...


On 06/11/16 15:45, jpff wrote:
> The text arrrved immediately as you were not geerating realtime audio 
> so time could run ahead.
>
> Do you yeally need sr=kr?
>
> On Sun, 6 Nov 2016, Richard wrote:
>
>> Because the text output appeared at once. But now I've changed a bit 
>> and it seems to work now.
>> Below is the new csd, that also outputs sound. There are some 
>> differences with the previous version:
>> -odac is used now
>> previous version only had ksmps =32, no sr and kr
>> sound is output now
>>
>> 
>> 
>> -nm0
>> -odac
>> 
>> 
>> sr = 44100
>> kr = 44100
>> ksmps = 1
>> nchnls = 1
>>
>> instr 1
>>    kCycle timeinstk
>>    printks "kCycle = %d\n", 0, kCycle
>>    kIndex = 0
>>    while kIndex < 10 do
>>        ;schedkwhen ktrigger, kmintim, kmaxnum, kinsnum, kwhen, kdur
>>        schedkwhen kIndex, 0, 1, 10, kIndex, 1
>>        kIndex += 1
>>    od
>>      ;stop after first control cycle
>>    if kCycle == 1 then
>>          turnoff
>>    endif
>> endin
>>
>> instr 10
>>    print p2,p3
>>    a1 oscils 10000, 220+10*p2, 1
>>      out a1
>> endin
>>
>> 
>> 
>> i 1 0 10
>> e
>> 
>> 
>>
>>
>>
>> On 06/11/16 00:42, jpff wrote:
>>> What make you think they are not 1sec apart?
>>>
>>> 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
>>
>> 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
>>
>
> 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

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