aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALu.c5
-rw-r--r--Alc/effects/autowah.c4
-rw-r--r--Alc/effects/compressor.c9
-rw-r--r--Alc/effects/distortion.c4
-rw-r--r--Alc/effects/equalizer.c3
-rw-r--r--Alc/effects/modulator.c5
-rw-r--r--Alc/effects/reverb.c3
-rw-r--r--Alc/panning.c15
-rw-r--r--OpenAL32/Include/alu.h21
9 files changed, 33 insertions, 36 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 48f22114..6d95a99c 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -997,7 +997,10 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCconte
/* Normalize the length, and compute panned gains. */
if(!(Distance > FLT_EPSILON))
+ {
Position[0] = Position[1] = Position[2] = 0.0f;
+ ComputeAmbientGains(Device, DryGain, Target);
+ }
else
{
ALfloat radius = ALSource->Radius;
@@ -1005,8 +1008,8 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCconte
Position[0] *= invlen;
Position[1] *= invlen;
Position[2] *= invlen;
+ ComputeDirectionalGains(Device, Position, DryGain, Target);
}
- ComputeDirectionalGains(Device, Position, DryGain, Target);
for(j = 0;j < MaxChannels;j++)
gains[j].Target = Target[j];
diff --git a/Alc/effects/autowah.c b/Alc/effects/autowah.c
index f4aaf49f..e4edb2d4 100644
--- a/Alc/effects/autowah.c
+++ b/Alc/effects/autowah.c
@@ -66,7 +66,6 @@ static ALboolean ALautowahState_deviceUpdate(ALautowahState *state, ALCdevice *d
static ALvoid ALautowahState_update(ALautowahState *state, ALCdevice *device, const ALeffectslot *slot)
{
ALfloat attackTime, releaseTime;
- ALfloat gain;
attackTime = slot->EffectProps.Autowah.AttackTime * state->Frequency;
releaseTime = slot->EffectProps.Autowah.ReleaseTime * state->Frequency;
@@ -76,8 +75,7 @@ static ALvoid ALautowahState_update(ALautowahState *state, ALCdevice *device, co
state->PeakGain = slot->EffectProps.Autowah.PeakGain;
state->Resonance = slot->EffectProps.Autowah.Resonance;
- gain = 1.0f/device->NumSpeakers * slot->Gain;
- SetGains(device, gain, state->Gain);
+ ComputeAmbientGains(device, slot->Gain, state->Gain);
}
static ALvoid ALautowahState_process(ALautowahState *state, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[BUFFERSIZE])
diff --git a/Alc/effects/compressor.c b/Alc/effects/compressor.c
index 9554a0f2..bc1cb81a 100644
--- a/Alc/effects/compressor.c
+++ b/Alc/effects/compressor.c
@@ -55,14 +55,11 @@ static ALboolean ALcompressorState_deviceUpdate(ALcompressorState *state, ALCdev
return AL_TRUE;
}
-static ALvoid ALcompressorState_update(ALcompressorState *state, ALCdevice *Device, const ALeffectslot *Slot)
+static ALvoid ALcompressorState_update(ALcompressorState *state, ALCdevice *device, const ALeffectslot *slot)
{
- ALfloat gain;
+ state->Enabled = slot->EffectProps.Compressor.OnOff;
- state->Enabled = Slot->EffectProps.Compressor.OnOff;
-
- gain = 1.0f/Device->NumSpeakers * Slot->Gain;
- SetGains(Device, gain, state->Gain);
+ ComputeAmbientGains(device, slot->Gain, state->Gain);
}
static ALvoid ALcompressorState_process(ALcompressorState *state, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[BUFFERSIZE])
diff --git a/Alc/effects/distortion.c b/Alc/effects/distortion.c
index 9e36ea20..95e76ac1 100644
--- a/Alc/effects/distortion.c
+++ b/Alc/effects/distortion.c
@@ -58,7 +58,6 @@ static ALvoid ALdistortionState_update(ALdistortionState *state, ALCdevice *Devi
ALfloat bandwidth;
ALfloat cutoff;
ALfloat edge;
- ALfloat gain;
/* Store distorted signal attenuation settings */
state->attenuation = Slot->EffectProps.Distortion.Gain;
@@ -82,8 +81,7 @@ static ALvoid ALdistortionState_update(ALdistortionState *state, ALCdevice *Devi
ALfilterState_setParams(&state->bandpass, ALfilterType_BandPass, 1.0f,
cutoff / (frequency*4.0f), bandwidth);
- gain = 1.0f/Device->NumSpeakers * Slot->Gain;
- SetGains(Device, gain, state->Gain);
+ ComputeAmbientGains(Device, Slot->Gain, state->Gain);
}
static ALvoid ALdistortionState_process(ALdistortionState *state, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE])
diff --git a/Alc/effects/equalizer.c b/Alc/effects/equalizer.c
index d04f36ee..f555cbe5 100644
--- a/Alc/effects/equalizer.c
+++ b/Alc/effects/equalizer.c
@@ -93,9 +93,8 @@ static ALboolean ALequalizerState_deviceUpdate(ALequalizerState *UNUSED(state),
static ALvoid ALequalizerState_update(ALequalizerState *state, ALCdevice *device, const ALeffectslot *slot)
{
ALfloat frequency = (ALfloat)device->Frequency;
- ALfloat gain = 1.0f/device->NumSpeakers * slot->Gain;
- SetGains(device, gain, state->Gain);
+ ComputeAmbientGains(device, slot->Gain, state->Gain);
/* Calculate coefficients for the each type of filter */
ALfilterState_setParams(&state->filter[0], ALfilterType_LowShelf,
diff --git a/Alc/effects/modulator.c b/Alc/effects/modulator.c
index e57040b3..01d19bcb 100644
--- a/Alc/effects/modulator.c
+++ b/Alc/effects/modulator.c
@@ -125,7 +125,7 @@ static ALboolean ALmodulatorState_deviceUpdate(ALmodulatorState *UNUSED(state),
static ALvoid ALmodulatorState_update(ALmodulatorState *state, ALCdevice *Device, const ALeffectslot *Slot)
{
- ALfloat gain, cw, a;
+ ALfloat cw, a;
if(Slot->EffectProps.Modulator.Waveform == AL_RING_MODULATOR_SINUSOID)
state->Waveform = SINUSOID;
@@ -149,8 +149,7 @@ static ALvoid ALmodulatorState_update(ALmodulatorState *state, ALCdevice *Device
state->Filter.a[1] = -a;
state->Filter.a[2] = 0.0f;
- gain = 1.0f/Device->NumSpeakers * Slot->Gain;
- SetGains(Device, gain, state->Gain);
+ ComputeAmbientGains(Device, Slot->Gain, state->Gain);
}
static ALvoid ALmodulatorState_process(ALmodulatorState *state, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE])
diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c
index 45d25da7..5b937d96 100644
--- a/Alc/effects/reverb.c
+++ b/Alc/effects/reverb.c
@@ -1148,8 +1148,7 @@ static ALvoid ALreverbState_update(ALreverbState *State, ALCdevice *Device, cons
else
{
/* Update channel gains */
- ALfloat gain = 2.0f/Device->NumSpeakers * Slot->Gain * ReverbBoost;
- SetGains(Device, gain, State->Gain);
+ ComputeAmbientGains(Device, Slot->Gain*2.0f, State->Gain);
}
}
diff --git a/Alc/panning.c b/Alc/panning.c
index 2e979049..9f05203f 100644
--- a/Alc/panning.c
+++ b/Alc/panning.c
@@ -31,8 +31,6 @@
#include "AL/alc.h"
#include "alu.h"
-extern inline void SetGains(const ALCdevice *device, ALfloat ingain, ALfloat gains[MaxChannels]);
-
void ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat elevation, ALfloat ingain, ALfloat gains[MaxChannels])
{
@@ -81,6 +79,19 @@ void ComputeDirectionalGains(const ALCdevice *device, const ALfloat dir[3], ALfl
}
}
+void ComputeAmbientGains(const ALCdevice *device, ALfloat ingain, ALfloat gains[MaxChannels])
+{
+ ALuint i;
+
+ for(i = 0;i < MaxChannels;i++)
+ gains[i] = 0.0f;
+ for(i = 0;i < device->NumSpeakers;i++)
+ {
+ enum Channel chan = device->Speaker[i].ChanName;
+ gains[chan] = device->Speaker[i].HOACoeff[0] * ingain;
+ }
+}
+
void ComputeBFormatGains(const ALCdevice *device, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MaxChannels])
{
ALuint i, j;
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 6ebafe86..3b0ce871 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -218,6 +218,13 @@ void ComputeDirectionalGains(const ALCdevice *device, const ALfloat dir[3], ALfl
void ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat elevation, ALfloat ingain, ALfloat gains[MaxChannels]);
/**
+ * ComputeAmbientGains
+ *
+ * Sets channel gains for ambient, omni-directional sounds.
+ */
+void ComputeAmbientGains(const ALCdevice *device, ALfloat ingain, ALfloat gains[MaxChannels]);
+
+/**
* ComputeBFormatGains
*
* Sets channel gains for a given (first-order) B-Format channel. The matrix is
@@ -226,20 +233,6 @@ void ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat elevation
*/
void ComputeBFormatGains(const ALCdevice *device, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MaxChannels]);
-/**
- * SetGains
- *
- * Helper to set the appropriate channels to the specified gain.
- */
-inline void SetGains(const ALCdevice *device, ALfloat ingain, ALfloat gains[MaxChannels])
-{
- ALuint i;
- for(i = 0;i < MaxChannels;i++)
- gains[i] = 0.0f;
- for(i = 0;i < device->NumSpeakers;i++)
- gains[device->Speaker[i].ChanName] = ingain;
-}
-
ALvoid CalcSourceParams(struct ALvoice *voice, const struct ALsource *source, const ALCcontext *ALContext);
ALvoid CalcNonAttnSourceParams(struct ALvoice *voice, const struct ALsource *source, const ALCcontext *ALContext);