Using MP3 as sound fx

Hi all,
Is it possible to use several MP3s instead of WAV files to Mix
multiple sound channels for sound fx?

Thanks,

Dominique
http://www.DelphiGamer.com := go on, write a game instead;

It’s quite possible, but you probably don’t want to use mp3 for sound
effects in any sort of game. If you have 12 sounds playing, you’re
going to be adding the cpu overhead of doing an mp3 decode 12 times over
to your already high cpu usage. The penalty for using wav files is
really only disk space and possibly the higher file IO (although if your
sound effects are short, you’re not going to be saving a huge amount by
loading an mp3 as opposed to a wav file).

What you SHOULD use mp3 for is for any sort of game music or voiceover.
Any audio that you won’t be playing more than one or two of at a time
and is a long sample that would take significant disk space is perfect
for using a compressed format.

Additionally, you might want to investigate using Ogg Vorbis
(www.vorbis.com) instead of mp3. Not only does it provide higher sound
quality, but you don’t have to worry about licensing any patents from
Fraunhofer to use it in your application.

Jon
S2 GamesOn Thu, 2003-04-17 at 12:11, Dominique Louis wrote:

Hi all,
Is it possible to use several MP3s instead of WAV files to Mix
multiple sound channels for sound fx?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1On Thursday 17 April 2003 21:46, Jon Shiring wrote:

It’s quite possible, but you probably don’t want to use mp3 for sound
effects in any sort of game. If you have 12 sounds playing, you’re
going to be adding the cpu overhead of doing an mp3 decode 12 times over
to your already high cpu usage. The penalty for using wav files is
really only disk space and possibly the higher file IO (although if your
sound effects are short, you’re not going to be saving a huge amount by
loading an mp3 as opposed to a wav file).

Since you’d usually want to cache sound effects in memory anyway, you could
load and decode the mp3/ogg when the game is started or a level is loaded.
CPU usage is hardly an issue in this case, and it does reduce the overall
size the game uses on the hard disk, and, more importantly, download sizes.

cu,
Nicolai
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+nwb6sxPozBga0lwRAlrZAJ9EvWG4ZGDcMJ1feSdlCCRbf0cxcwCbBulH
VE6mfrmo+e+2GZXaTK8s6zU=
=GRM/
-----END PGP SIGNATURE-----

Just FYI, compressing small wav files individually gives pretty poor
compression ratios (occassionally it makes them larger).

I’m working on a tool (oggtar) to concatenate a series of wav file
(converting them to a common sample rate/channel number/sample size) and
then use Vorbis to compress them down and store the metadata. You can
use the same tool to decompress them back to wav files later on. This
way you don’t have to do the decompression at runtime in your engine and
you simply load the wav files like normal, but you get significant
compression for distributing your application.

I consider this the best solution, since you get the distribution
savings and you don’t have to increase your load times in the
application.

Jon
S2 GamesOn Thu, 2003-04-17 at 12:56, Nicolai Haehnle wrote:

Since you’d usually want to cache sound effects in memory anyway, you could
load and decode the mp3/ogg when the game is started or a level is loaded.
CPU usage is hardly an issue in this case, and it does reduce the overall
size the game uses on the hard disk, and, more importantly, download sizes.

Just FYI, compressing small wav files individually gives pretty poor
compression ratios (occassionally it makes them larger).

Huh? We have lots of samples, and they compress just fine; they most
certainly never become larger. I just took a bunch of arbitrarily-chosen
samples from the StepMania default theme:

-rwxr-xr-x 1 glenn users 8359 Apr 17 20:23 MusicWheel change.mp3*
-rw-r–r-- 1 glenn users 92204 Apr 17 20:23 MusicWheel change.mp3.wav
-rwxr-xr-x 1 glenn users 10866 Apr 17 20:23 ScreenPrompt change.mp3*
-rw-r–r-- 1 glenn users 59948 Apr 17 20:23 ScreenPrompt change.mp3.wav
-rwxr-xr-x 1 glenn users 3528 Apr 17 20:23 ScreenSelectDifficulty change.mp3*
-rw-r–r-- 1 glenn users 32300 Apr 17 20:23 ScreenSelectDifficulty change.mp3.wav
-rwxr-xr-x 1 glenn users 7105 Apr 17 20:23 ScreenSelectGroup change.mp3*
-rw-r–r-- 1 glenn users 39212 Apr 17 20:23 ScreenSelectGroup change.mp3.wav

The MP3s are a tiny fraction of the size–and these MP3s are oddly encoded
at 128kbit mono, which is a fairly high bitrate.

I’m working on a tool (oggtar) to concatenate a series of wav file
(converting them to a common sample rate/channel number/sample size) and
then use Vorbis to compress them down and store the metadata. You can
use the same tool to decompress them back to wav files later on. This
way you don’t have to do the decompression at runtime in your engine and
you simply load the wav files like normal, but you get significant
compression for distributing your application.

StepMania’s sound code decompresses BGMs from MP3s and Oggs at runtime,
and it works just fine. It decompresses samples on load if they’re
below a certain (arbitrary) size, so it doesn’t decode several samples at
the same time. I’ll probably add a mode to preload the compressed data,
so only decoding has to happen at runtime, not disk access, which will
also reduce play latency (reading from disk takes time). Decompressing
small samples at load time is fast; a quick commandline decompression of
44 files (similar to the above) took only a couple seconds on a p2/450.

The details are somewhat different in some environments (eg. consoles),
but I can’t think of any case where I’d actually want to store WAVs
anywhere.On Thu, Apr 17, 2003 at 01:16:53PM -0700, Jon Shiring wrote:


Glenn Maynard

Jon Shiring writes:

I consider this the best solution, since you get the distribution
savings and you don’t have to increase your load times in the
application.

One note though - this isn’t very handy for say handheld devices. :-)–
[ Below is a random fortune, which is unrelated to the above message. ]
Anyone who has had a bull by the tail knows five or six more things
than someone who hasn’t.
– Mark Twain