diff options
author | Chris Robinson <[email protected]> | 2019-01-07 21:10:32 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-01-08 17:21:22 -0800 |
commit | 0c3662d8b2c82de02f1624c310803def9ddd25ab (patch) | |
tree | 8fc528a37c185150b75ac0c4fd1d278ee85d3751 | |
parent | 009d738c1e7e84e662d629c7e96b3fcc08adc17d (diff) |
Fix some comments and reduce indentation
-rw-r--r-- | Alc/hrtf.cpp | 67 |
1 files changed, 32 insertions, 35 deletions
diff --git a/Alc/hrtf.cpp b/Alc/hrtf.cpp index 4d1c27ee..ff9e2f79 100644 --- a/Alc/hrtf.cpp +++ b/Alc/hrtf.cpp @@ -327,9 +327,11 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALsiz if(!DualBand) { + /* For single-band decoding, apply the HF scale to the response. */ for(ALsizei i{0};i < NumChannels;++i) { - const ALdouble mult{static_cast<ALdouble>(AmbiOrderHFGain[OrderFromChan[i]]) * AmbiMatrix[c][i]}; + const ALdouble mult{ALdouble{AmbiOrderHFGain[OrderFromChan[i]]} * + AmbiMatrix[c][i]}; const ALsizei numirs{mini(Hrtf->irSize, HRIR_LENGTH-maxi(ldelay, rdelay))}; ALsizei lidx{ldelay}, ridx{rdelay}; for(ALsizei j{0};j < numirs;++j) @@ -338,44 +340,39 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALsiz tmpres[i][ridx++][1] += fir[j][1] * mult; } } + continue; } - else + + /* Split the left HRIR into low and high frequency bands. */ + auto tmpfilt_iter = std::transform(fir, fir+Hrtf->irSize, tmpfilt[2].begin(), + [](const ALfloat (&ir)[2]) noexcept { return ir[0]; }); + std::fill(tmpfilt_iter, tmpfilt[2].end(), 0.0); + splitter.clear(); + splitter.process(tmpfilt[0].data(), tmpfilt[1].data(), tmpfilt[2].data(), HRIR_LENGTH); + + /* Apply left ear response with delay and HF scale. */ + for(ALsizei i{0};i < NumChannels;++i) { - /* Extract the left HRIR and increase its per-order high-frequency - * response. - */ - auto tmpfilt_iter = std::transform(fir, fir+Hrtf->irSize, tmpfilt.back().begin(), - [](const ALfloat (&ir)[2]) noexcept { return ir[0]; }); - std::fill(tmpfilt_iter, tmpfilt.back().end(), 0.0); - splitter.clear(); - splitter.process(tmpfilt[0].data(), tmpfilt[1].data(), tmpfilt[2].data(), HRIR_LENGTH); - - /* Apply left ear response with delay. */ - for(ALsizei i{0};i < NumChannels;++i) - { - const ALdouble mult{AmbiMatrix[c][i]}; - const ALdouble hfgain{AmbiOrderHFGain[OrderFromChan[i]]}; - for(ALsizei lidx{ldelay},j{0};lidx < HRIR_LENGTH;++lidx,++j) - tmpres[i][lidx][0] += (tmpfilt[0][j]*hfgain + tmpfilt[1][j]) * mult; - } + const ALdouble mult{AmbiMatrix[c][i]}; + const ALdouble hfgain{AmbiOrderHFGain[OrderFromChan[i]]}; + for(ALsizei lidx{ldelay},j{0};lidx < HRIR_LENGTH;++lidx,++j) + tmpres[i][lidx][0] += (tmpfilt[0][j]*hfgain + tmpfilt[1][j]) * mult; + } - /* Extract the right HRIR and increase its per-order high-frequency - * response. - */ - tmpfilt_iter = std::transform(fir, fir+Hrtf->irSize, tmpfilt.back().begin(), - [](const ALfloat (&ir)[2]) noexcept { return ir[1]; }); - std::fill(tmpfilt_iter, tmpfilt.back().end(), 0.0); - splitter.clear(); - splitter.process(tmpfilt[0].data(), tmpfilt[1].data(), tmpfilt[2].data(), HRIR_LENGTH); + /* Split the right HRIR into low and high frequency bands. */ + tmpfilt_iter = std::transform(fir, fir+Hrtf->irSize, tmpfilt[2].begin(), + [](const ALfloat (&ir)[2]) noexcept { return ir[1]; }); + std::fill(tmpfilt_iter, tmpfilt[2].end(), 0.0); + splitter.clear(); + splitter.process(tmpfilt[0].data(), tmpfilt[1].data(), tmpfilt[2].data(), HRIR_LENGTH); - /* Apply right ear response with delay. */ - for(ALsizei i{0};i < NumChannels;++i) - { - const ALdouble mult{AmbiMatrix[c][i]}; - const ALdouble hfgain{AmbiOrderHFGain[OrderFromChan[i]]}; - for(ALsizei ridx{rdelay},j{0};ridx < HRIR_LENGTH;++ridx,++j) - tmpres[i][ridx][1] += (tmpfilt[0][j]*hfgain + tmpfilt[1][j]) * mult; - } + /* Apply right ear response with delay and HF scale. */ + for(ALsizei i{0};i < NumChannels;++i) + { + const ALdouble mult{AmbiMatrix[c][i]}; + const ALdouble hfgain{AmbiOrderHFGain[OrderFromChan[i]]}; + for(ALsizei ridx{rdelay},j{0};ridx < HRIR_LENGTH;++ridx,++j) + tmpres[i][ridx][1] += (tmpfilt[0][j]*hfgain + tmpfilt[1][j]) * mult; } } tmpfilt.clear(); |