Help - Search - Members - Calendar
Full Version: Trying to implement the wavpack library, having problems with floating
Hydrogenaudio Forums > Lossless Audio Compression > WavPack
Madman2003
I'm trying to implement wavpack into a music player, and i've got all the integer modes working nicely, but floating point remains distorted. Are there special considerations to be made that aren't mentioned in lib_use.txt?
bryant
QUOTE(Madman2003 @ Feb 11 2007, 15:19) *

I'm trying to implement wavpack into a music player, and i've got all the integer modes working nicely, but floating point remains distorted. Are there special considerations to be made that aren't mentioned in lib_use.txt?

Since you're looking at lib_use.txt I assume you're not using the "tiny decoder" which now automatically handles float data. In the standard library you need to convert the float data back into integers yourself. Assuming that you use the OPEN_NORMALIZE flag and set "norm_offset" to zero, the buffer will come back with 32-bit floating data in the range of +/- 1.0, although you will still have to clip it because float data may exceed 0 dB.

Something like this would be the simplest to convert to 16-bit integers in place:
CODE
    int32_t *lptr = buffer;

    while (num_samples--) {
        float fdata = * (float*) lptr;

        if (fdata > 1.0) fdata = 1.0;
        if (fdata < -1.0) fdata = -1.0;

        *lptr++ = (int32_t) (fdata * 32767.0);
    }


You can also use the "norm_offset" parameter to scale the values for you. For example, I use 23 in the winamp plugin to have the values returned in the same range as 24-bit integers (although they still must be clipped and converted, just not scaled).

Good luck and thanks for implementing WavPack support!
scthom
Thanks for this... I was having the same issues with my Media Center plugin but hadn't gotten around to finding out what the problem was.
Madman2003
I have one remaining problem, even though i use OPEN_WVC it doesn't actually open the correction file.
The correction file is in the same folder with the same name, any thought?
Madman2003
I figured out my problem, i didn't use MODE_WVC when opening files for metadata reading.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.