Archived

This topic is now archived and is closed to further replies.

ageny6

Compressing wave files

Recommended Posts

Is there a file format out there that can compress a .wav file but retain the .wav extension. In other words, I am not looking for who to convert to .mp3 or .ogg, what I am looking for is almost like a codec, but for audio .wav files. Any ideas? Thanks My signature used to suck. But it''s much better now.

Share this post


Link to post
Share on other sites
The ACM (Audio Compression Manager) of Windows will automatically use the appropriate codec for a .WAV file, so you can actually rename a .MP3 or .WMA to .WAV and it''ll play as a .WAV and the decompresion will be handled for you!

.WAV is really just a wrapper - most "plain" WAVs you''ll find aren''t "raw" sample data anyway.

Share this post


Link to post
Share on other sites
quote:
Original post by S1CA
.WAV is really just a wrapper - most "plain" WAVs you'll find aren't "raw" sample data anyway.


So how come, then, does a .wav takes up soo much hard drive space if it is not raw data?



My signature used to suck. But it's much better now.

[edited by - ageny6 on October 11, 2003 10:05:45 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by ageny6
So how come, then, does a .wav takes up soo much hard drive space if it is not raw data?


Lossy versus lossless compression and different levels of "lossiness" as well as different levels of CPU overhead to decompress/decode.

MP3, WMA, OGG etc are [typically] more lossy and use more CPU time to decode.

PCM, ADPCM etc are [typically] less lossy and use less CPU time, but have larger file sizes for the equivilent file.

The type of samples being compressed matters too - for example TrueSpeech WAVs are more applicable for spoken word audio.

Share this post


Link to post
Share on other sites
quote:
Original post by cowsarenotevil
When you compress a WAV file using an MP3 codec, will it be larger or smaller than the equivalent MP3?

Note sure what you mean? If you are asking about whether an mp3 is larger than a wav, the answer is not, because there is some data loss during the conversion.


My signature used to suck. But it''s much better now.

Share this post


Link to post
Share on other sites
Wait a minute!

That means that using uncompressed raw data for, say, background music would take less processing speed than playing a mp3? Did I get that straight? If so, is there a big difference, or is it barely noticable by today's standards?



My signature used to suck. But it's much better now.

[edited by - ageny6 on October 12, 2003 6:27:32 PM]

Share this post


Link to post
Share on other sites
quote:
Did I get that straight?


Yep, MP3/WMA/OGG etc take more CPU time to decode/decompress than simpler compression formats such as ADPCM.


quote:
If so, is there a big difference, or is it barely noticable by today''s standards?


It depends how scarce your CPU resources are - if you''re making a game for P200''s *AND* everything else in your game is using a lot of CPU power (physics/dynamics simulation for example), then yes, the difference can be important (big-ish).

On a "current" machine however, the audio decode time is a tiny percentage of the available CPU power - and there are usually much larger CPU hogs than audio decompression. Games commonly are CPU bound in some way though - so its something to look at _if_ the performance of your game on your target is below par.

Share this post


Link to post
Share on other sites
quote:
Yep, MP3/WMA/OGG etc take more CPU time to decode/decompress than simpler compression formats such as ADPCM.

It does take more time, however, it depends on how you load your audio files as well. If you have a small mp3 that gets played continuously as background music, with some (most?) audio libraries like fmod you can have it uncompress the file at loadup into memory so it only uncompresses once and continuously plays it from memory. I do that with most of my game sounds since a raw wav file is about 10mb per minute of audio (I think), and a 1 minute mp3 can be less than 1 mb. It takes a lot less disk space but more time when the game/level is loading. You will probably see the biggest performance hit when you try to play files directly from disk at runtime. Depending on the complexity of your game, you may have the extra time per frame to read from the disk and decompress on the fly. For example that worked fine for a simple galaga type game I made, but probably wouldn''t work well for a first person shooter where frames per second seem to be bragging rights for people.

Evillive2
E-Mail

Share this post


Link to post
Share on other sites
Since this is in ''game programming'', I''ll assume you''re using it for a game.

You can use zlib to compress your wav in a zip, then zlib again to decompress and load during game play. It will still be a wav file, but it will be smaller.

~~~~~
"the best thing about betting on apathy is that even when you lose, you dont care." - nethead.
Download and play Slime King I.

Share this post


Link to post
Share on other sites
quote:
Original post by dede
You can use zlib to compress your wav in a zip, then zlib again to decompress and load during game play. It will still be a wav file, but it will be smaller.


If you have a, for example, for minute song, and that it is about 40 someodd number of megabytes, does that mean that you get to load 40 megabytes worth of wav in memory?



My signature used to suck. But it''s much better now.

Share this post


Link to post
Share on other sites
quote:
If you have a, for example, for minute song, and that it is about 40 someodd number of megabytes, does that mean that you get to load 40 megabytes worth of wav in memory?


yes that is correct. Usually most game music is a loop of a short tune. Think back to those old nes games with the short midi loops. Great, now that Mario Bros music is stuck in my head again!!! I haven''t really looked into using midi for background music mainly because it is easier for me to plug my guitar or keyboard into my sound cards audio in and record as a wav, but I know midi files are really small and I think they use very little processing time, but that may be an option you might want to look into.


Evillive2
E-Mail

Share this post


Link to post
Share on other sites
quote:
Original post by ageny6
quote:
Original post by dede
You can use zlib to compress your wav in a zip, then zlib again to decompress and load during game play. It will still be a wav file, but it will be smaller.

If you have a, for example, for minute song, and that it is about 40 someodd number of megabytes, does that mean that you get to load 40 megabytes worth of wav in memory?
Depends. You can get away with double buffering your music.

Here''s are blocks of music
ABCDEF...

Load AB, play A, get B ready. When the A stops, start B. Erase A and load C. Repeat til end, and restart. That is a way you can get around 40 megs. zlib allows you to load things in blocks, you''ll just have to generate header information, which would be faster than decompressing a mp3.

If you do it in another thread(i.e. a mult-threaded application), it probably wouldn''t be too much of a preformance hit. You''ll have to play with how big your block size is too, you want it to be long enough to have enough time to get the next one, but not too big.


You can also just not care, since Windows has 2 gigs of virtual memory to play with. You''ll just have a very long loading time!


If you talking about 40 megs, I''d just use either .mp3 or .ogg. DirectShow has mp3 decompression, and .ogg has its own decompression for free. I''d go with mp3, since it is slightly more mature at this time, so it decompresses a bit faster.

~~~~~
"the best thing about betting on apathy is that even when you lose, you dont care." - nethead.
Download and play Slime King I.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by evillive2



...Think back to those old nes games with the short midi loops...


Evillive2
<a href="mailto:jessechoward@netscape.net"><img border="0" src="http:\\users.rcn.com/jhoward5/char1.gif" width="64" height="64">E-Mail</a>


I had no Idea NES uses MIDI.

Share this post


Link to post
Share on other sites
quote:
I had no Idea NES uses MIDI.


sure, its not like the game cartriges could hold data the size of a wave file!

My signature used to suck. But it''s much better now.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
http://www.vgmuseum.com/systems/nes/

That page doesn''t mention anything about MIDI.

Share this post


Link to post
Share on other sites