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

VFX: Keyboard Splitter and Envelope, Patcher zone pins, pt-BR strings

Ka1-S 1 месяц назад
Родитель
Сommit
4e9b341d86
7 измененных файлов с 2086 добавлено и 2 удалено
  1. 69 0
      resources/i18n/pt-BR.txt
  2. 832 0
      src/core/Vfx.cpp
  3. 77 0
      src/core/Vfx.h
  4. 264 1
      src/ui/I18nData.h
  5. 8 1
      src/ui/PatcherEditor.cpp
  6. 670 0
      src/ui/VfxEditors.cpp
  7. 166 0
      tests/Vfx164Tests.inc

+ 69 - 0
resources/i18n/pt-BR.txt

@@ -4845,3 +4845,72 @@ countries: br
 "Sample browser (separate window)" = "Browser de samples (janela separada)"
 "Sample browser" = "Browser de samples"
 "Open in the file manager" = "Abrir no gerenciador de arquivos"
+
+# Round 164b: FL's VFX note effects
+"Enable" = "Ativar"
+"All (gain-compensated)" = "Todas (ganho compensado)"
+"Cycle up" = "Ciclo para cima"
+"Cycle down" = "Ciclo para baixo"
+"Multimode: how an input mapped to several notes plays them" = "Multimodo: como uma entrada mapeada para várias notas as toca"
+"Multimode" = "Multimodo"
+"Base key" = "Tom base"
+"Pitch slide" = "Deslize de altura"
+"{0} plays {1} - left-click: add / remove, right-click: only this note, middle-click or Alt+click: reset the row" = "{0} toca {1} - clique esquerdo: adiciona / remove, clique direito: só esta nota, clique do meio ou Alt+clique: restaura a linha"
+"Offset (transpose)" = "Deslocamento (transpor)"
+"Base key: the note the rows and their octaves start on" = "Tom base: a nota em que as linhas e suas oitavas começam"
+"Pitch slide: the new notes start at the played pitch and glide to their own (in steps)" = "Deslize de altura: as notas novas começam na altura tocada e deslizam até a sua (em passos)"
+"Voice {0}" = "Voz {0}"
+"The voice output the notes of colour {0} go to" = "A saída de voz para onde vão as notas da cor {0}"
+"The colour the notes of colour {0} leave with" = "A cor com que saem as notas da cor {0}"
+"Voice output" = "Saída de voz"
+"Multiply" = "Multiplicar"
+"Subtract" = "Subtrair"
+"Humanize mode: the random part goes below the value, around it or above it" = "Modo de humanização: a parte aleatória fica abaixo do valor, em volta dele ou acima"
+"Reset all controls of this property" = "Restaura todos os controles desta propriedade"
+"in" = "entrada"
+"out" = "saída"
+"Center: the input level the curve turns around" = "Centro: o nível de entrada em torno do qual a curva gira"
+"Multiply: the slope around the center (negative inverts)" = "Multiplicar: a inclinação em torno do centro (negativo inverte)"
+"Offset: moves every value up or down" = "Deslocamento: move todos os valores para cima ou para baixo"
+"Tension: bends the curve (positive rises fast, negative starts slow)" = "Tensão: curva a linha (positivo sobe rápido, negativo começa devagar)"
+"Humanize: a random amount for each note" = "Humanizar: uma quantidade aleatória para cada nota"
+"sustain" = "sustentação"
+"Keyboard" = "Teclado"
+"Zone {0}" = "Zona {0}"
+"The zone's name (its output's name in the Patcher)" = "O nome da zona (o nome da saída dela no Patcher)"
+"Whole keyboard" = "Teclado inteiro"
+"The whole range at full level" = "A faixa inteira no nível máximo"
+"Back to the map's default (the zone is off when both maps are)" = "Volta ao padrão do mapa (a zona fica desligada quando os dois mapas estão assim)"
+"Random (the map is a probability)" = "Aleatório (o mapa é uma probabilidade)"
+"Absolute (the map sets the volume)" = "Absoluto (o mapa define o volume)"
+"Random: each note goes to one of the random zones, picked by their keyboard maps" = "Aleatório: cada nota vai para uma das zonas aleatórias, sorteada pelos mapas de teclado delas"
+"Absolute: the velocity map gives the volume instead of scaling the note's" = "Absoluto: o mapa de velocidade dá o volume em vez de escalar o da nota"
+"Transpose (semitones)" = "Transpor (semitons)"
+"Articulator {0}" = "Articulador {0}"
+"The note colour this articulator works on (the MIDI channel)" = "A cor de nota em que este articulador atua (o canal MIDI)"
+"Off: the notes pass unchanged" = "Desligado: as notas passam sem mudança"
+"Tempo: the time in beats (else in seconds)" = "Tempo: o tempo em batidas (senão em segundos)"
+"Pulse width" = "Largura de pulso"
+"seconds" = "segundos"
+"Time in {0}. Drag a point, double-click to add one, right-click to remove it, drag a segment to bend it." = "Tempo em {0}. Arraste um ponto, clique duas vezes para adicionar um, clique direito para removê-lo, arraste um segmento para curvá-lo."
+"Low key: the lowest note this articulator works on" = "Tecla baixa: a nota mais grave em que este articulador atua"
+"High key: the highest note this articulator works on" = "Tecla alta: a nota mais aguda em que este articulador atua"
+"Base level" = "Nível base"
+"Envelope level" = "Nível do envelope"
+"LFO level" = "Nível do LFO"
+"Attack: scales the time up to the decay point" = "Ataque: escala o tempo até o ponto de decaimento"
+"Decay: scales the time up to the sustain point" = "Decaimento: escala o tempo até o ponto de sustentação"
+"Sustain: raises or lowers the sustain level" = "Sustentação: sobe ou desce o nível de sustentação"
+"Release: scales the time after the sustain point" = "Liberação: escala o tempo depois do ponto de sustentação"
+"LYNX keeps this plugin's settings (from FL Studio) and passes its notes through unchanged." = "O LYNX guarda as configurações deste plugin (do FL Studio) e deixa as notas passarem sem mudança."
+"Maps each played note to other notes: transpose, scales, chords" = "Mapeia cada nota tocada para outras notas: transpor, escalas, acordes"
+"Sends each note colour to its own voice output" = "Manda cada cor de nota para a sua própria saída de voz"
+"Envelopes and LFOs on the notes' velocity, pitch, pan and Mod X / Y" = "Envelopes e LFOs na velocidade, altura, pan e Mod X / Y das notas"
+"Splits the keyboard and the velocity into zones, one output each" = "Divide o teclado e a velocidade em zonas, uma saída para cada"
+"Reshapes the notes' velocity, release, fine pitch, pan and Mod X / Y" = "Remodela a velocidade, liberação, afinação fina, pan e Mod X / Y das notas"
+"Plays step patterns and arpeggios from the held notes" = "Toca padrões de passos e arpejos com as notas seguradas"
+"FL's Python note scripts" = "Scripts de notas em Python do FL"
+"Presets: LYNX's own and, with FL Studio installed, FL's factory presets" = "Presets: os do LYNX e, com o FL Studio instalado, os de fábrica do FL"
+"Output port: output 1 goes out on this MIDI port, output 2 on the next one…; the plugins and Patchers that take that port play it" = "Porta de saída: a saída 1 sai nesta porta MIDI, a saída 2 na seguinte…; os plugins e Patchers que recebem essa porta tocam o que chega"
+"Sets a plugin channel's MIDI input port to this port, so it plays what this channel sends" = "Define a porta de entrada MIDI de um canal de plugin para esta porta, para ele tocar o que este canal manda"
+"VFX (note effects)" = "VFX (efeitos de nota)"

+ 832 - 0
src/core/Vfx.cpp

@@ -6,6 +6,7 @@
 #include <cstring>
 #include <functional>
 
+#include "core/FlSynths.h"
 #include "core/Song.h"
 #include "flp/Flp.h"
 
@@ -54,6 +55,7 @@ class Handoff
 {
 public:
     explicit Handoff (T initial) : active (std::make_unique<T> (std::move (initial))) {}
+    explicit Handoff (std::unique_ptr<T> initial) : active (std::move (initial)) {}
     ~Handoff()
     {
         delete pending.exchange (nullptr);
@@ -64,6 +66,11 @@ public:
         delete retired.exchange (nullptr);
         delete pending.exchange (new T (std::move (value)));
     }
+    void publish (std::unique_ptr<T> value)
+    {
+        delete retired.exchange (nullptr);
+        delete pending.exchange (value.release());
+    }
     // audio thread: true when new settings arrived
     bool take() noexcept
     {
@@ -340,6 +347,402 @@ double levelScale (const LevelScalerSettings& s, int tab, double x, double lo, d
     return out;
 }
 
+// ---------------------------------------------------------------------------------------------------------------
+// FL's mapping curves and VFX Keyboard Splitter (REA_rodada164b §Keyboard Splitter)
+
+MapCurve MapCurve::flat (double level)
+{
+    MapCurve m;
+    m.points.push_back ({ 0.0, level });
+    m.points.push_back ({ 1.0, level });
+    return m;
+}
+
+double MapCurve::at (double x) const noexcept
+{
+    if (points.empty())
+        return 0.0;
+    if (x <= points.front().x)
+        return points.front().y;
+    for (std::size_t i = 1; i < points.size(); ++i)
+        if (x < points[i].x)
+        {
+            const auto& a = points[i - 1];
+            const auto& b = points[i];
+            if (b.curve == 2) // hold: the previous level up to this point
+                return a.y;
+            auto f = b.x > a.x ? (x - a.x) / (b.x - a.x) : 1.0;
+            if (b.tension != 0.0f) // (the automation clips' bend, FL's sign)
+                f = std::pow (f, std::pow (2.0, (double) -b.tension * 3.0));
+            return a.y + (b.y - a.y) * f;
+        }
+    return points.back().y;
+}
+
+bool MapCurve::isFlat (double level) const noexcept
+{
+    return std::all_of (points.begin(), points.end(), [level] (const Point& p) { return std::abs (p.y - level) < 1e-9; });
+}
+
+namespace
+{
+bool readMap (Reader& r, MapCurve& m)
+{
+    r.i32(); // kind (3)
+    const auto version = r.i32();
+    const auto n = r.i32();
+    if (r.failed || n < 0 || n > 4096 || version < 2 || version > 3)
+        return false;
+    m.points.clear();
+    double x = 0.0;
+    for (int k = 0; k < n; ++k)
+    {
+        MapCurve::Point p;
+        const auto dx = r.get<double>();
+        x += std::isfinite (dx) ? dx : 0.0;
+        p.x = x;
+        p.y = r.get<double>();
+        if (! std::isfinite (p.y))
+            p.y = 0.0;
+        p.tension = r.get<float>();
+        if (! std::isfinite (p.tension))
+            p.tension = 0.0f;
+        p.curve = r.get<std::uint8_t>();
+        p.b13 = r.get<std::uint8_t>();
+        p.b14 = r.get<std::uint8_t>();
+        p.b15 = r.get<std::uint8_t>();
+        m.points.push_back (p);
+    }
+    for (auto& f : m.footer)
+        f = r.i32();
+    return ! r.failed;
+}
+
+void writeMap (std::vector<std::uint8_t>& out, const MapCurve& m, int kind = 3)
+{
+    put<std::int32_t> (out, kind);
+    put<std::int32_t> (out, 3);
+    put<std::int32_t> (out, (std::int32_t) m.points.size());
+    double x = 0.0;
+    for (const auto& p : m.points)
+    {
+        put<double> (out, p.x - x);
+        x = p.x;
+        put<double> (out, p.y);
+        put<float> (out, p.tension);
+        put<std::uint8_t> (out, p.curve);
+        put<std::uint8_t> (out, p.b13);
+        put<std::uint8_t> (out, p.b14);
+        put<std::uint8_t> (out, p.b15); // (FL's shape flag: 2 straight, 1 / 0xff bent up / down)
+    }
+    for (const auto f : m.footer)
+        put<std::int32_t> (out, f);
+}
+} // namespace
+
+KeyboardSplitterSettings defaultKeyboardSplitter()
+{
+    KeyboardSplitterSettings s;
+    s.zones[0].keyboard = MapCurve::flat (1.0); // zone 1: the whole keyboard
+    return s;
+}
+
+std::optional<KeyboardSplitterSettings> parseKeyboardSplitter (const std::vector<std::uint8_t>& fl)
+{
+    Reader r { fl.data(), fl.size() };
+    KeyboardSplitterSettings s;
+    s.header = r.u32();
+    if (r.failed || s.header >= 0x100004 || (s.header & 0xfffff) == 0)
+        return std::nullopt;
+    if ((s.header >> 20) != 0)
+        s.page = std::clamp ((int) r.get<std::uint8_t>(), 0, 1);
+    for (auto& z : s.zones)
+    {
+        if (! readMap (r, z.keyboard) || ! readMap (r, z.velocity))
+            return std::nullopt;
+        z.transpose = std::clamp (r.i32(), -48, 48);
+        z.absolute = r.get<std::uint8_t>() != 0;
+        z.random = r.get<std::uint8_t>() != 0;
+        // name: u8 length (255: a u32 follows), UTF-16 characters
+        std::uint32_t length = r.get<std::uint8_t>();
+        if (length == 255)
+            length = r.u32();
+        if (r.failed || length > 4096 || length * 2 > r.left())
+            return std::nullopt;
+        std::u16string name;
+        for (std::uint32_t k = 0; k < length; ++k)
+            name.push_back ((char16_t) r.get<std::uint16_t>());
+        z.name.clear();
+        for (std::size_t k = 0; k < name.size(); ++k)
+        {
+            std::uint32_t c = name[k];
+            if (c >= 0xd800 && c < 0xdc00 && k + 1 < name.size())
+                c = 0x10000 + ((c - 0xd800) << 10) + ((std::uint32_t) name[++k] - 0xdc00);
+            if (c < 0x80)
+                z.name.push_back ((char) c);
+            else if (c < 0x800)
+                z.name += { (char) (0xc0 | (c >> 6)), (char) (0x80 | (c & 0x3f)) };
+            else if (c < 0x10000)
+                z.name += { (char) (0xe0 | (c >> 12)), (char) (0x80 | ((c >> 6) & 0x3f)), (char) (0x80 | (c & 0x3f)) };
+            else
+                z.name += { (char) (0xf0 | (c >> 18)), (char) (0x80 | ((c >> 12) & 0x3f)), (char) (0x80 | ((c >> 6) & 0x3f)), (char) (0x80 | (c & 0x3f)) };
+        }
+    }
+    if (r.failed)
+        return std::nullopt;
+    return s;
+}
+
+std::vector<std::uint8_t> writeKeyboardSplitter (const KeyboardSplitterSettings& s)
+{
+    std::vector<std::uint8_t> out;
+    put<std::uint32_t> (out, 0x100003);
+    put<std::uint8_t> (out, (std::uint8_t) std::clamp (s.page, 0, 1));
+    for (const auto& z : s.zones)
+    {
+        writeMap (out, z.keyboard);
+        writeMap (out, z.velocity);
+        put<std::int32_t> (out, z.transpose);
+        put<std::uint8_t> (out, z.absolute ? 1 : 0);
+        put<std::uint8_t> (out, z.random ? 1 : 0);
+        std::u16string name;
+        for (std::size_t k = 0; k < z.name.size();)
+        {
+            const auto b = (std::uint8_t) z.name[k];
+            std::uint32_t c = b;
+            int more = b >= 0xf0 ? 3 : b >= 0xe0 ? 2 : b >= 0xc0 ? 1 : 0;
+            c = more == 3 ? b & 0x07 : more == 2 ? b & 0x0f : more == 1 ? b & 0x1f : b;
+            ++k;
+            for (; more > 0 && k < z.name.size(); --more, ++k)
+                c = (c << 6) | ((std::uint8_t) z.name[k] & 0x3f);
+            if (c >= 0x10000)
+            {
+                c -= 0x10000;
+                name.push_back ((char16_t) (0xd800 + (c >> 10)));
+                name.push_back ((char16_t) (0xdc00 + (c & 0x3ff)));
+            }
+            else
+                name.push_back ((char16_t) c);
+        }
+        if (name.size() < 255)
+            put<std::uint8_t> (out, (std::uint8_t) name.size());
+        else
+        {
+            put<std::uint8_t> (out, 255);
+            put<std::uint32_t> (out, (std::uint32_t) name.size());
+        }
+        for (const auto c : name)
+            put<std::uint16_t> (out, (std::uint16_t) c);
+    }
+    return out;
+}
+
+double splitterGain (double m) noexcept
+{
+    return m >= 1.0 ? 1.0 : (std::pow (11.0, m) - 1.0) / 10.0;
+}
+
+// ---------------------------------------------------------------------------------------------------------------
+// VFX Envelope (REA_rodada164b §Envelope)
+
+namespace
+{
+MapCurve curveOf (std::initializer_list<std::tuple<double, double, float>> points, std::array<std::int32_t, 5> footer)
+{
+    MapCurve m;
+    for (const auto& [x, y, t] : points)
+        m.points.push_back ({ x, y, t });
+    m.footer = footer;
+    return m;
+}
+} // namespace
+
+EnvelopeSettings defaultEnvelope()
+{
+    EnvelopeSettings s;
+    for (int g = 0; g < 16; ++g)
+    {
+        auto& a = s.articulators[(std::size_t) g];
+        for (int t = 0; t < EnvelopeSettings::targetCount; ++t)
+        {
+            auto& p = a.parts[(std::size_t) t];
+            p.lfoAmp = curveOf ({ { 0.0, 0.5, 0.0f }, { 1.0, 0.5, 0.0f }, { 1.25, 1.0, 0.0f }, { 2.25, 0.5, 0.0f } }, { 0, 0, -1, -1, -1 });
+            if (t == EnvelopeSettings::velocity)
+            {
+                p.base = 0.0f;
+                // a volume envelope: attack, a peak, sustain at half (= the note's own level), release
+                p.envelope = curveOf ({ { 0.0, 0.0, 0.0f }, { 0.75, 1.0, 0.2f }, { 2.25, 0.5, 0.2f }, { 2.5, 0.0, 0.2f } },
+                                      { 0, g == 0 ? -1 : 0, 1, -1, 2 });
+            }
+            else
+            {
+                p.base = 0.5f;
+                p.env = t == EnvelopeSettings::pitch ? 0.25f : 1.0f;
+                p.envelope = curveOf ({ { 0.0, 0.5, 0.0f }, { 0.25, 0.5, 0.0f } }, { 1, -1, -1, -1, -1 }); // (on, neutral)
+            }
+        }
+    }
+    return s;
+}
+
+namespace
+{
+bool readPart (Reader& r, EnvelopeSettings::Part& p)
+{
+    p.version = r.i32();
+    p.base = r.get<float>();
+    p.env = r.get<float>();
+    p.lfo = r.get<float>();
+    if (! readMap (r, p.envelope))
+        return false;
+    for (auto& k : p.adsr)
+        k = r.i32();
+    if (! readMap (r, p.lfoAmp))
+        return false;
+    p.speed = r.i32();
+    p.tension = r.i32();
+    p.skew = r.i32();
+    p.pulseWidth = r.i32();
+    p.phase = p.version >= 3 ? r.i32() : 0;
+    for (auto* f : { &p.base, &p.env, &p.lfo })
+        if (! std::isfinite (*f))
+            *f = 0.0f;
+    return ! r.failed;
+}
+
+void writePart (std::vector<std::uint8_t>& out, const EnvelopeSettings::Part& p)
+{
+    put<std::int32_t> (out, 3);
+    put<float> (out, p.base);
+    put<float> (out, p.env);
+    put<float> (out, p.lfo);
+    writeMap (out, p.envelope, 1);
+    for (const auto k : p.adsr)
+        put<std::int32_t> (out, k);
+    writeMap (out, p.lfoAmp, 2);
+    for (const auto v : { p.speed, p.tension, p.skew, p.pulseWidth, p.phase })
+        put<std::int32_t> (out, v);
+}
+
+void writeChunk (std::vector<std::uint8_t>& out, std::int32_t id, const std::vector<std::uint8_t>& data)
+{
+    put<std::int32_t> (out, id);
+    put<std::int64_t> (out, (std::int64_t) data.size());
+    out.insert (out.end(), data.begin(), data.end());
+}
+} // namespace
+
+std::optional<EnvelopeSettings> parseEnvelope (const std::vector<std::uint8_t>& fl)
+{
+    Reader r { fl.data(), fl.size() };
+    auto s = defaultEnvelope();
+    s.header = r.u32();
+    if (r.failed || s.header >= 0x10004)
+        return std::nullopt;
+    std::vector<std::int32_t> params;
+    int group = 0, target = 0;
+    while (r.left() >= 12)
+    {
+        const auto id = r.i32();
+        const auto size = r.get<std::int64_t>();
+        if (size < 0 || (std::uint64_t) size > r.left())
+            return std::nullopt;
+        const auto end = r.pos + (std::size_t) size;
+        Reader c { fl.data(), end, r.pos };
+        switch (id)
+        {
+            case 1003:
+                s.enabled = c.i32() != 0;
+                s.shownArticulator = std::clamp (c.i32(), 0, 15);
+                s.shownTarget = std::clamp (c.i32(), 0, 4);
+                s.shownPart = std::clamp (c.i32(), 0, 1);
+                break;
+            case 1008:
+                params.clear();
+                while (c.left() >= 4)
+                    params.push_back (c.i32());
+                break;
+            case 1007:
+                for (auto& t : s.toggles)
+                    t = c.left() >= 4 ? c.i32() : 0;
+                break;
+            case 1004:
+            {
+                group = std::clamp (c.i32(), 0, 15);
+                auto& a = s.articulators[(std::size_t) group];
+                a.colour = std::clamp (c.i32(), 0, 15);
+                a.low = std::clamp (c.i32(), 0, 132);
+                a.high = std::clamp (c.i32(), 0, 132);
+                break;
+            }
+            case 1005:
+                group = std::clamp (c.i32(), 0, 15);
+                target = std::clamp (c.i32(), 0, 4);
+                break;
+            case 1006:
+                if (! readPart (c, s.articulators[(std::size_t) group].parts[(std::size_t) target]))
+                    return std::nullopt;
+                break;
+            default: break;
+        }
+        r.pos = end;
+    }
+    if (r.failed)
+        return std::nullopt;
+    // the parameter values set the base / envelope / LFO levels (FL pushes them after loading)
+    if (params.size() >= 880)
+        for (int g = 0; g < 16; ++g)
+            for (int t = 0; t < 5; ++t)
+            {
+                auto& p = s.articulators[(std::size_t) g].parts[(std::size_t) t];
+                const auto at = (std::size_t) ((g * 5 + t) * 11);
+                p.base = std::clamp (params[at + 8], 0, 256) / 256.0f;
+                p.env = std::clamp (params[at + 9], -256, 256) / 256.0f;
+                p.lfo = std::clamp (params[at + 10], -256, 256) / 256.0f;
+            }
+    return s;
+}
+
+std::vector<std::uint8_t> writeEnvelope (const EnvelopeSettings& s)
+{
+    std::vector<std::uint8_t> out, chunk;
+    put<std::uint32_t> (out, 0x10003);
+    for (const auto v : { s.enabled ? 1 : 0, s.shownArticulator, s.shownTarget, s.shownPart })
+        put<std::int32_t> (chunk, v);
+    writeChunk (out, 1003, chunk);
+    chunk.clear();
+    for (const auto& a : s.articulators)
+        for (const auto& p : a.parts)
+            for (const auto v : { p.adsr[0], p.adsr[1], p.adsr[2], p.adsr[3], p.speed, p.tension, p.skew, p.pulseWidth,
+                                  (std::int32_t) std::lround (p.base * 256.0f), (std::int32_t) std::lround (p.env * 256.0f),
+                                  (std::int32_t) std::lround (p.lfo * 256.0f) })
+                put<std::int32_t> (chunk, v);
+    writeChunk (out, 1008, chunk);
+    chunk.clear();
+    for (const auto t : s.toggles)
+        put<std::int32_t> (chunk, t);
+    writeChunk (out, 1007, chunk);
+    for (int g = 0; g < 16; ++g)
+    {
+        const auto& a = s.articulators[(std::size_t) g];
+        chunk.clear();
+        for (const auto v : { g, a.colour, a.low, a.high })
+            put<std::int32_t> (chunk, v);
+        writeChunk (out, 1004, chunk);
+        for (int t = 0; t < 5; ++t)
+        {
+            chunk.clear();
+            for (const auto v : { g, t, 0 })
+                put<std::int32_t> (chunk, v);
+            writeChunk (out, 1005, chunk);
+            chunk.clear();
+            writePart (chunk, a.parts[(std::size_t) t]);
+            writeChunk (out, 1006, chunk);
+        }
+    }
+    return out;
+}
+
 // ---------------------------------------------------------------------------------------------------------------
 // Presets
 
@@ -463,6 +866,8 @@ std::vector<std::uint8_t> defaultState (Kind kind)
         case Kind::keyMapper: return writeKeyMapper (defaultKeyMapper());
         case Kind::colorMapper: return writeColorMapper (defaultColorMapper());
         case Kind::levelScaler: return writeLevelScaler (defaultLevelScaler());
+        case Kind::keyboardSplitter: return writeKeyboardSplitter (defaultKeyboardSplitter());
+        case Kind::envelope: return writeEnvelope (defaultEnvelope());
         default: break;
     }
     return {};
@@ -890,6 +1295,429 @@ private:
 };
 } // namespace
 
+namespace
+{
+// Each note on every zone whose keyboard × velocity level is above zero, on that zone's output (FL: the level
+// scales the note's volume, or replaces it with Absolute; Random zones play one of them, picked by their keyboard
+// level). LYNX works in velocities: vol = (11^(1.28 v) − 1) / 10 both ways.
+class KeyboardSplitter final : public Base<KeyboardSplitterSettings>
+{
+public:
+    explicit KeyboardSplitter (KeyboardSplitterSettings s) : Base (std::move (s)) {}
+    Kind kind() const noexcept override { return Kind::keyboardSplitter; }
+    bool configure (const std::vector<std::uint8_t>& fl) override
+    {
+        auto s = parseKeyboardSplitter (fl);
+        if (! s)
+            return false;
+        publish (std::move (*s));
+        return true;
+    }
+    void process (const Event* in, int count, int, const Transport&, EventList& out) noexcept override
+    {
+        const auto& s = current();
+        for (int i = 0; i < count; ++i)
+        {
+            const auto& e = in[i];
+            if (e.type == Event::Type::off)
+            {
+                voices.release (e.id, e.offset, e.voice.release, out);
+                continue;
+            }
+            if (e.type != Event::Type::on)
+                continue;
+            const auto x = ((double) e.voice.key + e.voice.cents / 100.0) / 132.0;
+            const auto velocity = std::min (1.0, (double) e.voice.velocity);
+            std::array<double, 16> w {};
+            bool anyRandom = false;
+            for (int z = 0; z < 16; ++z)
+            {
+                const auto& zone = s.zones[(std::size_t) z];
+                if (! zone.active())
+                    continue;
+                w[(std::size_t) z] = splitterGain (zone.keyboard.at (x));
+                anyRandom = anyRandom || zone.random;
+            }
+            if (anyRandom) // one weighted pick among the random zones, which then plays at full level
+            {
+                double total = 0.0;
+                for (int z = 0; z < 16; ++z)
+                    if (s.zones[(std::size_t) z].random && s.zones[(std::size_t) z].active())
+                        total += w[(std::size_t) z];
+                const auto r = random() * total;
+                int chosen = -1;
+                double acc = 0.0;
+                for (int z = 0; z < 16; ++z)
+                    if (s.zones[(std::size_t) z].random && s.zones[(std::size_t) z].active() && w[(std::size_t) z] > 0.0)
+                    {
+                        if (acc <= r)
+                            chosen = z;
+                        acc += w[(std::size_t) z];
+                        w[(std::size_t) z] = 0.0;
+                    }
+                if (chosen >= 0) // (FL then falls back on zone 1; LYNX plays no random zone)
+                    w[(std::size_t) chosen] = 1.0;
+            }
+            const auto volumeIn = velocityToVolume (velocity);
+            for (int z = 0; z < 16; ++z)
+            {
+                const auto& zone = s.zones[(std::size_t) z];
+                if (w[(std::size_t) z] <= 0.0)
+                    continue;
+                const auto level = w[(std::size_t) z] * splitterGain (zone.velocity.at (velocity));
+                if (level <= 1e-5)
+                    continue;
+                auto v = e.voice;
+                v.velocity = (float) volumeToVelocity (zone.absolute ? level : volumeIn * level);
+                v.key = e.voice.key + zone.transpose;
+                if (v.key < 0 || v.key > 127)
+                    continue;
+                if (const auto id = voices.add (e.id, z, v); id >= 0)
+                    out.add (onEvent (e.offset, z, id, v));
+            }
+        }
+    }
+
+private:
+    static double velocityToVolume (double v) noexcept { return (std::pow (11.0, 1.28 * v) - 1.0) / 10.0; }
+    static double volumeToVelocity (double vol) noexcept { return std::clamp (std::log (10.0 * vol + 1.0) / std::log (11.0) / 1.28, 0.0, 1.0); }
+    double random() noexcept
+    {
+        seed ^= seed << 13;
+        seed ^= seed >> 17;
+        seed ^= seed << 5;
+        return (double) (seed >> 8) / 16777216.0;
+    }
+    std::uint32_t seed = 0x12bd6aau;
+};
+} // namespace
+
+namespace
+{
+// An FL curve as the Envelope Controller's (core/FlSynths.h): accumulated points, LYNX's tension sign on the segment
+// starting at a point, a hold as a step
+void toArticulator (const MapCurve& m, ControllerArticulator& a)
+{
+    a.count = 0;
+    a.sustain = -1;
+    a.decayPoint = -1;
+    const auto sustain = m.footer[4], decay = m.footer[2];
+    for (std::size_t i = 0; i < m.points.size() && a.count < (int) a.time.size(); ++i)
+    {
+        const auto& p = m.points[i];
+        if (i > 0)
+        {
+            if (p.curve == 2 && p.x > m.points[i - 1].x && a.count + 1 < (int) a.time.size())
+            {
+                a.time[(std::size_t) a.count] = (float) p.x;
+                a.level[(std::size_t) a.count] = a.level[(std::size_t) a.count - 1];
+                a.tension[(std::size_t) a.count] = 0.0f;
+                ++a.count;
+            }
+            else if (p.curve <= 1)
+                a.tension[(std::size_t) a.count - 1] = std::clamp (-p.tension, -1.0f, 1.0f);
+        }
+        if ((int) i == sustain)
+            a.sustain = a.count;
+        if ((int) i == decay)
+            a.decayPoint = a.count;
+        a.time[(std::size_t) a.count] = (float) p.x;
+        a.level[(std::size_t) a.count] = (float) std::clamp (p.y, 0.0, 1.0);
+        a.tension[(std::size_t) a.count] = 0.0f;
+        ++a.count;
+    }
+}
+
+// What the audio thread evaluates: per articulator and target the envelope, the LFO amplitude and the LFO wave
+struct EnvelopeRuntime
+{
+    struct Part
+    {
+        bool envOn = false, lfoOn = false, envTempo = false, lfoTempo = false;
+        float base = 0.5f, env = 0.0f, lfo = 0.0f, offset = 0.5f;
+        ControllerArticulator envelope, amplitude, wave; // (levels 0…1 with base 0: their curves' values)
+        double rate = 1.0, startPhase = 0.0;            // LFO: cycles per unit, phase at the trigger
+    };
+    struct Articulator
+    {
+        int colour = 0, low = 0, high = 132;
+        std::array<Part, 5> parts;
+    };
+    bool enabled = true;
+    std::array<Articulator, 16> articulators;
+
+    // (big: on the heap, never on a stack)
+    static std::unique_ptr<EnvelopeRuntime> from (const EnvelopeSettings& s)
+    {
+        auto made = std::make_unique<EnvelopeRuntime>();
+        auto& rt = *made;
+        rt.enabled = s.enabled;
+        for (int g = 0; g < 16; ++g)
+        {
+            const auto& a = s.articulators[(std::size_t) g];
+            auto& r = rt.articulators[(std::size_t) g];
+            r.colour = a.colour;
+            r.low = a.low;
+            r.high = a.high;
+            for (int t = 0; t < 5; ++t)
+            {
+                const auto& p = a.parts[(std::size_t) t];
+                auto& q = r.parts[(std::size_t) t];
+                q.envOn = p.envOn() && ! p.envelope.points.empty();
+                q.lfoOn = p.lfoOn();
+                q.envTempo = (p.envelope.footer[0] & 1) != 0;
+                q.lfoTempo = (p.lfoAmp.footer[0] & 1) != 0;
+                q.base = p.base;
+                q.env = p.env;
+                q.lfo = p.lfo;
+                q.offset = t == EnvelopeSettings::velocity ? 0.0f : 0.5f;
+                toArticulator (p.envelope, q.envelope);
+                q.envelope.adsr = p.adsr;
+                q.envelope = controllerWithKnobs (q.envelope);
+                for (auto* c : { &q.envelope, &q.amplitude })
+                {
+                    c->base = 0.0f;
+                    c->envLevel = 1.0f;
+                    c->bipolar = false;
+                    c->envOn = true;
+                }
+                toArticulator (p.lfoAmp, q.amplitude);
+                q.wave.lfoSpeed = p.speed;
+                q.wave.lfoTension = p.tension;
+                q.wave.lfoSkew = p.skew;
+                q.wave.lfoPulseWidth = p.pulseWidth;
+                q.wave.lfoPhase = p.phase;
+                q.rate = controllerLfoRate (q.wave);
+                q.startPhase = controllerLfoStartPhase (q.wave);
+            }
+        }
+        return made;
+    }
+};
+
+// One note in, the same note out, its volume, fine pitch, pan and Mod X / Y moved by the envelopes and LFOs of every
+// articulator whose note colour and key range it matches (FL re-applies them each tick; LYNX each block).
+class Envelope final : public Processor
+{
+public:
+    explicit Envelope (const EnvelopeSettings& s) : settings (EnvelopeRuntime::from (s)) {}
+    Kind kind() const noexcept override { return Kind::envelope; }
+    bool configure (const std::vector<std::uint8_t>& fl) override
+    {
+        auto s = parseEnvelope (fl);
+        if (! s)
+            return false;
+        settings.publish (EnvelopeRuntime::from (*s));
+        return true;
+    }
+    bool busy() const noexcept override { return count > 0; }
+
+    void releaseAll (EventList& out) noexcept override
+    {
+        for (int i = 0; i < count; ++i)
+            if (! voices[(std::size_t) i].released)
+                out.add (offEvent (voices[(std::size_t) i], 0));
+        count = 0;
+    }
+
+    void process (const Event* in, int n, int samples, const Transport& transport, EventList& out) noexcept override
+    {
+        settings.take();
+        const auto& rt = settings.get();
+        const auto seconds = samples / std::max (1.0, transport.sampleRate);
+        const auto beats = seconds * transport.bpm / 60.0;
+        // the voices sounding move on (and send what changed)
+        for (int i = 0; i < count; ++i)
+        {
+            auto& v = voices[(std::size_t) i];
+            v.seconds += seconds;
+            v.beats += beats;
+            if (v.released)
+            {
+                v.releaseSeconds += seconds;
+                v.releaseBeats += beats;
+            }
+            apply (rt, v, 0, &out);
+        }
+        // the finished ones go (their output was released and their envelopes have ended, or 30 s after the release)
+        int kept = 0;
+        for (int i = 0; i < count; ++i)
+        {
+            const auto& v = voices[(std::size_t) i];
+            if (v.released && (v.releaseSeconds > 30.0 || finished (rt, v)))
+                continue;
+            voices[(std::size_t) kept++] = v;
+        }
+        count = kept;
+
+        for (int i = 0; i < n; ++i)
+        {
+            const auto& e = in[i];
+            if (e.type == Event::Type::on)
+            {
+                Voice v;
+                v.input = e.id;
+                v.id = nextId++;
+                if (nextId > 1 << 30)
+                    nextId = 1;
+                v.source = e.voice;
+                v.sent = e.voice;
+                for (int g = 0; g < 16; ++g)
+                {
+                    const auto& a = rt.articulators[(std::size_t) g];
+                    const auto key = e.voice.key + 1;
+                    if (a.colour == e.voice.colour && key >= a.low && key <= a.high)
+                        v.matched |= (std::uint16_t) (1u << g);
+                }
+                Voice playing = v;
+                apply (rt, playing, e.offset, nullptr);
+                out.add (onEvent (e.offset, 0, playing.id, playing.sent));
+                if (count < (int) voices.size())
+                    voices[(std::size_t) count++] = playing;
+            }
+            else if (e.type == Event::Type::off)
+                for (int k = 0; k < count; ++k)
+                {
+                    auto& v = voices[(std::size_t) k];
+                    if (v.input == e.id && ! v.released)
+                    {
+                        v.released = true;
+                        v.source.release = e.voice.release;
+                        out.add (offEvent (v, e.offset));
+                    }
+                }
+        }
+    }
+
+private:
+    struct Voice
+    {
+        int input = -1, id = 0;
+        Voice() = default;
+        vfx::Voice source, sent;
+        std::uint16_t matched = 0;
+        bool released = false;
+        double seconds = 0.0, beats = 0.0, releaseSeconds = 0.0, releaseBeats = 0.0;
+    };
+
+    static Event offEvent (const Voice& v, int offset) noexcept
+    {
+        Event e;
+        e.type = Event::Type::off;
+        e.offset = offset;
+        e.id = v.id;
+        e.voice = v.sent;
+        e.voice.release = v.source.release;
+        return e;
+    }
+
+    // the voice's levels now (FL's per-voice apply); with `out`, prop events for what changed
+    static void apply (const EnvelopeRuntime& rt, Voice& v, int offset, EventList* out) noexcept
+    {
+        auto now = v.source;
+        if (rt.enabled && v.matched != 0)
+        {
+            const auto sourceVolume = (std::pow (11.0, 1.28 * (double) v.source.velocity) - 1.0) / 10.0;
+            auto volume = sourceVolume;
+            double cents = v.source.cents, pan = v.source.pan, modX = v.source.modX * 2.0 - 1.0, modY = v.source.modY * 2.0 - 1.0;
+            for (int g = 15; g >= 0; --g) // (FL: the last articulator first)
+            {
+                if ((v.matched & (1u << g)) == 0)
+                    continue;
+                for (int t = 4; t >= 0; --t)
+                {
+                    const auto& p = rt.articulators[(std::size_t) g].parts[(std::size_t) t];
+                    if (! p.envOn && ! p.lfoOn)
+                        continue;
+                    const auto envTime = p.envTempo ? v.beats : v.seconds;
+                    const auto envRelease = ! v.released ? -1.0 : p.envTempo ? v.releaseBeats : v.releaseSeconds;
+                    const auto e = p.envOn ? controllerValue (p.envelope, envTime, envRelease) - p.offset : 0.0f;
+                    double l = 0.0;
+                    if (p.lfoOn)
+                    {
+                        const auto lfoTime = p.lfoTempo ? v.beats : v.seconds;
+                        const auto lfoRelease = ! v.released ? -1.0 : p.lfoTempo ? v.releaseBeats : v.releaseSeconds;
+                        const auto amp = controllerValue (p.amplitude, lfoTime, lfoRelease) - 0.5;
+                        l = amp * controllerLfoWave (p.wave, p.startPhase + p.rate * lfoTime);
+                    }
+                    if (t == EnvelopeSettings::velocity)
+                    {
+                        double m = p.base;
+                        if (p.envOn)
+                            m = p.env >= 0.0f ? p.base + 2.0 * p.env * e : (1.0 - p.base) + 2.0 * std::abs (p.env) * (1.0 - e);
+                        if (p.lfoOn)
+                            m *= 2.0 * p.lfo * l;
+                        volume = std::clamp (volume * m, 0.0, 4.0);
+                        continue;
+                    }
+                    auto d = (double) p.base - 0.5;
+                    if (p.envOn)
+                        d += 2.0 * p.env * e;
+                    if (p.lfoOn)
+                        d += 2.0 * p.lfo * l;
+                    if (t == EnvelopeSettings::pitch)
+                        cents += d * 4800.0;
+                    else if (t == EnvelopeSettings::pan)
+                        pan = std::clamp (pan + d, -1.0, 1.0);
+                    else if (t == EnvelopeSettings::modX)
+                        modX = std::clamp (modX + d, -2.0, 2.0);
+                    else
+                        modY = std::clamp (modY + d, -2.0, 2.0);
+                }
+            }
+            if (volume != sourceVolume)
+                now.velocity = (float) std::clamp (std::log (10.0 * volume + 1.0) / std::log (11.0) / 1.28, 0.0, 1.0);
+            now.cents = (float) std::clamp (cents, -6000.0 - v.source.key * 100.0, 6700.0 - v.source.key * 100.0);
+            now.pan = (float) pan;
+            now.modX = (float) std::clamp (modX * 0.5 + 0.5, 0.0, 1.0);
+            now.modY = (float) std::clamp (modY * 0.5 + 0.5, 0.0, 1.0);
+        }
+        if (out != nullptr)
+        {
+            auto send = [&] (Prop prop, float before, float after) {
+                if (std::abs (after - before) < 1e-4f)
+                    return;
+                Event p;
+                p.type = Event::Type::prop;
+                p.offset = offset;
+                p.id = v.id;
+                p.voice = v.sent;
+                p.prop = prop;
+                p.value = after;
+                out->add (p);
+            };
+            send (Prop::velocity, v.sent.velocity, now.velocity);
+            send (Prop::pitch, v.sent.cents, now.cents);
+            send (Prop::pan, v.sent.pan, now.pan);
+            send (Prop::modX, v.sent.modX, now.modX);
+            send (Prop::modY, v.sent.modY, now.modY);
+        }
+        now.key = v.source.key;
+        v.sent = now;
+    }
+
+    static bool finished (const EnvelopeRuntime& rt, const Voice& v) noexcept
+    {
+        if (! rt.enabled || v.matched == 0)
+            return true;
+        for (int g = 0; g < 16; ++g)
+            if ((v.matched & (1u << g)) != 0)
+                for (const auto& p : rt.articulators[(std::size_t) g].parts)
+                {
+                    if (p.envOn && ! controllerVoiceFinished (p.envelope, p.envTempo ? v.beats : v.seconds, p.envTempo ? v.releaseBeats : v.releaseSeconds))
+                        return false;
+                    if (p.lfoOn && ! controllerVoiceFinished (p.amplitude, p.lfoTempo ? v.beats : v.seconds, p.lfoTempo ? v.releaseBeats : v.releaseSeconds))
+                        return false;
+                }
+        return true;
+    }
+
+    Handoff<EnvelopeRuntime> settings;
+    std::array<Voice, 256> voices {};
+    int count = 0, nextId = 1;
+};
+} // namespace
+
 std::unique_ptr<Processor> makeProcessor (Kind kind, const std::vector<std::uint8_t>& fl)
 {
     switch (kind)
@@ -900,6 +1728,10 @@ std::unique_ptr<Processor> makeProcessor (Kind kind, const std::vector<std::uint
             return std::make_unique<ColorMapper> (parseColorMapper (fl).value_or (defaultColorMapper()));
         case Kind::levelScaler:
             return std::make_unique<LevelScaler> (parseLevelScaler (fl).value_or (defaultLevelScaler()));
+        case Kind::keyboardSplitter:
+            return std::make_unique<KeyboardSplitter> (parseKeyboardSplitter (fl).value_or (defaultKeyboardSplitter()));
+        case Kind::envelope:
+            return std::make_unique<Envelope> (parseEnvelope (fl).value_or (defaultEnvelope()));
         default: break;
     }
     return std::make_unique<ThroughProcessor> (kind);

+ 77 - 0
src/core/Vfx.h

@@ -164,6 +164,83 @@ std::vector<std::uint8_t> writeLevelScaler (const LevelScalerSettings& s);
 // The curve: x in lo…hi → out in lo…hi; `random` 0…1 places it in the humanize range (FL's T(tab, x, lo, hi, rnd))
 double levelScale (const LevelScalerSettings& s, int tab, double x, double lo, double hi, double random) noexcept;
 
+// FL's mapping curve (TMMap): points at x 0…1 with a level 0…1; a point's tension bends the segment that ends at it,
+// curve type 2 holds the previous level up to it (a step). Kept as FL stores them, so the file writes back as read.
+struct MapCurve
+{
+    struct Point
+    {
+        double x = 0.0, y = 0.0; // x absolute (FL stores the distance from the previous point)
+        float tension = 0.0f;
+        std::uint8_t curve = 0, b13 = 0, b14 = 0, b15 = 2;
+        bool operator== (const Point&) const = default;
+    };
+    std::vector<Point> points;
+    std::array<std::int32_t, 5> footer { 0, -1, -1, -1, -1 };
+    bool operator== (const MapCurve&) const = default;
+    static MapCurve flat (double level);
+    double at (double x) const noexcept;       // the level at x (the ends hold outside)
+    bool isFlat (double level) const noexcept; // every point at that level
+};
+
+// VFX Keyboard Splitter: 16 zones, each a keyboard map (x = key / 132) and a velocity map; a note plays on every
+// zone whose level is above zero, on that zone's output
+struct KeyboardSplitterSettings
+{
+    struct Zone
+    {
+        MapCurve keyboard = MapCurve::flat (0.0), velocity = MapCurve::flat (1.0);
+        int transpose = 0; // semitones −48…48
+        bool absolute = false, random = false;
+        std::string name;  // empty: "Zone N"
+        bool operator== (const Zone&) const = default;
+        bool active() const noexcept { return ! (keyboard.isFlat (0.0) && velocity.isFlat (1.0)); }
+    };
+    std::uint32_t header = 0x100003;
+    int page = 0; // (the editor's: 0 keyboard, 1 velocity)
+    std::array<Zone, 16> zones;
+    bool operator== (const KeyboardSplitterSettings&) const = default;
+};
+KeyboardSplitterSettings defaultKeyboardSplitter();
+std::optional<KeyboardSplitterSettings> parseKeyboardSplitter (const std::vector<std::uint8_t>& fl);
+std::vector<std::uint8_t> writeKeyboardSplitter (const KeyboardSplitterSettings& s);
+// FL's map level → volume gain: (11^m − 1) / 10; volume ↔ velocity: vol = (11^(1.28 v) − 1) / 10
+double splitterGain (double mapLevel) noexcept;
+
+// VFX Envelope: 16 articulators, each for one note colour and key range, with five targets (velocity, pitch, pan,
+// Mod X, Mod Y), each an envelope and an LFO as in FL's Envelope Controller
+struct EnvelopeSettings
+{
+    enum Target { velocity, pitch, pan, modX, modY, targetCount };
+    struct Part
+    {
+        int version = 3;
+        float base = 0.5f, env = 1.0f, lfo = 1.0f;   // base 0…1, amounts −1…1
+        MapCurve envelope;                          // footer: flags (bit 0 tempo), enabled, decay, loop, sustain
+        std::array<std::int32_t, 4> adsr { 128, 128, 0, 128 };
+        MapCurve lfoAmp;                            // the LFO's amplitude over time (footer as above)
+        std::int32_t speed = 40898, tension = 0, skew = 0, pulseWidth = 0, phase = 0;
+        bool envOn() const noexcept { return envelope.footer[1] != 0; }
+        bool lfoOn() const noexcept { return lfoAmp.footer[1] != 0; }
+        bool operator== (const Part&) const = default;
+    };
+    struct Articulator
+    {
+        int colour = 0, low = 0, high = 132; // key range: note + 1 (FL)
+        std::array<Part, targetCount> parts;
+        bool operator== (const Articulator&) const = default;
+    };
+    std::uint32_t header = 0x10003;
+    bool enabled = true;
+    int shownArticulator = 0, shownTarget = 0, shownPart = 0; // (the editor's)
+    std::array<std::int32_t, 4> toggles {};
+    std::array<Articulator, 16> articulators;
+    bool operator== (const EnvelopeSettings&) const = default;
+};
+EnvelopeSettings defaultEnvelope();
+std::optional<EnvelopeSettings> parseEnvelope (const std::vector<std::uint8_t>& fl);
+std::vector<std::uint8_t> writeEnvelope (const EnvelopeSettings& s);
+
 // ---------------------------------------------------------------------------------------------------------------
 // Presets
 

+ 264 - 1
src/ui/I18nData.h

@@ -14304,6 +14304,269 @@ inline constexpr unsigned char ptBR[] = {
 34, 32, 61, 32, 34, 66, 114, 111, 119, 115, 101, 114, 32, 100, 101, 32, 115, 97, 109, 112, 108, 101, 115, 34,
 10, 34, 79, 112, 101, 110, 32, 105, 110, 32, 116, 104, 101, 32, 102, 105, 108, 101, 32, 109, 97, 110, 97, 103,
 101, 114, 34, 32, 61, 32, 34, 65, 98, 114, 105, 114, 32, 110, 111, 32, 103, 101, 114, 101, 110, 99, 105, 97,
-100, 111, 114, 32, 100, 101, 32, 97, 114, 113, 117, 105, 118, 111, 115, 34, 10,
+100, 111, 114, 32, 100, 101, 32, 97, 114, 113, 117, 105, 118, 111, 115, 34, 10, 10, 35, 32, 82, 111, 117, 110,
+100, 32, 49, 54, 52, 98, 58, 32, 70, 76, 39, 115, 32, 86, 70, 88, 32, 110, 111, 116, 101, 32, 101, 102,
+102, 101, 99, 116, 115, 10, 34, 69, 110, 97, 98, 108, 101, 34, 32, 61, 32, 34, 65, 116, 105, 118, 97, 114,
+34, 10, 34, 65, 108, 108, 32, 40, 103, 97, 105, 110, 45, 99, 111, 109, 112, 101, 110, 115, 97, 116, 101, 100,
+41, 34, 32, 61, 32, 34, 84, 111, 100, 97, 115, 32, 40, 103, 97, 110, 104, 111, 32, 99, 111, 109, 112, 101,
+110, 115, 97, 100, 111, 41, 34, 10, 34, 67, 121, 99, 108, 101, 32, 117, 112, 34, 32, 61, 32, 34, 67, 105,
+99, 108, 111, 32, 112, 97, 114, 97, 32, 99, 105, 109, 97, 34, 10, 34, 67, 121, 99, 108, 101, 32, 100, 111,
+119, 110, 34, 32, 61, 32, 34, 67, 105, 99, 108, 111, 32, 112, 97, 114, 97, 32, 98, 97, 105, 120, 111, 34,
+10, 34, 77, 117, 108, 116, 105, 109, 111, 100, 101, 58, 32, 104, 111, 119, 32, 97, 110, 32, 105, 110, 112, 117,
+116, 32, 109, 97, 112, 112, 101, 100, 32, 116, 111, 32, 115, 101, 118, 101, 114, 97, 108, 32, 110, 111, 116, 101,
+115, 32, 112, 108, 97, 121, 115, 32, 116, 104, 101, 109, 34, 32, 61, 32, 34, 77, 117, 108, 116, 105, 109, 111,
+100, 111, 58, 32, 99, 111, 109, 111, 32, 117, 109, 97, 32, 101, 110, 116, 114, 97, 100, 97, 32, 109, 97, 112,
+101, 97, 100, 97, 32, 112, 97, 114, 97, 32, 118, 195, 161, 114, 105, 97, 115, 32, 110, 111, 116, 97, 115, 32,
+97, 115, 32, 116, 111, 99, 97, 34, 10, 34, 77, 117, 108, 116, 105, 109, 111, 100, 101, 34, 32, 61, 32, 34,
+77, 117, 108, 116, 105, 109, 111, 100, 111, 34, 10, 34, 66, 97, 115, 101, 32, 107, 101, 121, 34, 32, 61, 32,
+34, 84, 111, 109, 32, 98, 97, 115, 101, 34, 10, 34, 80, 105, 116, 99, 104, 32, 115, 108, 105, 100, 101, 34,
+32, 61, 32, 34, 68, 101, 115, 108, 105, 122, 101, 32, 100, 101, 32, 97, 108, 116, 117, 114, 97, 34, 10, 34,
+123, 48, 125, 32, 112, 108, 97, 121, 115, 32, 123, 49, 125, 32, 45, 32, 108, 101, 102, 116, 45, 99, 108, 105,
+99, 107, 58, 32, 97, 100, 100, 32, 47, 32, 114, 101, 109, 111, 118, 101, 44, 32, 114, 105, 103, 104, 116, 45,
+99, 108, 105, 99, 107, 58, 32, 111, 110, 108, 121, 32, 116, 104, 105, 115, 32, 110, 111, 116, 101, 44, 32, 109,
+105, 100, 100, 108, 101, 45, 99, 108, 105, 99, 107, 32, 111, 114, 32, 65, 108, 116, 43, 99, 108, 105, 99, 107,
+58, 32, 114, 101, 115, 101, 116, 32, 116, 104, 101, 32, 114, 111, 119, 34, 32, 61, 32, 34, 123, 48, 125, 32,
+116, 111, 99, 97, 32, 123, 49, 125, 32, 45, 32, 99, 108, 105, 113, 117, 101, 32, 101, 115, 113, 117, 101, 114,
+100, 111, 58, 32, 97, 100, 105, 99, 105, 111, 110, 97, 32, 47, 32, 114, 101, 109, 111, 118, 101, 44, 32, 99,
+108, 105, 113, 117, 101, 32, 100, 105, 114, 101, 105, 116, 111, 58, 32, 115, 195, 179, 32, 101, 115, 116, 97, 32,
+110, 111, 116, 97, 44, 32, 99, 108, 105, 113, 117, 101, 32, 100, 111, 32, 109, 101, 105, 111, 32, 111, 117, 32,
+65, 108, 116, 43, 99, 108, 105, 113, 117, 101, 58, 32, 114, 101, 115, 116, 97, 117, 114, 97, 32, 97, 32, 108,
+105, 110, 104, 97, 34, 10, 34, 79, 102, 102, 115, 101, 116, 32, 40, 116, 114, 97, 110, 115, 112, 111, 115, 101,
+41, 34, 32, 61, 32, 34, 68, 101, 115, 108, 111, 99, 97, 109, 101, 110, 116, 111, 32, 40, 116, 114, 97, 110,
+115, 112, 111, 114, 41, 34, 10, 34, 66, 97, 115, 101, 32, 107, 101, 121, 58, 32, 116, 104, 101, 32, 110, 111,
+116, 101, 32, 116, 104, 101, 32, 114, 111, 119, 115, 32, 97, 110, 100, 32, 116, 104, 101, 105, 114, 32, 111, 99,
+116, 97, 118, 101, 115, 32, 115, 116, 97, 114, 116, 32, 111, 110, 34, 32, 61, 32, 34, 84, 111, 109, 32, 98,
+97, 115, 101, 58, 32, 97, 32, 110, 111, 116, 97, 32, 101, 109, 32, 113, 117, 101, 32, 97, 115, 32, 108, 105,
+110, 104, 97, 115, 32, 101, 32, 115, 117, 97, 115, 32, 111, 105, 116, 97, 118, 97, 115, 32, 99, 111, 109, 101,
+195, 167, 97, 109, 34, 10, 34, 80, 105, 116, 99, 104, 32, 115, 108, 105, 100, 101, 58, 32, 116, 104, 101, 32,
+110, 101, 119, 32, 110, 111, 116, 101, 115, 32, 115, 116, 97, 114, 116, 32, 97, 116, 32, 116, 104, 101, 32, 112,
+108, 97, 121, 101, 100, 32, 112, 105, 116, 99, 104, 32, 97, 110, 100, 32, 103, 108, 105, 100, 101, 32, 116, 111,
+32, 116, 104, 101, 105, 114, 32, 111, 119, 110, 32, 40, 105, 110, 32, 115, 116, 101, 112, 115, 41, 34, 32, 61,
+32, 34, 68, 101, 115, 108, 105, 122, 101, 32, 100, 101, 32, 97, 108, 116, 117, 114, 97, 58, 32, 97, 115, 32,
+110, 111, 116, 97, 115, 32, 110, 111, 118, 97, 115, 32, 99, 111, 109, 101, 195, 167, 97, 109, 32, 110, 97, 32,
+97, 108, 116, 117, 114, 97, 32, 116, 111, 99, 97, 100, 97, 32, 101, 32, 100, 101, 115, 108, 105, 122, 97, 109,
+32, 97, 116, 195, 169, 32, 97, 32, 115, 117, 97, 32, 40, 101, 109, 32, 112, 97, 115, 115, 111, 115, 41, 34,
+10, 34, 86, 111, 105, 99, 101, 32, 123, 48, 125, 34, 32, 61, 32, 34, 86, 111, 122, 32, 123, 48, 125, 34,
+10, 34, 84, 104, 101, 32, 118, 111, 105, 99, 101, 32, 111, 117, 116, 112, 117, 116, 32, 116, 104, 101, 32, 110,
+111, 116, 101, 115, 32, 111, 102, 32, 99, 111, 108, 111, 117, 114, 32, 123, 48, 125, 32, 103, 111, 32, 116, 111,
+34, 32, 61, 32, 34, 65, 32, 115, 97, 195, 173, 100, 97, 32, 100, 101, 32, 118, 111, 122, 32, 112, 97, 114,
+97, 32, 111, 110, 100, 101, 32, 118, 195, 163, 111, 32, 97, 115, 32, 110, 111, 116, 97, 115, 32, 100, 97, 32,
+99, 111, 114, 32, 123, 48, 125, 34, 10, 34, 84, 104, 101, 32, 99, 111, 108, 111, 117, 114, 32, 116, 104, 101,
+32, 110, 111, 116, 101, 115, 32, 111, 102, 32, 99, 111, 108, 111, 117, 114, 32, 123, 48, 125, 32, 108, 101, 97,
+118, 101, 32, 119, 105, 116, 104, 34, 32, 61, 32, 34, 65, 32, 99, 111, 114, 32, 99, 111, 109, 32, 113, 117,
+101, 32, 115, 97, 101, 109, 32, 97, 115, 32, 110, 111, 116, 97, 115, 32, 100, 97, 32, 99, 111, 114, 32, 123,
+48, 125, 34, 10, 34, 86, 111, 105, 99, 101, 32, 111, 117, 116, 112, 117, 116, 34, 32, 61, 32, 34, 83, 97,
+195, 173, 100, 97, 32, 100, 101, 32, 118, 111, 122, 34, 10, 34, 77, 117, 108, 116, 105, 112, 108, 121, 34, 32,
+61, 32, 34, 77, 117, 108, 116, 105, 112, 108, 105, 99, 97, 114, 34, 10, 34, 83, 117, 98, 116, 114, 97, 99,
+116, 34, 32, 61, 32, 34, 83, 117, 98, 116, 114, 97, 105, 114, 34, 10, 34, 72, 117, 109, 97, 110, 105, 122,
+101, 32, 109, 111, 100, 101, 58, 32, 116, 104, 101, 32, 114, 97, 110, 100, 111, 109, 32, 112, 97, 114, 116, 32,
+103, 111, 101, 115, 32, 98, 101, 108, 111, 119, 32, 116, 104, 101, 32, 118, 97, 108, 117, 101, 44, 32, 97, 114,
+111, 117, 110, 100, 32, 105, 116, 32, 111, 114, 32, 97, 98, 111, 118, 101, 32, 105, 116, 34, 32, 61, 32, 34,
+77, 111, 100, 111, 32, 100, 101, 32, 104, 117, 109, 97, 110, 105, 122, 97, 195, 167, 195, 163, 111, 58, 32, 97,
+32, 112, 97, 114, 116, 101, 32, 97, 108, 101, 97, 116, 195, 179, 114, 105, 97, 32, 102, 105, 99, 97, 32, 97,
+98, 97, 105, 120, 111, 32, 100, 111, 32, 118, 97, 108, 111, 114, 44, 32, 101, 109, 32, 118, 111, 108, 116, 97,
+32, 100, 101, 108, 101, 32, 111, 117, 32, 97, 99, 105, 109, 97, 34, 10, 34, 82, 101, 115, 101, 116, 32, 97,
+108, 108, 32, 99, 111, 110, 116, 114, 111, 108, 115, 32, 111, 102, 32, 116, 104, 105, 115, 32, 112, 114, 111, 112,
+101, 114, 116, 121, 34, 32, 61, 32, 34, 82, 101, 115, 116, 97, 117, 114, 97, 32, 116, 111, 100, 111, 115, 32,
+111, 115, 32, 99, 111, 110, 116, 114, 111, 108, 101, 115, 32, 100, 101, 115, 116, 97, 32, 112, 114, 111, 112, 114,
+105, 101, 100, 97, 100, 101, 34, 10, 34, 105, 110, 34, 32, 61, 32, 34, 101, 110, 116, 114, 97, 100, 97, 34,
+10, 34, 111, 117, 116, 34, 32, 61, 32, 34, 115, 97, 195, 173, 100, 97, 34, 10, 34, 67, 101, 110, 116, 101,
+114, 58, 32, 116, 104, 101, 32, 105, 110, 112, 117, 116, 32, 108, 101, 118, 101, 108, 32, 116, 104, 101, 32, 99,
+117, 114, 118, 101, 32, 116, 117, 114, 110, 115, 32, 97, 114, 111, 117, 110, 100, 34, 32, 61, 32, 34, 67, 101,
+110, 116, 114, 111, 58, 32, 111, 32, 110, 195, 173, 118, 101, 108, 32, 100, 101, 32, 101, 110, 116, 114, 97, 100,
+97, 32, 101, 109, 32, 116, 111, 114, 110, 111, 32, 100, 111, 32, 113, 117, 97, 108, 32, 97, 32, 99, 117, 114,
+118, 97, 32, 103, 105, 114, 97, 34, 10, 34, 77, 117, 108, 116, 105, 112, 108, 121, 58, 32, 116, 104, 101, 32,
+115, 108, 111, 112, 101, 32, 97, 114, 111, 117, 110, 100, 32, 116, 104, 101, 32, 99, 101, 110, 116, 101, 114, 32,
+40, 110, 101, 103, 97, 116, 105, 118, 101, 32, 105, 110, 118, 101, 114, 116, 115, 41, 34, 32, 61, 32, 34, 77,
+117, 108, 116, 105, 112, 108, 105, 99, 97, 114, 58, 32, 97, 32, 105, 110, 99, 108, 105, 110, 97, 195, 167, 195,
+163, 111, 32, 101, 109, 32, 116, 111, 114, 110, 111, 32, 100, 111, 32, 99, 101, 110, 116, 114, 111, 32, 40, 110,
+101, 103, 97, 116, 105, 118, 111, 32, 105, 110, 118, 101, 114, 116, 101, 41, 34, 10, 34, 79, 102, 102, 115, 101,
+116, 58, 32, 109, 111, 118, 101, 115, 32, 101, 118, 101, 114, 121, 32, 118, 97, 108, 117, 101, 32, 117, 112, 32,
+111, 114, 32, 100, 111, 119, 110, 34, 32, 61, 32, 34, 68, 101, 115, 108, 111, 99, 97, 109, 101, 110, 116, 111,
+58, 32, 109, 111, 118, 101, 32, 116, 111, 100, 111, 115, 32, 111, 115, 32, 118, 97, 108, 111, 114, 101, 115, 32,
+112, 97, 114, 97, 32, 99, 105, 109, 97, 32, 111, 117, 32, 112, 97, 114, 97, 32, 98, 97, 105, 120, 111, 34,
+10, 34, 84, 101, 110, 115, 105, 111, 110, 58, 32, 98, 101, 110, 100, 115, 32, 116, 104, 101, 32, 99, 117, 114,
+118, 101, 32, 40, 112, 111, 115, 105, 116, 105, 118, 101, 32, 114, 105, 115, 101, 115, 32, 102, 97, 115, 116, 44,
+32, 110, 101, 103, 97, 116, 105, 118, 101, 32, 115, 116, 97, 114, 116, 115, 32, 115, 108, 111, 119, 41, 34, 32,
+61, 32, 34, 84, 101, 110, 115, 195, 163, 111, 58, 32, 99, 117, 114, 118, 97, 32, 97, 32, 108, 105, 110, 104,
+97, 32, 40, 112, 111, 115, 105, 116, 105, 118, 111, 32, 115, 111, 98, 101, 32, 114, 195, 161, 112, 105, 100, 111,
+44, 32, 110, 101, 103, 97, 116, 105, 118, 111, 32, 99, 111, 109, 101, 195, 167, 97, 32, 100, 101, 118, 97, 103,
+97, 114, 41, 34, 10, 34, 72, 117, 109, 97, 110, 105, 122, 101, 58, 32, 97, 32, 114, 97, 110, 100, 111, 109,
+32, 97, 109, 111, 117, 110, 116, 32, 102, 111, 114, 32, 101, 97, 99, 104, 32, 110, 111, 116, 101, 34, 32, 61,
+32, 34, 72, 117, 109, 97, 110, 105, 122, 97, 114, 58, 32, 117, 109, 97, 32, 113, 117, 97, 110, 116, 105, 100,
+97, 100, 101, 32, 97, 108, 101, 97, 116, 195, 179, 114, 105, 97, 32, 112, 97, 114, 97, 32, 99, 97, 100, 97,
+32, 110, 111, 116, 97, 34, 10, 34, 115, 117, 115, 116, 97, 105, 110, 34, 32, 61, 32, 34, 115, 117, 115, 116,
+101, 110, 116, 97, 195, 167, 195, 163, 111, 34, 10, 34, 75, 101, 121, 98, 111, 97, 114, 100, 34, 32, 61, 32,
+34, 84, 101, 99, 108, 97, 100, 111, 34, 10, 34, 90, 111, 110, 101, 32, 123, 48, 125, 34, 32, 61, 32, 34,
+90, 111, 110, 97, 32, 123, 48, 125, 34, 10, 34, 84, 104, 101, 32, 122, 111, 110, 101, 39, 115, 32, 110, 97,
+109, 101, 32, 40, 105, 116, 115, 32, 111, 117, 116, 112, 117, 116, 39, 115, 32, 110, 97, 109, 101, 32, 105, 110,
+32, 116, 104, 101, 32, 80, 97, 116, 99, 104, 101, 114, 41, 34, 32, 61, 32, 34, 79, 32, 110, 111, 109, 101,
+32, 100, 97, 32, 122, 111, 110, 97, 32, 40, 111, 32, 110, 111, 109, 101, 32, 100, 97, 32, 115, 97, 195, 173,
+100, 97, 32, 100, 101, 108, 97, 32, 110, 111, 32, 80, 97, 116, 99, 104, 101, 114, 41, 34, 10, 34, 87, 104,
+111, 108, 101, 32, 107, 101, 121, 98, 111, 97, 114, 100, 34, 32, 61, 32, 34, 84, 101, 99, 108, 97, 100, 111,
+32, 105, 110, 116, 101, 105, 114, 111, 34, 10, 34, 84, 104, 101, 32, 119, 104, 111, 108, 101, 32, 114, 97, 110,
+103, 101, 32, 97, 116, 32, 102, 117, 108, 108, 32, 108, 101, 118, 101, 108, 34, 32, 61, 32, 34, 65, 32, 102,
+97, 105, 120, 97, 32, 105, 110, 116, 101, 105, 114, 97, 32, 110, 111, 32, 110, 195, 173, 118, 101, 108, 32, 109,
+195, 161, 120, 105, 109, 111, 34, 10, 34, 66, 97, 99, 107, 32, 116, 111, 32, 116, 104, 101, 32, 109, 97, 112,
+39, 115, 32, 100, 101, 102, 97, 117, 108, 116, 32, 40, 116, 104, 101, 32, 122, 111, 110, 101, 32, 105, 115, 32,
+111, 102, 102, 32, 119, 104, 101, 110, 32, 98, 111, 116, 104, 32, 109, 97, 112, 115, 32, 97, 114, 101, 41, 34,
+32, 61, 32, 34, 86, 111, 108, 116, 97, 32, 97, 111, 32, 112, 97, 100, 114, 195, 163, 111, 32, 100, 111, 32,
+109, 97, 112, 97, 32, 40, 97, 32, 122, 111, 110, 97, 32, 102, 105, 99, 97, 32, 100, 101, 115, 108, 105, 103,
+97, 100, 97, 32, 113, 117, 97, 110, 100, 111, 32, 111, 115, 32, 100, 111, 105, 115, 32, 109, 97, 112, 97, 115,
+32, 101, 115, 116, 195, 163, 111, 32, 97, 115, 115, 105, 109, 41, 34, 10, 34, 82, 97, 110, 100, 111, 109, 32,
+40, 116, 104, 101, 32, 109, 97, 112, 32, 105, 115, 32, 97, 32, 112, 114, 111, 98, 97, 98, 105, 108, 105, 116,
+121, 41, 34, 32, 61, 32, 34, 65, 108, 101, 97, 116, 195, 179, 114, 105, 111, 32, 40, 111, 32, 109, 97, 112,
+97, 32, 195, 169, 32, 117, 109, 97, 32, 112, 114, 111, 98, 97, 98, 105, 108, 105, 100, 97, 100, 101, 41, 34,
+10, 34, 65, 98, 115, 111, 108, 117, 116, 101, 32, 40, 116, 104, 101, 32, 109, 97, 112, 32, 115, 101, 116, 115,
+32, 116, 104, 101, 32, 118, 111, 108, 117, 109, 101, 41, 34, 32, 61, 32, 34, 65, 98, 115, 111, 108, 117, 116,
+111, 32, 40, 111, 32, 109, 97, 112, 97, 32, 100, 101, 102, 105, 110, 101, 32, 111, 32, 118, 111, 108, 117, 109,
+101, 41, 34, 10, 34, 82, 97, 110, 100, 111, 109, 58, 32, 101, 97, 99, 104, 32, 110, 111, 116, 101, 32, 103,
+111, 101, 115, 32, 116, 111, 32, 111, 110, 101, 32, 111, 102, 32, 116, 104, 101, 32, 114, 97, 110, 100, 111, 109,
+32, 122, 111, 110, 101, 115, 44, 32, 112, 105, 99, 107, 101, 100, 32, 98, 121, 32, 116, 104, 101, 105, 114, 32,
+107, 101, 121, 98, 111, 97, 114, 100, 32, 109, 97, 112, 115, 34, 32, 61, 32, 34, 65, 108, 101, 97, 116, 195,
+179, 114, 105, 111, 58, 32, 99, 97, 100, 97, 32, 110, 111, 116, 97, 32, 118, 97, 105, 32, 112, 97, 114, 97,
+32, 117, 109, 97, 32, 100, 97, 115, 32, 122, 111, 110, 97, 115, 32, 97, 108, 101, 97, 116, 195, 179, 114, 105,
+97, 115, 44, 32, 115, 111, 114, 116, 101, 97, 100, 97, 32, 112, 101, 108, 111, 115, 32, 109, 97, 112, 97, 115,
+32, 100, 101, 32, 116, 101, 99, 108, 97, 100, 111, 32, 100, 101, 108, 97, 115, 34, 10, 34, 65, 98, 115, 111,
+108, 117, 116, 101, 58, 32, 116, 104, 101, 32, 118, 101, 108, 111, 99, 105, 116, 121, 32, 109, 97, 112, 32, 103,
+105, 118, 101, 115, 32, 116, 104, 101, 32, 118, 111, 108, 117, 109, 101, 32, 105, 110, 115, 116, 101, 97, 100, 32,
+111, 102, 32, 115, 99, 97, 108, 105, 110, 103, 32, 116, 104, 101, 32, 110, 111, 116, 101, 39, 115, 34, 32, 61,
+32, 34, 65, 98, 115, 111, 108, 117, 116, 111, 58, 32, 111, 32, 109, 97, 112, 97, 32, 100, 101, 32, 118, 101,
+108, 111, 99, 105, 100, 97, 100, 101, 32, 100, 195, 161, 32, 111, 32, 118, 111, 108, 117, 109, 101, 32, 101, 109,
+32, 118, 101, 122, 32, 100, 101, 32, 101, 115, 99, 97, 108, 97, 114, 32, 111, 32, 100, 97, 32, 110, 111, 116,
+97, 34, 10, 34, 84, 114, 97, 110, 115, 112, 111, 115, 101, 32, 40, 115, 101, 109, 105, 116, 111, 110, 101, 115,
+41, 34, 32, 61, 32, 34, 84, 114, 97, 110, 115, 112, 111, 114, 32, 40, 115, 101, 109, 105, 116, 111, 110, 115,
+41, 34, 10, 34, 65, 114, 116, 105, 99, 117, 108, 97, 116, 111, 114, 32, 123, 48, 125, 34, 32, 61, 32, 34,
+65, 114, 116, 105, 99, 117, 108, 97, 100, 111, 114, 32, 123, 48, 125, 34, 10, 34, 84, 104, 101, 32, 110, 111,
+116, 101, 32, 99, 111, 108, 111, 117, 114, 32, 116, 104, 105, 115, 32, 97, 114, 116, 105, 99, 117, 108, 97, 116,
+111, 114, 32, 119, 111, 114, 107, 115, 32, 111, 110, 32, 40, 116, 104, 101, 32, 77, 73, 68, 73, 32, 99, 104,
+97, 110, 110, 101, 108, 41, 34, 32, 61, 32, 34, 65, 32, 99, 111, 114, 32, 100, 101, 32, 110, 111, 116, 97,
+32, 101, 109, 32, 113, 117, 101, 32, 101, 115, 116, 101, 32, 97, 114, 116, 105, 99, 117, 108, 97, 100, 111, 114,
+32, 97, 116, 117, 97, 32, 40, 111, 32, 99, 97, 110, 97, 108, 32, 77, 73, 68, 73, 41, 34, 10, 34, 79,
+102, 102, 58, 32, 116, 104, 101, 32, 110, 111, 116, 101, 115, 32, 112, 97, 115, 115, 32, 117, 110, 99, 104, 97,
+110, 103, 101, 100, 34, 32, 61, 32, 34, 68, 101, 115, 108, 105, 103, 97, 100, 111, 58, 32, 97, 115, 32, 110,
+111, 116, 97, 115, 32, 112, 97, 115, 115, 97, 109, 32, 115, 101, 109, 32, 109, 117, 100, 97, 110, 195, 167, 97,
+34, 10, 34, 84, 101, 109, 112, 111, 58, 32, 116, 104, 101, 32, 116, 105, 109, 101, 32, 105, 110, 32, 98, 101,
+97, 116, 115, 32, 40, 101, 108, 115, 101, 32, 105, 110, 32, 115, 101, 99, 111, 110, 100, 115, 41, 34, 32, 61,
+32, 34, 84, 101, 109, 112, 111, 58, 32, 111, 32, 116, 101, 109, 112, 111, 32, 101, 109, 32, 98, 97, 116, 105,
+100, 97, 115, 32, 40, 115, 101, 110, 195, 163, 111, 32, 101, 109, 32, 115, 101, 103, 117, 110, 100, 111, 115, 41,
+34, 10, 34, 80, 117, 108, 115, 101, 32, 119, 105, 100, 116, 104, 34, 32, 61, 32, 34, 76, 97, 114, 103, 117,
+114, 97, 32, 100, 101, 32, 112, 117, 108, 115, 111, 34, 10, 34, 115, 101, 99, 111, 110, 100, 115, 34, 32, 61,
+32, 34, 115, 101, 103, 117, 110, 100, 111, 115, 34, 10, 34, 84, 105, 109, 101, 32, 105, 110, 32, 123, 48, 125,
+46, 32, 68, 114, 97, 103, 32, 97, 32, 112, 111, 105, 110, 116, 44, 32, 100, 111, 117, 98, 108, 101, 45, 99,
+108, 105, 99, 107, 32, 116, 111, 32, 97, 100, 100, 32, 111, 110, 101, 44, 32, 114, 105, 103, 104, 116, 45, 99,
+108, 105, 99, 107, 32, 116, 111, 32, 114, 101, 109, 111, 118, 101, 32, 105, 116, 44, 32, 100, 114, 97, 103, 32,
+97, 32, 115, 101, 103, 109, 101, 110, 116, 32, 116, 111, 32, 98, 101, 110, 100, 32, 105, 116, 46, 34, 32, 61,
+32, 34, 84, 101, 109, 112, 111, 32, 101, 109, 32, 123, 48, 125, 46, 32, 65, 114, 114, 97, 115, 116, 101, 32,
+117, 109, 32, 112, 111, 110, 116, 111, 44, 32, 99, 108, 105, 113, 117, 101, 32, 100, 117, 97, 115, 32, 118, 101,
+122, 101, 115, 32, 112, 97, 114, 97, 32, 97, 100, 105, 99, 105, 111, 110, 97, 114, 32, 117, 109, 44, 32, 99,
+108, 105, 113, 117, 101, 32, 100, 105, 114, 101, 105, 116, 111, 32, 112, 97, 114, 97, 32, 114, 101, 109, 111, 118,
+195, 170, 45, 108, 111, 44, 32, 97, 114, 114, 97, 115, 116, 101, 32, 117, 109, 32, 115, 101, 103, 109, 101, 110,
+116, 111, 32, 112, 97, 114, 97, 32, 99, 117, 114, 118, 195, 161, 45, 108, 111, 46, 34, 10, 34, 76, 111, 119,
+32, 107, 101, 121, 58, 32, 116, 104, 101, 32, 108, 111, 119, 101, 115, 116, 32, 110, 111, 116, 101, 32, 116, 104,
+105, 115, 32, 97, 114, 116, 105, 99, 117, 108, 97, 116, 111, 114, 32, 119, 111, 114, 107, 115, 32, 111, 110, 34,
+32, 61, 32, 34, 84, 101, 99, 108, 97, 32, 98, 97, 105, 120, 97, 58, 32, 97, 32, 110, 111, 116, 97, 32,
+109, 97, 105, 115, 32, 103, 114, 97, 118, 101, 32, 101, 109, 32, 113, 117, 101, 32, 101, 115, 116, 101, 32, 97,
+114, 116, 105, 99, 117, 108, 97, 100, 111, 114, 32, 97, 116, 117, 97, 34, 10, 34, 72, 105, 103, 104, 32, 107,
+101, 121, 58, 32, 116, 104, 101, 32, 104, 105, 103, 104, 101, 115, 116, 32, 110, 111, 116, 101, 32, 116, 104, 105,
+115, 32, 97, 114, 116, 105, 99, 117, 108, 97, 116, 111, 114, 32, 119, 111, 114, 107, 115, 32, 111, 110, 34, 32,
+61, 32, 34, 84, 101, 99, 108, 97, 32, 97, 108, 116, 97, 58, 32, 97, 32, 110, 111, 116, 97, 32, 109, 97,
+105, 115, 32, 97, 103, 117, 100, 97, 32, 101, 109, 32, 113, 117, 101, 32, 101, 115, 116, 101, 32, 97, 114, 116,
+105, 99, 117, 108, 97, 100, 111, 114, 32, 97, 116, 117, 97, 34, 10, 34, 66, 97, 115, 101, 32, 108, 101, 118,
+101, 108, 34, 32, 61, 32, 34, 78, 195, 173, 118, 101, 108, 32, 98, 97, 115, 101, 34, 10, 34, 69, 110, 118,
+101, 108, 111, 112, 101, 32, 108, 101, 118, 101, 108, 34, 32, 61, 32, 34, 78, 195, 173, 118, 101, 108, 32, 100,
+111, 32, 101, 110, 118, 101, 108, 111, 112, 101, 34, 10, 34, 76, 70, 79, 32, 108, 101, 118, 101, 108, 34, 32,
+61, 32, 34, 78, 195, 173, 118, 101, 108, 32, 100, 111, 32, 76, 70, 79, 34, 10, 34, 65, 116, 116, 97, 99,
+107, 58, 32, 115, 99, 97, 108, 101, 115, 32, 116, 104, 101, 32, 116, 105, 109, 101, 32, 117, 112, 32, 116, 111,
+32, 116, 104, 101, 32, 100, 101, 99, 97, 121, 32, 112, 111, 105, 110, 116, 34, 32, 61, 32, 34, 65, 116, 97,
+113, 117, 101, 58, 32, 101, 115, 99, 97, 108, 97, 32, 111, 32, 116, 101, 109, 112, 111, 32, 97, 116, 195, 169,
+32, 111, 32, 112, 111, 110, 116, 111, 32, 100, 101, 32, 100, 101, 99, 97, 105, 109, 101, 110, 116, 111, 34, 10,
+34, 68, 101, 99, 97, 121, 58, 32, 115, 99, 97, 108, 101, 115, 32, 116, 104, 101, 32, 116, 105, 109, 101, 32,
+117, 112, 32, 116, 111, 32, 116, 104, 101, 32, 115, 117, 115, 116, 97, 105, 110, 32, 112, 111, 105, 110, 116, 34,
+32, 61, 32, 34, 68, 101, 99, 97, 105, 109, 101, 110, 116, 111, 58, 32, 101, 115, 99, 97, 108, 97, 32, 111,
+32, 116, 101, 109, 112, 111, 32, 97, 116, 195, 169, 32, 111, 32, 112, 111, 110, 116, 111, 32, 100, 101, 32, 115,
+117, 115, 116, 101, 110, 116, 97, 195, 167, 195, 163, 111, 34, 10, 34, 83, 117, 115, 116, 97, 105, 110, 58, 32,
+114, 97, 105, 115, 101, 115, 32, 111, 114, 32, 108, 111, 119, 101, 114, 115, 32, 116, 104, 101, 32, 115, 117, 115,
+116, 97, 105, 110, 32, 108, 101, 118, 101, 108, 34, 32, 61, 32, 34, 83, 117, 115, 116, 101, 110, 116, 97, 195,
+167, 195, 163, 111, 58, 32, 115, 111, 98, 101, 32, 111, 117, 32, 100, 101, 115, 99, 101, 32, 111, 32, 110, 195,
+173, 118, 101, 108, 32, 100, 101, 32, 115, 117, 115, 116, 101, 110, 116, 97, 195, 167, 195, 163, 111, 34, 10, 34,
+82, 101, 108, 101, 97, 115, 101, 58, 32, 115, 99, 97, 108, 101, 115, 32, 116, 104, 101, 32, 116, 105, 109, 101,
+32, 97, 102, 116, 101, 114, 32, 116, 104, 101, 32, 115, 117, 115, 116, 97, 105, 110, 32, 112, 111, 105, 110, 116,
+34, 32, 61, 32, 34, 76, 105, 98, 101, 114, 97, 195, 167, 195, 163, 111, 58, 32, 101, 115, 99, 97, 108, 97,
+32, 111, 32, 116, 101, 109, 112, 111, 32, 100, 101, 112, 111, 105, 115, 32, 100, 111, 32, 112, 111, 110, 116, 111,
+32, 100, 101, 32, 115, 117, 115, 116, 101, 110, 116, 97, 195, 167, 195, 163, 111, 34, 10, 34, 76, 89, 78, 88,
+32, 107, 101, 101, 112, 115, 32, 116, 104, 105, 115, 32, 112, 108, 117, 103, 105, 110, 39, 115, 32, 115, 101, 116,
+116, 105, 110, 103, 115, 32, 40, 102, 114, 111, 109, 32, 70, 76, 32, 83, 116, 117, 100, 105, 111, 41, 32, 97,
+110, 100, 32, 112, 97, 115, 115, 101, 115, 32, 105, 116, 115, 32, 110, 111, 116, 101, 115, 32, 116, 104, 114, 111,
+117, 103, 104, 32, 117, 110, 99, 104, 97, 110, 103, 101, 100, 46, 34, 32, 61, 32, 34, 79, 32, 76, 89, 78,
+88, 32, 103, 117, 97, 114, 100, 97, 32, 97, 115, 32, 99, 111, 110, 102, 105, 103, 117, 114, 97, 195, 167, 195,
+181, 101, 115, 32, 100, 101, 115, 116, 101, 32, 112, 108, 117, 103, 105, 110, 32, 40, 100, 111, 32, 70, 76, 32,
+83, 116, 117, 100, 105, 111, 41, 32, 101, 32, 100, 101, 105, 120, 97, 32, 97, 115, 32, 110, 111, 116, 97, 115,
+32, 112, 97, 115, 115, 97, 114, 101, 109, 32, 115, 101, 109, 32, 109, 117, 100, 97, 110, 195, 167, 97, 46, 34,
+10, 34, 77, 97, 112, 115, 32, 101, 97, 99, 104, 32, 112, 108, 97, 121, 101, 100, 32, 110, 111, 116, 101, 32,
+116, 111, 32, 111, 116, 104, 101, 114, 32, 110, 111, 116, 101, 115, 58, 32, 116, 114, 97, 110, 115, 112, 111, 115,
+101, 44, 32, 115, 99, 97, 108, 101, 115, 44, 32, 99, 104, 111, 114, 100, 115, 34, 32, 61, 32, 34, 77, 97,
+112, 101, 105, 97, 32, 99, 97, 100, 97, 32, 110, 111, 116, 97, 32, 116, 111, 99, 97, 100, 97, 32, 112, 97,
+114, 97, 32, 111, 117, 116, 114, 97, 115, 32, 110, 111, 116, 97, 115, 58, 32, 116, 114, 97, 110, 115, 112, 111,
+114, 44, 32, 101, 115, 99, 97, 108, 97, 115, 44, 32, 97, 99, 111, 114, 100, 101, 115, 34, 10, 34, 83, 101,
+110, 100, 115, 32, 101, 97, 99, 104, 32, 110, 111, 116, 101, 32, 99, 111, 108, 111, 117, 114, 32, 116, 111, 32,
+105, 116, 115, 32, 111, 119, 110, 32, 118, 111, 105, 99, 101, 32, 111, 117, 116, 112, 117, 116, 34, 32, 61, 32,
+34, 77, 97, 110, 100, 97, 32, 99, 97, 100, 97, 32, 99, 111, 114, 32, 100, 101, 32, 110, 111, 116, 97, 32,
+112, 97, 114, 97, 32, 97, 32, 115, 117, 97, 32, 112, 114, 195, 179, 112, 114, 105, 97, 32, 115, 97, 195, 173,
+100, 97, 32, 100, 101, 32, 118, 111, 122, 34, 10, 34, 69, 110, 118, 101, 108, 111, 112, 101, 115, 32, 97, 110,
+100, 32, 76, 70, 79, 115, 32, 111, 110, 32, 116, 104, 101, 32, 110, 111, 116, 101, 115, 39, 32, 118, 101, 108,
+111, 99, 105, 116, 121, 44, 32, 112, 105, 116, 99, 104, 44, 32, 112, 97, 110, 32, 97, 110, 100, 32, 77, 111,
+100, 32, 88, 32, 47, 32, 89, 34, 32, 61, 32, 34, 69, 110, 118, 101, 108, 111, 112, 101, 115, 32, 101, 32,
+76, 70, 79, 115, 32, 110, 97, 32, 118, 101, 108, 111, 99, 105, 100, 97, 100, 101, 44, 32, 97, 108, 116, 117,
+114, 97, 44, 32, 112, 97, 110, 32, 101, 32, 77, 111, 100, 32, 88, 32, 47, 32, 89, 32, 100, 97, 115, 32,
+110, 111, 116, 97, 115, 34, 10, 34, 83, 112, 108, 105, 116, 115, 32, 116, 104, 101, 32, 107, 101, 121, 98, 111,
+97, 114, 100, 32, 97, 110, 100, 32, 116, 104, 101, 32, 118, 101, 108, 111, 99, 105, 116, 121, 32, 105, 110, 116,
+111, 32, 122, 111, 110, 101, 115, 44, 32, 111, 110, 101, 32, 111, 117, 116, 112, 117, 116, 32, 101, 97, 99, 104,
+34, 32, 61, 32, 34, 68, 105, 118, 105, 100, 101, 32, 111, 32, 116, 101, 99, 108, 97, 100, 111, 32, 101, 32,
+97, 32, 118, 101, 108, 111, 99, 105, 100, 97, 100, 101, 32, 101, 109, 32, 122, 111, 110, 97, 115, 44, 32, 117,
+109, 97, 32, 115, 97, 195, 173, 100, 97, 32, 112, 97, 114, 97, 32, 99, 97, 100, 97, 34, 10, 34, 82, 101,
+115, 104, 97, 112, 101, 115, 32, 116, 104, 101, 32, 110, 111, 116, 101, 115, 39, 32, 118, 101, 108, 111, 99, 105,
+116, 121, 44, 32, 114, 101, 108, 101, 97, 115, 101, 44, 32, 102, 105, 110, 101, 32, 112, 105, 116, 99, 104, 44,
+32, 112, 97, 110, 32, 97, 110, 100, 32, 77, 111, 100, 32, 88, 32, 47, 32, 89, 34, 32, 61, 32, 34, 82,
+101, 109, 111, 100, 101, 108, 97, 32, 97, 32, 118, 101, 108, 111, 99, 105, 100, 97, 100, 101, 44, 32, 108, 105,
+98, 101, 114, 97, 195, 167, 195, 163, 111, 44, 32, 97, 102, 105, 110, 97, 195, 167, 195, 163, 111, 32, 102, 105,
+110, 97, 44, 32, 112, 97, 110, 32, 101, 32, 77, 111, 100, 32, 88, 32, 47, 32, 89, 32, 100, 97, 115, 32,
+110, 111, 116, 97, 115, 34, 10, 34, 80, 108, 97, 121, 115, 32, 115, 116, 101, 112, 32, 112, 97, 116, 116, 101,
+114, 110, 115, 32, 97, 110, 100, 32, 97, 114, 112, 101, 103, 103, 105, 111, 115, 32, 102, 114, 111, 109, 32, 116,
+104, 101, 32, 104, 101, 108, 100, 32, 110, 111, 116, 101, 115, 34, 32, 61, 32, 34, 84, 111, 99, 97, 32, 112,
+97, 100, 114, 195, 181, 101, 115, 32, 100, 101, 32, 112, 97, 115, 115, 111, 115, 32, 101, 32, 97, 114, 112, 101,
+106, 111, 115, 32, 99, 111, 109, 32, 97, 115, 32, 110, 111, 116, 97, 115, 32, 115, 101, 103, 117, 114, 97, 100,
+97, 115, 34, 10, 34, 70, 76, 39, 115, 32, 80, 121, 116, 104, 111, 110, 32, 110, 111, 116, 101, 32, 115, 99,
+114, 105, 112, 116, 115, 34, 32, 61, 32, 34, 83, 99, 114, 105, 112, 116, 115, 32, 100, 101, 32, 110, 111, 116,
+97, 115, 32, 101, 109, 32, 80, 121, 116, 104, 111, 110, 32, 100, 111, 32, 70, 76, 34, 10, 34, 80, 114, 101,
+115, 101, 116, 115, 58, 32, 76, 89, 78, 88, 39, 115, 32, 111, 119, 110, 32, 97, 110, 100, 44, 32, 119, 105,
+116, 104, 32, 70, 76, 32, 83, 116, 117, 100, 105, 111, 32, 105, 110, 115, 116, 97, 108, 108, 101, 100, 44, 32,
+70, 76, 39, 115, 32, 102, 97, 99, 116, 111, 114, 121, 32, 112, 114, 101, 115, 101, 116, 115, 34, 32, 61, 32,
+34, 80, 114, 101, 115, 101, 116, 115, 58, 32, 111, 115, 32, 100, 111, 32, 76, 89, 78, 88, 32, 101, 44, 32,
+99, 111, 109, 32, 111, 32, 70, 76, 32, 83, 116, 117, 100, 105, 111, 32, 105, 110, 115, 116, 97, 108, 97, 100,
+111, 44, 32, 111, 115, 32, 100, 101, 32, 102, 195, 161, 98, 114, 105, 99, 97, 32, 100, 111, 32, 70, 76, 34,
+10, 34, 79, 117, 116, 112, 117, 116, 32, 112, 111, 114, 116, 58, 32, 111, 117, 116, 112, 117, 116, 32, 49, 32,
+103, 111, 101, 115, 32, 111, 117, 116, 32, 111, 110, 32, 116, 104, 105, 115, 32, 77, 73, 68, 73, 32, 112, 111,
+114, 116, 44, 32, 111, 117, 116, 112, 117, 116, 32, 50, 32, 111, 110, 32, 116, 104, 101, 32, 110, 101, 120, 116,
+32, 111, 110, 101, 226, 128, 166, 59, 32, 116, 104, 101, 32, 112, 108, 117, 103, 105, 110, 115, 32, 97, 110, 100,
+32, 80, 97, 116, 99, 104, 101, 114, 115, 32, 116, 104, 97, 116, 32, 116, 97, 107, 101, 32, 116, 104, 97, 116,
+32, 112, 111, 114, 116, 32, 112, 108, 97, 121, 32, 105, 116, 34, 32, 61, 32, 34, 80, 111, 114, 116, 97, 32,
+100, 101, 32, 115, 97, 195, 173, 100, 97, 58, 32, 97, 32, 115, 97, 195, 173, 100, 97, 32, 49, 32, 115, 97,
+105, 32, 110, 101, 115, 116, 97, 32, 112, 111, 114, 116, 97, 32, 77, 73, 68, 73, 44, 32, 97, 32, 115, 97,
+195, 173, 100, 97, 32, 50, 32, 110, 97, 32, 115, 101, 103, 117, 105, 110, 116, 101, 226, 128, 166, 59, 32, 111,
+115, 32, 112, 108, 117, 103, 105, 110, 115, 32, 101, 32, 80, 97, 116, 99, 104, 101, 114, 115, 32, 113, 117, 101,
+32, 114, 101, 99, 101, 98, 101, 109, 32, 101, 115, 115, 97, 32, 112, 111, 114, 116, 97, 32, 116, 111, 99, 97,
+109, 32, 111, 32, 113, 117, 101, 32, 99, 104, 101, 103, 97, 34, 10, 34, 83, 101, 116, 115, 32, 97, 32, 112,
+108, 117, 103, 105, 110, 32, 99, 104, 97, 110, 110, 101, 108, 39, 115, 32, 77, 73, 68, 73, 32, 105, 110, 112,
+117, 116, 32, 112, 111, 114, 116, 32, 116, 111, 32, 116, 104, 105, 115, 32, 112, 111, 114, 116, 44, 32, 115, 111,
+32, 105, 116, 32, 112, 108, 97, 121, 115, 32, 119, 104, 97, 116, 32, 116, 104, 105, 115, 32, 99, 104, 97, 110,
+110, 101, 108, 32, 115, 101, 110, 100, 115, 34, 32, 61, 32, 34, 68, 101, 102, 105, 110, 101, 32, 97, 32, 112,
+111, 114, 116, 97, 32, 100, 101, 32, 101, 110, 116, 114, 97, 100, 97, 32, 77, 73, 68, 73, 32, 100, 101, 32,
+117, 109, 32, 99, 97, 110, 97, 108, 32, 100, 101, 32, 112, 108, 117, 103, 105, 110, 32, 112, 97, 114, 97, 32,
+101, 115, 116, 97, 32, 112, 111, 114, 116, 97, 44, 32, 112, 97, 114, 97, 32, 101, 108, 101, 32, 116, 111, 99,
+97, 114, 32, 111, 32, 113, 117, 101, 32, 101, 115, 116, 101, 32, 99, 97, 110, 97, 108, 32, 109, 97, 110, 100,
+97, 34, 10, 34, 86, 70, 88, 32, 40, 110, 111, 116, 101, 32, 101, 102, 102, 101, 99, 116, 115, 41, 34, 32,
+61, 32, 34, 86, 70, 88, 32, 40, 101, 102, 101, 105, 116, 111, 115, 32, 100, 101, 32, 110, 111, 116, 97, 41,
+34, 10,
 };
 } // namespace lynx::i18n::data

+ 8 - 1
src/ui/PatcherEditor.cpp

@@ -823,8 +823,15 @@ private:
         {
             const auto kind = vfx::kindOf (node.channel);
             const auto shown = kind ? patcher::shownMidiOutputs (d, n) : 1;
+            std::optional<vfx::KeyboardSplitterSettings> zones; // (the Keyboard Splitter's outputs carry the zones' names)
+            if (kind == vfx::Kind::keyboardSplitter)
+                if (const auto st = vfx::readState (node.channel.pluginState))
+                    zones = vfx::parseKeyboardSplitter (st->fl);
             for (int o = 0; o < shown; ++o)
-                add (true, PatchWire::Kind::midi, o, kind ? juce::String (vfx::outputName (*kind, o)) : tr ("MIDI out"));
+                add (true, PatchWire::Kind::midi, o,
+                     zones && o < 16 && ! zones->zones[(std::size_t) o].name.empty() ? juce::String::fromUTF8 (zones->zones[(std::size_t) o].name.c_str())
+                     : kind ? juce::String (vfx::outputName (*kind, o))
+                            : tr ("MIDI out"));
         }
         for (int i = 0; i < ports.audioIns; ++i)
             add (false, PatchWire::Kind::audio, i, i == 0 ? tr ("In") : tr ("Side-chain"));

+ 670 - 0
src/ui/VfxEditors.cpp

@@ -654,6 +654,674 @@ private:
     juce::Rectangle<float> graph;
 };
 
+// ---------------------------------------------------------------------------------------------------------------
+// An FL mapping / envelope curve, edited with the mouse: drag a point, double-click to add one, right-click a point to
+// remove it, drag a segment up or down to bend it; Alt+click a segment straightens it
+
+class CurveEditor final : public juce::Component
+{
+public:
+    std::function<void (const vfx::MapCurve&)> onChange;
+    std::function<void (juce::Graphics&, juce::Rectangle<float>, double xMax)> drawGrid; // under the curves
+    std::vector<std::pair<vfx::MapCurve, juce::Colour>> behind;                          // other curves, faint
+    double fixedXMax = 0.0;  // > 0: the x range (maps: 1); else it follows the curve (envelopes)
+    bool bipolar = false;    // a centre line
+    int sustainPoint = -1, loopPoint = -1;
+    juce::Colour colour = theme::colour::accent;
+    float marker = -1.0f;    // a vertical line (x), e.g. the last note
+
+    void setCurve (const vfx::MapCurve& c)
+    {
+        if (dragging < 0 && bending < 0)
+            curve = c;
+        repaint();
+    }
+
+    void paint (juce::Graphics& g) override
+    {
+        const auto area = plot();
+        g.setColour (theme::colour::bg0);
+        g.fillRoundedRectangle (area, 4.0f);
+        const auto xMax = range();
+        if (drawGrid)
+            drawGrid (g, area, xMax);
+        if (bipolar)
+        {
+            g.setColour (theme::colour::borderStrong);
+            g.drawHorizontalLine ((int) area.getCentreY(), area.getX(), area.getRight());
+        }
+        for (const auto& [c, col] : behind)
+            stroke (g, c, col.withAlpha (0.35f), 1.2f, false);
+        stroke (g, curve, colour, 2.2f, true);
+        for (int i = 0; i < (int) curve.points.size(); ++i)
+        {
+            const auto p = toScreen (curve.points[(std::size_t) i]);
+            const auto r = i == hover || i == dragging ? 5.5f : 4.0f;
+            g.setColour (theme::colour::bg0);
+            g.fillEllipse (juce::Rectangle<float> (r * 2.0f + 2.0f, r * 2.0f + 2.0f).withCentre (p));
+            g.setColour (i == sustainPoint ? theme::colour::warning : colour);
+            g.fillEllipse (juce::Rectangle<float> (r * 2.0f, r * 2.0f).withCentre (p));
+        }
+        if (sustainPoint >= 0 && sustainPoint < (int) curve.points.size())
+        {
+            const auto x = toScreen (curve.points[(std::size_t) sustainPoint]).x;
+            g.setColour (theme::colour::warning.withAlpha (0.6f));
+            g.drawVerticalLine ((int) x, area.getY(), area.getBottom());
+            g.setFont (theme::font (theme::type::caption));
+            g.drawText (tr ("sustain"), juce::Rectangle<float> (x + 3.0f, area.getY() + 2.0f, 60.0f, 14.0f), juce::Justification::centredLeft);
+        }
+        if (marker >= 0.0f && marker <= xMax)
+        {
+            g.setColour (theme::colour::textPrimary.withAlpha (0.7f));
+            const auto x = area.getX() + (float) (marker / xMax) * area.getWidth();
+            g.drawVerticalLine ((int) x, area.getY(), area.getBottom());
+        }
+        g.setColour (theme::colour::borderStrong);
+        g.drawRoundedRectangle (area, 4.0f, 1.0f);
+    }
+
+    void mouseMove (const juce::MouseEvent& e) override
+    {
+        const auto h = pointAt (e.position);
+        if (h != hover)
+        {
+            hover = h;
+            repaint();
+        }
+    }
+    void mouseExit (const juce::MouseEvent&) override
+    {
+        hover = -1;
+        repaint();
+    }
+
+    void mouseDown (const juce::MouseEvent& e) override
+    {
+        const auto at = pointAt (e.position);
+        if (e.mods.isPopupMenu())
+        {
+            if (at > 0 && at < (int) curve.points.size() - 1 && curve.points.size() > 2)
+            {
+                curve.points.erase (curve.points.begin() + at);
+                hover = -1;
+                commit();
+            }
+            return;
+        }
+        if (at >= 0)
+        {
+            dragging = at;
+            return;
+        }
+        const auto seg = segmentAt (e.position.x);
+        if (seg > 0 && e.mods.isAltDown())
+        {
+            curve.points[(std::size_t) seg].tension = 0.0f;
+            curve.points[(std::size_t) seg].b15 = 2;
+            commit();
+            return;
+        }
+        if (seg > 0)
+        {
+            bending = seg;
+            bendStart = curve.points[(std::size_t) seg].tension;
+        }
+    }
+
+    void mouseDrag (const juce::MouseEvent& e) override
+    {
+        const auto area = plot();
+        if (dragging >= 0)
+        {
+            auto& p = curve.points[(std::size_t) dragging];
+            const auto xMax = range();
+            auto x = (double) ((e.position.x - area.getX()) / area.getWidth()) * xMax;
+            const auto lo = dragging == 0 ? 0.0 : curve.points[(std::size_t) dragging - 1].x;
+            const auto hi = dragging + 1 < (int) curve.points.size() ? curve.points[(std::size_t) dragging + 1].x : (fixedXMax > 0.0 ? fixedXMax : 1.0e4);
+            p.x = dragging == 0 ? 0.0 : std::clamp (x, lo, hi);
+            p.y = std::clamp ((double) ((area.getBottom() - e.position.y) / area.getHeight()), 0.0, 1.0);
+            if (e.mods.isShiftDown()) // (snap the level to 1/8)
+                p.y = std::round (p.y * 8.0) / 8.0;
+            commit();
+        }
+        else if (bending > 0)
+        {
+            auto& p = curve.points[(std::size_t) bending];
+            const auto rising = p.y >= curve.points[(std::size_t) bending - 1].y;
+            const auto dy = (float) -e.getDistanceFromDragStartY() / 120.0f;
+            p.tension = std::clamp (bendStart + (rising ? -dy : dy), -1.0f, 1.0f);
+            p.b15 = p.tension == 0.0f ? 2 : p.tension > 0.0f ? 1 : 0xff;
+            commit();
+        }
+    }
+    void mouseUp (const juce::MouseEvent&) override
+    {
+        dragging = bending = -1;
+    }
+    void mouseDoubleClick (const juce::MouseEvent& e) override
+    {
+        if (pointAt (e.position) >= 0)
+            return;
+        const auto area = plot();
+        const auto x = (double) ((e.position.x - area.getX()) / area.getWidth()) * range();
+        const auto y = std::clamp ((double) ((area.getBottom() - e.position.y) / area.getHeight()), 0.0, 1.0);
+        auto at = curve.points.begin();
+        while (at != curve.points.end() && at->x <= x)
+            ++at;
+        if (at == curve.points.begin())
+            return;
+        curve.points.insert (at, vfx::MapCurve::Point { x, y });
+        commit();
+    }
+
+private:
+    juce::Rectangle<float> plot() const { return getLocalBounds().toFloat().reduced (2.0f, 2.0f); }
+    double range() const
+    {
+        if (fixedXMax > 0.0)
+            return fixedXMax;
+        const auto last = curve.points.empty() ? 1.0 : curve.points.back().x;
+        return std::max (1.0, std::ceil (last * 1.25 * 4.0) / 4.0);
+    }
+    juce::Point<float> toScreen (const vfx::MapCurve::Point& p) const
+    {
+        const auto area = plot();
+        return { area.getX() + (float) (p.x / range()) * area.getWidth(), area.getBottom() - (float) p.y * area.getHeight() };
+    }
+    int pointAt (juce::Point<float> at) const
+    {
+        for (int i = (int) curve.points.size() - 1; i >= 0; --i)
+            if (toScreen (curve.points[(std::size_t) i]).getDistanceFrom (at) < 8.0f)
+                return i;
+        return -1;
+    }
+    int segmentAt (float sx) const
+    {
+        for (int i = 1; i < (int) curve.points.size(); ++i)
+            if (sx >= toScreen (curve.points[(std::size_t) i - 1]).x && sx < toScreen (curve.points[(std::size_t) i]).x)
+                return i;
+        return -1;
+    }
+    void stroke (juce::Graphics& g, const vfx::MapCurve& c, juce::Colour col, float width, bool fill) const
+    {
+        if (c.points.empty())
+            return;
+        const auto area = plot();
+        const auto xMax = range();
+        juce::Path path;
+        const auto steps = (int) area.getWidth() / 2;
+        for (int k = 0; k <= steps; ++k)
+        {
+            const auto x = xMax * k / steps;
+            const juce::Point<float> p (area.getX() + area.getWidth() * (float) k / (float) steps, area.getBottom() - (float) c.at (x) * area.getHeight());
+            if (k == 0)
+                path.startNewSubPath (p);
+            else
+                path.lineTo (p);
+        }
+        if (fill)
+        {
+            juce::Path under (path);
+            under.lineTo (area.getBottomRight());
+            under.lineTo (area.getBottomLeft());
+            under.closeSubPath();
+            g.setColour (col.withAlpha (0.12f));
+            g.fillPath (under);
+        }
+        g.setColour (col);
+        g.strokePath (path, juce::PathStrokeType (width));
+    }
+    void commit()
+    {
+        repaint();
+        if (onChange)
+            onChange (curve);
+    }
+
+    vfx::MapCurve curve;
+    int hover = -1, dragging = -1, bending = -1;
+    float bendStart = 0.0f;
+};
+
+// ---------------------------------------------------------------------------------------------------------------
+// VFX Keyboard Splitter: the zones, a page per map (keyboard, velocity), the current zone's map over the others
+
+juce::Colour zoneColour (int z)
+{
+    return juce::Colour::fromHSV (std::fmod ((float) z * 2.5f / 16.0f, 1.0f), 0.62f, 0.95f, 1.0f);
+}
+
+class KeyboardSplitterBody final : public Body
+{
+public:
+    using S = vfx::KeyboardSplitterSettings;
+
+    KeyboardSplitterBody()
+    {
+        for (int z = 0; z < 16; ++z)
+        {
+            auto& b = zoneButtons[(std::size_t) z];
+            b.setButtonText (juce::String (z + 1));
+            b.setClickingTogglesState (false);
+            b.onClick = [this, z] {
+                zone = z;
+                refreshControls();
+            };
+            addAndMakeVisible (b);
+        }
+        for (int p = 0; p < 2; ++p)
+        {
+            auto& b = pages[(std::size_t) p];
+            b.setButtonText (p == 0 ? tr ("Keyboard") : tr ("Velocity"));
+            b.setClickingTogglesState (false);
+            b.setColour (juce::TextButton::buttonOnColourId, theme::colour::accentMuted);
+            b.onClick = [this, p] { change ([p] (S& st) { st.page = p; }); };
+            addAndMakeVisible (b);
+        }
+        name.setTextToShowWhenEmpty (tr ("Zone {0}", { "1" }), theme::colour::textDisabled);
+        name.onReturnKey = name.onFocusLost = [this] {
+            change ([z = zone, text = name.getText().trim().toStdString()] (S& st) { st.zones[(std::size_t) z].name = text; });
+        };
+        ui::setHint (name, tr ("The zone's name (its output's name in the Patcher)"));
+        addAndMakeVisible (name);
+        flag.onClick = [this] {
+            change ([z = zone, on = flag.getToggleState()] (S& st) {
+                auto& zn = st.zones[(std::size_t) z];
+                (st.page == 0 ? zn.random : zn.absolute) = on;
+            });
+        };
+        addAndMakeVisible (flag);
+        transpose.caption = tr ("Transpose");
+        addAndMakeVisible (transpose);
+        for (auto [label, make] : std::initializer_list<std::pair<const char*, int>> { { TR_NOOP ("Whole keyboard"), 0 }, { TR_NOOP ("Clear"), 1 } })
+        {
+            auto* b = make == 0 ? &whole : &clear;
+            b->setButtonText (tr (label));
+            b->onClick = [this, make = make] {
+                change ([z = zone, make] (S& st) {
+                    auto& curve = st.page == 0 ? st.zones[(std::size_t) z].keyboard : st.zones[(std::size_t) z].velocity;
+                    curve = vfx::MapCurve::flat (make == 0 ? 1.0 : (st.page == 0 ? 0.0 : 1.0));
+                });
+            };
+            addAndMakeVisible (b);
+        }
+        ui::setHint (whole, tr ("The whole range at full level"));
+        ui::setHint (clear, tr ("Back to the map's default (the zone is off when both maps are)"));
+        editor.fixedXMax = 1.0;
+        editor.onChange = [this] (const vfx::MapCurve& c) {
+            change ([z = zone, c] (S& st) { (st.page == 0 ? st.zones[(std::size_t) z].keyboard : st.zones[(std::size_t) z].velocity) = c; });
+        };
+        editor.drawGrid = [this] (juce::Graphics& g, juce::Rectangle<float> area, double) {
+            g.setFont (theme::font (theme::type::caption));
+            if (settings.page == 0) // octaves: C0 … C10 (x = key / 132)
+                for (int key = 0; key <= 132; key += 12)
+                {
+                    const auto x = area.getX() + area.getWidth() * (float) key / 132.0f;
+                    g.setColour (theme::colour::border);
+                    g.drawVerticalLine ((int) x, area.getY(), area.getBottom());
+                    g.setColour (theme::colour::textSecondary);
+                    if (key < 132)
+                        g.drawText ("C" + juce::String (key / 12), juce::Rectangle<float> (x + 3.0f, area.getBottom() - 16.0f, 40.0f, 14.0f), juce::Justification::centredLeft);
+                }
+            else
+                for (int q = 1; q < 4; ++q)
+                {
+                    g.setColour (theme::colour::border);
+                    g.drawVerticalLine ((int) (area.getX() + area.getWidth() * (float) q / 4.0f), area.getY(), area.getBottom());
+                }
+            for (int q = 1; q < 4; ++q)
+            {
+                g.setColour (theme::colour::border.withAlpha (0.5f));
+                g.drawHorizontalLine ((int) (area.getY() + area.getHeight() * (float) q / 4.0f), area.getX(), area.getRight());
+            }
+        };
+        addAndMakeVisible (editor);
+    }
+
+    void refresh (const std::vector<std::uint8_t>& fl) override
+    {
+        settings = vfx::parseKeyboardSplitter (fl).value_or (vfx::defaultKeyboardSplitter());
+        refreshControls();
+    }
+
+    int preferredHeight() const override { return 400; }
+    int preferredWidth() const override { return 860; }
+
+    void resized() override
+    {
+        auto area = getLocalBounds().reduced (12, 6);
+        auto top = area.removeFromTop (30);
+        for (auto& b : zoneButtons)
+            b.setBounds (top.removeFromLeft (30).reduced (1, 0));
+        top.removeFromLeft (12);
+        name.setBounds (top.removeFromLeft (150).reduced (0, 2));
+        top.removeFromLeft (12);
+        for (auto& b : pages)
+            b.setBounds (top.removeFromLeft (84).reduced (1, 0));
+        area.removeFromTop (6);
+        auto row = area.removeFromTop (64);
+        transpose.setBounds (row.removeFromLeft (70));
+        row.removeFromLeft (10);
+        flag.setBounds (row.removeFromLeft (220).withSizeKeepingCentre (220, 24));
+        clear.setBounds (row.removeFromRight (90).withSizeKeepingCentre (90, 26));
+        row.removeFromRight (6);
+        whole.setBounds (row.removeFromRight (130).withSizeKeepingCentre (130, 26));
+        area.removeFromTop (6);
+        editor.setBounds (area);
+    }
+
+private:
+    void refreshControls()
+    {
+        const auto& z = settings.zones[(std::size_t) zone];
+        for (int k = 0; k < 16; ++k)
+        {
+            auto& b = zoneButtons[(std::size_t) k];
+            const auto active = settings.zones[(std::size_t) k].active();
+            b.setColour (juce::TextButton::buttonColourId, active ? zoneColour (k).withAlpha (0.55f) : theme::colour::bg3);
+            b.setColour (juce::TextButton::buttonOnColourId, zoneColour (k));
+            b.setColour (juce::TextButton::textColourOffId, active ? theme::colour::textPrimary : theme::colour::textDisabled);
+            b.setToggleState (k == zone, juce::dontSendNotification);
+        }
+        for (int p = 0; p < 2; ++p)
+            pages[(std::size_t) p].setToggleState (p == settings.page, juce::dontSendNotification);
+        if (! name.hasKeyboardFocus (true))
+            name.setText (juce::String::fromUTF8 (z.name.c_str()), juce::dontSendNotification);
+        name.setTextToShowWhenEmpty (tr ("Zone {0}", { juce::String (zone + 1) }), theme::colour::textDisabled);
+        const auto keyboard = settings.page == 0;
+        flag.setButtonText (keyboard ? tr ("Random (the map is a probability)") : tr ("Absolute (the map sets the volume)"));
+        ui::setHint (flag, keyboard ? tr ("Random: each note goes to one of the random zones, picked by their keyboard maps")
+                                    : tr ("Absolute: the velocity map gives the volume instead of scaling the note's"));
+        flag.setToggleState (keyboard ? z.random : z.absolute, juce::dontSendNotification);
+        transpose.setVisible (keyboard);
+        editor.colour = zoneColour (zone);
+        editor.behind.clear();
+        for (int k = 0; k < 16; ++k)
+            if (k != zone && settings.zones[(std::size_t) k].active())
+                editor.behind.emplace_back (keyboard ? settings.zones[(std::size_t) k].keyboard : settings.zones[(std::size_t) k].velocity, zoneColour (k));
+        editor.setCurve (keyboard ? z.keyboard : z.velocity);
+        transpose.repaint();
+        repaint();
+    }
+
+    void change (std::function<void (S&)> f)
+    {
+        if (edit)
+            edit ([f] (std::vector<std::uint8_t>& fl) {
+                auto s = vfx::parseKeyboardSplitter (fl).value_or (vfx::defaultKeyboardSplitter());
+                f (s);
+                fl = vfx::writeKeyboardSplitter (s);
+            });
+    }
+
+    S settings = vfx::defaultKeyboardSplitter();
+    int zone = 0;
+    std::array<juce::TextButton, 16> zoneButtons;
+    std::array<juce::TextButton, 2> pages;
+    juce::TextEditor name;
+    juce::ToggleButton flag;
+    juce::TextButton whole, clear;
+    Knob transpose { intSpec (tr ("Transpose (semitones)"), -48, 48, 0, [] (double v) { return (v > 0 ? "+" : "") + juce::String ((int) std::lround (v)); }),
+                     [this] { return (double) settings.zones[(std::size_t) zone].transpose; },
+                     [this] (double v) { change ([z = zone, v] (S& st) { st.zones[(std::size_t) z].transpose = (int) std::lround (v); }); } };
+    CurveEditor editor;
+};
+
+// ---------------------------------------------------------------------------------------------------------------
+// VFX Envelope: 16 articulators (each for a note colour and key range), 5 targets, an envelope and an LFO each
+
+class EnvelopeBody final : public Body
+{
+public:
+    using E = vfx::EnvelopeSettings;
+
+    EnvelopeBody()
+    {
+        for (int g = 0; g < 16; ++g)
+        {
+            auto& b = articulatorButtons[(std::size_t) g];
+            b.setButtonText (juce::String (g + 1));
+            b.setClickingTogglesState (false);
+            b.setColour (juce::TextButton::buttonOnColourId, theme::colour::accent);
+            b.onClick = [this, g] { change ([g] (E& st) { st.shownArticulator = g; }); };
+            ui::setHint (b, tr ("Articulator {0}", { juce::String (g + 1) }));
+            addAndMakeVisible (b);
+        }
+        static const char* targetNames[] = { TR_NOOP ("Velocity"), TR_NOOP ("Pitch"), TR_NOOP ("Pan"), TR_NOOP ("Mod X"), TR_NOOP ("Mod Y") };
+        for (int t = 0; t < 5; ++t)
+        {
+            auto& b = targets[(std::size_t) t];
+            b.setButtonText (tr (targetNames[t]));
+            b.setClickingTogglesState (false);
+            b.setColour (juce::TextButton::buttonOnColourId, theme::colour::accentMuted);
+            b.onClick = [this, t] { change ([t] (E& st) { st.shownTarget = t; }); };
+            addAndMakeVisible (b);
+        }
+        for (int p = 0; p < 2; ++p)
+        {
+            auto& b = partTabs[(std::size_t) p];
+            b.setButtonText (p == 0 ? tr ("Envelope") : tr ("LFO"));
+            b.setClickingTogglesState (false);
+            b.setColour (juce::TextButton::buttonOnColourId, theme::colour::accentMuted);
+            b.onClick = [this, p] { change ([p] (E& st) { st.shownPart = p; }); };
+            addAndMakeVisible (b);
+        }
+        for (int c = 0; c < 16; ++c)
+            colour.addItem (tr ("Colour {0}", { juce::String (c + 1) }), c + 1);
+        colour.onChange = [this] { changeArticulator ([c = colour.getSelectedId() - 1] (E::Articulator& a) { a.colour = std::max (0, c); }); };
+        ui::setHint (colour, tr ("The note colour this articulator works on (the MIDI channel)"));
+        addAndMakeVisible (colour);
+        enable.setButtonText (tr ("Enable"));
+        enable.onClick = [this] { change ([on = enable.getToggleState()] (E& st) { st.enabled = on; }); };
+        ui::setHint (enable, tr ("Off: the notes pass unchanged"));
+        addAndMakeVisible (enable);
+        partOn.onClick = [this] {
+            changePart ([lfo = settings.shownPart == 1, on = partOn.getToggleState()] (E::Part& p) { (lfo ? p.lfoAmp : p.envelope).footer[1] = on ? -1 : 0; });
+        };
+        addAndMakeVisible (partOn);
+        tempo.setButtonText (tr ("Tempo"));
+        tempo.onClick = [this] {
+            changePart ([lfo = settings.shownPart == 1, on = tempo.getToggleState()] (E::Part& p) {
+                auto& f = (lfo ? p.lfoAmp : p.envelope).footer[0];
+                f = on ? (f | 1) : (f & ~1);
+            });
+        };
+        ui::setHint (tempo, tr ("Tempo: the time in beats (else in seconds)"));
+        addAndMakeVisible (tempo);
+        for (auto* k : { &low, &high, &base, &envLevel, &lfoLevel, &attack, &decay, &sustain, &release, &speed, &lfoTension, &skew, &pulseWidth })
+            addAndMakeVisible (k);
+        low.caption = tr ("Low");
+        high.caption = tr ("High");
+        base.caption = tr ("Base");
+        envLevel.caption = tr ("Env");
+        lfoLevel.caption = tr ("LFO");
+        attack.caption = tr ("Attack");
+        decay.caption = tr ("Decay");
+        sustain.caption = tr ("Sustain");
+        release.caption = tr ("Release");
+        speed.caption = tr ("Speed");
+        lfoTension.caption = tr ("Tension");
+        skew.caption = tr ("Skew");
+        pulseWidth.caption = tr ("Pulse width");
+        editor.onChange = [this] (const vfx::MapCurve& c) {
+            changePart ([lfo = settings.shownPart == 1, c] (E::Part& p) {
+                auto& curve = lfo ? p.lfoAmp : p.envelope;
+                const auto footer = curve.footer;
+                curve = c;
+                curve.footer = footer;
+                // the sustain / decay / loop points stay inside the curve
+                for (const auto k : { 2, 3, 4 })
+                    if (curve.footer[(std::size_t) k] >= (int) curve.points.size())
+                        curve.footer[(std::size_t) k] = (int) curve.points.size() - 1;
+            });
+        };
+        addAndMakeVisible (editor);
+    }
+
+    void refresh (const std::vector<std::uint8_t>& fl) override
+    {
+        settings = vfx::parseEnvelope (fl).value_or (vfx::defaultEnvelope());
+        const auto& a = articulator();
+        const auto& p = part();
+        for (int g = 0; g < 16; ++g)
+        {
+            const auto& ag = settings.articulators[(std::size_t) g];
+            const auto used = std::any_of (ag.parts.begin(), ag.parts.end(), [] (const E::Part& q) { return q.lfoOn() || (q.envOn() && ! neutral (q)); });
+            articulatorButtons[(std::size_t) g].setColour (juce::TextButton::textColourOffId, used ? theme::colour::textPrimary : theme::colour::textDisabled);
+            articulatorButtons[(std::size_t) g].setToggleState (g == settings.shownArticulator, juce::dontSendNotification);
+        }
+        for (int t = 0; t < 5; ++t)
+        {
+            const auto& q = a.parts[(std::size_t) t];
+            targets[(std::size_t) t].setToggleState (t == settings.shownTarget, juce::dontSendNotification);
+            targets[(std::size_t) t].setColour (juce::TextButton::textColourOffId,
+                                                q.lfoOn() || (q.envOn() && ! neutral (q)) ? theme::colour::accent : theme::colour::textPrimary);
+        }
+        for (int k = 0; k < 2; ++k)
+            partTabs[(std::size_t) k].setToggleState (k == settings.shownPart, juce::dontSendNotification);
+        colour.setSelectedId (a.colour + 1, juce::dontSendNotification);
+        enable.setToggleState (settings.enabled, juce::dontSendNotification);
+        const auto lfo = settings.shownPart == 1;
+        const auto& curve = lfo ? p.lfoAmp : p.envelope;
+        partOn.setButtonText (lfo ? tr ("LFO on") : tr ("Envelope on"));
+        partOn.setToggleState (lfo ? p.lfoOn() : p.envOn(), juce::dontSendNotification);
+        tempo.setToggleState ((curve.footer[0] & 1) != 0, juce::dontSendNotification);
+        for (auto* k : { &attack, &decay, &sustain, &release })
+            k->setVisible (! lfo);
+        for (auto* k : { &speed, &lfoTension, &skew, &pulseWidth })
+            k->setVisible (lfo);
+        editor.bipolar = lfo || settings.shownTarget != E::velocity;
+        editor.sustainPoint = curve.footer[4];
+        editor.setCurve (curve);
+        for (auto* c : getChildren())
+            if (dynamic_cast<Knob*> (c) != nullptr)
+                c->repaint();
+        repaint();
+    }
+
+    int preferredHeight() const override { return 470; }
+    int preferredWidth() const override { return 860; }
+
+    void resized() override
+    {
+        auto area = getLocalBounds().reduced (12, 6);
+        auto top = area.removeFromTop (30);
+        for (auto& b : articulatorButtons)
+            b.setBounds (top.removeFromLeft (28).reduced (1, 0));
+        top.removeFromLeft (14);
+        for (auto& b : targets)
+            b.setBounds (top.removeFromLeft (72).reduced (1, 0));
+        enable.setBounds (top.removeFromRight (90));
+        area.removeFromTop (8);
+        auto row = area.removeFromTop (70);
+        auto left = row.removeFromLeft (130);
+        colour.setBounds (left.removeFromTop (26));
+        for (auto* k : { &low, &high })
+            k->setBounds (row.removeFromLeft (62));
+        row.removeFromLeft (14);
+        for (auto* k : { &base, &envLevel, &lfoLevel })
+            k->setBounds (row.removeFromLeft (62));
+        area.removeFromTop (8);
+        auto parts = area.removeFromTop (28);
+        for (auto& b : partTabs)
+            b.setBounds (parts.removeFromLeft (100).reduced (1, 0));
+        parts.removeFromLeft (14);
+        partOn.setBounds (parts.removeFromLeft (140));
+        tempo.setBounds (parts.removeFromLeft (90));
+        area.removeFromTop (6);
+        auto knobs = area.removeFromBottom (70);
+        for (auto* k : { &attack, &decay, &sustain, &release })
+            k->setBounds (knobs.withWidth (62).translated ((int) (k == &attack ? 0 : k == &decay ? 1 : k == &sustain ? 2 : 3) * 66, 0));
+        for (auto* k : { &speed, &lfoTension, &skew, &pulseWidth })
+            k->setBounds (knobs.withWidth (62).translated ((int) (k == &speed ? 0 : k == &lfoTension ? 1 : k == &skew ? 2 : 3) * 66, 0));
+        area.removeFromBottom (6);
+        editor.setBounds (area);
+    }
+
+    void paint (juce::Graphics& g) override
+    {
+        g.setColour (theme::colour::textSecondary);
+        g.setFont (theme::font (theme::type::caption));
+        const auto& p = part();
+        const auto lfo = settings.shownPart == 1;
+        const auto unit = ((lfo ? p.lfoAmp : p.envelope).footer[0] & 1) != 0 ? tr ("beats") : tr ("seconds");
+        g.drawText (tr ("Time in {0}. Drag a point, double-click to add one, right-click to remove it, drag a segment to bend it.", { unit }),
+                    editor.getBounds().translated (0, editor.getHeight() + 2).withHeight (14), juce::Justification::centredLeft);
+    }
+
+private:
+    static bool neutral (const E::Part& p)
+    {
+        return std::all_of (p.envelope.points.begin(), p.envelope.points.end(), [] (const vfx::MapCurve::Point& q) { return std::abs (q.y - 0.5) < 1e-6; })
+               && std::abs (p.base - 0.5f) < 1e-6f;
+    }
+    const E::Articulator& articulator() const { return settings.articulators[(std::size_t) settings.shownArticulator]; }
+    const E::Part& part() const { return articulator().parts[(std::size_t) settings.shownTarget]; }
+
+    void change (std::function<void (E&)> f)
+    {
+        if (edit)
+            edit ([f] (std::vector<std::uint8_t>& fl) {
+                auto s = vfx::parseEnvelope (fl).value_or (vfx::defaultEnvelope());
+                f (s);
+                fl = vfx::writeEnvelope (s);
+            });
+    }
+    void changeArticulator (std::function<void (E::Articulator&)> f)
+    {
+        change ([f] (E& st) { f (st.articulators[(std::size_t) st.shownArticulator]); });
+    }
+    void changePart (std::function<void (E::Part&)> f)
+    {
+        change ([f] (E& st) { f (st.articulators[(std::size_t) st.shownArticulator].parts[(std::size_t) st.shownTarget]); });
+    }
+    Knob partKnob (const juce::String& hint, int lo, int hi, int def, std::function<int& (E::Part&)> field, std::function<juce::String (double)> text = nullptr)
+    {
+        return Knob (intSpec (hint, lo, hi, def, std::move (text)),
+                     [this, field] { auto p = part(); return (double) field (p); },
+                     [this, field] (double v) { changePart ([field, v] (E::Part& p) { field (p) = (int) std::lround (v); }); });
+    }
+    Knob levelKnob (const juce::String& hint, int lo, int hi, int def, float E::Part::*field)
+    {
+        return Knob (intSpec (hint, lo, hi, def, [lo] (double v) { return lo < 0 ? juce::String (v / 2.56, 0) + "%" : juce::String (v / 2.56, 0) + "%"; }),
+                     [this, field] { return (double) std::lround (part().*field * 256.0f); },
+                     [this, field] (double v) { changePart ([field, v] (E::Part& p) { p.*field = (float) (v / 256.0); }); });
+    }
+    static juce::String keyText (double v)
+    {
+        const auto k = (int) std::lround (v) - 1; // (FL stores the key + 1)
+        return k < 0 ? juce::String ("-") : juce::MidiMessage::getMidiNoteName (std::clamp (k, 0, 131), true, true, 0);
+    }
+
+    E settings = vfx::defaultEnvelope();
+    std::array<juce::TextButton, 16> articulatorButtons;
+    std::array<juce::TextButton, 5> targets;
+    std::array<juce::TextButton, 2> partTabs;
+    juce::ComboBox colour;
+    juce::ToggleButton enable, partOn, tempo;
+    Knob low { intSpec (tr ("Low key: the lowest note this articulator works on"), 0, 132, 0, keyText),
+               [this] { return (double) articulator().low; },
+               [this] (double v) { changeArticulator ([v] (E::Articulator& a) { a.low = (int) std::lround (v); a.high = std::max (a.high, a.low); }); } };
+    Knob high { intSpec (tr ("High key: the highest note this articulator works on"), 0, 132, 132, keyText),
+                [this] { return (double) articulator().high; },
+                [this] (double v) { changeArticulator ([v] (E::Articulator& a) { a.high = (int) std::lround (v); a.low = std::min (a.low, a.high); }); } };
+    Knob base = levelKnob (tr ("Base level"), 0, 256, 128, &E::Part::base);
+    Knob envLevel = levelKnob (tr ("Envelope level"), -256, 256, 256, &E::Part::env);
+    Knob lfoLevel = levelKnob (tr ("LFO level"), -256, 256, 256, &E::Part::lfo);
+    Knob attack = partKnob (tr ("Attack: scales the time up to the decay point"), 0, 256, 128, [] (E::Part& p) -> int& { return p.adsr[0]; });
+    Knob decay = partKnob (tr ("Decay: scales the time up to the sustain point"), 0, 256, 128, [] (E::Part& p) -> int& { return p.adsr[1]; });
+    Knob sustain = partKnob (tr ("Sustain: raises or lowers the sustain level"), -256, 256, 0, [] (E::Part& p) -> int& { return p.adsr[2]; });
+    Knob release = partKnob (tr ("Release: scales the time after the sustain point"), 0, 256, 128, [] (E::Part& p) -> int& { return p.adsr[3]; });
+    Knob speed = partKnob (tr ("LFO speed"), 0, 65536, 40898, [] (E::Part& p) -> int& { return p.speed; }, [] (double v) {
+        const auto rate = (std::pow (10001.0, v / 65536.0) - 1.0) / 625.0;
+        return juce::String (rate, rate < 1.0 ? 2 : 1);
+    });
+    Knob lfoTension = partKnob (tr ("LFO tension"), -128, 128, 0, [] (E::Part& p) -> int& { return p.tension; });
+    Knob skew = partKnob (tr ("LFO skew"), -128, 128, 0, [] (E::Part& p) -> int& { return p.skew; });
+    Knob pulseWidth = partKnob (tr ("LFO pulse width"), -128, 128, 0, [] (E::Part& p) -> int& { return p.pulseWidth; });
+    CurveEditor editor;
+};
+
 // A kind LYNX does not edit yet: says so (its notes pass through)
 class PendingBody final : public Body
 {
@@ -676,6 +1344,8 @@ std::unique_ptr<Body> makeBody (vfx::Kind kind)
         case vfx::Kind::keyMapper: return std::make_unique<KeyMapperBody>();
         case vfx::Kind::colorMapper: return std::make_unique<ColorMapperBody>();
         case vfx::Kind::levelScaler: return std::make_unique<LevelScalerBody>();
+        case vfx::Kind::keyboardSplitter: return std::make_unique<KeyboardSplitterBody>();
+        case vfx::Kind::envelope: return std::make_unique<EnvelopeBody>();
         default: break;
     }
     return std::make_unique<PendingBody>();

+ 166 - 0
tests/Vfx164Tests.inc

@@ -360,3 +360,169 @@ TEST (vfx_level_scaler_curves_match_fl)
     const auto out = vfx164::run (*p, { vfx164::on (60, 0, 0, 0.9f), vfx164::on (64, 0, 0, 0.2f) });
     CHECK (out.size() == 2 && near (out[0].voice.velocity, 0.5) && near (out[1].voice.velocity, 0.5) && out[0].voice.key == 60);
 }
+
+TEST (vfx_keyboard_splitter_zones)
+{
+    using namespace vfx164;
+    using S = lynx::vfx::KeyboardSplitterSettings;
+    auto keys = [] (const std::vector<lynx::vfx::Event>& out) {
+        std::vector<std::pair<int, int>> k; // (output, key)
+        for (const auto& e : out)
+            if (e.type == lynx::vfx::Event::Type::on)
+                k.emplace_back (e.output, e.voice.key);
+        std::sort (k.begin(), k.end());
+        return k;
+    };
+    auto def = lynx::vfx::defaultKeyboardSplitter();
+    CHECK (lynx::vfx::parseKeyboardSplitter (lynx::vfx::writeKeyboardSplitter (def)) == def);
+    auto p = lynx::vfx::makeProcessor (lynx::vfx::Kind::keyboardSplitter, lynx::vfx::writeKeyboardSplitter (def));
+    auto out = run (*p, { on (60, 0, 0, 0.78125f) });
+    CHECK (out.size() == 1 && out[0].output == 0 && out[0].voice.key == 60 && std::abs (out[0].voice.velocity - 0.78125f) < 1e-4f);
+    // FL's "3 zone split transposed"
+    S split;
+    auto zone = [] (double from, double to) {
+        lynx::vfx::MapCurve m;
+        m.points.push_back ({ 0.0, 0.0 });
+        m.points.push_back ({ from / 132.0, 0.0 });
+        m.points.push_back ({ from / 132.0, 1.0 });
+        m.points.push_back ({ (to + 1) / 132.0, 1.0 });
+        m.points.push_back ({ (to + 1) / 132.0, 0.0 });
+        m.points.push_back ({ 1.0, 0.0 });
+        return m;
+    };
+    split.zones[0].keyboard = zone (0, 47);
+    split.zones[0].transpose = 36;
+    split.zones[1].keyboard = zone (48, 83);
+    split.zones[2].keyboard = zone (84, 131);
+    split.zones[2].transpose = -36;
+    p = lynx::vfx::makeProcessor (lynx::vfx::Kind::keyboardSplitter, lynx::vfx::writeKeyboardSplitter (split));
+    CHECK ((keys (run (*p, { on (40) })) == std::vector<std::pair<int, int>> { { 0, 76 } }));
+    CHECK ((keys (run (*p, { on (60) })) == std::vector<std::pair<int, int>> { { 1, 60 } }));
+    CHECK ((keys (run (*p, { on (90) })) == std::vector<std::pair<int, int>> { { 2, 54 } }));
+    out = run (*p, { off (40) });
+    CHECK (out.size() == 1 && out[0].type == lynx::vfx::Event::Type::off && out[0].voice.key == 76 && out[0].output == 0);
+    // Velocity / Limited (absolute): v 1 → map 0.75 → velocity 0.75 / 1.28
+    S limited = lynx::vfx::defaultKeyboardSplitter();
+    limited.zones[0].velocity.points = { { 0.0, 0.0 }, { 0.75, 0.75 }, { 1.0, 0.75 } };
+    limited.zones[0].absolute = true;
+    p = lynx::vfx::makeProcessor (lynx::vfx::Kind::keyboardSplitter, lynx::vfx::writeKeyboardSplitter (limited));
+    out = run (*p, { on (60, 0, 0, 1.0f), on (62, 0, 0, 0.4f) });
+    CHECK (out.size() == 2 && std::abs (out[0].voice.velocity - 0.5859f) < 1e-3f && std::abs (out[1].voice.velocity - 0.3125f) < 1e-3f);
+    // random zones: each note on exactly one of them
+    S rnd;
+    rnd.zones[0].keyboard = rnd.zones[1].keyboard = lynx::vfx::MapCurve::flat (1.0);
+    rnd.zones[0].random = rnd.zones[1].random = true;
+    p = lynx::vfx::makeProcessor (lynx::vfx::Kind::keyboardSplitter, lynx::vfx::writeKeyboardSplitter (rnd));
+    int counts[2] {};
+    for (int k = 0; k < 200; ++k)
+    {
+        out = run (*p, { on (60), off (60, 1) });
+        CHECK (out.size() == 2);
+        if (! out.empty())
+            ++counts[std::clamp (out[0].output, 0, 1)];
+    }
+    CHECK (counts[0] > 50 && counts[1] > 50);
+}
+
+TEST (vfx_reads_fl_factory_presets)
+{
+    if (realFlpDir.empty())
+        return;
+    namespace fs = std::filesystem;
+    int files = 0;
+    for (const auto kind : { lynx::vfx::Kind::keyMapper, lynx::vfx::Kind::keyboardSplitter, lynx::vfx::Kind::envelope })
+    {
+        const auto dir = fs::path (realFlpDir) / "Patches" / "Plugin presets" / "Effects" / lynx::vfx::flName (kind);
+        if (! fs::is_directory (dir))
+            continue;
+        for (const auto& entry : fs::recursive_directory_iterator (dir))
+        {
+            if (entry.path().extension() != ".fst")
+                continue;
+            std::ifstream in (entry.path(), std::ios::binary);
+            const std::vector<std::uint8_t> bytes ((std::istreambuf_iterator<char> (in)), {});
+            const auto state = lynx::vfx::stateFromFlPreset (bytes, kind);
+            CHECK (state.has_value());
+            if (! state)
+            {
+                std::printf ("  not read: %s\n", entry.path().string().c_str());
+                continue;
+            }
+            ++files;
+            if (kind == lynx::vfx::Kind::keyMapper)
+            {
+                const auto s = lynx::vfx::parseKeyMapper (*state);
+                CHECK (s && lynx::vfx::writeKeyMapper (*s) == *state);
+            }
+            if (kind == lynx::vfx::Kind::keyboardSplitter)
+            {
+                const auto s = lynx::vfx::parseKeyboardSplitter (*state);
+                CHECK (s.has_value());
+                if (s)
+                {
+                    const auto again = lynx::vfx::parseKeyboardSplitter (lynx::vfx::writeKeyboardSplitter (*s));
+                    CHECK (again && again->zones == s->zones);
+                }
+            }
+            if (kind == lynx::vfx::Kind::envelope)
+            {
+                const auto s = lynx::vfx::parseEnvelope (*state);
+                CHECK (s.has_value());
+                if (s)
+                {
+                    const auto again = lynx::vfx::parseEnvelope (lynx::vfx::writeEnvelope (*s));
+                    CHECK (again && *again == *s);
+                }
+            }
+        }
+    }
+    CHECK (files >= 50);
+}
+
+TEST (vfx_envelope_moves_the_notes_it_matches)
+{
+    using namespace vfx164;
+    using E = lynx::vfx::EnvelopeSettings;
+    auto def = lynx::vfx::defaultEnvelope();
+    const auto again = lynx::vfx::parseEnvelope (lynx::vfx::writeEnvelope (def));
+    CHECK (again && *again == def);
+    auto p = lynx::vfx::makeProcessor (lynx::vfx::Kind::envelope, lynx::vfx::writeEnvelope (def));
+    lynx::vfx::EventList out;
+    lynx::vfx::Transport t;
+    t.sampleRate = 48000.0;
+    // colour 0: the volume envelope starts silent; colour 3 passes untouched
+    std::vector<lynx::vfx::Event> in { on (60, 0, 0, 0.78125f), on (64, 0, 3, 0.5f) };
+    p->process (in.data(), 2, 480, t, out);
+    out.sortByOffset();
+    CHECK (out.size() == 2 && out[0].voice.velocity < 0.01f && std::abs (out[1].voice.velocity - 0.5f) < 1e-5f);
+    // 0.75 s in: the peak (volume × 2)
+    float peak = 0.0f;
+    for (int b = 0; b < 75; ++b)
+    {
+        out.clear();
+        p->process (nullptr, 0, 480, t, out);
+        for (int k = 0; k < out.size(); ++k)
+            if (out[k].type == lynx::vfx::Event::Type::prop && out[k].prop == lynx::vfx::Prop::velocity)
+                peak = std::max (peak, out[k].value);
+    }
+    const auto twice = (float) (std::log (10.0 * 2.0 + 1.0) / std::log (11.0) / 1.28); // velocity of volume × 2
+    CHECK (std::abs (peak - twice) < 0.02f);
+    CHECK (p->busy());
+    // pitch: articulator 1's pitch envelope flat at the top, 100 %: +48 semitones
+    auto up = lynx::vfx::defaultEnvelope();
+    auto& pitch = up.articulators[0].parts[E::pitch];
+    pitch.env = 1.0f;
+    pitch.envelope.points = { { 0.0, 1.0 }, { 1.0, 1.0 } };
+    pitch.envelope.footer[1] = -1;
+    up.articulators[0].parts[E::velocity].envelope.footer[1] = 0; // (no volume envelope)
+    up.articulators[0].low = 61; // keys 60…71 only
+    up.articulators[0].high = 72;
+    p = lynx::vfx::makeProcessor (lynx::vfx::Kind::envelope, lynx::vfx::writeEnvelope (up));
+    const auto res = run (*p, { on (60), on (72) });
+    CHECK (res.size() == 2 && std::abs (res[0].voice.cents - 4800.0f) < 0.5f && res[1].voice.cents == 0.0f);
+    // the plugin off: everything passes
+    up.enabled = false;
+    p = lynx::vfx::makeProcessor (lynx::vfx::Kind::envelope, lynx::vfx::writeEnvelope (up));
+    const auto off = run (*p, { on (60) });
+    CHECK (off.size() == 1 && off[0].voice.cents == 0.0f);
+}