diff options
author | Chris Robinson <[email protected]> | 2019-02-21 19:05:20 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-02-21 19:05:20 -0800 |
commit | 01ac6e2e562d711c2781c402ad0886426d34c844 (patch) | |
tree | 85ef2e66f2aaced9cbd4e8a3e08ea9b0fae93bd1 /Alc | |
parent | 7a9d67934fbbe9ce8220e23d82fd0b5bababee50 (diff) |
Combine reverb transform matrices one column at a time
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/effects/reverb.cpp | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/Alc/effects/reverb.cpp b/Alc/effects/reverb.cpp index 20ea378a..6a8b38ea 100644 --- a/Alc/effects/reverb.cpp +++ b/Alc/effects/reverb.cpp @@ -765,31 +765,36 @@ alu::Matrix GetTransformFromVector(const ALfloat *vec) /* Update the early and late 3D panning gains. */ ALvoid Update3DPanning(const ALfloat *ReflectionsPan, const ALfloat *LateReverbPan, const ALfloat earlyGain, const ALfloat lateGain, const EffectTarget &target, ReverbState *State) { - /* Note: ret is transposed. */ - auto MatrixMult = [](const alu::Matrix &m1, const alu::Matrix &m2) noexcept -> alu::Matrix + /* Multiples two matrices, producing the given column's results. */ + auto MatrixMult = [](const alu::Matrix &m1, const alu::Matrix &m2, size_t col) noexcept -> std::array<ALfloat,MAX_AMBI_CHANNELS> { - alu::Matrix ret; - for(int col{0};col < 4;col++) - { - for(int row{0};row < 4;row++) - ret[col][row] = m1[row][0]*m2[0][col] + m1[row][1]*m2[1][col] + - m1[row][2]*m2[2][col] + m1[row][3]*m2[3][col]; - } + std::array<ALfloat,MAX_AMBI_CHANNELS> ret{}; + for(int row{0};row < 4;row++) + ret[row] = m1[row][0]*m2[0][col] + m1[row][1]*m2[1][col] + + m1[row][2]*m2[2][col] + m1[row][3]*m2[3][col]; return ret; }; - /* Create a matrix that first converts A-Format to B-Format, then - * transforms the B-Format signal according to the panning vector. + /* Create matrices that transform a B-Format signal according to the + * panning vectors. */ - alu::Matrix earlymat{MatrixMult(GetTransformFromVector(ReflectionsPan), A2B)}; - alu::Matrix latemat{MatrixMult(GetTransformFromVector(LateReverbPan), A2B)}; + const alu::Matrix earlymat{GetTransformFromVector(ReflectionsPan)}; + const alu::Matrix latemat{GetTransformFromVector(LateReverbPan)}; State->mOutBuffer = target.FOAOut->Buffer; State->mOutChannels = target.FOAOut->NumChannels; - for(ALsizei i{0};i < NUM_LINES;i++) - ComputePanGains(target.FOAOut, earlymat[i].data(), earlyGain, - State->mEarly.PanGain[i]); - for(ALsizei i{0};i < NUM_LINES;i++) - ComputePanGains(target.FOAOut, latemat[i].data(), lateGain, State->mLate.PanGain[i]); + for(size_t i{0u};i < NUM_LINES;i++) + { + /* Combine the B-Format transform matrix with one that first converts + * A-Format to B-Format. + */ + auto coeffs = MatrixMult(earlymat, A2B, i); + ComputePanGains(target.FOAOut, coeffs.data(), earlyGain, State->mEarly.PanGain[i]); + } + for(size_t i{0u};i < NUM_LINES;i++) + { + auto coeffs = MatrixMult(latemat, A2B, i); + ComputePanGains(target.FOAOut, coeffs.data(), lateGain, State->mLate.PanGain[i]); + } } void ReverbState::update(const ALCcontext *Context, const ALeffectslot *Slot, const ALeffectProps *props, const EffectTarget target) |