diff options
-rw-r--r-- | alc/alu.cpp | 4 | ||||
-rw-r--r-- | core/bsinc_tables.cpp | 13 |
2 files changed, 8 insertions, 9 deletions
diff --git a/alc/alu.cpp b/alc/alu.cpp index deffaad1..8f056e7c 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -182,8 +182,8 @@ inline void BsincPrepare(const uint increment, BsincState *state, const BSincTab if(increment > MixerFracOne) { - sf = MixerFracOne / static_cast<float>(increment); - sf = maxf(0.0f, (BSincScaleCount-1) * (sf-table->scaleBase) * table->scaleRange); + sf = MixerFracOne/static_cast<float>(increment) - table->scaleBase; + sf = maxf(0.0f, BSincScaleCount*sf*table->scaleRange - 1.0f); si = float2uint(sf); /* The interpolation factor is fit to this diagonally-symmetric curve * to reduce the transition ripple caused by interpolating different diff --git a/core/bsinc_tables.cpp b/core/bsinc_tables.cpp index cfd9a046..8f375ac2 100644 --- a/core/bsinc_tables.cpp +++ b/core/bsinc_tables.cpp @@ -123,7 +123,7 @@ struct BSincHeader { uint num_points{Order+1}; for(uint si{0};si < BSincScaleCount;++si) { - const double scale{scaleBase + (scaleRange * si / (BSincScaleCount-1))}; + const double scale{scaleBase + (scaleRange * (si+1) / BSincScaleCount)}; const uint a_{std::min(static_cast<uint>(num_points / 2.0 / scale), num_points)}; const uint m{2 * a_}; @@ -162,14 +162,13 @@ struct BSincFilterArray { auto filter = std::make_unique<filter_type>(BSincScaleCount); /* Calculate the Kaiser-windowed Sinc filter coefficients for each - * scale and phase index. The output of scale index 0 is all 0s, so - * start at 1. + * scale and phase index. */ - for(uint si{1};si < BSincScaleCount;++si) + for(uint si{0};si < BSincScaleCount;++si) { const uint m{hdr.a[si] * 2}; const size_t o{(BSincPointsMax-m) / 2}; - const double scale{hdr.scaleBase + (hdr.scaleRange * si / (BSincScaleCount-1))}; + const double scale{hdr.scaleBase + (hdr.scaleRange * (si+1) / BSincScaleCount)}; const double cutoff{scale - (hdr.scaleBase * std::max(0.5, scale) * 2.0)}; const auto a = static_cast<double>(hdr.a[si]); const double l{a - 1.0}; @@ -236,8 +235,8 @@ struct BSincFilterArray { } /* This last simplification is done to complete the bilinear - * equation for the combination of phase and scale. - */ + * equation for the combination of phase and scale. + */ for(size_t i{0};i < m;++i) { const double spDelta{(filter[si+1][pi+1][o+i] - filter[si+1][pi][o+i]) - |