Symbian Sound Mixer implementation
Purpose & scope
The other day I had to implement a sound mixer for a game of mine and I spent quite a lot of time trying to find out what kind of audio file format I was suppose to feed the mixer with. So I thought I may as well share my experience here if only as a reference for myself the next time I have to play with audio files on Symbian OS. On this page I provide practical information about
file format manipulation, playing and mixing sounds on Symbian OS.
I based the initial implementation of my mixer on the S60 Platform: Sound Mixer Example v2.0
from Nokia forum. First thing you can do I guess is download it, compile it, run it and debug it. That got me started pretty fast.
Now that example is pretty impressive I have to say, good job Nokia people
However it took me a while to get it to play my own
files and figure out exactly what kind of audio file format you have to provide.
Audio File Format
The Nokia example mentioned above comes with three
files without header. Those header-less files are also called
audio file. Their format can be describe as:
- Format: PCM Uncompressed
- Attributes: 16000Hz, 8 Bits, Mono
A side effect of the header-less
file is that you won't be able to play it on your average desktop media player. I find it rather unpractical.
The Symbian API used to play the sound is
. Now my understanding is that one can feed that function with 8 Bits PCM Uncompressed data of various channels (mono or stereo) and sample rates (in Hz). However in our example the channel is hard coded to Mono and the sample rate to 16000Hz. In fact since the
files we are talking about were stripped off their header the application can't determined those value so it has to be hard coded somehow.
It took me some times to figure out the expected format for those
files. Then I was able to convert my own audio files from whatever other
format to the correct one using the free version of Switch
. However you will still obtain a
file with header. To remove the header you can always use SOX
by running a command like
sox inputSound.wav outputSound.raw
. Note the
extension for the output file which is actually telling SOX to remove the header. Then your file should be ready to be played by the Nokia example has is.
However I find it easier to modify the
loader in the mixer to leave out the 44 Bits of the
header rather than expecting
files. It's also more convenient to be able to play your sound files on your desktop or use the exact same sound file for running your application on other platform. It's much easier if like me you are writing portable OpenGL
Export using Audacity
I used Audacity 1.3.6 (beta).
- Open your
wav file in Audacity.
- Set the rate on the sound sample.
- Set the project rate using the combobox from bottom left corner.
- Do file -> export.
- Choose 'Other uncompressed file' from the 'Save as type' combobox.
- Click on 'Options'.
- Choose 'WAV (Microsoft)' from the 'Header' combobox.
- Choose 'Unsigned 8 bit PCM' from the 'Encoding' combobox.
- Click 'Ok' and 'Save'.
- You are done.