Bläddra i källkod

Anvil Bus: refit on Live's second Drum Buss render set (round 190gx)

Round 190gu rendered Live 12.4's Drum Buss at the settings round 190fk could not
measure (46 cases at 44.1 / 48 / 96 kHz). Anvil Bus is refitted on them under
the plugin quality gate: no case of the 190ei bank (31) or the 190gu bank (46,
all three rates) gets worse, to 0.001 dB.

- Comp sits before the curve (Comp + Drive 50 %: staircase 1.63 -> 0.17 dB),
  refitted on all eight Comp cases; Dry/Wet keeps the raw input as dry.
- Type EQ depth below 100 % = amount^8 for Soft and Medium (Medium 50 % noise
  2.95 -> 0.41 dB); a Soft 75 % knot (stair 1.07 -> 0.33 dB).
- Boom: lift and Q per amount (0.25 / 1.0 knots: drums 4.98 -> 0.43,
  7.82 -> 3.32 dB), refitted decay 0 / 0.5 knots, the bell a cookbook peak so
  Live's long ring at 1.0 fits.
- Damp corner 6 % above the set value (0.38 -> 0.24 dB).
- Transients: a broadband level term with the shaper refitted (sustained pad
  3.53 -> 3.05 dB, drums -1.0 3.76 -> 3.61 dB).
- Generic panel in Live's four columns; the .als import's approximation notes
  name the new measured settings.
- Mean headline error: 190ei bank 1.216 -> 1.198 dB, 190gu bank 1.261 -> 0.766.
Ka1-S 2 veckor sedan
förälder
incheckning
382c1ccdd6
7 ändrade filer med 357 tillägg och 65 borttagningar
  1. 27 0
      docs/PARITY.md
  2. 12 8
      src/core/AlsDevicesLot3.cpp
  3. 145 36
      src/core/AnvilBus.h
  4. 21 19
      src/core/PluginLayout.cpp
  5. 3 2
      tests/Anvil190fkTests.inc
  6. 148 0
      tests/AnvilBus190gxTests.inc
  7. 1 0
      tests/tests.cpp

+ 27 - 0
docs/PARITY.md

@@ -3415,6 +3415,33 @@ Also: `Song::automationChunks` (runtime only): stand-in / freeze render songs an
 song they stand for (the renderer works in 128-sample chunks while any automation plays; some instruments sound about
 −66 dB different at 512): frozen audio now nulls where the freeze took the song's automation away.
 
+## Round 190gx: Anvil Bus refitted on Live's second Drum Buss render set
+
+Round 190gu rendered Live 12.4's Drum Buss again: the settings 190fk could not measure (types at 25 / 50 %, Soft 75 %,
+Boom amount / decay / frequency, Crunch 0.25 / 1.0, Transients on a sustained pad, Comp with Drive and with Trim, Dry/Wet
+with Comp, every type at +6 dBFS, Damping 500 Hz / 2 kHz), 46 cases, each at 44.1, 48 and 96 kHz. Anvil Bus was
+refitted on them with the plugin quality gate: the 31 cases of 190ei and the 46 new ones, every case at or under its
+error before (to 0.001 dB), at all three rates. Anvil Bus is in no release yet (only the 0.1.28 rollup), so the new laws
+need no engine-version switch.
+
+| Item | Live (190gu) | Anvil Bus now | |
+|---|---|---|---|
+| Comp's place | before the curve (Comp + Drive 50 %: staircase THD and level follow) | moved before the curve, refitted: 8 Comp cases all closer (Drive 50 % stair 1.63 → 0.17 dB, drums 2.65 → 0.65) | ✅ |
+| Dry/Wet with Comp | dry = the raw input (0.003 dB) | the same (test: sample for sample) | ✅ |
+| Type EQ below 100 % | Soft / Medium keep the neutral shape until near 100 % | depth = amount⁸ for Soft and Medium (Medium 50 % noise 2.95 → 0.41 dB) | ✅ |
+| Soft 75 % | folds 0 dBFS to −12.1 dBFS | its own knot (stair 1.07 → 0.33 dB) | ✅ |
+| Boom amount | lift and ring grow fast (1.0 rings ≈ −20 dB/s at 50 Hz) | lift and Q per amount (0.25: drums 4.98 → 0.43; 1.0: 7.82 → 3.32 dB) | ⚠️ |
+| Boom decay 0 / 0.5 | | refitted knots (drums 3.22 → 3.08, 1.87 → 1.75) | ⚠️ |
+| Damping | one-pole | corner 6 % above the set value (0.38 → 0.24 dB) | ✅ |
+| Transients on steady sound | a pad: −1.0 → −3.9 dB, +0.25 → +1.15 | a broadband level term joins the shaper (pad 3.53 → 3.05, 0.98 → 0.80 dB); the full depth would move the drum loop | ⚠️ |
+| Crunch's grit | THD 1 → 2.3 / 4.4 / 12 % at 0.25 / 0.5 / 1.0 | not carried (tried: lift before the curve; failed the gate) | ❌ |
+| Output never above 0 dBFS | yes (+6 dBFS in → ≤ 0.0) | not limited (tried an output ceiling; failed the gate) | ❌ |
+| Rates 44.1 / 48 / 96 kHz | agree within 0.25 dB | errors against Live the same at the three rates (mean 0.77 / 0.77 / 0.79 dB) | ✅ |
+| Panel | Drive, types, Trim, Comp \| Crunch, Damp, Transients \| Boom, Freq, Decay \| Out, Dry/Wet | the generic panel in those four columns | ✅ |
+
+Mean headline error: 190ei bank 1.216 → 1.198 dB, 190gu bank 1.261 → 0.766 dB (48 kHz); details and CPU in
+`/mnt/e/lynx-work/livefacts190gx/db/REPORT.md`.
+
 ## Round 190fk: Anvil Bus — LYNX's drum-bus engine in the role of Ableton Live's Drum Buss
 
 Owner decision O20: Live's Drum Buss colours even at its all-zero setting, so it imports onto a dedicated engine

+ 12 - 8
src/core/AlsDevicesLot3.cpp

@@ -481,15 +481,19 @@ bool drumBussToEngine (const Element& device, Translated& out)
     out.links.push_back ({ "DryWet", an::dryWet, [] (double v) { return unit (v); } });
 
     // the report: what the engine holds as a fit rather than a measurement at that very setting
+    // (round 190gx: the measured settings are Live's 190ei and 190gu renders)
     const auto drive = (double) p[an::drive];
-    if (drive > 0.0 && drive != 0.25 && drive != 0.5 && drive != 1.0)
-        out.notes.approximated.push_back ("drive between the measured amounts (0, 25, 50, 100 %): curve and gain interpolated");
-    if (type != 0 && drive > 0.0)
-        out.notes.approximated.push_back ("the drive type's EQ fitted at 100 % and taken in proportion below");
-    if (p[an::boom] > 0.0f && std::abs (p[an::boom] - 0.5f) > 1.0e-3f)
-        out.notes.approximated.push_back ("Boom fitted at amount 0.5; other amounts scale its resonance");
-    if (p[an::crunch] > 0.0f && std::abs (p[an::crunch] - 0.5f) > 1.0e-3f)
-        out.notes.approximated.push_back ("Crunch fitted at 0.5; other amounts scale its band");
+    const auto measured = [] (double v, std::initializer_list<double> at) {
+        return std::any_of (at.begin(), at.end(), [v] (double a) { return std::abs (v - a) < 1.0e-3; });
+    };
+    if (drive > 0.0 && ! measured (drive, { 0.25, 0.5, 1.0 }) && ! (type == 0 && measured (drive, { 0.75 })))
+        out.notes.approximated.push_back ("drive between the measured amounts (0, 25, 50, 100 %; Soft also 75 %): curve and gain interpolated");
+    if (drive > 0.0 && ! measured (drive, { 0.25, 0.5, 1.0 }))
+        out.notes.approximated.push_back ("the drive type's EQ fitted at 25, 50 and 100 % and interpolated between");
+    if (p[an::boom] > 0.0f && ! measured ((double) p[an::boom], { 0.25, 0.5, 1.0 }))
+        out.notes.approximated.push_back ("Boom fitted at amounts 0.25, 0.5 and 1.0; amounts between interpolate its lift and resonance");
+    if (p[an::crunch] > 0.0f)
+        out.notes.approximated.push_back ("Crunch as its mid-band level (fitted at 0.25, 0.5 and 1.0; its grit is not carried)");
     if (outDb > 12.0)
         out.notes.approximated.push_back (text ("output %.1f dB (Anvil Bus: up to +12 dB)", outDb));
     if (device.boolean ("BoomAudition/Manual", false))

+ 145 - 36
src/core/AnvilBus.h

@@ -6,9 +6,10 @@
 // staircase, an impulse, a sweep and a drum loop through each setting); nothing of Live's code or content is used.
 //
 // Signal flow (one stereo path, every stage per channel):
-//   Trim → [Comp] → colour pre-emphasis → Drive (×gain, the type's curve, 4× oversampled) → Damp (one-pole low pass)
-//        → colour / type / Crunch / Boom EQ (magnitude-matched sections, core/FacetEq.h) → Transients → Output
-//        → Dry/Wet against the raw input (delayed by the oversampler's latency)
+//   Trim → Comp (round 190gx: before the curve, as Live's renders show) → colour pre-emphasis → Drive (×gain, the
+//        type's curve, 4× oversampled) → Damp (one-pole low pass) → colour / type / Crunch EQ (magnitude-matched
+//        sections, core/FacetEq.h) and Boom's resonant peak → Transients → Output → Dry/Wet against the raw input
+//        (delayed by the oversampler's latency; Live's dry branch is the raw input with Comp on too, 190gu)
 //   - the colour is there at every setting (the device is never transparent: a "smile" EQ and a soft saturator);
 //   - Drive: three types — Soft folds the loudest peaks over (a sine folder at high drive), Medium and Hard clip with
 //     their own EQ under the drive;
@@ -68,8 +69,11 @@ struct Bell
 };
 // The drive per type (Soft, Medium, Hard) and amount (0, 25, 50, 100 %): the small-signal gain into the curve, dB
 // [MEASURED: 1 kHz at −60 dBFS, the all-zero device's +1.97 dB included]
-constexpr double driveAmounts[4] { 0.0, 0.25, 0.5, 1.0 };
-constexpr double driveDbTable[3][4] { { 1.97, 3.92, 8.91, 11.52 }, { 1.97, 5.73, 9.48, 16.98 }, { 1.97, 5.94, 7.75, 14.23 } };
+// (round 190gx: a knot at 75 %, fitted for Soft on Live's 75 % staircase and noise — 0 dBFS folds to −12.1 dBFS there;
+// Medium and Hard keep 190fk's straight line between 50 and 100 %)
+constexpr int amountKnots = 5;
+constexpr double driveAmounts[amountKnots] { 0.0, 0.25, 0.5, 0.75, 1.0 };
+constexpr double driveDbTable[3][amountKnots] { { 1.97, 3.92, 8.91, 10.16, 11.52 }, { 1.97, 5.73, 9.48, 13.23, 16.98 }, { 1.97, 5.94, 7.75, 10.99, 14.23 } };
 
 // Every constant the engine runs on, in one place (the defaults are the fitted values; the measurement harness may
 // try others)
@@ -92,41 +96,71 @@ struct Tuning
     // little better, 0.115 vs 0.124 dB, but lifts the drum loop's kick attack: the plain curve keeps every 0 % case)]
     // (round 190fk, second pass: where the level-only fit raised the staircase's THD above the rack's, (m, k) were refitted
     // for the lowest level error with THD at or under the rack's: Soft 25 %, Medium 100 %, Hard 25 / 50 / 100 %)
-    double curveM[3][4] { { 0.0, 0.1911, 0.28, 0.82 }, { 0.0, 0.40, 0.18, 0.1121 }, { 0.0, 0.1740, 0.0587, 0.0744 } };
-    double curveK[3][4] { { 1.0, 1.5246, 1.40, 1.12 }, { 1.0, 1.26, 1.36, 1.1761 }, { 1.0, 1.4394, 1.491, 1.1656 } };
+    double curveM[3][amountKnots] { { 0.0, 0.1911, 0.28, 0.8045, 0.82 }, { 0.0, 0.40, 0.18, 0.14605, 0.1121 }, { 0.0, 0.1740, 0.0587, 0.06655, 0.0744 } };
+    double curveK[3][amountKnots] { { 1.0, 1.5246, 1.40, 1.1705, 1.12 }, { 1.0, 1.26, 1.36, 1.26805, 1.1761 }, { 1.0, 1.4394, 1.491, 1.3283, 1.1656 } };
+    // round 190gx: the type EQ's depth below 100 % = typeEqDb · amount^typeEqExp [FITTED on Live's noise at 25 / 50 / 75 %:
+    // Soft and Medium keep the neutral device's shape until close to 100 % (noise TF rms Soft 0.34 / 0.58 / 0.72 →
+    // 0.19 / 0.22 / 0.20 dB, Medium 1.49 / 2.95 → 0.23 / 0.41); Hard grows in proportion (190fk's law fits best)]
+    double typeEqExp[3] { 8.0, 8.0, 1.0 };
+    double driveDb[3][amountKnots] { { 1.97, 3.92, 8.91, 10.16, 11.52 }, { 1.97, 5.73, 9.48, 13.23, 16.98 }, { 1.97, 5.94, 7.75, 10.99, 14.23 } };
     // Crunch: the mid band's lift 20·log10 (1 + crunchK · amount) between two shelves, and its grit
     double crunchK = 2.14, crunchLowHz = 95.2, crunchLowQ = 0.743, crunchHighHz = 9041.0, crunchHighQ = 0.826;
     double crunchGrit = 0.0;
+    // round 190gx: where Crunch's band lift sits — 0 = after the curve (190fk), 1 = before it, so the always-on curve
+    // grits the lifted mid band; crunchDriveDb · amount more gain into the curve (taken off after it)
+    int crunchPre = 0;
+    double crunchDriveDb = 0.0;
     // Boom (amount 0.5 fitted at decay 0.2 and 1.0): a bell at the frequency and a resonant 12 dB/oct high pass
     double boomBellDb02 = 13.75, boomBellDb10 = 18.65, boomBellQ02 = 3.32, boomBellQ10 = 2.18;
     double boomCutQ02 = 0.581, boomCutQ10 = 0.476, boomCutAt02 = 1.470, boomCutAt10 = 0.816;
+    // round 190gx: the same four at decay 0 and 0.5 (the defaults continue 190fk's straight line through 0.2 and 1.0),
+    // the bell's growth with the amount ((amount / 0.5)^boomAmtExp of its linear lift) and the cut's follow of it
+    // [FITTED on Live's decay 0 / 0.5 renders, sig + drums: 0.84 / 3.22 → 0.70 / 3.08 and 0.53 / 1.87 → 0.43 / 1.75 dB]
+    double boomBellDb00 = 14.055, boomBellQ00 = 2.807, boomCutQ00 = 0.5143, boomCutAt00 = 1.659;
+    double boomBellDb05 = 17.582, boomBellQ05 = 2.384, boomCutQ05 = 0.4297, boomCutAt05 = 1.191;
+    double boomCutAmtExp = 1.0;
+    // the bell's lift (its linear part, A − 1) and its Q at amount 0.25 and 1.0 relative to amount 0.5, straight in
+    // between and to 0 below 0.25 [FITTED on Live's amount 0.25 / 1.0 renders, sig + drums: 1.66 / 4.98 → 0.27 / 0.43 and
+    // 0.90 / 7.82 → 0.25 / 3.32 dB; Live's ring at 1.0 lasts: −20 dB/s at 50 Hz after an impulse (190fk: in proportion,
+    // the Q fixed: lift 0.5 / 2.0, Q 1 / 1)]
+    double boomGs25 = 0.1145, boomGs100 = 5.502, boomQs25 = 0.6161, boomQs100 = 2.138;
     // Damp: a first-order low pass; 0 = bilinear (zero at Nyquist), 1 = one-pole (impulse invariant: no zero at Nyquist,
     // the top flattens like Live's) [MEASURED re the all-zero device: −3 dB at 1020 / 6662 Hz for 1 / 6 kHz; the one-pole
     // fits 1 / 6 kHz at 0.36 / 0.36 dB rms against 1.44 / 1.18 for the bilinear one, round 190fk]
+    // (round 190gx: the corner sits 6 % above the set frequency [FITTED on Damping 500 Hz / 2 kHz (190gu, sig + noise) and
+    // 1 / 6 kHz (190ei): noise TF rms 0.38 / 0.36 / 0.39 / 0.38 → 0.24 / 0.26 / 0.26 / 0.24 dB])
     int dampKind = 1;
-    double dampScale = 1.0;
-    // Comp: fixed feed-forward compressor (dB), peak detector, stereo linked; pre = before the curve
-    // [FITTED on the staircase and the drum loop with Comp on, round 190fk: level rms 0.107 dB, drum segments 0.738 dB]
-    double compThresholdDb = -18.18, compRatio = 4.0, compKneeDb = 1.715, compAttackMs = 0.5273, compReleaseMs = 148.5, compMakeupDb = 11.05;
-    int compPre = 0;
+    double dampScale = 1.0604;
+    // Comp: fixed feed-forward compressor (dB), peak detector, stereo linked; pre = before the curve. Round 190gx: Live's
+    // renders with Comp + Drive 50 % and Comp + Trim −12 dB put it BEFORE the curve (right after Trim): the staircase with
+    // Drive 50 % 1.63 → 0.17 dB, its THD rms 11.6 → 2.8 dB; refitted on all eight Comp cases (190ei d70 / d71, 190gu
+    // k / w: every one closer, e.g. drum loop 0.73 → 0.48, Drive 50 % drums 2.65 → 0.73 dB)
+    double compThresholdDb = -19.70, compRatio = 2.903, compKneeDb = 5.353, compAttackMs = 1.498, compReleaseMs = 283.8, compMakeupDb = 11.11;
+    int compPre = 1;
     // Transients: attack / sustain dB per unit of the amount (positive and negative side) above the split, on Strike
     // Shaper's detector (its knobs end at ±15 / ±24 dB) [FITTED on the drum loop at −0.5 / +0.5 / +1.0, round 190fk:
     // segment levels rms 1.07 / 1.14 / 2.41 dB]
-    double tAttackPos = 22.56, tSustainPos = 19.01, tAttackNeg = 14.55, tSustainNeg = -22.47, tSplitHz = 330.5;
+    // Round 190gx: Live's Transients move steady material too (a sustained pad, rms re the neutral device: −1.0 → −3.92
+    // dB, −0.25 → −0.75, +0.25 → +1.15; the detector alone leaves a pad all but untouched), so a broadband level per unit
+    // of the amount joins the shaper, refitted with it on the drum loop and the pad (190ei d40–d42 + 190gu t-cases, no
+    // case worse: pad −1.0 3.53 → 3.05 dB, +0.25 0.98 → 0.80, drums −1.0 3.76 → 3.62, +0.25 0.75 → 0.60). Live's full
+    // steady-state cut at −1.0 is not reached: a larger level term moves the drum loop's segments off (190ei renders).
+    double tAttackPos = 22.96, tSustainPos = 17.18, tAttackNeg = 15.49, tSustainNeg = -15.47, tSplitHz = 330.5;
+    double tLevelPos = 0.80, tLevelNeg = -0.633;
     // an extra fixed low cut after the colour (12 dB/oct, Q 0.707; 0 = none: Boom's high pass does that job)
     double lowCutHz = 0.0;
     // the output stage's ceiling (0 = none): a soft clip whose peaks stay under `ceiling`
-    double ceiling = 0.0;
+    double ceiling = 0.0, ceilingKnee = 0.7;
 };
 
 // a value of a per-amount table (0, 25, 50, 100 %), piecewise linear in the amount
 inline double byAmount (const double* ys, double amount) noexcept
 {
     const auto x = std::clamp (amount, 0.0, 1.0);
-    for (int i = 1; i < 4; ++i)
+    for (int i = 1; i < amountKnots; ++i)
         if (x <= driveAmounts[i])
             return ys[i - 1] + (ys[i] - ys[i - 1]) * (x - driveAmounts[i - 1]) / (driveAmounts[i] - driveAmounts[i - 1]);
-    return ys[3];
+    return ys[amountKnots - 1];
 }
 // The curve's small-signal drive gain (dB) for a type and amount
 inline double driveGainDb (Type type, double amount) noexcept { return byAmount (driveDbTable[(int) type], amount); }
@@ -137,17 +171,32 @@ struct BoomBands
 {
     double hz = 50.0, bellDb = 0.0, bellQ = 2.0, cutHz = 10.0, cutQ = 0.5;
 };
+// a value at decay 0 / 0.2 / 0.5 / 1.0, piecewise linear in the decay
+inline double byDecay (double d0, double d02, double d05, double d10, double decay) noexcept
+{
+    const auto d = std::clamp (decay, 0.0, 1.0);
+    if (d <= 0.2) return d0 + (d02 - d0) * d / 0.2;
+    if (d <= 0.5) return d02 + (d05 - d02) * (d - 0.2) / 0.3;
+    return d05 + (d10 - d05) * (d - 0.5) / 0.5;
+}
 inline BoomBands boomBands (const Tuning& t, double amount, double hz, double decay) noexcept
 {
     BoomBands b;
     const auto a = std::clamp (amount, 0.0, 1.0);
-    const auto x = (std::clamp (decay, 0.0, 1.0) - 0.2) / 0.8;
     b.hz = std::clamp (hz, 30.0, 90.0);
-    const auto atHalf = std::pow (10.0, (t.boomBellDb02 + (t.boomBellDb10 - t.boomBellDb02) * x) / 20.0) - 1.0;
-    b.bellDb = std::clamp (20.0 * std::log10 (1.0 + atHalf * a / 0.5), 0.0, 30.0);
-    b.bellQ = std::clamp (t.boomBellQ02 + (t.boomBellQ10 - t.boomBellQ02) * x, 1.0, 6.0);
-    b.cutQ = std::clamp (t.boomCutQ02 + (t.boomCutQ10 - t.boomCutQ02) * x, 0.3, 1.5);
-    b.cutHz = std::max (10.0, b.hz * std::clamp (t.boomCutAt02 + (t.boomCutAt10 - t.boomCutAt02) * x, 0.5, 2.0) * std::min (1.0, a / 0.5));
+    const auto atHalf = std::pow (10.0, byDecay (t.boomBellDb00, t.boomBellDb02, t.boomBellDb05, t.boomBellDb10, decay) / 20.0) - 1.0;
+    const auto rel = a / 0.5;
+    // the amount's scale of the lift and of the Q (1 at 0.5; knots at 0.25 and 1.0; the lift → 0 at 0)
+    const auto byAmt = [a] (double at25, double at100, bool toZero) {
+        if (a <= 0.25) return toZero ? at25 * a / 0.25 : at25;
+        if (a <= 0.5) return at25 + (1.0 - at25) * (a - 0.25) / 0.25;
+        return 1.0 + (at100 - 1.0) * (a - 0.5) / 0.5;
+    };
+    b.bellDb = std::clamp (20.0 * std::log10 (1.0 + atHalf * byAmt (t.boomGs25, t.boomGs100, true)), 0.0, 40.0);
+    b.bellQ = std::clamp (byDecay (t.boomBellQ00, t.boomBellQ02, t.boomBellQ05, t.boomBellQ10, decay) * byAmt (t.boomQs25, t.boomQs100, false), 0.5, 80.0);
+    b.cutQ = std::clamp (byDecay (t.boomCutQ00, t.boomCutQ02, t.boomCutQ05, t.boomCutQ10, decay), 0.3, 1.5);
+    const auto follow = rel <= 1.0 ? rel : (t.boomCutAmtExp == 1.0 ? 1.0 : std::pow (rel, t.boomCutAmtExp - 1.0));
+    b.cutHz = std::max (10.0, b.hz * std::clamp (byDecay (t.boomCutAt00, t.boomCutAt02, t.boomCutAt05, t.boomCutAt10, decay), 0.5, 2.0) * follow);
     return b;
 }
 // The transient shaper's attack / sustain gains (dB) for an amount −1 … +1
@@ -203,7 +252,10 @@ public:
         pre.reset();
         for (auto& b : eq)
             b.reset();
+        for (auto& b : crunchEq)
+            b.reset();
         dampLp.reset();
+        boomBell.reset();
         dcHp.reset();
         splitLow[0] = splitLow[1] = 0.0;
         shaper.reset();
@@ -212,6 +264,7 @@ public:
         dryL.fill (0.0f);
         dryR.fill (0.0f);
         rampsReady = false;
+        levelReady = false;
     }
 
     // last block's gain reduction of Comp (dB, ≥ 0) and the transient gains (dB), for the editor
@@ -239,8 +292,11 @@ private:
     };
 
     // one Facet-style band (core/FacetEq.h's analog prototypes and magnitude-matched sections) into eq[k]
-    int band (int k, facet::Shape shape, double hz, double db, double q) noexcept
+    int band (int k, facet::Shape shape, double hz, double db, double q) noexcept { return band (eq, k, shape, hz, db, q); }
+    template <std::size_t N>
+    int band (std::array<Biquad, N>& dst, int k, facet::Shape shape, double hz, double db, double q) noexcept
     {
+        const int cap = (int) N;
         EffectParams p {};
         p[(std::size_t) facet::scaleParam] = 0.5f; // 100 %
         p[(std::size_t) facet::param (0, 0)] = facet::shapeValue (shape);
@@ -252,9 +308,9 @@ private:
         p[(std::size_t) facet::param (0, 4)] = facet::slopeValue (12);
         std::array<facet::Section, facet::maxSections> s {};
         const int count = facet::design (p, 0, sr, s);
-        for (int i = 0; i < count && k < eqMax; ++i, ++k)
+        for (int i = 0; i < count && k < cap; ++i, ++k)
         {
-            auto& b = eq[(std::size_t) k];
+            auto& b = dst[(std::size_t) k];
             b.b0 = s[(std::size_t) i].b0;
             b.b1 = s[(std::size_t) i].b1;
             b.b2 = s[(std::size_t) i].b2;
@@ -270,8 +326,8 @@ private:
         const auto ti = (int) s.type;
         const auto d = std::clamp ((double) s.drive, 0.0, 1.0);
         // the curve's input and output gains
-        driveGain = std::pow (10.0, driveGainDb (s.type, d) / 20.0);
-        const auto eqDb = t.typeEqDb[ti] * d;
+        driveGain = std::pow (10.0, byAmount (t.driveDb[ti], d) / 20.0);
+        const auto eqDb = t.typeEqDb[ti] * (t.typeEqExp[ti] == 1.0 ? d : std::pow (d, t.typeEqExp[ti]));
         // the type's EQ at 1 kHz (analog prototype), so the measured 1 kHz levels hold
         double typeAt1k = 0.0;
         if (std::abs (eqDb) > 1e-9)
@@ -318,22 +374,44 @@ private:
         if (std::abs (eqDb) > 1e-9)
             k = band (k, s.type == Type::hard ? facet::Shape::lowShelf : facet::Shape::bell, t.typeEqHz[ti], eqDb, t.typeEqQ[ti]);
         const auto cDb = crunchDb (t, s.crunch);
-        if (cDb > 1e-9)
+        crunchAmount = std::clamp ((double) s.crunch, 0.0, 1.0);
+        crunchCount = 0;
+        crunchPreGain = crunchPostGain = 1.0;
+        if (cDb > 1e-9 && t.crunchPre == 0)
         {
             k = band (k, facet::Shape::lowShelf, t.crunchLowHz, -cDb, t.crunchLowQ);
             k = band (k, facet::Shape::highShelf, t.crunchHighHz, -cDb, t.crunchHighQ);
         }
-        crunchAmount = std::clamp ((double) s.crunch, 0.0, 1.0);
+        else if (cDb > 1e-9)
+        {
+            // round 190gx: the lift before the curve (the 1 kHz sine at −12 dBFS gains Live's THD: 1.0 → 2.3 / 4.4 / 12 %
+            // at Crunch 0.25 / 0.5 / 1.0), its make-up gain there too; crunchDriveDb more into the curve, taken off after
+            crunchCount = band (crunchEq, 0, facet::Shape::lowShelf, t.crunchLowHz, -cDb, t.crunchLowQ);
+            crunchCount = band (crunchEq, crunchCount, facet::Shape::highShelf, t.crunchHighHz, -cDb, t.crunchHighQ);
+            const auto extra = t.crunchDriveDb * crunchAmount;
+            crunchPreGain = std::pow (10.0, (cDb + extra) / 20.0);
+            crunchPostGain = std::pow (10.0, -extra / 20.0);
+        }
+        if (! configured || crunchCount != lastCrunchCount)
+            for (auto& b : crunchEq)
+                b.reset();
+        lastCrunchCount = crunchCount;
         // Boom: its bell, and its resonant high pass — there at every setting (at 10 Hz with Boom at 0, which is also
         // what keeps the all-zero device's lowest octave where Live's is: +1.7 dB at 31 Hz)
         {
             const auto b = boomBands (t, s.boom, boomHz (s.boomFreq), s.boomDecay);
-            if (s.boom > 1.0e-4f)
-                k = band (k, facet::Shape::bell, b.hz, b.bellDb, b.bellQ);
+            // (round 190gx: the bell is the cookbook peak of the same analog prototype, so Live's long rings at high
+            // amounts fit: Q and lift beyond the Facet section's ±30 dB / Q 28 range)
+            const auto bellOn = s.boom > 1.0e-4f;
+            if (bellOn)
+                boomBell.peaking (sr, b.hz, b.bellQ, b.bellDb);
+            if (bellOn != boomOn || ! configured)
+                boomBell.reset();
+            boomOn = bellOn;
             k = band (k, facet::Shape::lowCut, b.cutHz, 0.0, b.cutQ);
         }
         eqCount = k;
-        colourGain = std::pow (10.0, (t.colourGainDb + cDb) / 20.0);
+        colourGain = std::pow (10.0, (t.colourGainDb + (t.crunchPre == 0 ? cDb : 0.0)) / 20.0) * crunchPostGain;
         if (! configured)
             for (auto& b : eq)
                 b.reset();
@@ -395,9 +473,12 @@ private:
         if (compOn && t.compPre != 0)
             compress (l, r, n);
 
-        // pre-emphasis, drive, the curve (oversampled), the DC guard, the stage's output
+        // pre-emphasis, (Crunch's lift when it sits before the curve), drive, the curve (oversampled), the DC guard, the
+        // stage's output
         pre.processBlock (l, r, n);
-        const auto g = (float) driveGain;
+        for (int k = 0; k < crunchCount; ++k)
+            crunchEq[(std::size_t) k].processBlock (l, r, n);
+        const auto g = (float) (driveGain * crunchPreGain);
         for (int i = 0; i < n; ++i)
         {
             l[i] *= g;
@@ -419,6 +500,8 @@ private:
         // the EQ
         for (int k = 0; k < eqCount; ++k)
             eq[(std::size_t) k].processBlock (l, r, n);
+        if (boomOn)
+            boomBell.processBlock (l, r, n);
         const auto cg = (float) colourGain;
         for (int i = 0; i < n; ++i)
         {
@@ -436,6 +519,26 @@ private:
             shape (l, r, n, amount);
         else
             idleSplit (l, r, n);
+        {
+            const auto levelDb = amount >= 0.0 ? t.tLevelPos * amount : t.tLevelNeg * -amount;
+            const auto target = (float) std::pow (10.0, levelDb / 20.0);
+            if (! levelReady)
+            {
+                levelGain = target;
+                levelReady = true;
+            }
+            if (target != 1.0f || levelGain != 1.0f)
+            {
+                const auto step = (target - levelGain) / (float) n;
+                for (int i = 0; i < n; ++i)
+                {
+                    levelGain += step;
+                    l[i] *= levelGain;
+                    r[i] *= levelGain;
+                }
+            }
+            levelGain = target;
+        }
 
         // Output, the ceiling, Dry/Wet
         const auto outStep = (outTarget - outGain) / (float) n;
@@ -464,7 +567,7 @@ private:
 
     float ceil (float x) const noexcept
     {
-        const auto c = (float) tune.ceiling, knee = 0.7f * c, room = c - knee;
+        const auto c = (float) tune.ceiling, knee = (float) tune.ceilingKnee * c, room = c - knee;
         const auto a = std::abs (x);
         if (a <= knee) return x;
         const auto y = knee + room * std::tanh ((a - knee) / room);
@@ -549,6 +652,11 @@ private:
     Biquad pre, dampLp;
     std::array<Biquad, eqMax> eq {};
     int eqCount = 0;
+    Biquad boomBell;
+    bool boomOn = false;
+    std::array<Biquad, 4> crunchEq {};
+    int crunchCount = 0, lastCrunchCount = 0;
+    double crunchPreGain = 1.0, crunchPostGain = 1.0;
     Biquad dcHp;
     strike::Shaper shaper;
     double splitLow[2] {};
@@ -556,7 +664,8 @@ private:
     float foldKf = 1.0f, foldInv = 1.0f, foldMixf = 0.0f;
     bool dampOn = false, configured = false, rampsReady = false;
     double grDb = 0.0, attackCoef = 0.0, releaseCoef = 0.0;
-    float trimGain = 1.0f, outGain = 1.0f, wet = 1.0f;
+    float trimGain = 1.0f, outGain = 1.0f, wet = 1.0f, levelGain = 1.0f;
+    bool levelReady = false;
     Settings last;
     std::array<float, maxDry> dryL {}, dryR {};
     int dryPos = 0;

+ 21 - 19
src/core/PluginLayout.cpp

@@ -2336,31 +2336,33 @@ Layout strikeLayout()
     return l;
 }
 
-// round 190fk: Anvil Bus, LYNX's drum-bus processor. The generic layout: DRIVE (type keys, Drive big, Crunch, Damp) on
-// the left, TRANSIENTS big in the middle, BOOM (amount big, frequency, decay) on the right, Comp, Trim, Output and Dry/Wet
-// along the bottom (the editor, ui/ProEditors.cpp AnvilEditor, draws the forged-steel look)
+// round 190fk: Anvil Bus, LYNX's drum-bus processor (the editor draws the forged-steel look, ui/PluginArtEffects.inc).
+// Round 190gx: the controls in the reference's four columns, top to bottom [Live 12.4 Drum Buss panel shot,
+// /mnt/e/lynx-work/live190gu/drumbus/live-drumbuss-panel-type0-drive25.png]: Drive, the three types stacked, Trim, Comp |
+// Crunch, Damp, Transients | Boom, Freq., Decay | the Output fader and Dry/Wet (the reference's Bass meter, Force to note
+// and Boom audition are left out: LYNX has no such outputs)
 Layout anvilLayout()
 {
     Layout l;
     l.width = 600;
     l.height = 330;
     auto& v = l.items;
-    v.push_back (section (4, 4, 196, 250, TR_NOOP ("Drive")));
-    v.push_back (tabs (16, 30, 172, 22, "Drive type", TR_NOOP ("Soft|Medium|Hard"), { 0.0f, 0.5f, 1.0f }));
-    v.push_back (dial (102, 100, 64, "Drive", TR_NOOP ("Drive"), big));
-    v.push_back (dial (56, 196, 36, "Crunch", TR_NOOP ("Crunch")));
-    v.push_back (dial (148, 196, 36, "Damp", TR_NOOP ("Damp")));
-    v.push_back (section (204, 4, 192, 250, TR_NOOP ("Transients")));
-    v.push_back (dial (300, 110, 80, "Transients", TR_NOOP ("Transients"), bipolar | big));
-    v.push_back (section (400, 4, 196, 250, TR_NOOP ("Boom")));
-    v.push_back (dial (498, 100, 64, "Boom", TR_NOOP ("Boom"), big));
-    v.push_back (dial (452, 196, 36, "Boom freq.", TR_NOOP ("Freq.")));
-    v.push_back (dial (544, 196, 36, "Boom decay", TR_NOOP ("Decay")));
-    v.push_back (section (4, 258, 592, 68, "", boxed));
-    v.push_back (toggle (24, 278, 80, 26, "Comp", TR_NOOP ("Comp")));
-    v.push_back (dial (220, 280, 28, "Trim", TR_NOOP ("Trim")));
-    v.push_back (dial (360, 280, 28, "Output", TR_NOOP ("Output")));
-    v.push_back (dial (500, 280, 28, "Dry/Wet", TR_NOOP ("Dry/Wet")));
+    v.push_back (section (4, 4, 146, 322, TR_NOOP ("Drive")));
+    v.push_back (dial (77, 68, 52, "Drive", TR_NOOP ("Drive"), big));
+    v.push_back (radio (30, 118, 94, 72, "Drive type", TR_NOOP ("Soft|Medium|Hard"), { 0.0f, 0.5f, 1.0f }));
+    v.push_back (dial (77, 226, 30, "Trim", TR_NOOP ("Trim")));
+    v.push_back (toggle (22, 286, 110, 26, "Comp", TR_NOOP ("Comp")));
+    v.push_back (section (154, 4, 146, 322, "", boxed));
+    v.push_back (dial (227, 58, 40, "Crunch", TR_NOOP ("Crunch")));
+    v.push_back (dial (227, 150, 40, "Damp", TR_NOOP ("Damp")));
+    v.push_back (dial (227, 246, 48, "Transients", TR_NOOP ("Transients"), bipolar | big));
+    v.push_back (section (304, 4, 146, 322, TR_NOOP ("Boom")));
+    v.push_back (dial (377, 68, 52, "Boom", TR_NOOP ("Boom"), big));
+    v.push_back (dial (377, 162, 40, "Boom freq.", TR_NOOP ("Freq.")));
+    v.push_back (dial (377, 250, 40, "Boom decay", TR_NOOP ("Decay")));
+    v.push_back (section (454, 4, 142, 322, "", boxed));
+    v.push_back (slider (Item::vslider, 505, 24, 40, 200, "Output", TR_NOOP ("Output")));
+    v.push_back (dial (525, 276, 30, "Dry/Wet", TR_NOOP ("Dry/Wet")));
     return l;
 }
 

+ 3 - 2
tests/Anvil190fkTests.inc

@@ -142,7 +142,8 @@ TEST (anvil190fk_safe_at_the_extremes)
 {
     using namespace lynx;
     namespace a = anvil;
-    // every control at its ends, a +12 dBFS square wave then silence: finite, no denormals left, reset clean
+    // every control at its ends, a +12 dBFS square wave then silence: finite, no denormals left, reset clean (round 190gx:
+    // ten seconds of silence — Boom at 1.0 rings for seconds, as Live's does: −20 dB/s at 50 Hz)
     for (const float v : { 0.0f, 1.0f })
     {
         EffectParams p {};
@@ -152,7 +153,7 @@ TEST (anvil190fk_safe_at_the_extremes)
         e.prepare (44100.0);
         std::vector<float> l (4096), r (4096);
         bool finite = true;
-        for (int b = 0; b < 40; ++b)
+        for (int b = 0; b < 128; ++b)
         {
             for (int i = 0; i < 4096; ++i)
                 l[(std::size_t) i] = r[(std::size_t) i] = b < 20 ? ((i / 50) % 2 ? 4.0f : -4.0f) : 0.0f;

+ 148 - 0
tests/AnvilBus190gxTests.inc

@@ -0,0 +1,148 @@
+// --- Round 190gx: Anvil Bus refitted on Live 12.4's second Drum Buss render set (round 190gu: 46 cases at 44.1 / 48 /
+// 96 kHz; /mnt/e/lynx-work/livefacts190gx/db/REPORT.md). The numbers in the checks are Live's own measurements.
+
+namespace anvil190gx
+{
+using namespace lynx;
+
+// the engine on a stereo-identical signal (256-sample blocks) at `rate`; the output, latency removed
+inline std::vector<float> run (const EffectParams& p, std::vector<float> x, double rate = 48000.0)
+{
+    anvil::Engine e;
+    e.prepare (rate);
+    auto r = x;
+    for (int at = 0; at < (int) x.size(); at += 256)
+        e.process (x.data() + at, r.data() + at, std::min (256, (int) x.size() - at), p.data());
+    x.erase (x.begin(), x.begin() + anvil::Engine::latency());
+    return x;
+}
+inline double rmsDb (const std::vector<float>& x, std::size_t from, std::size_t to)
+{
+    double s = 0.0;
+    for (auto i = from; i < to && i < x.size(); ++i)
+        s += (double) x[i] * x[i];
+    return 10.0 * std::log10 (s / (double) std::max<std::size_t> (1, to - from) + 1e-30);
+}
+// a sustained chord of detuned band-limited saws (A3 / C#4 / E4, like the measurement's pad), peak about 0.5
+inline std::vector<float> pad (double rate, double seconds)
+{
+    std::vector<float> x ((std::size_t) (rate * seconds));
+    const double roots[3] { 220.0, 277.18, 329.63 }, detune[3] { 0.997, 1.0, 1.003 };
+    for (std::size_t i = 0; i < x.size(); ++i)
+    {
+        double v = 0.0;
+        for (const auto f0 : roots)
+            for (const auto d : detune)
+                for (int h = 1; h <= 20; ++h)
+                    v += std::sin (2.0 * 3.141592653589793 * f0 * d * h * (double) i / rate) / h;
+        x[i] = (float) (0.02 * v);
+    }
+    return x;
+}
+} // namespace anvil190gx
+
+TEST (anvil190gx_comp_sits_before_the_curve)
+{
+    using namespace lynx;
+    namespace a = anvil;
+    using anvil190fk::params;
+    using anvil190fk::sineOut;
+    CHECK (a::Tuning {}.compPre == 1);
+    // Comp + Drive 50 % (Soft), the 1 kHz staircase [Live 190gu: −36 → −16.03, −24 → −5.03, −12 → −1.16, 0 → −0.57 dBFS]
+    const auto p = params ({ { a::comp, 1.0f }, { a::drive, 0.5f } });
+    CHECK (std::abs (sineOut (p, -36.0) - (-16.03)) < 0.5);
+    CHECK (std::abs (sineOut (p, -24.0) - (-5.03)) < 0.5);
+    CHECK (std::abs (sineOut (p, -12.0) - (-1.16)) < 0.5);
+    // Comp + Trim −12 dB [Live: −36 → −34.90, −12 → −11.08, 0 → −4.96 dBFS]
+    const auto t = params ({ { a::comp, 1.0f }, { a::trim, a::trimValue (-12.0) } });
+    CHECK (std::abs (sineOut (t, -36.0) - (-34.90)) < 0.3 && std::abs (sineOut (t, -12.0) - (-11.08)) < 0.3 && std::abs (sineOut (t, 0.0) - (-4.96)) < 0.4);
+}
+
+TEST (anvil190gx_dry_wet_blends_the_raw_input_with_comp_on)
+{
+    // Live 190gu: Comp on, Dry/Wet 0.5 = 0.5 · input + 0.5 · the Comp-on device, sample for sample (within 0.005 dB on
+    // every step of the staircase); LYNX's blend is that exactly
+    using namespace lynx;
+    namespace a = anvil;
+    std::vector<float> x (48000);
+    for (std::size_t i = 0; i < x.size(); ++i)
+        x[i] = (float) (0.4 * std::sin (2.0 * 3.141592653589793 * 1000.0 * (double) i / 48000.0) * std::min (1.0, (double) i / 4800.0));
+    const auto wet = anvil190gx::run (anvil190fk::params ({ { a::comp, 1.0f } }), x);
+    const auto half = anvil190gx::run (anvil190fk::params ({ { a::comp, 1.0f }, { a::dryWet, 0.5f } }), x);
+    double worst = 0.0;
+    for (std::size_t i = 1000; i < half.size(); ++i)
+        worst = std::max (worst, std::abs ((double) half[i] - (0.5 * x[i] + 0.5 * wet[i])));
+    CHECK (worst < 1.0e-5);
+}
+
+TEST (anvil190gx_boom_amount_sets_the_ring)
+{
+    using namespace lynx;
+    namespace a = anvil;
+    using anvil190fk::params;
+    using anvil190fk::relGain;
+    // small-signal lift at 50 Hz (decay 1.0) grows with the amount [Live noise TF re the neutral device: +4.0 dB at 0.25,
+    // +14.1 at 0.5, ≥ +20.8 at 1.0 (the measurement's 2.9 Hz bins under-read the 1.0 peak)]
+    const auto at = [] (float amount) {
+        return relGain (params ({ { a::boom, amount }, { a::boomFreq, a::boomHzValue (50.0) }, { a::boomDecay, 1.0f } }), 50.0);
+    };
+    const auto g25 = at (0.25f), g50 = at (0.5f), g100 = at (1.0f);
+    CHECK (g25 > 2.0 && g25 < 7.0);
+    CHECK (std::abs (g50 - 14.1) < 2.5);
+    CHECK (g100 > 20.0);
+    // the ring after an impulse lasts at 1.0 [Live: 50 Hz still −42 → −50 dB from 0.02 to 0.4 s after it, about −20 dB/s]
+    std::vector<float> x (48000 * 2, 0.0f);
+    x[4800] = 1.0f;
+    const auto y = anvil190gx::run (params ({ { a::boom, 1.0f }, { a::boomFreq, a::boomHzValue (50.0) }, { a::boomDecay, 1.0f } }), x);
+    const auto early = anvil190gx::rmsDb (y, 4800 + 960, 4800 + 960 + 2400), late = anvil190gx::rmsDb (y, 4800 + 14400, 4800 + 14400 + 2400);
+    CHECK (early - late < 25.0); // 0.25 s apart: Live −6 dB; 190fk's fixed Q fell ~60 dB
+}
+
+TEST (anvil190gx_soft_75_and_type_eq_depth)
+{
+    using namespace lynx;
+    namespace a = anvil;
+    using anvil190fk::params;
+    using anvil190fk::sineOut;
+    using anvil190fk::relGain;
+    // Soft 75 %: small signal +10.22 dB, 0 dBFS folds to −12.1 dBFS [Live 190gu a075s]
+    const auto s75 = params ({ { a::drive, 0.75f } });
+    CHECK (std::abs (sineOut (s75, -60.0) - (-60.0 + 10.22)) < 0.15);
+    CHECK (sineOut (s75, 0.0) < -5.0);
+    // Medium 50 %: no dip around 180 Hz yet (Live's noise TF keeps the neutral shape; the −16 dB bell is a 100 % thing)
+    const auto m50 = params ({ { a::drive, 0.5f }, { a::driveType, 0.5f } }), m0 = params ({ { a::driveType, 0.5f } });
+    const auto dip = (relGain (m50, 180.0) - relGain (m0, 180.0)) - (relGain (m50, 1000.0) - relGain (m0, 1000.0));
+    CHECK (std::abs (dip) < 1.5);
+}
+
+TEST (anvil190gx_rate_independent)
+{
+    // Live's three render rates agree within 0.25 dB rms; LYNX's engine: the same settings on the pad at 44.1 / 48 / 96 kHz
+    using namespace lynx;
+    namespace a = anvil;
+    const auto p = anvil190fk::params ({ { a::drive, 0.5f }, { a::comp, 1.0f }, { a::boom, 0.5f }, { a::transients, a::transientsValue (-0.5) } });
+    double level[3] {};
+    const double rates[3] { 44100.0, 48000.0, 96000.0 };
+    for (int k = 0; k < 3; ++k)
+    {
+        const auto y = anvil190gx::run (p, anvil190gx::pad (rates[k], 1.5), rates[k]);
+        level[k] = anvil190gx::rmsDb (y, (std::size_t) (rates[k] * 0.5), (std::size_t) (rates[k] * 1.4));
+    }
+    CHECK (std::abs (level[0] - level[1]) < 0.25 && std::abs (level[2] - level[1]) < 0.25);
+}
+
+TEST (anvil190gx_transients_move_a_steady_pad)
+{
+    // Live 190gu: a sustained pad's rms re the neutral device: −1.0 → −3.92 dB, +0.25 → +1.15 dB. Anvil Bus holds the
+    // direction with part of the depth (a deeper level term moves the drum loop's measured segments off)
+    using namespace lynx;
+    namespace a = anvil;
+    const auto x = anvil190gx::pad (48000.0, 1.5);
+    const auto level = [&] (double t) {
+        const auto y = anvil190gx::run (anvil190fk::params ({ { a::transients, a::transientsValue (t) } }), x);
+        return anvil190gx::rmsDb (y, 24000, 67200);
+    };
+    const auto neutral = level (0.0);
+    CHECK (level (-1.0) - neutral < -0.4);
+    CHECK (level (0.25) - neutral > 0.3);
+}

+ 1 - 0
tests/tests.cpp

@@ -17585,6 +17585,7 @@ TEST (fl_low_lifter_matches_fl_engine)
 #include "Follow190fgTests.inc"
 #include "Relfix190fpTests.inc"
 #include "Anvil190fkTests.inc"
+#include "AnvilBus190gxTests.inc"
 #include "Donate190fqTests.inc"
 #include "GenPreset190fsTests.inc"
 #include "Issues190ftTests.inc"