SimpleAudioEngine Class Reference
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
-
backgroundMusicVolume
Background music volume. Range is 0.0f to 1.0f. This will only have an effect if willPlayBackgroundMusic returns YES
property -
effectsVolume
Effects volume. Range is 0.0f to 1.0f
property -
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 -
+ sharedEngine
returns the shared instance of the SimpleAudioEngine object
-
– preloadBackgroundMusic:
Preloads a music file so it will be ready to play as background music
-
– playBackgroundMusic:
plays background music in a loop
-
– playBackgroundMusic:loop:
plays background music, if loop is true the music will repeat otherwise it will be played once
-
– stopBackgroundMusic
stops playing background music
-
– pauseBackgroundMusic
pauses the background music
-
– resumeBackgroundMusic
resume background music that has been paused
-
– rewindBackgroundMusic
rewind the background music
-
– isBackgroundMusicPlaying
returns whether or not the background music is playing
-
– playEffect:
plays an audio effect with a file path
-
– 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
-
– playEffect:pitch:pan:gain:
plays an audio effect with a file path, pitch, pan and gain
-
– preloadEffect:
preloads an audio effect
-
– unloadEffect:
unloads an audio effect from memory
-
– soundSourceForFile:
Gets a CDSoundSource object set up to play the specified file.
-
+ end
Shuts down the shared audio engine instance so that it can be reinitialised
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
Class Methods
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