zenilib: zenilib/jni/external/openal-soft/Alc/alcDedicated.c Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
alcDedicated.c
Go to the documentation of this file.
1
21 #include "config.h"
22
23 #include <stdlib.h>
24
25 #include "alMain.h"
26 #include "alFilter.h"
27 #include "alAuxEffectSlot.h"
28 #include "alError.h"
29 #include "alu.h"
30
31
32 typedef struct ALdedicatedState {
33 // Must be first in all effects!
34 ALeffectState state;
35
36 ALfloat gains[MaxChannels];
37 } ALdedicatedState;
38
39
40 static ALvoid DedicatedDestroy(ALeffectState *effect)
41 {
42 ALdedicatedState *state = (ALdedicatedState*)effect;
43 free(state);
44 }
45
46 static ALboolean DedicatedDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
47 {
48 (void)effect;
49 (void)Device;
50 return AL_TRUE;
51 }
52
53 static ALvoid DedicatedUpdate(ALeffectState *effect, ALCdevice *device, const ALeffectslot *Slot)
54 {
55 ALdedicatedState *state = (ALdedicatedState*)effect;
56 ALfloat Gain;
57 ALsizei s;
58
59 Gain = Slot->Gain * Slot->effect.Dedicated.Gain;
60 for(s = 0;s < MaxChannels;s++)
61 state->gains[s] = 0.0f;
62
63 if(Slot->effect.type == AL_EFFECT_DEDICATED_DIALOGUE)
64 ComputeAngleGains(device, atan2f(0.0f, 1.0f), 0.0f, Gain, state->gains);
65 else if(Slot->effect.type == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT)
66 state->gains[LFE] = Gain;
67 }
68
69 static ALvoid DedicatedProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *RESTRICT SamplesIn, ALfloat (*RESTRICT SamplesOut)[BUFFERSIZE])
70 {
71 ALdedicatedState *state = (ALdedicatedState*)effect;
72 const ALfloat *gains = state->gains;
73 ALuint i, c;
74
75 for(c = 0;c < MaxChannels;c++)
76 {
77 for(i = 0;i < SamplesToDo;i++)
78 SamplesOut[c][i] = SamplesIn[i] * gains[c];
79 }
80 }
81
82 ALeffectState *DedicatedCreate(void)
83 {
84 ALdedicatedState *state;
85 ALsizei s;
86
87 state = malloc(sizeof(*state));
88 if(!state)
89 return NULL;
90
91 state->state.Destroy = DedicatedDestroy;
92 state->state.DeviceUpdate = DedicatedDeviceUpdate;
93 state->state.Update = DedicatedUpdate;
94 state->state.Process = DedicatedProcess;
95
96 for(s = 0;s < MaxChannels;s++)
97 state->gains[s] = 0.0f;
98
99 return &state->state;
100 }
DedicatedDestroy
static ALvoid DedicatedDestroy(ALeffectState *effect)
Definition: alcDedicated.c:40
ALvoid
void ALvoid
Definition: al.h:74
s
GLdouble s
Definition: glew.h:1376
void
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
Definition: glew.h:1824
LFE
Definition: alMain.h:484
AL_TRUE
#define AL_TRUE
Definition: al.h:86
NULL
#define NULL
Definition: ftobjs.h:61
f
GLclampf f
Definition: glew.h:3390
alu.h
ALsizei
int ALsizei
Definition: al.h:62
free
SDL_EventEntry * free
Definition: SDL_events.c:80
ALCdevice_struct
Definition: alMain.h:560
ALeffectState
Definition: alAuxEffectSlot.h:11
alError.h
alFilter.h
ALfloat
float ALfloat
Definition: al.h:68
ALdedicatedState
struct ALdedicatedState ALdedicatedState
alAuxEffectSlot.h
ALeffectslot::effect
ALeffect effect
Definition: alAuxEffectSlot.h:21
ALeffectslot
Definition: alAuxEffectSlot.h:19
alMain.h
DedicatedDeviceUpdate
static ALboolean DedicatedDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
Definition: alcDedicated.c:46
AL_EFFECT_DEDICATED_DIALOGUE
#define AL_EFFECT_DEDICATED_DIALOGUE
Definition: alext.h:202
c
const GLfloat * c
Definition: glew.h:14913
ComputeAngleGains
ALvoid ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat hwidth, ALfloat ingain, ALfloat *gains)
Definition: panning.c:149
DedicatedUpdate
static ALvoid DedicatedUpdate(ALeffectState *effect, ALCdevice *device, const ALeffectslot *Slot)
Definition: alcDedicated.c:53
ALeffectslot::Gain
volatile ALfloat Gain
Definition: alAuxEffectSlot.h:23
ALuint
unsigned int ALuint
Definition: al.h:59
DedicatedProcess
static ALvoid DedicatedProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *RESTRICT SamplesIn, ALfloat(*RESTRICT SamplesOut)[BUFFERSIZE])
Definition: alcDedicated.c:69
malloc
#define malloc
Definition: SDL_malloc.c:635
DedicatedCreate
ALeffectState * DedicatedCreate(void)
Definition: alcDedicated.c:82
ALeffect::Dedicated
struct ALeffect::@55 Dedicated
ALboolean
char ALboolean
Definition: al.h:38
ALeffect::Gain
ALfloat Gain
Definition: alEffect.h:33
AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT
#define AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT
Definition: alext.h:203
i
int i
Definition: pngrutil.c:1377
BUFFERSIZE
#define BUFFERSIZE
Definition: alMain.h:556
ALeffect::type
ALenum type
Definition: alEffect.h:27
MaxChannels
Definition: alMain.h:491