views:

1432

answers:

4

My application needs to play sound files. The only cross-platform file format I can use is WAVE (I'm using QSound of the Qt framework).

The file sizes of these sounds are quite large and I'd like to know if there is a way to reduce it, without losing (too much) quality.

I need the file to be stereo.

+5  A: 

The only way to reduce the size of a wav file is to resample it to a lower bit rate or use less bits per sample. Wav files don't have compression capabilities like mp3 or ogg.

If you are using a 16 bit 44 khz file you can cut the file size in half by going to a 22khz sample rate, and all you will lose is some of the high frequencies.

Robert Harvey
This is probably the only way youre going to get WAV to "compress" without losing quality. It's still losing quality of course, but not in a very noticable way, and you'll get a 50% data size compression.
Karl
And if you're looking for something to do the conversion with, I suggest using Audacity (http://audacity.sourceforge.net/)
Andre Miller
+1  A: 

You can zip them (using zlib or similar), then uncompress them on demand. If you've got many minutes of continuous wav it may be worth looking into audio-specific lossless compression algorithms like FLAC.

pjc50
There's no reason not to use FLAC even if the samples are quite short.
Josh K
+1  A: 

Why not use FLAC? It's the best way to do lossless compression of WAV without sacrificing any quality at all.

Josh K
A: 

You probably should have a look into the Phonon Module of Qt. It's cross-platform and supports the native formats of the different platforms. I think you can assume MP3 support for most of the OSes.

beef2k