Erik de Castro Lopo wrote:


The fix in this case was this:

for (;;)
{ /* Bunch of other code. */


        fractional += increment ;
       rem = fmod (fractional, 1.0);   /* floating point modulus */
       integer += lrint (round (fractional - rem));
       fractional = rem;
       }

which is far more robust.


In LinuxSampler we do

 double increment;
 double fullindex;
 int integer;
 double fractional;
 for (;;)
 {
   /* Bunch of other code. */

   fullindex += increment;
   integer = lrintf(fullindex);
   fractional = fullindex - integer;
 }


I did not benchmark the above code against yours but I think it should be faster.
(plus instead of lrintf() we use an asm FISTL macro which is a bit faster (around 10% IIRC).


cheers,
Benno
http://www.linuxsampler.org




Reply via email to