Mp3 In Games?


Winterkid

Active Member
Joined
Nov 15, 2004
Messages
942
Age
51
Location
Surrey BC CANADA
Website
Visit site
With the built-in MP3 support in the Arm cores, will games be able to play MP3's in-game or will too much of the CPU still be used too much to allow processing room for it?

Alright, for example, I code or port a game (in my dreams) that's not very CPU intensive, like a puzzle or card game, or even a light platformer. Would MP3 music slow it down too dramatically, even with the built-in MP3 handling?

This is just a for instance, and I know MIDI is a lot easier for most devs to work with.
 
With the built-in MP3 support in the Arm cores, will games be able to play MP3's in-game or will too much of the CPU still be used too much to allow processing room for it?

Alright, for example, I code or port a game (in my dreams) that's not very CPU intensive, like a puzzle or card game, or even a light platformer. Would MP3 music slow it down too dramatically, even with the built-in MP3 handling?

This is just a for instance, and I know MIDI is a lot easier for most devs to work with.


Isn't decent software midi mixing more CPU intensive than MP3?

-OCA|
 
Last edited by a moderator:
I was led to believe MIDI files were really easy to work with and play cause they're not really sound files, just data about where to play the instruments and which instruments to play with no recorded sounds at all.
 
i think libmad and tremor are running on the second core by default at gp2x linux, correct me if iam wrong.
So if your game isnt useing the second core you can run mp3/ogg at it at low cost.
 
Right - this brings up a question of mine: can the GP2X play MIDI out of box? Carrying around a Kirby, Mario, Zelda, or Final Fantasy sound track (or all of them) at under a Meg is one of my fever dreams involving the GP2X.
 
i think libmad and tremor are running on the second core by default at gp2x linux, correct me if iam wrong.
So if your game isnt useing the second core you can run mp3/ogg at it at low cost.
Second core is used for video processing, not sound. I think the idea is that the mmsp2 is supposed to be doing a lot of work on the second core decoding video, so all audio processing is done in software on the first core.

Anyway, I've just done a quick test using Lacuna and SDL_Mixer. Playing an ogg instead of a mod (don't have mp3 support compiled into my version of SDL_Mixer) does slow the current build of the game down slightly and there are occasional yerks in the motion, but I am using a high quality 44khz ogg which is overkill for tiny speakers on a handheld. I would assume dropping the ogg quality should improve the gameplay without much difference in sound output quality. You'll be able to test for yourself when Lacuna is released as you will be able to select the music to play this time instead of just the one mod.
 
Last edited by a moderator:
Playing an ogg instead of a mod (don't have mp3 support compiled into my version of SDL_Mixer) does slow the current build of the game down slightly and there are occasional yerks in the motion, but I am using a high quality 44khz ogg which is overkill for tiny speakers on a handheld.


Isn't Ogg a bit slower to decompress than MP3? I think I remember reading that somewhere.

Also, you say you're using a high quality ogg file - what bitrate and/or quality setting was it?



Right - this brings up a question of mine: can the GP2X play MIDI out of box? Carrying around a Kirby, Mario, Zelda, or Final Fantasy sound track (or all of them) at under a Meg is one of my fever dreams involving the GP2X.

I highly doubt it. A good wavetable instrument set is about 16-20 megs. That said, I would imagine some programmers will write programs to play SPCs, PSFs, NSFs, and other emulated sound formats so you can listen to them as they originally sounded yet with tiny file sizes. Depending on how open the built in launcher is, it may even be possible to integrate that into the built in launcher as an add-on of some kind.

That said - if nobody gives that a shot, I may just look into it over christmas break, when I'll actually have the free time to do something with my GP2x. It sounds like a simple enough port that I could do it.. I think :p

-OCA|
 
Last edited by a moderator:
We've got a version of SDL mixer that compiles with timidity (and ogg tremor for that matter), but can't convince it to look on the SD card for the wavetables. I'll have a look at it when the unit ships (soon i hope!)
 
Last edited by a moderator:
The changes to libTremor that I worked on with others on the GP32 to speed up the decoding a bit seem to move over to the GP2X just fine and you can use the patched version of the lib as a basis for building SDL_mixer for example. Speed at the expense of some minor quality drops.

Just doing some more testing in that arena but a low quality OGG should not hit the system overly hard. The current ARM-Linux versions of libTremor (OGG Vorbis) and libMAD (MP3) only run on the 1st core. Shifting them over or making running it on the 2nd core an option would be a very cool idea and I am sure it will happen in time but we shall see ;).
 
It was http://www.machinaesupremacy.com/downloads...-_sidstyler.ogg if anyone wants to check. It's 5mb for 3 minutes which seems large for an ogg so I'm assuming it's pretty high quality.


Hey, one of my favorite bands :D

They tend to encode their Oggs between 192kbps and 256kbps. Playing that song, it seems to hover around 215.

Personally, when encoding for something with limited space, I encode at 96kbps. Even then, I only notice the quality loss when I'm actually trying to find the difference.

So, does the CPU time for ogg decoding scale linearly with the bitrate? If so, it sounds like a lower bitrate Ogg would be perfectly acceptable.

-OCA|
 
Last edited by a moderator:
So, does the CPU time for ogg decoding scale linearly with the bitrate? If so, it sounds like a lower bitrate Ogg would be perfectly acceptable.

-OCA|

No idea how it scales but lower bitrate oggs are easier to decode. I think the second core should be more than fast enough to decode high quality ogg and mp3 realtime. There are mp3 players about with slower processors.
It's probably just a matter of waiting a few months for devs to start playing. I'm sure there is an arm optimised version of tremor about that should give a head start.
 
Last edited by a moderator:
I know little, but MIDI files operate by poking around in your computer and sort of calculating which sound to play out from an established library or according to an algorithm or something - that is, while they're tiny little files themselves, they require the processing computer to make up for that tininess by handline the actual sound itself.

MIDI files have no sound; they just have instructions for some intermediary. Example:

MIDI: Hey, buddy, give me a Violin in E for about two seconds.
Music Software: OK, done. Let me just pull up that file... ahah! There it goes.

Now, note that "violin in E" is defined by the software or whatever is processing the MIDI. Which means it could actually sound like a mouth organ. Or nails on a chalkboard.

Then again, recall that with this system we don't really need a halfway decent wavetable instrument set.
 
Software MIDI requires a wavetable set.

A wavetable set is a file containing samples of instruments; the one that comes with Windows (used by Microsoft GM software synthesis) is about 5mb.

Also, MP3 in games is *plausible* on the GP32 using a fixed-point MP3 decoder, however nobody has tried this.
 
I believe what may be confusing some people about MIDI is the difference between the wavetable set (which is stored once, either somewhere in your system folder or on your sound card if you have a higher-end one) and the MIDI file that contains the instructions Prothall is referring to. The files you download when you download a MIDI song are the handful of bytes that contain those playing instructions. Sheet music, if you will. The wavetable is generally already installed on your computer with your sound drivers and not re-downloaded with each MIDI. (This is why MIDIs can remain so small in size.) The downside to this is that since different setups may have different wavetables (or even players that don't use wavetables at all!) a MIDI will sound different on different computers. (The fact that Windows now ships with a software wavetable synthesizer and standardized wavetable does do a lot to help standardize this, though. But some people, me for instance, still prefer the sound of their sound card's synthesis and switch over to it whenever possible.)

And to answer the original question about MIDI, I'm not sure if mixing MIDI or decoding streaming audio would take more processing. It probably depends on the method of mixing MIDI that you choose. A simple FM-synth could run easily, a simple wavetable a little more complexly, and a high-quality wavetable with an even greater drain on power. For games, though, if you're going to eschew streaming music (MP3s, OGGs) for music made up of instructions on what to play when, you might as well use a MOD-type file so you can control the instrument sounds that are used yourself. And if you're just going to play the MIDI files to listen to them, then I'm quite certain the GP2X is up to the task of playing them quite nicely when all its resources are devoted to it.
 
OH, I get it now.

The wavetable is the instruments, and the midi file is the sheet music.
I understood the whole midi sheet music thing, but I never thought of the what space the wavetable is taking up. Wouldn't there be a wavetable built into the mplayer on the gp2x?
 
Back
Top