2
\$\begingroup\$

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?

\$\endgroup\$
6
\$\begingroup\$

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.

\$\endgroup\$
1
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ may I ask why a downvote?? \$\endgroup\$ – Ali1S232 Jul 3 '11 at 22:09
  • \$\begingroup\$ 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. \$\endgroup\$ – Vijayendra Jul 4 '11 at 18:40
  • \$\begingroup\$ 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) \$\endgroup\$ – Ali1S232 Jul 4 '11 at 19:08
  • \$\begingroup\$ lol.. u guys are funny. I up voted u to make things even :) \$\endgroup\$ – Free Lancer Apr 19 '12 at 3:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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