Csound Csound-dev Csound-tekno Search About

[CSOUND-DEV:3075] Bug in negative function length found

Date2003-08-31 15:36
FromGabriel Maldonado
Subject[CSOUND-DEV:3075] Bug in negative function length found
Hi jpff,
I've just discovered a bug in negative p3 of f score opcode 
(non-pow-of-two function length):

at line 121 of fgens.c there are the following lines:

     if ((flen = (long)(e->p[3]+0.5))) {  /* if user flen given  */
       if (flen < 0 ) { /* gab for non-pow-of-two-length */
         flen = labs(flen); <=== change this line
         lenmask = 0xFFFFFFFF;
         lobits = 0;    /* Hope this is not needed! */
       }

the line must be changed into:

         flen = labs(flen-1);

because of the  flen = (long)(e->p[3]+0.5))
expression, that adds 0.5.
In fact, in case I want a table of 100 elements i would write the 
following line in the score:

f1 0 512 -100 10 1

but instead of 100 elements, the old code allocated a table of 99 
elements...

Please, correct it in canonical!

-- 
Gabriel Maldonado
http://csounds.com/maldonado/home2.htm
--

Date2003-08-31 17:29
FromJohn
Subject[CSOUND-DEV:3076] Re: Bug in negative function length found
On Sun, 31 Aug 2003, Gabriel Maldonado wrote:

> Hi jpff,
> I've just discovered a bug in negative p3 of f score opcode 
> (non-pow-of-two function length):
> 
> at line 121 of fgens.c there are the following lines:

OK; have fixed both source systems
==John ff