diff options
author | Chris Robinson <[email protected]> | 2016-09-05 02:02:14 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-09-05 02:02:14 -0700 |
commit | 8a64f071213f387c4675012ec1df51b9295564b3 (patch) | |
tree | 8a892e91b2748d6e0bc4e108b14384f8d897e4b6 | |
parent | 42452b7f796a317a8d1159d16c5b84f8defd5e80 (diff) |
Use a predefined identity matrix
-rw-r--r-- | Alc/ALu.c | 7 | ||||
-rw-r--r-- | Alc/effects/compressor.c | 12 | ||||
-rw-r--r-- | Alc/effects/equalizer.c | 12 | ||||
-rw-r--r-- | Alc/effects/modulator.c | 12 | ||||
-rw-r--r-- | OpenAL32/Include/alu.h | 1 |
5 files changed, 14 insertions, 30 deletions
@@ -93,6 +93,13 @@ extern inline void aluMatrixfSet(aluMatrixf *matrix, ALfloat m20, ALfloat m21, ALfloat m22, ALfloat m23, ALfloat m30, ALfloat m31, ALfloat m32, ALfloat m33); +const aluMatrixf IdentityMatrixf = {{ + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f }, + { 0.0f, 0.0f, 0.0f, 1.0f }, +}}; + static inline HrtfDirectMixerFunc SelectHrtfMixer(void) { diff --git a/Alc/effects/compressor.c b/Alc/effects/compressor.c index 1426ea70..ab0a4216 100644 --- a/Alc/effects/compressor.c +++ b/Alc/effects/compressor.c @@ -78,23 +78,15 @@ static ALboolean ALcompressorState_deviceUpdate(ALcompressorState *state, ALCdev static ALvoid ALcompressorState_update(ALcompressorState *state, const ALCdevice *device, const ALeffectslot *slot, const ALeffectProps *props) { - aluMatrixf matrix; ALuint i; state->Enabled = props->Compressor.OnOff; - aluMatrixfSet(&matrix, - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f - ); - STATIC_CAST(ALeffectState,state)->OutBuffer = device->FOAOut.Buffer; STATIC_CAST(ALeffectState,state)->OutChannels = device->FOAOut.NumChannels; for(i = 0;i < 4;i++) - ComputeFirstOrderGains(device->FOAOut, matrix.m[i], slot->Params.Gain, - state->Gain[i]); + ComputeFirstOrderGains(device->FOAOut, IdentityMatrixf.m[i], + slot->Params.Gain, state->Gain[i]); } static ALvoid ALcompressorState_process(ALcompressorState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels) diff --git a/Alc/effects/equalizer.c b/Alc/effects/equalizer.c index 2b59cb37..61932ffb 100644 --- a/Alc/effects/equalizer.c +++ b/Alc/effects/equalizer.c @@ -126,21 +126,13 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCdevice * { ALfloat frequency = (ALfloat)device->Frequency; ALfloat gain, freq_mult; - aluMatrixf matrix; ALuint i; - aluMatrixfSet(&matrix, - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f - ); - STATIC_CAST(ALeffectState,state)->OutBuffer = device->FOAOut.Buffer; STATIC_CAST(ALeffectState,state)->OutChannels = device->FOAOut.NumChannels; for(i = 0;i < MAX_EFFECT_CHANNELS;i++) - ComputeFirstOrderGains(device->FOAOut, matrix.m[i], slot->Params.Gain, - state->Gain[i]); + ComputeFirstOrderGains(device->FOAOut, IdentityMatrixf.m[i], + slot->Params.Gain, state->Gain[i]); /* Calculate coefficients for the each type of filter. Note that the shelf * filters' gain is for the reference frequency, which is the centerpoint diff --git a/Alc/effects/modulator.c b/Alc/effects/modulator.c index 08f3d5eb..5ca37f4f 100644 --- a/Alc/effects/modulator.c +++ b/Alc/effects/modulator.c @@ -117,7 +117,6 @@ static ALboolean ALmodulatorState_deviceUpdate(ALmodulatorState *UNUSED(state), static ALvoid ALmodulatorState_update(ALmodulatorState *state, const ALCdevice *Device, const ALeffectslot *Slot, const ALeffectProps *props) { - aluMatrixf matrix; ALfloat cw, a; ALuint i; @@ -146,18 +145,11 @@ static ALvoid ALmodulatorState_update(ALmodulatorState *state, const ALCdevice * state->Filter[i].process = ALfilterState_processC; } - aluMatrixfSet(&matrix, - 1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f - ); - STATIC_CAST(ALeffectState,state)->OutBuffer = Device->FOAOut.Buffer; STATIC_CAST(ALeffectState,state)->OutChannels = Device->FOAOut.NumChannels; for(i = 0;i < MAX_EFFECT_CHANNELS;i++) - ComputeFirstOrderGains(Device->FOAOut, matrix.m[i], Slot->Params.Gain, - state->Gain[i]); + ComputeFirstOrderGains(Device->FOAOut, IdentityMatrixf.m[i], + Slot->Params.Gain, state->Gain[i]); } static ALvoid ALmodulatorState_process(ALmodulatorState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels) diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index 9a92dc50..d236c58b 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -79,6 +79,7 @@ inline void aluVectorSet(aluVector *vector, ALfloat x, ALfloat y, ALfloat z, ALf typedef union aluMatrixf { alignas(16) ALfloat m[4][4]; } aluMatrixf; +const aluMatrixf IdentityMatrixf; inline void aluMatrixfSetRow(aluMatrixf *matrix, ALuint row, ALfloat m0, ALfloat m1, ALfloat m2, ALfloat m3) |