Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

What are the best practices for playing sounds in iPhone games? Specifically, what are the best practices while playing sounds simultaneously without affecting other processing much. Is there any recommendation about how sound files must be made to suit the processing?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

From Technical Note TN2199, relative to the use of OpenAL

  • Use the alBufferDataStatic API, found in the oalStaticBufferExtension.h header file, instead of the standard alBufferData function. This eliminates extra buffer copies by allowing your application to own the audio data memory used by the buffer objects.

  • If your application renders several audio buffers simultaneously, you should typically use a lower sample rate, such as 22kHz. When rendering a single source, a 44.1kHz sample rate may be most efficient. Experiment and analyze the performance of your application. Individual circumstances determine the best tradeoff between sample rate and the number of audio sources being rendered.

A link with general audio tips for iPhone.

And my personal opinion:

  • Preload the sounds into memory ( load screens is the better place for this ).
  • Use formats with high compression to take less memory. Like .ogg.
  • To the musics, try to load them via streaming, because them can occupy a lot of memory.
  • The spacial sounds ( sounds with a position ) needs to be mono, if the game needs them, it's a memory saving.
  • Put a sample limit, more than 5 or six sounds at same time can be confusing and they don't contribute.
  • If your game is developed in c++, you can use a library like cAudio or make yourself a OpenAL wrapper, these approach has the benefit that you only has the functionality that you needs.

  • Rule of thumb: don't allocate/deallocate memory into gameplay. This is applicable to sounds and the other resources like images.

share|improve this answer
    
Great Answer. Thanks You. –  Vijayendra Tripathi Jul 4 '11 at 18:34

there is a game engine named cocos2D, and it contains an audio engine named cocosdenshion. it's a three layer object oriented sound engine. you can easily select a layer and starting working with that. and it's all based on openAL, you can surly get enough ideas from cocosdension even if you don't want to use it directly. and it's under MIT License so you can use that without any worry.

share|improve this answer
    
may I ask why a downvote?? –  Ali.S Jul 3 '11 at 22:09
    
Thanks for the suggestion. Did you ask me about downvote?? I am new to stackexchange. Sorry, I might have accidentally pressed some wrong link. Let me know if thats my mistake and how can revert it. –  Vijayendra Tripathi Jul 4 '11 at 18:40
    
I don't know if it was yours or if it was someone else who did this. (at least I don't know how can i find out) –  Ali.S Jul 4 '11 at 19:08
    
lol.. u guys are funny. I up voted u to make things even :) –  Free Lancer Apr 19 '12 at 3:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.