Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Most convenient way to play sound in iOS games?

Tags:

ios

iphone

audio

I'm making a game and would like to have a background loop of game music and on top of it have two different channels of sound effects. I would like to control the volume of these channels. I looked at fmod, but it was out of my budget. Now instead I'm looking at the MixerHostAudio example provided by Apple. It's a clear example, but a bit long-winded being 1000+ lines just for playing two sounds, so I'm wondering if I should be doing something else instead.

My ideal API would look something like this:

SoundSystem *sounds = [SoundSystem soundSystemWithLoop:@"koto.mp3"]; 
[sounds play:@"chimes.mp3" channel:1 looping:YES volume:0.0];
[sounds fadeTo:1.0 channel:1 delay:0.5];
[sounds play:@"buddha_bell.mp3" channel:2];
like image 690
Bemmu Avatar asked Nov 28 '10 08:11

Bemmu


2 Answers

You can use AVAudioPlayer for the background loop and Finch for SFX. Both are easy to work with. You’d have to write the channel volume control above Finch yourself, but that’s not hard either, being just an array of sounds with a common volume control.

like image 192
zoul Avatar answered Oct 01 '22 09:10

zoul


CocosDenshion Sound Engine does everything you want.

It is trivial to use once you get it in your project.

CocosDenshion is the sound part of Cocos2D.

I just personally do not care for Cocos2D (although, of course, many people love it and use it).

However CocosDenshion for sound does everything you want with no problems. Yes it does both BG loops and SFX. It manages all memory, etc.

It is easy to use CocosDenshion (just copy a few files to your project) -- no problem. (You do not have to fool with the whole Cocos2D situation...you install simply only the Denshion section.)

Hope it helps!

like image 33
Fattie Avatar answered Oct 01 '22 09:10

Fattie