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

Merge wip/parity190ar-translate

# Conflicts:
#	tests/tests.cpp
Ka1-S 3 недель назад
Родитель
Сommit
7cfdf7bbf9

+ 41 - 0
docs/PARITY.md

@@ -2278,6 +2278,47 @@ Proof: `docs/analise/REA_rodada186c.md` (REA of FL 2026 + a hand check in FL).
 | Links to deleted inserts (pain point 1) | dropped | Mixer menu option, off: kept as a greyed dashed chip, "Disconnected links" in the Routing section reconnects or removes them | LYNX extra |
 | Mixer groups that follow the Playlist (pain point 4) | none | Mixer menu option, off, + "Arrange inserts like the Playlist" | LYNX extra |
 
+## Round 190ar, part 2: missing plugins load with the measured settings (fitted-map translators)
+
+Until now a project that used one of these six plugins and was opened without it got LYNX's stand-in at its default
+settings. Round 190ar measured, black-box, which LYNX setting matches each of their settings (one fitted transfer per
+control, from probe renders through the public parameters). `translate = fitted-map` carries those transfers into the
+substitute table: the saved state's parameter values are read (the plugin's own plain XML state as the host stores
+it, captured by saving probe settings; nothing else of the plugin is read) and every linked LYNX parameter is set from
+the measured transfer, linear between the measured settings. A state that cannot be read leaves the stand-in at
+its defaults, as before. Nothing changes for projects that have the plugin installed, and no LYNX effect's sound
+changed.
+
+Scores of what the stand-in sounds like against the plugin (before = stand-in at its defaults = what a project got
+until now; after = stand-in with the translated state):
+
+| Missing plugin (kind) | Stand-in | Bank | Files | Before → after | Null | Level error | Up / same / down |
+|---|---|---|---|---|---|---|---|
+| Bus compressor (SSL Native Bus Compressor 2) | Crest Compressor | tp172c | 16 | 2.69 → 6.06 | 1.1 → −23.2 dB | 8.6 → 0.4 dB | 14 / 2 / 0 |
+| | | programme 182 | 20 | 2.60 → 6.20 | 1.2 → −23.9 dB | 8.9 → 0.5 dB | 19 / 1 / 0 |
+| Compressor (SSL Native X-Comp) | Crest Compressor | tp172c | 12 | 1.75 → 6.75 | 0.9 → −37.3 dB | 7.7 → 0.6 dB | 12 / 0 / 0 |
+| | | programme 182 | 25 | 3.00 → 6.44 | −6.1 → −35.1 dB | 4.9 → 0.6 dB | 21 / 4 / 0 |
+| Limiter (FG-X 2) | Apex Limiter | tp172c | 12 | 3.92 → 7.58 | −50.3 → −90.1 dB | 3.7 → 0.3 dB | 10 / 2 / 0 |
+| | | programme 182 | 25 | 3.48 → 7.44 | −50.7 → −66.6 dB | 3.8 → 0.2 dB | 20 / 5 / 0 |
+| Saturator (SSL Native X-Saturator) | Ember Saturator | tp172c | 12 | 2.33 → 5.00 | −6.4 → −18.3 dB | 8.4 → 1.0 dB | 11 / 1 / 0 |
+| | | programme 182 | 25 | 2.04 → 5.60 | −6.5 → −19.7 dB | 7.1 → 0.8 dB | 24 / 1 / 0 |
+| Gate (SSL X-Gate) | Sentry Gate | tp172c | 12 | 6.75 → 7.33 | −23.3 → −33.6 dB | 0.1 → 0.0 dB | 5 / 7 / 0 |
+| | | programme 182 | 25 | 6.56 → 7.24 | −30.9 → −35.9 dB | 0.1 → 0.1 dB | 11 / 14 / 0 |
+| Lookahead compressor (Harrison) | Crest Compressor | tp172c | 8 | 2.75 → 5.50 | −7.2 → −18.6 dB | 3.3 → 1.2 dB | 7 / 1 / 0 |
+| | | programme 182 | 25 | 3.04 → 5.92 | −9.8 → −22.1 dB | 3.1 → 0.7 dB | 19 / 5 / 1 |
+
+The tp172c rows and the lookahead compressor's programme row are rendered from the C++ translator's own output on the
+captured states; the other programme rows are the same maps evaluated by the fitter (the C++ translator agrees with it
+within 2e-4 on the 18 captured states of the test). The lookahead compressor's map was fitted again on the Vari-mu
+law of round 190v (33 files: 5.48 with the old map on the new law → 5.82). One file went down (lookahead compressor,
+one vocal setting, 6 → 5).
+
+Limits: values between the captured settings are interpolated, and a few fitted transfers are not monotonic (they
+are carried as measured); beyond the captured range the first-to-last trend continues. The second (A/B) slot of the
+FG-X 2 state is not read. The EQ modules have no translator: their fitted per-setting maps are not smooth enough to
+interpolate (a translation in physical units is needed). The FET compressors and X-Limit need the new laws of this
+round and get their translators once those are in.
+
 ## Round 177b: workflow extras beyond FL (FL's own way stays unchanged)
 
 | Feature | FL Studio | LYNX | Status |

+ 47 - 0
src/core/FittedMaps.inc

@@ -0,0 +1,47 @@
+// Generated by round 190ar's tr/gentr.py from the fitted setting maps and captured component states: do not edit.
+    { "PluginName=\"SSL Native Bus Compressor 2\"", "Crest Compressor",
+      { { 0, 0.55f }, { 3, 0.4276f }, { 34, 0.0f } },
+      { { "Threshold", 1, false, false, { { -20.0f, 0.3323f }, { -15.0f, 0.39645f }, { -10.0f, 0.42305f }, { -8.0f, 0.43369f }, { -5.0f, 0.48586f }, { 0.0f, 0.57282f }, { 5.0f, 0.65977f }, { 10.0f, 0.74672f }, { 15.0f, 0.83368f }, { 20.0f, 0.92063f } } },
+        { "Ratio", 2, false, false, { { 0.0f, 0.48286f }, { 1.0f, 0.51666f }, { 2.0f, 0.58326f }, { 3.0f, 0.62322f }, { 4.0f, 0.61161f }, { 5.0f, 0.5971f }, { 6.0f, 0.60786f } } },
+        { "MakeupGain", 37, false, false, { { -5.0f, 0.44406f }, { -2.5f, 0.46878f }, { 0.0f, 0.4935f }, { 2.5f, 0.51822f }, { 5.0f, 0.54294f }, { 7.5f, 0.56766f }, { 10.0f, 0.59238f }, { 12.5f, 0.6171f }, { 15.0f, 0.64182f } } },
+        { "Attack", 5, false, false, { { 0.0f, 0.28328f }, { 1.0f, 0.35923f }, { 2.0f, 0.48578f }, { 3.0f, 0.5871f }, { 4.0f, 0.66322f }, { 5.0f, 0.75837f }, { 6.0f, 0.79628f } } },
+        { "Release", 6, false, false, { { 0.0f, 0.1448f }, { 1.0f, 0.1448f }, { 2.0f, 0.1448f }, { 3.0f, 0.1448f }, { 4.0f, 0.17226f }, { 5.0f, 0.22718f }, { 6.0f, 0.2455f } } },
+        { "Release", 7, false, true, { { 0.0f, 1.0f }, { 1.0f, 1.0f }, { 2.0f, 1.0f }, { 3.0f, 1.0f }, { 4.0f, 1.0f }, { 5.0f, 0.0f }, { 6.0f, 1.0f } } },
+        { "DryWetMix", 35, false, false, { { 0.0f, 0.0f }, { 12.5f, 0.0f }, { 25.0f, 0.13197f }, { 37.5f, 0.27664f }, { 50.0f, 0.42131f }, { 62.5f, 0.56598f }, { 75.0f, 0.71066f }, { 87.5f, 0.85533f }, { 100.0f, 1.0f } } } } },
+    { "PluginName=\"SSL Native X-Comp v6\"", "Crest Compressor",
+      { { 0, 0.0f }, { 34, 0.0f } },
+      { { "threshold", 1, false, false, { { -48.0f, 0.05556f }, { -40.5f, 0.18774f }, { -33.0f, 0.37641f }, { -30.0f, 0.45188f }, { -25.5f, 0.56509f }, { -24.0f, 0.60282f }, { -22.0f, 0.65308f }, { -20.0f, 0.70395f }, { -18.0f, 0.72228f }, { -10.5f, 0.79171f }, { -3.0f, 0.86114f }, { 4.5f, 0.93057f }, { 12.0f, 1.0f } } },
+        { "ratio", 2, false, false, { { 1.0f, 0.0f }, { 1.01f, 0.07926f }, { 1.17f, 0.2556f }, { 1.9f, 0.43194f }, { 1.99f, 0.4445f }, { 3.91f, 0.60829f }, { 4.0f, 0.61393f }, { 8.22f, 0.68611f }, { 10.0f, 0.7068f }, { 16.18f, 0.76067f }, { 29.44f, 0.83523f }, { 50.0f, 0.95091f } } },
+        { "knee", 3, false, false, { { 0.0f, 0.0f }, { 5.0f, 0.0059f }, { 10.0f, 0.0118f }, { 15.0f, 0.12492f }, { 20.0f, 0.23803f }, { 25.0f, 0.35115f }, { 30.0f, 0.46426f }, { 35.0f, 0.57738f }, { 40.0f, 0.66667f } } },
+        { "makeup", 37, false, false, { { -6.0f, 0.42483f }, { -0.75f, 0.49054f }, { 0.0f, 0.5f }, { 1.5f, 0.5065f }, { 3.0f, 0.53732f }, { 4.5f, 0.55624f }, { 9.75f, 0.62195f }, { 15.0f, 0.68765f }, { 20.25f, 0.75336f }, { 25.5f, 0.81906f }, { 30.75f, 0.88476f }, { 36.0f, 0.95047f } } },
+        { "attack", 5, false, false, { { 0.5f, 0.52546f }, { 0.87f, 0.5842f }, { 1.0f, 0.59382f }, { 2.87f, 0.66262f }, { 7.57f, 0.74103f }, { 10.0f, 0.76824f }, { 15.86f, 0.81945f }, { 28.53f, 0.84868f }, { 30.13f, 0.85172f }, { 46.32f, 0.87792f }, { 69.92f, 0.90715f }, { 100.0f, 0.95606f } } },
+        { "release", 6, false, false, { { 1.0f, 0.0f }, { 1.42f, 0.03806f }, { 8.07f, 0.22834f }, { 37.86f, 0.41862f }, { 50.0f, 0.45998f }, { 51.16f, 0.46352f }, { 100.0f, 0.57541f }, { 119.9f, 0.59471f }, { 295.95f, 0.70437f }, { 300.39f, 0.70639f }, { 620.63f, 0.81404f }, { 1161.65f, 0.9237f }, { 2000.0f, 1.0f } } } } },
+    { "client id=\"FGX2-state\"", "Apex Limiter",
+      { { 2, 0.01216f }, { 3, 0.95424f }, { 7, 0.33566f } },
+      { { "LevelGain", 0, false, false, { { 0.0f, 0.0f }, { 0.125f, 0.08356f }, { 0.15f, 0.10027f }, { 0.2f, 0.13369f }, { 0.25f, 0.16711f }, { 0.3f, 0.20053f }, { 0.375f, 0.25067f }, { 0.4f, 0.26738f }, { 0.5f, 0.33422f }, { 0.625f, 0.41778f }, { 0.75f, 0.50134f }, { 0.875f, 0.58489f }, { 1.0f, 0.66845f } } },
+        { "LevelMode", 4, false, true, { { 0.0f, 0.95f }, { 0.125f, 0.95f }, { 0.25f, 0.95f }, { 0.375f, 0.95f }, { 0.5f, 0.95f }, { 0.625f, 0.225f }, { 0.75f, 0.95f }, { 0.875f, 0.0f }, { 1.0f, 0.95f } } },
+        { "LevelCeiling", 1, false, false, { { -0.0f, 1.0f }, { 0.125f, 0.99139f }, { 0.25f, 0.98279f }, { 0.3333f, 0.97707f }, { 0.375f, 0.97418f }, { 0.5f, 0.96557f }, { 0.625f, 0.95696f }, { 0.75f, 0.94836f }, { 0.875f, 0.93975f }, { 1.0f, 0.93114f } } } } },
+    { "PluginName=\"SSL Native X-Saturator v6\"", "Ember Saturator",
+      { { 1, 0.5f }, { 7, 0.0f } },
+      { { "drive", 0, false, false, { { -12.0f, 0.0f }, { -7.5f, 0.02649f }, { -3.0f, 0.11647f }, { 0.0f, 0.17647f }, { 1.5f, 0.20646f }, { 4.0f, 0.25642f }, { 6.0f, 0.29645f }, { 10.5f, 0.38643f }, { 12.0f, 0.41667f }, { 15.0f, 0.4933f }, { 18.0f, 0.57024f }, { 19.5f, 0.60871f }, { 22.0f, 0.67241f }, { 24.0f, 0.71646f } } },
+        { "drive", 6, false, false, { { -12.0f, 0.21662f }, { -7.5f, 0.23188f }, { -3.0f, 0.27322f }, { 0.0f, 0.30079f }, { 1.5f, 0.31457f }, { 4.0f, 0.33752f }, { 6.0f, 0.35591f }, { 10.5f, 0.39726f }, { 12.0f, 0.41115f }, { 15.0f, 0.37264f }, { 18.0f, 0.33397f }, { 19.5f, 0.31464f }, { 22.0f, 0.28262f }, { 24.0f, 0.28654f } } },
+        { "harmonics", 2, false, false, { { 0.0f, 0.46563f }, { 12.5f, 0.47028f }, { 25.0f, 0.47492f }, { 30.0f, 0.47678f }, { 37.5f, 0.48026f }, { 50.0f, 0.48607f }, { 62.5f, 0.48994f }, { 75.0f, 0.49381f }, { 80.0f, 0.49536f }, { 87.5f, 0.49815f }, { 100.0f, 0.50279f } } },
+        { "shape", 37, false, false, { { -50.0f, 0.33442f }, { -37.5f, 0.38941f }, { -25.0f, 0.4444f }, { -12.5f, 0.49938f }, { 0.0f, 0.55437f }, { 12.5f, 0.60936f }, { 25.0f, 0.66435f }, { 37.5f, 0.71933f }, { 40.0f, 0.73033f }, { 50.0f, 0.77432f } } },
+        { "depth", 5, false, false, { { 0.0f, 0.96708f }, { 12.5f, 0.95188f }, { 25.0f, 0.93668f }, { 30.0f, 0.9306f }, { 37.5f, 0.92148f }, { 50.0f, 0.90628f }, { 62.5f, 0.89108f }, { 75.0f, 0.87588f }, { 87.5f, 0.86068f }, { 100.0f, 0.84548f } } },
+        { "mix", 5, true, false, { { 0.0f, -0.61622f }, { 12.5f, -0.53919f }, { 25.0f, -0.46216f }, { 35.0f, -0.40054f }, { 37.5f, -0.38513f }, { 50.0f, -0.30811f }, { 62.5f, -0.23108f }, { 75.0f, -0.15405f }, { 87.5f, -0.07703f }, { 100.0f, 0.0f } } },
+        { "output", 6, true, false, { { -30.0f, -0.12212f }, { -26.2f, -0.096f }, { -22.5f, -0.06988f }, { -18.7f, -0.04376f }, { -15.0f, -0.01764f }, { -11.2f, 0.00847f }, { -7.5f, 0.03459f }, { -4.0f, 0.05904f }, { -3.7f, 0.06071f }, { 0.0f, 0.08683f } } } } },
+    { "PluginName=\"SSL X-Gate\"", "Sentry Gate",
+      { { 0, 0.0f } },
+      { { "Upper Threshold", 1, false, false, { { -72.0f, 0.0f }, { -63.0f, 0.0f }, { -54.0f, 0.04619f }, { -45.0f, 0.21695f }, { -36.0f, 0.38771f }, { -30.0f, 0.52786f }, { -27.0f, 0.57715f }, { -24.0f, 0.62605f }, { -20.0f, 0.69098f }, { -18.0f, 0.72923f }, { -9.0f, 0.89999f }, { 0.0f, 1.0f } } },
+        { "Max Gain Reduction", 3, false, false, { { 0.0f, 0.0f }, { 9.0f, 0.04164f }, { 12.0f, 0.06011f }, { 18.0f, 0.14534f }, { 27.0f, 0.2737f }, { 36.0f, 0.40206f }, { 40.0f, 0.45956f }, { 45.0f, 0.43302f }, { 54.0f, 0.38494f }, { 60.0f, 0.35301f }, { 63.0f, 0.37148f }, { 72.0f, 0.42645f } } },
+        { "Attack", 4, false, false, { { 0.01f, 0.0f }, { 0.5f, 0.20656f }, { 1.4f, 0.30902f }, { 3.5f, 0.29548f }, { 8.34f, 0.27741f }, { 23.77f, 0.2458f }, { 50.0f, 0.2142f }, { 89.02f, 0.18259f }, { 142.61f, 0.15098f }, { 212.43f, 0.11937f }, { 300.0f, 0.12561f } } },
+        { "Hold", 6, false, false, { { 2.0f, 0.05198f }, { 8.6f, 0.23843f }, { 10.0f, 0.26717f }, { 21.8f, 0.43634f }, { 46.4f, 0.48686f }, { 50.0f, 0.49247f }, { 137.3f, 0.58554f }, { 300.0f, 0.68422f }, { 551.9f, 0.7829f }, { 909.0f, 0.88158f }, { 1386.8f, 0.98026f }, { 2000.0f, 1.0f } } },
+        { "Release", 5, false, false, { { 2.0f, 0.0f }, { 15.0f, 0.00867f }, { 64.2f, 0.32059f }, { 85.9f, 0.41325f }, { 100.0f, 0.46738f }, { 251.1f, 0.71785f }, { 291.8f, 0.77064f }, { 300.0f, 0.7798f }, { 563.0f, 1.0f }, { 1000.0f, 1.0f }, { 1562.1f, 1.0f }, { 2249.5f, 1.0f }, { 3062.1f, 1.0f }, { 4000.0f, 1.0f } } },
+        { "Gate Mode", 2, false, true, { { 0.0f, 1.0f }, { 1.0f, 1.0f }, { 2.0f, 0.25f } } },
+        { "Expander Knee", 7, false, false, { { 0.0f, 0.09271f }, { 3.0f, 0.08455f }, { 6.0f, 0.07639f }, { 9.0f, 0.08287f }, { 12.0f, 0.08935f }, { 15.0f, 0.09583f }, { 18.0f, 0.10231f }, { 21.0f, 0.10878f }, { 24.0f, 0.11201f } } } } },
+    { "<HarrisonLookaheadCompressor", "Crest Compressor",
+      { { 0, 0.45f }, { 5, 0.0f }, { 6, 0.90628f }, { 9, 0.0f }, { 34, 0.0f } },
+      { { "threshold", 1, false, false, { { -64.0f, 0.45687f }, { -56.0f, 0.52494f }, { -48.0f, 0.57448f }, { -40.0f, 0.62403f }, { -32.0f, 0.67358f }, { -24.0f, 0.72312f }, { -22.0032f, 0.73549f }, { -17.9968f, 0.76038f }, { -16.0f, 0.79805f }, { -12.0f, 0.874f }, { -8.0f, 0.94995f }, { 0.0f, 1.0f } } },
+        { "ratio", 2, false, false, { { 1.01f, 0.2968f }, { 2.0f, 0.32295f }, { 2.00887f, 0.32295f }, { 3.00965f, 0.60672f }, { 3.38375f, 0.7116f }, { 4.0f, 0.88197f }, { 5.7575f, 0.8729f }, { 8.13125f, 0.8607f }, { 10.505f, 0.84851f }, { 12.8788f, 0.83631f }, { 15.2525f, 0.82412f }, { 17.6262f, 0.81192f }, { 20.0f, 0.79973f } } },
+        { "knee", 3, false, false, { { 1.0f, 0.08756f }, { 3.375f, 0.06559f }, { 5.75f, 0.04362f }, { 6.0f, 0.04133f }, { 6.0008f, 0.04133f }, { 8.125f, 0.11531f }, { 10.5f, 0.19788f }, { 11.9991f, 0.24999f }, { 12.875f, 0.28044f }, { 15.25f, 0.36301f }, { 17.625f, 0.44558f }, { 20.0f, 0.5037f } } },
+        { "makeup", 37, false, false, { { 0.0f, 0.5f }, { 1.5f, 0.52447f }, { 3.0f, 0.54894f }, { 3.75f, 0.55271f }, { 3.999f, 0.55391f }, { 7.5f, 0.60133f }, { 11.25f, 0.652f }, { 15.0f, 0.70267f }, { 18.75f, 0.75334f }, { 22.5f, 0.804f }, { 26.25f, 0.85467f }, { 30.0f, 0.90534f } } } } },

+ 114 - 0
src/core/PluginSubstitutes.cpp

@@ -555,6 +555,8 @@ translate = harrison-strip
 product = bus / smart compressors (SSL Bus Compressor 2, G3, VBC, sonible smart:comp, pure:comp)
 vendor = Complete Access (role)
 lynx = Crest Compressor
+# round 190ar: the references with a fitted setting map load at the mapped settings (core/FittedMaps.inc)
+translate = fitted-map
 names = SSL Native Bus Compressor 2; SSL G3 MultiBusComp; SSL 360 Link Bus Compressor; SSL Native X-Comp v6; SSL Fusion HF Compressor; VBC FG-Grey; VBC FG-MU; VBC FG-Red; smartcomp3; smartcomp2; purecomp; learncomp; Harrison_LookaheadCompressor; Harrison_MPCCompressor; VM FG-Stress; VM FG-Bomber
 
 [complete-access-vintage-comps]
@@ -573,6 +575,7 @@ names = VM FG-2A; VM SD-3A; VM Custom Opto
 product = limiters (Slate FG-X 2, SSL X-Limit, sonible smart:limit, pure:limit)
 vendor = Complete Access (role)
 lynx = Apex Limiter
+translate = fitted-map
 names = FG-X 2; FG-X; SSL X-Limit; smartlimit; purelimit; learnlimit; Bus Clipper
 
 [complete-access-eqs]
@@ -591,6 +594,7 @@ names = SSL DeEss; VM FG-DS 902; Eiosis E2Deesser; smartdeess; puredeess; Harris
 product = gates (SSL X-Gate, Slate Gate Classic / Drums, Harrison Spectral Gate)
 vendor = Complete Access (role)
 lynx = Sentry Gate
+translate = fitted-map
 names = SSL X-Gate; VM Gate Classic; VM Gate Drums; Harrison_SpectralGate
 
 [complete-access-reverbs]
@@ -612,6 +616,7 @@ names = SSL Native X-Echo; SSL X-Delay; Stellar Echo SD-201; Harrison_3DDelay
 product = saturators (Slate Heatwave / Revival, SSL Fusion Vintage Drive / X-Saturator, Harrison Tape Saturator)
 vendor = Complete Access (role)
 lynx = Ember Saturator
+translate = fitted-map
 names = Heatwave; VM Revival; SSL Fusion Vintage Drive; SSL Native X-Saturator v6; SSL Fusion Transformer; Harrison Tape Saturator
 
 [complete-access-tuners]
@@ -2697,8 +2702,117 @@ int translateSoundtoysEchoBoy (const std::vector<std::uint8_t>& state, EffectSlo
     return 0;
 }
 
+// round 190ar: fitted setting maps as state translators. A map (reference parameter -> LYNX parameter, a transfer fitted
+// black-box on the reference's probe renders) is stored against the entry of the component state that carries that
+// parameter — found on states saved through the public parameter API at known settings (the one entry that moves along a
+// one-control sweep) — as knots  state value -> LYNX value  (linear between them, or the nearest one for a switch; an
+// "add" link is an offset on a value another link set). `fixed` = LYNX parameters the map holds constant.
+// The table is generated (core/FittedMaps.inc); nothing of the reference is read but its saved parameter values.
+struct FittedLink
+{
+    const char* id;
+    int target;
+    bool add, step;
+    std::vector<std::pair<float, float>> knots;
+};
+struct FittedMap
+{
+    const char* marker; // text that names the reference inside its state
+    const char* effect; // the LYNX effect the map was fitted on
+    std::vector<std::pair<int, float>> fixed;
+    std::vector<FittedLink> links;
+};
+const std::vector<FittedMap>& fittedMaps()
+{
+    static const std::vector<FittedMap> maps {
+#include "core/FittedMaps.inc"
+    };
+    return maps;
+}
+
+float fittedValue (const FittedLink& l, double v)
+{
+    const auto& k = l.knots;
+    if (k.empty())
+        return 0.0f;
+    if (l.step)
+    {
+        auto best = k.front();
+        for (const auto& q : k)
+            if (std::abs (q.first - v) < std::abs (best.first - v))
+                best = q;
+        return best.second;
+    }
+    if (v <= k.front().first)
+        return k.front().second;
+    for (std::size_t i = 1; i < k.size(); ++i)
+        if (v <= k[i].first)
+        {
+            const double span = (double) k[i].first - k[i - 1].first;
+            const double f = span > 0.0 ? (v - k[i - 1].first) / span : 1.0;
+            return (float) (k[i - 1].second + f * (k[i].second - k[i - 1].second));
+        }
+    return k.back().second;
+}
+
+int translateFittedMap (const std::vector<std::uint8_t>& state, EffectSlot& slot)
+{
+    const std::string text (state.begin(), state.end());
+    for (const auto& m : fittedMaps())
+    {
+        if (text.find (m.marker) == std::string::npos)
+            continue;
+        const auto kind = effectKindNamed (m.effect);
+        if (! kind || slot.kind != *kind)
+            return 0;
+        // the block to read: the selected A / B state of a two-state plugin, else the whole text; the first entry of an id wins
+        std::size_t from = 0, to = text.size();
+        if (const auto root = text.find ("<SSL_PLUGIN_STATE"); root != std::string::npos)
+        {
+            const bool useB = attributeIn (text, root, "StateASelected") == "0";
+            const auto block = text.find (useB ? "<B " : "<A ", root);
+            if (block == std::string::npos)
+                return 0;
+            from = block;
+            const auto close = text.find (useB ? "</B>" : "</A>", block);
+            to = close == std::string::npos ? text.size() : close;
+        }
+        std::map<std::string, double> values;
+        for (const char* tag : { "<PARAM ", "<entry " })
+            for (auto q = text.find (tag, from); q != std::string::npos && q < to; q = text.find (tag, q + 7))
+            {
+                const auto id = attributeIn (text, q, "id");
+                float value = 0;
+                if (! id.empty() && values.find (id) == values.end() && parseFloat (attributeIn (text, q, "value"), value) && std::isfinite (value))
+                    values[id] = value;
+            }
+        int count = 0;
+        for (const auto& l : m.links)
+            if (values.find (l.id) != values.end())
+                ++count;
+        if (count == 0)
+            return 0; // not a state this map knows: the entry's defaults stay
+        for (const auto& [index, value] : m.fixed)
+            if (index >= 0 && index < maxEffectParams)
+                slot.params[(std::size_t) index] = value;
+        for (const auto& l : m.links)
+        {
+            const auto it = values.find (l.id);
+            if (it == values.end() || l.target < 0 || l.target >= maxEffectParams)
+                continue;
+            auto& p = slot.params[(std::size_t) l.target];
+            const auto y = fittedValue (l, it->second);
+            p = std::clamp (l.add ? p + y : y, 0.0f, 1.0f);
+        }
+        return count;
+    }
+    return 0;
+}
+
 RawTranslator rawTranslatorNamed (std::string_view name)
 {
+    if (name == "fitted-map")
+        return translateFittedMap;
     if (name == "soundtoys-echoboy")
         return translateSoundtoysEchoBoy;
     if (name == "soundtoys-littlealterboy")

Разница между файлами не показана из-за своего большого размера
+ 374 - 0
tests/Parity190arTranslateData.inc


+ 85 - 0
tests/Parity190arTranslateTests.inc

@@ -0,0 +1,85 @@
+// Round 190ar part 2: fitted setting maps as state translators (core/FittedMaps.inc). The data are captured component
+// states (saved through the public parameter API at the bank's settings) and the LYNX parameters the map gives there.
+namespace p190artr
+{
+struct Case
+{
+    const char* label;
+    const char* plugin;
+    const char* effect;
+    const char* xml;
+    std::vector<std::pair<int, float>> expected;
+};
+inline const std::vector<Case>& cases()
+{
+    static const std::vector<Case> c {
+#include "Parity190arTranslateData.inc"
+    };
+    return c;
+}
+inline lynx::EffectSlot slotFor (const std::string& plugin, const std::string& xml, int* translated = nullptr)
+{
+    using namespace lynx;
+    ForeignPlugin fp;
+    fp.format = ForeignPlugin::Format::vst3;
+    fp.name = plugin;
+    fp.state = substtest::flVst3State (substtest::juceXmlComponent (xml));
+    const auto id = pluginIdentity (fp);
+    const auto* entry = findPluginSubstitute (id, false);
+    if (entry == nullptr)
+        return {};
+    int n = 0;
+    auto slot = makeSubstituteSlot (*entry, &id, &n);
+    if (translated != nullptr)
+        *translated = n;
+    return slot;
+}
+} // namespace p190artr
+
+TEST (p190ar_fitted_maps_translate_the_captured_states)
+{
+    using namespace lynx;
+    CHECK (p190artr::cases().size() >= 18);
+    for (const auto& c : p190artr::cases())
+    {
+        int n = 0;
+        const auto slot = p190artr::slotFor (c.plugin, c.xml, &n);
+        CHECK (std::string (effectInfo (slot.kind).name) == c.effect);
+        CHECK (n >= 3); // the state was read (links applied)
+        float worst = 0.0f;
+        for (const auto& [index, value] : c.expected)
+            worst = std::max (worst, std::abs (slot.params[(std::size_t) index] - value));
+        if (worst > 2.0e-4f)
+            std::printf ("p190ar translate %s: worst %.5f\n", c.label, (double) worst);
+        CHECK (worst <= 2.0e-4f);
+    }
+}
+
+TEST (p190ar_fitted_maps_leave_unknown_states_alone)
+{
+    using namespace lynx;
+    // a reference of the same role without a map, and a mapped one whose state carries none of the mapped entries:
+    // the substitute stays at its defaults (the entry's preset), nothing is half applied
+    const auto plain = makeEffectSlot (EffectKind::crestCompressor);
+    int n = -1;
+    auto s = p190artr::slotFor ("VBC FG-Red", "<package version=\"1.0\"><entry id=\"Threshold\" type=\"float64\" value=\"0.3\"/></package>", &n);
+    CHECK (s.kind == EffectKind::crestCompressor && n == 0 && s.params == plain.params);
+    s = p190artr::slotFor ("SSL Native X-Comp v6", "<SSL_PLUGIN_STATE PluginName=\"SSL Native X-Comp v6\" StateASelected=\"1\"><A x=\"1\"><PROCESSOR_STATE>"
+                                                   "<PARAM id=\"somethingElse\" value=\"1.0\"/></PROCESSOR_STATE></A></SSL_PLUGIN_STATE>", &n);
+    CHECK (s.kind == EffectKind::crestCompressor && n == 0 && s.params == plain.params);
+    // the B state is read when it is the selected one
+    const std::string a = "<PARAM id=\"threshold\" value=\"12.0\"/><PARAM id=\"ratio\" value=\"4.0\"/>";
+    const std::string b = "<PARAM id=\"threshold\" value=\"-10.0\"/><PARAM id=\"ratio\" value=\"10.0\"/>";
+    auto two = [&] (const char* selected) {
+        return p190artr::slotFor ("SSL Native X-Comp v6", std::string ("<SSL_PLUGIN_STATE PluginName=\"SSL Native X-Comp v6\" StateASelected=\"") + selected
+                                                          + "\"><A x=\"1\"><PROCESSOR_STATE>" + a + "</PROCESSOR_STATE></A><B x=\"1\"><PROCESSOR_STATE>" + b
+                                                          + "</PROCESSOR_STATE></B></SSL_PLUGIN_STATE>");
+    };
+    const auto sa = two ("1"), sb = two ("0");
+    CHECK (sa.params != sb.params);
+    // a transfer never leaves 0 .. 1, whatever the state says
+    s = p190artr::slotFor ("SSL Native X-Comp v6", "<SSL_PLUGIN_STATE PluginName=\"SSL Native X-Comp v6\" StateASelected=\"1\"><A x=\"1\"><PROCESSOR_STATE>"
+                                                   "<PARAM id=\"threshold\" value=\"-900.0\"/><PARAM id=\"makeup\" value=\"900.0\"/></PROCESSOR_STATE></A></SSL_PLUGIN_STATE>");
+    for (const auto v : s.params)
+        CHECK (v >= 0.0f && v <= 1.0f);
+}

+ 1 - 0
tests/tests.cpp

@@ -17459,6 +17459,7 @@ TEST (fl_low_lifter_matches_fl_engine)
 #include "Parity190alTests.inc"
 #include "Slicex190hTests.inc"
 #include "AudioX190aqTests.inc"
+#include "Parity190arTranslateTests.inc"
 #include "Surge190xTests.inc"
 #include "Issue114Tests.inc"
 #include "Slicex190rTests.inc"

Некоторые файлы не были показаны из-за большого количества измененных файлов