diff options
author | Chris Robinson <[email protected]> | 2018-12-08 04:10:45 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-12-08 04:10:45 -0800 |
commit | 9e9b771e8a672f6b637a78f006da922e6cd7d026 (patch) | |
tree | cd61b7cb463b44a3d5304e4cf7465a4ecdc01199 /Alc/bformatdec.cpp | |
parent | 5ea3c8fb609f88446f73c4e0274b733f1bd5f1be (diff) |
A bit more cleanup
Diffstat (limited to 'Alc/bformatdec.cpp')
-rw-r--r-- | Alc/bformatdec.cpp | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/Alc/bformatdec.cpp b/Alc/bformatdec.cpp index 00db0393..7af3a864 100644 --- a/Alc/bformatdec.cpp +++ b/Alc/bformatdec.cpp @@ -1,9 +1,11 @@ #include "config.h" +#include <cmath> #include <array> #include <vector> #include <numeric> +#include <algorithm> #include <functional> #include "bformatdec.h" @@ -136,13 +138,9 @@ void BFormatDec::reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate, else if(conf->CoeffScale == AmbDecScale::FuMa) coeff_scale = FuMa2N3DScale; - float ratio{400.0f / (float)srate}; - for(auto &chan : mUpSampler) - { - chan.XOver.init(ratio); - chan.XOver.clear(); - std::fill(std::begin(chan.Gains), std::end(chan.Gains), 0.0f); - } + mUpSampler[0].XOver.init(400.0f / (float)srate); + std::fill(std::begin(mUpSampler[0].Gains), std::end(mUpSampler[0].Gains), 0.0f); + std::fill(std::begin(mUpSampler)+1, std::end(mUpSampler), mUpSampler[0]); const bool periphonic{(conf->ChanMask&AMBI_PERIPHONIC_MASK) != 0}; if(periphonic) @@ -211,23 +209,20 @@ void BFormatDec::reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate, } else { - using namespace std::placeholders; mDualBand = AL_TRUE; - ratio = conf->XOverFreq / (ALfloat)srate; - std::for_each(std::begin(mXOver), std::end(mXOver), - std::bind(std::mem_fn(&BandSplitter::init), _1, ratio)); + mXOver[0].init(conf->XOverFreq / (float)srate); + std::fill(std::begin(mXOver)+1, std::end(mXOver), mXOver[0]); - ratio = powf(10.0f, conf->XOverRatio / 40.0f); + float ratio{std::pow(10.0f, conf->XOverRatio / 40.0f)}; for(ALsizei i{0};i < conf->NumSpeakers;i++) { ALsizei chan = chanmap[i]; - ALfloat gain; - ALsizei j, k; + ALfloat gain{}; if(!periphonic) { - for(j = 0,k = 0;j < MAX_AMBI2D_COEFFS;j++) + for(ALsizei j{0},k{0};j < MAX_AMBI2D_COEFFS;j++) { ALsizei l = map2DTo3D[j]; if(j == 0) gain = conf->HFOrderGain[0] * ratio; @@ -238,7 +233,7 @@ void BFormatDec::reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate, mMatrix.Dual[chan][HF_BAND][j] = conf->HFMatrix[i][k++] / coeff_scale[l] * gain; } - for(j = 0,k = 0;j < MAX_AMBI2D_COEFFS;j++) + for(ALsizei j{0},k{0};j < MAX_AMBI2D_COEFFS;j++) { ALsizei l = map2DTo3D[j]; if(j == 0) gain = conf->LFOrderGain[0] / ratio; @@ -252,7 +247,7 @@ void BFormatDec::reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate, } else { - for(j = 0,k = 0;j < MAX_AMBI_COEFFS;j++) + for(ALsizei j{0},k{0};j < MAX_AMBI_COEFFS;j++) { if(j == 0) gain = conf->HFOrderGain[0] * ratio; else if(j == 1) gain = conf->HFOrderGain[1] * ratio; @@ -262,7 +257,7 @@ void BFormatDec::reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate, mMatrix.Dual[chan][HF_BAND][j] = conf->HFMatrix[i][k++] / coeff_scale[j] * gain; } - for(j = 0,k = 0;j < MAX_AMBI_COEFFS;j++) + for(ALsizei j{0},k{0};j < MAX_AMBI_COEFFS;j++) { if(j == 0) gain = conf->LFOrderGain[0] / ratio; else if(j == 1) gain = conf->LFOrderGain[1] / ratio; @@ -360,9 +355,8 @@ void AmbiUpsampler::reset(const ALCdevice *device, const ALfloat w_scale, const { using namespace std::placeholders; - float ratio{400.0f / (float)device->Frequency}; - std::for_each(std::begin(mXOver), std::end(mXOver), - std::bind(std::mem_fn(&BandSplitter::init), _1, ratio)); + mXOver[0].init(400.0f / (float)device->Frequency); + std::fill(std::begin(mXOver)+1, std::end(mXOver), mXOver[0]); memset(mGains, 0, sizeof(mGains)); if(device->Dry.CoeffCount > 0) |