Просмотр исходного кода

Fuzz fixes: Fruity Delay Bank time product in 64-bit, Maximus saturation table index guarded against NaN/inf

Ka1-S 1 месяц назад
Родитель
Сommit
041a09247a
2 измененных файлов с 6 добавлено и 3 удалено
  1. 1 1
      src/core/FruityDelayBank.cpp
  2. 5 2
      src/core/HarmlessFx.cpp

+ 1 - 1
src/core/FruityDelayBank.cpp

@@ -741,7 +741,7 @@ struct Engine::Impl
     {
         auto& bk = bank[b];
         bk.offL = roundEven ((double) ((bk.offsetMs * (float) rateOs) / 100000.0f));
-        bk.time = (float) (p (b, 12) * rateOs);
+        bk.time = (float) ((std::int64_t) p (b, 12) * rateOs); // (64-bit: the product overflows an int at 192 kHz)
         if (bk.opt.sync)
             bk.time = (float) ((double) bk.time * 0.03125 / (double) tempo);
         else

+ 5 - 2
src/core/HarmlessFx.cpp

@@ -344,7 +344,9 @@ void buildSaturation (int thr, float ceil, double top, MaximusPreset::Band& b, b
     }
     b.sat[65537] = b.sat[65536];
     b.satOut = soundgoodizer ? f32 ((double) ceil * 3.0517578125e-05) : ceil;
-    b.satIn = f32 (1.0 / top);
+    // (post gain and ceiling both at 0 left top = 0: an infinite input scale, then 0 · inf = NaN read as a table index.
+    // Round 111: the scale stays finite; that band is silent anyway, its output scale being the ceiling 0.)
+    b.satIn = top > 0.0 ? f32 (1.0 / top) : 0.0f;
 }
 } // namespace
 
@@ -1317,9 +1319,10 @@ private:
             auto sat = [&] (float x) {
                 const auto v = (double) x * k;
                 const auto a = std::fabs (v);
+                if (! (a < 65536.0)) // (also NaN / inf: never an index outside the table)
+                    return (float) ((v < 0.0 ? -(double) t[65536] : (double) t[65536]) * (double) S.satOut);
                 auto i = (long long) a;
                 const auto fr = a - (double) i;
-                i = std::min<long long> (i, 65536);
                 const auto y = (double) t[i] + ((double) t[i + 1] - (double) t[i]) * fr;
                 return (float) ((v < 0.0 ? -y : y) * (double) S.satOut);
             };