I've just started messing with CocosDenshion, but I can't get the SimpleAudioEngine to play effects.
[SimpleAudioEngine sharedEngine].muted = NO; [SimpleAudioEngine sharedEngine].effectsVolume = 1.0; ALuint soundId = [[SimpleAudioEngine sharedEngine] playEffect:@"Fanfare.wav"]; NSLog(@"Played effect id %d", soundId); //[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@"Fanfare.wav"];
This is a fresh cocos2d 0.82 project, and I've pasted the above to the bottom of the HelloWorld init method.
Here is the debug output:
2009-12-08 13:26:22.665 SoundTest[33551:20b] cocos2d: cocos2d v0.8.2 2009-12-08 13:26:22.675 SoundTest[33551:20b] cocos2d: Using Director Type:TimerDirector 2009-12-08 13:26:23.114 SoundTest[33551:20b] Denshion: Checking for other audio 2009-12-08 13:26:23.117 SoundTest[33551:20b] Denshion: Other audio is not playing audio will be exclusive 2009-12-08 13:26:23.118 SoundTest[33551:20b] Denshion: channel def 0 0 30 0 2009-12-08 13:26:23.267 SoundTest[33551:20b] Denshion: Loading openAL buffer 0 Fanfare.wav 2009-12-08 13:26:23.271 SoundTest[33551:20b] Denshion: size 506384 frequency 44100 format 4355 79249408 2009-12-08 13:26:23.276 SoundTest[33551:20b] Played effect id 2432
The problem is, no sound was output at all. If I uncomment the line that calls playBackgroundMusic, it plays it (and loops). I've tried short sound effects (less than 1 second) and a 15 second clip to no effect. Is there some special setup needed to play effects?