Csound Csound-dev Csound-tekno Search About

[Cs-dev] timecounting bug

Date2012-02-24 16:26
FromVictor Lazzarini
Subject[Cs-dev] timecounting bug
On 5.16, if the score event is beyond the max allowable duration, there is either a crash or csound gets hung.



-d


ksmps=1
0dbfs=1
nchnls=2
instr 1

asig rand 0dbfs

outs asig,asig
endin


i1 0 360000




Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie




------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2012-02-24 18:40
FromTito Latini
SubjectRe: [Cs-dev] timecounting bug
AttachmentsNone  

Date2012-02-24 19:13
FromVictor.Lazzarini@nuim.ie
SubjectRe: [Cs-dev] timecounting bug
AttachmentsNone  None  None  None  

Date2012-02-24 21:32
FromTito Latini
SubjectRe: [Cs-dev] timecounting bug
AttachmentsNone  

Date2012-02-24 22:40
FromVictor.Lazzarini@nuim.ie
SubjectRe: [Cs-dev] timecounting bug
AttachmentsNone  None  None  None  

Date2012-02-25 07:32
FromTito Latini
SubjectRe: [Cs-dev] timecounting bug
AttachmentsNone  

Date2012-02-25 08:07
FromVictor Lazzarini
SubjectRe: [Cs-dev] timecounting bug
I would have thought that

 if (--(csound->cyclesRemaining) <= 0) ...

etc
could safely be made 

if (--(csound->cyclesRemaining) <= 0) ...

[maybe with the check that it is not 0 already]

because time counting should not be expected to become negative. But you are right that if an int is used, it would be simpler to keep the variable signed.

Victor
On 25 Feb 2012, at 07:32, Tito Latini wrote:

>> why not go all the way and use Uint64 instead? It should give us another million years.
> 
> int64 requires less changes, musmon.c contains
> 
>  if (--(csound->cyclesRemaining) <= 0) ...
>  ...
>  while (csound->cyclesRemaining <= 0)...
>  ...
> 
> Here is the simplest patch, you can improve or ignore it
> 
> diff -ur csound5~/Engine/musmon.c csound5/Engine/musmon.c
> --- csound5~/Engine/musmon.c	2012-02-24 22:58:37.000000000 +0100
> +++ csound5/Engine/musmon.c	2012-02-24 23:09:48.000000000 +0100
> @@ -805,7 +805,7 @@
>     return retval;
> }
> 
> -#define RNDINT(x) ((int) ((double) (x) + ((double) (x) < 0.0 ? -0.5 : 0.5)))
> +#define RNDINT64(x) ((int64_t) ((double) (x) + ((double) (x) < 0.0 ? -0.5 : 0.5)))
> 
> extern  int     sensMidi(CSOUND *);
> 
> @@ -919,10 +919,10 @@
>       /* calculate the number of k-periods remaining until next event */
>       if (O->Beatmode)
>         csound->cyclesRemaining =
> -          RNDINT((csound->nxtbt - csound->curBeat) / csound->curBeat_inc);
> +          RNDINT64((csound->nxtbt - csound->curBeat) / csound->curBeat_inc);
>       else {
>         csound->cyclesRemaining =
> -          RNDINT((csound->nxtim*csound->esr - csound->icurTime) / csound->ksmps);
> +          RNDINT64((csound->nxtim*csound->esr - csound->icurTime) / csound->ksmps);
>         csound->nxtim = (csound->cyclesRemaining*csound->ksmps+csound->icurTime)/csound->esr;
>       }
>     }
> diff -ur csound5~/H/csoundCore.h csound5/H/csoundCore.h
> --- csound5~/H/csoundCore.h	2012-02-24 22:58:37.000000000 +0100
> +++ csound5/H/csoundCore.h	2012-02-24 23:17:35.000000000 +0100
> @@ -1062,7 +1062,7 @@
>     /** start time of current section    */
>     double        timeOffs, beatOffs;
>     /** current time in seconds, inc. per kprd */
> -    long          icurTime;   /* Current time in samples */
> +    int64_t       icurTime;   /* Current time in samples */
>     double        curTime_inc;
>     /** current time in beats, inc per kprd */
>     double        curBeat, curBeat_inc;
> @@ -1209,7 +1209,7 @@
>     void          **cfgVariableDB;
>     double        prvbt, curbt, nxtbt;
>     double        curp2, nxtim;
> -    int           cyclesRemaining;
> +    int64_t       cyclesRemaining;
>     EVTBLK        evt;
>     void          *memalloc_db;
>     MGLOBAL       *midiGlobals;
> 
> ------------------------------------------------------------------------------
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing 
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie




------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2012-02-25 12:32
FromMichael Gogins
SubjectRe: [Cs-dev] timecounting bug
I agree with Tito, use int64_t. In my view it is unnecessarily
complicated to think that if time counting in Csound is necessarily
positive (in other contexts, it might not be!), therefore the number
representing the time count also must necessarily be positive.

Regards,
MIke

On Sat, Feb 25, 2012 at 3:07 AM, Victor Lazzarini
 wrote:
> I would have thought that
>
>  if (--(csound->cyclesRemaining) <= 0) ...
>
> etc
> could safely be made
>
> if (--(csound->cyclesRemaining) <= 0) ...
>
> [maybe with the check that it is not 0 already]
>
> because time counting should not be expected to become negative. But you are right that if an int is used, it would be simpler to keep the variable signed.
>
> Victor
> On 25 Feb 2012, at 07:32, Tito Latini wrote:
>
>>> why not go all the way and use Uint64 instead? It should give us another million years.
>>
>> int64 requires less changes, musmon.c contains
>>
>>  if (--(csound->cyclesRemaining) <= 0) ...
>>  ...
>>  while (csound->cyclesRemaining <= 0)...
>>  ...
>>
>> Here is the simplest patch, you can improve or ignore it
>>
>> diff -ur csound5~/Engine/musmon.c csound5/Engine/musmon.c
>> --- csound5~/Engine/musmon.c  2012-02-24 22:58:37.000000000 +0100
>> +++ csound5/Engine/musmon.c   2012-02-24 23:09:48.000000000 +0100
>> @@ -805,7 +805,7 @@
>>     return retval;
>> }
>>
>> -#define RNDINT(x) ((int) ((double) (x) + ((double) (x) < 0.0 ? -0.5 : 0.5)))
>> +#define RNDINT64(x) ((int64_t) ((double) (x) + ((double) (x) < 0.0 ? -0.5 : 0.5)))
>>
>> extern  int     sensMidi(CSOUND *);
>>
>> @@ -919,10 +919,10 @@
>>       /* calculate the number of k-periods remaining until next event */
>>       if (O->Beatmode)
>>         csound->cyclesRemaining =
>> -          RNDINT((csound->nxtbt - csound->curBeat) / csound->curBeat_inc);
>> +          RNDINT64((csound->nxtbt - csound->curBeat) / csound->curBeat_inc);
>>       else {
>>         csound->cyclesRemaining =
>> -          RNDINT((csound->nxtim*csound->esr - csound->icurTime) / csound->ksmps);
>> +          RNDINT64((csound->nxtim*csound->esr - csound->icurTime) / csound->ksmps);
>>         csound->nxtim = (csound->cyclesRemaining*csound->ksmps+csound->icurTime)/csound->esr;
>>       }
>>     }
>> diff -ur csound5~/H/csoundCore.h csound5/H/csoundCore.h
>> --- csound5~/H/csoundCore.h   2012-02-24 22:58:37.000000000 +0100
>> +++ csound5/H/csoundCore.h    2012-02-24 23:17:35.000000000 +0100
>> @@ -1062,7 +1062,7 @@
>>     /** start time of current section    */
>>     double        timeOffs, beatOffs;
>>     /** current time in seconds, inc. per kprd */
>> -    long          icurTime;   /* Current time in samples */
>> +    int64_t       icurTime;   /* Current time in samples */
>>     double        curTime_inc;
>>     /** current time in beats, inc per kprd */
>>     double        curBeat, curBeat_inc;
>> @@ -1209,7 +1209,7 @@
>>     void          **cfgVariableDB;
>>     double        prvbt, curbt, nxtbt;
>>     double        curp2, nxtim;
>> -    int           cyclesRemaining;
>> +    int64_t       cyclesRemaining;
>>     EVTBLK        evt;
>>     void          *memalloc_db;
>>     MGLOBAL       *midiGlobals;
>>
>> ------------------------------------------------------------------------------
>> Virtualization & Cloud Management Using Capacity Planning
>> Cloud computing makes use of virtualization - but cloud computing
>> also focuses on allowing computing to be delivered as a service.
>> http://www.accelacomm.com/jaw/sfnl/114/51521223/
>> _______________________________________________
>> Csound-devel mailing list
>> Csound-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/csound-devel
>
> Dr Victor Lazzarini
> Senior Lecturer
> Dept. of Music
> NUI Maynooth Ireland
> tel.: +353 1 708 3545
> Victor dot Lazzarini AT nuim dot ie
>
>
>
>
> ------------------------------------------------------------------------------
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel



-- 
Michael Gogins
Irreducible Productions
http://www.michael-gogins.com
Michael dot Gogins at gmail dot com

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net