Re: [linux-audio-dev] pbd's votes on LADSPA

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

Subject: Re: [linux-audio-dev] pbd's votes on LADSPA
From: James McCartney (asynth_AT_io.com)
Date: Mon Mar 27 2000 - 07:18:37 EEST


on 3/26/00 8:14 PM, Paul Barton-Davis at pbd_AT_Op.Net wrote:

> But anyway, my real point was that if you force a signed 24 bit
> integer sample stream into a 24 bit mantissa, you can't convert it in
> both directions and keep all the bits all the time. the range is
> -(2^24) to +((2^24-1) because of the sign bit, and you will inevitably
> end up with values that cannot be exactly represented. Consider the
> very simple case: a sample value of 16777214, the maximum
> theoretically possible minus one. The scaled representation of this
> number (16777214/167777215) is irrational, and thus is not accurately
> representable by any number of bits.
>
> I think that what you are suggesting is something along the lines of:
>
> normal 24 bit float representation 16777214 * (2 ^ 0)
> scaled value 16777214 * (2 ^ -24)
>
> but this is not the correct answer.

24 bit numbers range from -8388608 to 8388607. 16777214 is not representable
in 24 bits.
Just to pick nits, any number representable as a ratio is ratio-nal by
definition. including "(16777214/167777215)" or whatever..

The following works on my machine and shows that all 24 bit integers can be
converted to and from 32 bit floats and retain all their bits on
reconversion :

void testbits()
{
    long startval = 0xFF800000;
    long endval = 0x007FFFFF;
    float convertTo = 1./(1L<<24);
    float convertFrom = (1L<<24);
    for (long i=startval; i<=endval; ++i) {
        float in = i;
        float cin = in * convertTo;
        if (!(-1.0 <= cin && cin < 1.0)) {
            printf("%08X failed range %g\n", i, cin);
            break;
        }
        long out = cin * convertFrom;
        if (out != i) {
            printf("%08X failed bits-in == bits-out %08X\n", i, out);
            break;
        }
    }
    printf("passed\n");
}

--- james mccartney james_AT_audiosynth.com <http://www.audiosynth.com>
SuperCollider - a real time synthesis programming language for the PowerMac.
<ftp://www.audiosynth.com/pub/updates/SC2.2.7.sea.hqx>


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

This archive was generated by hypermail 2b28 : Mon Mar 27 2000 - 07:52:56 EEST