fix accidental level wrap; compensate for amplitude loss

master
zetaPRIME 2021-11-11 02:09:52 -05:00
parent 651daf5e4a
commit eb40b74234
2 changed files with 3 additions and 2 deletions

View File

@ -56,7 +56,8 @@ const std::array<std::array<std::array<double, LUT_TAPS>, LUT_LEVELS>, LUT_STEPS
for (size_t i = 0; i < LUT_LEVELS; i++) {
double m = 1.0/std::max(static_cast<double>(i), 1.0); // sinc function "expands" the higher we pitch things
double om = m * lerp(1.0, kaiser, std::pow(m, 0.333)); // apply kaiser proportionally; we want it less the higher we go
double om = lerp(0.2, 1.0, m) // we need to compensate slightly for amplitude loss at higher levels
/* */ * lerp(1.0, kaiser, std::pow(m, 0.333)); // apply kaiser proportionally; we want it less the higher we go
t[step][i][tap] = sinc(sx*m) * om;
if (t[step][i][tap] != t[step][i][tap]) t[step][i][tap] = 0; // NaN guard
}

View File

@ -22,7 +22,7 @@ namespace Xybrid::NodeLib {
auto ll = le - ls;
double ip = std::floor(pos);
auto& pt = NodeLib::resamplerLUT[static_cast<size_t>((pos - ip)*NodeLib::LUT_STEPS) % NodeLib::LUT_STEPS][static_cast<size_t>(std::clamp(std::floor(rate - 0.00001), 0.0, LUT_LEVELS*1.0))];
auto& pt = NodeLib::resamplerLUT[static_cast<size_t>((pos - ip)*NodeLib::LUT_STEPS) % NodeLib::LUT_STEPS][static_cast<size_t>(std::clamp(std::floor(rate - 0.00001), 0.0, (LUT_LEVELS-1)*1.0))];
Data::AudioFrame out(0.0);