Rana
Rana

Reputation: 247

How can i use more them one sound simultainiously in iphone application using cocos2d?

Duplicate:

use more then one sound in my iphone application using cocos2d

Hi, All of the member of this forums.I need to help yours for doing my game project.I want to play some sound in my gaming project.When this game is started a background sound is playing continuously until the game is stop (exit). When game is played that time some action button are work and every action one sound is play for few second but background sound did not stop that time. How can i do this if anyone have a solution than reply with answer please.

Upvotes: 0

Views: 1161

Answers (3)

Matt Williamson
Matt Williamson

Reputation: 40193

If you are using cocos2d 0.82, then you can use denshion for this.

Play background music: [[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"somemusic.mp3"];

Play SOUND EFFECT: [[SimpleAudioEngine sharedEngine] playEffect:@"mysound.wav"]

You can find this and more at http://www.cocos2d-iphone.org/wiki/doku.php/cocosdenshion:cookbook

Upvotes: 1

TWA
TWA

Reputation: 12816

Check out the AVAudioPlayer class. It will do what you need.

One thing to be aware of is that this class will only play one mp3 format sound at one time. I suggest converting to IMA4 format if you are using mp3 and need to play multiple sounds at once.

You can use the afconvert command to convert between sound file formats.

AVAudioPlayer is available in firmware 2.2+.

Upvotes: 0

John Leidegren
John Leidegren

Reputation: 60987

You could, if you implemented your own mixer. Just playback a buffer and mix the audio yourself. It' basically boils down to just averaging two different amplitudes. In some cases it's a bit more advanced.

Upvotes: 0

Related Questions