diff options
author | Chris Robinson <[email protected]> | 2019-11-28 14:51:45 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-11-28 14:51:45 -0800 |
commit | 846a9979567ac9033ccb5ca96f683b21555b2708 (patch) | |
tree | 6d856139e396aa2714ff75336ac495225a76d811 /alc/hrtf.cpp | |
parent | 4eb9a0b835dda89a833d9f9d00ed94f46b471e9f (diff) |
Add an option to limit the HRTF's IR size
Diffstat (limited to 'alc/hrtf.cpp')
-rw-r--r-- | alc/hrtf.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/alc/hrtf.cpp b/alc/hrtf.cpp index f8df522b..1b3c47e3 100644 --- a/alc/hrtf.cpp +++ b/alc/hrtf.cpp @@ -342,9 +342,6 @@ void BuildBFormatHrtf(const HrtfStore *Hrtf, DirectHrtfState *state, Hrtf->delays[idx[0]][1]*blend[0] + Hrtf->delays[idx[1]][1]*blend[1] + Hrtf->delays[idx[2]][1]*blend[2] + Hrtf->delays[idx[3]][1]*blend[3]); - const size_t irSize{Hrtf->irSize}; - ASSUME(irSize >= MIN_IR_SIZE); - /* Calculate the blended HRIR coefficients. */ double *coeffout{al::assume_aligned<16>(&res.hrir[0][0])}; std::fill(coeffout, coeffout + HRIR_LENGTH*2, 0.0); @@ -1264,7 +1261,7 @@ al::vector<std::string> EnumerateHrtf(const char *devname) return list; } -HrtfStore *GetLoadedHrtf(const std::string &name, ALuint devrate) +HrtfStore *GetLoadedHrtf(const std::string &name, const char *devname, const ALuint devrate) { std::lock_guard<std::mutex> _{EnumeratedHrtfLock}; auto entry_iter = std::find_if(EnumeratedHrtfs.cbegin(), EnumeratedHrtfs.cend(), @@ -1362,9 +1359,9 @@ HrtfStore *GetLoadedHrtf(const std::string &name, ALuint devrate) rs.init(hrtf->sampleRate, devrate); for(size_t i{0};i < irCount;++i) { + HrirArray &coeffs = const_cast<HrirArray&>(hrtf->coeffs[i]); for(size_t j{0};j < 2;++j) { - HrirArray &coeffs = const_cast<HrirArray&>(hrtf->coeffs[i]); std::transform(coeffs.cbegin(), coeffs.cend(), inout[0].begin(), [j](const float2 &in) noexcept -> double { return in[j]; }); rs.process(HRIR_LENGTH, inout[0].data(), HRIR_LENGTH, inout[1].data()); @@ -1383,6 +1380,15 @@ HrtfStore *GetLoadedHrtf(const std::string &name, ALuint devrate) hrtf->sampleRate = devrate; } + if(auto hrtfsizeopt = ConfigValueUInt(devname, nullptr, "hrtf-size")) + { + if(*hrtfsizeopt > 0 && *hrtfsizeopt < hrtf->irSize) + { + hrtf->irSize = maxu(*hrtfsizeopt, MIN_IR_SIZE); + hrtf->irSize -= hrtf->irSize % MOD_IR_SIZE; + } + } + TRACE("Loaded HRTF %s for sample rate %uhz, %u-sample filter\n", name.c_str(), hrtf->sampleRate, hrtf->irSize); LoadedHrtfs.emplace_back(LoadedHrtf{fname, std::move(hrtf)}); |