 |
 |
|
 |
02-01-2010, 07:35 AM
|
#1 (permalink)
|
|
Registered Member
Join Date: Aug 2008
Posts: 27
|
MP3 playback causing poor performance.
Hi all,
I have a game which is running using a timer quite happily at 30fps. I have just tried adding playback of a local ambient MP3 track, but the performance of my game takes quite a hit, and becomes noticeably slower.
My question is, how *should* I be going about playing back an MP3?
Cheers,
D.
|
|
|
02-01-2010, 11:15 AM
|
#2 (permalink)
|
|
Registered Member
Join Date: Jan 2010
Posts: 4
|
For all I know the iPhone only has hardware support to play one compressed-audio-file at a time. (i.e. mp3)
I use an AVAudioplayer to play mp3 music only when the iPod is currently not playing any other music. So for me, using AVAudioPlayer means no performance difference, as long as one makes sure only one mp3 is currently playing. Starting a second AVAudioPlayer means the second song gets decoded by the software, which is computation-intensive. (Remember the users iPod App may be playing in the background when your app is started).
For Effects I use "AudioServicesPlaySystemSound" which doesn't interfere with performance either, but the effects then need to be uncompressed and less then 5 secs. A nice file format for uncompressed audio files seems to be "caf" which can be made from a wav but is considerably smaller even without compression.
|
|
|
02-01-2010, 02:59 PM
|
#3 (permalink)
|
|
Registered Member
Join Date: Nov 2009
Location: Beaverton, OR
Posts: 118
|
Quote:
Originally Posted by Duncster2k4
Hi all,
I have a game which is running using a timer quite happily at 30fps. I have just tried adding playback of a local ambient MP3 track, but the performance of my game takes quite a hit, and becomes noticeably slower.
My question is, how *should* I be going about playing back an MP3?
Cheers,
D.
|
Make sure your audio session is set up to Ambient Solo and that your only playing one track, this will utilize the hardware. Still though even with hardware use MP3 playback takes quite a bit of utilization. We've noticed playback generally causes a 5-8fps drop, so it really depends on how much headroom you have above 30fps. For instance if your game could run at 40-50fps but you have it capped at 30fps you probably won't see a problem. On the other hand if your barely making 30fps, your going to be dipping down into mid and low 20's most likely.
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 391 |
| 29 members and 362 guests |
| AdamSubach, aderrington, airsoft808, benoitr007, bensj, Danneman, dev123, Duncan C, ErichGS, gtyt38, gustavo7sexton, HemiMG, Jeremy1026, lifeCoder45, mriphoneman, Ovidius, Paul10, Piequanna, pofak, qilin, Racker, raheel, Sega dude, squidboy, timle8n1, ZunePod |
| Most users ever online was 965, 06-30-2010 at 04:26 AM. |
» Stats |
Members: 41,860
Threads: 49,768
Posts: 213,054
Top Poster: BrianSlick (3,138)
|
| Welcome to our newest member, gustavo7sexton |
|