aboutsummaryrefslogtreecommitdiffstats
path: root/alc/hrtf.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'alc/hrtf.cpp')
-rw-r--r--alc/hrtf.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/alc/hrtf.cpp b/alc/hrtf.cpp
index 26e08cba..89e07efc 100644
--- a/alc/hrtf.cpp
+++ b/alc/hrtf.cpp
@@ -295,7 +295,15 @@ void DirectHrtfState::build(const HrtfStore *Hrtf, const al::span<const AngularP
* calculation of the new IR length to deal with the head and tail
* generated by the HF scaling.
*/
- static constexpr bool DualBand{true};
+ constexpr bool DualBand{false};
+ const double xover_norm{400.0 / Hrtf->sampleRate};
+
+ for(size_t i{0};i < mChannels.size();++i)
+ {
+ const size_t order{AmbiIndex::OrderFromChannel[i]};
+ mChannels[i].mSplitter.init(static_cast<float>(xover_norm));
+ mChannels[i].mHfScale = AmbiOrderHFGain[order];
+ }
ALuint min_delay{HRTF_HISTORY_LENGTH*HRIR_DELAY_FRACONE};
ALuint max_delay{0};
@@ -342,11 +350,10 @@ void DirectHrtfState::build(const HrtfStore *Hrtf, const al::span<const AngularP
/* For dual-band processing, add a 16-sample delay to compensate for the HF
* scale on the minimum-phase response.
*/
- static constexpr ALuint base_delay{DualBand ? 16 : 0};
- const double xover_norm{400.0 / Hrtf->sampleRate};
+ constexpr ALuint base_delay{DualBand ? 16 : 0};
BandSplitterR<double> splitter{xover_norm};
- auto tmpres = al::vector<std::array<double2,HRIR_LENGTH>>(mCoeffs.size());
+ auto tmpres = al::vector<std::array<double2,HRIR_LENGTH>>(mChannels.size());
auto tmpflt = al::vector<std::array<double,HRIR_LENGTH*4>>(3);
const al::span<double,HRIR_LENGTH*4> tempir{tmpflt[2]};
for(size_t c{0u};c < AmbiPoints.size();++c)
@@ -357,11 +364,9 @@ void DirectHrtfState::build(const HrtfStore *Hrtf, const al::span<const AngularP
if /*constexpr*/(!DualBand)
{
- /* For single-band decoding, apply the HF scale to the response. */
- for(size_t i{0u};i < mCoeffs.size();++i)
+ for(size_t i{0u};i < mChannels.size();++i)
{
- const size_t order{AmbiIndex::OrderFromChannel[i]};
- const double mult{double{AmbiOrderHFGain[order]} * AmbiMatrix[c][i]};
+ const double mult{AmbiMatrix[c][i]};
const ALuint numirs{HRIR_LENGTH - maxu(ldelay, rdelay)};
ALuint lidx{ldelay}, ridx{rdelay};
for(ALuint j{0};j < numirs;++j)
@@ -399,7 +404,7 @@ void DirectHrtfState::build(const HrtfStore *Hrtf, const al::span<const AngularP
splitter.process(tempir, tmpflt[0].data(), tmpflt[1].data());
/* Apply left ear response with delay and HF scale. */
- for(size_t i{0u};i < mCoeffs.size();++i)
+ for(size_t i{0u};i < mChannels.size();++i)
{
const double mult{AmbiMatrix[c][i]};
const double hfgain{AmbiOrderHFGain[AmbiIndex::OrderFromChannel[i]]};
@@ -419,7 +424,7 @@ void DirectHrtfState::build(const HrtfStore *Hrtf, const al::span<const AngularP
splitter.clear();
splitter.process(tempir, tmpflt[0].data(), tmpflt[1].data());
- for(size_t i{0u};i < mCoeffs.size();++i)
+ for(size_t i{0u};i < mChannels.size();++i)
{
const double mult{AmbiMatrix[c][i]};
const double hfgain{AmbiOrderHFGain[AmbiIndex::OrderFromChannel[i]]};
@@ -431,11 +436,12 @@ void DirectHrtfState::build(const HrtfStore *Hrtf, const al::span<const AngularP
tmpflt.clear();
impres.clear();
- for(size_t i{0u};i < mCoeffs.size();++i)
+ for(size_t i{0u};i < mChannels.size();++i)
{
auto copy_arr = [](const double2 &in) noexcept -> float2
{ return float2{{static_cast<float>(in[0]), static_cast<float>(in[1])}}; };
- std::transform(tmpres[i].cbegin(), tmpres[i].cend(), mCoeffs[i].begin(), copy_arr);
+ std::transform(tmpres[i].cbegin(), tmpres[i].cend(), mChannels[i].mCoeffs.begin(),
+ copy_arr);
}
tmpres.clear();