Best way to store music?

Started by
15 comments, last by Promit 16 years, 11 months ago
I have a DirectX game that plays music using DirectSound. The problem is, the game's music is stored as *.wav, which takes up a lot of space (which is bad, because I want to game to be distributed over the internet). I've searched the internet and the site, but it's only confused me. What's the best way to solve this problem? (By "best" I mean smallest file size while still maintaining quality and speed) Is it using *.mp3 or *.ogg files and playing them with DirectShow? Will that slow down my game at all? Will I still be able to play sound effects? I've heard that there is a way of compressing wav files... is this a good solution? Thanks!
Advertisement
Quote:Original post by UltimateWalrus
Is it using *.mp3 or *.ogg files and playing them with DirectShow?
I would go for .ogg. I've used them a few times and they always resolved to be slightly smaller than mp3 for similar quality... but the difference was rather small. I don't know how it is now but I think there's enough to go for .ogg anyway.
By the way, I simply love libvorbis - I managed to compile and use it in a few hours. Personally I would suggest to give it a ride instad of DS in this case!
Quote:Original post by UltimateWalrus
Will that slow down my game at all?
Sure, you have to manage it correctly, but consider today's processors can encode multiple streams in real time... decoding isn't really so difficult.
Quote:Original post by UltimateWalrus
I've heard that there is a way of compressing wav files... is this a good solution?
As far as I know, not nearly as good as using vorbis (or any other "natively compressed" format)... by the way, UT2003 and later uses them so it's a pretty good reference!


Previously "Krohm"

Definately ogg
you can encode a .wav file with a lossless algorithm, which generally will reduce the size by over 50%, without affecting sound quality
FLAC is a great one, apple also has their lossless formats (which the iPod can actually play), just search for "lossless compression" or "lossless audio"

I can say FLAC has had some playback issues on my computer though, so I'm not sure how that would work in a game, performance wise.

I agree that .ogg files seem to be smaller than .mp3 files, though by only a little. I'm not terribly familiar with their specifications, however.

***I just realized you said over the internet - definitely just go with .ogg or .mp3, lossless is far too large***
Another vote for OGG. It's incredibly simple to get code working with DirectSound and ogg vorbis. You just pass vorbis a file (or a file in memory, and you write functions to interface with vorbis), and it gives you raw wave data back out.
I noticed that you also mentioned sound effects... if you're worried that other formats may slow down your game, you can keep the sound effects as wave files. Unless I'm assumeing too much, your sound effects will be short (~2 seconds max) and so shouldn't take up much space any way.

Alex~
"The truth hurts for a moment. A lie hurts for a long time." - Dean C. P.
Forget about MP3. You need a licence to use it in a commercial application and its inferior to OGG in every way that counts.

And don't worry about decoding performance either. If you want reassurance, try measuring your game's performance with and without a media player running in the background.

Admiral
Ring3 Circus - Diary of a programmer, journal of a hacker.
Quote:Original post by TheAdmiral
Forget about MP3. You need a licence to use it in a commercial application and its inferior to OGG in every way that counts.

And don't worry about decoding performance either. If you want reassurance, try measuring your game's performance with and without a media player running in the background.

Admiral


Of course if you're talking Windows (which you are if you're using DirectX) your customer has already paid for the license, and you can use the Windows APIs to play the MP3 with no repercussions. Personally I'd probably use WMA mostly because I'm pretty sure Windows will continue to support it well. In terms of compression and performance it's better than MP3 and probably about equivalent to OGG (perhaps the audiophiles and the open-source junkies will quibble one way or the other).

Geoff


Quote:Original post by gdunbar
Quote:Original post by TheAdmiral
Forget about MP3. You need a licence to use it in a commercial application and its inferior to OGG in every way that counts.

And don't worry about decoding performance either. If you want reassurance, try measuring your game's performance with and without a media player running in the background.

Admiral


Of course if you're talking Windows (which you are if you're using DirectX) your customer has already paid for the license, and you can use the Windows APIs to play the MP3 with no repercussions.
The subtle difference is that the Windows OS contains a license to include a player. The Windows Media / DirectShow components doing exactly this.

Depending on how successful the product is you might not be affected, but just distributing MP3 encoded content requires a license - regardless of whether you offer them a means to play it or not:

Quote:5) Do I need a license to distribute mp3, mp3PRO or mp3surround encoded content?:

Yes. A license is needed for commercial (i.e., revenue-generating) use of mp3/mp3PRO in broadcast systems (terrestrial, satellite, cable and/or other distribution channels), streaming applications (via Internet, intranets and/or other networks), other content distribution systems (pay-audio or audio-on-demand applications and the like) or for use of mp3/mp3PRO on physical media (compact discs, digital versatile discs, semiconductor chips, hard drives, memory cards and the like).

However, no license is needed for private, non-commercial activities (e.g., home-entertainment, receiving broadcasts and creating a personal music library), not generating revenue or other consideration of any kind or for entities with associated annual gross revenue less than US$ 100 000.00.


I've not used OGG myself but I've yet to hear anything bad about it [smile]

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

I`ve been using Ogg for last 6 years in about 5 projects and the quality/size ratio is surely better than with MP3 (at that time we didn`t have to even think about the absurd license fees). However, Audiere library that I`ve been using so far, has some issues with Vista (which is understandable, since that library was written even before WinXP). I just switched to irrKlang and this seems to work fine under Vista.

Regarding the performance, even on 450 MHz Celeron with 64MB of RAM, the streamed music wasn`t slowing it down very much - maybe 5% hit on such an ancient machine. But on anything over 1 GHz, the performance difference was barely 1-2 fps (Music On/Off). Always streamed, of course.
So don`t worry about the performance at all.

VladR My 3rd person action RPG on GreenLight: http://steamcommunity.com/sharedfiles/filedetails/?id=92951596

This topic is closed to new replies.

Advertisement