author Ryan C. Gordon <icculus@icculus.org>
Tue, 15 May 2018 01:04:11 -0400
changeset 11987 0c284754e25b
parent 10952 fabcc99bb455
permissions -rw-r--r--
audio: converting int32 to/from float shouldn't use doubles.

The concern is that a massive int sample, like 0x7FFFFFFF, won't fit in a
float32, which doesn't have enough bits to hold a whole number this large,
just to divide it to get a value between 0 and 1.
Previously we would convert to double, to get more bits, do the division, and
cast back to a float, but this is expensive.

Casting to double is more accurate, but it's 2x to 3x slower. Shifting out
the least significant byte of an int32, so it'll definitely fit in a float,
and dividing by 0x7FFFFF is still accurate to about 5 decimal places, and the
difference doesn't appear to be perceptable.
     2 Bugs are now managed in the SDL bug tracker, here:
     4     https://bugzilla.libsdl.org/
     6 You may report bugs there, and search to see if a given issue has already
     7  been reported, discussed, and maybe even fixed.
    10 You may also find help at the SDL forums/mailing list:
    12     https://discourse.libsdl.org/
    14 Bug reports are welcome here, but we really appreciate if you use Bugzilla, as
    15  bugs discussed on the mailing list may be forgotten or missed.