#include <SoundEngine.h>
Definition at line 16 of file SoundEngine.h.
◆ SoundEngine()
| IncrementalEngine::SoundEngine::SoundEngine |
( |
| ) |
|
Definition at line 10 of file SoundEngine.cpp.
15 assert(
"SoundEngine failed during its inizialization. Sound turned off." &&
_soundOn);
◆ ~SoundEngine()
| IncrementalEngine::SoundEngine::~SoundEngine |
( |
| ) |
|
|
virtual |
◆ Clear()
| void IncrementalEngine::SoundEngine::Clear |
( |
| ) |
|
|
private |
Definition at line 242 of file SoundEngine.cpp.
244 std::vector<TInfoSource>::iterator itSource;
247 ALuint source = (*itSource).Source;
248 alDeleteSources(1, &source);
◆ CreateSource()
| int IncrementalEngine::SoundEngine::CreateSource |
( |
| ) |
|
◆ DeleteSource()
| bool IncrementalEngine::SoundEngine::DeleteSource |
( |
unsigned int |
source | ) |
|
◆ FinalizeAL()
| void IncrementalEngine::SoundEngine::FinalizeAL |
( |
| ) |
|
|
private |
Definition at line 230 of file SoundEngine.cpp.
234 ALCcontext* context = alcGetCurrentContext();
235 ALCdevice* device = alcGetContextsDevice(context);
237 alcMakeContextCurrent(NULL);
238 alcDestroyContext(context);
239 alcCloseDevice(device);
◆ GetALErrorString()
| std::string IncrementalEngine::SoundEngine::GetALErrorString |
( |
ALenum |
error | ) |
|
|
private |
Definition at line 289 of file SoundEngine.cpp.
294 return std::string(
"AL_NO_ERROR");
296 case AL_INVALID_NAME:
297 return std::string(
"AL_INVALID_NAME");
299 case AL_INVALID_ENUM:
300 return std::string(
"AL_INVALID_ENUM");
302 case AL_INVALID_VALUE:
303 return std::string(
"AL_INVALID_VALUE");
305 case AL_INVALID_OPERATION:
306 return std::string(
"AL_INVALID_OPERATION");
308 case AL_OUT_OF_MEMORY:
309 return std::string(
"AL_OUT_OF_MEMORY");
◆ GetGain()
| float IncrementalEngine::SoundEngine::GetGain |
( |
| ) |
|
◆ GetSource()
| unsigned int IncrementalEngine::SoundEngine::GetSource |
( |
bool |
reserved = false | ) |
|
|
private |
Definition at line 254 of file SoundEngine.cpp.
256 unsigned int result = 0;
260 for (
unsigned int i = 0; i <
_sources.size(); ++i)
264 alGetSourcei(
_sources[i].Source, AL_SOURCE_STATE, &state);
265 if (state != AL_PLAYING && state != AL_PAUSED)
274 alGenSources(1, &l_Info.Source);
275 if ((error = alGetError()) != AL_NO_ERROR)
281 l_Info.Reserved = reserved;
283 result = (
unsigned int)
_sources.size() - 1;
◆ GetSourceGain()
| bool IncrementalEngine::SoundEngine::GetSourceGain |
( |
unsigned int |
source, |
|
|
float & |
outGain |
|
) |
| |
◆ InitAL()
| bool IncrementalEngine::SoundEngine::InitAL |
( |
| ) |
|
|
private |
Definition at line 214 of file SoundEngine.cpp.
217 ALCdevice* device = alcOpenDevice(NULL);
218 ALCcontext* context = alcCreateContext(device, NULL);
220 alcMakeContextCurrent(context);
222 if ((error = alcGetError(device)) != ALC_NO_ERROR)
227 return alutInitWithoutContext(NULL, NULL) == AL_TRUE;
◆ Pause()
| void IncrementalEngine::SoundEngine::Pause |
( |
| ) |
|
Definition at line 68 of file SoundEngine.cpp.
71 std::vector<TInfoSource>::iterator it;
76 alGetSourcei((*it).Source, AL_SOURCE_STATE, &state);
77 if (state == AL_PLAYING &&
_pause)
79 alSourcePause((*it).Source);
81 else if (state == AL_PAUSED && !
_pause)
83 alSourcePlay((*it).Source);
◆ PauseSource()
| bool IncrementalEngine::SoundEngine::PauseSource |
( |
unsigned int |
source | ) |
|
Definition at line 145 of file SoundEngine.cpp.
151 alGetSourcei(
_sources[source].Source, AL_SOURCE_STATE, &state);
152 if (state == AL_PLAYING)
154 alSourcePause(
_sources[source].Source);
156 else if (state == AL_PAUSED)
158 alSourcePlay(
_sources[source].Source);
◆ Play()
| bool IncrementalEngine::SoundEngine::Play |
( |
const Sound * |
sound | ) |
|
Definition at line 35 of file SoundEngine.cpp.
39 ALfloat vector[3] = { 0.0f, 0.0f, 0.0f };
47 alSourcei(
_sources[index].Source, AL_BUFFER, sound->Buffer);
48 alSourcei(
_sources[index].Source, AL_SOURCE_RELATIVE, AL_TRUE);
49 alSourcef(
_sources[index].Source, AL_PITCH, 1.0f);
50 alSourcef(
_sources[index].Source, AL_GAIN, 1.0f);
51 alSourcefv(
_sources[index].Source, AL_POSITION, vector);
52 alSourcefv(
_sources[index].Source, AL_VELOCITY, vector);
53 alSourcefv(
_sources[index].Source, AL_DIRECTION, vector);
54 alSourcei(
_sources[index].Source, AL_LOOPING, AL_FALSE);
56 alSourcePlay(
_sources[index].Source);
◆ PlaySource()
| bool IncrementalEngine::SoundEngine::PlaySource |
( |
unsigned int |
source, |
|
|
const Sound * |
sound, |
|
|
bool |
loop |
|
) |
| |
Definition at line 119 of file SoundEngine.cpp.
127 alSourcei(
_sources[source].Source, AL_BUFFER, sound->Buffer);
128 alSourcef(
_sources[source].Source, AL_PITCH, 1.0f);
129 alSourcef(
_sources[source].Source, AL_GAIN, 1.0f);
130 alSourcei(
_sources[source].Source, AL_LOOPING, loop ? AL_TRUE : AL_FALSE);
132 alSourcePlay(
_sources[source].Source);
◆ Reset()
| void IncrementalEngine::SoundEngine::Reset |
( |
| ) |
|
◆ SetGain()
| void IncrementalEngine::SoundEngine::SetGain |
( |
float |
gain | ) |
|
◆ SetSourceGain()
| bool IncrementalEngine::SoundEngine::SetSourceGain |
( |
unsigned int |
source, |
|
|
float |
inGain |
|
) |
| |
◆ SoundOff()
| void IncrementalEngine::SoundEngine::SoundOff |
( |
| ) |
|
|
inline |
◆ SoundOn()
| void IncrementalEngine::SoundEngine::SoundOn |
( |
| ) |
|
|
inline |
◆ Stop()
| void IncrementalEngine::SoundEngine::Stop |
( |
| ) |
|
Definition at line 88 of file SoundEngine.cpp.
91 std::vector<TInfoSource>::iterator it;
95 alGetSourcei((*it).Source, AL_SOURCE_STATE, &state);
96 if (state == AL_PLAYING || state == AL_PAUSED)
98 alSourceStop((*it).Source);
◆ StopSource()
| bool IncrementalEngine::SoundEngine::StopSource |
( |
unsigned int |
source | ) |
|
Definition at line 168 of file SoundEngine.cpp.
174 alGetSourcei(
_sources[source].Source, AL_SOURCE_STATE, &state);
175 if (state == AL_PLAYING || state == AL_PAUSED)
177 alSourceStop(
_sources[source].Source);
◆ _pause
| bool IncrementalEngine::SoundEngine::_pause |
|
private |
◆ _soundOn
| bool IncrementalEngine::SoundEngine::_soundOn |
|
private |
◆ _sources
| std::vector<TInfoSource> IncrementalEngine::SoundEngine::_sources |
|
private |