Csound Csound-dev Csound-tekno Search About

[Csnd] mysterious problem: possible bug

Date2010-07-08 21:37
FromPeiman Khosravi
Subject[Csnd] mysterious problem: possible bug
Hello,

Can someone please explain why this csd works with ksmps=10 but not  
ksmps=100?

No errors but the performance terminate almost immediately.

It has something to do with the combination of diskin, ilength and  
event_i! But I cannot wok it out.

Thanks in advance

Peiman




-odac -d -3




sr = 96000
ksmps = 10
nchnls = 2


instr Setup

	ilength   filelen "mary.wav"        ; Length of file in seconds

	; Process audio file

	event_i "i", 1, 0.0, ilength

	turnoff
endin

instr 1
ar1, ar2	diskin2	  "mary.wav", 1
outs ar1, ar2

endin







i "Setup" 0 0.0001  ; Start processor








Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2010-07-08 21:53
FromJacob Joaquin
Subject[Csnd] Re: mysterious problem: possible bug
On Thu, Jul 8, 2010 at 1:37 PM, Peiman Khosravi
 wrote:
> Can someone please explain why this csd works with ksmps=10 but not
> ksmps=100?

Changing 0.0001 to 1 fixes it. I don't know why. Though I have a
theory. I'll try to run a test later.

Best,
Jake

Date2010-07-08 22:29
FromJacob Joaquin
Subject[Csnd] Re: mysterious problem: possible bug
I think I know why.  And please stick with me, as I think I'm going to
have a hard time explaining this one.

The value set in p3 rounds to the nearest k-block duration.  When
ksmps is set to 10, the duration of a kblock is (10 / 96000), or
0.000104.  I believe Csound also rounds to the 6th decimal place, so
I'm testing using the value 0.000104 instead of 0.0001046666666667.

0.0001 I believe rounds up to 0.000104, because it is greater than
half of 0.000104.

When ksmps is set to 100, the duration of a kblock is (100/ 96000), or 0.001042.

0.0001 is less than half that, so it rounds, I think, down to a duration of 0.0.

So my test was this, I set ksmps to 10.  Then I set p3 of setup to
0.000053, and it successfully played instr 1.  Setting p3 to 0.000052
did not launch instr 1.  Refining it further, 0.0000525 doesn't work,
but 0.0000526 does.

I ran a second test, this time setting ksmps to 100.  0.000521 works,
as does 0.0005205, but not 0.0005204.

Best,
Jake

Date2010-07-08 22:45
FromJacob Joaquin
Subject[Csnd] Re: mysterious problem: possible bug
I forgot the second part of this, and that has to do with keeping
Csound running and the internal event scheduler.  I don't really know
how it works, but this is how I think it works based on my experience.

There are two things that keep Csound running. First, if there is an
active event running, the Csound process keeps going. The second is
that Csound knows to keep running if any score event (not orchestra
event) is scheduled to happen in the future.

If an event is added to the scheduler in the orchestra that is beyond
the final end time set in the score, the Csound process will stop if
at any point there are no active events, thus never played the
orchestra scheduled event.

In your case, I'm guess if the duration of the Setup instrument is
rounded to 0, runs the init portion, including scheduling the event.
But since the duration is 0, Csound thinks it is done at time 0, and
exits before triggering the orchestra made event.

Does this make any sense?

Best,
Jake

Date2010-07-08 23:08
FromSteven Yi
Subject[Csnd] Re: Re: mysterious problem: possible bug
Strange, I would have imagined csound to process at least one block in
either scenario and not round out the event.  Do you all get anything
if you put in a print statement?

On Thu, Jul 8, 2010 at 5:45 PM, Jacob Joaquin  wrote:
> I forgot the second part of this, and that has to do with keeping
> Csound running and the internal event scheduler.  I don't really know
> how it works, but this is how I think it works based on my experience.
>
> There are two things that keep Csound running. First, if there is an
> active event running, the Csound process keeps going. The second is
> that Csound knows to keep running if any score event (not orchestra
> event) is scheduled to happen in the future.
>
> If an event is added to the scheduler in the orchestra that is beyond
> the final end time set in the score, the Csound process will stop if
> at any point there are no active events, thus never played the
> orchestra scheduled event.
>
> In your case, I'm guess if the duration of the Setup instrument is
> rounded to 0, runs the init portion, including scheduling the event.
> But since the duration is 0, Csound thinks it is done at time 0, and
> exits before triggering the orchestra made event.
>
> Does this make any sense?
>
> Best,
> Jake
> --
> The Csound Blog - http://csound.noisepages.com/
> Slipmat - http://slipmat.noisepages.com/
>
>
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>
>


Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"


Date2010-07-08 23:36
FromJacob Joaquin
Subject[Csnd] Re: Re: Re: mysterious problem: possible bug
Sorry to be overly brief, but I'm late somewhere.

Yes, I do get a print statement, even if I set p3 to 0. Though k-rate
prints do not print. I'm guessing it's because init time has no
durational dimension to it, they just run when called, but k-rate is
affected by a duration of 0.

Best,
Jake

Date2010-07-09 18:26
FromPeiman Khosravi
Subject[Csnd] Re: Re: Re: Re: mysterious problem: possible bug
Hi Jake,

Thanks very much for testing this and the explanation. It makes  
perfect sense.

Best,

Peiman

On 8 Jul 2010, at 23:36, Jacob Joaquin wrote:

> Sorry to be overly brief, but I'm late somewhere.
>
> Yes, I do get a print statement, even if I set p3 to 0. Though k-rate
> prints do not print. I'm guessing it's because init time has no
> durational dimension to it, they just run when called, but k-rate is
> affected by a duration of 0.
>
> Best,
> Jake
> -- 
> The Csound Blog - http://csound.noisepages.com/
> Slipmat - http://slipmat.noisepages.com/
>
>
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"
>



Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2010-07-09 18:48
FromJacob Joaquin
Subject[Csnd] Re: Re: Re: Re: Re: mysterious problem: possible bug
On Fri, Jul 9, 2010 at 10:26 AM, Peiman Khosravi
 wrote:
> Thanks very much for testing this and the explanation. It makes perfect
> sense.

No problem.  In the mean time, I found what I think is a better
solution than 0.0001. In the "Setup" instr, set p3 to (ksmps / sr).
It'll work even if the audio sample is less than a second in duration.
 Example:



instr 1
    p3 = ksmps / sr   ; *HERE*
    event_i "i", 2, 0, 1
    turnoff
endin
instr 2
    prints "instr 2 launches successfully\n"
endin


i 1 0 1




Best,
Jake

Date2010-07-10 02:00
FromPeiman Khosravi
Subject[Csnd] Re: Re: Re: Re: Re: Re: mysterious problem: possible bug
Great idea. Thanks :-)

P

On 9 Jul 2010, at 18:48, Jacob Joaquin wrote:

> On Fri, Jul 9, 2010 at 10:26 AM, Peiman Khosravi
>  wrote:
>> Thanks very much for testing this and the explanation. It makes  
>> perfect
>> sense.
>
> No problem.  In the mean time, I found what I think is a better
> solution than 0.0001. In the "Setup" instr, set p3 to (ksmps / sr).
> It'll work even if the audio sample is less than a second in duration.
> Example:
>
> 
> 
> instr 1
>    p3 = ksmps / sr   ; *HERE*
>    event_i "i", 2, 0, 1
>    turnoff
> endin
> instr 2
>    prints "instr 2 launches successfully\n"
> endin
> 
> 
> i 1 0 1
> 
> 
>
>
> Best,
> Jake
> -- 
> The Csound Blog - http://csound.noisepages.com/
> Slipmat - http://slipmat.noisepages.com/
>
>
> Send bugs reports to the Sourceforge bug tracker
>            https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"
>



Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2010-07-19 21:26
FromLouis Cohen
Subject[Csnd] Re: mysterious problem: possible bug
It looks like instr 1 executes the event statement once since it's  
followed by a turnoff. But I would have coded it differently, and this  
might get around any complications with k-cycles:

Try this:

instr 1
   ktrig init 0
   if (ktrig==0) then
	event_i "i", 2, 0, 1
         ktrig = 1
    endif
endin

In this case it should not matter how long the instrument runs, and  
there's no chance that the event_i line would get executed more than  
once.

-Lou


On Jul 9, 2010, at 9:00 PM, Peiman Khosravi wrote:

> Great idea. Thanks :-)
>
> P
>
> On 9 Jul 2010, at 18:48, Jacob Joaquin wrote:
>
>> On Fri, Jul 9, 2010 at 10:26 AM, Peiman Khosravi
>>  wrote:
>>> Thanks very much for testing this and the explanation. It makes  
>>> perfect
>>> sense.
>>
>> No problem.  In the mean time, I found what I think is a better
>> solution than 0.0001. In the "Setup" instr, set p3 to (ksmps / sr).
>> It'll work even if the audio sample is less than a second in  
>> duration.
>> Example:
>>
>> 
>> 
>> instr 1
>>   p3 = ksmps / sr   ; *HERE*
>>   event_i "i", 2, 0, 1
>>   turnoff
>> endin
>> instr 2
>>   prints "instr 2 launches successfully\n"
>> endin
>> 
>> 
>> i 1 0 1
>> 
>> 
>>
>>
>> Best,
>> Jake
>> -- 
>> The Csound Blog - http://csound.noisepages.com/
>> Slipmat - http://slipmat.noisepages.com/
>>
>>
>> Send bugs reports to the Sourceforge bug tracker
>>           https://sourceforge.net/tracker/?group_id=81968&atid=564599
>> Discussions of bugs and features can be posted here
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
>> "unsubscribe csound"
>>
>
>
>
> Send bugs reports to the Sourceforge bug tracker
>           https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body  
> "unsubscribe csound"
>



Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"