Re: [linux-audio-dev] Traps in floating point code

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] Traps in floating point code
From: Benno Senoner (sbenno_AT_gardena.net)
Date: Tue Jun 29 2004 - 11:19:32 EEST


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


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Tue Jun 29 2004 - 17:40:34 EEST