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
-
backgroundMusicVolumeBackground music volume. Range is 0.0f to 1.0f. This will only have an effect if willPlayBackgroundMusic returns YES
property -
effectsVolumeEffects volume. Range is 0.0f to 1.0f
property -
willPlayBackgroundMusicIf 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 -
+ sharedEnginereturns 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
-
– stopBackgroundMusicstops playing background music
-
– pauseBackgroundMusicpauses the background music
-
– resumeBackgroundMusicresume background music that has been paused
-
– rewindBackgroundMusicrewind the background music
-
– isBackgroundMusicPlayingreturns 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.
-
+ endShuts 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 backgroundMusicVolumeDeclared In
SimpleAudioEngine.hClass Methods
Instance Methods
isBackgroundMusicPlaying
returns whether or not the background music is playing
- (BOOL)isBackgroundMusicPlayingDeclared In
SimpleAudioEngine.hpauseBackgroundMusic
pauses the background music
- (void)pauseBackgroundMusicDeclared In
SimpleAudioEngine.hplayBackgroundMusic:
plays background music in a loop
- (void)playBackgroundMusic:(NSString *)filePathDeclared In
SimpleAudioEngine.hplayBackgroundMusic:loop:
plays background music, if loop is true the music will repeat otherwise it will be played once
- (void)playBackgroundMusic:(NSString *)filePath loop:(BOOL)loopDeclared In
SimpleAudioEngine.hplayEffect:
plays an audio effect with a file path
- (ALuint)playEffect:(NSString *)filePathDeclared In
SimpleAudioEngine.hplayEffect: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)gainDeclared In
SimpleAudioEngine.hpreloadBackgroundMusic:
Preloads a music file so it will be ready to play as background music
- (void)preloadBackgroundMusic:(NSString *)filePathDeclared In
SimpleAudioEngine.hpreloadEffect:
preloads an audio effect
- (void)preloadEffect:(NSString *)filePathDeclared In
SimpleAudioEngine.hresumeBackgroundMusic
resume background music that has been paused
- (void)resumeBackgroundMusicDeclared In
SimpleAudioEngine.hrewindBackgroundMusic
rewind the background music
- (void)rewindBackgroundMusicDeclared In
SimpleAudioEngine.hsoundSourceForFile:
Gets a CDSoundSource object set up to play the specified file.
- (CDSoundSource *)soundSourceForFile:(NSString *)filePathDeclared In
SimpleAudioEngine.hstopBackgroundMusic
stops playing background music
- (void)stopBackgroundMusicDeclared In
SimpleAudioEngine.h