diff options
author | Chris Robinson <[email protected]> | 2020-01-12 11:24:30 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-01-12 11:24:30 -0800 |
commit | 00d80497d8b3653448a01f82c87fe5c59d157e67 (patch) | |
tree | f4f8f6767e7ccc163d1538c26350a20004be5d02 /alc | |
parent | c182a3376a21f66d463a2bf68fcaae6918540bd9 (diff) |
Warn when resampled HRIR delays get clamped
Diffstat (limited to 'alc')
-rw-r--r-- | alc/hrtf.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/alc/hrtf.cpp b/alc/hrtf.cpp index 2ac4c539..05222c7a 100644 --- a/alc/hrtf.cpp +++ b/alc/hrtf.cpp @@ -1337,13 +1337,27 @@ HrtfStore *GetLoadedHrtf(const std::string &name, const char *devname, const ALu } rs = {}; + size_t max_clipped{0}; + uint64_t max_delay{0}; const ALuint srate{hrtf->sampleRate}; for(size_t i{0};i < irCount;++i) { for(ALubyte &delay : const_cast<ubyte2&>(hrtf->delays[i])) - delay = static_cast<ALubyte>(minu64(MAX_HRIR_DELAY*HRIR_DELAY_FRACONE, - (uint64_t{delay}*devrate + srate/2) / srate)); + { + const uint64_t new_delay{(uint64_t{delay}*devrate + srate/2) / srate}; + max_delay = maxu64(max_delay, new_delay); + if(new_delay <= MAX_HRIR_DELAY*HRIR_DELAY_FRACONE) + delay = static_cast<ALubyte>(new_delay); + else + { + ++max_clipped; + delay = MAX_HRIR_DELAY*HRIR_DELAY_FRACONE; + } + } } + if(max_clipped > 0) + WARN("%zu delay%s clamped (max: %.2f)\n", max_clipped, (max_clipped==1)?"":"s", + static_cast<double>(max_delay) / double{HRIR_DELAY_FRACONE}); /* Scale the IR size for the new sample rate and update the stored * sample rate. |