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

als: lot 3 — EQ Three, Drum Buss, Auto Filter modulation, Operator / Drift, rack and plugin envelopes (round 190ed)

EQ Three opens as a three-band Prism Multiband (crossover sum, kill switches as solo),
Drum Buss as a "Drum Buss" rack of Ember Saturator and Shell Channel with Live's
controls as macros, Auto Filter's LFO / envelope follower / side chain as a Peak
Controller linked to the Filter's cutoff, Operator without FM and Drift as the
built-in synth. Envelopes of rack macros, of devices and plugins inside racks (through
a free macro), of VST2 plugin parameters and of a Simpler's filter now come in; VST3
parameters are listed with the reason. Import-only: no engine or loader change.
Laws without a Live render are tagged [ASSUMED]; docs/analise/ALS_FORMAT.md section 18.
Ka1-S 3 недель назад
Родитель
Сommit
e135c2d7bb

+ 1 - 0
CMakeLists.txt

@@ -55,6 +55,7 @@ add_library(lynx_core STATIC
     src/core/AlsImport.cpp
     src/core/AlsDevices.cpp
     src/core/AlsDevicesLot2.cpp
+    src/core/AlsDevicesLot3.cpp
     src/core/FlmFormat.cpp
     src/core/FlmImport.cpp
     src/core/FlmEffects.cpp

+ 29 - 2
docs/analise/ALS_FORMAT.md

@@ -180,9 +180,9 @@ PluginDevice{ IsExpanded, BreakoutIsExpanded, On{Manual, AutomationTarget, MidiC
 | Tempo / TimeSignature + automation | `Song::bpm`, `beatsPerBar` + tempo automation clip; signature changes → markers |
 | Locators | Playlist markers |
 | Session clips / Scenes | the clip grid (round 181c, section 13; the default by the user's choice of 2026-11-08); Settings › General › Workflow can put them on the Playlist after the arrangement instead, one section per scene (a marker per scene) |
-| Volume/Pan/Send/plugin-param automation | automation clips on the matching target |
+| Volume/Pan/Send/plugin-param automation | automation clips on the matching target (round 190ed, §18: rack macros, devices inside racks through a free macro, VST2 plugin parameters, a Simpler's filter; VST3 parameters listed) |
 | PluginDevice | `PluginRef.foreign` (vst2 id / vst3 class id + state), resolved like an .flp's plugins |
-| Native devices | the LYNX engine in the same role with its settings translated (slice N3, section 14: Simpler, Sampler zones, Drum Rack pads, racks, EQ Eight, Compressor, Glue Compressor, Utility, Reverb); every other device is dropped and listed in the import report |
+| Native devices | the LYNX engine in the same role with its settings translated (slice N3, section 14: Simpler, Sampler zones, Drum Rack pads, racks, EQ Eight, Compressor, Glue Compressor, Utility, Reverb; lot 2 §15; lot 3 §18: EQ Three, Drum Buss, Auto Filter's modulation, Operator without FM, Drift); every other device is dropped and listed in the import report |
 
 ## 9. What Live's loader requires (found by experiment, 2026-11-06) [LIVE]
 Live crashes on a set that is merely well-formed. It either exits or shows "A serious program error". A set written by another program must follow these rules:
@@ -383,3 +383,30 @@ device each, 48 kHz float); round 190da fitted the laws and ran every case throu
   output offsets fitted on the curves at drive 0 and +12 dB (`AlsDevicesLot2.cpp`, `saturatorFit`).
 - **Reverb**: Live's 1 kHz T30 ≈ 0.91 × Decay → Atrium's decay 0.94 × Decay; the loop's high shelf (gain g) → Atrium's
   High mult 1 / (1 + 0.08·(−20 log10 g)·Decay). Atrium's fully wet tail is louder than Live's (listed with the measured sizes).
+
+## 18. Live's own devices → LYNX's own, lot 3, and the envelopes of racks and plugins (round 190ed, 2026-11-12)
+Code: `src/core/AlsDevicesLot3.cpp` (laws and translators, declared in `AlsDevices.h`), `AlsDevices.cpp` (dispatch),
+`AlsImport.cpp` (rack / plugin envelopes, the Peak Controller links, the synths). No Live render of these devices
+exists yet: every law that is not plain unit maths is [ASSUMED] and listed in the round's handoff
+(`/mnt/e/lynx-work/als190ed/HANDOFF.md`, "needs live render").
+
+| Live device (tag) | LYNX | Translated | Listed in the report |
+|---|---|---|---|
+| EQ Three (`FilterEQ3`) | Prism Multiband, 3 bands, minimum-phase (the crossover sum), no dynamics | FreqLo / FreqHi → crossovers, Slope → 24 / 48 dB/oct, GainLo / Mid / Hi (linear) → band levels (dB), kill switches and −inf gains → the bands that still sound are soloed | the pair (fitted), gains under −30 dB, all bands off (Prism's lowest output) |
+| Drum Buss (`DrumBuss`) | an Audio Effect Rack "Drum Buss": Ember Saturator → Shell Channel, plus a "Dry" chain when Dry/Wet is under 100 % or can move | Drive (24 dB at 100 %) and Soft / Medium / Hard → Ember tube / tape / transistor; Damping → Ember's high cut; Input Trim → Ember's input; Transients → Shell's transient shaper (Amount, Invert below 0); Boom → Shell's low enhancer at the boom's pitch; Crunch → Shell's high enhancer; Comp → Shell's listen-mic compressor; Output → Shell's output; Dry/Wet → the chains' volumes. The rack's macros (Drive, Crunch, Damping, Transients, Boom, Boom Freq, Trim, Output, Dry/Wet) each span their control: Live's envelopes and macros reach them | every fitted part, Boom decay, negative transients under automation |
+| Auto Filter's LFO / envelope follower / side chain | a Peak Controller (FL's internal-controller link) in front of the Filter — or at the end of the side-chain source track's insert — whose output 0 (peak + LFO) drives the Filter's cutoff through a 33-point curve | LFO rate (Hz at the set's tempo, or synced), shape, phase offset, amount; the follower's amount and release (a straight fall); the cutoff's base | amounts (law assumed), the follower's attack, stereo LFO offset, falling saw, inside a rack (no link possible) |
+| Operator (`Operator`) | the built-in synth, only when no FM is in use: operator A alone (B … D off or at −inf), or algorithm 11's carriers (≤ 3) | waveforms Sine (0), White noise (21), User (22 → the synth's harmonic table), coarse / fine ratio → pitch, volume, A's envelope (ms → s), filter, glide, global volume / pan | the pair (fitted), envelope levels / slopes / loop, LFO, pitch envelope, spread, tone; with FM the device stays unsupported ("FM synthesis: no LYNX engine for it yet") |
+| Drift (`Drift`) | the built-in synth | oscillator 1 / 2 types → nearest waves, transposes, detune, levels, noise; filter I / II (12 dB / 24 dB ladder), frequency, resonance, key tracking; envelope 1 (amp ADSR); voice mode mono; glide; volume | the pair (fitted), shape, high pass, envelope 2 / LFO / cycling envelope / matrix, drift, stereo / unison voices |
+
+**Envelopes (arrangement automation).** Before lot 3 only envelopes on mixer, tempo, sends and the parameters of converted
+devices on a track's own chain came in. Now also:
+- a rack's own macro (Audio Effect Rack on an insert → `effectParam` slot parameter k; Instrument Rack on a channel →
+  `channelParam` k; 0 … 127 → 0 … 1);
+- a converted device inside a rack, a plugin inside a rack, a nested rack's macro: a free macro of the outer rack (no
+  mapping, no name, not under an envelope itself) is mapped over the target's whole range, set to the target's value
+  (nothing moves), excluded from Rand and variations and named after the parameter; the envelope drives that macro through
+  the device's law;
+- a VST2 plugin's parameter (`ParameterId` = its index [model]) on an insert or as the track's instrument;
+- a Simpler's filter frequency / resonance → the Sampler's Cutoff / Resonance knobs.
+A VST3 plugin's parameter keeps the plugin's own id, not LYNX's index: listed once with that reason. Envelopes of devices
+LYNX does not translate stay listed as "Automation of a device parameter (track)".

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
scripts/build-local.sh


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
scripts/build-windows-zig.sh


+ 17 - 0
src/core/AlsDevices.cpp

@@ -708,6 +708,8 @@ std::optional<Translated> effectFromLiveDevice (const Element& device, const Con
         t.to = "Filter";
         t.approximate = true;
         ok = autoFilterToFilter (device, t);
+        if (ok)
+            autoFilterModulation (device, context, t); // (190ed)
     }
     else if (tag == "Saturator")
     {
@@ -765,6 +767,21 @@ std::optional<Translated> effectFromLiveDevice (const Element& device, const Con
         t.approximate = true;
         ok = reduxToLofi (device, t);
     }
+    // ---- lot 3 (round 190ed) ----
+    else if (tag == "FilterEQ3")
+    {
+        t.from = "EQ Three";
+        t.to = "Prism Multiband";
+        t.approximate = true;
+        ok = eqThreeToPrism (device, t);
+    }
+    else if (tag == "DrumBuss")
+    {
+        t.from = "Drum Buss";
+        t.to = "Drum Buss rack (Ember Saturator, Shell Channel)";
+        t.approximate = true;
+        ok = drumBussToRack (device, t);
+    }
     if (! ok)
         return std::nullopt;
     t.slot.enabled = device.boolean ("On/Manual", true);

+ 65 - 0
src/core/AlsDevices.h

@@ -30,6 +30,11 @@
 //   Arpeggiator                    → the channel arpeggiator
 //   Pitch, Velocity, Chord, Note Length → written into the notes of the track's clips
 // and, for every translated device, which Live parameter drives which LYNX parameter (automation, rack macros).
+// Lot 3 (round 190ed):
+//   EQ Three                       → Prism Multiband (3 bands, crossover sum, no dynamics)
+//   Drum Buss                      → an Audio Effect Rack "Drum Buss": Ember Saturator → Shell Channel (+ a dry chain)
+//   Auto Filter's LFO / envelope follower / side chain → a Peak Controller linked to the Filter's cutoff
+//   Operator (no FM in use), Drift → the built-in synth
 
 #include <array>
 #include <functional>
@@ -317,11 +322,71 @@ struct Translated
     SideInput side;
     int sideParam = -1;            // (190cf) the LYNX parameter that switches the external side chain on (−1 = none)
     std::vector<ParamLink> links;  // (190cf) automation / macro routes
+    // (190ed) a modulation the effect needs from outside itself: a Peak Controller slot (FL's internal-controller link;
+    // its output 0 = peak + LFO) in front of the effect on the same insert — or, `onSideChain`, at the end of the
+    // side-chain source's insert — driving parameter `param` through `curve` (evenly spaced over the output's 0..1).
+    // A rack chain cannot hold the link: there the importer lists it instead.
+    struct Modulator
+    {
+        EffectSlot controller;
+        int param = 0;
+        std::vector<float> curve;
+        int sideTrackId = -1;           // the envelope follower listens to this track of the set (Live's track Id)
+        bool sideOther = false;         // a side-chain input whose source is not a track (the follower hears the input)
+        std::vector<std::string> notes; // the report lines when it is applied (laws)
+        std::string what;               // "LFO", "envelope follower", "LFO and envelope follower"
+    };
+    std::optional<Modulator> modulator;
 };
 // nullopt: not one of the devices above, or its element lacks the parameters (then the importer does what it did
 // before: the device is dropped and listed)
 std::optional<Translated> effectFromLiveDevice (const xml::Element& device, const Context& context = {});
 
+// ================================================================================================ lot 3 (190ed)
+// ---- EQ Three → Prism Multiband ---------------------------------------------------------------------------------
+// The kill switches and −inf gains: Prism's bands that still sound are soloed (Prism's solo passes only those bands); a
+// gain at Live's floor (−70 dB, shown as −inf) is a killed band [DATA: GainLo / GainMid / GainHi 0.000316 … 1.995]
+bool eqThreeToPrism (const xml::Element& device, Translated& out);
+// ---- Drum Buss → a rack -----------------------------------------------------------------------------------------
+// The generated rack's macros, in order (each mapped over the whole range of its LYNX control)
+enum DrumBussMacro { dbDrive, dbCrunch, dbDamping, dbTransients, dbBoom, dbBoomFreq, dbTrim, dbOutput, dbDryWet, dbMacros };
+// Live's Drive (0 … 1, shown 0 … 100 %) as Ember's drive in dB [ASSUMED: 24 dB at 100 %]
+double drumBussDriveDb (double drive) noexcept;
+// the Boom frequency (30 … 90 Hz) as Shell's Low freq. (its 6th-order low pass sits at 0.72 × that: the boom's pitch)
+double drumBussBoomLfHz (double boomHz) noexcept;
+bool drumBussToRack (const xml::Element& device, Translated& out);
+// ---- Auto Filter's modulation → a Peak Controller ---------------------------------------------------------------
+// The Peak Controller's controls for an amount (its laws, core/Effects.cpp PeakController): the peak's amount k (−2 … 2,
+// the output per unit of peak) and the LFO's (−1 … 1, the output per unit of wave)
+float peakAmountValue (double k) noexcept;
+float peakLfoAmountValue (double k) noexcept;
+// the LFO's period in quarter notes → its Speed control (period = (1001^(raw / 65536) − 1) · 0.128, raw = 200 + 65336 v)
+float peakLfoSpeedValue (double beats) noexcept;
+// a linear decay of the peak from 1 to 0 over `ms` at `bpm` → its Decay control ((10001^(d / 128) − 1) · 0.0192 per
+// quarter note, d = 5 + 123 v)
+float peakDecayValue (double ms, double bpm) noexcept;
+// The cutoff's modulation c(t) = c0 + L·w(t) + E·e(t) (cutoff in the Filter's 0..1, w the bipolar LFO, e the peak) as
+// the controller's settings and the link's curve; `invert` true = the LFO runs half a cycle later (a negative E flips
+// the curve)
+struct CutoffModulation
+{
+    float lfoAmount = 0.5f, peakAmount = 0.5f; // the controller's [5] and [1]
+    bool invert = false;
+    std::vector<float> curve;
+};
+CutoffModulation cutoffModulation (double c0, double lfoDepth, double envDepth) noexcept;
+// Fills `out.modulator` from the device's LFO / envelope follower / side chain (nothing when both are off)
+void autoFilterModulation (const xml::Element& device, const Context& context, Translated& out);
+
+// ---- Live's synths → the built-in synth -------------------------------------------------------------------------
+// Operator's coarse ratio [DOC: 0 = 0.5, then 1 … 48] and fine (thousandths of it) as semitones above the note
+double operatorRatioSemitones (int coarse, double fine) noexcept;
+// false: not translated (FM in use, a waveform LYNX's synth has no exact counterpart for): the caller lists the device
+bool operatorToSynth (const xml::Element& device, ChannelDef& channel, double bpm, Notes& notes);
+bool driftToSynth (const xml::Element& device, ChannelDef& channel, double bpm, Notes& notes);
+// The ratio's semitones as the synth's octave / semitones / cents (octave −3 … 3, semitones −11 … 11, cents ±100)
+void setOscillatorPitch (SynthOscillator& osc, double semitones) noexcept;
+
 // ---- Simpler ----------------------------------------------------------------------------------------------------
 // Voices [DOC: 1 … 8, 10, 12, 14, 16, 20, 24, 32; DATA: the stored index 0 … 14, 5 in a new Simpler = 6 voices]
 int simplerVoices (int index) noexcept;

+ 2 - 8
src/core/AlsDevicesLot2.cpp

@@ -525,12 +525,8 @@ bool autoFilterToFilter (const Element& device, Translated& out)
     const auto outputGain = newer ? manual (device, "Output", 1.0) : 1.0;
     if (std::abs (outputGain - 1.0) > 1.0e-3)
         out.notes.dropped.push_back (text ("output gain %.1f dB", dbOfGain (outputGain)));
-    const auto lfo = manual (device, newer ? "Lfo_Amount" : "LfoAmount", 0.0);
-    if (std::abs (lfo) > 1.0e-4)
-        out.notes.dropped.push_back ("LFO on the cutoff");
-    const auto envelope = manual (device, newer ? "Envelope_Amount" : "ModHub", 0.0);
-    if (std::abs (envelope) > 1.0e-4)
-        out.notes.dropped.push_back ("envelope follower on the cutoff");
+    // (190ed) the LFO, the envelope follower and its side chain: autoFilterModulation (lot 3) — a Peak Controller linked
+    // to the cutoff, or the importer's line where no link can be made
     if (manual (device, newer ? "Filter_Drive" : "Drive", 0.0) > 1.0e-4 || (int) manual (device, newer ? "Filter_Circuit" : "CircuitLpHp", 0) != 0)
         out.notes.dropped.push_back ("filter circuit / drive");
     // Slope [MEASURED 190cz a08 / a30–a33 / b08 / b30–b33: on = a second cookbook stage at the same cutoff with Q2 =
@@ -540,8 +536,6 @@ bool autoFilterToFilter (const Element& device, Translated& out)
     p[4] = steep ? 1.0f : 0.0f;
     if (steep && type != 0)
         out.notes.approximated.push_back (type == 1 ? "24 dB/oct high pass (Live's measured on the low pass)" : "24 dB/oct band pass (Live's measured on the low pass)");
-    if (manualBool (device, "SideChain/OnOff", false))
-        out.notes.dropped.push_back ("side-chain input of the envelope follower");
     return true;
 }
 

+ 631 - 0
src/core/AlsDevicesLot3.cpp

@@ -0,0 +1,631 @@
+// Live's own devices → LYNX's, lot 3 (round 190ed; core/AlsDevices.h has the list and the evidence tags). The same
+// rules as lots 1 and 2: each conversion is a law in a unit, what is fitted or has no counterpart becomes a note for the
+// import report, only the device's saved state is read, and each translator records which Live parameter drives
+// which LYNX parameter (ParamLink) so automation and rack macros follow. No Live render of these devices exists yet:
+// every law that is not plain unit maths is tagged [ASSUMED] and the round's handoff lists the renders that settle it.
+
+#include "core/AlsDevices.h"
+
+#include <algorithm>
+#include <cmath>
+#include <cstdio>
+
+#include "core/DynamicsSuite.h"
+#include "core/Effects.h"
+#include "core/MixSuite.h"
+#include "core/Rack.h"
+#include "core/XmlLite.h"
+
+namespace lynx::alsdev
+{
+namespace
+{
+using xml::Element;
+
+float unit (double v) noexcept { return (float) std::clamp (v, 0.0, 1.0); }
+float linValue (double v, double lo, double hi) noexcept { return unit ((v - lo) / (hi - lo)); }
+float logValue (double v, double lo, double hi) noexcept { return unit (std::log (std::clamp (v, lo, hi) / lo) / std::log (hi / lo)); }
+
+std::string text (const char* format, double a, double b = 0.0, double c = 0.0)
+{
+    char out[240];
+    std::snprintf (out, sizeof (out), format, a, b, c);
+    return out;
+}
+
+double manual (const Element& device, const std::string& name, double fallback) { return device.number (name + "/Manual", fallback); }
+bool manualBool (const Element& device, const std::string& name, bool fallback) { return device.boolean (name + "/Manual", fallback); }
+bool has (const Element& device, const std::string& name) { return (bool) device.path (name + "/Manual"); }
+
+// Live's floor of a linear gain control (−70 dB) is shown as −inf [DATA: 0.0003162277571 at the bottom of the ranges]
+bool isFloor (double gain) noexcept { return gain <= 0.000317; }
+} // namespace
+
+// ================================================================================================ EQ Three
+
+bool eqThreeToPrism (const Element& device, Translated& out)
+{
+    using namespace dyn::prism;
+    if (! has (device, "GainLo") || ! has (device, "FreqLo") || ! has (device, "FreqHi"))
+        return false;
+    out.slot = makeEffectSlot (EffectKind::prismMultiband);
+    auto& p = out.slot.params;
+    p[bandCountParam] = bandCountValue (3);
+    // the crossover sum (Live's EQ Three splits the signal into three bands and sums them [DOC]): Prism's minimum-phase
+    // mode, the all-pass compensated crossover tree; 24 / 48 dB/oct [DOC; DATA Slope 0 … 1, ASSUMED 0 = 24]
+    p[processingMode] = 1.0f;
+    const auto slopeDb = manual (device, "Slope", 1.0) > 0.5 ? 48 : 24;
+    out.links.push_back ({ "FreqLo", crossoverParam (0), [] (double hz) { return crossoverValue (hz); } });
+    out.links.push_back ({ "FreqHi", crossoverParam (1), [] (double hz) { return crossoverValue (hz); } });
+    auto lo = std::clamp (manual (device, "FreqLo", 250.0), 30.0, 18000.0), hi = std::clamp (manual (device, "FreqHi", 2500.0), 30.0, 18000.0);
+    if (hi < lo)
+        std::swap (lo, hi);
+    p[(std::size_t) crossoverParam (0)] = crossoverValue (lo);
+    p[(std::size_t) crossoverParam (1)] = crossoverValue (hi);
+    p[slope] = (float) (slopeDb == 48 ? 1.0 : 0.5);
+    for (int k = 0; k < 2; ++k)
+        p[(std::size_t) (xoverSlope0 + k)] = crossoverSlopeValue (slopeDb);
+    // no dynamics: each band only a level (its range 0 dB, ratio 1 : 1)
+    static const char* const gains[3] { "GainLo", "GainMid", "GainHi" };
+    static const char* const ons[3] { "LowOn", "MidOn", "HighOn" };
+    std::array<bool, 3> sounds {};
+    bool clamped = false;
+    for (int b = 0; b < 3; ++b)
+    {
+        const auto gain = manual (device, gains[b], 1.0);
+        sounds[(std::size_t) b] = manualBool (device, ons[b], true) && ! isFloor (gain);
+        p[(std::size_t) param (b, fRange)] = 0.5f;
+        p[(std::size_t) param (b, fRatio)] = 0.0f;
+        p[(std::size_t) param (b, fEnabled)] = 1.0f;
+        // a linear gain [DATA: 0.000316 … 1.995 = −70 … +6 dB] → Prism's band level (−30 … +30 dB)
+        const auto db = dbOfGain (gain);
+        p[(std::size_t) param (b, fLevel)] = linValue (db, -30.0, 30.0);
+        clamped = clamped || (db < -30.0 && ! isFloor (gain));
+        out.links.push_back ({ gains[b], param (b, fLevel), [] (double g) { return linValue (dbOfGain (g), -30.0, 30.0); } });
+    }
+    const auto alive = (int) std::count (sounds.begin(), sounds.end(), true);
+    if (alive < 3)
+        for (int b = 0; b < 3; ++b)
+            p[(std::size_t) param (b, fSolo)] = sounds[(std::size_t) b] ? 1.0f : 0.0f;
+    if (alive == 0)
+    {
+        p[output] = 0.0f; // Prism's lowest output (−36 dB): no setting of Prism is silent
+        out.notes.approximated.push_back ("all three bands off: Prism's output at -36 dB (Live: silence)");
+    }
+    if (clamped)
+        out.notes.approximated.push_back ("a band gain under -30 dB (Prism's lowest band level)");
+    p[mix] = 1.0f;
+    out.notes.approximated.push_back (text ("the bands as Prism's minimum-phase crossover sum at %.0f dB/oct (Live's filters: law assumed)", slopeDb));
+    return true;
+}
+
+// ================================================================================================ Drum Buss
+
+double drumBussDriveDb (double drive) noexcept { return 24.0 * std::clamp (drive, 0.0, 1.0); }
+double drumBussBoomLfHz (double boomHz) noexcept { return std::clamp (boomHz, 30.0, 90.0) / 0.72; }
+
+bool drumBussToRack (const Element& device, Translated& out)
+{
+    namespace em = mixsuite::ember;
+    namespace sh = mixsuite::shell;
+    if (! has (device, "DriveAmount") || ! has (device, "TransientShaping") || ! has (device, "BoomAmount"))
+        return false;
+
+    // Ember: input trim, drive (Soft / Medium / Hard [DOC order; DATA DriveType 0 … 2]), damping as its high cut, no
+    // level compensation
+    auto ember = makeEffectSlot (EffectKind::ember);
+    auto& e = ember.params;
+    static constexpr int styles[3] { 0, 1, 2 }; // tube, tape, transistor [ASSUMED: soft, medium, hard]
+    const auto type = std::clamp ((int) manual (device, "DriveType", 0), 0, 2);
+    e[em::style] = (float) styles[type] / (float) (em::styles - 1);
+    e[em::autoGain] = 0.0f;
+    e[em::drive] = linValue (drumBussDriveDb (manual (device, "DriveAmount", 0.2)), 0.0, 36.0);
+    const auto trimDb = dbOfGain (manual (device, "InputTrim", 1.0));
+    e[em::inputGain] = linValue (trimDb, -24.0, 24.0);
+    // Damping [DATA 500 … 20000 Hz] → Ember's high cut (2 … 20 kHz; its wide range 1 … 20 kHz below that, off at 20 kHz)
+    const auto damping = std::clamp (manual (device, "DampingFrequency", 20000.0), 500.0, 20000.0);
+    const auto wide = damping < 2000.0;
+    e[em::wideCuts] = wide ? 1.0f : 0.0f;
+    e[em::highCut] = damping >= 19999.0 ? 1.0f : logValue (damping, 2000.0, 20000.0);
+    e[em::highCutWide] = damping >= 19999.0 ? 1.0f : logValue (damping, 1000.0, 20000.0);
+    e[em::mix] = 1.0f;
+
+    // Shell Channel: the transient shaper (−1 … +1: Amount = |t|, Invert below 0), Boom as the low enhancer (its pitch =
+    // the enhancer's corner, Amount as its amount), Crunch as the high enhancer, the Compressor as the listen-mic
+    // compressor, the output gain
+    auto shell = makeEffectSlot (EffectKind::shellChannel);
+    auto& s = shell.params;
+    const auto transients = std::clamp (manual (device, "TransientShaping", 0.0), -1.0, 1.0);
+    s[sh::tsOn] = std::abs (transients) > 1.0e-4 ? 1.0f : 0.0f;
+    s[sh::tsAmount] = (float) std::abs (transients);
+    s[sh::tsInvert] = transients < 0.0 ? 1.0f : 0.0f;
+    const auto boom = std::clamp (manual (device, "BoomAmount", 0.0), 0.0, 1.0);
+    s[sh::lfOn] = boom > 1.0e-4 ? 1.0f : 0.0f;
+    s[sh::lfFreq] = sh::lfValue (drumBussBoomLfHz (manual (device, "BoomFrequency", 50.0)));
+    s[sh::lfAmount] = (float) boom;
+    const auto crunch = std::clamp (manual (device, "CrunchAmount", 0.0), 0.0, 1.0);
+    s[sh::hfOn] = crunch > 1.0e-4 ? 1.0f : 0.0f;
+    s[sh::hfAmount] = (float) crunch;
+    if (device.boolean ("EnableCompression/Manual", device.boolean ("EnableCompression", false)))
+    {
+        s[sh::lmcOn] = 1.0f;
+        s[sh::lmcComp] = 0.25f; // [ASSUMED: Live's fixed drum compressor as a light listen-mic compression]
+    }
+    const auto outDb = dbOfGain (manual (device, "OutputGain", 1.0));
+    s[sh::output] = linValue (outDb, -20.0, 20.0);
+    s[sh::outputMix] = 1.0f;
+
+    // the rack: "Drum Buss" chain (Ember → Shell) and, when the device is not fully wet or a macro moves Dry/Wet, a "Dry"
+    // chain beside it (the chains' volumes: dry 1 − x, wet x [ASSUMED linear])
+    out.slot = rack::makeRackSlot (RackDoc::Kind::audioEffect);
+    auto& doc = out.slot.patcher;
+    if (auto* r = rack::rackOf (doc); r != nullptr && ! r->chains.empty())
+        r->chains.front().name = "Drum Buss";
+    PatchNode en, sn;
+    en.effect = std::move (ember);
+    en.label = "Drive";
+    sn.effect = std::move (shell);
+    sn.label = "Shape";
+    const auto emberNode = rack::addDevice (doc, 0, std::move (en));
+    const auto shellNode = rack::addDevice (doc, 0, std::move (sn));
+    if (emberNode < 0 || shellNode < 0)
+        return false;
+    const auto dryWet = std::clamp (manual (device, "DryWet", 1.0), 0.0, 1.0);
+    // (a macro on Dry/Wet: KeyMidi on channel 16 [DATA]; an envelope on it without a dry chain stays listed)
+    const auto wetMoves = (int) device.number ("DryWet/KeyMidi/Channel", -1) == 16;
+    int dry = -1;
+    if (dryWet < 0.9999 || wetMoves)
+    {
+        dry = rack::addChain (doc, "Dry");
+        if (auto* r = rack::rackOf (doc); r != nullptr && dry >= 0)
+        {
+            r->chains[0].volume = (float) dryWet;
+            r->chains[(std::size_t) dry].volume = (float) (1.0 - dryWet);
+        }
+    }
+
+    // the macros, each over the whole range of its LYNX control (a macro at v sets the control to v), named after
+    // Live's controls; Live's own parameters reach them through `links`
+    auto* r = rack::rackOf (doc);
+    if (r == nullptr)
+        return false;
+    struct M
+    {
+        int macro;
+        const char* name;
+        int node, param;
+    };
+    const M macros[] { { dbDrive, "Drive", emberNode, em::drive },          { dbCrunch, "Crunch", shellNode, sh::hfAmount },
+                       { dbDamping, "Damping", emberNode, wide ? em::highCutWide : em::highCut },
+                       { dbTransients, "Transients", shellNode, sh::tsAmount }, { dbBoom, "Boom", shellNode, sh::lfAmount },
+                       { dbBoomFreq, "Boom Freq", shellNode, sh::lfFreq },   { dbTrim, "Trim", emberNode, em::inputGain },
+                       { dbOutput, "Output", shellNode, sh::output } };
+    for (const auto& m : macros)
+    {
+        RackMapping target;
+        target.node = m.node;
+        target.param = m.param;
+        rack::map (doc, m.macro, target);
+        r = rack::rackOf (doc);
+        r->macros[(std::size_t) m.macro].name = m.name;
+    }
+    if (dry >= 0)
+    {
+        RackMapping wet, dryMap;
+        wet.target = dryMap.target = RackMapping::Target::chainVolume;
+        wet.chain = 0;
+        dryMap.chain = dry;
+        wet.min = dryMap.max = 0.0f;
+        wet.max = dryMap.min = rack::volumeValue (1.0f);
+        rack::map (doc, dbDryWet, wet);
+        rack::map (doc, dbDryWet, dryMap);
+        r = rack::rackOf (doc);
+        r->macros[(std::size_t) dbDryWet].name = "Dry/Wet";
+    }
+    // each macro where its control is now (nothing moves)
+    const auto valueOf = [&doc] (int node, int param) { return doc.nodes[(std::size_t) node].effect.params[(std::size_t) param]; };
+    for (const auto& m : macros)
+        r->macros[(std::size_t) m.macro].value = valueOf (m.node, m.param) * 127.0f;
+    if (dry >= 0)
+        r->macros[(std::size_t) dbDryWet].value = (float) (127.0 * std::clamp ((double) rack::volumeValue ((float) dryWet) / rack::volumeValue (1.0f), 0.0, 1.0));
+    r->shownMacros = dry >= 0 ? 10 : 8;
+    r->name = "Drum Buss";
+    rack::compile (doc);
+
+    // Live's parameters → the macros (the macro's 0..1 is its control's 0..1)
+    out.links.push_back ({ "DriveAmount", dbDrive, [] (double v) { return linValue (drumBussDriveDb (v), 0.0, 36.0); } });
+    out.links.push_back ({ "CrunchAmount", dbCrunch, [] (double v) { return unit (v); } });
+    if (wide)
+        out.links.push_back ({ "DampingFrequency", dbDamping, [] (double hz) { return hz >= 19999.0 ? 1.0f : logValue (hz, 1000.0, 20000.0); } });
+    else
+        out.links.push_back ({ "DampingFrequency", dbDamping, [] (double hz) { return hz >= 19999.0 ? 1.0f : logValue (hz, 2000.0, 20000.0); } });
+    if (transients >= 0.0)
+        out.links.push_back ({ "TransientShaping", dbTransients, [] (double t) { return unit (t); } }); // (the positive side: Invert stays off)
+    out.links.push_back ({ "BoomAmount", dbBoom, [] (double v) { return unit (v); } });
+    out.links.push_back ({ "BoomFrequency", dbBoomFreq, [] (double hz) { return sh::lfValue (drumBussBoomLfHz (hz)); } });
+    out.links.push_back ({ "InputTrim", dbTrim, [] (double g) { return linValue (dbOfGain (g), -24.0, 24.0); } });
+    out.links.push_back ({ "OutputGain", dbOutput, [] (double g) { return linValue (dbOfGain (g), -20.0, 20.0); } });
+    if (dry >= 0)
+        out.links.push_back ({ "DryWet", dbDryWet, [] (double x) {
+                                   return (float) std::clamp ((double) rack::volumeValue ((float) std::clamp (x, 0.0, 1.0)) / rack::volumeValue (1.0f), 0.0, 1.0);
+                               } });
+
+    // the report: what is a fit, what has no counterpart
+    out.notes.approximated.push_back (std::string ("drive as Ember's ") + (type == 0 ? "tube" : (type == 1 ? "tape" : "transistor"))
+                                      + " style (Soft / Medium / Hard; drive law assumed)");
+    if (s[sh::tsOn] > 0.5f)
+        out.notes.approximated.push_back ("transients as Shell Channel's transient shaper");
+    if (boom > 1.0e-4)
+        out.notes.approximated.push_back ("Boom as Shell Channel's low enhancer (its decay is not applied)");
+    if (crunch > 1.0e-4)
+        out.notes.approximated.push_back ("Crunch as Shell Channel's high enhancer (a lift of the highs, not a distortion)");
+    if (s[sh::lmcOn] > 0.5f)
+        out.notes.approximated.push_back ("the compressor as Shell Channel's listen-mic compressor");
+    if (dry >= 0)
+        out.notes.approximated.push_back ("Dry/Wet as the rack's dry and wet chains");
+    if (damping < 1000.0)
+        out.notes.approximated.push_back (text ("damping %.0f Hz as 1 kHz (Ember's high cut: from 1 kHz)", damping));
+    if (trimDb < -24.0)
+        out.notes.approximated.push_back (text ("input trim %.1f dB (Ember's input: down to -24 dB)", trimDb));
+    if (std::abs (outDb) > 20.0)
+        out.notes.approximated.push_back (text ("output %.1f dB (Shell Channel's output: +/-20 dB)", outDb));
+    if (transients < 0.0)
+        out.notes.approximated.push_back ("negative transients: automation / macros of Transients are not carried");
+    return true;
+}
+
+// ================================================================================================ Auto Filter modulation
+
+float peakAmountValue (double k) noexcept
+{
+    const auto raw = (k < 0.0 ? -1.0 : 1.0) * 256.0 * std::log (1.0 + std::min (std::abs (k), 2.0) / 0.4) / std::log (6.0);
+    return unit ((raw / 256.0 + 1.0) * 0.5);
+}
+
+float peakLfoAmountValue (double k) noexcept
+{
+    const auto raw = (k < 0.0 ? -1.0 : 1.0) * 256.0 * std::log (1.0 + std::min (std::abs (k), 1.0) / 0.2) / std::log (6.0);
+    return unit ((raw / 256.0 + 1.0) * 0.5);
+}
+
+float peakLfoSpeedValue (double beats) noexcept
+{
+    const auto raw = 65536.0 * std::log (std::max (beats, 3.0 / 96.0) / 0.128 + 1.0) / std::log (1001.0);
+    return unit ((raw - 200.0) / 65336.0);
+}
+
+float peakDecayValue (double ms, double bpm) noexcept
+{
+    // per quarter note the peak falls by perBeat (1 = the whole range): 1 / (the release in quarter notes)
+    const auto perBeat = 60000.0 / (std::max (ms, 0.1) * std::max (bpm, 1.0));
+    const auto d = 128.0 * std::log (perBeat / 0.0192 + 1.0) / std::log (10001.0);
+    return unit ((d - 5.0) / 123.0);
+}
+
+CutoffModulation cutoffModulation (double c0, double lfoDepth, double envDepth) noexcept
+{
+    // the output o = E'·peak + L'·(w + 1)/2 (bases 0) and the cutoff = y0 + S·o: S = ±(2L + |E|) carries both at full
+    // scale without clipping the output; a negative E turns the curve over, and the LFO with it (half a cycle later)
+    CutoffModulation m;
+    const auto L = std::abs (lfoDepth), E = envDepth;
+    const auto sign = E < 0.0 ? -1.0 : 1.0;
+    const auto span = std::max (2.0 * L + std::abs (E), 1.0e-6);
+    const auto S = sign * span;
+    m.invert = sign < 0.0;
+    m.lfoAmount = peakLfoAmountValue (2.0 * L / span);
+    m.peakAmount = peakAmountValue (std::abs (E) / span);
+    const auto y0 = c0 - sign * L;
+    constexpr int points = 33;
+    for (int i = 0; i < points; ++i)
+        m.curve.push_back (unit (y0 + S * (double) i / (double) (points - 1)));
+    return m;
+}
+
+void autoFilterModulation (const Element& device, const Context& context, Translated& out)
+{
+    const auto newer = device.name() == "AutoFilter2";
+    // the depths in the Filter's cutoff units (0..1 = 20 Hz … 20 kHz, log: one unit = log2 (1000) octaves)
+    constexpr double octavesPerUnit = 9.965784284662087;
+    // the older device: LFO Amount [DATA 0 … 30] and the envelope's ModHub [DATA −127 … 127] in semitones of its cutoff
+    // (a pitch) [ASSUMED]; the new one: Lfo_Amount [DATA 0 … 1] and Envelope_Amount [DATA −1 … 1] as fractions of the
+    // whole range [ASSUMED]
+    const auto lfoRaw = manual (device, newer ? "Lfo_Amount" : "LfoAmount", 0.0);
+    const auto envRaw = manual (device, newer ? "Envelope_Amount" : "ModHub", 0.0);
+    const auto lfoDepth = newer ? std::clamp (lfoRaw, 0.0, 1.0) * 0.5 : lfoRaw / 12.0 / octavesPerUnit;
+    const auto envDepth = newer ? std::clamp (envRaw, -1.0, 1.0) : envRaw / 12.0 / octavesPerUnit;
+    const auto lfoOn = (newer || manualBool (device, "Lfo/IsOn", true)) && std::abs (lfoDepth) > 1.0e-5;
+    const auto envOn = std::abs (envDepth) > 1.0e-5;
+    if (! lfoOn && ! envOn)
+        return;
+    const auto c0 = (double) out.slot.params[1];
+    const auto m = cutoffModulation (c0, lfoOn ? lfoDepth : 0.0, envOn ? envDepth : 0.0);
+    Translated::Modulator mod;
+    mod.controller = makeEffectSlot (EffectKind::peakController);
+    auto& p = mod.controller.params;
+    p[0] = 0.0f;                                         // Base
+    p[1] = envOn ? m.peakAmount : 0.5f;                  // Amount (0.5 = none)
+    p[2] = 0.5f;                                         // Tension (linear)
+    p[4] = 0.0f;                                         // LFO base
+    p[5] = lfoOn ? m.lfoAmount : 0.5f;                   // LFO amount (0.5 = none)
+    p[6] = 0.5f;                                         // LFO tension (linear)
+    p[10] = 0.0f;                                        // Mute off: the audio passes
+    p[11] = 0.0f;                                        // Ramp off
+    mod.param = 1;
+    mod.curve = m.curve;
+    if (envOn)
+    {
+        // the follower's release → the peak's linear fall from full scale; its attack: the peak rises at once
+        const auto release = newer ? manual (device, "Envelope_Release", 0.25) * 1000.0 : manual (device, "Release", 200.0); // [DATA s / ms]
+        const auto attack = newer ? manual (device, "Envelope_Attack", 0.001) * 1000.0 : manual (device, "Attack", 6.0);
+        p[3] = peakDecayValue (release, context.bpm);
+        mod.notes.push_back (text ("envelope follower: amount %.0f as %.2f octaves at full scale, release %.0f ms as a straight fall (law assumed)", envRaw,
+                                   envDepth * octavesPerUnit, release));
+        if (attack > 1.0)
+            mod.notes.push_back (text ("envelope follower attack %.1f ms (the Peak Controller rises at once)", attack));
+        if (manualBool (device, "SideChain/OnOff", false))
+        {
+            const auto side = sideInputOf (device);
+            mod.sideTrackId = side.trackId;
+            mod.sideOther = side.trackId < 0;
+        }
+    }
+    if (lfoOn)
+    {
+        // the rate: Hz (fixed at the set's tempo) or a synced note value [DATA: older RateType 0 / 1, BeatRate 0 … 21; the
+        // new device's Lfo_TimeMode 0 = Hz, 2 = synced: ASSUMED]
+        double beats = 1.0;
+        bool synced = false;
+        if (newer)
+        {
+            const auto mode = (int) manual (device, "Lfo_TimeMode", 0);
+            synced = mode == 2;
+            beats = synced ? liveBeatRateBeats ((int) manual (device, "Lfo_SyncedRate", 4)) : context.bpm / 60.0 / std::max (manual (device, "Lfo_Frequency", 1.0), 0.01);
+            if (mode != 0 && mode != 2)
+                mod.notes.push_back (text ("LFO time mode %.0f (taken as Hz)", mode));
+        }
+        else
+        {
+            synced = (int) manual (device, "Lfo/RateType", 0) == 1;
+            beats = synced ? liveBeatRateBeats ((int) manual (device, "Lfo/BeatRate", 4)) : context.bpm / 60.0 / std::max (manual (device, "Lfo/Frequency", 1.0), 0.01);
+        }
+        p[7] = peakLfoSpeedValue (beats);
+        // the shape [DOC order: sine, square, triangle, saw up, saw down, S&H; DATA older Type 0 … 6, new 0 … 7: ASSUMED
+        // the same first six] → the controller's sine 0, triangle 1, square 2, saw 3, random 4
+        const auto type = (int) manual (device, newer ? "Lfo_Waveform" : "Lfo/Type", 0);
+        static constexpr int shapes[6] { 0, 2, 1, 3, 3, 4 };
+        p[8] = (float) shapes[std::clamp (type, 0, 5)] / 4.0f;
+        // the phase offset (degrees) and the half cycle a turned-over curve needs
+        const auto phase = manual (device, newer ? "Lfo_PhaseOffset" : "Lfo/Offset", 0.0) / 360.0 + (m.invert ? 0.5 : 0.0);
+        p[9] = (float) (phase - std::floor (phase));
+        mod.notes.push_back (text ("LFO: amount %.2f as %.2f octaves either side (law assumed)", lfoRaw, lfoDepth * octavesPerUnit));
+        if (! synced)
+            mod.notes.push_back (text ("LFO rate %.2f Hz held as a note length at the set's tempo", beats > 0.0 ? context.bpm / 60.0 / beats : 0.0));
+        if (type == 4)
+            mod.notes.push_back ("LFO falling saw as a rising one");
+        if (type > 5)
+            mod.notes.push_back ("LFO shape as a sine");
+        if (std::abs (manual (device, newer ? "Lfo_Spin" : "Lfo/Spin", 0.0)) > 1.0e-4
+            || (newer ? manual (device, "Lfo_Phase", 0.0) : manual (device, "Lfo/Phase", 0.0)) > 1.0e-3)
+            mod.notes.push_back ("LFO stereo offset between left and right (one cutoff for both sides)");
+    }
+    mod.what = lfoOn && envOn ? "LFO and envelope follower" : (lfoOn ? "LFO" : "envelope follower");
+    out.modulator = std::move (mod);
+}
+
+// ================================================================================================ Operator, Drift
+
+double operatorRatioSemitones (int coarse, double fine) noexcept
+{
+    const auto c = coarse <= 0 ? 0.5 : (double) std::min (coarse, 48);
+    return 12.0 * std::log2 (c * (1.0 + std::clamp (fine, 0.0, 1000.0) / 1000.0));
+}
+
+void setOscillatorPitch (SynthOscillator& osc, double semitones) noexcept
+{
+    const auto whole = std::round (semitones);
+    auto st = (int) whole;
+    osc.detune = (float) std::clamp ((semitones - whole) * 100.0, -100.0, 100.0);
+    osc.octave = std::clamp (st / 12, -3, 3); // (toward zero: ±11 semitones stay in the octave)
+    osc.semitones = std::clamp (st - 12 * osc.octave, -11, 11);
+}
+
+namespace
+{
+// the synth's level and the channel volume for a linear gain (the channel's curve tops at 1 = 0 dB)
+void setLevel (ChannelDef& channel, double gain)
+{
+    const auto g = std::clamp (gain, 0.0, 1.0);
+    channel.volume = g <= 0.0 ? 0.0f : (float) (std::log (10.0 * g + 1.0) / std::log (11.0));
+}
+
+// Operator's envelope [DATA: ms and linear levels] as ADSR seconds; anything beyond a plain ADSR goes to the notes
+void operatorEnvelope (const Element& env, SynthSettings& s, Notes& notes)
+{
+    s.attack = (float) (manual (env, "AttackTime", 0.1) / 1000.0);
+    s.decay = (float) (manual (env, "DecayTime", 600.0) / 1000.0);
+    s.sustain = (float) std::clamp (manual (env, "SustainLevel", 1.0), 0.0, 1.0);
+    s.release = (float) (manual (env, "ReleaseTime", 50.0) / 1000.0);
+    if (! isFloor (manual (env, "AttackLevel", 0.0)) || manual (env, "DecayLevel", 1.0) < 0.999 || ! isFloor (manual (env, "ReleaseLevel", 0.0)))
+        notes.approximated.push_back ("envelope start / peak / end levels (the synth's envelope runs 0 → 1 → sustain → 0)");
+    if (std::abs (manual (env, "AttackSlope", 0.0)) > 1.0e-3 || std::abs (manual (env, "DecaySlope", 1.0) - 1.0) > 1.0e-3 || std::abs (manual (env, "ReleaseSlope", 1.0) - 1.0) > 1.0e-3)
+        notes.approximated.push_back ("envelope slopes (straight segments)");
+    if ((int) manual (env, "LoopMode", 0) != 0)
+        notes.dropped.push_back ("envelope loop mode");
+}
+} // namespace
+
+bool operatorToSynth (const Element& device, ChannelDef& channel, double bpm, Notes& notes)
+{
+    if (! device.path ("Operator.0/Envelope") || ! device.path ("Globals/Algorithm"))
+        return false;
+    const auto algorithm = (int) manual (device, "Globals/Algorithm", 0);
+    // which operators sound: on, above Live's floor
+    std::array<bool, 4> sounding {};
+    for (int k = 0; k < 4; ++k)
+    {
+        const auto stem = "Operator." + std::to_string (k) + "/";
+        sounding[(std::size_t) k] = manualBool (device, stem + "IsOn", true) && ! isFloor (manual (device, stem + "Volume", 1.0));
+    }
+    // A is a carrier in every algorithm [DOC]; with B … D silent it is a plain oscillator. Algorithm 10 = four carriers,
+    // no modulation [DOC: the last algorithm, all side by side]. Any other case is FM: not translated.
+    std::vector<int> carriers;
+    if (! sounding[1] && ! sounding[2] && ! sounding[3])
+        carriers = { 0 };
+    else if (algorithm == 10)
+        for (int k = 0; k < 4; ++k)
+            if (sounding[(std::size_t) k])
+                carriers.push_back (k);
+    if (carriers.empty() || ! sounding[(std::size_t) carriers.front()])
+        return false;
+    // waveforms: 0 = sine, 21 = white noise, 22 = User (its 64 harmonics) [DATA: 0, 15, 20, 21, 22 seen; 21 is operator A
+    // of the shipped "White Noise" preset, alone; the User wave holds the harmonic table; the others' order is not
+    // settled: not translated]
+    for (const auto k : carriers)
+    {
+        const auto wave = (int) manual (device, "Operator." + std::to_string (k) + "/WaveForm", 0);
+        if (wave != 0 && wave != 21 && wave != 22)
+            return false;
+        if (manual (device, "Operator." + std::to_string (k) + "/Feedback", 0.0) > 0.5 && carriers.size() > 1)
+            return false;
+    }
+
+    channel.instrument = InstrumentKind::synth;
+    auto& s = channel.synth;
+    s = SynthSettings {};
+    for (auto& o : s.osc)
+        o.level = 0.0f;
+    bool userUsed = false, differentEnvelopes = false;
+    for (std::size_t i = 0; i < carriers.size() && i < 3; ++i)
+    {
+        const auto k = carriers[i];
+        const auto stem = "Operator." + std::to_string (k) + "/";
+        auto& o = s.osc[i];
+        const auto wave = (int) manual (device, stem + "WaveForm", 0);
+        if (wave == 22)
+        {
+            if (userUsed)
+                return false; // one harmonic table per synth
+            userUsed = true;
+            o.wave = Waveform::spectral;
+            for (int h = 0; h < 64 && h < SynthSettings::spectrumSize; ++h)
+                s.spectrum[(std::size_t) h] = (float) std::clamp (device.number (stem + "UserHarmonics/Harmonics." + std::to_string (h), h == 0 ? 1.0 : 0.0), 0.0, 1.0);
+        }
+        else
+            o.wave = wave == 21 ? Waveform::noise : Waveform::sine;
+        setOscillatorPitch (o, operatorRatioSemitones ((int) manual (device, stem + "Tune/Coarse", 1), manual (device, stem + "Tune/Fine", 0.0))
+                                   + manual (device, "Globals/Transpose", 0.0));
+        o.level = (float) std::clamp (manual (device, stem + "Volume", 1.0), 0.0, 1.0);
+        if (manualBool (device, stem + "Tune/FixedFrequencyOn", false))
+            notes.dropped.push_back ("fixed-frequency operator (it follows the note here)");
+        if (i == 0)
+            operatorEnvelope (device.path (stem + "Envelope"), s, notes);
+        else
+            differentEnvelopes = differentEnvelopes || std::abs (manual (device, stem + "Envelope/DecayTime", 0.0) - s.decay * 1000.0) > 1.0
+                                 || std::abs (manual (device, stem + "Envelope/AttackTime", 0.0) - s.attack * 1000.0) > 1.0;
+        if (manual (device, stem + "Feedback", 0.0) > 0.5)
+            notes.dropped.push_back ("operator feedback");
+    }
+    if (carriers.size() > 3)
+        notes.dropped.push_back ("the fourth carrier (the synth has three oscillators)");
+    if (differentEnvelopes)
+        notes.approximated.push_back ("one envelope for every oscillator (operator A's)");
+    // the filter [DATA: Filter/OnOff, Type 0 … 4 (low, high, band pass, notch, morph: the Auto Filter's list ASSUMED),
+    // Frequency Hz, Resonance 0 … 1.25, Slope (24 dB/oct: the synth's 4-pole ladder ASSUMED), FrequencyKeyScale %]
+    if (manualBool (device, "Filter/OnOff", false))
+    {
+        static constexpr int types[5] { 0, 2, 1, 3, 0 };
+        s.filterType = types[std::clamp ((int) manual (device, "Filter/Type", 0), 0, 4)];
+        s.cutoff = (float) std::clamp (manual (device, "Filter/Frequency", 20000.0), 20.0, 20000.0);
+        s.resonance = (float) std::clamp (manual (device, "Filter/Resonance", 0.0) / 1.25, 0.0, 1.0);
+        s.ladder = manualBool (device, "Filter/Slope", false) && s.filterType == 0;
+        s.keyTrack = (float) std::clamp (manual (device, "Filter/FrequencyKeyScale", 0.0) / 100.0, 0.0, 2.0);
+        notes.approximated.push_back ("filter on the synth's filter (resonance and key tracking laws assumed)");
+        if (std::abs (manual (device, "Filter/EnvelopeAmount", 0.0)) > 0.5)
+            notes.dropped.push_back ("filter envelope");
+        if (manual (device, "Filter/Drive", 0.0) > 0.01 || (int) manual (device, "Filter/CircuitLpHp", 0) != 0)
+            notes.dropped.push_back ("filter circuit / drive");
+    }
+    else
+        s.cutoff = 20000.0f;
+    // voices: Live's polyphony index; glide [DATA: PortamentoOn, PortamentoTime ms] at the set's tempo
+    s.porta = manualBool (device, "Globals/PortamentoOn", false);
+    if (s.porta)
+        s.portaBeats = (float) (manual (device, "Globals/PortamentoTime", 50.0) / 1000.0 * bpm / 60.0);
+    setLevel (channel, manual (device, "Globals/Volume", 1.0));
+    channel.pan = (float) std::clamp (manual (device, "Globals/Panorama", 0.0), -1.0, 1.0);
+    if (manual (device, "Globals/SpreadAmount", 0.0) > 0.5)
+        notes.dropped.push_back ("spread");
+    if (std::abs (manual (device, "Globals/Tone", 0.7) - 0.7) > 0.01)
+        notes.dropped.push_back ("tone (the anti-alias filter)");
+    // the LFO and the pitch envelope reach an operator only when both its own switch and the section's are on [DATA]
+    bool lfo = false, pitchEnv = false;
+    for (const auto k : carriers)
+    {
+        const auto stem = "Operator." + std::to_string (k) + "/";
+        lfo = lfo || (manualBool (device, "Lfo/LfoOn", false) && manualBool (device, stem + "LfoOn", true));
+        pitchEnv = pitchEnv || (manualBool (device, "PitchEnv/PitchEnvOn", false) && manualBool (device, stem + "PitchEnvOn", true));
+    }
+    if (lfo)
+        notes.dropped.push_back ("LFO");
+    if (pitchEnv)
+        notes.dropped.push_back ("pitch envelope");
+    notes.approximated.push_back (std::string (carriers.size() == 1 ? "operator A alone" : "the carriers of algorithm 11") + " as the built-in synth's oscillators (level not matched to Live's)");
+    return true;
+}
+
+bool driftToSynth (const Element& device, ChannelDef& channel, double bpm, Notes& notes)
+{
+    if (! has (device, "Oscillator1_Type") || ! has (device, "Filter_Frequency") || ! has (device, "Envelope1_Attack"))
+        return false;
+    channel.instrument = InstrumentKind::synth;
+    auto& s = channel.synth;
+    s = SynthSettings {};
+    // oscillator 1 [DOC order: sine, triangle, shark tooth, saturated, saw, pulse, rectangle; DATA 0 … 6] and 2 [DOC:
+    // sine, triangle, saturated, saw, rectangle; DATA 0 … 4] as the synth's nearest waves; octaves [DATA −2 … 3 / −3 … 2]
+    static constexpr Waveform waves1[7] { Waveform::sine, Waveform::triangle, Waveform::saw, Waveform::sine, Waveform::saw, Waveform::square, Waveform::square };
+    static constexpr Waveform waves2[5] { Waveform::sine, Waveform::triangle, Waveform::sine, Waveform::saw, Waveform::square };
+    const auto t1 = std::clamp ((int) manual (device, "Oscillator1_Type", 0), 0, 6);
+    const auto t2 = std::clamp ((int) manual (device, "Oscillator2_Type", 0), 0, 4);
+    const auto transpose = manual (device, "Global_Transpose", 0.0);
+    s.osc[0].wave = waves1[t1];
+    setOscillatorPitch (s.osc[0], 12.0 * manual (device, "Oscillator1_Transpose", 0.0) + transpose);
+    s.osc[0].level = manualBool (device, "Mixer_OscillatorOn1", true) ? (float) std::clamp (manual (device, "Mixer_OscillatorGain1", 1.0), 0.0, 1.0) : 0.0f;
+    s.osc[1].wave = waves2[t2];
+    setOscillatorPitch (s.osc[1], 12.0 * manual (device, "Oscillator2_Transpose", 0.0) + manual (device, "Oscillator2_Detune", 0.0) + transpose);
+    s.osc[1].level = manualBool (device, "Mixer_OscillatorOn2", true) ? (float) std::clamp (manual (device, "Mixer_OscillatorGain2", 1.0), 0.0, 1.0) : 0.0f;
+    s.osc[2].wave = Waveform::noise;
+    s.osc[2].level = manualBool (device, "Mixer_NoiseOn", true) ? (float) std::clamp (manual (device, "Mixer_NoiseLevel", 0.0), 0.0, 1.0) : 0.0f;
+    if (t1 == 2 || t1 == 3 || t2 == 2)
+        notes.approximated.push_back ("shark tooth / saturated waves as the synth's saw / sine");
+    if (std::abs (manual (device, "Oscillator1_Shape", 0.0)) > 1.0e-3)
+        notes.dropped.push_back ("oscillator 1 shape");
+    // the filter: low pass [DOC: type I 12 dB/oct, II 24 dB/oct ladder; DATA Filter_Type 0 … 1], key tracking, the high pass
+    s.filterType = 0;
+    s.ladder = (int) manual (device, "Filter_Type", 0) == 1;
+    s.cutoff = (float) std::clamp (manual (device, "Filter_Frequency", 20000.0), 20.0, 20000.0);
+    s.resonance = (float) std::clamp (manual (device, "Filter_Resonance", 0.0), 0.0, 1.0);
+    s.keyTrack = (float) std::clamp (manual (device, "Filter_Tracking", 0.0), 0.0, 1.0);
+    if (manual (device, "Filter_HiPassFrequency", 10.0) > 20.0)
+        notes.dropped.push_back ("the high pass before the filter");
+    // envelope 1 = the amp envelope [DOC] in seconds [DATA]
+    s.attack = (float) manual (device, "Envelope1_Attack", 0.001);
+    s.decay = (float) manual (device, "Envelope1_Decay", 0.6);
+    s.sustain = (float) std::clamp (manual (device, "Envelope1_Sustain", 1.0), 0.0, 1.0);
+    s.release = (float) manual (device, "Envelope1_Release", 0.6);
+    // voice mode [DATA Global_VoiceMode 0 … 2, ASSUMED 0 poly, 1 mono, 2 stereo / unison] and glide (s) at the set's tempo
+    const auto voiceMode = (int) manual (device, "Global_VoiceMode", 0);
+    s.mono = voiceMode == 1;
+    if (voiceMode == 2)
+        notes.dropped.push_back ("stereo / unison voices");
+    const auto glide = manual (device, "Global_Glide", 0.0);
+    s.porta = glide > 0.001;
+    s.portaBeats = (float) (glide * bpm / 60.0);
+    setLevel (channel, manual (device, "Global_Volume", 0.5));
+    // what the built-in synth has no place for
+    notes.dropped.push_back ("modulation (envelope 2, LFO, cycling envelope and the modulation matrix)");
+    if (manual (device, "Global_DriftDepth", 0.0) > 1.0e-3)
+        notes.dropped.push_back ("drift (the random detune of each voice)");
+    notes.approximated.push_back ("oscillators, filter and amp envelope on the built-in synth (level not matched to Live's)");
+    return true;
+}
+} // namespace lynx::alsdev

+ 357 - 8
src/core/AlsImport.cpp

@@ -100,6 +100,20 @@ struct Target
     std::function<float (double)> law;
 };
 
+// (round 190ed) an automated parameter inside a rack, or one of a rack's own macros, kept until the rack has its place
+// (an insert's slot or a channel): then a macro of that rack carries the envelope (core/Rack.h macros are the slot's
+// automatable parameters 0 … 15)
+struct RackAuto
+{
+    std::string id;         // the parameter's AutomationTarget Id
+    std::vector<int> path;  // rack nodes from the rack being read down to the document that holds the target
+    int node = -1;          // −1: macro `param` of that document; else the node whose parameter `param` the envelope moves
+    int param = 0;
+    std::function<float (double)> law; // Live's value → the target's 0..1
+    float current = 0.0f;   // the target's 0..1 as imported (a new macro starts there: no change in sound)
+    std::string name;
+};
+
 struct Ctx
 {
     const AlsImportOptions& options;
@@ -121,6 +135,25 @@ struct Ctx
     std::map<int, std::vector<alsdev::NoteEffect>> noteEffects;
     int skipLeadingMidi = 0;
     std::string signatureTarget; // the main track's TimeSignature AutomationTarget Id (round 190cg)
+    // round 190ed: every AutomationTarget Id an arrangement envelope points at; where the rack being read collects its
+    // automated parameters; targets on the channel being read (their index is set when the channel is placed)
+    std::set<std::string> automated;
+    std::vector<RackAuto>* rackAutos = nullptr;
+    std::vector<std::pair<std::string, Target>> channelTargets;
+    std::set<std::string> explained; // envelopes already listed with their own reason
+    // round 190ed: a Peak Controller linked to a translated effect's parameter (Auto Filter's LFO / envelope follower),
+    // placed once its slots are known: the controller's insert and slot (−1 = appended to that insert after every
+    // track is read: a side-chain source), the effect's insert and slot
+    struct PendingLink
+    {
+        int sourceInsert = -1, sourceSlot = -1;
+        EffectSlot controller;
+        int targetTrack = -1, targetSlot = -1, param = 0;
+        std::vector<float> curve;
+        std::vector<std::string> notes;
+        std::string from, what;
+    };
+    std::vector<PendingLink> pendingLinks;
 
     // the scale of the first MIDI clip that has Live's clip scale switched on (round 190o)
     std::optional<projectkey::Key> clipKey;
@@ -395,19 +428,135 @@ void pluginMappings (Ctx& ctx, const Element& device, PatcherDoc& doc, int node)
         }
 }
 
+// (round 190ed) The envelopes on a plugin's parameters. Live keeps a plugin parameter as 0..1 [DATA, model]; a VST2's
+// ParameterId is its index [model], which LYNX's plugin parameters use too; a VST3's is the plugin's own parameter id,
+// not an index: listed, not kept
+void pluginAutos (Ctx& ctx, const Element& device, const std::string& plugin,
+                  const std::function<void (const std::string& id, int param, float current, const std::string& name)>& sink)
+{
+    const auto vst3 = (bool) device.path ("PluginDesc/Vst3PluginInfo");
+    for (const auto& p : device.path ("ParameterList").children ("PluginFloatParameter"))
+        if (const auto id = targetId (p.child ("ParameterValue")); ! id.empty() && ctx.automated.count (id) != 0)
+        {
+            const auto index = (int) p.number ("ParameterId", -1);
+            if (vst3 || index < 0)
+            {
+                ctx.note (&FlpImportReport::unsupported, "Automation of a VST3 plugin's parameter (" + plugin + ": Live keeps the plugin's own id, not its index)");
+                ctx.explained.insert (id);
+                continue;
+            }
+            auto name = p.value ("ParameterName");
+            sink (id, index, (float) std::clamp (p.number ("ParameterValue/Manual", 0.0), 0.0, 1.0), plugin + " " + (name.empty () ? "#" + std::to_string (index) : name));
+        }
+}
+
+// (round 190ed) The macro of rack `doc` that drives a target `path` leads to from `depth`: the target itself when it is
+// a macro of `doc`, else a free macro of `doc` (no mapping, no name of its own, not under an envelope itself) mapped
+// over the target's whole range and set to the target's value (nothing moves; Rand and variations leave it alone).
+// A target in a nested rack goes through a free macro of each rack on the way. −1 when no macro is free.
+int bindMacro (PatcherDoc& doc, const std::vector<RackAuto>& all, const RackAuto& a, std::size_t depth)
+{
+    auto* r = rack::rackOf (doc);
+    if (r == nullptr)
+        return -1;
+    if (depth == a.path.size() && a.node < 0)
+        return a.param >= 0 && a.param < rackMacroCount ? a.param : -1;
+    RackMapping target;
+    auto value = a.current;
+    if (depth == a.path.size())
+    {
+        target.node = a.node;
+        target.param = a.param;
+    }
+    else
+    {
+        const auto n = a.path[depth];
+        if (n < 0 || n >= (int) doc.nodes.size())
+            return -1;
+        auto& node = doc.nodes[(std::size_t) n];
+        auto& inner = node.generator ? node.channel.patcher : node.effect.patcher;
+        const auto k = bindMacro (inner, all, a, depth + 1);
+        if (k < 0 || rack::rackOf (inner) == nullptr)
+            return -1;
+        target.node = n;
+        target.param = k;
+        value = rack::rackOf (inner)->macros[(std::size_t) k].value / 127.0f;
+        r = rack::rackOf (doc);
+    }
+    // a second envelope reaching the same target uses the macro already bound to it
+    for (int k = 0; k < rackMacroCount; ++k)
+        for (const auto& m : r->macros[(std::size_t) k].mappings)
+            if (m.target == RackMapping::Target::param && m.node == target.node && m.param == target.param && m.min == 0.0f && m.max == 1.0f)
+                return k;
+    std::set<int> reserved;
+    for (const auto& other : all)
+        if (other.node < 0 && other.path.size() == depth && std::equal (other.path.begin(), other.path.end(), a.path.begin()))
+            reserved.insert (other.param);
+    for (int k = 0; k < rackMacroCount; ++k)
+    {
+        auto& m = r->macros[(std::size_t) k];
+        if (! m.mappings.empty() || ! m.name.empty() || reserved.count (k) != 0)
+            continue;
+        target.min = 0.0f;
+        target.max = 1.0f;
+        if (! rack::map (doc, k, target))
+            return -1;
+        r = rack::rackOf (doc);
+        auto& bound = r->macros[(std::size_t) k];
+        bound.name = a.name;
+        bound.excludeFromRandom = bound.excludeFromVariations = true;
+        while (r->shownMacros <= k && r->shownMacros < rackMacroCount)
+            r->shownMacros = rack::moreMacros (r->shownMacros);
+        rack::setMacro (doc, k, std::clamp (value, 0.0f, 1.0f) * 127.0f);
+        rack::compile (doc);
+        return k;
+    }
+    return -1;
+}
+
+// (round 190ed) A rack has its place: each envelope it collected targets the rack's macro that carries it
+void placeRackAutos (Ctx& ctx, PatcherDoc& doc, const std::vector<RackAuto>& autos, const std::function<AutomationTarget (int macro)>& at,
+                     bool onChannel = false)
+{
+    for (const auto& a : autos)
+    {
+        const auto k = bindMacro (doc, autos, a, 0);
+        if (k < 0)
+        {
+            ctx.note (&FlpImportReport::unsupported, "Automation inside a rack whose macros are all in use (" + a.name + ")");
+            ctx.explained.insert (a.id);
+            continue;
+        }
+        if (onChannel)
+            ctx.channelTargets.push_back ({ a.id, Target { at (k), ValueMap::plain, a.name, a.law } });
+        else
+            ctx.targets[a.id] = { at (k), ValueMap::plain, a.name, a.law };
+    }
+}
+
 bool rackFrom (Ctx& ctx, const Element& device, PatcherDoc& doc, int depth);
 
 // One of Live's own audio effects as the LYNX effect in its role, settings translated (round 190bq, core/AlsDevices.h).
 // The report lists the pair — under "converted" when the maths is the same, under "kept but approximated" when the
 // pair is fitted — and every setting that is clamped, fitted or has no counterpart. False: not a device LYNX maps (or
 // its element lacks the parameters): the caller drops and lists it as before.
-bool nativeEffectFrom (Ctx& ctx, const Element& d, EffectSlot& slot, std::vector<alsdev::ParamLink>* links = nullptr, std::string* name = nullptr)
+bool nativeEffectFrom (Ctx& ctx, const Element& d, EffectSlot& slot, std::vector<alsdev::ParamLink>* links = nullptr, std::string* name = nullptr,
+                       std::optional<alsdev::Translated::Modulator>* modulator = nullptr)
 {
     alsdev::Context context;
     context.bpm = ctx.song.bpm;
     auto t = alsdev::effectFromLiveDevice (d, context);
     if (! t)
         return false;
+    // (round 190ed) a modulation from outside the effect (Auto Filter's LFO / envelope follower): the caller places
+    // its Peak Controller and link; inside a rack chain no link can be made, so it is listed
+    if (t->modulator)
+    {
+        if (modulator != nullptr)
+            *modulator = std::move (t->modulator);
+        else
+            t->notes.dropped.push_back (t->modulator->what + " on the cutoff inside a rack");
+    }
     if (links != nullptr)
         *links = t->links;
     if (name != nullptr)
@@ -493,13 +642,24 @@ int rackDeviceFrom (Ctx& ctx, const Element& d, PatcherDoc& doc, int chain, bool
         ctx.note (&FlpImportReport::converted, "Plugin: " + p->name);
         const auto n = rack::addDevice (doc, chain, std::move (node));
         if (n >= 0)
+        {
             pluginMappings (ctx, d, doc, n);
+            pluginAutos (ctx, d, p->name, [&ctx, n] (const std::string& id, int param, float current, const std::string& name) {
+                if (ctx.rackAutos != nullptr)
+                    ctx.rackAutos->push_back ({ id, {}, n, param, [] (double v) { return (float) std::clamp (v, 0.0, 1.0); }, current, name });
+            });
+        }
         return n;
     }
     if ((tag == "AudioEffectGroupDevice" || tag == "InstrumentGroupDevice") && depth < 8)
     {
         auto inner = rack::makeRack (tag == "InstrumentGroupDevice" ? RackDoc::Kind::instrument : RackDoc::Kind::audioEffect);
-        if (! rackFrom (ctx, d, inner, depth + 1))
+        // (round 190ed) the inner rack's automated targets: reached from here through this node
+        std::vector<RackAuto> innerAutos;
+        auto* const outerAutos = std::exchange (ctx.rackAutos, &innerAutos);
+        const auto read = rackFrom (ctx, d, inner, depth + 1);
+        ctx.rackAutos = outerAutos;
+        if (! read)
             return -1;
         if (tag == "InstrumentGroupDevice")
         {
@@ -518,6 +678,12 @@ int rackDeviceFrom (Ctx& ctx, const Element& d, PatcherDoc& doc, int chain, bool
         const auto n = rack::addDevice (doc, chain, std::move (node));
         if (n < 0)
             return -1;
+        if (ctx.rackAutos != nullptr)
+            for (auto& a : innerAutos)
+            {
+                a.path.insert (a.path.begin(), n);
+                ctx.rackAutos->push_back (std::move (a));
+            }
         // the inner rack's macros mapped onto the outer rack's (0…127 → 0..1) [DATA]
         for (int k = 0; k < rackMacroCount; ++k)
             if (const auto m = mappingOf (d.child ("MacroControls." + std::to_string (k))))
@@ -548,12 +714,19 @@ int rackDeviceFrom (Ctx& ctx, const Element& d, PatcherDoc& doc, int chain, bool
     }
     // (round 190bq) Live's own effects LYNX has an engine for: the LYNX effect in the chain
     std::vector<alsdev::ParamLink> links;
-    if (! isInstrumentDevice (tag) && nativeEffectFrom (ctx, d, node.effect, &links))
+    std::string from;
+    if (! isInstrumentDevice (tag) && nativeEffectFrom (ctx, d, node.effect, &links, &from))
     {
         node.label = d.value ("UserName");
         const auto n = rack::addDevice (doc, chain, std::move (node));
         if (n >= 0 && native != nullptr)
             *native = true;
+        // (round 190ed) envelopes on its parameters: carried by a macro of the rack once the rack has its place
+        if (n >= 0 && ctx.rackAutos != nullptr)
+            for (const auto& l : links)
+                if (const auto id = targetId (d.path (l.live)); ! id.empty() && ctx.automated.count (id) != 0)
+                    ctx.rackAutos->push_back ({ id, {}, n, l.param, l.value, doc.nodes[(std::size_t) n].effect.params[(std::size_t) l.param],
+                                                from + " " + spacedName (pathFileName (l.live)) });
         // (round 190cf) the rack's macros drive the LYNX effect's parameters over the range the mapping holds, each
         // end through the parameter's law (between the ends the macro moves LYNX's control in a straight line)
         if (n >= 0)
@@ -681,6 +854,12 @@ bool rackFrom (Ctx& ctx, const Element& device, PatcherDoc& doc, int depth)
         if (auto& m = r->macros[(std::size_t) k]; m.name.empty() && m.mappings.empty() && droppedTargets[(std::size_t) k].size() == 1)
             m.name = droppedTargets[(std::size_t) k].front();
     r->shownMacros = std::clamp ((int) device.number ("NumVisibleMacroControls", 8), 1, rackMacroCount);
+    // (round 190ed) the macros an envelope moves (0…127 → the slot's parameter k, 0..1)
+    if (ctx.rackAutos != nullptr)
+        for (int k = 0; k < rackMacroCount; ++k)
+            if (const auto id = targetId (device.child ("MacroControls." + std::to_string (k))); ! id.empty() && ctx.automated.count (id) != 0)
+                ctx.rackAutos->push_back ({ id, {}, -1, k, [] (double v) { return (float) std::clamp (v / 127.0, 0.0, 1.0); },
+                                            r->macros[(std::size_t) k].value / 127.0f, rack::macroName (*r, k) });
     r->selector = (float) std::clamp (device.number ("ChainSelector/Manual", 0.0), 0.0, 127.0);
     r->selectorFiltersCtrl = device.boolean ("ChainSelectorFilterMidiCtrl", false);
     r->autoSelect = device.boolean ("IsAutoSelectEnabled", false);
@@ -734,6 +913,11 @@ bool instrumentFrom (Ctx& ctx, const Element& device, ChannelDef& channel, std::
             channel.plugin.name = p->name;
             channel.plugin.foreign = *p;
             ctx.note (&FlpImportReport::converted, "Plugin: " + p->name);
+            // (round 190ed) envelopes on the plugin's parameters (the track's own instrument only)
+            if (depth == 0 && ! ctx.inDrumPad)
+                pluginAutos (ctx, device, p->name, [&ctx] (const std::string& id, int param, float, const std::string& name) {
+                    ctx.channelTargets.push_back ({ id, Target { AutomationTarget { AutomationTargetKind::channelParam, -1, 0, param }, ValueMap::plain, name, {} } });
+                });
             return true;
         }
         return false;
@@ -791,6 +975,18 @@ bool instrumentFrom (Ctx& ctx, const Element& device, ChannelDef& channel, std::
             else
             {
                 ctx.pendingKeyShift = r.keyShift;
+                // (round 190ed) envelopes on the filter's frequency (Hz, the same law) and resonance (as the import
+                // reads it) move the Sampler's Cutoff / Resonance knobs
+                const auto filter = device.path ("Filter/Slot/Value/SimplerFilter");
+                if (depth == 0 && device.boolean ("Filter/IsOn/Manual", false) && filter)
+                {
+                    if (const auto id = targetId (filter.child ("Freq")); ! id.empty() && ctx.automated.count (id) != 0)
+                        ctx.channelTargets.push_back ({ id, Target { AutomationTarget { AutomationTargetKind::channelParam, -1, 0, samplerparam::cutoff }, ValueMap::plain,
+                                                                     "Simpler Filter Freq", [] (double hz) { return samplerparam::toValue (samplerparam::cutoff, (float) std::clamp (hz, 20.0, 20000.0)); } } });
+                    if (const auto id = targetId (filter.child ("Res")); ! id.empty() && ctx.automated.count (id) != 0)
+                        ctx.channelTargets.push_back ({ id, Target { AutomationTarget { AutomationTargetKind::channelParam, -1, 0, samplerparam::resonance }, ValueMap::plain,
+                                                                     "Simpler Filter Res", [] (double r) { return samplerparam::toValue (samplerparam::resonance, (float) std::clamp (r, 0.0, 1.0)); } } });
+                }
                 for (const auto& n : notes.approximated)
                     ctx.note (&FlpImportReport::approximated, "Simpler: " + n);
                 for (const auto& n : notes.dropped)
@@ -860,10 +1056,17 @@ bool instrumentFrom (Ctx& ctx, const Element& device, ChannelDef& channel, std::
     if (tag == "InstrumentGroupDevice" && depth < 8) // (round 183c: a LYNX Instrument Rack)
     {
         auto doc = rack::makeRack (RackDoc::Kind::instrument);
-        if (rackFrom (ctx, device, doc, depth))
+        // (round 190ed) the envelopes inside the rack and on its macros (the track's own instrument only): the channel's
+        // macro parameters
+        std::vector<RackAuto> autos;
+        auto* const saved = std::exchange (ctx.rackAutos, depth == 0 && ! ctx.inDrumPad ? &autos : nullptr);
+        const auto read = rackFrom (ctx, device, doc, depth);
+        ctx.rackAutos = saved;
+        if (read)
         {
             channel.instrument = InstrumentKind::patcher;
             channel.patcher = std::move (doc);
+            placeRackAutos (ctx, channel.patcher, autos, [] (int k) { return AutomationTarget { AutomationTargetKind::channelParam, -1, 0, k }; }, true);
             return true;
         }
         return false;
@@ -881,6 +1084,29 @@ bool instrumentFrom (Ctx& ctx, const Element& device, ChannelDef& channel, std::
                     }
         return false;
     }
+    // (round 190ed) Operator without FM in use and Drift: the built-in synth with their oscillators, filter and amp
+    // envelope (core/AlsDevices.h); the report lists the pair as fitted and what has no place
+    if (tag == "Operator" || tag == "Drift")
+    {
+        alsdev::Notes notes;
+        ChannelDef synth = channel;
+        if (tag == "Operator" ? alsdev::operatorToSynth (device, synth, ctx.song.bpm, notes) : alsdev::driftToSynth (device, synth, ctx.song.bpm, notes))
+        {
+            channel = std::move (synth);
+            ctx.note (&FlpImportReport::partialEffects, tag + " -> built-in synth (settings fitted to LYNX's engine)");
+            for (const auto& n : notes.approximated)
+                ctx.note (&FlpImportReport::partialEffects, tag + ": " + n);
+            for (const auto& n : notes.dropped)
+                ctx.note (&FlpImportReport::partialEffects, tag + ": " + n + " (not applied)");
+            return true;
+        }
+        if (tag == "Operator")
+        {
+            // FM (or a waveform whose order is not settled): no LYNX engine holds it yet
+            ctx.note (&FlpImportReport::unsupported, deviceName (device) + " (FM synthesis: no LYNX engine for it yet)");
+            return false;
+        }
+    }
     // Live's synths: no LYNX equivalent; the channel keeps a built-in synth, as for an unknown FL generator
     ctx.note (&FlpImportReport::unsupported, deviceName (device));
     return false;
@@ -935,6 +1161,87 @@ bool midiEffectFrom (Ctx& ctx, const Element& d, ChannelDef& channel, std::vecto
     return true;
 }
 
+// (round 190ed) The Peak Controller of a translated effect's modulation (core/AlsDevices.h Translated::Modulator): in
+// front of the effect on its insert, or (a side-chain envelope follower) at the end of the source track's insert once
+// every track is read; the link is made then (finishLinks)
+void placeModulator (Ctx& ctx, const Element& d, MixerTrack& insert, int track, alsdev::Translated::Modulator& mod, std::vector<alsdev::ParamLink>& links,
+                     const std::string& from)
+{
+    // the parameter the link moves keeps no envelope of its own (the link would fight it)
+    for (auto it = links.begin(); it != links.end(); ++it)
+        if (it->param == mod.param)
+        {
+            if (const auto id = targetId (d.path (it->live)); ! id.empty() && ctx.automated.count (id) != 0)
+            {
+                ctx.note (&FlpImportReport::partialEffects, from + ": automation of the cutoff under its " + mod.what + " (the link moves the cutoff; not carried)");
+                ctx.explained.insert (id);
+            }
+            links.erase (it);
+            break;
+        }
+    Ctx::PendingLink link;
+    link.controller = std::move (mod.controller);
+    link.targetTrack = track;
+    link.param = mod.param;
+    link.curve = std::move (mod.curve);
+    link.notes = std::move (mod.notes);
+    link.from = from;
+    link.what = mod.what;
+    if (mod.sideTrackId >= 0)
+        if (const auto it = ctx.insertOfTrack.find (mod.sideTrackId); it != ctx.insertOfTrack.end())
+        {
+            link.sourceInsert = it->second;
+            link.notes.push_back ("envelope follower on the side-chain source: its Peak Controller sits at the end of that track's insert");
+            ctx.pendingLinks.push_back (std::move (link));
+            return;
+        }
+    if (mod.sideTrackId >= 0 || mod.sideOther)
+        link.notes.push_back ("side-chain input of the envelope follower (its source is not a track of the set; the follower hears the effect's input)");
+    if (insert.effects.size() + 2 > (std::size_t) maxEffectSlots)
+    {
+        ctx.note (&FlpImportReport::partialEffects, from + ": " + mod.what + " on the cutoff (no free effect slot for its Peak Controller) (not applied)");
+        return;
+    }
+    insert.effects.push_back (std::move (link.controller));
+    link.sourceInsert = track;
+    link.sourceSlot = (int) insert.effects.size() - 1;
+    ctx.pendingLinks.push_back (std::move (link));
+}
+
+// (round 190ed) Every track is read: the side-chain controllers go to the end of their source inserts and each link is made
+void finishLinks (Ctx& ctx)
+{
+    auto& song = ctx.song;
+    for (auto& link : ctx.pendingLinks)
+    {
+        if (link.targetSlot < 0 || link.sourceInsert < 0 || link.sourceInsert >= (int) song.mixer.size())
+            continue;
+        if (link.sourceSlot < 0)
+        {
+            auto& source = song.mixer[(std::size_t) link.sourceInsert];
+            if (source.effects.size() >= (std::size_t) maxEffectSlots)
+            {
+                ctx.note (&FlpImportReport::partialEffects, link.from + ": " + link.what + " on the cutoff (no free effect slot on the side-chain source) (not applied)");
+                continue;
+            }
+            source.effects.push_back (std::move (link.controller));
+            link.sourceSlot = (int) source.effects.size() - 1;
+        }
+        Automation a;
+        a.name = song.mixer[(std::size_t) link.targetTrack].name + " " + link.from + " cutoff (" + link.what + ")";
+        a.target = { AutomationTargetKind::effectParam, link.targetTrack, link.targetSlot, link.param };
+        a.source.track = link.sourceInsert;
+        a.source.slot = link.sourceSlot;
+        a.source.output = 0; // peak + LFO
+        a.curve = link.curve;
+        song.automations.push_back (std::move (a));
+        ctx.note (&FlpImportReport::partialEffects, link.from + " " + link.what + " -> Peak Controller linked to the Filter's cutoff");
+        for (const auto& n : link.notes)
+            ctx.note (&FlpImportReport::partialEffects, link.from + ": " + n);
+    }
+    ctx.pendingLinks.clear();
+}
+
 // Audio effects of a track (after its instrument): plugins carried over, the rest listed
 void effectsFrom (Ctx& ctx, const std::vector<Element>& devices, MixerTrack& insert)
 {
@@ -952,6 +1259,11 @@ void effectsFrom (Ctx& ctx, const std::vector<Element>& devices, MixerTrack& ins
                 slot.plugin.foreign = *p;
                 insert.effects.push_back (std::move (slot));
                 ctx.note (&FlpImportReport::converted, "Plugin: " + p->name);
+                // (round 190ed) envelopes on the plugin's parameters
+                const auto track = (int) (&insert - ctx.song.mixer.data()), at = (int) insert.effects.size() - 1;
+                pluginAutos (ctx, d, p->name, [&ctx, track, at] (const std::string& id, int param, float, const std::string& name) {
+                    ctx.targets[id] = { AutomationTarget { AutomationTargetKind::effectParam, track, at, param }, ValueMap::plain, name, {} };
+                });
             }
             continue;
         }
@@ -959,8 +1271,19 @@ void effectsFrom (Ctx& ctx, const std::vector<Element>& devices, MixerTrack& ins
         {
             auto slot = rack::makeRackSlot (RackDoc::Kind::audioEffect);
             slot.enabled = d.boolean ("On/Manual", true);
-            if (rackFrom (ctx, d, slot.patcher, 0))
+            // (round 190ed) the envelopes inside the rack and on its macros: the slot's macro parameters
+            std::vector<RackAuto> autos;
+            auto* const saved = std::exchange (ctx.rackAutos, &autos);
+            const auto read = rackFrom (ctx, d, slot.patcher, 0);
+            ctx.rackAutos = saved;
+            if (read)
+            {
                 insert.effects.push_back (std::move (slot));
+                const auto track = (int) (&insert - ctx.song.mixer.data()), at = (int) insert.effects.size() - 1;
+                placeRackAutos (ctx, insert.effects.back().patcher, autos, [track, at] (int k) {
+                    return AutomationTarget { AutomationTargetKind::effectParam, track, at, k };
+                });
+            }
             continue;
         }
         if (isMidiEffect (tag))
@@ -971,11 +1294,19 @@ void effectsFrom (Ctx& ctx, const std::vector<Element>& devices, MixerTrack& ins
         // (round 190bq) Live's own effects LYNX has an engine for: the LYNX effect, settings translated
         std::vector<alsdev::ParamLink> links;
         std::string from;
-        if (EffectSlot slot; insert.effects.size() < (std::size_t) maxEffectSlots && nativeEffectFrom (ctx, d, slot, &links, &from))
+        std::optional<alsdev::Translated::Modulator> modulator;
+        if (EffectSlot slot; insert.effects.size() < (std::size_t) maxEffectSlots && nativeEffectFrom (ctx, d, slot, &links, &from, &modulator))
         {
+            const auto track = (int) (&insert - ctx.song.mixer.data());
+            // (round 190ed) the modulation's Peak Controller: in front of the effect, or at the end of the side-chain
+            // source's insert once every track is read; the link drives the parameter the modulation moves, so that
+            // parameter's own envelope is not carried as well
+            if (modulator)
+                placeModulator (ctx, d, insert, track, *modulator, links, from);
             insert.effects.push_back (std::move (slot));
+            if (modulator && ! ctx.pendingLinks.empty() && ctx.pendingLinks.back().targetSlot == -1)
+                ctx.pendingLinks.back().targetSlot = (int) insert.effects.size() - 1;
             // (round 190cf) automation of the device's parameters follows onto the LYNX effect's, by the same laws
-            const auto track = (int) (&insert - ctx.song.mixer.data());
             for (auto& l : links)
                 if (const auto id = targetId (d.path (l.live)); ! id.empty())
                     ctx.targets[id] = { AutomationTarget { AutomationTargetKind::effectParam, track, (int) insert.effects.size() - 1, l.param },
@@ -1343,7 +1674,8 @@ void addAutomation (Ctx& ctx, const Element& envelopes, const std::string& owner
         const auto it = ctx.targets.find (id);
         if (it == ctx.targets.end())
         {
-            ctx.note (&FlpImportReport::unsupported, "Automation of a device parameter (" + owner + ")");
+            if (ctx.explained.count (id) == 0)
+                ctx.note (&FlpImportReport::unsupported, "Automation of a device parameter (" + owner + ")");
             continue;
         }
         std::vector<std::pair<double, double>> events;
@@ -1753,6 +2085,13 @@ std::optional<Song> importAlsXml (const xml::Document& doc, const AlsImportOptio
 
     // tracks: one insert each (returns too), in order
     const auto tracks = set.child ("Tracks").children();
+    // (round 190ed) the parameters an arrangement envelope moves
+    for (const auto& owner : { main.child ("AutomationEnvelopes") })
+        for (const auto& env : owner.path ("Envelopes").children ("AutomationEnvelope"))
+            ctx.automated.insert (env.path ("EnvelopeTarget/PointeeId").attr ("Value"));
+    for (const auto& t : tracks)
+        for (const auto& env : t.path ("AutomationEnvelopes/Envelopes").children ("AutomationEnvelope"))
+            ctx.automated.insert (env.path ("EnvelopeTarget/PointeeId").attr ("Value"));
     std::vector<int> insertOf (tracks.size(), 0), rowOf (tracks.size(), -1);
     std::map<std::string, int> groupInsert, groupRow;
     std::vector<int> returns;
@@ -1887,6 +2226,14 @@ std::optional<Song> importAlsXml (const xml::Document& doc, const AlsImportOptio
             }
             song.channels.push_back (std::move (c));
             channelOf[i] = (int) song.channels.size() - 1;
+            // (round 190ed) the envelopes on the channel's instrument (a plugin's parameters, an Instrument Rack's macros,
+            // a Simpler's filter)
+            for (auto& [id, target] : ctx.channelTargets)
+            {
+                target.target.index = channelOf[i];
+                ctx.targets[id] = std::move (target);
+            }
+            ctx.channelTargets.clear();
             if (! noteEffects.empty())
                 ctx.noteEffects[channelOf[i]] = std::move (noteEffects);
             if (ctx.pendingKeyShift != 0)
@@ -1915,6 +2262,8 @@ std::optional<Song> importAlsXml (const xml::Document& doc, const AlsImportOptio
             ctx.note (&FlpImportReport::unsupported, "Take lanes (only the main lane is kept)");
     }
 
+    finishLinks (ctx); // (round 190ed)
+
     // Session clips: in the clip grid (round 181c, the default: the user's choice of 2026-11-08), or on the Playlist
     // after the arrangement, one section per scene (an option; the default before)
     const auto scenes = set.child ("Scenes").children ("Scene");

+ 2 - 1
tests/AlsDevices190cfTests.inc

@@ -419,7 +419,8 @@ TEST (als190cf_filter_saturation_eq_chorus_pan_redux)
     {
         CHECK (filter->slot.kind == EffectKind::filter && shown (filter->slot, 0) == "High-pass" && shown (filter->slot, 1) == "880 Hz" && shown (filter->slot, 2) == "Q 6.50");
         CHECK (! als190cf::hasNote (filter->notes.approximated, "resonance") && shown (filter->slot, 4) == "24 dB/oct");
-        CHECK (filter->slot.params[3] == 1.0f && als190cf::hasNote (filter->notes.dropped, "LFO") &&
+        // (round 190ed) the LFO is no longer dropped: a Peak Controller linked to the cutoff carries it
+        CHECK (filter->slot.params[3] == 1.0f && filter->modulator.has_value() && filter->modulator->what == "LFO" &&
                als190cf::hasNote (filter->notes.approximated, "24 dB/oct high pass (Live's measured on the low pass)"));
         const auto* cutoff = als190cf::linkOf (*filter, "Cutoff");
         CHECK (cutoff != nullptr && cutoff->param == 1 && formatEffectParam (EffectKind::filter, 1, cutoff->value (69.0), 120.0) == "440 Hz");

+ 582 - 0
tests/AlsDevices190edTests.inc

@@ -0,0 +1,582 @@
+// --- Live's own devices in a set → LYNX's own, lot 3 (round 190ed, core/AlsDevices.h): EQ Three, Drum Buss, Auto
+// Filter's LFO / envelope follower / side chain, Operator and Drift, and the envelopes of racks, devices inside racks and
+// plugins. The device elements are written by the tests with the member names Live saves; no file of Live's is used.
+// Which statements about Live are [ASSUMED] is listed in the round's handoff.
+
+#include "core/AlsDevices.h"
+#include "core/AlsImport.h"
+#include "core/DynamicsSuite.h"
+#include "core/Effects.h"
+#include "core/MixSuite.h"
+#include "core/Patcher.h"
+#include "core/Rack.h"
+#include "core/XmlLite.h"
+
+namespace als190ed
+{
+using als175a::v;
+using als190bq::flag;
+using als190bq::hasNote;
+using als190bq::num;
+using als190bq::par;
+using als190bq::reportHas;
+using als190cf::near;
+using als190cf::on;
+using als190cf::target;
+
+inline std::optional<lynx::alsdev::Translated> translate (const std::string& text, double bpm = 120.0) { return als190cf::translate (text, bpm); }
+
+// a set: one MIDI track (Id 10) with `midiDevices` and `midiEnvelopes`, one audio track (Id 20) with `audioDevices` and
+// `audioEnvelopes`, a second audio track (Id 30, "Kick") with no devices
+inline std::string set (const std::string& midiDevices, const std::string& audioDevices, const std::string& midiEnvelopes = {}, const std::string& audioEnvelopes = {})
+{
+    using als175a::mixer;
+    using als175a::name;
+    std::string s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Ableton MajorVersion=\"5\" MinorVersion=\"12.0_12117\" Creator=\"test\">\n<LiveSet><Tracks>";
+    s += "<MidiTrack Id=\"10\">" + name ("Keys") + v ("Color", "3") + v ("TrackGroupId", "-1") + "<DeviceChain>" + mixer (100, 1.0, 0.0, true) +
+         "<AudioOutputRouting>" + v ("Target", "AudioOut/Main") + "</AudioOutputRouting><DeviceChain><Devices>" + midiDevices +
+         "</Devices></DeviceChain></DeviceChain><AutomationEnvelopes><Envelopes>" + midiEnvelopes + "</Envelopes></AutomationEnvelopes></MidiTrack>";
+    s += "<AudioTrack Id=\"20\">" + name ("Bus") + v ("Color", "20") + v ("TrackGroupId", "-1") + "<DeviceChain>" + mixer (200, 1.0, 0.0, true) +
+         "<AudioOutputRouting>" + v ("Target", "AudioOut/Main") + "</AudioOutputRouting><DeviceChain><Devices>" + audioDevices +
+         "</Devices></DeviceChain></DeviceChain><AutomationEnvelopes><Envelopes>" + audioEnvelopes + "</Envelopes></AutomationEnvelopes></AudioTrack>";
+    s += "<AudioTrack Id=\"30\">" + name ("Kick") + v ("Color", "21") + v ("TrackGroupId", "-1") + "<DeviceChain>" + mixer (300, 1.0, 0.0, true) +
+         "<AudioOutputRouting>" + v ("Target", "AudioOut/Main") + "</AudioOutputRouting><DeviceChain><Devices></Devices></DeviceChain></DeviceChain></AudioTrack>";
+    s += "</Tracks><MainTrack><DeviceChain>" + mixer (900, 1.0, 0.0, true, {}, "<Tempo><Manual Value=\"120\" /></Tempo><TimeSignature><Manual Value=\"201\" /></TimeSignature>") +
+         "</DeviceChain></MainTrack></LiveSet>\n</Ableton>\n";
+    return s;
+}
+
+inline std::optional<lynx::Song> import (const std::string& text, lynx::FlpImportReport& report)
+{
+    lynx::xml::Document doc;
+    if (! doc.parse (text))
+        return std::nullopt;
+    auto options = als175a::options (&report);
+    std::string error;
+    auto song = lynx::importAlsXml (doc, options, &error);
+    if (! song)
+        std::printf ("  import error: %s\n", error.c_str());
+    return song;
+}
+
+inline const lynx::Automation* automationOn (const lynx::Song& song, const lynx::AutomationTarget& t)
+{
+    for (const auto& a : song.automations)
+        if (a.target == t)
+            return &a;
+    return nullptr;
+}
+
+inline std::string eqThree (double lo, double mid, double hi, bool lowOn, bool midOn, bool highOn, double freqLo = 250.0, double freqHi = 2500.0, double slope = 1.0)
+{
+    return "<FilterEQ3 Id=\"3\">" + on() + par ("GainLo", lo) + par ("GainMid", mid) + par ("GainHi", hi) + par ("FreqLo", freqLo) + par ("FreqHi", freqHi) +
+           flag ("LowOn", lowOn) + flag ("MidOn", midOn) + flag ("HighOn", highOn) + par ("Slope", slope) + "</FilterEQ3>";
+}
+
+inline std::string drumBuss (const std::string& extra)
+{
+    return "<DrumBuss Id=\"4\">" + on() + extra + "</DrumBuss>";
+}
+
+// the older Auto Filter: low pass at `note`, its LFO amount, rate, envelope amount
+inline std::string autoFilter (double note, double lfoAmount, double modHub, const std::string& extra = {})
+{
+    return "<AutoFilter Id=\"5\">" + on() + par ("FilterType", 0) + par ("Cutoff", note) + par ("Resonance", 0.0) + flag ("Slope", false) + par ("ModHub", modHub) +
+           par ("Attack", 6.0) + par ("Release", 200.0) + par ("LfoAmount", lfoAmount) + "<Lfo>" + par ("Type", 0) + par ("Frequency", 1.0) + par ("RateType", 1) +
+           par ("BeatRate", 9) + par ("Spin", 0.0) + par ("Phase", 0.0) + par ("Offset", 0.0) + flag ("IsOn", true) + "</Lfo>" + extra + "</AutoFilter>";
+}
+
+inline std::string sideChain (int track)
+{
+    return "<SideChain><OnOff><Manual Value=\"true\" /></OnOff><RoutedInput><Routable>" + v ("Target", "AudioIn/Track." + std::to_string (track) + "/PostMixerOut") +
+           "</Routable></RoutedInput></SideChain>";
+}
+
+// a peak controller run over `seconds` of a constant-amplitude input at 120 BPM, stopped: the last value of `output`
+inline float controllerOutput (const lynx::EffectSlot& slot, float amplitude, int output, double seconds = 0.05)
+{
+    auto fx = lynx::makeEffect (slot);
+    fx->prepare (48000.0);
+    fx->setPlaying (false);
+    std::vector<float> l (256, amplitude), r (256, amplitude);
+    for (int b = 0; b < (int) (seconds * 48000.0 / 256.0); ++b)
+    {
+        std::fill (l.begin(), l.end(), amplitude);
+        std::fill (r.begin(), r.end(), amplitude);
+        fx->process (l.data(), r.data(), 256, slot.params, 120.0);
+    }
+    return fx->controlOutput (output);
+}
+
+inline std::unique_ptr<lynx::patcher::Graph> graphOf (const lynx::PatcherDoc& doc)
+{
+    auto g = std::make_unique<lynx::patcher::Graph> (doc, 48000.0, lynx::patcher::builtInFactories (48000.0));
+    g->prepare (48000.0);
+    return g;
+}
+
+inline std::string operatorDevice (int algorithm, const std::array<double, 4>& volumes, int waveA = 0, int coarseA = 1, const std::string& extra = {})
+{
+    std::string s = "<Operator Id=\"6\">" + on();
+    for (int k = 0; k < 4; ++k)
+    {
+        const auto n = std::to_string (k);
+        s += "<Operator." + n + "><Envelope>" + par ("AttackTime", 2.0) + par ("AttackLevel", 0.000316227757) + par ("DecayTime", 400.0) + par ("DecayLevel", 1.0) +
+             par ("SustainLevel", 0.5) + par ("ReleaseTime", 300.0) + par ("ReleaseLevel", 0.000316227757) + par ("AttackSlope", 0.0) + par ("DecaySlope", 1.0) +
+             par ("ReleaseSlope", 1.0) + par ("LoopMode", 0) + "</Envelope><Tune>" + par ("Coarse", k == 0 ? coarseA : 1) + par ("Fine", 0.0) +
+             flag ("FixedFrequencyOn", false) + "</Tune>" + par ("Volume", volumes[(std::size_t) k]) + flag ("IsOn", true) + par ("WaveForm", k == 0 ? waveA : 0) +
+             par ("Feedback", 0.0) + flag ("LfoOn", true) + flag ("PitchEnvOn", true) + "<UserHarmonics>";
+        for (int h = 0; h < 64; ++h)
+            s += v (("Harmonics." + std::to_string (h)).c_str(), h == 0 ? "1" : (h == 2 ? "0.5" : "0"));
+        s += "</UserHarmonics></Operator." + n + ">";
+    }
+    s += "<Globals>" + par ("Algorithm", algorithm) + par ("Transpose", 0.0) + par ("Volume", 0.5) + par ("Panorama", 0.0) + par ("SpreadAmount", 0.0) +
+         par ("Tone", 0.7) + flag ("PortamentoOn", false) + par ("PortamentoTime", 50.0) + "</Globals>" + "<Filter>" + flag ("OnOff", false) + "</Filter><Lfo>" +
+         flag ("LfoOn", false) + "</Lfo><PitchEnv>" + flag ("PitchEnvOn", false) + "</PitchEnv>" + extra + "</Operator>";
+    return s;
+}
+} // namespace als190ed
+
+TEST (als190ed_eq_three_becomes_prism)
+{
+    using namespace lynx;
+    using namespace lynx::dyn::prism;
+    using als190ed::near;
+    // −6 dB low, +3 dB mid, 0 dB high, 48 dB/oct at 300 Hz / 3 kHz
+    const auto t = als190ed::translate (als190ed::eqThree (0.501187, 1.412538, 1.0, true, true, true, 300.0, 3000.0, 1.0));
+    CHECK (t.has_value() && t->slot.kind == EffectKind::prismMultiband && t->from == "EQ Three" && t->approximate);
+    if (! t)
+        return;
+    const auto& p = t->slot.params;
+    CHECK (bandCount (p) == 3 && phaseOf (p[processingMode]) == Phase::minimum);
+    CHECK (near (crossoverHz (p[(std::size_t) crossoverParam (0)]), 300.0, 0.5) && near (crossoverHz (p[(std::size_t) crossoverParam (1)]), 3000.0, 3.0));
+    CHECK (crossoverSlopeDbOct (p, 0) == 48 && crossoverSlopeDbOct (p, 1) == 48);
+    CHECK (near (levelDb (p[(std::size_t) param (0, fLevel)]), -6.0, 0.01) && near (levelDb (p[(std::size_t) param (1, fLevel)]), 3.0, 0.01) &&
+           near (levelDb (p[(std::size_t) param (2, fLevel)]), 0.0, 0.01));
+    CHECK (p[(std::size_t) param (0, fSolo)] == 0.0f && p[(std::size_t) param (1, fSolo)] == 0.0f && near (rangeDb (p[(std::size_t) param (0, fRange)]), 0.0, 1.0e-6));
+    // the static response: each band's level in its middle, flat where the gains are 0 dB
+    const double flat[3] { 0.0, 0.0, 0.0 };
+    const double levels[3] { -6.0, 3.0, 0.0 };
+    CHECK (std::abs (responseDb (p, flat, 48000.0, 1000.0)) < 0.05 && std::abs (responseDb (p, flat, 48000.0, 60.0)) < 0.05);
+    CHECK (near (responseDb (p, levels, 48000.0, 40.0), -6.0, 0.2) && near (responseDb (p, levels, 48000.0, 950.0), 3.0, 0.2) &&
+           near (responseDb (p, levels, 48000.0, 14000.0), 0.0, 0.2));
+    // the links: gains (linear → dB) and the crossovers
+    const auto* gain = als190cf::linkOf (*t, "GainMid");
+    const auto* freq = als190cf::linkOf (*t, "FreqHi");
+    CHECK (gain != nullptr && freq != nullptr);
+    if (gain != nullptr && freq != nullptr)
+        CHECK (near (levelDb (gain->value (2.0)), 6.02, 0.01) && near (crossoverHz (freq->value (5000.0)), 5000.0, 5.0));
+    // a kill switch: the bands that still sound are soloed, the killed one is gone; −inf counts as killed
+    const auto killed = als190ed::translate (als190ed::eqThree (1.0, 1.0, 0.000316227757, false, true, true, 250.0, 2500.0, 0.0));
+    CHECK (killed.has_value());
+    if (killed)
+    {
+        const auto& k = killed->slot.params;
+        CHECK (k[(std::size_t) param (0, fSolo)] == 0.0f && k[(std::size_t) param (1, fSolo)] == 1.0f && k[(std::size_t) param (2, fSolo)] == 0.0f);
+        CHECK (crossoverSlopeDbOct (k, 0) == 24);
+        const double zero[3] { 0.0, 0.0, 0.0 };
+        CHECK (responseDb (k, zero, 48000.0, 30.0) < -20.0 && std::abs (responseDb (k, zero, 48000.0, 790.0)) < 1.0 && responseDb (k, zero, 48000.0, 16000.0) < -20.0);
+        CHECK (als190bq::hasNote (killed->notes.approximated, "minimum-phase crossover sum at 24 dB/oct"));
+    }
+    // every band off: Prism's lowest output, listed
+    const auto silent = als190ed::translate (als190ed::eqThree (1.0, 1.0, 1.0, false, false, false));
+    CHECK (silent.has_value() && silent && als190bq::hasNote (silent->notes.approximated, "all three bands off"));
+}
+
+TEST (als190ed_drum_buss_becomes_a_rack)
+{
+    using namespace lynx;
+    using namespace lynx::alsdev;
+    namespace em = mixsuite::ember;
+    namespace sh = mixsuite::shell;
+    using als190ed::near;
+    using als190ed::par;
+    // Drive 50 % medium, damping 6 kHz, transients +0.4, boom 0.3 at 60 Hz, trim −6 dB, output −3 dB, 100 % wet, compressor on
+    const auto extra = als190ed::flag ("EnableCompression", true) + par ("DriveAmount", 0.5) + par ("DriveType", 1) + par ("CrunchAmount", 0.0) +
+                       par ("DampingFrequency", 6000.0) + par ("TransientShaping", 0.4) + par ("BoomFrequency", 60.0) + par ("BoomAmount", 0.3) +
+                       par ("BoomDecay", 1.0) + par ("InputTrim", 0.501187) + par ("OutputGain", 0.707946) + par ("DryWet", 1.0);
+    const auto t = als190ed::translate (als190ed::drumBuss (extra));
+    CHECK (t.has_value() && t->slot.kind == EffectKind::patcher && rack::isRack (t->slot));
+    if (! t || ! rack::isRack (t->slot))
+        return;
+    const auto& doc = t->slot.patcher;
+    const auto* r = rack::rackOf (doc);
+    CHECK (r->chains.size() == 1 && r->chains[0].nodes.size() == 2 && r->name == "Drum Buss");
+    if (r->chains.size() != 1 || r->chains[0].nodes.size() != 2)
+        return;
+    const auto& e = doc.nodes[(std::size_t) r->chains[0].nodes[0]].effect;
+    const auto& s = doc.nodes[(std::size_t) r->chains[0].nodes[1]].effect;
+    CHECK (e.kind == EffectKind::ember && s.kind == EffectKind::shellChannel);
+    CHECK (near (em::driveDb (e.params[em::drive]), 12.0, 0.01) && em::styleOf (e.params[em::style]) == em::Style::tape && e.params[em::autoGain] == 0.0f);
+    CHECK (near (em::highCutHz (e.params[em::highCut]), 6000.0, 1.0) && e.params[em::wideCuts] == 0.0f);
+    CHECK (near (e.params[em::inputGain], (float) ((-6.0 + 24.0) / 48.0), 1.0e-4));
+    CHECK (s.params[sh::tsOn] == 1.0f && near (s.params[sh::tsAmount], 0.4, 1.0e-6) && s.params[sh::tsInvert] == 0.0f);
+    CHECK (s.params[sh::lfOn] == 1.0f && near (sh::lfHz (s.params[sh::lfFreq]) * 0.72, 60.0, 0.1) && near (s.params[sh::lfAmount], 0.3, 1.0e-6));
+    CHECK (s.params[sh::hfOn] == 0.0f && s.params[sh::lmcOn] == 1.0f && near (sh::gainDb (s.params[sh::output]), -3.0, 0.01));
+    // the macros sit where their controls are; Live's parameters reach the controls through them
+    CHECK (r->macros[dbDrive].name == "Drive" && near (r->macros[dbDrive].value, e.params[em::drive] * 127.0f, 1.0e-3) && r->macros[dbDrive].mappings.size() == 1);
+    CHECK (r->macros[dbBoomFreq].mappings.size() == 1 && r->macros[dbBoomFreq].mappings[0].param == sh::lfFreq);
+    const auto* drive = als190cf::linkOf (*t, "DriveAmount");
+    const auto* trans = als190cf::linkOf (*t, "TransientShaping");
+    CHECK (drive != nullptr && drive->param == dbDrive && near (em::driveDb (drive->value (1.0)), 24.0, 0.01) && trans != nullptr && trans->param == dbTransients);
+    CHECK (als190cf::linkOf (*t, "DryWet") == nullptr); // (no dry chain: nothing moves Dry/Wet)
+    CHECK (als190bq::hasNote (t->notes.approximated, "drive as Ember's tape style") && als190bq::hasNote (t->notes.approximated, "Boom as Shell Channel's low enhancer"));
+    // it runs: a 100 Hz sine through the rack comes out (Ember + Shell in series), no NaN
+    {
+        auto g = als190ed::graphOf (doc);
+        double energy = 0.0;
+        bool finite = true;
+        for (int b = 0; b < 40; ++b)
+        {
+            std::vector<float> l (512), rr (512);
+            for (int i = 0; i < 512; ++i)
+                l[(std::size_t) i] = rr[(std::size_t) i] = 0.25f * (float) std::sin (2.0 * 3.141592653589793 * 100.0 * (b * 512 + i) / 48000.0);
+            g->process (l.data(), rr.data(), nullptr, nullptr, l.data(), rr.data(), 512, 120.0);
+            for (int i = 0; i < 512; ++i)
+            {
+                finite = finite && std::isfinite (l[(std::size_t) i]);
+                if (b >= 20)
+                    energy += (double) l[(std::size_t) i] * l[(std::size_t) i];
+            }
+        }
+        CHECK (finite && energy > 1.0);
+    }
+    // 41 % wet and a negative transient: a dry chain beside, the chains' volumes 0.59 / 0.41, Invert on, the macro on Dry/Wet
+    const auto wet = als190ed::translate (als190ed::drumBuss (par ("DriveAmount", 0.0) + par ("DriveType", 2) + par ("DampingFrequency", 1200.0) +
+                                                              par ("TransientShaping", -0.45) + par ("BoomAmount", 0.0) + par ("DryWet", 0.41)));
+    CHECK (wet.has_value() && wet && rack::isRack (wet->slot));
+    if (wet && rack::isRack (wet->slot))
+    {
+        const auto* w = rack::rackOf (wet->slot.patcher);
+        CHECK (w->chains.size() == 2 && near (w->chains[0].volume, 0.41, 1.0e-6) && near (w->chains[1].volume, 0.59, 1.0e-6) && w->chains[1].nodes.empty());
+        const auto& we = wet->slot.patcher.nodes[(std::size_t) w->chains[0].nodes[0]].effect;
+        const auto& ws = wet->slot.patcher.nodes[(std::size_t) w->chains[0].nodes[1]].effect;
+        CHECK (em::styleOf (we.params[em::style]) == em::Style::transistor && we.params[em::wideCuts] == 1.0f && near (em::highCutWideHz (we.params[em::highCutWide]), 1200.0, 1.0));
+        CHECK (ws.params[sh::tsInvert] == 1.0f && near (ws.params[sh::tsAmount], 0.45, 1.0e-6) && ws.params[sh::lfOn] == 0.0f);
+        CHECK (w->macros[dbDryWet].mappings.size() == 2 && als190cf::linkOf (*wet, "DryWet") != nullptr && als190cf::linkOf (*wet, "TransientShaping") == nullptr);
+        CHECK (als190bq::hasNote (wet->notes.approximated, "negative transients"));
+    }
+}
+
+TEST (als190ed_peak_controller_laws)
+{
+    using namespace lynx;
+    using namespace lynx::alsdev;
+    using als190ed::near;
+    // the amounts come back through the controller's own processing: peak k × a constant input level, LFO base + k × wave
+    for (const double k : { 0.25, 0.5, 1.0 })
+    {
+        auto slot = makeEffectSlot (EffectKind::peakController);
+        slot.params[0] = 0.0f;
+        slot.params[1] = peakAmountValue (k);
+        slot.params[2] = 0.5f;
+        slot.params[5] = 0.5f; // no LFO
+        CHECK (near (als190ed::controllerOutput (slot, 0.5f, 1), 0.5 * k, 2.0e-3));
+    }
+    // the LFO's period: a square wave (shape 2) at a quarter-note period changes sign every 0.25 s at 120 BPM
+    {
+        auto slot = makeEffectSlot (EffectKind::peakController);
+        slot.params[1] = 0.5f;
+        slot.params[4] = 0.0f;
+        slot.params[5] = peakLfoAmountValue (1.0);
+        slot.params[6] = 0.5f;
+        slot.params[7] = peakLfoSpeedValue (1.0);
+        slot.params[8] = 0.5f; // square
+        auto fx = makeEffect (slot);
+        fx->prepare (48000.0);
+        fx->setPlaying (false);
+        std::vector<float> l (48), r (48);
+        std::vector<float> outs;
+        for (int b = 0; b < 2000; ++b) // 2 s in 1 ms blocks
+        {
+            fx->process (l.data(), r.data(), 48, slot.params, 120.0);
+            outs.push_back (fx->controlOutput (2));
+        }
+        int flips = 0;
+        for (std::size_t i = 1; i < outs.size(); ++i)
+            flips += (outs[i] > 0.5f) != (outs[i - 1] > 0.5f) ? 1 : 0;
+        CHECK (flips >= 7 && flips <= 9); // 2 s / 0.25 s = 8 half periods
+        CHECK (near (*std::max_element (outs.begin(), outs.end()), 1.0, 1.0e-3));
+    }
+    // the decay: a peak of 1 falls to 0 over the release time (200 ms at 120 BPM → 0.4 quarter notes)
+    {
+        auto slot = makeEffectSlot (EffectKind::peakController);
+        slot.params[0] = 0.0f;
+        slot.params[1] = peakAmountValue (1.0);
+        slot.params[2] = 0.5f;
+        slot.params[3] = peakDecayValue (200.0, 120.0);
+        slot.params[5] = 0.5f;
+        auto fx = makeEffect (slot);
+        fx->prepare (48000.0);
+        fx->setPlaying (false);
+        std::vector<float> l (48, 1.0f), r (48, 1.0f);
+        fx->process (l.data(), r.data(), 48, slot.params, 120.0);
+        std::fill (l.begin(), l.end(), 0.0f);
+        std::fill (r.begin(), r.end(), 0.0f);
+        float at100 = -1.0f;
+        for (int b = 1; b <= 100; ++b)
+        {
+            fx->process (l.data(), r.data(), 48, slot.params, 120.0);
+            if (b == 100)
+                at100 = fx->controlOutput (1);
+        }
+        CHECK (near (at100, 0.5, 0.02)); // halfway after 100 ms
+    }
+    // the curve: c0 = 0.5, an LFO of ±0.1 and an envelope of +0.2 → from 0.4 over a span of 0.4; a negative envelope turns
+    // the curve over (and the LFO with it)
+    const auto up = cutoffModulation (0.5, 0.1, 0.2);
+    CHECK (up.curve.size() == 33 && near (up.curve.front(), 0.4, 1.0e-6) && near (up.curve.back(), 0.8, 1.0e-6) && ! up.invert);
+    const auto down = cutoffModulation (0.5, 0.1, -0.2);
+    CHECK (near (down.curve.front(), 0.6, 1.0e-6) && near (down.curve.back(), 0.2, 1.0e-6) && down.invert);
+    const auto clipped = cutoffModulation (0.95, 0.1, 0.0);
+    CHECK (near (clipped.curve.front(), 0.85, 1.0e-6) && clipped.curve.back() == 1.0f);
+}
+
+TEST (als190ed_auto_filter_modulation_is_a_linked_peak_controller)
+{
+    using namespace lynx;
+    using als190ed::near;
+    // Bus: an Auto Filter at C6 (note 84 ≈ 1047 Hz) with a synced LFO (1 bar … index 9 = a quarter note) of 12 semitones
+    // and an envelope follower of +24 semitones; Keys: an Auto Filter whose envelope listens to Kick (track 30)
+    const auto bus = als190ed::autoFilter (84.0, 12.0, 24.0);
+    const auto keys = als190ed::autoFilter (60.0, 0.0, 36.0, als190ed::sideChain (30));
+    FlpImportReport report;
+    const auto song = als190ed::import (als190ed::set (keys, bus), report);
+    CHECK (song.has_value());
+    if (! song)
+        return;
+    int keysInsert = -1, busInsert = -1, kickInsert = -1;
+    for (int i = 0; i < (int) song->mixer.size(); ++i)
+    {
+        keysInsert = song->mixer[(std::size_t) i].name == "Keys" ? i : keysInsert;
+        busInsert = song->mixer[(std::size_t) i].name == "Bus" ? i : busInsert;
+        kickInsert = song->mixer[(std::size_t) i].name == "Kick" ? i : kickInsert;
+    }
+    CHECK (busInsert > 0 && keysInsert > 0 && kickInsert > 0);
+    if (busInsert <= 0 || keysInsert <= 0 || kickInsert <= 0)
+        return;
+    // the bus: the controller in front of the filter, the link from its output 0 to the cutoff
+    const auto& fx = song->mixer[(std::size_t) busInsert].effects;
+    CHECK (fx.size() == 2 && fx[0].kind == EffectKind::peakController && fx[1].kind == EffectKind::filter);
+    const Automation* link = nullptr;
+    for (const auto& a : song->automations)
+        if (a.isLive() && a.target == AutomationTarget { AutomationTargetKind::effectParam, busInsert, 1, 1 })
+            link = &a;
+    CHECK (link != nullptr && link->source.track == busInsert && link->source.slot == 0 && link->source.output == 0 && link->curve.size() == 33);
+    if (link != nullptr && fx.size() == 2)
+    {
+        // ±1 octave of LFO and +2 octaves of envelope in the cutoff's units (log2 1000 octaves per unit)
+        const double perOct = 1.0 / 9.965784284662087;
+        const double c0 = fx[1].params[1];
+        CHECK (near (link->curve.front(), c0 - perOct, 1.0e-4) && near (link->curve.back(), c0 - perOct + 4.0 * perOct, 1.0e-4));
+        // the controller: no base, a quarter-note LFO, the envelope's amount and release
+        CHECK (fx[0].params[0] == 0.0f && fx[0].params[4] == 0.0f && fx[0].params[10] == 0.0f && fx[0].params[11] == 0.0f);
+        CHECK (near (fx[0].params[7], alsdev::peakLfoSpeedValue (1.0), 1.0e-6) && near (fx[0].params[3], alsdev::peakDecayValue (200.0, 120.0), 1.0e-6));
+    }
+    CHECK (report.partialEffects.count ("Auto Filter LFO and envelope follower -> Peak Controller linked to the Filter's cutoff") == 1);
+    CHECK (report.partialEffects.count ("Auto Filter envelope follower -> Peak Controller linked to the Filter's cutoff") == 1);
+    CHECK (! als190ed::reportHas (report.partialEffects, "LFO on the cutoff (not applied)"));
+    // the side chain: the controller at the end of Kick's insert, the link to Keys' filter
+    const auto& kick = song->mixer[(std::size_t) kickInsert].effects;
+    const auto& keysFx = song->mixer[(std::size_t) keysInsert].effects;
+    CHECK (kick.size() == 1 && kick[0].kind == EffectKind::peakController && keysFx.size() == 1 && keysFx[0].kind == EffectKind::filter);
+    const Automation* side = nullptr;
+    for (const auto& a : song->automations)
+        if (a.isLive() && a.target == AutomationTarget { AutomationTargetKind::effectParam, keysInsert, 0, 1 })
+            side = &a;
+    CHECK (side != nullptr && side->source.track == kickInsert && side->source.slot == 0);
+
+    // inside a rack no link can be made: listed
+    const auto rack = "<AudioEffectGroupDevice Id=\"7\">" + als190ed::on() + als175a::v ("UserName", "Wobble") + "<Branches><AudioEffectBranch Id=\"0\"><Name>" +
+                      als175a::v ("EffectiveName", "Filter") + als175a::v ("UserName", "") + "</Name>" + als175a::v ("IsSoloed", "false") +
+                      "<DeviceChain><AudioToAudioDeviceChain><Devices>" + als190ed::autoFilter (84.0, 12.0, 0.0) + "</Devices></AudioToAudioDeviceChain></DeviceChain>" +
+                      als190cf::range ("BranchSelectorRange", 0, 127, 0, 127) + als190cf::branchMixer (1.0, 0.0) + "</AudioEffectBranch></Branches>" +
+                      als190cf::macros ({}, {}) + "</AudioEffectGroupDevice>";
+    FlpImportReport rackReport;
+    const auto racked = als190ed::import (als190ed::set ({}, rack), rackReport);
+    CHECK (racked.has_value() && rackReport.partialEffects.count ("Auto Filter: LFO on the cutoff inside a rack (not applied)") == 1);
+}
+
+TEST (als190ed_operator_and_drift_become_the_synth)
+{
+    using namespace lynx;
+    using namespace lynx::alsdev;
+    using als190ed::near;
+    using als190ed::par;
+    // the ratio as the synth's pitch: 0.5 = −12, 3 = +19.02, 1 + 500/1000 = +7.02
+    CHECK (near (operatorRatioSemitones (0, 0.0), -12.0) && near (operatorRatioSemitones (3, 0.0), 19.0196, 1.0e-3) && near (operatorRatioSemitones (1, 500.0), 7.0196, 1.0e-3));
+    SynthOscillator o;
+    setOscillatorPitch (o, 19.0196);
+    CHECK (o.octave == 1 && o.semitones == 7 && near (o.detune, 1.96, 0.01));
+    setOscillatorPitch (o, -12.0);
+    CHECK (o.octave == -1 && o.semitones == 0 && near (o.detune, 0.0, 1.0e-6));
+    // operator A alone (B … D at −inf), a sine at ratio 2
+    {
+        xml::Document doc;
+        CHECK (doc.parse (als190ed::operatorDevice (0, { 0.8, 0.000316227757, 0.000316227757, 0.000316227757 }, 0, 2)));
+        ChannelDef c;
+        Notes notes;
+        CHECK (operatorToSynth (doc.root(), c, 120.0, notes));
+        CHECK (c.instrument == InstrumentKind::synth && c.synth.osc[0].wave == Waveform::sine && c.synth.osc[0].octave == 1 && c.synth.osc[0].semitones == 0 &&
+               near (c.synth.osc[0].level, 0.8, 1.0e-6) && c.synth.osc[1].level == 0.0f && c.synth.osc[2].level == 0.0f);
+        CHECK (near (c.synth.attack, 0.002, 1.0e-6) && near (c.synth.decay, 0.4, 1.0e-6) && near (c.synth.sustain, 0.5, 1.0e-6) && near (c.synth.release, 0.3, 1.0e-6));
+        CHECK (near (channelGain (c.volume), 0.5, 1.0e-4) && near (c.synth.cutoff, 20000.0, 1.0e-3));
+    }
+    // FM in use (B sounding into A in algorithm 1): not translated
+    {
+        xml::Document doc;
+        CHECK (doc.parse (als190ed::operatorDevice (0, { 1.0, 0.3, 0.000316227757, 0.000316227757 })));
+        ChannelDef c;
+        Notes notes;
+        CHECK (! operatorToSynth (doc.root(), c, 120.0, notes));
+    }
+    // algorithm 11: carriers side by side; A's User wave = its harmonic table
+    {
+        xml::Document doc;
+        CHECK (doc.parse (als190ed::operatorDevice (10, { 1.0, 0.5, 0.25, 0.000316227757 }, 22)));
+        ChannelDef c;
+        Notes notes;
+        CHECK (operatorToSynth (doc.root(), c, 120.0, notes));
+        CHECK (c.synth.osc[0].wave == Waveform::spectral && c.synth.spectrum[0] == 1.0f && c.synth.spectrum[2] == 0.5f && c.synth.spectrum[1] == 0.0f);
+        CHECK (c.synth.osc[1].wave == Waveform::sine && near (c.synth.osc[1].level, 0.5, 1.0e-6) && near (c.synth.osc[2].level, 0.25, 1.0e-6));
+        CHECK (als190bq::hasNote (notes.approximated, "the carriers of algorithm 11"));
+    }
+    // Drift: saw (type 4) an octave down, rectangle +7 st (detune 7), noise; the 24 dB filter at 2 kHz, the amp envelope, mono
+    {
+        const auto drift = "<Drift Id=\"8\">" + als190ed::on() + par ("Oscillator1_Type", 4) + par ("Oscillator1_Shape", 0.0) + par ("Oscillator1_Transpose", -1) +
+                           par ("Oscillator2_Type", 4) + par ("Oscillator2_Detune", 7.0) + par ("Oscillator2_Transpose", 0) + par ("Mixer_OscillatorGain1", 0.7) +
+                           als190ed::flag ("Mixer_OscillatorOn1", true) + par ("Mixer_OscillatorGain2", 0.5) + als190ed::flag ("Mixer_OscillatorOn2", true) +
+                           par ("Mixer_NoiseLevel", 0.1) + als190ed::flag ("Mixer_NoiseOn", true) + par ("Filter_Type", 1) + par ("Filter_Frequency", 2000.0) +
+                           par ("Filter_Resonance", 0.3) + par ("Filter_Tracking", 0.5) + par ("Filter_HiPassFrequency", 10.0) + par ("Envelope1_Attack", 0.01) +
+                           par ("Envelope1_Decay", 0.2) + par ("Envelope1_Sustain", 0.6) + par ("Envelope1_Release", 0.4) + par ("Global_VoiceMode", 1) +
+                           par ("Global_Glide", 0.05) + par ("Global_Volume", 0.5) + par ("Global_Transpose", 0) + par ("Global_DriftDepth", 0.07) + "</Drift>";
+        xml::Document doc;
+        CHECK (doc.parse (drift));
+        ChannelDef c;
+        Notes notes;
+        CHECK (driftToSynth (doc.root(), c, 120.0, notes));
+        CHECK (c.synth.osc[0].wave == Waveform::saw && c.synth.osc[0].octave == -1 && near (c.synth.osc[0].level, 0.7, 1.0e-6));
+        CHECK (c.synth.osc[1].wave == Waveform::square && c.synth.osc[1].semitones == 7 && c.synth.osc[2].wave == Waveform::noise && near (c.synth.osc[2].level, 0.1, 1.0e-6));
+        CHECK (c.synth.ladder && near (c.synth.cutoff, 2000.0, 1.0e-3) && near (c.synth.resonance, 0.3, 1.0e-6) && near (c.synth.keyTrack, 0.5, 1.0e-6));
+        CHECK (near (c.synth.attack, 0.01, 1.0e-6) && near (c.synth.sustain, 0.6, 1.0e-6) && c.synth.mono && c.synth.porta && near (c.synth.portaBeats, 0.1, 1.0e-6));
+        CHECK (als190bq::hasNote (notes.dropped, "drift (the random detune") && als190bq::hasNote (notes.dropped, "modulation (envelope 2"));
+    }
+    // through the importer: Operator with FM stays unsupported with its reason; the plain one is a fitted synth channel
+    FlpImportReport report;
+    const auto song = als190ed::import (als190ed::set (als190ed::operatorDevice (0, { 1.0, 0.000316227757, 0.000316227757, 0.000316227757 }), {}), report);
+    CHECK (song.has_value() && report.partialEffects.count ("Operator -> built-in synth (settings fitted to LYNX's engine)") == 1);
+    FlpImportReport fmReport;
+    const auto fm = als190ed::import (als190ed::set (als190ed::operatorDevice (0, { 1.0, 0.5, 0.000316227757, 0.000316227757 }), {}), fmReport);
+    CHECK (fm.has_value() && fmReport.unsupported.count ("Operator (FM synthesis: no LYNX engine for it yet)") == 1);
+}
+
+TEST (als190ed_envelopes_of_racks_and_plugins_follow)
+{
+    using namespace lynx;
+    using als190ed::near;
+    using als190ed::par;
+    using als190ed::target;
+    using als175a::v;
+    // Bus: an Audio Effect Rack with macro 0 (target 700) mapped on a Saturator's drive and automated, the Saturator's
+    // Dry/Wet automated (701: a free macro carries it), a nested rack whose macro 2 is automated (702); a VST2 plugin whose
+    // parameter 3 is automated (703); a VST3 plugin whose parameter is automated (704: listed)
+    const auto saturator = "<Saturator Id=\"0\">" + als190ed::on() + v ("UserName", "") + target ("PreDrive", 6.0, 600, als190cf::mapped (0, 0.0, 12.0)) +
+                           par ("Type", 0) + par ("PostDrive", 0.0) + target ("DryWet", 0.5, 701) + "</Saturator>";
+    const auto innerMacros = [] {
+        auto m = als190cf::macros ({}, { 0, 0, 64 });
+        const auto at = m.find ("<MacroControls.2>");
+        m.replace (at, std::string ("<MacroControls.2>").size(), "<MacroControls.2><AutomationTarget Id=\"702\" />");
+        return m;
+    }();
+    const auto inner = "<AudioEffectGroupDevice Id=\"9\">" + als190ed::on() + v ("UserName", "Inner") + "<Branches><AudioEffectBranch Id=\"0\"><Name>" +
+                       v ("EffectiveName", "Empty") + v ("UserName", "") + "</Name>" + v ("IsSoloed", "false") +
+                       "<DeviceChain><AudioToAudioDeviceChain><Devices></Devices></AudioToAudioDeviceChain></DeviceChain>" +
+                       als190cf::range ("BranchSelectorRange", 0, 127, 0, 127) + als190cf::branchMixer (1.0, 0.0) + "</AudioEffectBranch></Branches>" + innerMacros +
+                       "</AudioEffectGroupDevice>";
+    auto outerMacros = als190cf::macros ({ "Drive" }, { 64 });
+    outerMacros.replace (outerMacros.find ("<MacroControls.0>"), std::string ("<MacroControls.0>").size(), "<MacroControls.0><AutomationTarget Id=\"700\" />");
+    const auto rack = "<AudioEffectGroupDevice Id=\"5\">" + als190ed::on() + v ("UserName", "Dirt") + "<Branches><AudioEffectBranch Id=\"0\"><Name>" +
+                      v ("EffectiveName", "Chain") + v ("UserName", "") + "</Name>" + v ("IsSoloed", "false") + "<DeviceChain><AudioToAudioDeviceChain><Devices>" +
+                      saturator + inner + "</Devices></AudioToAudioDeviceChain></DeviceChain>" + als190cf::range ("BranchSelectorRange", 0, 127, 0, 127) +
+                      als190cf::branchMixer (1.0, 0.0) + "</AudioEffectBranch></Branches>" + outerMacros + "</AudioEffectGroupDevice>";
+    const auto params = [] (int pid, int target, double value) {
+        return "<ParameterList><PluginFloatParameter Id=\"0\">" + v ("ParameterName", "Gain") + v ("ParameterId", std::to_string (pid)) + v ("VisualIndex", "0") +
+               "<ParameterValue><Manual Value=\"" + als190ed::num (value) + "\" /><AutomationTarget Id=\"" + std::to_string (target) +
+               "\" /></ParameterValue></PluginFloatParameter></ParameterList>";
+    };
+    auto vst2 = als175a::vst2Device ("00");
+    vst2.insert (vst2.rfind ("</PluginDevice>"), params (3, 703, 0.25));
+    auto vst3 = als175a::vst3Device ("00");
+    vst3.insert (vst3.rfind ("</PluginDevice>"), params (12345678, 704, 0.5));
+    // Keys: an Instrument Rack (one chain: a VST2 instrument plugin) whose macro 1 is automated (710)
+    auto keyMacros = als190cf::macros ({}, { 0, 32 });
+    keyMacros.replace (keyMacros.find ("<MacroControls.1>"), std::string ("<MacroControls.1>").size(), "<MacroControls.1><AutomationTarget Id=\"710\" />");
+    auto instrument = als175a::vst2Device ("00");
+    instrument.replace (instrument.find ("<VstPluginInfo Id=\"0\">"), std::string ("<VstPluginInfo Id=\"0\">").size(), "<VstPluginInfo Id=\"0\">" + v ("NumAudioInputs", "0"));
+    const auto keysRack = "<InstrumentGroupDevice Id=\"6\">" + als190ed::on() + "<Branches><InstrumentBranch Id=\"0\"><Name>" + v ("EffectiveName", "Synth") +
+                          "</Name><DeviceChain><MidiToAudioDeviceChain><Devices>" + instrument + "</Devices></MidiToAudioDeviceChain></DeviceChain>" +
+                          als190cf::range ("BranchSelectorRange", 0, 127, 0, 127) + "<ZoneSettings>" + als190cf::range ("KeyRange", 0, 127, 0, 127) +
+                          als190cf::range ("VelocityRange", 1, 127, 1, 127) + "</ZoneSettings>" + als190cf::branchMixer (1.0, 0.0) + "</InstrumentBranch></Branches>" +
+                          keyMacros + "</InstrumentGroupDevice>";
+    const auto busEnvelopes = als190cf::envelope (0, 700, 0.0, 127.0) + als190cf::envelope (1, 701, 0.2, 0.8) + als190cf::envelope (2, 702, 127.0, 0.0) +
+                              als190cf::envelope (3, 703, 0.1, 0.9) + als190cf::envelope (4, 704, 0.0, 1.0);
+    const auto keysEnvelopes = als190cf::envelope (5, 710, 0.0, 63.5);
+    FlpImportReport report;
+    const auto song = als190ed::import (als190ed::set (keysRack, rack + vst2 + vst3, keysEnvelopes, busEnvelopes), report);
+    CHECK (song.has_value());
+    if (! song)
+        return;
+    int bus = -1;
+    for (int i = 0; i < (int) song->mixer.size(); ++i)
+        bus = song->mixer[(std::size_t) i].name == "Bus" ? i : bus;
+    CHECK (bus > 0 && song->mixer[(std::size_t) bus].effects.size() == 3);
+    if (bus <= 0 || song->mixer[(std::size_t) bus].effects.size() != 3)
+        return;
+    const auto& slot = song->mixer[(std::size_t) bus].effects[0];
+    const auto* r = rack::rackOf (slot.patcher);
+    CHECK (r != nullptr);
+    if (r == nullptr)
+        return;
+    // macro 0: its own envelope, 0 … 127 → 0 … 1
+    const auto* m0 = als190ed::automationOn (*song, { AutomationTargetKind::effectParam, bus, 0, 0 });
+    CHECK (m0 != nullptr && m0->points.size() == 2 && m0 != nullptr && near (m0->points[0].value, 0.0) && near (m0->points[1].value, 1.0));
+    // the Saturator's Dry/Wet: the first free macro (1), over Ember's mix, at its value now (0.5), excluded from Rand
+    int bound = -1;
+    for (int k = 0; k < rackMacroCount; ++k)
+        if (r->macros[(std::size_t) k].name == "Saturator Dry Wet")
+            bound = k;
+    CHECK (bound == 1 && r->macros[1].mappings.size() == 1 && r->macros[1].mappings[0].param == mixsuite::ember::mix && near (r->macros[1].value, 0.5f * 127.0f, 1.0e-3) &&
+           r->macros[1].excludeFromRandom && r->macros[1].excludeFromVariations);
+    const auto* mix = als190ed::automationOn (*song, { AutomationTargetKind::effectParam, bus, 0, 1 });
+    CHECK (mix != nullptr && mix->points.size() == 2);
+    if (mix != nullptr && mix->points.size() == 2)
+        CHECK (near (mix->points[0].value, 0.2, 1.0e-6) && near (mix->points[1].value, 0.8, 1.0e-6));
+    // the nested rack's macro 2: an outer free macro (2) mapped over the inner macro's whole range
+    CHECK (r->macros[2].mappings.size() == 1 && r->macros[2].mappings[0].param == 2 && near (r->macros[2].value, 64.0f, 1.0e-3));
+    const auto* nested = als190ed::automationOn (*song, { AutomationTargetKind::effectParam, bus, 0, 2 });
+    CHECK (nested != nullptr && nested->points.size() == 2 && nested != nullptr && near (nested->points[0].value, 1.0) && near (nested->points[1].value, 0.0));
+    CHECK (r->shownMacros >= 4);
+    // the bound macro really moves the Saturator's mix in the rack
+    {
+        auto doc = slot.patcher;
+        rack::setMacro (doc, 1, 127.0f);
+        int ember = -1;
+        for (int n = 0; n < (int) doc.nodes.size(); ++n)
+            if (! doc.nodes[(std::size_t) n].generator && doc.nodes[(std::size_t) n].effect.kind == EffectKind::ember)
+                ember = n;
+        CHECK (ember >= 0 && near (doc.nodes[(std::size_t) ember].effect.params[mixsuite::ember::mix], 1.0, 1.0e-6));
+    }
+    // the VST2 plugin's parameter 3; the VST3 one listed once, without the generic line
+    const auto* gain = als190ed::automationOn (*song, { AutomationTargetKind::effectParam, bus, 1, 3 });
+    CHECK (gain != nullptr && gain->points.size() == 2 && gain != nullptr && near (gain->points[0].value, 0.1) && near (gain->points[1].value, 0.9));
+    CHECK (report.unsupported.count ("Automation of a VST3 plugin's parameter (kHs Gain: Live keeps the plugin's own id, not its index)") == 1);
+    CHECK (report.unsupported.count ("Automation of a device parameter (Bus)") == 0);
+    // the Instrument Rack's macro 1 on the Keys channel: 0 … 63.5 → 0 … 0.5
+    int keys = -1;
+    for (int c = 0; c < (int) song->channels.size(); ++c)
+        keys = song->channels[(std::size_t) c].name == "Keys" ? c : keys;
+    CHECK (keys >= 0 && song->channels[(std::size_t) std::max (keys, 0)].instrument == InstrumentKind::patcher);
+    const auto* macro1 = als190ed::automationOn (*song, { AutomationTargetKind::channelParam, keys, 0, 1 });
+    CHECK (macro1 != nullptr && macro1->points.size() == 2 && macro1 != nullptr && near (macro1->points[1].value, 0.5));
+    CHECK (report.unsupported.count ("Automation of a device parameter (Keys)") == 0);
+}

+ 1 - 0
tests/tests.cpp

@@ -17401,6 +17401,7 @@ TEST (fl_low_lifter_matches_fl_engine)
 #include "Als181cTests.inc"
 #include "AlsDevices190bqTests.inc"
 #include "AlsDevices190cfTests.inc"
+#include "AlsDevices190edTests.inc"
 #include "Merge180cTests.inc"
 #include "Slicer180cTests.inc"
 #include "Slicer190fTests.inc"

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