Inherits from NSObject
Conforms to CDAudioInterruptProtocol
Declared in SimpleAudioEngine.h

Overview

A wrapper to the CDAudioManager object. This is recommended for basic audio requirements. If you just want to play some sound fx and some background music and have no interest in learning the lower level workings then this is the interface to use.

Requirements: – Firmware: OS 2.2 or greater – Files: SimpleAudioEngine., CocosDenshion. – Frameworks: OpenAL, AudioToolbox, AVFoundation

Tasks

Properties

backgroundMusicVolume

Background music volume. Range is 0.0f to 1.0f. This will only have an effect if willPlayBackgroundMusic returns YES

@property (readwrite) float backgroundMusicVolume

Declared In

SimpleAudioEngine.h

effectsVolume

Effects volume. Range is 0.0f to 1.0f

@property (readwrite) float effectsVolume

Declared In

SimpleAudioEngine.h

willPlayBackgroundMusic

If NO it indicates background music will not be played either because no background music is loaded or the audio session does not permit it.

@property (readonly) BOOL willPlayBackgroundMusic

Declared In

SimpleAudioEngine.h

Class Methods

end

Shuts down the shared audio engine instance so that it can be reinitialised

+ (void)end

Declared In

SimpleAudioEngine.h

sharedEngine

returns the shared instance of the SimpleAudioEngine object

+ (SimpleAudioEngine *)sharedEngine

Declared In

SimpleAudioEngine.h

Instance Methods

isBackgroundMusicPlaying

returns whether or not the background music is playing

- (BOOL)isBackgroundMusicPlaying

Declared In

SimpleAudioEngine.h

pauseBackgroundMusic

pauses the background music

- (void)pauseBackgroundMusic

Declared In

SimpleAudioEngine.h

playBackgroundMusic:

plays background music in a loop

- (void)playBackgroundMusic:(NSString *)filePath

Declared In

SimpleAudioEngine.h

playBackgroundMusic:loop:

plays background music, if loop is true the music will repeat otherwise it will be played once

- (void)playBackgroundMusic:(NSString *)filePath loop:(BOOL)loop

Declared In

SimpleAudioEngine.h

playEffect:

plays an audio effect with a file path

- (ALuint)playEffect:(NSString *)filePath

Declared In

SimpleAudioEngine.h

playEffect:pitch:pan:gain:

plays an audio effect with a file path, pitch, pan and gain

- (ALuint)playEffect:(NSString *)filePath pitch:(Float32)pitch pan:(Float32)pan gain:(Float32)gain

Declared In

SimpleAudioEngine.h

preloadBackgroundMusic:

Preloads a music file so it will be ready to play as background music

- (void)preloadBackgroundMusic:(NSString *)filePath

Declared In

SimpleAudioEngine.h

preloadEffect:

preloads an audio effect

- (void)preloadEffect:(NSString *)filePath

Declared In

SimpleAudioEngine.h

resumeBackgroundMusic

resume background music that has been paused

- (void)resumeBackgroundMusic

Declared In

SimpleAudioEngine.h

rewindBackgroundMusic

rewind the background music

- (void)rewindBackgroundMusic

Declared In

SimpleAudioEngine.h

soundSourceForFile:

Gets a CDSoundSource object set up to play the specified file.

- (CDSoundSource *)soundSourceForFile:(NSString *)filePath

Declared In

SimpleAudioEngine.h

stopBackgroundMusic

stops playing background music

- (void)stopBackgroundMusic

Declared In

SimpleAudioEngine.h

stopEffect:

stop a sound that is playing, note you must pass in the soundId that is returned when you started playing the sound with playEffect

- (void)stopEffect:(ALuint)soundId

Declared In

SimpleAudioEngine.h

unloadEffect:

unloads an audio effect from memory

- (void)unloadEffect:(NSString *)filePath

Declared In

SimpleAudioEngine.h