Getting sound out of a Symbian app is difficult in the best of times – if you add an extra abstraction layer (hello, Qt), the situation (obviously) does not improve. Nevertheless, sound is needed especially for games – and I think that I have a well-working way to get it done.
Once again: this is for Symbian ONLY! It will not work on Maemo, etc
Step 1 – create the files
Our friends at Nokia’s have offered a nice sound engine in their Sound Mixer example. Adapting it to Qt for Symbian is not difficult – just create a folder s60sound, and extract the files found in the archive below into the folder:
Step 2 – store the WAV files
Next up, create a /rsc folder in the project home, and store the wav files here. I have found out that long wav files (longer than 20secs) or very large WAV files (more than 300kb) cause problems – this might have something to do with stack sizes, and has been discussed on Forum Nokia.
Step 3 – update the pro file
Next up is the pro file. First of all, add the headers and cpp files to the relevant sections. Then, add the libraries and the wav files above by editing the Symbian segment of the .pro file as to look like this:
TARGET.UID3 = YOUR UID HERE
LIBS += -lcone
myFiles.sources = rsc*.wav
DEPLOYMENT += myFiles
Step 4 – update the ConstructL of the wrapper
Next, look into the SoundMixerContainer. You will see how I load four samples there – abstract from it.
Step 5 – update sound routines
Then, look at the sound routines I use to play the nion-background music SFX. Create your own – the integer which always changes is the channel.
Step 6 – use
Not much to add here…
P.S. I would love to provide you with sampole WAV files here, but cannot due to copyright reasons!