J2ME Mobile Game Audio
Feature phones still account for 75% of all the world's mobile phones. Even in 2014, these "dumbphones" actually outnumber iOS or Android devices worldwide. Java ME (J2ME) is the dominant "OS" in emerging markets such as Africa, India, SE Asia The Middle East and LATAM, but it hasn't been updated since 2004.
Building a high quality app aimed at J2ME is incredibly time consuming and frustrating work. There are still developers making J2ME mobile games and dealing with the crippling limitations. The entire audio file size budget for a typical dumbphone game ranges from 7 kilobytes to 30 kilobytes, depending on the handset.
Should this deter one from launching a neat J2ME game? Heck Naw! The limitations faced on such a project can actually serve as creative fuel. For inspiration, take a look at this list of the Java-based mobile games. There is an asthetic appeal to making something cool on ancient platforms such as J2ME. Game builds must be made to work on a dizzying array of handsets and graphics are often customized for several screen resolutions. For audio, the situation is even simpler: Either the device does not support sounds, it supports MIDI, or uses some proprietary audio technology.
Here are a few tips from Mr Lou for making game sounds work with J2ME:
In the beginning, phones could typically only handle 1 Player object at a time. As a result, you had to make the user select whether they wanted music or sound effects. Later, the, 2 simultaneous Player objects became possible, but only if they handled 2 different formats. You couldn't (and still can't) play two MIDI files at the same time. Most J2ME enabled phones nowadays also support playback of MP3 and WAV files. Even today there are only very few phones that supports more than 2 simultaneous Player objects.
A lot of phones also supports the brilliant Mobile eXtensible Music File Format (XMF/mXMF) - but only some of them does it correctly. XMF basically consists of a MIDI file + a sound-font. Meaning, it allows you to provide your own instruments for your MIDI file. For one thing this means that your music will (finally) sound the same on all devices. Another interesting use for this was to provide a sound-font containing multiple sound effects, and that way have something similar to the SoundPool you can have with Android.
I've done extensive testing with the XMF format, and sadly found that the XMF format is poorly supported. Only Symbian devices seems to support it well. Sony Ericsson feature phones are very buggy and limited when it comes to XMF playback (will only play XMF files containing a sound-font less than 30kb - and even then it sometimes just crashes). And other brands seems to not support it at all, so sadly I have to recommend that you avoid the format. As a musician I was rather annoyed by that, because it could really have given the J2ME platform some awesomeness regarding audio.
There's been experiments in the past regarding playback of MODules (MOD/XM/S3M/IT files). I won't go into details, but let's just say that it's not the way to go. Almost no phones can handle it.
On newer J2ME enabled phones you can get away with using MP3 for music nowadays. But it does take up memory of course. So in order to support as many devices as possible, the best practise is to use MIDI for music and AMR files for sound effects. You can e.g. create your music Player first, and then in a try/catch block load a sound effect. If it fails, it'll just be null. So you check if the sound effect object is null before starting playback.