-
Notifications
You must be signed in to change notification settings - Fork 1
/
AuxEffectSlot.cpp
69 lines (52 loc) · 1.41 KB
/
AuxEffectSlot.cpp
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
#include "Common.h"
ALuint Extension::AuxEffectSlotGetFromID(int ID)
{
map<int, ALuint>::iterator FoundAux = AuxSlotMap.find(ID);
//An auxiliary slot with the ID was found, return its handle.
if(FoundAux != AuxSlotMap.end())
return FoundAux->second;
//Nothing found, return zero.
return 0;
}
void Extension::AuxEffectSlotLoadEffect(ALuint Handle)
{
if(!alIsAuxiliaryEffectSlot(AuxSlot))
return;
alAuxiliaryEffectSloti(AuxSlot, AL_EFFECTSLOT_EFFECT, Handle);
}
/* Actions */
void Extension::AuxEffectSlotCreate(int ID)
{
//Generate an object.
alGenAuxiliaryEffectSlots(1, &AuxSlot);
//Store the auxiliary slot in the map.
if(AuxSlot)
{
//Delete the old effect in the map.
if(AuxSlotMap.find(ID) != AuxSlotMap.end())
alDeleteAuxiliaryEffectSlots(1, &AuxSlotMap[ID]);
AuxSlotMap[ID] = AuxSlot;
}
}
void Extension::AuxEffectSlotSelectByID(int ID)
{
AuxSlot = AuxEffectSlotGetFromID(ID);
}
void Extension::AuxEffectSlotSetGain(float Gain)
{
if(!alIsAuxiliaryEffectSlot(AuxSlot))
return;
Gain = max(0, min(1, Gain));
alAuxiliaryEffectSlotf(AuxSlot, AL_EFFECTSLOT_GAIN, Gain);
}
void Extension::AuxEffectSlotSetAutoAdjust(int Adjust)
{
if(!alIsAuxiliaryEffectSlot(AuxSlot))
return;
Adjust = Adjust ? AL_TRUE : AL_FALSE;
alAuxiliaryEffectSloti(AuxSlot, AL_EFFECTSLOT_AUXILIARY_SEND_AUTO, Adjust);
}
void Extension::AuxEffectSlotLoadEffectByID(int ID)
{
AuxEffectSlotLoadEffect(EffectGetFromID(ID));
}