Explorar o código

WIP 190lf-dyn (untested, saved after the 04:56 crash)

Ka1-S hai 2 semanas
pai
achega
e8ce16dcaf

+ 57 - 0
docs/analise/REA_rodada190lf_dyn.md

@@ -0,0 +1,57 @@
+# REA round 190lf, sub-round "dyn" — Waves CLA-2A → Glow Leveler's cell law, CLA-76 leftovers
+
+Scope (brief `waves2_190lf/briefs/SUB-DYN.md`): the Waves CLA-2A's opto behaviour as a compact LYNX model inside Glow
+Leveler, then what round 190ky left open on the CLA-76 (Crest's FET law). Owner's permission of 2026-11-17 for REA on
+third-party binaries, clean-room as in rounds 190kt / 190ky: what is recorded here is structure, behaviour and parameter
+meaning; LYNX's code is written from this description and every constant is fitted on our own black-box renders. Vendor
+tables were located, not read out and not used; no licence check was touched; the demo's mutes are masked.
+Lab: `/mnt/e/lynx-work/waves2_190lf/dyn/` (lab/, cap/, runs/, ev/, HANDOFF.md).
+
+## 1. Waves CLA-2A
+
+### 1.1 What REA showed [DECOMP]
+
+- DSP (`LA2AProc.A`, round 190ky's `ev/cla2a_gmcp/functions/0x1800011a4.c`), read as structure: a first-order input
+  stage; the **side chain is fed back** from the cell's attenuated signal (in Limit a share of the input is blended in);
+  a cascade of second-order sections (the Hi Freq weighting); two optional level-dependent stages *inside the side
+  chain* (a one-pole peak detector and a gain `2^(−(20 log10 env − thr) · k)` above a threshold — the side-chain
+  amplifier running out of headroom); a rectifier and a light transfer chosen by the mode (two tables: Compress /
+  Limit); **two cell states** that share the drive with a split factor and each move towards their share with
+  charge / discharge coefficients computed per sample from their own state (the discharge from tables); the audio is
+  multiplied by the cell's gain, then split by a first-order all-pass crossover into a low and a high band, the **high
+  band scaled by a function of the cell state** (reduced less under reduction: the tilt), plus a small parallel path of
+  the un-attenuated signal; an optional output-transformer stage (two first-order filters and a static nonlinearity
+  subtracted from the signal); mix with the dry input, output gain.
+- Control DLL `CLA-2A.dll` (decompiled this round: `ev/cla2a_dll`, 2 060 functions): the knob → coefficient laws are
+  tables in dB, two sets (Compress / Limit), converted to linear gains at initialisation (`0x1800270f0.c`); the scale
+  getters `SideChainInGainScale` / `OutGainScale` serve the meters. Tables located, not read out.
+
+### 1.2 Black-box findings [EXEC]
+
+Probes (Waves demo mode on refcap030's fxmeasure host: hidden, no editor, no input sent, the trial lock only;
+`cap/cla2a_1.txt`, `cla2a_2.txt`, 123 renders, 69 s of host time; every stimulus starts with 1.5 s of silence):
+1 kHz stairs −40 … 0 dBFS (2 dB, 0.4 s) at peak reduction 0 / 30 / 46 / 60 / 70 / 80 / 90 / 100 (Compress) and 46 / 60 / 80
+(Limit); 60 Hz / 200 Hz / 5 kHz stairs at Hi Freq 0 / 20 / 50 / 100 (peak reduction 70); −6 dBFS bursts of 50 ms / 300 ms /
+2 s / 8 s on a −40 dBFS probe; pink-noise stairs; synthetic drums; a 30-tone multitone alone and under a 1 kHz tone at
+−20 / −10 / 0 dBFS (the tilt); the Gain dial 0 … 100 at a low level; 1 kHz / 100 Hz level steps (harmonics); refcap182's six
+states (loadcomponent) on the probe stimuli.
+
+- **The demo mutes are fades** to about −120 dB (not runs of exact zeros as round 190ky saw on the CLA-76): masked as
+  frames more than 30 dB under the input, ±4 frames (`lab/probe.py`).
+- **The cell keeps its state across `reset`**: a probe processed after the stairs starts ≈ 1 dB down and recovers over
+  seconds (`a_C70_b300`). The fit therefore simulates each probe after the one the host processed before it (script
+  order, the 0.3 / 0.2 s settles in between). refcap182's programme renders do the same (each file after the previous
+  one of its setting): their first seconds carry the previous file's tail (a host artefact, not modelled).
+- **No long memory**: at peak reduction 83 the recovery after 300 ms, 2 s and 8 s bursts is the same within 0.03 dB
+  (only a 50 ms burst, which leaves less reduction, recovers faster), as round 165w found; the exposure term below was
+  left free in the fit.
+- The Gain dial's level at 1 kHz (−40 dBFS, nothing reduced): 0 … 100 → −56.2, −35.0, −18.1, −2.5, 8.48, 16.91, 24.75,
+  29.77, 33.78, 35.29, 38.80 dB — round 123's table within 0.06 dB (from 10 up).
+
+### 1.3 LYNX's cell law
+
+@@CELL@@
+
+## 2. Waves CLA-76 leftovers
+
+@@C76@@

+ 1 - 0
src/core/MixSuite.cpp

@@ -1397,6 +1397,7 @@ public:
             c.makeupRef = 100.0 * std::clamp ((double) p[makeupRef], 0.0, 1.0);
             c.memory = on (p[optoMemory]);
             c.scWeighting = on (p[scWeighting]) ? 1 : 0;
+            c.cellLaw = on (p[cellLaw]) ? 1 : 0; // round 190lf (hidden)
             const auto mx = std::clamp (p[mix], 0.0f, 1.0f);
             const int hz = analogHz (p[analog]);
             const auto trimGain = (float) dbToGain (trimDb (p[trim]));

+ 6 - 1
src/core/MixSuite.h

@@ -248,7 +248,12 @@ namespace glow
 // output: the reference saves its VU DISPLAY knob with the state, so LYNX keeps the editor's selector with the project)
 // round 190dm (appended): the Opto classic voicing's cell memory (VoiceMatch.h opto::Settings::memory; off = as before)
 // round 190fx (appended): the Opto classic voicing's side-chain weighting (opto::Settings::scWeighting; off = as before)
-enum Param { peakReduction, gain, mode, emphasis, mix, trim, autoMakeup, voicing, optoLaw, analog, releaseLaw, makeupRef, vuDisplay, optoMemory, scWeighting, count };
+enum Param { peakReduction, gain, mode, emphasis, mix, trim, autoMakeup, voicing, optoLaw, analog, releaseLaw, makeupRef, vuDisplay, optoMemory, scWeighting, count,
+             // round 190lf, hidden (not in the info: no control, no text; saved while non-zero): the Opto classic voicing's
+             // cell law (VoiceMatch.h opto::Settings::cellLaw = 1, LYNX's compact opto behaviour model, REA_rodada190lf_dyn
+             // §1). 0 = off: new instances and every project saved before (the laws above, bit for bit); the CLA-2A
+             // translator sets it
+             cellLaw = count };
 // round 165x: an editor edit with the reference's AUTO MAKEUP behaviour (switching it on takes the dial as the
 // reference; switching it off leaves the make-up in the Gain dial, as the trial turns its own Gain knob)
 std::vector<std::pair<int, float>> linkedEdit (const EffectParams& p, int param, float value);

+ 10 - 2
src/core/PluginSubstitutes.cpp

@@ -1846,6 +1846,10 @@ int translateWavesCla2a (const std::vector<std::uint8_t>& state, EffectSlot& slo
     // round 165x [EXEC]: 17 = VU DISPLAY (0 In, 1 GR, 2 Out; read back through the trial's own parameter)
     const auto vu = std::lround (wavesValue (rw, 17).value_or (1.0));
     slot.params[g::vuDisplay] = vu == 0 ? 0.5f : vu == 2 ? 1.0f : 0.0f;
+    // round 190lf [EXEC] (REA_rodada190lf_dyn §1): the cell law — LYNX's compact opto behaviour model, fitted on our
+    // demo-mode probes of the reference (stairs at eight peak reduction dials, Compress and Limit; bursts of 50 ms … 8 s;
+    // 60 Hz / 200 Hz / 1 kHz / 5 kHz stairs at Hi Freq 0 / 20 / 50 / 100; a multitone under reduction for the tilt)
+    slot.params[g::cellLaw] = 1.0f;
     return 8;
 }
 
@@ -1881,10 +1885,14 @@ constexpr Cla76Fit cla76Fits[10] {
     { -31.3386, 0.1073, 3.5943, -1.71 }, // Bluey 4 (law at -40 dBFS: 0.00 dB)
     { -27.7634, 0.1384, 11.2319, -1.06 }, // Bluey A (law at -40 dBFS: -0.00 dB)
 };
-constexpr Cla76Times cla76Times[3] { // the slow follower's attack and half the fast follower's release (ms) at knob 1 / 7
+constexpr Cla76Times cla76Times[4] { // the slow follower's attack and half the fast follower's release (ms) at knob 1 / 7
     { 11.8931, 5.4866, 247.8996, 30.3698 }, // 20 / 12 / 8 (fit76r.py)
     { 29.6727, 0.6607, 1039.0365, 132.2632 }, // 4 (fit76j.py, fit76p.py)
     { 5.2967, 0.1560, 1847.6547, 33.0881 }, // all buttons (fit76jA.py)
+    // round 190lf [EXEC] (REA_rodada190lf_dyn §2): Bluey 20 / 12 / 8 — the release at knob 7 fitted through the shipped
+    // voicings on Bluey 12:1 probes (waves2_190lf/dyn/lab/fit76x.py), knob 1 refined on refcap182's Bluey 12:1 programme
+    // (X4, lab/x4prog.py: the probe fit's 2.1 s at knob 1 over-reduced it), the attack as the row above
+    { 11.8931, 5.4866, 795.0, 12.6423 },
 };
 constexpr double cla76RangeDb = 40.0;
 constexpr int cla76InPoints = 14, cla76OutPoints = 12;
@@ -1925,7 +1933,7 @@ int translateWavesCla76 (const std::vector<std::uint8_t>& state, EffectSlot& slo
     p[c::knee] = linNorm (f.w1, 0.0, 72.0);
     p[c::range] = off ? 0.0f : linNorm (cla76RangeDb, 0.0, 60.0);
     // the knobs' times, geometric between knob 1 and knob 7 (20 / 12 / 8, 4 and all buttons each their own)
-    const auto& t = cla76Times[ratioIndex == 4 ? 2 : ratioIndex == 3 ? 1 : 0];
+    const auto& t = cla76Times[ratioIndex == 4 ? 2 : ratioIndex == 3 ? 1 : bluey ? 3 : 0]; // round 190lf: Bluey 20 / 12 / 8 their own
     p[c::attack] = c::attackValue (t.attack7 * std::pow (t.attack1 / t.attack7, (7.0 - attackKnob) / 6.0));
     p[c::release] = c::releaseValue (t.release7 * std::pow (t.release1 / t.release7, (7.0 - releaseKnob) / 6.0));
     p[c::autoRelease] = 0.0f;

+ 130 - 0
src/core/VoiceMatch.cpp

@@ -1280,10 +1280,23 @@ void Leveler::reset() noexcept
     scLow172.reset();
     scHigh190.reset();
     scLow190.reset();
+    // round 190lf: the cell law's state
+    ccf = ccs = cc3 = cexp = cenv = 0.0;
+    for (int c = 0; c < 2; ++c)
+    {
+        cyp[c] = chx[c] = chy[c] = 0.0;
+        for (auto* f : { &cellLow, &cellHigh })
+            f->x1[c] = f->x2[c] = f->y1[c] = f->y2[c] = 0.0;
+    }
 }
 
 void Leveler::process (float* l, float* r, int n, const Settings& s) noexcept
 {
+    if (s.cellLaw == 1)
+    {
+        processCell (l, r, n, s);
+        return;
+    }
     const double dt = 1.0 / sr;
     if (scDesignedRate != sr)
     {
@@ -1414,6 +1427,123 @@ void Leveler::process (float* l, float* r, int n, const Settings& s) noexcept
     }
     last = (float) maxGr;
 }
+namespace
+{
+// round 190lf [EXEC] (docs/analise/REA_rodada190lf_dyn.md §1): the cell law (Settings::cellLaw = 1), LYNX's compact opto
+// behaviour model. Per sample: the side chain hears the cell's output (feedback; in Limit plus a share of the input)
+// through a low and a high peaking filter, the louder channel's level |sc| · 10^(shift / 20) (shift: the peak
+// reduction dial's and the Hi Freq dial's laws, below) held by the light's persistence (a peak hold releasing with
+// envMs) is u, and lights the cell above u = 1: C* = (u − 1)^gamma. A fast and a slow
+// conductance share C* (1 − share, share; a third, very fast one share3 of it): each charges towards its part (the fast one in the log1p domain at
+// (1 + C)^beta / tau), and releases as dC/dt = −(a Cⁿ + b C) / (1 + mg · E), E an exposure (0 … 1) that charges while the
+// cell is lit and fades slowly — the longer and harder it was lit, the slower it recovers. The audio sees
+// g = 1 / (1 + Cf + Cs) (Limit: floored), its band above tiltHz (first order) reduced less (× min (hmax, g^−kappa)), then
+// the gain dial's make-up, the small 2nd / 3rd harmonic and the unit's idle response of the Opto classic voicing.
+// Every constant is fitted on our own probes (waves2_190lf/dyn/lab/fit2a.py; tables written by lab/gen2a.py).
+struct CellLaw
+{
+    double gamma, gammaLimit, feedForward, floorDb, tauA, beta, a, n, b, share, tauAs, a2, n2, b2, mg, mchMs, mdcMs;
+    double lowHz, lowQ, lowDb, highHz, highQ, highDb, highDbSlope, tiltHz, kappa, hmaxDb, limitShift, envMs;
+    double share3, att3Ms, rel3Ms; // a third, very fast conductance (one-pole attack / release) taking share3 of C*
+    double lowDbSlope;             // the low filter's gain per 50 of the Hi Freq dial away from 50 (as highDbSlope)
+};
+// fit2a:begin (CELL190LF: lab/gen2a.py)
+constexpr CellLaw cell190lf { 2.99579, 3.41216, 0.0590878, 29.5474, 62.4002, 0.364894, 0.978602, 2.90891, 6.9967, 0.240615, 1578.64, 55.4413, 4.83264, 0.258853, 1.82323, 343.78, 86.7507,
+                              86.091, 0.482178, 4.08894, 8007.81, 0.936114, 8.06835, -0.400425, 20000, 1.66958, 17.2213, 2.18174, 1.81797, 0, 0.5, 10, -1.71018 };
+constexpr double cellPrKnob[] { 0, 30, 46, 60, 70, 80, 90, 100 };
+constexpr double cellPrShift[] { -60, -5, 17.9491, 29.3419, 37.824, 42.789, 45.602, 48.4861 };
+constexpr double cellHfKnob[] { 0, 20, 50, 100 };
+constexpr double cellHfShift[] { -2.927, -4.05829, 0, 5.41484 };
+constexpr double cellGainKnob[] { 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
+constexpr double cellGainDb[] { -56.219, -34.954, -18.053, -2.544, 8.477, 16.908, 24.746, 29.768, 33.784, 35.289, 38.799 };
+// fit2a:end
+void cellPeak (double sr, double hz, double q, double db, double& b0, double& b1, double& b2, double& a1, double& a2) noexcept
+{
+    const double A = std::pow (10.0, db / 40.0), w = 2.0 * pi * std::min (hz, 0.45 * sr) / sr, al = std::sin (w) / (2.0 * q), cw = std::cos (w), a0 = 1.0 + al / A;
+    b0 = (1.0 + al * A) / a0; b1 = -2.0 * cw / a0; b2 = (1.0 - al * A) / a0; a1 = -2.0 * cw / a0; a2 = (1.0 - al / A) / a0;
+}
+} // namespace
+
+void Leveler::processCell (float* l, float* r, int n, const Settings& s) noexcept
+{
+    const auto& c = cell190lf;
+    const double dt = 1.0 / sr;
+    const double hf = std::clamp (s.hiFreq, 0.0, 100.0);
+    const double highDb = c.highDb + c.highDbSlope * (hf - 50.0) / 50.0, lowDb = c.lowDb + c.lowDbSlope * (hf - 50.0) / 50.0;
+    if (cellRate != sr || cellHiFreq != hf) // the filters follow the Hi Freq dial
+    {
+        cellRate = sr;
+        cellHiFreq = hf;
+        cellPeak (sr, c.lowHz, c.lowQ, lowDb, cellLow.b0, cellLow.b1, cellLow.b2, cellLow.a1, cellLow.a2);
+        cellPeak (sr, c.highHz, c.highQ, highDb, cellHigh.b0, cellHigh.b1, cellHigh.b2, cellHigh.a1, cellHigh.a2);
+    }
+    const double shift = table (cellPrKnob, cellPrShift, (int) std::size (cellPrKnob), std::clamp (s.peakReduction, 0.0, 100.0))
+                       + table (cellHfKnob, cellHfShift, (int) std::size (cellHfKnob), hf) + (s.limit ? c.limitShift : 0.0);
+    const double K = dbToGain (shift), gam = s.limit ? c.gammaLimit : c.gamma, ff = s.limit ? c.feedForward : 0.0;
+    const double gFloor = s.limit ? dbToGain (-c.floorDb) : 0.0;
+    const double eUp = 1.0 - std::exp (-dt * 1000.0 / c.mchMs), eDn = 1.0 - std::exp (-dt * 1000.0 / c.mdcMs);
+    const double envR = std::exp (-dt * 1000.0 / c.envMs);
+    const double a3 = 1.0 - std::exp (-dt * 1000.0 / c.att3Ms), r3 = 1.0 - std::exp (-dt * 1000.0 / c.rel3Ms);
+    const double cAs = 1.0 - std::exp (-dt * 1000.0 / c.tauAs), hpc = std::exp (-2.0 * pi * c.tiltHz / sr), hmax = dbToGain (c.hmaxDb);
+    // the measured level at 1 kHz (the idle response's mid-band loss given back, as the Opto classic voicing does)
+    const double mk = dbToGain (table (cellGainKnob, cellGainDb, (int) std::size (cellGainKnob), std::clamp (s.gain, 0.0, 100.0)) + idleMakeupDb
+                                + (s.autoMakeup ? autoMakeupDb (s.peakReduction) - autoMakeupDb (s.makeupRef) : 0.0));
+    const auto bq = [] (Peak2& f, double x, int ch) noexcept
+    {
+        const double y = f.b0 * x + f.b1 * f.x1[ch] + f.b2 * f.x2[ch] - f.a1 * f.y1[ch] - f.a2 * f.y2[ch];
+        f.x2[ch] = f.x1[ch]; f.x1[ch] = x; f.y2[ch] = f.y1[ch]; f.y1[ch] = y;
+        return y;
+    };
+    const double* tb = idleB;
+    const double* ta = idleA;
+    double maxGr = 0.0;
+    for (int i = 0; i < n; ++i)
+    {
+        float* ch[2] = { &l[i], &r[i] };
+        double u = 0.0;
+        for (int k = 0; k < 2; ++k)
+            u = std::max (u, std::abs (bq (cellHigh, bq (cellLow, cyp[k] + ff * *ch[k], k), k)));
+        cenv = std::max (u * K, cenv * envR);
+        u = cenv;
+        const double ct = u > 1.0 ? std::pow (u - 1.0, gam) : 0.0;
+        const double t3 = c.share3 * ct, tf = (1.0 - c.share) * (1.0 - c.share3) * ct, ts = c.share * (1.0 - c.share3) * ct;
+        cc3 += (t3 > cc3 ? a3 : r3) * (t3 - cc3);
+        const double lit = ct / (1.0 + ct);
+        cexp += (lit > cexp ? eUp : eDn) * (lit - cexp);
+        const double slow = 1.0 + c.mg * cexp;
+        if (tf > ccf)
+        {
+            double cd = std::log1p (ccf);
+            cd += (std::log1p (tf) - cd) * (1.0 - std::exp (-dt * 1000.0 * std::pow (1.0 + ccf, c.beta) / c.tauA));
+            ccf = std::expm1 (cd);
+        }
+        else
+            ccf = std::max (tf, ccf - dt * (c.a * std::pow (ccf, c.n) + c.b * ccf) / slow);
+        if (ts > ccs)
+            ccs += (ts - ccs) * cAs;
+        else
+            ccs = std::max (ts, ccs - dt * (c.a2 * std::pow (ccs, c.n2) + c.b2 * ccs) / slow);
+        const double g = std::max (gFloor, 1.0 / (1.0 + ccf + ccs + cc3));
+        const double h = std::min (hmax, std::pow (g, -c.kappa));
+        for (int k = 0; k < 2; ++k)
+        {
+            const double y = g * *ch[k];
+            cyp[k] = y;
+            const double hp = hpc * (chy[k] + y - chx[k]);
+            chx[k] = y;
+            chy[k] = hp;
+            double o = (y + (h - 1.0) * hp) * mk;
+            o = o + h2 * o * o + h3 * o * o * o;
+            for (int j = 3; j > 0; --j) { tx[k][j] = tx[k][j - 1]; ty[k][j] = ty[k][j - 1]; }
+            tx[k][0] = o;
+            const double t = tb[0] * tx[k][0] + tb[1] * tx[k][1] + tb[2] * tx[k][2] + tb[3] * tx[k][3] - ta[1] * ty[k][1] - ta[2] * ty[k][2] - ta[3] * ty[k][3];
+            ty[k][0] = t;
+            *ch[k] = (float) t;
+        }
+        maxGr = std::max (maxGr, -gainToDb (g));
+    }
+    last = (float) maxGr;
+}
 } // namespace opto
 
 // ================================================================== program-dependent peak compressor

+ 12 - 0
src/core/VoiceMatch.h

@@ -214,6 +214,12 @@ struct Settings
     // weighting. 0 = the voicing's own emphasis (every project before); 1 = the even weighting those references measured
     // (much less treble emphasis, a little more bass), its 1 kHz gain the same, so every 1 kHz law fitted before holds
     int scWeighting = 0;
+    // round 190lf [EXEC] (REA_rodada190lf_dyn §1): the cell law. 0 = the laws above (every project before); 1 = LYNX's
+    // compact opto behaviour model fitted on our black-box probes of an opto-leveler emulation (a feedback side chain
+    // through a low and a high peaking filter, a fast and a slow conductance sharing the light, an exposure that slows
+    // the release, a high-frequency band that is reduced less, its own peak reduction / Hi Freq / gain laws). Uses
+    // gain, peakReduction, hiFreq, limit, autoMakeup / makeupRef; the other switches above are ignored
+    int cellLaw = 0;
 };
 double autoMakeupDb (double peakReduction) noexcept; // round 152: AUTO MAKEUP's gain (dB) at a peak reduction dial
 double gainForMakeupDb (double db) noexcept;          // round 165x: the gain dial giving makeupDb (inverse)
@@ -235,6 +241,12 @@ private:
     Biquad scHigh190, scLow190; // round 190fx: the even weighting (Settings::scWeighting)
     double scShift190 = 0.0;    // its level shift (dB) that keeps the chain's 1 kHz gain where the emphasis put it
     double scDesignedRate = 0.0;
+    // round 190lf: the cell law's state (Settings::cellLaw = 1)
+    void processCell (float* l, float* r, int n, const Settings& s) noexcept;
+    struct Peak2 { double b0 = 1, b1 = 0, b2 = 0, a1 = 0, a2 = 0, x1[2] {}, x2[2] {}, y1[2] {}, y2[2] {}; };
+    Peak2 cellLow, cellHigh;
+    double cellHiFreq = -1.0, cellRate = 0.0;
+    double ccf = 0.0, ccs = 0.0, cc3 = 0.0, cexp = 0.0, cenv = 0.0, cyp[2] {}, chx[2] {}, chy[2] {};
     float last = 0.0f;
 };
 } // namespace opto

+ 89 - 0
tests/Parity190lfDynTests.inc

@@ -0,0 +1,89 @@
+// Round 190lf, sub-round "dyn": REA of the Waves CLA-2A (owner's permission of 2026-11-17; docs/analise/
+// REA_rodada190lf_dyn.md, /mnt/e/lynx-work/waves2_190lf/dyn/HANDOFF.md).
+// - Glow Leveler's Opto classic voicing gets a cell law (hidden cellLaw): LYNX's compact opto behaviour model (feedback
+//   side chain through a low and a high peaking filter, a fast and a slow conductance sharing the light, the high band
+//   reduced less), fitted on our demo-mode probes. Off for new instances and every project saved before (bit for bit:
+//   lab/gold.sh). The CLA-2A translator sets it.
+#include <cmath>
+
+#include "core/Effects.h"
+#include "core/MixSuite.h"
+
+namespace parity190lf
+{
+namespace g = lynx::mixsuite::glow;
+inline lynx::EffectSlot glow (double pr, double gain, bool limit, double hf, bool cell)
+{
+    auto s = lynx::makeEffectSlot (lynx::EffectKind::glowLeveler);
+    s.params[(std::size_t) g::voicing] = 1.0f;
+    s.params[(std::size_t) g::optoLaw] = 1.0f;
+    s.params[(std::size_t) g::releaseLaw] = 1.0f;
+    s.params[(std::size_t) g::peakReduction] = (float) (pr / 100.0);
+    s.params[(std::size_t) g::gain] = (float) (gain / 100.0);
+    s.params[(std::size_t) g::mode] = limit ? 1.0f : 0.0f;
+    s.params[(std::size_t) g::emphasis] = (float) (hf / 100.0);
+    s.params[(std::size_t) g::cellLaw] = cell ? 1.0f : 0.0f;
+    return s;
+}
+// the gain (dB) of the last 100 ms of a 1 kHz tone at `db` dBFS held `sec` s
+inline double steadyDb (const lynx::EffectSlot& s, double db, double sec = 2.0)
+{
+    const double sr = 48000.0;
+    const auto n = (std::size_t) (sec * sr);
+    std::vector<float> l (n), r (n);
+    for (std::size_t i = 0; i < n; ++i)
+        l[i] = r[i] = (float) (std::pow (10.0, db / 20.0) * std::sin (2.0 * M_PI * 1000.0 * (double) i / sr));
+    const auto x = l;
+    auto fx = lynx::makeEffect (s);
+    fx->prepare (sr);
+    for (std::size_t off = 0; off < n; off += 256)
+        fx->process (l.data() + off, r.data() + off, (int) std::min<std::size_t> (256, n - off), s.params, 120.0);
+    double ey = 0.0, ex = 0.0;
+    for (auto i = n - (std::size_t) (0.1 * sr); i < n; ++i)
+        ey += (double) l[i] * l[i], ex += (double) x[i] * x[i];
+    return 10.0 * std::log10 (ey / ex);
+}
+} // namespace parity190lf
+
+TEST (parity190lf_glow_cell_law_is_hidden_and_off_for_new_and_old_glows)
+{
+    using namespace lynx;
+    namespace g = mixsuite::glow;
+    const auto& info = effectInfo (EffectKind::glowLeveler);
+    CHECK (info.params.size() == (std::size_t) g::count && g::cellLaw == g::count); // hidden: no control, no string
+    auto s = makeEffectSlot (EffectKind::glowLeveler);
+    CHECK (s.params[(std::size_t) g::cellLaw] == 0.0f && savedEffectParamCount (s) <= (std::size_t) g::count);
+    s.params[(std::size_t) g::cellLaw] = 1.0f;
+    CHECK (savedEffectParamCount (s) == (std::size_t) g::cellLaw + 1);
+}
+
+TEST (parity190lf_glow_cell_law_levels_like_the_measured_reference)
+{
+    using parity190lf::glow;
+    using parity190lf::steadyDb;
+    // below the threshold: the gain dial's measured level (Gain 40: +8.48 dB at 1 kHz)
+    CHECK (std::abs (steadyDb (glow (46, 40, false, 50, true), -40.0) - 8.48) < 0.2);
+    // more peak reduction = more reduction at a loud tone, Limit more than Compress at a high dial
+    const auto c46 = steadyDb (glow (46, 40, false, 50, true), -6.0), c70 = steadyDb (glow (70, 40, false, 50, true), -6.0);
+    const auto c90 = steadyDb (glow (90, 40, false, 50, true), -6.0);
+    CHECK (c46 > c70 && c70 > c90 && c46 < 8.0);
+    // the output keeps rising with the input (a leveler, not a brickwall) in Compress
+    CHECK (steadyDb (glow (70, 40, false, 50, true), 0.0) + 0.0 > steadyDb (glow (70, 40, false, 50, true), -12.0) - 12.0);
+    // Hi Freq turned down = less side-chain sensitivity at 1 kHz (the measured shift)
+    CHECK (steadyDb (glow (70, 40, false, 0, true), -10.0) > steadyDb (glow (70, 40, false, 100, true), -10.0));
+    // the switch changes the sound; off keeps the round-165w law
+    CHECK (std::abs (steadyDb (glow (70, 40, false, 50, true), -10.0) - steadyDb (glow (70, 40, false, 50, false), -10.0)) > 1e-3);
+}
+
+TEST (parity190lf_waves_cla2a_translates_onto_the_cell_law)
+{
+    using namespace lynx;
+    namespace g = mixsuite::glow;
+    std::string values;
+    for (int i = 0; i < 208; ++i)
+        values += i == 38 ? "40 " : i == 74 ? "70 " : i == 153 ? "50 " : i == 204 ? "100 " : i == 140 ? "2 " : "0 ";
+    int n = 0;
+    const auto s = vm123::wavesSlot ("CLA-2A", values.c_str(), n);
+    CHECK (s.kind == EffectKind::glowLeveler && n == 8 && s.params[(std::size_t) g::cellLaw] == 1.0f);
+    CHECK (std::abs (s.params[(std::size_t) g::peakReduction] - 0.70f) < 1e-6f && s.params[(std::size_t) g::voicing] == 1.0f);
+}

+ 1 - 0
tests/tests.cpp

@@ -17777,6 +17777,7 @@ TEST (fl_low_lifter_matches_fl_engine)
 #include "Parity190jsTests.inc" // round 190js: the Waves reverbs on Reeverb 2, Hush's Single Vocal revision, Facet's auto-threshold refit
 #include "Parity190ktTests.inc" // round 190kt: REA of the Waves SSLComp DSP, Crest's console law, SSLComp on Crest
 #include "Parity190kyTests.inc" // round 190ky: Crest's FET law (REA of the Waves CLA-76 DSP), CLA-76 on it
+#include "Parity190lfDynTests.inc" // round 190lf (dyn): Glow Leveler's cell law (REA of the Waves CLA-2A), CLA-2A on it
 #include "Sampler190dhTests.inc"
 #include "Fix190eaTests.inc"
 #include "Iss158Tests.inc"