Advertise Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

sdkIQ for iPhone
($4.99)

Your First iPhone App
($1.99)

iPhone Code Generator
($9.99)

Dual Matches
($0.99)

Calcuccino Programmers' Calculator
($2.99)

SDKtoday
(free)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-01-2010, 07:35 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2008
Posts: 27
Default 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.
Duncster2k4 is offline   Reply With Quote
Old 02-01-2010, 11:15 AM   #2 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 4
Default

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.
Bersaelor is offline   Reply With Quote
Old 02-01-2010, 02:59 PM   #3 (permalink)
Registered Member
 
Centurion Games's Avatar
 
Join Date: Nov 2009
Location: Beaverton, OR
Posts: 118
Default

Quote:
Originally Posted by Duncster2k4 View Post
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.
__________________
Centurion Games|@centuriongames
Centurion Games is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


» Advertisements
» Stats
Members: 41,860
Threads: 49,768
Posts: 213,054
Top Poster: BrianSlick (3,138)
Welcome to our newest member, gustavo7sexton
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:57 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0