Explorar o código

Hush De-esser classic (DeEsser role): BandPass states translated, BandPass = high-pass + 4th-order low-pass (measured), 25.6 dB floor, no latency

Ka1-S hai 1 mes
pai
achega
4e7dffd904

+ 6 - 4
src/core/MixSuite.cpp

@@ -944,6 +944,8 @@ public:
     {
     {
         if (vocalOn)
         if (vocalOn)
             return vocalEngine.latencySamples();
             return vocalEngine.latencySamples();
+        if (classicOn) // round 165 [EXEC]: the reference reports 0 samples, so the classic voicing has no latency
+            return 0;
         return delay.len + (osFactor > 1 ? Oversampler::latency() : 0);
         return delay.len + (osFactor > 1 ? Oversampler::latency() : 0);
     }
     }
     float controlOutput (int k) const noexcept override { return meters.read (k); }
     float controlOutput (int k) const noexcept override { return meters.read (k); }
@@ -1009,9 +1011,10 @@ private:
             scL = scR = nullptr;
             scL = scR = nullptr;
             return;
             return;
         }
         }
-        if (classic (p))
+        classicOn = classic (p);
+        if (classicOn)
         {
         {
-            // the measured classic de-esser has no look-ahead; the fixed latency Hush reports is kept as a plain delay
+            // the measured classic de-esser has no look-ahead and (round 165) no latency, as the reference
             vmatch::deesser::Settings c;
             vmatch::deesser::Settings c;
             c.hz = hz (p[frequency]);
             c.hz = hz (p[frequency]);
             c.thresholdDb = classicThresholdDb (p[threshold]);
             c.thresholdDb = classicThresholdDb (p[threshold]);
@@ -1020,8 +1023,6 @@ private:
             c.listen = on (p[listen]);
             c.listen = on (p[listen]);
             c.outputDb = lin (p[output], -12.0, 12.0);
             c.outputDb = lin (p[output], -12.0, 12.0);
             classicEngine.process (l, r, n, c);
             classicEngine.process (l, r, n, c);
-            for (int i = 0; i < n; ++i)
-                delay.process (l[i], r[i]);
             meters.set (classicEngine.reductionDb(), 0.0f, inPeak, Meters::peak (l, r, n));
             meters.set (classicEngine.reductionDb(), 0.0f, inPeak, Meters::peak (l, r, n));
             meters.setDetector (classicEngine.detectorDb());
             meters.setDetector (classicEngine.detectorDb());
             return;
             return;
@@ -1236,6 +1237,7 @@ private:
     vmatch::deesser::DeEsser classicEngine;
     vmatch::deesser::DeEsser classicEngine;
     vmatch::vocalds::DeEsser vocalEngine;
     vmatch::vocalds::DeEsser vocalEngine;
     bool vocalOn = false;
     bool vocalOn = false;
+    bool classicOn = false; // round 165: the classic voicing has no latency
     Biquad detect, detectLp, listenF, listenLp, split, bandLp, bandLp2, topHp, topHp2;
     Biquad detect, detectLp, listenF, listenLp, split, bandLp, bandLp2, topHp, topHp2;
     double env = 0.0, gr = 0.0, fullEnv = 0.0;
     double env = 0.0, gr = 0.0, fullEnv = 0.0;
     double envCh[2] {}, grCh[2] {};
     double envCh[2] {}, grCh[2] {};

+ 3 - 1
src/core/PluginSubstitutes.cpp

@@ -1387,7 +1387,9 @@ int translateWavesDeEsser (const std::vector<std::uint8_t>& state, EffectSlot& s
     if (const auto m = wavesValue (rw, 14))
     if (const auto m = wavesValue (rw, 14))
         slot.params[h::mode] = *m >= 0.5 ? 1.0f : 0.0f, ++n;
         slot.params[h::mode] = *m >= 0.5 ? 1.0f : 0.0f, ++n;
     if (const auto d = wavesValue (rw, 13))
     if (const auto d = wavesValue (rw, 13))
-        slot.params[h::detector] = *d >= 1.5 ? 1.0f : 0.0f, ++n;
+        // round 165 [EXEC]: the 17.1 trial stores HighPass 1 / BandPass 0 (band-pass states were read as high-pass); 2 =
+        // band-pass as before
+        slot.params[h::detector] = (*d < 0.5 || *d >= 1.5) ? 1.0f : 0.0f, ++n;
     if (const auto l = wavesValue (rw, 10))
     if (const auto l = wavesValue (rw, 10))
         slot.params[h::listen] = *l >= 0.5 ? 1.0f : 0.0f, ++n;
         slot.params[h::listen] = *l >= 0.5 ? 1.0f : 0.0f, ++n;
     return n;
     return n;

+ 21 - 5
src/core/VoiceMatch.cpp

@@ -761,12 +761,19 @@ namespace deesser
 namespace
 namespace
 {
 {
 constexpr double thrOffset = -0.6009, thrSlope = -0.0097, ratio = 7.1171, knee = 1.2597, attackMs = 0.3027, releaseMs = 12.1503;
 constexpr double thrOffset = -0.6009, thrSlope = -0.0097, ratio = 7.1171, knee = 1.2597, attackMs = 0.3027, releaseMs = 12.1503;
-constexpr double splitK = 0.3306, splitExp = 0.0491, scK = 1.0120, scExp = -0.0353, bpQ = 1.2988, bpOffset = 3.9011;
+constexpr double splitK = 0.3306, splitExp = 0.0491, scK = 1.0120, scExp = -0.0353;
+// round 165 [EXEC] (DeEsser 17.1 trial, tone stairs, thresholds −10 … −60): the reduction stops at 25.6 dB (wide band);
+// BandPass is the HighPass side chain followed by a 4th-order low-pass (two 2nd-order sections, Q 0.68) at 1.8435 x the
+// frequency (x (f / 5506)^-0.139: 1.75 x at 8 kHz: 9 … 14 kHz within 0.2 dB, 2 dB at 16 kHz): the trial's BandPass needs 0.3 / 0.7 / 1.8 / 4.4 / 11.9 dB more than its HighPass at 4.5 / 5.5 / 7 / 9 /
+// 12 kHz (dial 5506 Hz), this low-pass 0.06 dB rms from that (round 123's band-pass, Q 1.3 + 3.9 dB, was up to 8 dB off,
+// and the translator read every BandPass state as HighPass)
+constexpr double maxReductionDb = 25.6, bpLpK = 1.8435, bpLpExp = -0.139, bpLpQ = 0.68;
 
 
 void rbj (Biquad& b, int type, double f, double q, double sr) noexcept
 void rbj (Biquad& b, int type, double f, double q, double sr) noexcept
 {
 {
     const double w = 2.0 * pi * std::min (f, sr * 0.49) / sr, cw = std::cos (w), al = std::sin (w) / (2.0 * q);
     const double w = 2.0 * pi * std::min (f, sr * 0.49) / sr, cw = std::cos (w), al = std::sin (w) / (2.0 * q);
     if (type == 0) b.set ((1 + cw) / 2, -(1 + cw), (1 + cw) / 2, 1 + al, -2 * cw, 1 - al); // high-pass
     if (type == 0) b.set ((1 + cw) / 2, -(1 + cw), (1 + cw) / 2, 1 + al, -2 * cw, 1 - al); // high-pass
+    else if (type == 2) b.set ((1 - cw) / 2, 1 - cw, (1 - cw) / 2, 1 + al, -2 * cw, 1 - al); // low-pass
     else b.set (al, 0.0, -al, 1 + al, -2 * cw, 1 - al);                                     // band-pass (0 dB peak)
     else b.set (al, 0.0, -al, 1 + al, -2 * cw, 1 - al);                                     // band-pass (0 dB peak)
 }
 }
 } // namespace
 } // namespace
@@ -782,6 +789,8 @@ void DeEsser::reset() noexcept
 {
 {
     sc1.reset();
     sc1.reset();
     sc2.reset();
     sc2.reset();
+    bp1.reset();
+    bp2.reset();
     lpX[0] = lpX[1] = lpY[0] = lpY[1] = 0.0;
     lpX[0] = lpX[1] = lpY[0] = lpY[1] = 0.0;
     env = gr = 0.0;
     env = gr = 0.0;
 }
 }
@@ -795,8 +804,10 @@ void DeEsser::design (const Settings& s) noexcept
     designedBp = s.bandPass;
     designedBp = s.bandPass;
     const double rel = f / 5506.0;
     const double rel = f / 5506.0;
     const double fsc = f * scK * std::pow (rel, scExp);
     const double fsc = f * scK * std::pow (rel, scExp);
-    rbj (sc1, s.bandPass ? 1 : 0, fsc, s.bandPass ? bpQ : 0.70710678, sr);
+    rbj (sc1, 0, fsc, 0.70710678, sr);
     sc2.b0 = sc1.b0; sc2.b1 = sc1.b1; sc2.b2 = sc1.b2; sc2.a1 = sc1.a1; sc2.a2 = sc1.a2;
     sc2.b0 = sc1.b0; sc2.b1 = sc1.b1; sc2.b2 = sc1.b2; sc2.a1 = sc1.a1; sc2.a2 = sc1.a2;
+    rbj (bp1, 2, f * bpLpK * std::pow (rel, bpLpExp), bpLpQ, sr);
+    bp2.b0 = bp1.b0; bp2.b1 = bp1.b1; bp2.b2 = bp1.b2; bp2.a1 = bp1.a1; bp2.a2 = bp1.a2;
     const double k = std::tan (pi * std::min (f * splitK * std::pow (rel, splitExp), 0.45 * sr) / sr);
     const double k = std::tan (pi * std::min (f * splitK * std::pow (rel, splitExp), 0.45 * sr) / sr);
     lpB = k / (1.0 + k);
     lpB = k / (1.0 + k);
     lpA = (k - 1.0) / (k + 1.0);
     lpA = (k - 1.0) / (k + 1.0);
@@ -806,17 +817,22 @@ void DeEsser::process (float* l, float* r, int n, const Settings& s) noexcept
 {
 {
     design (s);
     design (s);
     const double T = std::clamp (s.thresholdDb, -80.0, 0.0);
     const double T = std::clamp (s.thresholdDb, -80.0, 0.0);
-    const double thr = T + thrOffset + thrSlope * (T + 24.2) + (s.bandPass ? bpOffset : 0.0);
+    const double thr = T + thrOffset + thrSlope * (T + 24.2);
     const double aA = coefMs (attackMs, sr), aR = coefMs (releaseMs, sr), out = dbToGain (s.outputDb);
     const double aA = coefMs (attackMs, sr), aR = coefMs (releaseMs, sr), out = dbToGain (s.outputDb);
     double maxGr = 0.0, maxO = -200.0;
     double maxGr = 0.0, maxO = -200.0;
     for (int i = 0; i < n; ++i)
     for (int i = 0; i < n; ++i)
     {
     {
-        const double a = sc2.process (sc1.process (l[i], 0), 0), b = sc2.process (sc1.process (r[i], 1), 1);
+        double a = sc2.process (sc1.process (l[i], 0), 0), b = sc2.process (sc1.process (r[i], 1), 1);
+        if (s.bandPass)
+        {
+            a = bp2.process (bp1.process ((float) a, 0), 0);
+            b = bp2.process (bp1.process ((float) b, 1), 1);
+        }
         const double p = 0.5 * (a * a + b * b);
         const double p = 0.5 * (a * a + b * b);
         env += (p > env ? aA : aR) * (p - env);
         env += (p > env ? aA : aR) * (p - env);
         const double o = 10.0 * std::log10 (std::max (env, 1e-24)) - thr;
         const double o = 10.0 * std::log10 (std::max (env, 1e-24)) - thr;
         maxO = std::max (maxO, o);
         maxO = std::max (maxO, o);
-        gr = (1.0 - 1.0 / ratio) * (o > 30.0 * knee ? o : knee * std::log1p (std::exp (o / knee)));
+        gr = std::min (maxReductionDb, (1.0 - 1.0 / ratio) * (o > 30.0 * knee ? o : knee * std::log1p (std::exp (o / knee))));
         const double g = dbToGain (-gr);
         const double g = dbToGain (-gr);
         maxGr = std::max (maxGr, gr);
         maxGr = std::max (maxGr, gr);
         if (s.listen)
         if (s.listen)

+ 1 - 1
src/core/VoiceMatch.h

@@ -123,7 +123,7 @@ private:
     double sr = 48000.0, designedHz = -1.0;
     double sr = 48000.0, designedHz = -1.0;
     float lastDet = -120.0f;
     float lastDet = -120.0f;
     bool designedBp = false;
     bool designedBp = false;
-    Biquad sc1, sc2;
+    Biquad sc1, sc2, bp1, bp2; // round 165: bp1 / bp2 = BandPass's low-pass after the high-pass
     double lpB = 0.0, lpA = 0.0, lpX[2] {}, lpY[2] {};
     double lpB = 0.0, lpA = 0.0, lpX[2] {}, lpY[2] {};
     double env = 0.0, gr = 0.0;
     double env = 0.0, gr = 0.0;
     float last = 0.0f;
     float last = 0.0f;

+ 33 - 0
tests/Parity165Tests.inc

@@ -68,3 +68,36 @@ TEST (ridge_e_channel_eq_to_sidechain_round165)
     own.params[r::eqToSidechain] = 1.0f;
     own.params[r::eqToSidechain] = 1.0f;
     CHECK (std::abs (vm123::sineGainDb (own, 8000.0, -30.0)) < 0.3);
     CHECK (std::abs (vm123::sineGainDb (own, 8000.0, -30.0)) < 0.3);
 }
 }
+
+// round 165h §2: Hush De-esser's classic voicing ← Waves DeEsser (17.1 trial, black-box): BandPass states translated
+// (17.1 stores HighPass 1 / BandPass 0), BandPass = the high-pass side chain + a 4th-order low-pass, the wide-band
+// reduction stops at 25.6 dB, no latency
+TEST (hush_classic_deesser_bandpass_and_floor_round165)
+{
+    using namespace lynx;
+    namespace h = mixsuite::hush;
+    int n = 0;
+    auto bp = vm123::wavesSlot ("DeEsser", "5506 2 -30 7 0.5 10 * * * * 0 3.98 32 0 1", n);
+    auto hp = vm123::wavesSlot ("DeEsser", "5506 2 -30 7 0.5 10 * * * * 0 3.98 32 1 1", n);
+    CHECK (bp.params[h::detector] == 1.0f && hp.params[h::detector] == 0.0f && bp.params[h::mode] == 1.0f);
+    // [EXEC] the trial at 9 kHz (wide band, threshold −30): −20 / −10 / 0 dBFS in → BandPass −3.93 / −12.52 / −21.09 dB,
+    // HighPass −7.70 / −16.29 / −24.87 dB
+    static constexpr double want[][3] = { { -20, -3.93, -7.70 }, { -10, -12.52, -16.29 }, { 0, -21.09, -24.87 } };
+    for (const auto& w : want)
+    {
+        const auto gb = vm123::sineGainDb (bp, 9000.0, w[0]), gh = vm123::sineGainDb (hp, 9000.0, w[0]);
+        std::printf ("  DeEsser 9 kHz at %.0f dBFS: band-pass %.2f (trial %.2f), high-pass %.2f (trial %.2f)\n", w[0], gb, w[1], gh, w[2]);
+        CHECK (std::abs (gb - w[1]) < 0.7 && std::abs (gh - w[2]) < 0.7);
+    }
+    // the wide-band floor: threshold −60, 7 kHz at −10 dBFS → −25.57 dB on the trial (round 123's model: −40 dB)
+    auto deep = vm123::wavesSlot ("DeEsser", "5506 2 -60 7 0.5 10 * * * * 0 3.98 32 0 1", n);
+    const auto g = vm123::sineGainDb (deep, 7000.0, -10.0);
+    std::printf ("  DeEsser floor: %.2f dB (trial -25.57)\n", g);
+    CHECK (std::abs (g + 25.57) < 0.3);
+    // no latency, as the reference
+    auto fx = makeEffect (deep);
+    fx->prepare (48000.0);
+    std::vector<float> l (512, 0.0f), r (512, 0.0f);
+    fx->process (l.data(), r.data(), 512, deep.params, 120.0);
+    CHECK (fx->latencySamples() == 0);
+}