IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Trying to implement the wavpack library, having problems with floating, Any special considerations (besides clip issues)?
Madman2003
post Feb 12 2007, 00:19
Post #1





Group: Members
Posts: 132
Joined: 18-February 04
Member No.: 12104



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?
Go to the top of the page
+Quote Post
bryant
post Feb 12 2007, 00:53
Post #2


WavPack Developer


Group: Developer (Donating)
Posts: 1291
Joined: 3-January 02
From: San Francisco CA
Member No.: 900



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!
Go to the top of the page
+Quote Post
scthom
post Feb 12 2007, 01:16
Post #3





Group: Members
Posts: 6
Joined: 16-August 05
From: Gilbert, AZ
Member No.: 23926



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.
Go to the top of the page
+Quote Post
Madman2003
post Feb 12 2007, 11:49
Post #4





Group: Members
Posts: 132
Joined: 18-February 04
Member No.: 12104



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?
Go to the top of the page
+Quote Post
Madman2003
post Feb 12 2007, 22:04
Post #5





Group: Members
Posts: 132
Joined: 18-February 04
Member No.: 12104



I figured out my problem, i didn't use MODE_WVC when opening files for metadata reading.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 21st September 2014 - 17:43