Game Development Community

Problem playing clipped mp3 file

by Prashant K Singh · in iTorque 2D · 08/24/2009 (6:37 am) · 3 replies

I am using a .mp3 file as the background score to my game. mp3 format introduces a 0.5 sec (approx) dead region at the start and end of the file. This causes the sound to break when played in a loop. I have the exact markers in terms of time that tell me the start and end of the valid sound within the file. Is there a way that I can play the file clipped within this time. I am using startiPhoneAudioStream() function.

Please let me know if there is a way to do this, even if it means modifying the engine code.

Thanks

#1
08/24/2009 (8:24 am)
The 0.x startup time is the time required to even prepare file for playback. There is nothing that can be done about it, it holds for all compressed sounds on the iphone that are hardware decoded inclusive the official ipod player.

the only way to partially get around it is not using hardware decompression at all but thats no option as iTGB is already overheavy on cpu usage, you don't have any left to waste it for mp3 / aac decompression
#2
08/25/2009 (5:40 am)
Marc, I had a look at the engine code, BackgroundTrackMgr specifically. It seems to me that the data is being loaded onto a buffer which is then used to playback the audio. Couldn't we force this buffer to load only certain amount of data and not the whole file. I know this is a very abstract thought, but I just wanted to check if there is a possibility of doing such a thing, and more importantly, how.
#3
08/25/2009 (6:33 am)
You could try it, as we have the sources, there is nothing to prevent you from trying it :)
I would consult the Apple iPhone SDK documentation on the sound systems to find out about ways to optimize it.