aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-05-29 16:51:00 -0700
committerChris Robinson <[email protected]>2009-05-29 16:51:00 -0700
commit2c20f2678478c2320a0236baf288baed8987b1f8 (patch)
treea1183d8badad01480382a8bdd18dca87c5cb1a8d
parent2a21a449b4828a08780e44d17586de4ba2119f0a (diff)
Apply slot gain on slot output, not input
-rw-r--r--Alc/ALu.c4
-rw-r--r--Alc/alcEcho.c8
-rw-r--r--Alc/alcReverb.c64
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h10
-rw-r--r--OpenAL32/alAuxEffectSlot.c2
5 files changed, 47 insertions, 41 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index afc35aaf..a7845dc3 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -749,7 +749,7 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext,
wetgainhf[i] *= ALSource->Send[i].WetFilter.GainHF;
break;
}
- wetsend[i] *= ALSource->Send[i].Slot->Gain * ListenerGain;
+ wetsend[i] *= ListenerGain;
}
else
{
@@ -1310,7 +1310,7 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma
while(ALEffectSlot)
{
if(ALEffectSlot->EffectState)
- ALEffect_Process(ALEffectSlot->EffectState, SamplesToDo, ALEffectSlot->WetBuffer, DryBuffer);
+ ALEffect_Process(ALEffectSlot->EffectState, ALEffectSlot, SamplesToDo, ALEffectSlot->WetBuffer, DryBuffer);
for(i = 0;i < SamplesToDo;i++)
ALEffectSlot->WetBuffer[i] = 0.0f;
diff --git a/Alc/alcEcho.c b/Alc/alcEcho.c
index 99bd8a54..7185e125 100644
--- a/Alc/alcEcho.c
+++ b/Alc/alcEcho.c
@@ -79,7 +79,7 @@ ALvoid EchoDestroy(ALeffectState *effect)
}
}
-ALvoid EchoUpdate(ALeffectState *effect, ALCcontext *Context, struct ALeffectslot *Slot, ALeffect *Effect)
+ALvoid EchoUpdate(ALeffectState *effect, ALCcontext *Context, ALeffect *Effect)
{
ALechoState *state = (ALechoState*)effect;
ALuint newdelay1, newdelay2;
@@ -107,13 +107,14 @@ ALvoid EchoUpdate(ALeffectState *effect, ALCcontext *Context, struct ALeffectslo
state->iirFilter.coeff = a;
}
-ALvoid EchoProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[OUTPUTCHANNELS])
+ALvoid EchoProcess(ALeffectState *effect, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[OUTPUTCHANNELS])
{
ALechoState *state = (ALechoState*)effect;
const ALuint delay = state->BufferLength-1;
ALuint tap1off = state->Tap[0].offset;
ALuint tap2off = state->Tap[1].offset;
ALuint fboff = state->Tap[2].offset;
+ ALfloat gain = Slot->Gain;
ALfloat samp[2];
ALuint i;
@@ -135,6 +136,9 @@ ALvoid EchoProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *Sam
// Sample second tap. Reverse LR panning
samp[0] += state->SampleBuffer[tap2off]*state->GainR;
samp[1] += state->SampleBuffer[tap2off]*state->GainL;
+ // Apply slot gain
+ samp[0] *= gain;
+ samp[1] *= gain;
SamplesOut[i][FRONT_LEFT] += samp[0];
SamplesOut[i][FRONT_RIGHT] += samp[1];
diff --git a/Alc/alcReverb.c b/Alc/alcReverb.c
index 911705aa..24d1eb39 100644
--- a/Alc/alcReverb.c
+++ b/Alc/alcReverb.c
@@ -371,7 +371,7 @@ static __inline ALint aluCart2LUTpos(ALfloat re, ALfloat im)
// This updates the reverb state. This is called any time the reverb effect
// is loaded into a slot.
-ALvoid VerbUpdate(ALeffectState *effect, ALCcontext *Context, ALeffectslot *Slot, ALeffect *Effect)
+ALvoid VerbUpdate(ALeffectState *effect, ALCcontext *Context, ALeffect *Effect)
{
ALverbState *State = (ALverbState*)effect;
ALuint index;
@@ -567,11 +567,12 @@ ALvoid VerbUpdate(ALeffectState *effect, ALCcontext *Context, ALeffectslot *Slot
// This processes the reverb state, given the input samples and an output
// buffer.
-ALvoid VerbProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[OUTPUTCHANNELS])
+ALvoid VerbProcess(ALeffectState *effect, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[OUTPUTCHANNELS])
{
ALverbState *State = (ALverbState*)effect;
ALuint index;
ALfloat early[4], late[4], out[4];
+ ALfloat gain = Slot->Gain;
for(index = 0;index < SamplesToDo;index++)
{
@@ -579,30 +580,31 @@ ALvoid VerbProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *Sam
ReverbInOut(State, SamplesIn[index], early, late);
// Mix early reflections and late reverb.
- out[0] = early[0] + late[0];
- out[1] = early[1] + late[1];
- out[2] = early[2] + late[2];
- out[3] = early[3] + late[3];
+ out[0] = (early[0] + late[0]) * gain;
+ out[1] = (early[1] + late[1]) * gain;
+ out[2] = (early[2] + late[2]) * gain;
+ out[3] = (early[3] + late[3]) * gain;
// Output the results.
- SamplesOut[index][FRONT_LEFT] += out [0];
- SamplesOut[index][FRONT_RIGHT] += out [1];
- SamplesOut[index][FRONT_CENTER] += out [3];
- SamplesOut[index][SIDE_LEFT] += out [0];
- SamplesOut[index][SIDE_RIGHT] += out [1];
- SamplesOut[index][BACK_LEFT] += out [0];
- SamplesOut[index][BACK_RIGHT] += out [1];
- SamplesOut[index][BACK_CENTER] += out [2];
+ SamplesOut[index][FRONT_LEFT] += out[0];
+ SamplesOut[index][FRONT_RIGHT] += out[1];
+ SamplesOut[index][FRONT_CENTER] += out[3];
+ SamplesOut[index][SIDE_LEFT] += out[0];
+ SamplesOut[index][SIDE_RIGHT] += out[1];
+ SamplesOut[index][BACK_LEFT] += out[0];
+ SamplesOut[index][BACK_RIGHT] += out[1];
+ SamplesOut[index][BACK_CENTER] += out[2];
}
}
// This processes the EAX reverb state, given the input samples and an output
// buffer.
-ALvoid EAXVerbProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[OUTPUTCHANNELS])
+ALvoid EAXVerbProcess(ALeffectState *effect, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[OUTPUTCHANNELS])
{
ALverbState *State = (ALverbState*)effect;
ALuint index;
ALfloat early[4], late[4];
+ ALfloat gain = Slot->Gain;
for(index = 0;index < SamplesToDo;index++)
{
@@ -613,29 +615,29 @@ ALvoid EAXVerbProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *
// panning adjust according to OUTPUTCHANNELS, the output from the
// reverb engine is not so scalable.
SamplesOut[index][FRONT_LEFT] +=
- (State->Early.PanGain[FRONT_LEFT] * early[0]) +
- (State->Late.PanGain[FRONT_LEFT] * late[0]);
+ (State->Early.PanGain[FRONT_LEFT]*early[0] +
+ State->Late.PanGain[FRONT_LEFT]*late[0]) * gain;
SamplesOut[index][FRONT_RIGHT] +=
- (State->Early.PanGain[FRONT_RIGHT] * early[1]) +
- (State->Late.PanGain[FRONT_RIGHT] * late[1]);
+ (State->Early.PanGain[FRONT_RIGHT]*early[1] +
+ State->Late.PanGain[FRONT_RIGHT]*late[1]) * gain;
SamplesOut[index][FRONT_CENTER] +=
- (State->Early.PanGain[FRONT_CENTER] * early[3]) +
- (State->Late.PanGain[FRONT_CENTER] * late[3]);
+ (State->Early.PanGain[FRONT_CENTER]*early[3] +
+ State->Late.PanGain[FRONT_CENTER]*late[3]) * gain;
SamplesOut[index][SIDE_LEFT] +=
- (State->Early.PanGain[SIDE_LEFT] * early[0]) +
- (State->Late.PanGain[SIDE_LEFT] * late[0]);
+ (State->Early.PanGain[SIDE_LEFT]*early[0] +
+ State->Late.PanGain[SIDE_LEFT]*late[0]) * gain;
SamplesOut[index][SIDE_RIGHT] +=
- (State->Early.PanGain[SIDE_RIGHT] * early[1]) +
- (State->Late.PanGain[SIDE_RIGHT] * late[1]);
+ (State->Early.PanGain[SIDE_RIGHT]*early[1] +
+ State->Late.PanGain[SIDE_RIGHT]*late[1]) * gain;
SamplesOut[index][BACK_LEFT] +=
- (State->Early.PanGain[BACK_LEFT] * early[0]) +
- (State->Late.PanGain[BACK_LEFT] * late[0]);
+ (State->Early.PanGain[BACK_LEFT]*early[0] +
+ State->Late.PanGain[BACK_LEFT]*late[0]) * gain;
SamplesOut[index][BACK_RIGHT] +=
- (State->Early.PanGain[BACK_RIGHT] * early[1]) +
- (State->Late.PanGain[BACK_RIGHT] * late[1]);
+ (State->Early.PanGain[BACK_RIGHT]*early[1] +
+ State->Late.PanGain[BACK_RIGHT]*late[1]) * gain;
SamplesOut[index][BACK_CENTER] +=
- (State->Early.PanGain[BACK_CENTER] * early[2]) +
- (State->Late.PanGain[BACK_CENTER] * late[2]);
+ (State->Early.PanGain[BACK_CENTER]*early[2] +
+ State->Late.PanGain[BACK_CENTER]*late[2]) * gain;
}
}
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index e4c46d70..eb41132b 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -55,17 +55,17 @@ ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context);
struct ALeffectState {
ALvoid (*Destroy)(ALeffectState *State);
- ALvoid (*Update)(ALeffectState *State, ALCcontext *Context, ALeffectslot *Slot, ALeffect *Effect);
- ALvoid (*Process)(ALeffectState *State, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[OUTPUTCHANNELS]);
+ ALvoid (*Update)(ALeffectState *State, ALCcontext *Context, ALeffect *Effect);
+ ALvoid (*Process)(ALeffectState *State, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[OUTPUTCHANNELS]);
};
ALeffectState *EAXVerbCreate(ALCcontext *Context);
ALeffectState *VerbCreate(ALCcontext *Context);
ALeffectState *EchoCreate(ALCcontext *Context);
-#define ALEffect_Destroy(a) ((a)->Destroy((a)))
-#define ALEffect_Update(a,b,c,d) ((a)->Update((a),(b),(c),(d)))
-#define ALEffect_Process(a,b,c,d) ((a)->Process((a),(b),(c),(d)))
+#define ALEffect_Destroy(a) ((a)->Destroy((a)))
+#define ALEffect_Update(a,b,c) ((a)->Update((a),(b),(c)))
+#define ALEffect_Process(a,b,c,d,e) ((a)->Process((a),(b),(c),(d),(e)))
#ifdef __cplusplus
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index d2e43183..62d153c1 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -491,7 +491,7 @@ static ALvoid InitializeEffect(ALCcontext *Context, ALeffectslot *ALEffectSlot,
else if(effect->type == AL_EFFECT_ECHO)
ALEffectSlot->EffectState = EchoCreate(Context);
}
- ALEffect_Update(ALEffectSlot->EffectState, Context, ALEffectSlot, effect);
+ ALEffect_Update(ALEffectSlot->EffectState, Context, effect);
}