Playing game sound effects and background music simultaneously

Playing game sound effects and background music simultaneously

DEllel's picture
I'm trying to finish off a game for Meego (mobile), but i've been having loads of problems trying to get multiple sounds to play together. I tried using QMediaPlayer with an ogg bgm and wav sfx but this often broke the sound playing (on Netbook and n900) depending on the number of sfx triggered at the same time. I also tried using the sample QuickHit's QAudioOuput mixing code, but that also seems to break. What are other people using to play multiple sounds and background music?
9 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
vyau's picture

Hi DEllel:

When you said it is broken, do you mean the sound/music is choppy when you tried to play them?

--vincent

DEllel's picture

With QMediaPlayer playing some sfx would silence the music track.

vyau's picture

Can you tell me the version of Qt and QtMobility that you are using?
thanks

--vincent

DEllel's picture

MeeGo 1.1.2 SDK Update

QtCreator 2.0.1
Qt 4.7.0
Qt Mobility 1.0

Targets installed:
meego-core-armv7l-1.1.2
meego-netbook-ia32-1.1.2

vyau's picture

Let me look into it and get back to you.

DEllel's picture

I decided to use QAudioOutput and rework the QuickHit example code. However i'm getting a half second delay between a sample being triggered and it starting to play. This is related to the size of QAudioOutput's audio buffer, and the smallest value that QAudioOutput::bytesFree() will return. Whether i'm using 22khz mono or 44khz stereo, the size of the audio buffer that QAudioOutput actually uses (it ignores the requested size) conspires to introduce that half second delay. I can't see how to reduce it. Has anyone encountered the same problem?
Thanks

vyau's picture

Can you point me to the QuickHit example code if it is available for general download?
thanks

DEllel's picture

https://projects.forum.nokia.com/quickhit

It appears that in the N900 implementation of QAudioOutput the system doesn't start playing the contents of the audio buffer until it is completely filled, thus introducing a delay in playing the size of the audio buffer, which you can't reduce because the system ignores the buffer size request and always allocates itself enough for about 0.5 seconds.

The QuickHit sample's ga_src sound engine didn't work when i put it into my game so i wrote my own mixing roughly based on it. But the principle is the same, feeding raw data to the audio buffer. And if the audio buffer doesn't start playing until it's filled (0.5 seconds of it) you have my problem.

Thanks

Login to leave a comment.