Welcome! I am an indie iOS Developer, Web Developer, and all around code monkey! Please feel free to take a look around and if you have any questions you can contact me using this form

Sound Manager v1.1 Documentation

Sound Manager v1.1 Documentation

© 2013 Brandon Lassiter



This library requires SimpleAudioEngine to be included in your project


Sound Manager is an extension to SimpleAudioEngine that increases functionality and allows full game/app synchronization of sound properties. Sound Manager returns a Singleton. This library is FREE to use for both personal and commercial use if the following is adhered to:


1. Credit to Brandon Lassiter is placed somewhere within the game/app.

2. Source code is left in tact.

3. Once the app/game is approved an email is sent to brandon@brandonlassiter.com informing me that you used it! I will then place information regarding your game/app on the Sound Manager website to showcase its use.


If you would like to use this library without the previous restrictions you can send a donation of $5 USD via one of the donation buttons located at http://www.brandonlassiter.com, however, it would still be nice if you followed number 3 (but is not required).


Changes in version 1.1


1. Added pauseBGMusic.

2. Added resumeBGMusic.

3. Fixed bug for background music looping.

4. Added preloadSoundtrack.

5. Added playSoundtrack.

6. Added stopSoundtrack.



Starting the Sound Manager


To utilize the Sound Manager you need to include it in your project. In Xcode click File->Add Files to “Project Name” and find both SoundManager.h, SoundManager.m, SimpleAudioEngine.h, and SimpleAudioEngine.m. Make sure that the “Copy items to destination group’s folder (if needed)” is Checked.


Once the files have been added to your project you need to include them in your source code. I recommend doing this inside prefix.pch so that it is incorporated in the rest of your project and there is no need to add it multiple times. Import the header files using the following code:


#import “SoundManager.h”


Starting the Sound Manager


- (void)startEngine;


Sample Code

[[SoundManagersharedSoundManager] startEngine];


This will start the sound manager and set the default background music and sound effect volumes. The values for backGroundVolume and effectsVolume are float values and can range from 0.0 to 1.0;


When the Sound Manager is started it uses the default values set for the user. If it is the first time this has ever been used it will automatically set both volume levels to 1.0. These values will be used throughout the use of Sound Manager. I.E. when toggleMute is called it will return the music and sound effect volumes back to whatever is set as the default value. You can change the default values by using:


- (void)changeDefaultVolumes:(bool)change backGroundVolume:(float)bgVolume effectsVolume:(float)effectVolume changeNow:(bool)adjust;


changeDefaultVolumes:(bool)change – Should be set to YES

backGroundVolume:(float)bgVolume – Float Value ranging from 1.0 to 0.0. Sets the Default Music Volume

effectsVolume:(float)effectVolume – Float Value ranging from 1.0 to 0.0. Sets the Default Sound Effect Volume

changeNow:(bool)adjust – YES or NO. If set to YES it ail change the current volume to the new values.


Sample Code:

[[SoundManagersharedSoundManager] changeDefaultVolumes:YES backGroundVolume:0.2 effectsVolume:0.5 changeNow:YES];


Preload Background Music


- (void)preloadBGMusic:(NSString *)bgMusic;


preloadBGMusic:(NSString *)bgMusic – String Value. The name of the audio file to preload.


Sample Code

[[SoundManagersharedSoundManager] preloadBGMusic:@”Music.mp3″];


Preload Sound Effect


- (void)preloadAudioEffect:(NSString *)effect;


preloadAudioEffect:(NSString *)effect – String Value. The name of the audio file to preload.


Sample Code

[[SoundManagersharedSoundManager] preloadAudioEffect:@”Effect.mp3″];


Play Background Music


- (void)startBackgroundMusic:(NSString *)music loop:(BOOL)loopValue;


This will start background music with the option to loop the audio.


startBackgroundMusic:(NSString *)music – String Value. The name of the audio file to play.

loop:(BOOL)loopValue – YES or NO. If set to YES the music will loop indefinitely.


Sample Code

// Starts Background Music and Loops

[[SoundManagersharedSoundManager] startBackgroundMusic:@”Music.mp3″ loop:YES];


// Starts Background Music and only plays once

[[SoundManagersharedSoundManager] startBackgroundMusic:@”Music.mp3″ loop:NO];


Stop Background Music


- (void)stopBackgroundMusic;


Sample Code

[[SoundManagersharedSoundManager] stopBackgroundMusic];


Play Sound Effect


- (void)playSoundEffect:(NSString *)effect;


playSoundEffect:(NSString *)effect – String Value. The name of the audio file to play.


Sample Code

[[SoundManagersharedSoundManager] playSoundEffect:@”Effect.mp3″];


Toggle Mute


- (void)toggleMute:(bool)mute fade:(bool)fadeYesNo fadeTime:(float)time;


This allows you to either mute or un-mute the music and sound effects. You can choose to either have it all turn off or back on at one time, or gradually fade in or out depending on the state of the volume.


toggleMute:(bool)mute – Should be set to YES in order to mute/un-mute volume.

fade:(bool)fadeYesNo – Do you want the music to fade in or out? YES or NO

fadeTime:(float)time – How long should the fade in/out be (in seconds)? Set this to 0if fade is set to NO.


toggleMute uses the default volume levels when it fades back in.


Sample Code

// Mute or Un-Mute, Fade in or out with a fade time of 1.5 seconds.

[[SoundManagersharedSoundManager] toggleMute:YES fade:YES fadeTime:1.5];


// Mute or Un-Mute, No Fade.

[[SoundManagersharedSoundManager] toggleMute:YES fade:NO fadeTime:0];


Fade Out Music


- (void)fadeOutMusic:(float)time endVolume:(float)endVol;


This will fade out the music to a specified value.


fadeOutMusic:(float)time – Time (in seconds) that it will take to fade to the specified level.

endVolume:(float)endVol – Volume level at the end of fade (float value between 0.0 and 1.0)


Sample Code

// Fade out music from current volume level to 0.1 with a 1.5 second fade duration.

[[SoundManagersharedSoundManager] fadeOutMusic:1.5 endVolume:0.1];


Fade In Music


- (void)fadeInMusic:(float)time volume:(float)newVol;


This will fade in the music to a specified value.


fadeInMusic:(float)time – Time (in seconds) that it will take to fade to the specified level.

volume:(float)newVol – Volume level at the end of fade (float value between 0.0 and 1.0)


Sample Code

//Fade music in to a level of 0.8 with a 1.5 second fade time

[[SoundManagersharedSoundManager] fadeInMusic:1.5 volume:0.8];


Pause Background Music


- (void)pauseBGMusic;


Pauses the Background Music.


Sample Code

[[SoundManagersharedSoundManager] pauseBGMusic];


Resume Background Music


- (void)resumeBGMusic;


Resumes the Background Music


Sample Code

[[SoundManagersharedSoundManager] resumeBGMusic];


Preload Soundtrack


- (void)preloadSoundtrack:(NSArray *)tracks;


preloadSoundtrack:(NSArray *)tracks – Sends an NSArray containing the string values of the songs to preload.


Preloads all of the music files contained in your soundtrack.


Sample Code

// start is just a blank string to take up an index spot. Do not place an audio file string there

NSString *start = @”Starting String”;

NSString *song1 = @”Song1.mp3″;

NSString *song2 = @”Song2.mp3″;

NSString *song3 = @”Song3.mp3″;

NSString *song4 = @”Song4.mp3″;

NSString *song5 = @”Song5.mp3″;


NSArray *songs = [NSArrayarrayWithObjects:start, song1, song2, song3, song4, song5, nil];


[[SoundManagersharedSoundManager] preloadSoundtrack:songs];


Playing the soundtrack


- (void)playSoundTrack:(NSArray *)tracks;


Plays the preloaded sound track array you preloaded. Note you must preload the soundtrack you want to play prior to calling playSoundTrack


Sample Code

[[SoundManagersharedSoundManager] playSoundTrack];


Stopping the soundtrack


-(void) stopSoundTrack:(BOOL)stopNow;


Stops the soundtrack from playing.


stopSoundTrack:(BOOL)stopNow – If set to YES audio will stop immediately. If set to NO it will stop playing at the end of the current song.


Sample Code

// Stops after current song

[[SoundManagersharedSoundManager] stopSoundTrack:NO];


// Stops now

[[SoundManagersharedSoundManager] stopSoundTrack:YES];

© 2012 Brandon Lassiter