-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAudioManager.h
70 lines (64 loc) · 3.09 KB
/
AudioManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//--------------------------------------------------------------//
// AudioManager.h //
// Singleton //
// Plays WAV files //
// Can play one BGM at a time, and many sound effects at once //
// //
// By: Ather Omar //
//--------------------------------------------------------------//
#ifndef _AUDIOMANAGER_H
#define _AUDIOMANAGER_H
//-----------------------------------------------------------
#include "AssetManager.h"
//-----------------------------------------------------------
// QuickSDL
//-----------------------------------------------------------
namespace QuickSDL {
//-------------------------------------------------------
// AudioManager
//-------------------------------------------------------
class AudioManager {
private:
//Needed to make AudioManager a singleton class
static AudioManager* sInstance;
//Used to load audio files
AssetManager* mAssetMgr;
public:
//-----------------------------------------
//Returns a pointer to the class instance
//-----------------------------------------
static AudioManager* Instance();
//-----------------------------------------------------
//Releases the class instance and sets it back to NULL
//-----------------------------------------------------
static void Release();
//----------------------------------------------------------------------------------------------
//Sets the BGM to play using the provided file, loops = -1 is infinite looping (default: -1)
//-----------------------------------------------------------------------------------------------
void PlayMusic(std::string filename, int loops = -1);
//-------------------------------------------------------
//Pauses the currently playing BGM if there is any
//-------------------------------------------------------
void PauseMusic();
//-------------------------
//Resumes paused BGM
//-------------------------
void ResumeMusic();
//--------------------------------------------------
//Plays a sound effect from the file provided
//plays if for the given loops (default: 0)
//on the given channel (default: 0)
//--------------------------------------------------
void PlaySFX(std::string filename, int loops = 0, int channel = 0);
private:
//------------------------------------------------------------------------------------------
//Contructor is private so that Instance() must be used to get an instance when needed
//------------------------------------------------------------------------------------------
AudioManager();
//-------------------------------------------------------------------------------------
//Destructor is private so that the instance can only be destroyed using Release()
//-------------------------------------------------------------------------------------
~AudioManager();
};
}
#endif