diff options
Diffstat (limited to 'Alc/hrtf.cpp')
-rw-r--r-- | Alc/hrtf.cpp | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/Alc/hrtf.cpp b/Alc/hrtf.cpp index 44cf3d74..96d5ec43 100644 --- a/Alc/hrtf.cpp +++ b/Alc/hrtf.cpp @@ -206,7 +206,7 @@ IdxBlend CalcAzIndex(ALsizei azcount, ALfloat az) * and azimuth in radians. The coefficients are normalized. */ void GetHrtfCoeffs(const HrtfEntry *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat distance, - ALfloat spread, ALfloat (*RESTRICT coeffs)[2], ALsizei *delays) + ALfloat spread, HrirArray<ALfloat> &coeffs, ALsizei *delays) { const ALfloat dirfact{1.0f - (spread / al::MathDefs<float>::Tau())}; @@ -273,7 +273,7 @@ void GetHrtfCoeffs(const HrtfEntry *Hrtf, ALfloat elevation, ALfloat azimuth, AL idx[3] *= irSize; /* Calculate the blended HRIR coefficients. */ - ALfloat *coeffout{al::assume_aligned<16>(coeffs[0])}; + ALfloat *coeffout{al::assume_aligned<16>(&coeffs[0][0])}; coeffout[0] = PassthruCoeff * (1.0f-dirfact); coeffout[1] = PassthruCoeff * (1.0f-dirfact); std::fill(coeffout+2, coeffout + irSize*2, 0.0f); @@ -343,8 +343,8 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALsiz BandSplitterR<double> splitter; splitter.init(xover_norm); - al::vector<std::array<std::array<ALdouble,2>,HRIR_LENGTH>> tmpres(NumChannels); - al::vector<std::array<ALdouble,HRIR_LENGTH>> tmpfilt(3); + auto tmpres = al::vector<HrirArray<ALdouble>>(NumChannels); + auto tmpfilt = al::vector<std::array<ALdouble,HRIR_LENGTH>>(3); for(ALsizei c{0};c < AmbiCount;++c) { const ALfloat (*fir)[2]{&Hrtf->coeffs[idx[c] * Hrtf->irSize]}; @@ -402,29 +402,24 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALsiz } } tmpfilt.clear(); + idx.clear(); for(ALsizei i{0};i < NumChannels;++i) { - for(ALsizei idx{0};idx < HRIR_LENGTH;idx++) - { - state->Chan[i].Coeffs[idx][0] = static_cast<ALfloat>(tmpres[i][idx][0]); - state->Chan[i].Coeffs[idx][1] = static_cast<ALfloat>(tmpres[i][idx][1]); - } + auto copy_arr = [](const std::array<double,2> &in) noexcept -> std::array<float,2> + { return std::array<float,2>{{static_cast<float>(in[0]), static_cast<float>(in[1])}}; }; + std::transform(tmpres[i].begin(), tmpres[i].end(), state->Chan[i].Coeffs.begin(), + copy_arr); } tmpres.clear(); - idx.clear(); - ALsizei max_length; - if(!DualBand) - max_length = mini(max_delay-min_delay + Hrtf->irSize, HRIR_LENGTH); - else - { - /* Increase the IR size by 2/3rds to account for the tail generated by - * the filter. - */ - const ALsizei irsize = mini(Hrtf->irSize*5/3, HRIR_LENGTH); - max_length = mini(max_delay-min_delay + irsize, HRIR_LENGTH); - } + ALsizei max_length{HRIR_LENGTH}; + /* Increase the IR size by 2/3rds with dual-band processing to account for + * the tail generated by the filter. + */ + const ALsizei irsize{DualBand ? mini(Hrtf->irSize*5/3, max_length) : Hrtf->irSize}; + max_length = mini(max_delay-min_delay + irsize, max_length); + /* Round up to the next IR size multiple. */ max_length += MOD_IR_SIZE-1; max_length -= max_length%MOD_IR_SIZE; |