-
Notifications
You must be signed in to change notification settings - Fork 0
/
RLAudioManager.h
127 lines (102 loc) · 3.53 KB
/
RLAudioManager.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#pragma once
//STL includes
#include <list>
#include <map>
#include <string>
//OpenAL includes
//#include <al\al.h>
#include "AL\al.h"
//#include <al\alc.h>
#include "AL\alc.h"
//#include <al\alu.h>
#include "AL\alu.h"
//#include <al\alut.h>
#include "AL\alut.h"
//Local includes
#include "RLAudioUtilities.h"
#include "RLAudioData.h"
#include "RLAudioTypes.h"
namespace RustyLib
{
namespace Audio
{
//Primary Class for managing audio and hiding API
class RLAudioManager
{
private:
//Static instance of CAudioManager
static RLAudioManager _instance;
//Associative array of AudioData
std::map<std::string,RLAudioData*> loadedAudioMap;
//Audio config file path
const static std::string CONFIG_FILE;
//Audio Catalogue File Path (read from CONFIG_FILE)
std::string audioCataloguePath;
//Pointer to the current background track
RLTrack* pCurrentTrack;
//List of audio that has been "fired and forgotten"
std::list<RLAudio*> forgottenAudioList;
//List of ambient effects currently in play
std::list<RLAmbience*> ambienceList;
//Master volume
float masterVolume;
/*******Open AL Specific Data***********/
ALCdevice *pALCdevice;
ALCcontext *pALCcontext;
//Listener Properties
float ListenerPosition[3];
float ListenerOrientation[6];
//Play Sound Effect Methods
//Will add audio to internal monitoring list
void FireAndForget(const std::string& name);
//Will return a reference for another object to track
RLSoundEffect* FireAndReturn(const std::string& name);
//OpenAL Initialisation Method
void InitialiseOpenAL(void );
//OpenAL De-Initialisation Method
void DestroyOpenAL(void );
/********PRIVATE INITIALISATION METHODS*******/
//Load config data specified in the CONFIG_FILE
void LoadConfigData(void );
//Load audio data as specified in catalogue file
void LoadAudioData(void );
//Explicitly disallow the copy constructor and equals assignment
RLAudioManager(const RLAudioManager&);
RLAudioManager& operator=(const RLAudioManager&);
public:
RLAudioManager(void);
~RLAudioManager(void);
//Singleton Access Method
static RLAudioManager& Instance(void );
/*******Initialisation Method(s)********/
//Will prepare and intialise OpenAL and load all required data
void Initialise(void );
/********Methods for creating sources********/
const unsigned int GetBufferID(const std::string& name)const;
/********Methods for getting buffer duration********/
const float GetBufferDuration(const std::string& name)const;
/******Background music methods**********/
//Changes current looped track to name
void PlayBackgroundMusic(const std::string& name);
//Continues play of current looped track
void PlayBackgroundMusic(void );
//Pauses play of current looped track
void PauseBackgroundMusic(void );
//Stops current looped track from playing
void StopBackgroundMusic(void );
//Rewinds current looped track
void RewindBackgroundMusic(void );
/*******Sound Effect Methods*********/
//Plays a sound effect, will return reference if capture = true
RLSoundEffect* PlaySoundEffect(const std::string& name, const bool capturing = false);
/*********Ambience Methods***********/
//Will and an ambient effect to be processed
void AddToAmbience(const std::string& name);
//Will remove all ambient effects currently playing
void ClearAmbience(void );
/*********Update Method***********/
//Core update method (allows tracking of ambient and forgotten sounds)
void Update(float timeStep);
};
}
}