QUOTE(nirm @ Dec 5 2006, 02:18)

Hello,
I'm trying to use wavpack as a library in another application and have a few questions regarding its usage.
I prefer wavpack over the rest because I was impressed of its fast encoding speed in comparison to others which offer only fast decoding.
As I have no experience with audio/audio compression please forgive me if some (or all...) of my questions don't make a lot of sense.
1. first of all is there some detailed API documentation of wavpack? The only reference I found is
hereIt helped a little but I would love to have a look at something a little more comprehensive.
I know that there needs to be better documentation on using the library and the document you site is very old (and really applies more to using the library for storing WavPack in another container). It turns out that I have delayed the release of WavPack 4.40 a few days (it was supposed to be on Sunday) so that I could create a better document for this so hopefully you can wait for that. In the meantime you can also look at the per-function documentation in wputils.c for the best description of the interface. Also, the Audition plugin is probably the cleanest example code to work from because it has fewer options that the command-line tools, and the winamp plugin is a mess.

QUOTE(nirm @ Dec 5 2006, 02:18)

2. I'm trying to encode audio which is saved in raw format (no wave header) and uses logarithmic quantization (mu-law)
I know all of its metadata (channels, sample width etc) so I can supply it to the context, however I have had no success so far
with compressing the mu-law samples.
Even the command line tool returns with an unsupported type error. the only way I got it to work was converting it to linear samples (with sox) and then compressing.
Is it possible to compress it without the supposedly unnecessary conversion? how?
I don't understand how the command-line tool would give you an unsupported type error if the files have no .wav header. In any event, WavPack does not handle mu-law data; it only handles uncompressed PCM. Now, with a little work it should be able to compress mu-law data if is was converted to unsigned and presented as 8-bit PCM in a .wav file (or directly to the encoder as signed). WavPack is not designed for this (because it's not linear), but will probably compress it better as (unsigned) 8-bit mu-law than it would after it was converted to 12 or 13-bit PCM (but you should try both because I'm not sure, neither would be really optimal).
That is for lossless. What might make more sense is converting it to 12 or 13-bit and then compressing it with the lossy mode of WavPack. In this mode you could probably retain virtually all of the original quality at about 3 bits per sample because WavPack is much more efficient than mu-law for this. Of course, if you then converted back into mu-law after decoding you would have yet another lossy hit, but perhaps the WavPack data could be decompressed to PCM as the final product. I don't know your application.
QUOTE(nirm @ Dec 5 2006, 02:18)

3. The compression function takes samples in the form of longs, whereas I have them in chars.
should I cast the entire buffer to long* and cut the length which I specify to a quarter ? should I cast each of the samples to long (and by that, make the buffer 4 times longer)?
The second. Yes, this makes the buffer 4 times bigger, but WavPack operates on longs internally so it really doesn't make any difference. Keep in mind that you don't have to convert a huge buffer into longs; WavPack accepts the samples in whatever size chunks you want and buffers them internally until it has a full block.
QUOTE(nirm @ Dec 5 2006, 02:18)

4. Could you outline the process of decompression for me because I couldn't quite figure it out from the link above and from the code of the command line tool.
Well, it's really pretty straightforward. Try looking at the analyze_file() function in wvgain.c because it has the least "extra" stuff. And look at the comments for the functions called in wputils.c for details.
Good luck!

edit: clarification of signed/unsigned