ソースを参照

parity147b: Ember Saturator — Saturn 2's channel mode M/S, per-band drive pan and band pan (measured black-box on the trial, translated); LYNX Tune — the real-time corrector's keyboard: note statuses with up / down directions, range bar + presets (notes outside pass uncorrected), Reset scale, view navigation; tests, pt-BR, round doc 147b

Ka1-S 1 ヶ月 前
親
コミット
ae2d2ee80f

+ 12 - 8
docs/PARITY.md

@@ -342,18 +342,20 @@ sources, 50 modulation slots).
 | 28 styles in 6 families | ⚠️ | 4 families (tube, tape, transistor, fuzz) |
 | Per-band tone: Bass / Mid / Treble / Presence | ✅ | round 128: ±18 dB (Saturn ±24) on the band's saturated signal — LYNX's own curves (shelf 120 Hz, bell 800 Hz, shelf 3.5 kHz, bell 6 kHz); the global tilt / cuts stay as LYNX extras in the bottom bar |
 | Per-band power, solo, mute | ✅ | round 128 (panel buttons, tags on the display) |
-| Drive pan (L / R), band pan | ❌ | |
+| Drive pan (L / R), band pan | ✅ | round 147b: per band DRIVE PAN (beside the drive) and PAN (under the level) [EXEC trial: the far channel's drive × (1 − \|pan\|) on the 0–100 % scale; the band pan's far side 1 − \|pan\|]; translated from Saturn 2 states |
 | Feedback amount / frequency | ✅ | round 128: a band-passed loop around the shaper (10 Hz – 1 kHz, loop gain up to 0.9) |
 | Dynamics (compress / expand the band) | ✅ | round 128: −1 … +1, the band's level follows its input level |
 | Modulation (+ Add Modulation: XLFO, EG, EF, MIDI, XY, slots) | ❌ | |
 | Crossover slope (bottom bar) | ✅ | global (original per band) |
 | Linear phase / minimum phase | ❌ | |
 | High Quality mode (oversampling) | ✅ | "Oversampling 2x / 4x / 8x" |
-| Channel mode M/S | ❌ | |
+| Channel mode M/S | ✅ | round 147b: "Channel L/R \| M/S" in the bottom bar [EXEC trial: M = (L + R) / 2, S = (R − L) / 2 through the bands' two channels; drive pan and band pan then balance mid / side]; translated (state slot 695) |
 | In / Out gain + mix | ✅ | round 128: In (±24 dB) in the bottom bar; Out; Dry / wet |
 | Auto gain | — | LYNX extra (Saturn has none; Decapitator has Auto) |
 | Decapitator: Drive, 5 styles (A, E, N, T, P), Low Cut, Tone, High Cut, Thump, Steep, Mix, Output, Auto, Punish | ⚠️ | trial not installed; Ember covers drive / tone / cuts / mix / auto gain, no Thump / Steep / Punish |
 
+**Round 147b:** configuration 6 → 7 (channel mode M/S, drive pan, band pan, measured on the trial and translated), design 7 → 7. Remaining: 6 bands, 28 styles, modulation, linear phase.
+
 ## Aether ← Fresh Air
 
 Parameters of the original: Mid Air 0–100 %, High Air 0–100 %, Bypass, Trim −12…0 dB.
@@ -1021,12 +1023,12 @@ positions against wtune.png once it exists.
 | Reference pitch | ±100 c (415.3–466.16 Hz), 440 | "A4" knob 430–450 Hz | ⚠️ | range ±40 c only |
 | Root | 17 names (sharps and flats) | KEY menu, 12 names (sharps) | ✅ | |
 | Scale type | 44 (User, Chromatic, Major, Natural/Harmonic/Melodic minors, Justonic, modes, Blues, Whole tone, Diminished, Bebop, pentatonics, Pythagorean, Maqamat, Indian thaats …) | SCALE menu, 13 + Custom | ⚠️ | her states use Major / Natural Minor only (covered) |
-| Range | keyboard span with draggable boundary handles + presets Bass / Baritone / Tenor / Alto / Mezzo / Soprano / Generic; notes outside → **bypassed** | "Input type" menu (Soprano / Alto-Tenor / Low male / Instrument) = detector range | ⚠️ | 4 presets vs 7, no handles, outside notes not bypassed |
-| Keyboard | multi-octave piano at the bottom, per-note status area | one octave of on/off key toggles at the bottom ("TARGET NOTES") | ⚠️ | same place, less content |
-| Note status per key | Legal / Illegal / Illegal-Pitch-Up / Illegal-Pitch-Down / Bypass (click cycles) | on / off | ⚠️ | Up/Down/Bypass missing |
-| Group Octaves | switch (per-note edits apply to all octaves) | always grouped | ⚠️ | |
-| Reset Scale / Send Scale to All / Receive (key) | buttons | — (key comes from translation / project key) | ❌ | |
-| Keyboard view / navigation buttons | yes | — | ❌ | one octave only |
+| Range | keyboard span with draggable boundary handles + presets Bass / Baritone / Tenor / Alto / Mezzo / Soprano / Generic; notes outside → **bypassed** | "Input type" menu (Soprano / Alto-Tenor / Low male / Instrument) = detector range | ✅ | round 147b: the range bar over the keys (drag a boundary), seven presets in the keyboard strip (LYNX's spans [model]: classical voice ranges ± a third; they also pick the detector's input type), notes sung outside pass uncorrected |
+| Keyboard | multi-octave piano at the bottom, per-note status area | one octave of on/off key toggles at the bottom ("TARGET NOTES") | ✅ | round 128: four octaves; round 147b: 2–7 octaves shown, scrollable (see navigation) |
+| Note status per key | Legal / Illegal / Illegal-Pitch-Up / Illegal-Pitch-Down / Bypass (click cycles) | on / off | ✅ | round 128: Bypass mode; round 147b: REMOVE mode cycles legal → illegal → illegal up → illegal down (arrows on the key; an illegal note's direction picks the next legal note up / down) |
+| Group Octaves | switch (per-note edits apply to all octaves) | always grouped | ⚠️ | per-octave statuses would need 128 per-key values; LYNX keeps the grouped behaviour (the reference's default) |
+| Reset Scale / Send Scale to All / Receive (key) | buttons | — (key comes from translation / project key) | ⚠️ | round 147b: RESET SCALE in the keyboard strip; Send / Receive (instance-to-instance transmission) not done |
+| Keyboard view / navigation buttons | yes | — | ✅ | round 147b: − / + (more / fewer octaves, 2–7) and ◀ / ▶ (scroll by an octave) in the keyboard strip |
 | Central display | target note name + correction amount in cents | `pitchring`: note name, ±100 c ring, sung offset + octave | ✅ | |
 | Scrolling pitch graph | not in WTRT (guide lists none) | `pitchtrace` (input vs corrected, 8 s) | ➕ | Auto-Tune-style; useful |
 | Input / output meters | −28 … 0 dBFS | — | ✅ | round 135w: IN / OUT meters on the "Real-time" page |
@@ -1041,6 +1043,8 @@ positions against wtune.png once it exists.
 | MIDI learn, gestures | right-click; Alt-click etc. | yes | ✅ | |
 | Window | fixed | resizable 800×548 | ✅ | |
 
+**Round 147b:** configuration 8 → 9, design 6 → 7 (the keyboard: note statuses with directions, the range bar and presets, Reset scale, the view's navigation). Remaining: Group Octaves off, Send / Receive, MIDI reference tone.
+
 **Scores** — configuration: 4/10 (for a Waves Tune RT user: key/scale/formant/time are there, but Speed, Tolerance,
 Vibrato, Correction %, note statuses and range bypass are not), design: 5/10 (note display centre + keyboard at the
 bottom match; the knob row is Auto-Tune's).

+ 79 - 0
docs/analise/REA_rodada147b.md

@@ -0,0 +1,79 @@
+# REA round 147b (parity147b): Ember's mid / side and pans, LYNX Tune's keyboard, Ridge
+
+2026-10-24. Sub-round of parity147 (docs/PARITY.md, tier 3): Ember Saturator ← Saturn 2's channel mode M/S, drive
+pan and band pan; LYNX Tune ← Waves Tune Real-Time's keyboard (note statuses, range, navigation); Ridge Strip ← SSL
+E-Channel's auto make-up and ANALOG. Evidence markers: [EXEC] measured here on the official trial, hosted black-box in
+our measurement host (`tools/fxmeasure`: public VST3 parameters, value texts, audio in / out, the component state as a
+DAW stores it); [MANUAL] vendor manual / spec dossier; [model] LYNX's own choice. Nothing was decompiled; no graphics,
+presets or names were copied. Raw data: `D:\lynx-work\parity147\b\` (params.txt = Saturn 2's parameter list, m1.txt /
+m1.log / o_*.wav = the runs, s2_*.bin = saved states).
+
+## 1. Ember Saturator: Saturn 2's channel mode, drive pan, band pan
+
+### What the trial does [EXEC]
+
+Host parameters (Saturn 2, 1089 parameters): `Channel Mode` (index 695, Left/Right | Mid/Side), per band `Drive Pan`
+(−1 … +1, band field 5) and `Pan` (band field 12, value texts "Left: 0 dB / Right: −6.02 dB" at −0.5), global Input /
+Output Pan. Saved state (FFBS, 951 values): the channel mode at 695, drive pan at 7 + 17b + 5, band pan at 7 + 17b + 12
+(−1 … +1); the parameter indices and the state slots coincide (s2_def / s2_ms / s2_dp.bin differ only there).
+
+One band, Warm Tube, drive 50 %, a 1 kHz sine at −12 dBFS (harmonics H2 / H3 / H5 per channel, `harm.py`):
+
+| Run | Result |
+|---|---|
+| L/R, drive pan −1 | left = the centred result (H2 −32.6, H3 −44.0 dB); right = exactly the drive-0 % run (−43.7 / −59.3 / −115.8) |
+| L/R, drive pan −0.5 | right between the 20 % and 30 % runs: the 25 % run, i.e. **the far channel's drive × (1 − \|pan\|)** on the 0–100 % scale |
+| M/S, L = R (pure mid) | identical to L/R (to the last digit): M = (L + R) / 2, decoded L = M ± S (no √2 scaling) |
+| M/S, drive pan −1 / +1 | the mid / the side keeps the full drive (−1 = mid, +1 = side) |
+| M/S, left-only tone, centred | L keeps only odd products, R only even ones: the side is (R − L) / 2 (a left-only tone gives S = −M) |
+| band pan, L/R | the far channel × (1 − \|pan\|) (pan +1: left silent) |
+| band pan, M/S | the same law on mid / side (pan −1: the side silent, +1: the mid silent) |
+
+### LYNX (src/core/MixSuite.{h,cpp} `ember::`, editor `EmberEditor` in src/ui/ProEditors.cpp)
+
+Appended after the Classic voicing (round 136): `Channel mode` (0 L/R, 1 M/S), `B1 … B4 drive pan`, `B1 … B4 pan`
+(Ember: 92 parameters). Defaults = the old sound (centred, L/R).
+
+- M/S: the whole engine runs on M = (L + R) / 2 (channel 0) and S = (R − L) / 2 (channel 1), decoded L = M − S,
+  R = M + S (the trial's sign).
+- Drive pan: channel 0 / 1's drive (dB, Ember's 0–36 dB = Saturn's % × 30 dB in the translation) × (1 − |pan|) on the
+  far side; with Auto gain each channel gets its own make-up.
+- Band pan: the band's output gains (1 − |pan| on the far side), single-band and multiband.
+- Editor: DRIVE PAN beside the drive knob, PAN under LEVEL in the band panel, "Channel L/R | M/S" in the bottom bar;
+  splitting / removing a band carries its pans. The generic layout has a "Stereo" section.
+- Saturn 2 states: the channel mode and every band's drive pan / pan translated.
+- Tests: tests/Parity147bTests.inc (laws, M/S identity for a mid signal, side removal with pan, multiband pan,
+  translation).
+
+## 2. LYNX Tune: the Waves Tune Real-Time role's keyboard
+
+[MANUAL] (docs/specs/waves-tune-real-time.md, the v16 guide): a multi-octave keyboard with per-note statuses (Legal,
+Illegal, Illegal-Pitch-Up, Illegal-Pitch-Down, Bypass; a click cycles), the range (boundary handles + presets Bass,
+Baritone, Tenor, Alto, Mezzo Soprano, Soprano, Generic; notes outside → bypassed), Group Octaves, Reset Scale,
+Send / Receive, view buttons (− / + and ◀ / ▶ under the keys, `parity129/ref/wtune.png`). [EXEC] attempt: the Waves
+shell hung in our host while scanning (as in round 144: no parameter list in 200 s; the process was killed by its PID)
+— nothing was measured on Waves this round.
+
+LYNX (src/core/LynxTune.{h,cpp}, the `tunekeys` display in src/ui/PluginEditors.cpp; appended after `outputTrim`):
+
+| Parameter | Values | Law |
+|---|---|---|
+| C … B dir | Nearest / Up / Down (default Nearest) | an illegal note's direction: a sung pitch nearest to it goes to the next legal note up / down (`targetNote`), after the tolerance hysteresis |
+| Range low / high | MIDI notes 0 … 127 (default 0 / 127) | sung notes outside pass uncorrected (like a bypassed note) |
+
+Editor: the keyboard strip holds BYPASS / REMOVE, RESET SCALE, the seven range presets, − / + (2–7 octaves shown) and
+◀ / ▶ (scroll), LATCH; a range bar over the keys (lit between the boundaries; click / drag moves the nearer one); keys
+outside the range are dimmed; REMOVE cycles legal → illegal (cross) → illegal up (▲) → illegal down (▼) → legal; the
+octave names follow MIDI (C4 = 60). Range presets [model]: the classical voice ranges widened by a third (Bass C2–G#4,
+Baritone F2–C#5, Tenor G#2–E5, Alto C#3–A5, Mezzo F3–C#6, Soprano G#3–E6, Generic = everything); a preset also picks
+the detector's input type (low male / alto-tenor / soprano). Group Octaves stays on (per-octave statuses would need
+128 per-key values), Send / Receive not done. Tests: the direction law, the range bypass on a 450 Hz tone
+(corrected to 440 Hz in range, 450 Hz outside), the defaults.
+
+## 3. Ridge Strip: auto make-up and ANALOG
+
+Waits for round 145 (vox145), which appends ~34 Vocal-strip parameters to Ridge; see "Where I stopped".
+
+## Where I stopped
+
+- (filled at the end of the round)

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

@@ -3936,3 +3936,22 @@ countries: br
 "Links (this project, then global)" = "Vínculos (deste projeto, depois os globais)"
 "global" = "global"
 "Pattern events" = "Eventos do pattern"
+"Drive pan" = "Pan do drive"
+"L/R|M/S" = "L/R|M/S"
+"Baritone" = "Barítono"
+"Tenor" = "Tenor"
+"Alto" = "Contralto"
+"Mezzo" = "Mezzo"
+"Soprano" = "Soprano"
+"Generic" = "Genérico"
+"Reset scale" = "Reiniciar escala"
+"Bypass mode: a key switches its note between corrected and passed as sung" = "Modo Bypass: uma tecla alterna a nota entre corrigida e passada como cantada"
+"Remove mode: a key cycles its note: legal, illegal (to the nearest note), illegal pitch up, illegal pitch down" = "Modo Remover: uma tecla percorre os estados da nota: válida, inválida (para a nota mais próxima), inválida para cima, inválida para baixo"
+"Reset scale: every note of the scale legal again, nothing bypassed" = "Reiniciar escala: todas as notas da escala válidas de novo, nada em bypass"
+"Range preset: notes sung outside the range pass uncorrected (Generic: the whole keyboard)" = "Predefinição de extensão: notas cantadas fora da extensão passam sem correção (Genérico: o teclado inteiro)"
+"Keyboard view: show more / fewer octaves" = "Vista do teclado: mostrar mais / menos oitavas"
+"Keyboard view: scroll down / up an octave" = "Vista do teclado: rolar uma oitava para baixo / para cima"
+"Latch: off = a key's edit lasts only while it is held" = "Trava: desligada = a edição de uma tecla dura só enquanto ela é segurada"
+"Range: drag a boundary; notes sung outside it pass uncorrected" = "Extensão: arraste um limite; notas cantadas fora dela passam sem correção"
+"Click a key: change that note's status in every octave" = "Clique numa tecla: muda o estado dessa nota em todas as oitavas"
+"Click a key: bypass / correct that note in every octave" = "Clique numa tecla: bypass / corrigir essa nota em todas as oitavas"

+ 6 - 1
src/core/FabFilterStates.cpp

@@ -418,7 +418,8 @@ int fromProG (const State& s, EffectSlot& slot)
 // ---------------------------------------------------------------- Saturn 2 -> Ember Saturator
 // layout (FFBS v1, 951 values): 0 input gain dB, 2 output gain dB, 5 mix %, 6 band count, band b at 7 + 17b:
 // 2 dynamics, 3 style, 4 drive (norm), 6 … 9 bass / mid / treble / presence dB, 10 mix %, 11 level, 13 enabled,
-// 15 crossover (log2 Hz, the band's upper edge), 16 crossover slope (6, 12, 24, 36, 48)
+// 15 crossover (log2 Hz, the band's upper edge), 16 crossover slope (6, 12, 24, 36, 48); round 147: 5 drive pan,
+// 12 band pan (−1 … +1), 695 the channel mode (0 left / right, 1 mid / side)
 int fromSaturn2 (const State& s, EffectSlot& slot)
 {
     if (slot.kind != EffectKind::ember || s.named || s.count != 951 || ! finiteAll (s, 7 + 17 * 6))
@@ -466,6 +467,9 @@ int fromSaturn2 (const State& s, EffectSlot& slot)
             const auto st = roundIndex (s.at (base + 14));
             set (bandExtra (b, 1), st == 1 ? 0.5f : (st == 2 || st == 3) ? 1.0f : 0.0f);
         }
+        // round 147 (measured on the trial, REA_rodada147b): drive pan at 5 and band pan at 12, both −1 … +1
+        set (bandDrivePanParam (b), (float) (0.5 + 0.5 * std::clamp ((double) s.at (base + 5), -1.0, 1.0)));
+        set (bandPanParam (b), (float) (0.5 + 0.5 * std::clamp ((double) s.at (base + 12), -1.0, 1.0)));
         if (b == 0)
         {
             static constexpr int slopes[5] { 12, 12, 24, 24, 48 };
@@ -477,6 +481,7 @@ int fromSaturn2 (const State& s, EffectSlot& slot)
     set (inputGain, linValue (std::clamp ((double) s.at (0), -24.0, 24.0), -24.0, 24.0)); // round 128
     set (output, linValue (s.at (2), -18.0, 18.0));
     set (autoGain, 1.0f); // Saturn compensates its level as the drive rises (§4)
+    set (channelMode, s.at (695) >= 0.5f ? 1.0f : 0.0f); // round 147: the channel mode (0 left / right, 1 mid / side)
     return n;
 }
 

+ 69 - 1
src/core/LynxTune.cpp

@@ -137,11 +137,55 @@ const EffectInfo& info()
         e.params.push_back ({ "Drive", 0.0f });
         e.params.push_back ({ "Wide formant", 0.0f });
         e.params.push_back ({ "Output", 0.5f });
+        // round 147: an illegal note's direction (C … B) and the keyboard's range
+        static const char* const dirNames[12] { "C dir", "C# dir", "D dir", "D# dir", "E dir", "F dir", "F# dir", "G dir", "G# dir", "A dir", "A# dir", "B dir" };
+        for (const auto* nm : dirNames)
+            e.params.push_back ({ nm, 0.0f });
+        e.params.push_back ({ "Range low", 0.0f });
+        e.params.push_back ({ "Range high", 1.0f });
         return e;
     }();
     return i;
 }
 
+NoteDir noteDir (float v) noexcept { return (NoteDir) stepped (v, 3); }
+int rangeNote (float v) noexcept { return std::clamp ((int) std::lround (std::clamp (v, 0.0f, 1.0f) * 127.0f), 0, 127); }
+float rangeNoteValue (int note) noexcept { return (float) std::clamp (note, 0, 127) / 127.0f; }
+const char* rangePresetName (int k) noexcept
+{
+    static const char* const n[rangePresets] { "Bass", "Baritone", "Tenor", "Alto", "Mezzo", "Soprano", "Generic" };
+    return n[std::clamp (k, 0, rangePresets - 1)];
+}
+std::pair<int, int> rangePresetNotes (int k) noexcept
+{
+    // [model] the classical voice ranges (bass E2–E4, baritone A2–A4, tenor C3–C5, alto F3–F5, mezzo A3–A5, soprano
+    // C4–C6) widened by a third on each side; Generic = the whole keyboard (no note bypassed)
+    static constexpr std::pair<int, int> r[rangePresets] { { 36, 68 }, { 41, 73 }, { 44, 76 }, { 49, 81 }, { 53, 85 }, { 56, 88 }, { 0, 127 } };
+    return r[std::clamp (k, 0, rangePresets - 1)];
+}
+int targetNote (double sung, std::uint16_t legal, int previous, double hysteresis, const NoteDir* dirs) noexcept
+{
+    const auto t = vocal::nearestNote (sung, legal, previous, hysteresis);
+    legal &= 0xfff;
+    if (dirs == nullptr || legal == 0 || t == previous)
+        return t;
+    const auto base = (int) std::lround (sung);
+    const auto pc = ((base % 12) + 12) % 12;
+    if ((legal >> pc) & 1u)
+        return t;
+    const auto d = dirs[pc];
+    if (d == NoteDir::nearest)
+        return t;
+    const int step = d == NoteDir::up ? 1 : -1;
+    for (int k = 1; k <= 12; ++k)
+    {
+        const auto n = base + step * k;
+        if ((legal >> (((n % 12) + 12) % 12)) & 1u)
+            return n;
+    }
+    return t;
+}
+
 std::string paramText (int param, float v)
 {
     char t[48];
@@ -191,6 +235,17 @@ std::string paramText (int param, float v)
     }
     if ((param >= noteC && param < noteC + 12) || (param >= bypassC && param < bypassC + 12))
         return onOff();
+    if (param >= noteDirC && param < noteDirC + 12)
+    {
+        static const char* const n[3] { "Nearest", "Up", "Down" };
+        return n[(int) noteDir (v)];
+    }
+    if (param == rangeLow || param == rangeHigh)
+    {
+        static const char* const names[12] { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
+        const auto k = rangeNote (v);
+        return std::string (names[k % 12]) + std::to_string (k / 12 - 1);
+    }
     std::snprintf (t, sizeof t, "%.2f", (double) v);
     return t;
 }
@@ -278,6 +333,16 @@ public:
         const auto vibDelay = vibratoOnsetMs (p[vibratoDelay]) * 0.001;
         const auto vibOnset = vibratoOnsetMs (p[vibratoOnset]) * 0.001;
         auto mask = (std::uint16_t) (vocal::scaleMask (sc, keyIndex (p[key]), notes) & notes);
+        // round 147: the illegal notes' directions and the keyboard range (outside it: uncorrected)
+        std::array<NoteDir, 12> dirs {};
+        bool anyDir = false;
+        for (int k = 0; k < 12; ++k)
+        {
+            dirs[(std::size_t) k] = noteDir (p[(std::size_t) (noteDirC + k)]);
+            anyDir = anyDir || dirs[(std::size_t) k] != NoteDir::nearest;
+        }
+        const auto lowNote = rangeNote (p[rangeLow]), highNote = rangeNote (p[rangeHigh]);
+        const bool ranged = lowNote > 0 || highNote < 127;
 
         // MIDI targets: the pitch classes held on the source channel (none held: the scale)
         const auto ch = midiChannelIndex (p[midiChannel]);
@@ -375,7 +440,8 @@ public:
                         // the first notes of the next one, by up to half a semitone the wrong way)
                         shift = 0.0;
                     }
-                    const auto t = vocal::nearestNote (ignoreVib ? center2 : sung, mask, target, hysteresis);
+                    const auto t = anyDir ? targetNote (ignoreVib ? center2 : sung, mask, target, hysteresis, dirs.data())
+                                          : vocal::nearestNote (ignoreVib ? center2 : sung, mask, target, hysteresis);
                     // round 135w: Tolerance time — a new note must last that long before the target moves to it
                     if (t != target && holdTime > 0.0 && target >= 0)
                     {
@@ -406,6 +472,8 @@ public:
                     wanted = (double) target - heard;
                     if (((bypass >> (((target % 12) + 12) % 12)) & 1u) != 0)
                         wanted = 0.0; // a bypassed note passes as sung
+                    if (ranged && (sung < (double) lowNote - 0.5 || sung > (double) highNote + 0.5))
+                        wanted = 0.0; // round 147: outside the keyboard's range: passes as sung
                     // flex-tune: a note far from its target is left as sung. [EXEC] Auto-Tune Pro (round 120 §5): the
                     // correction of a note d cents from its target is min (d, (1 − F) / F · (50 − d)) cents, d measured
                     // in hundredths of the gap to the next target on the sung side (a semitone in chromatic)

+ 18 - 0
src/core/LynxTune.h

@@ -18,6 +18,7 @@
 #include <array>
 #include <cstdint>
 #include <memory>
+#include <utility>
 #include <string>
 
 namespace lynx
@@ -73,8 +74,25 @@ enum Param : int
     drive,                   // 0 … 10
     wideFormant,             // on: Formant shift reaches ±12 semitones
     outputTrim,              // −24 … +24 dB
+    // round 147 (appended; the Waves Tune Real-Time role's keyboard, REA_rodada147b; defaults = the old behaviour):
+    // what an illegal (removed) note does — 0 the nearest legal note (as before), 0.5 the next legal note up, 1 the next
+    // one down — and the keyboard's range: sung notes outside [low, high] pass uncorrected
+    noteDirC,                // 12 values (C … B)
+    rangeLow = noteDirC + 12, // MIDI note = round (127 v); default 0
+    rangeHigh,               // default 127
     count
 };
+enum class NoteDir { nearest, up, down };
+NoteDir noteDir (float v) noexcept;
+int rangeNote (float v) noexcept;       // 0 … 127
+float rangeNoteValue (int note) noexcept;
+// the keyboard's range presets (LYNX's own spans, classical voice ranges with a margin): low / high MIDI notes
+constexpr int rangePresets = 7;          // Bass, Baritone, Tenor, Alto, Mezzo, Soprano, Generic (the whole keyboard)
+const char* rangePresetName (int k) noexcept;
+std::pair<int, int> rangePresetNotes (int k) noexcept;
+// The target note (a MIDI note number) for a sung pitch (notes): the nearest legal one with the hysteresis toward
+// `previous`, then an illegal note's direction (noteDirs: the 12 directions); −1 = none legal
+int targetNote (double sung, std::uint16_t legal, int previous, double hysteresis, const NoteDir* noteDirs) noexcept;
 
 constexpr int vibratoShapes = 4;
 

+ 77 - 9
src/core/MixSuite.cpp

@@ -1328,6 +1328,13 @@ double toneDb (float v) noexcept { return lin (v, -18.0, 18.0); }
 double feedbackAmount (float v) noexcept { return lin (v, 0.0, 1.0); }
 double feedbackHz (float v) noexcept { return logMap (v, 10.0, 1000.0); }
 double dynamicsAmount (float v) noexcept { return lin (v, -1.0, 1.0); }
+double panOf (float v) noexcept { return std::clamp ((double) v * 2.0 - 1.0, -1.0, 1.0); }
+std::pair<float, float> panScales (double pan) noexcept
+{
+    pan = std::clamp (pan, -1.0, 1.0);
+    return { (float) (pan > 0.0 ? 1.0 - pan : 1.0), (float) (pan < 0.0 ? 1.0 + pan : 1.0) };
+}
+bool midSide (const EffectParams& p) noexcept { return on (p[channelMode]); }
 int bandParam (int band, int field) noexcept
 {
     if (band <= 0)
@@ -1509,8 +1516,25 @@ public:
 
     void process (float* l, float* r, int n, const EffectParams& p, double) noexcept override
     {
+        // round 147: mid / side — M = (L + R) / 2 on channel 0, S = (R − L) / 2 on channel 1 (the trial's sign: a
+        // left-only tone's even harmonics land on the right), decoded L = M − S, R = M + S
+        const bool ms = midSide (p);
+        if (ms)
+            for (int i = 0; i < n; ++i)
+            {
+                const auto m = 0.5f * (l[i] + r[i]), sd = 0.5f * (r[i] - l[i]);
+                l[i] = m;
+                r[i] = sd;
+            }
         for (int off = 0; off < n; off += maxBlock)
             chunk (l + off, r + off, std::min (maxBlock, n - off), p);
+        if (ms)
+            for (int i = 0; i < n; ++i)
+            {
+                const auto m = l[i], sd = r[i];
+                l[i] = m - sd;
+                r[i] = m + sd;
+            }
     }
 
 private:
@@ -1540,6 +1564,12 @@ private:
         const auto vk = voiceIndex (p[voice]);
         const auto s = vk > 0 ? voiceStyle (vk) : styleOf (p[style]);
         const auto drv = (float) dbToGain (driveDb (p[drive]) + (on (p[punish]) ? punishDb : 0.0));
+        // round 147: the drive pan — the far channel's drive × (1 − |pan|) (in dB, the trial's 0 … 100 % scale)
+        const auto [dsA, dsB] = panScales (panOf (p[bandDrivePanParam (0)]));
+        const bool drivePanned = dsA != 1.0f || dsB != 1.0f;
+        const auto drvA = drivePanned ? (float) dbToGain (driveDb (p[drive]) * dsA + (on (p[punish]) ? punishDb : 0.0)) : drv;
+        const auto drvB = drivePanned ? (float) dbToGain (driveDb (p[drive]) * dsB + (on (p[punish]) ? punishDb : 0.0)) : drv;
+        const auto [panA, panB] = panScales (panOf (p[bandPanParam (0)]));
         const bool tape = s == Style::tape && vk == 0;
         const auto [lc, hc] = configureCuts (p);
         configureVoice (vk);
@@ -1558,6 +1588,8 @@ private:
             lastStyle = s;
         }
         const auto comp = on (p[autoGain]) ? makeup : 1.0f;
+        const auto compA = drivePanned && on (p[autoGain]) ? autoMakeup (s, drvA) : comp;
+        const auto compB = drivePanned && on (p[autoGain]) ? autoMakeup (s, drvB) : comp;
 
         for (int i = 0; i < n; ++i)
         {
@@ -1577,8 +1609,8 @@ private:
                 a = emphasis.process (a, 0);
                 b = emphasis.process (b, 1);
             }
-            wl[(std::size_t) i] = a * drv;
-            wr[(std::size_t) i] = b * drv;
+            wl[(std::size_t) i] = a * drvA;
+            wr[(std::size_t) i] = b * drvB;
         }
 
         // round 128: band 1's power, mute, feedback, dynamics and tone (single-band mode)
@@ -1603,7 +1635,7 @@ private:
 
         for (int i = 0; i < n; ++i)
         {
-            auto a = dc.process (wl[(std::size_t) i], 0) * comp, b = dc.process (wr[(std::size_t) i], 1) * comp;
+            auto a = dc.process (wl[(std::size_t) i], 0) * compA, b = dc.process (wr[(std::size_t) i], 1) * compB;
             if (tape)
             {
                 a = deemphasis.process (a, 0);
@@ -1626,6 +1658,8 @@ private:
             dry.process (da, db);
             if (! powered) { a = da; b = db; }  // switched off: the band passes clean
             if (muted) { a = 0.0f; b = 0.0f; }
+            a *= panA; // round 147: the band's pan
+            b *= panB;
             l[i] = (da + (a - da) * mx) * out;
             r[i] = (db + (b - db) * mx) * out;
         }
@@ -1673,6 +1707,7 @@ private:
 
         std::array<Style, maxBands> st {};
         std::array<float, maxBands> drv {}, bmix {}, lvl {}, comp {};
+        std::array<float, maxBands> drvB {}, compB {}, panA {}, panB {}; // round 147: channel 1's drive, the band pan
         bool anySolo = false;
         for (int b = 0; b < nb; ++b) anySolo = anySolo || bandState (p[(std::size_t) bandExtra (b, 1)]) == BandState::solo;
         for (int b = 0; b < nb; ++b)
@@ -1682,6 +1717,21 @@ private:
             bmix[(std::size_t) b] = std::clamp (p[(std::size_t) bandParam (b, 2)], 0.0f, 1.0f);
             lvl[(std::size_t) b] = (float) dbToGain (bandLevelDb (p[(std::size_t) bandParam (b, 3)]));
             comp[(std::size_t) b] = autoOn ? autoMakeup (st[(std::size_t) b], drv[(std::size_t) b]) : 1.0f;
+            // round 147: drive pan (channel 0's drive stays in drv) and band pan
+            const auto [dsA, dsB] = panScales (panOf (p[(std::size_t) bandDrivePanParam (b)]));
+            const auto dDb = driveDb (p[(std::size_t) bandParam (b, 1)]);
+            drvB[(std::size_t) b] = drv[(std::size_t) b];
+            compB[(std::size_t) b] = comp[(std::size_t) b];
+            if (dsA != 1.0f || dsB != 1.0f)
+            {
+                drv[(std::size_t) b] = (float) dbToGain (dDb * dsA) * punishGain;
+                drvB[(std::size_t) b] = (float) dbToGain (dDb * dsB) * punishGain;
+                comp[(std::size_t) b] = autoOn ? autoMakeup (st[(std::size_t) b], drv[(std::size_t) b]) : 1.0f;
+                compB[(std::size_t) b] = autoOn ? autoMakeup (st[(std::size_t) b], drvB[(std::size_t) b]) : 1.0f;
+            }
+            const auto [pa, pb] = panScales (panOf (p[(std::size_t) bandPanParam (b)]));
+            panA[(std::size_t) b] = pa;
+            panB[(std::size_t) b] = pb;
             bandOs[(std::size_t) b][0].setFactor (factor);
             bandOs[(std::size_t) b][1].setFactor (factor);
         }
@@ -1731,7 +1781,7 @@ private:
                 dryBand[0][(std::size_t) i] = da;
                 dryBand[1][(std::size_t) i] = db;
                 bl[i] *= drv[(std::size_t) b];
-                br[i] *= drv[(std::size_t) b];
+                br[i] *= drvB[(std::size_t) b];
             }
             const auto s = st[(std::size_t) b];
             // round 128: the band's feedback, dynamics, tone, power and solo / mute
@@ -1750,17 +1800,18 @@ private:
                 bandOs[(std::size_t) b][0].process (bl, n, curve);
                 bandOs[(std::size_t) b][1].process (br, n, curve);
             }
-            const auto m = bmix[(std::size_t) b], g = lvl[(std::size_t) b], k = comp[(std::size_t) b];
+            const auto m = bmix[(std::size_t) b], g = lvl[(std::size_t) b], k = comp[(std::size_t) b], kB = compB[(std::size_t) b];
+            const auto gA = g * panA[(std::size_t) b], gB = g * panB[(std::size_t) b];
             const bool post = ex.toneOn || ex.dyn != 0.0;
             const bool powered = on (p[(std::size_t) bandExtra (b, 0)]);
             const auto state = bandState (p[(std::size_t) bandExtra (b, 1)]);
             const bool silent = state == BandState::mute || (anySolo && state != BandState::solo);
             for (int i = 0; i < n; ++i)
             {
-                auto wa = bandDc[(std::size_t) b].process (bl[i], 0) * k, wb = bandDc[(std::size_t) b].process (br[i], 1) * k;
+                auto wa = bandDc[(std::size_t) b].process (bl[i], 0) * k, wb = bandDc[(std::size_t) b].process (br[i], 1) * kB;
                 if (post) ex.post (wa, wb, dryBand[0][(std::size_t) i], dryBand[1][(std::size_t) i]);
-                auto ya = (dryBand[0][(std::size_t) i] + (wa - dryBand[0][(std::size_t) i]) * m) * g;
-                auto yb = (dryBand[1][(std::size_t) i] + (wb - dryBand[1][(std::size_t) i]) * m) * g;
+                auto ya = (dryBand[0][(std::size_t) i] + (wa - dryBand[0][(std::size_t) i]) * m) * gA;
+                auto yb = (dryBand[1][(std::size_t) i] + (wb - dryBand[1][(std::size_t) i]) * m) * gB;
                 if (! powered) { ya = dryBand[0][(std::size_t) i]; yb = dryBand[1][(std::size_t) i]; }
                 if (silent) { ya = 0.0f; yb = 0.0f; }
                 if (b == 0)
@@ -1997,7 +2048,11 @@ const EffectInfo& emberInfo()
                                      // round 136: the Classic voicing (EmberClassic.h)
                                      { "Voicing", 0.0f }, { "Classic style", 0.0f }, { "Classic drive", 0.0f }, { "Classic punish", 0.0f },
                                      { "Classic low cut", 0.0f }, { "Classic thump", 0.0f }, { "Classic tone", 0.5f }, { "Classic high cut", 1.0f },
-                                     { "Classic steep", 0.0f }, { "Classic mix", 1.0f }, { "Classic output", 1.0f } } };
+                                     { "Classic steep", 0.0f }, { "Classic mix", 1.0f }, { "Classic output", 1.0f },
+                                     // round 147 (Saturn 2's channel mode, drive pan and band pan)
+                                     { "Channel mode", 0.0f },
+                                     { "B1 drive pan", 0.5f }, { "B2 drive pan", 0.5f }, { "B3 drive pan", 0.5f }, { "B4 drive pan", 0.5f },
+                                     { "B1 pan", 0.5f }, { "B2 pan", 0.5f }, { "B3 pan", 0.5f }, { "B4 pan", 0.5f } } };
     return info;
 }
 
@@ -2220,6 +2275,19 @@ std::string paramText (EffectKind kind, int param, float v)
             case classicHighCut: return hzText (emberclassic::highCutHz (v));
             case classicMix: return fmt ("%.0f%%", v * 100.0);
             case classicOutput: return fmt ("%+.1f dB", emberclassic::outputDb (v));
+            // round 147
+            case channelMode: return on (v) ? "Mid/Side" : "Left/Right";
+            case band1DrivePan: case band2DrivePan: case band3DrivePan: case band4DrivePan:
+            {
+                const auto pan = panOf (v);
+                return std::abs (pan) < 0.005 ? std::string ("centre") : fmt ("%.0f%% ", std::abs (pan) * 100.0) + (pan < 0.0 ? "L/M" : "R/S");
+            }
+            case band1Pan: case band2Pan: case band3Pan: case band4Pan:
+            {
+                const auto [a, b] = panScales (panOf (v));
+                const auto db = [] (float g) { return g <= 0.0f ? std::string ("-inf") : fmt ("%.1f", gainToDb (g)); };
+                return std::abs (panOf (v)) < 0.005 ? std::string ("centre") : db (a) + " / " + db (b) + " dB";
+            }
             default:
                 if (param >= band1On && param < band1On + maxBands * extraFields)
                     switch ((param - band1On) % extraFields)

+ 12 - 0
src/core/MixSuite.h

@@ -18,6 +18,7 @@
 
 #include <algorithm>
 #include <array>
+#include <utility>
 #include <memory>
 #include <string>
 
@@ -220,9 +221,20 @@ enum Param
     // its substitute role plays; its own controls with the original's laws. Voicing 0 = Ember's own engine (unchanged)
     voicing, classicStyle, classicDrive, classicPunish, classicLowCut, classicThump, classicTone, classicHighCut,
     classicSteep, classicMix, classicOutput,
+    // round 147 (Saturn 2 parity, measured black-box on the trial, REA_rodada147b; appended, defaults = the old sound):
+    // the channel mode (0 left / right, 1 mid / side: M = (L + R) / 2, S = (R − L) / 2 go through the bands' two
+    // channels), each band's drive pan (−1 … +1: the far channel's drive × (1 − |pan|)) and each band's pan (−1 … +1:
+    // the far channel's gain 1 − |pan|; in mid / side, left = mid)
+    channelMode, band1DrivePan, band2DrivePan, band3DrivePan, band4DrivePan, band1Pan, band2Pan, band3Pan, band4Pan,
     count
 };
 constexpr int maxBands = 4;
+inline int bandDrivePanParam (int band) noexcept { return band1DrivePan + std::clamp (band, 0, maxBands - 1); }
+inline int bandPanParam (int band) noexcept { return band1Pan + std::clamp (band, 0, maxBands - 1); }
+double panOf (float v) noexcept;        // −1 … +1 (0.5 = centre)
+// the two channels' scale for a pan of −1 … +1 (the far side's 1 − |pan|): first = channel 0 (left / mid)
+std::pair<float, float> panScales (double pan) noexcept;
+bool midSide (const EffectParams& p) noexcept;
 // a band's round-128 parameters: field 0 power, 1 state, 2 bass, 3 mid, 4 treble, 5 presence, 6 feedback,
 // 7 feedback frequency, 8 dynamics
 constexpr int extraFields = 9;

+ 25 - 3
src/core/PluginLayout.cpp

@@ -1025,7 +1025,7 @@ Layout lynxTune()
     // BYPASS / REMOVE modes and LATCH (round 128).
     Layout l;
     l.width = 800;
-    l.height = 610;
+    l.height = 622;
     l.pages = { TR_NOOP ("Pitch graph"), TR_NOOP ("Advanced"), TR_NOOP ("Real-time") }; // round 135w: + Real-time
     auto& v = l.items;
     auto menu = [&v] (float x, float y, float w, const char* param, const char* caption, const char* options, int steps = 0) {
@@ -1118,8 +1118,9 @@ Layout lynxTune()
         rt (io);
     }
     // --- the keyboard: BYPASS / REMOVE modes, LATCH, four octaves (a key edits its note name in every octave)
-    v.push_back (section (0, 482, 800, 128, TR_NOOP ("TARGET NOTES")));
-    v.push_back (display (8, 502, 784, 102, "tunekeys"));
+    // round 147: + the range bar, the range presets, Reset scale and the view's navigation (the real-time corrector's)
+    v.push_back (section (0, 482, 800, 140, TR_NOOP ("TARGET NOTES")));
+    v.push_back (display (8, 502, 784, 114, "tunekeys"));
     return l;
 }
 
@@ -1896,6 +1897,27 @@ Layout emberLayout()
     v.push_back (toggle (12, 726, 110, 20, "Wide cuts", TR_NOOP ("Wide cuts")));
     v.push_back (dial (340, 712, 22, "Low cut (wide)", TR_NOOP ("Low cut")));
     v.push_back (dial (440, 712, 22, "High cut (wide)", TR_NOOP ("High cut")));
+    // round 147 (Saturn 2): the channel mode and each band's drive pan / pan
+    l.height = 870;
+    v.push_back (section (4, 760, 512, 106, TR_NOOP ("Stereo")));
+    v.push_back (tabs (12, 784, 140, 20, "Channel mode", TR_NOOP ("L/R|M/S"), { 0.0f, 1.0f }));
+    v.push_back (label (170, 778, 80, 14, TR_NOOP ("Drive pan")));
+    v.push_back (label (170, 818, 80, 14, TR_NOOP ("Pan")));
+    static const char* const drivePans[] { "B1 drive pan", "B2 drive pan", "B3 drive pan", "B4 drive pan" };
+    static const char* const pans[] { "B1 pan", "B2 pan", "B3 pan", "B4 pan" };
+    for (int b = 0; b < 4; ++b)
+        for (int r = 0; r < 2; ++r)
+        {
+            const auto cy = 792.0f + 40.0f * (float) r;
+            auto k = knob (280.0f + 60.0f * (float) b, cy, 16, r == 0 ? drivePans[b] : pans[b], nullptr, cy + 9.0f, noCaption | bipolar, 0);
+            k.colour = b;
+            if (b > 0)
+            {
+                k.whenParam = "Bands";
+                k.whenMin = 0.17f + 0.333f * (float) (b - 1);
+            }
+            v.push_back (k);
+        }
     return l;
 }
 

+ 72 - 0
src/ui/I18nData.h

@@ -11091,5 +11091,77 @@ inline constexpr unsigned char ptBR[] = {
 115, 32, 103, 108, 111, 98, 97, 105, 115, 41, 34, 10, 34, 103, 108, 111, 98, 97, 108, 34, 32, 61, 32, 34,
 103, 108, 111, 98, 97, 108, 34, 10, 34, 80, 97, 116, 116, 101, 114, 110, 32, 101, 118, 101, 110, 116, 115, 34,
 32, 61, 32, 34, 69, 118, 101, 110, 116, 111, 115, 32, 100, 111, 32, 112, 97, 116, 116, 101, 114, 110, 34, 10,
+34, 68, 114, 105, 118, 101, 32, 112, 97, 110, 34, 32, 61, 32, 34, 80, 97, 110, 32, 100, 111, 32, 100, 114,
+105, 118, 101, 34, 10, 34, 76, 47, 82, 124, 77, 47, 83, 34, 32, 61, 32, 34, 76, 47, 82, 124, 77, 47,
+83, 34, 10, 34, 66, 97, 114, 105, 116, 111, 110, 101, 34, 32, 61, 32, 34, 66, 97, 114, 195, 173, 116, 111,
+110, 111, 34, 10, 34, 84, 101, 110, 111, 114, 34, 32, 61, 32, 34, 84, 101, 110, 111, 114, 34, 10, 34, 65,
+108, 116, 111, 34, 32, 61, 32, 34, 67, 111, 110, 116, 114, 97, 108, 116, 111, 34, 10, 34, 77, 101, 122, 122,
+111, 34, 32, 61, 32, 34, 77, 101, 122, 122, 111, 34, 10, 34, 83, 111, 112, 114, 97, 110, 111, 34, 32, 61,
+32, 34, 83, 111, 112, 114, 97, 110, 111, 34, 10, 34, 71, 101, 110, 101, 114, 105, 99, 34, 32, 61, 32, 34,
+71, 101, 110, 195, 169, 114, 105, 99, 111, 34, 10, 34, 82, 101, 115, 101, 116, 32, 115, 99, 97, 108, 101, 34,
+32, 61, 32, 34, 82, 101, 105, 110, 105, 99, 105, 97, 114, 32, 101, 115, 99, 97, 108, 97, 34, 10, 34, 66,
+121, 112, 97, 115, 115, 32, 109, 111, 100, 101, 58, 32, 97, 32, 107, 101, 121, 32, 115, 119, 105, 116, 99, 104,
+101, 115, 32, 105, 116, 115, 32, 110, 111, 116, 101, 32, 98, 101, 116, 119, 101, 101, 110, 32, 99, 111, 114, 114,
+101, 99, 116, 101, 100, 32, 97, 110, 100, 32, 112, 97, 115, 115, 101, 100, 32, 97, 115, 32, 115, 117, 110, 103,
+34, 32, 61, 32, 34, 77, 111, 100, 111, 32, 66, 121, 112, 97, 115, 115, 58, 32, 117, 109, 97, 32, 116, 101,
+99, 108, 97, 32, 97, 108, 116, 101, 114, 110, 97, 32, 97, 32, 110, 111, 116, 97, 32, 101, 110, 116, 114, 101,
+32, 99, 111, 114, 114, 105, 103, 105, 100, 97, 32, 101, 32, 112, 97, 115, 115, 97, 100, 97, 32, 99, 111, 109,
+111, 32, 99, 97, 110, 116, 97, 100, 97, 34, 10, 34, 82, 101, 109, 111, 118, 101, 32, 109, 111, 100, 101, 58,
+32, 97, 32, 107, 101, 121, 32, 99, 121, 99, 108, 101, 115, 32, 105, 116, 115, 32, 110, 111, 116, 101, 58, 32,
+108, 101, 103, 97, 108, 44, 32, 105, 108, 108, 101, 103, 97, 108, 32, 40, 116, 111, 32, 116, 104, 101, 32, 110,
+101, 97, 114, 101, 115, 116, 32, 110, 111, 116, 101, 41, 44, 32, 105, 108, 108, 101, 103, 97, 108, 32, 112, 105,
+116, 99, 104, 32, 117, 112, 44, 32, 105, 108, 108, 101, 103, 97, 108, 32, 112, 105, 116, 99, 104, 32, 100, 111,
+119, 110, 34, 32, 61, 32, 34, 77, 111, 100, 111, 32, 82, 101, 109, 111, 118, 101, 114, 58, 32, 117, 109, 97,
+32, 116, 101, 99, 108, 97, 32, 112, 101, 114, 99, 111, 114, 114, 101, 32, 111, 115, 32, 101, 115, 116, 97, 100,
+111, 115, 32, 100, 97, 32, 110, 111, 116, 97, 58, 32, 118, 195, 161, 108, 105, 100, 97, 44, 32, 105, 110, 118,
+195, 161, 108, 105, 100, 97, 32, 40, 112, 97, 114, 97, 32, 97, 32, 110, 111, 116, 97, 32, 109, 97, 105, 115,
+32, 112, 114, 195, 179, 120, 105, 109, 97, 41, 44, 32, 105, 110, 118, 195, 161, 108, 105, 100, 97, 32, 112, 97,
+114, 97, 32, 99, 105, 109, 97, 44, 32, 105, 110, 118, 195, 161, 108, 105, 100, 97, 32, 112, 97, 114, 97, 32,
+98, 97, 105, 120, 111, 34, 10, 34, 82, 101, 115, 101, 116, 32, 115, 99, 97, 108, 101, 58, 32, 101, 118, 101,
+114, 121, 32, 110, 111, 116, 101, 32, 111, 102, 32, 116, 104, 101, 32, 115, 99, 97, 108, 101, 32, 108, 101, 103,
+97, 108, 32, 97, 103, 97, 105, 110, 44, 32, 110, 111, 116, 104, 105, 110, 103, 32, 98, 121, 112, 97, 115, 115,
+101, 100, 34, 32, 61, 32, 34, 82, 101, 105, 110, 105, 99, 105, 97, 114, 32, 101, 115, 99, 97, 108, 97, 58,
+32, 116, 111, 100, 97, 115, 32, 97, 115, 32, 110, 111, 116, 97, 115, 32, 100, 97, 32, 101, 115, 99, 97, 108,
+97, 32, 118, 195, 161, 108, 105, 100, 97, 115, 32, 100, 101, 32, 110, 111, 118, 111, 44, 32, 110, 97, 100, 97,
+32, 101, 109, 32, 98, 121, 112, 97, 115, 115, 34, 10, 34, 82, 97, 110, 103, 101, 32, 112, 114, 101, 115, 101,
+116, 58, 32, 110, 111, 116, 101, 115, 32, 115, 117, 110, 103, 32, 111, 117, 116, 115, 105, 100, 101, 32, 116, 104,
+101, 32, 114, 97, 110, 103, 101, 32, 112, 97, 115, 115, 32, 117, 110, 99, 111, 114, 114, 101, 99, 116, 101, 100,
+32, 40, 71, 101, 110, 101, 114, 105, 99, 58, 32, 116, 104, 101, 32, 119, 104, 111, 108, 101, 32, 107, 101, 121,
+98, 111, 97, 114, 100, 41, 34, 32, 61, 32, 34, 80, 114, 101, 100, 101, 102, 105, 110, 105, 195, 167, 195, 163,
+111, 32, 100, 101, 32, 101, 120, 116, 101, 110, 115, 195, 163, 111, 58, 32, 110, 111, 116, 97, 115, 32, 99, 97,
+110, 116, 97, 100, 97, 115, 32, 102, 111, 114, 97, 32, 100, 97, 32, 101, 120, 116, 101, 110, 115, 195, 163, 111,
+32, 112, 97, 115, 115, 97, 109, 32, 115, 101, 109, 32, 99, 111, 114, 114, 101, 195, 167, 195, 163, 111, 32, 40,
+71, 101, 110, 195, 169, 114, 105, 99, 111, 58, 32, 111, 32, 116, 101, 99, 108, 97, 100, 111, 32, 105, 110, 116,
+101, 105, 114, 111, 41, 34, 10, 34, 75, 101, 121, 98, 111, 97, 114, 100, 32, 118, 105, 101, 119, 58, 32, 115,
+104, 111, 119, 32, 109, 111, 114, 101, 32, 47, 32, 102, 101, 119, 101, 114, 32, 111, 99, 116, 97, 118, 101, 115,
+34, 32, 61, 32, 34, 86, 105, 115, 116, 97, 32, 100, 111, 32, 116, 101, 99, 108, 97, 100, 111, 58, 32, 109,
+111, 115, 116, 114, 97, 114, 32, 109, 97, 105, 115, 32, 47, 32, 109, 101, 110, 111, 115, 32, 111, 105, 116, 97,
+118, 97, 115, 34, 10, 34, 75, 101, 121, 98, 111, 97, 114, 100, 32, 118, 105, 101, 119, 58, 32, 115, 99, 114,
+111, 108, 108, 32, 100, 111, 119, 110, 32, 47, 32, 117, 112, 32, 97, 110, 32, 111, 99, 116, 97, 118, 101, 34,
+32, 61, 32, 34, 86, 105, 115, 116, 97, 32, 100, 111, 32, 116, 101, 99, 108, 97, 100, 111, 58, 32, 114, 111,
+108, 97, 114, 32, 117, 109, 97, 32, 111, 105, 116, 97, 118, 97, 32, 112, 97, 114, 97, 32, 98, 97, 105, 120,
+111, 32, 47, 32, 112, 97, 114, 97, 32, 99, 105, 109, 97, 34, 10, 34, 76, 97, 116, 99, 104, 58, 32, 111,
+102, 102, 32, 61, 32, 97, 32, 107, 101, 121, 39, 115, 32, 101, 100, 105, 116, 32, 108, 97, 115, 116, 115, 32,
+111, 110, 108, 121, 32, 119, 104, 105, 108, 101, 32, 105, 116, 32, 105, 115, 32, 104, 101, 108, 100, 34, 32, 61,
+32, 34, 84, 114, 97, 118, 97, 58, 32, 100, 101, 115, 108, 105, 103, 97, 100, 97, 32, 61, 32, 97, 32, 101,
+100, 105, 195, 167, 195, 163, 111, 32, 100, 101, 32, 117, 109, 97, 32, 116, 101, 99, 108, 97, 32, 100, 117, 114,
+97, 32, 115, 195, 179, 32, 101, 110, 113, 117, 97, 110, 116, 111, 32, 101, 108, 97, 32, 195, 169, 32, 115, 101,
+103, 117, 114, 97, 100, 97, 34, 10, 34, 82, 97, 110, 103, 101, 58, 32, 100, 114, 97, 103, 32, 97, 32, 98,
+111, 117, 110, 100, 97, 114, 121, 59, 32, 110, 111, 116, 101, 115, 32, 115, 117, 110, 103, 32, 111, 117, 116, 115,
+105, 100, 101, 32, 105, 116, 32, 112, 97, 115, 115, 32, 117, 110, 99, 111, 114, 114, 101, 99, 116, 101, 100, 34,
+32, 61, 32, 34, 69, 120, 116, 101, 110, 115, 195, 163, 111, 58, 32, 97, 114, 114, 97, 115, 116, 101, 32, 117,
+109, 32, 108, 105, 109, 105, 116, 101, 59, 32, 110, 111, 116, 97, 115, 32, 99, 97, 110, 116, 97, 100, 97, 115,
+32, 102, 111, 114, 97, 32, 100, 101, 108, 97, 32, 112, 97, 115, 115, 97, 109, 32, 115, 101, 109, 32, 99, 111,
+114, 114, 101, 195, 167, 195, 163, 111, 34, 10, 34, 67, 108, 105, 99, 107, 32, 97, 32, 107, 101, 121, 58, 32,
+99, 104, 97, 110, 103, 101, 32, 116, 104, 97, 116, 32, 110, 111, 116, 101, 39, 115, 32, 115, 116, 97, 116, 117,
+115, 32, 105, 110, 32, 101, 118, 101, 114, 121, 32, 111, 99, 116, 97, 118, 101, 34, 32, 61, 32, 34, 67, 108,
+105, 113, 117, 101, 32, 110, 117, 109, 97, 32, 116, 101, 99, 108, 97, 58, 32, 109, 117, 100, 97, 32, 111, 32,
+101, 115, 116, 97, 100, 111, 32, 100, 101, 115, 115, 97, 32, 110, 111, 116, 97, 32, 101, 109, 32, 116, 111, 100,
+97, 115, 32, 97, 115, 32, 111, 105, 116, 97, 118, 97, 115, 34, 10, 34, 67, 108, 105, 99, 107, 32, 97, 32,
+107, 101, 121, 58, 32, 98, 121, 112, 97, 115, 115, 32, 47, 32, 99, 111, 114, 114, 101, 99, 116, 32, 116, 104,
+97, 116, 32, 110, 111, 116, 101, 32, 105, 110, 32, 101, 118, 101, 114, 121, 32, 111, 99, 116, 97, 118, 101, 34,
+32, 61, 32, 34, 67, 108, 105, 113, 117, 101, 32, 110, 117, 109, 97, 32, 116, 101, 99, 108, 97, 58, 32, 98,
+121, 112, 97, 115, 115, 32, 47, 32, 99, 111, 114, 114, 105, 103, 105, 114, 32, 101, 115, 115, 97, 32, 110, 111,
+116, 97, 32, 101, 109, 32, 116, 111, 100, 97, 115, 32, 97, 115, 32, 111, 105, 116, 97, 118, 97, 115, 34, 10,
 };
 } // namespace lynx::i18n::data

+ 235 - 57
src/ui/PluginEditors.cpp

@@ -1127,39 +1127,76 @@ public:
         g.drawText (tr ("HOLD"), juce::Rectangle<float> (inner, 12.0f * s).withCentre (c.translated (0.0f, inner * 0.78f)), juce::Justification::centred);
     }
 
-    // --- LYNX Tune's keyboard (round 128) --------------------------------------------------------------
-    // Four octaves (C2 … B5) as in the auto-mode correctors; a key edits its note name in every octave: in BYPASS mode
-    // it switches "pass uncorrected" (still a target, no correction), in REMOVE mode it removes the note from the
-    // targets. LATCH off = the edit lasts only while the key is held (live use).
-    static constexpr int tuneOctaves = 4;
+    // --- LYNX Tune's keyboard (round 128; round 147: the Waves Tune Real-Time role's keyboard) ----------------------
+    // A key edits its note name in every octave (the reference's Group Octaves, always on here): in BYPASS mode it
+    // switches "pass uncorrected" (still a target, no correction), in REMOVE mode a click cycles the note's status like
+    // the reference's — legal → illegal (to the nearest legal note) → illegal, pitch up → illegal, pitch down → legal.
+    // LATCH off = the edit lasts only while the key is held (live use). Round 147: the view's navigation (− / + = fewer
+    // / more octaves, ◀ / ▶ = scroll), the range bar over the keys (click or drag near a boundary: the notes outside
+    // the range pass uncorrected), the range presets and Reset scale.
+    int tuneFirstOctave = 2, tuneShownOctaves = 4; // the view: C2 … B5 by default (the editor's own, not saved)
+    int tuneRangeDrag = -1;                       // 0 = the low boundary, 1 = the high one
+    enum TuneButton { tbBypass, tbRemove, tbReset, tbRange0, tbZoomOut = tbRange0 + lynxtune::rangePresets, tbZoomIn, tbLeft, tbRight, tbLatch, tbCount };
     juce::Rectangle<float> tuneKeysStrip (juce::Rectangle<float> r) const { return r.withHeight (22.0f * scale()); }
-    juce::Rectangle<float> tuneKeysBed (juce::Rectangle<float> r) const { return r.withTrimmedTop (26.0f * scale()).reduced (2.0f * scale(), 2.0f * scale()); }
-    juce::Rectangle<float> tuneModeButton (juce::Rectangle<float> r, int which) const // 0 bypass, 1 remove, 2 latch
+    juce::Rectangle<float> tuneKeysBed (juce::Rectangle<float> r) const { return r.withTrimmedTop (36.0f * scale()).reduced (2.0f * scale(), 2.0f * scale()); }
+    juce::Rectangle<float> tuneRangeBar (juce::Rectangle<float> r) const
     {
         const auto s = scale();
-        const auto strip = tuneKeysStrip (r).reduced (2.0f * s, 2.0f * s);
-        return which == 2 ? strip.withLeft (strip.getRight() - 70.0f * s) : strip.withWidth (78.0f * s).translated ((float) which * 82.0f * s, 0.0f);
+        const auto bed = tuneKeysBed (r);
+        return { bed.getX(), bed.getY() - 10.0f * s, bed.getWidth(), 8.0f * s };
     }
-    // pitch class (0…11) and octave index of the key under p, −1 = none
+    juce::Rectangle<float> tuneModeButton (juce::Rectangle<float> r, int which) const
+    {
+        const auto s = scale();
+        const auto strip = tuneKeysStrip (r).reduced (2.0f * s, 2.0f * s);
+        auto at = [&] (float x, float w) { return juce::Rectangle<float> (strip.getX() + x * s, strip.getY(), w * s, strip.getHeight()); };
+        if (which == tbBypass) return at (0.0f, 66.0f);
+        if (which == tbRemove) return at (70.0f, 66.0f);
+        if (which == tbReset) return at (144.0f, 74.0f);
+        if (which >= tbRange0 && which < tbZoomOut) return at (230.0f + 54.0f * (float) (which - tbRange0), 52.0f);
+        if (which >= tbZoomOut && which <= tbRight) return at (618.0f + 24.0f * (float) (which - tbZoomOut), 22.0f);
+        return strip.withLeft (strip.getRight() - 62.0f * s); // LATCH
+    }
+    int tuneVisibleWhites() const { return 7 * tuneShownOctaves; }
+    int tuneFirstNote() const { return 12 * (tuneFirstOctave + 1); } // MIDI note of the first C shown (C4 = 60)
+    float tuneNoteX (juce::Rectangle<float> bed, int note) const     // the left edge of a note's white key column
+    {
+        static const int whiteOf[12] { 0, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6 };
+        const auto rel = note - tuneFirstNote();
+        const auto oct = (int) std::floor ((double) rel / 12.0);
+        const auto w = 7 * oct + whiteOf[((rel % 12) + 12) % 12];
+        return bed.getX() + bed.getWidth() * (float) w / (float) tuneVisibleWhites();
+    }
+    // the MIDI note of the key under p, −1 = none
     int tuneKeyAt (juce::Rectangle<float> r, juce::Point<float> p) const
     {
         const auto bed = tuneKeysBed (r);
         if (! bed.contains (p))
             return -1;
         static const int whitePc[7] { 0, 2, 4, 5, 7, 9, 11 };
-        const auto ww = bed.getWidth() / (float) (7 * tuneOctaves);
+        const auto n = tuneVisibleWhites();
+        const auto ww = bed.getWidth() / (float) n;
         if (p.y < bed.getY() + bed.getHeight() * 0.6f) // black keys first (on top)
-            for (int w = 0; w < 7 * tuneOctaves; ++w)
+            for (int w = 0; w < n; ++w)
             {
                 const auto pc = whitePc[w % 7];
                 if (pc == 4 || pc == 11)
                     continue;
                 const auto bx = bed.getX() + ww * (float) (w + 1) - ww * 0.3f;
                 if (p.x >= bx && p.x < bx + ww * 0.6f)
-                    return pc + 1;
+                    return tuneFirstNote() + 12 * (w / 7) + pc + 1;
             }
-        const auto w = juce::jlimit (0, 7 * tuneOctaves - 1, (int) ((p.x - bed.getX()) / ww));
-        return whitePc[w % 7];
+        const auto w = juce::jlimit (0, n - 1, (int) ((p.x - bed.getX()) / ww));
+        return tuneFirstNote() + 12 * (w / 7) + whitePc[w % 7];
+    }
+    // the note under x in the range bar (the nearest white-key column), clamped to the view
+    int tuneNoteAtX (juce::Rectangle<float> r, float x) const
+    {
+        const auto bed = tuneKeysBed (r);
+        static const int whitePc[7] { 0, 2, 4, 5, 7, 9, 11 };
+        const auto n = tuneVisibleWhites();
+        const auto w = juce::jlimit (0, n - 1, (int) ((x - bed.getX()) / (bed.getWidth() / (float) n)));
+        return tuneFirstNote() + 12 * (w / 7) + whitePc[w % 7];
     }
     void paintTuneKeys (juce::Graphics& g, juce::Rectangle<float> r, const EffectSlot& fx)
     {
@@ -1168,115 +1205,246 @@ public:
         const auto& p = fx.params;
         const auto sc = (vocal::Scale) lynxtune::effectiveScale (p[lynxtune::scale], p[lynxtune::moreScales]);
         const auto inScale = vocal::scaleMask (sc, lynxtune::keyIndex (p[lynxtune::key]), 0xfff);
-        // mode buttons, latch, legend
-        const char* const names[3] { TR_NOOP ("Bypass"), TR_NOOP ("Remove"), TR_NOOP ("Latch") };
-        for (int b = 0; b < 3; ++b)
+        const auto lowNote = lynxtune::rangeNote (p[lynxtune::rangeLow]), highNote = lynxtune::rangeNote (p[lynxtune::rangeHigh]);
+        // the strip: modes, Reset scale, the range presets, the view's navigation, latch
+        for (int b = 0; b < tbCount; ++b)
         {
             const auto br = tuneModeButton (r, b);
-            const auto lit = b == 2 ? tuneLatch : tuneRemove == (b == 1);
-            skin::button (g, br, lit, br.contains (mouseAt), b == 0 ? juce::Colour (0xffe0a040) : accent, radius::sm * s);
+            bool lit = false;
+            juce::String name;
+            if (b == tbBypass) { lit = ! tuneRemove; name = tr ("Bypass"); }
+            else if (b == tbRemove) { lit = tuneRemove; name = tr ("Remove"); }
+            else if (b == tbReset) name = tr ("Reset scale");
+            else if (b >= tbRange0 && b < tbZoomOut)
+            {
+                const auto [lo, hi] = lynxtune::rangePresetNotes (b - tbRange0);
+                lit = lo == lowNote && hi == highNote;
+                name = tr (lynxtune::rangePresetName (b - tbRange0));
+            }
+            else if (b == tbZoomOut) name = "-";
+            else if (b == tbZoomIn) name = "+";
+            else if (b == tbLeft) name = "<";
+            else if (b == tbRight) name = ">";
+            else { lit = tuneLatch; name = tr ("Latch"); }
+            skin::button (g, br, lit, br.contains (mouseAt), b == tbBypass ? juce::Colour (0xffe0a040) : accent, radius::sm * s);
             g.setColour (lit ? colour::textPrimary : colour::textSecondary);
             g.setFont (font (juce::jmax (8.0f, 10.0f * s), true));
-            g.drawText (tr (names[b]), br, juce::Justification::centred);
+            g.drawText (name, br, juce::Justification::centred);
         }
-        g.setColour (colour::textDisabled);
-        g.setFont (font (juce::jmax (7.0f, 9.0f * s)));
-        g.drawText (tr ("Click a key: {0} that note in every octave", { tuneRemove ? tr ("remove / restore") : tr ("bypass / correct") }),
-                    tuneKeysStrip (r).withTrimmedLeft (170.0f * s).withTrimmedRight (80.0f * s), juce::Justification::centred, true);
-        // keys
+        // the range bar: the notes inside the range lit, the two boundaries as handles
         const auto bed = tuneKeysBed (r);
-        const auto ww = bed.getWidth() / (float) (7 * tuneOctaves);
+        {
+            const auto rb = tuneRangeBar (r);
+            g.setColour (colour::bg0);
+            g.fillRoundedRectangle (rb, 2.0f * s);
+            const auto x0 = juce::jlimit (rb.getX(), rb.getRight(), tuneNoteX (bed, lowNote));
+            const auto x1 = juce::jlimit (rb.getX(), rb.getRight(), tuneNoteX (bed, highNote + 1));
+            if (x1 > x0)
+            {
+                g.setColour (accent.withAlpha (fx.enabled ? 0.55f : 0.25f));
+                g.fillRoundedRectangle (juce::Rectangle<float> (x0, rb.getY(), x1 - x0, rb.getHeight()), 2.0f * s);
+            }
+            g.setColour (colour::textPrimary);
+            for (const auto x : { x0, x1 })
+                if (x > rb.getX() && x < rb.getRight())
+                    g.fillRect (juce::Rectangle<float> (3.0f * s, rb.getHeight() + 4.0f * s).withCentre ({ x, rb.getCentreY() }));
+        }
+        // keys
+        const auto n = tuneVisibleWhites();
+        const auto ww = bed.getWidth() / (float) n;
         static const int whitePc[7] { 0, 2, 4, 5, 7, 9, 11 };
-        const auto sungPc = pitchHistory.empty() || pitchHistory.back().sung < 0.5f ? -1 : ((int) std::lround (pitchHistory.back().target) % 12 + 12) % 12;
-        auto keyColour = [&] (int pc, bool black) {
-            const auto on = p[(std::size_t) (lynxtune::noteC + pc)] >= 0.5f && ((inScale >> pc) & 1u) != 0;
+        const auto sungNote = pitchHistory.empty() || pitchHistory.back().sung < 0.5f ? -1 : (int) std::lround (pitchHistory.back().target);
+        auto legal = [&] (int pc) { return p[(std::size_t) (lynxtune::noteC + pc)] >= 0.5f && ((inScale >> pc) & 1u) != 0; };
+        auto keyColour = [&] (int note, bool black) {
+            const auto pc = note % 12;
             const auto bypassed = p[(std::size_t) (lynxtune::bypassC + pc)] >= 0.5f;
             auto c = black ? juce::Colour (0xff1c1e24) : juce::Colour (0xffd9dbe0);
-            if (! on)
+            if (! legal (pc))
                 c = black ? juce::Colour (0xff101114) : juce::Colour (0xff5a5d66); // removed / not in the scale
             else if (bypassed)
                 c = black ? juce::Colour (0xff6b4d16) : juce::Colour (0xffe6be6e);
+            if (note < lowNote || note > highNote) // outside the range: passes uncorrected
+                c = c.interpolatedWith (colour::bg0, 0.55f);
             return c;
         };
-        auto mark = [&] (juce::Rectangle<float> k, int pc) {
-            const auto on = p[(std::size_t) (lynxtune::noteC + pc)] >= 0.5f && ((inScale >> pc) & 1u) != 0;
-            if (on && fx.enabled) // a target: the accent line at the key's top
+        auto mark = [&] (juce::Rectangle<float> k, int note) {
+            const auto pc = note % 12;
+            const auto inRange = note >= lowNote && note <= highNote;
+            if (legal (pc) && fx.enabled && inRange) // a target: the accent line at the key's top
             {
                 g.setColour (p[(std::size_t) (lynxtune::bypassC + pc)] >= 0.5f ? juce::Colour (0xffe0a040) : accent);
                 g.fillRect (k.withHeight (3.0f * s));
             }
-            if (! on && ((inScale >> pc) & 1u) != 0) // removed by hand: a cross
+            if (! legal (pc))
             {
+                const auto dir = lynxtune::noteDir (p[(std::size_t) (lynxtune::noteDirC + pc)]);
                 const auto x = juce::Rectangle<float> (7.0f * s, 7.0f * s).withCentre ({ k.getCentreX(), k.getY() + 10.0f * s });
                 g.setColour (accent.withAlpha (0.9f));
-                g.drawLine (x.getX(), x.getY(), x.getRight(), x.getBottom(), 1.5f * s);
-                g.drawLine (x.getRight(), x.getY(), x.getX(), x.getBottom(), 1.5f * s);
+                if (dir != lynxtune::NoteDir::nearest) // illegal, pitch up / down: an arrow
+                {
+                    juce::Path a;
+                    const auto up = dir == lynxtune::NoteDir::up;
+                    a.addTriangle (x.getX(), up ? x.getBottom() : x.getY(), x.getRight(), up ? x.getBottom() : x.getY(), x.getCentreX(), up ? x.getY() : x.getBottom());
+                    g.fillPath (a);
+                }
+                else if (((inScale >> pc) & 1u) != 0) // removed by hand: a cross
+                {
+                    g.drawLine (x.getX(), x.getY(), x.getRight(), x.getBottom(), 1.5f * s);
+                    g.drawLine (x.getRight(), x.getY(), x.getX(), x.getBottom(), 1.5f * s);
+                }
             }
-            if (pc == sungPc && fx.enabled)
+            if (note == sungNote && fx.enabled)
             {
                 g.setColour (accent.withAlpha (0.55f));
                 g.fillEllipse (juce::Rectangle<float> (7.0f * s, 7.0f * s).withCentre ({ k.getCentreX(), k.getBottom() - 9.0f * s }));
             }
         };
-        for (int w = 0; w < 7 * tuneOctaves; ++w)
+        for (int w = 0; w < n; ++w)
         {
-            const auto pc = whitePc[w % 7];
+            const auto note = tuneFirstNote() + 12 * (w / 7) + whitePc[w % 7];
             const auto k = juce::Rectangle<float> (bed.getX() + ww * (float) w, bed.getY(), ww - 1.0f, bed.getHeight());
-            g.setColour (keyColour (pc, false));
+            g.setColour (keyColour (note, false));
             g.fillRoundedRectangle (k, 2.0f * s);
-            mark (k, pc);
-            if (pc == 0)
+            mark (k, note);
+            if (note % 12 == 0)
             {
                 g.setColour (juce::Colour (0xff3a3d45));
                 g.setFont (font (juce::jmax (7.0f, 9.0f * s)));
-                g.drawText ("C" + juce::String (2 + w / 7), k.withTrimmedBottom (2.0f * s).withTop (k.getBottom() - 14.0f * s), juce::Justification::centred);
+                g.drawText ("C" + juce::String (note / 12 - 1), k.withTrimmedBottom (2.0f * s).withTop (k.getBottom() - 14.0f * s), juce::Justification::centred);
             }
         }
-        for (int w = 0; w < 7 * tuneOctaves; ++w)
+        for (int w = 0; w < n; ++w)
         {
             const auto pc = whitePc[w % 7];
             if (pc == 4 || pc == 11)
                 continue;
+            const auto note = tuneFirstNote() + 12 * (w / 7) + pc + 1;
             const auto k = juce::Rectangle<float> (bed.getX() + ww * (float) (w + 1) - ww * 0.3f, bed.getY(), ww * 0.6f, bed.getHeight() * 0.6f);
-            g.setColour (keyColour (pc + 1, true));
+            g.setColour (keyColour (note, true));
             g.fillRoundedRectangle (k, 2.0f * s);
-            mark (k, pc + 1);
+            mark (k, note);
         }
     }
+    void tuneSetRangeAt (juce::Rectangle<float> r, float x, bool pickNearer)
+    {
+        const auto* fx = current();
+        if (fx == nullptr)
+            return;
+        const auto note = tuneNoteAtX (r, x);
+        const auto lo = lynxtune::rangeNote (fx->params[lynxtune::rangeLow]), hi = lynxtune::rangeNote (fx->params[lynxtune::rangeHigh]);
+        if (pickNearer)
+            tuneRangeDrag = std::abs (note - lo) <= std::abs (note - hi) ? 0 : 1;
+        if (tuneRangeDrag == 0)
+            setParams ({ { lynxtune::rangeLow, lynxtune::rangeNoteValue (juce::jmin (note, hi)) } });
+        else if (tuneRangeDrag == 1)
+            setParams ({ { lynxtune::rangeHigh, lynxtune::rangeNoteValue (juce::jmax (note, lo)) } });
+        const auto shown = tuneRangeDrag == 0 ? lynxtune::rangeLow : lynxtune::rangeHigh;
+        ui::showValueTip (*this, tuneRangeBar (r).toNearestInt(), tr ("Range") + " " + juce::String (lynxtune::paramText (shown, current()->params[(std::size_t) shown])));
+    }
     void tuneKeyClick (juce::Rectangle<float> r, juce::Point<float> at)
     {
         const auto* fx = current();
         if (fx == nullptr)
             return;
-        for (int b = 0; b < 3; ++b)
+        for (int b = 0; b < tbCount; ++b)
             if (tuneModeButton (r, b).contains (at))
             {
-                if (b == 2)
+                if (b == tbLatch)
                     tuneLatch = ! tuneLatch;
-                else
-                    tuneRemove = b == 1;
+                else if (b == tbBypass || b == tbRemove)
+                    tuneRemove = b == tbRemove;
+                else if (b == tbReset) // every note of the scale legal again, nothing bypassed, no direction
+                {
+                    std::vector<std::pair<int, float>> c;
+                    for (int k = 0; k < 12; ++k)
+                    {
+                        c.push_back ({ lynxtune::noteC + k, 1.0f });
+                        c.push_back ({ lynxtune::bypassC + k, 0.0f });
+                        c.push_back ({ lynxtune::noteDirC + k, 0.0f });
+                    }
+                    setParams (c);
+                }
+                else if (b >= tbRange0 && b < tbZoomOut)
+                {
+                    // a range preset: the keyboard's range, and the detector's input type that covers it
+                    const auto k = b - tbRange0;
+                    const auto [lo, hi] = lynxtune::rangePresetNotes (k);
+                    std::vector<std::pair<int, float>> c { { lynxtune::rangeLow, lynxtune::rangeNoteValue (lo) }, { lynxtune::rangeHigh, lynxtune::rangeNoteValue (hi) } };
+                    static constexpr float inputType[lynxtune::rangePresets] { 2.0f / 3.0f, 2.0f / 3.0f, 1.0f / 3.0f, 1.0f / 3.0f, 0.0f, 0.0f, -1.0f };
+                    if (inputType[k] >= 0.0f)
+                        c.push_back ({ lynxtune::range, inputType[k] });
+                    setParams (c);
+                }
+                else if (b == tbZoomOut) tuneShownOctaves = juce::jmin (7, tuneShownOctaves + 1);
+                else if (b == tbZoomIn) tuneShownOctaves = juce::jmax (2, tuneShownOctaves - 1);
+                else if (b == tbLeft) tuneFirstOctave = juce::jmax (0, tuneFirstOctave - 1);
+                else if (b == tbRight) tuneFirstOctave = juce::jmin (9 - tuneShownOctaves, tuneFirstOctave + 1);
+                tuneFirstOctave = juce::jlimit (0, juce::jmax (0, 9 - tuneShownOctaves), tuneFirstOctave);
                 repaint();
                 return;
             }
-        const auto pc = tuneKeyAt (r, at);
-        if (pc < 0)
+        if (tuneRangeBar (r).expanded (0.0f, 2.0f * scale()).contains (at))
+        {
+            tuneSetRangeAt (r, at.x, true);
             return;
-        const auto onP = lynxtune::noteC + pc, byP = lynxtune::bypassC + pc;
+        }
+        const auto note = tuneKeyAt (r, at);
+        if (note < 0)
+            return;
+        const auto pc = note % 12;
+        const auto onP = lynxtune::noteC + pc, byP = lynxtune::bypassC + pc, dirP = lynxtune::noteDirC + pc;
         const auto on = fx->params[(std::size_t) onP] >= 0.5f, by = fx->params[(std::size_t) byP] >= 0.5f;
+        const auto dir = lynxtune::noteDir (fx->params[(std::size_t) dirP]);
         tuneHeld = tuneLatch ? -1 : pc;
         tuneHeldValues = { fx->params[(std::size_t) onP], fx->params[(std::size_t) byP] };
+        tuneHeldDir = fx->params[(std::size_t) dirP];
         if (tuneRemove)
-            setParams ({ { onP, on ? 0.0f : 1.0f }, { byP, 0.0f } });
+        {
+            // the reference's status cycle: legal → illegal → illegal, pitch up → illegal, pitch down → legal (a note
+            // outside the scale stays illegal: only its direction cycles)
+            const auto sc = (vocal::Scale) lynxtune::effectiveScale (fx->params[lynxtune::scale], fx->params[lynxtune::moreScales]);
+            const bool scaleNote = ((vocal::scaleMask (sc, lynxtune::keyIndex (fx->params[lynxtune::key]), 0xfff) >> pc) & 1u) != 0;
+            const auto nextDir = dir == lynxtune::NoteDir::nearest ? 0.5f : (dir == lynxtune::NoteDir::up ? 1.0f : 0.0f);
+            if (scaleNote && on)
+                setParams ({ { onP, 0.0f }, { byP, 0.0f }, { dirP, 0.0f } });
+            else if (scaleNote && dir == lynxtune::NoteDir::down)
+                setParams ({ { onP, 1.0f }, { byP, 0.0f }, { dirP, 0.0f } });
+            else
+                setParams ({ { onP, on ? 1.0f : 0.0f }, { byP, 0.0f }, { dirP, nextDir } });
+        }
         else
-            setParams ({ { onP, 1.0f }, { byP, by && on ? 0.0f : 1.0f } });
+            setParams ({ { onP, 1.0f }, { byP, by && on ? 0.0f : 1.0f }, { dirP, 0.0f } });
     }
     void tuneKeyRelease()
     {
+        if (tuneRangeDrag >= 0)
+        {
+            tuneRangeDrag = -1;
+            ui::hideValueTip();
+        }
         if (tuneHeld < 0)
             return;
-        setParams ({ { lynxtune::noteC + tuneHeld, tuneHeldValues.first }, { lynxtune::bypassC + tuneHeld, tuneHeldValues.second } });
+        setParams ({ { lynxtune::noteC + tuneHeld, tuneHeldValues.first }, { lynxtune::bypassC + tuneHeld, tuneHeldValues.second },
+                     { lynxtune::noteDirC + tuneHeld, tuneHeldDir } });
         tuneHeld = -1;
     }
+    juce::String tuneKeysHint (juce::Rectangle<float> r, juce::Point<float> at) const
+    {
+        for (int b = 0; b < tbCount; ++b)
+            if (tuneModeButton (r, b).contains (at))
+            {
+                if (b == tbBypass) return tr ("Bypass mode: a key switches its note between corrected and passed as sung");
+                if (b == tbRemove) return tr ("Remove mode: a key cycles its note: legal, illegal (to the nearest note), illegal pitch up, illegal pitch down");
+                if (b == tbReset) return tr ("Reset scale: every note of the scale legal again, nothing bypassed");
+                if (b >= tbRange0 && b < tbZoomOut) return tr ("Range preset: notes sung outside the range pass uncorrected (Generic: the whole keyboard)");
+                if (b == tbZoomOut || b == tbZoomIn) return tr ("Keyboard view: show more / fewer octaves");
+                if (b == tbLeft || b == tbRight) return tr ("Keyboard view: scroll down / up an octave");
+                return tr ("Latch: off = a key's edit lasts only while it is held");
+            }
+        if (tuneRangeBar (r).expanded (0.0f, 2.0f * scale()).contains (at))
+            return tr ("Range: drag a boundary; notes sung outside it pass uncorrected");
+        return tuneRemove ? tr ("Click a key: change that note's status in every octave") : tr ("Click a key: bypass / correct that note in every octave");
+    }
     void paintAutoKey (juce::Graphics& g, juce::Rectangle<float> r)
     {
         using namespace theme;
@@ -3109,6 +3277,13 @@ public:
             rhythmMouse (e, activeLayout().items[(std::size_t) dragItem], false);
             return;
         }
+        if (tuneRangeDrag >= 0) // round 147: LYNX Tune's range boundary
+        {
+            for (const auto& it : activeLayout().items)
+                if (it.type == Item::display && juce::String (it.display) == "tunekeys")
+                    tuneSetRangeAt (rectOf (it), e.position.x, false);
+            return;
+        }
         if (dragItem < 0 || ! drag.isActive())
             return;
         const auto& item = activeLayout().items[(std::size_t) dragItem];
@@ -3277,6 +3452,8 @@ public:
             return { tr ("VU display: what the meter shows (input level, gain reduction, output level)"), {}, false, false };
         if (item.type == Item::display && juce::String (item.display) == "xy")
             return { tr ("Drag the point: both values at once"), {}, false, false };
+        if (item.type == Item::display && juce::String (item.display) == "tunekeys") // round 147
+            return { tuneKeysHint (rectOf (item), p), {}, false, false };
         if (isRhythmEdit (item)) // round 144
             return { tr ("Rhythm taps: drag up / down = level, sideways = time; double-click = add or remove a tap; right-click = patterns"), {}, false, false };
         if (isRhythmPatterns (item))
@@ -3510,6 +3687,7 @@ private:
     PitchPoint holdPoint { 0.0f, 0.0f, 0.0f };
     int tuneHeld = -1, autoKeyFlash = 0;
     std::pair<float, float> tuneHeldValues { 1.0f, 0.0f };
+    float tuneHeldDir = 0.0f; // round 147
     std::array<double, 12> keyHistogram {};
     // is the scrolling pitch trace on the current page? (it then feeds the history; else the ring does)
     bool pitchTraced() const

+ 23 - 12
src/ui/ProEditors.cpp

@@ -2062,17 +2062,21 @@ private:
         out.push_back (button ({ a.getX() + 70.0f, a.getY() + 12.0f, 32.0f, 22.0f }, idPower, tr ("On"), powered (b), tr ("Band on / off: a band switched off passes clean")));
         out.push_back (button ({ a.getX() + 106.0f, a.getY() + 12.0f, 22.0f, 22.0f }, idSolo, "S", state (b) == BandState::solo, tr ("Solo the band")));
         out.push_back (button ({ a.getX() + 130.0f, a.getY() + 12.0f, 22.0f, 22.0f }, idMute, "M", state (b) == BandState::mute, tr ("Mute the band")));
-        add (menu ({ a.getX() + 160.0f, a.getY() + 10.0f, 150.0f, 26.0f }, fp (b, 0), {}, "Tube|Tape|Transistor|Fuzz"));
+        add (menu ({ a.getX() + 160.0f, a.getY() + 10.0f, 120.0f, 26.0f }, fp (b, 0), {}, "Tube|Tape|Transistor|Fuzz"));
         add (knob ({ a.getX() + 10.0f, a.getY() + 60.0f, 66.0f, 92.0f }, fp (b, 2), tr ("Mix")));
         add (knob ({ a.getX() + 78.0f, a.getY() + 60.0f, 66.0f, 92.0f }, xp (b, 6), tr ("Feedback")));
         add (knob ({ a.getX() + 146.0f, a.getY() + 60.0f, 66.0f, 92.0f }, xp (b, 7), tr ("Freq")));
         add (knob ({ a.getX() + 214.0f, a.getY() + 60.0f, 70.0f, 92.0f }, xp (b, 8), tr ("Dynamics"), 1, true));
-        add (knob ({ a.getX() + 290.0f, a.getY() + 24.0f, 132.0f, 144.0f }, fp (b, 1), tr ("Drive"), 2));
+        add (knob ({ a.getX() + 290.0f, a.getY() + 40.0f, 124.0f, 128.0f }, fp (b, 1), tr ("Drive"), 2));
+        // round 147 (Saturn 2): the drive pan beside the drive (the far channel's drive shrinks), the band's pan under
+        // its level; both act on left / right or on mid / side (the bottom bar's Channel)
+        add (knob ({ a.getX() + 352.0f, a.getY() + 2.0f, 74.0f, 52.0f }, bandDrivePanParam (b), tr ("Drive pan"), 0, true));
         add (fader ({ a.getX() + 432.0f, a.getY() + 14.0f, 42.0f, 148.0f }, xp (b, 2), tr ("Bass"), true));
         add (fader ({ a.getX() + 476.0f, a.getY() + 14.0f, 42.0f, 148.0f }, xp (b, 3), tr ("Mid"), true));
         add (fader ({ a.getX() + 520.0f, a.getY() + 14.0f, 42.0f, 148.0f }, xp (b, 4), tr ("Treble"), true));
         add (fader ({ a.getX() + 564.0f, a.getY() + 14.0f, 42.0f, 148.0f }, xp (b, 5), tr ("Presence"), true));
-        add (knob ({ a.getX() + 612.0f, a.getY() + 60.0f, 70.0f, 92.0f }, fp (b, 3), tr ("Level"), 1, true));
+        add (knob ({ a.getX() + 612.0f, a.getY() + 8.0f, 70.0f, 78.0f }, fp (b, 3), tr ("Level"), 1, true));
+        add (knob ({ a.getX() + 612.0f, a.getY() + 88.0f, 70.0f, 78.0f }, bandPanParam (b), tr ("Pan"), 1, true));
         if (count() > 1)
         {
             out.push_back (button ({ a.getRight() - 72.0f, a.getY() + 10.0f, 20.0f, 20.0f }, idPrev, "<", false, tr ("Previous / next band")));
@@ -2092,19 +2096,26 @@ private:
         out.push_back (toggle ({ s.getX() + 690.0f, s.getY(), 110.0f, s.getHeight() }, wideCuts, tr ("Wide cuts")));
         const auto bar = barArea();
         const auto cy = bar.getCentreY();
-        out.push_back (barMenu ({ 10.0f, cy - 11.0f, 160.0f, 22.0f }, xoverSlope, tr ("Crossover"), "12 dB/oct|24 dB/oct|48 dB/oct", { 0.0f, 0.5f, 1.0f }));
-        out.push_back (barMenu ({ 176.0f, cy - 11.0f, 140.0f, 22.0f }, quality, tr ("Oversampling"), "2x|4x|8x", { 0.0f, 0.5f, 1.0f }));
-        out.push_back (barMenu ({ 322.0f, cy - 11.0f, 100.0f, 22.0f }, bands, tr ("Bands"), "1|2|3|4"));
-        out.push_back (barValue ({ 428.0f, cy - 11.0f, 100.0f, 22.0f }, inputGain, tr ("In")));
-        out.push_back (barValue ({ 534.0f, cy - 11.0f, 90.0f, 22.0f }, tone, tr ("Tilt")));
-        out.push_back (barValue ({ 630.0f, cy - 11.0f, 120.0f, 22.0f }, wide() ? lowCutWide : lowCut, tr ("Low cut")));
-        out.push_back (barValue ({ 756.0f, cy - 11.0f, 130.0f, 22.0f }, wide() ? highCutWide : highCut, tr ("High cut")));
+        out.push_back (barMenu ({ 10.0f, cy - 11.0f, 150.0f, 22.0f }, xoverSlope, tr ("Crossover"), "12 dB/oct|24 dB/oct|48 dB/oct", { 0.0f, 0.5f, 1.0f }));
+        out.push_back (barMenu ({ 166.0f, cy - 11.0f, 130.0f, 22.0f }, quality, tr ("Oversampling"), "2x|4x|8x", { 0.0f, 0.5f, 1.0f }));
+        out.push_back (barMenu ({ 302.0f, cy - 11.0f, 90.0f, 22.0f }, bands, tr ("Bands"), "1|2|3|4"));
+        out.push_back (barValue ({ 398.0f, cy - 11.0f, 90.0f, 22.0f }, inputGain, tr ("In")));
+        out.push_back (barValue ({ 494.0f, cy - 11.0f, 80.0f, 22.0f }, tone, tr ("Tilt")));
+        out.push_back (barValue ({ 580.0f, cy - 11.0f, 110.0f, 22.0f }, wide() ? lowCutWide : lowCut, tr ("Low cut")));
+        out.push_back (barValue ({ 696.0f, cy - 11.0f, 120.0f, 22.0f }, wide() ? highCutWide : highCut, tr ("High cut")));
+        // round 147 (Saturn 2's channel mode): the bands work on left / right or on mid / side
+        out.push_back (barMenu ({ 822.0f, cy - 11.0f, 128.0f, 22.0f }, channelMode, tr ("Channel"), "L/R|M/S", { 0.0f, 1.0f }));
     }
 
     // band settings as a block (style, drive, mix, level + round 128's power, state, tone, feedback, dynamics) to move
     // bands around when splitting / removing
-    static constexpr int blockSize = 4 + mixsuite::ember::extraFields;
-    int blockParam (int b, int k) const { return k < 4 ? fp (b, k) : xp (b, k - 4); }
+    static constexpr int blockSize = 4 + mixsuite::ember::extraFields + 2; // round 147: + drive pan, pan
+    int blockParam (int b, int k) const
+    {
+        if (k == blockSize - 2) return mixsuite::ember::bandDrivePanParam (b);
+        if (k == blockSize - 1) return mixsuite::ember::bandPanParam (b);
+        return k < 4 ? fp (b, k) : xp (b, k - 4);
+    }
     std::array<float, blockSize> bandValues (int b) const
     {
         std::array<float, blockSize> out {};

+ 4 - 0
tests/LynxTuneTests95.inc

@@ -562,7 +562,11 @@ TEST (lynx_tune_editor_layout_round95)
         // lists the extra scales (More scales)
         if (item.type == lynx::plugui::Item::display && item.display != nullptr && std::string (item.display) == "tunekeys")
             for (int k = 0; k < 12; ++k)
+            {
                 placed[(std::size_t) (lynx::lynxtune::noteC + k)] = placed[(std::size_t) (lynx::lynxtune::bypassC + k)] = true;
+                placed[(std::size_t) (lynx::lynxtune::noteDirC + k)] = true; // round 147b: the note directions
+                placed[(std::size_t) lynx::lynxtune::rangeLow] = placed[(std::size_t) lynx::lynxtune::rangeHigh] = true; // and the range bar
+            }
         if (item.type == lynx::plugui::Item::menu && item.param != nullptr && std::string (item.param) == "Scale")
             placed[(std::size_t) lynx::lynxtune::moreScales] = true;
     }

+ 1 - 1
tests/Parity128Tests.inc

@@ -175,7 +175,7 @@ TEST (ember_round128_new_parameters_default_to_the_old_sound)
 {
     using namespace lynx::mixsuite::ember;
     const auto& in = lynx::effectInfo (lynx::EffectKind::ember);
-    CHECK ((int) in.params.size() == count && count == 83 && count <= lynx::maxEffectParams); // round 135 (7) + round 136 (the Classic voicing, 11)
+    CHECK ((int) in.params.size() == count && count == 92 && count <= lynx::maxEffectParams); // round 135 (7) + round 136 (the Classic voicing, 11) + round 147b (9)
     const auto p = mixsuite96::defaults (lynx::EffectKind::ember);
     CHECK (std::abs (inputDb (p[inputGain])) < 1e-9);
     for (int b = 0; b < maxBands; ++b)

+ 182 - 0
tests/Parity147bTests.inc

@@ -0,0 +1,182 @@
+// --- Round 147b: parity items (docs/PARITY.md, REA_rodada147b) ----------------------------------------------------
+
+namespace p147b
+{
+// one second of a 1 kHz sine through Ember (one block size), the given left / right inputs
+inline std::pair<std::vector<float>, std::vector<float>> emberRun (const lynx::EffectParams& p, float gl, float gr)
+{
+    auto fx = lynx::makeEffect (lynx::EffectKind::ember);
+    fx->prepare (48000.0);
+    std::vector<float> l (24000), r (24000);
+    for (int i = 0; i < 24000; ++i)
+    {
+        const auto s = 0.25f * (float) std::sin (2.0 * 3.14159265358979 * 1000.0 * i / 48000.0);
+        l[(std::size_t) i] = gl * s;
+        r[(std::size_t) i] = gr * s;
+    }
+    for (int at = 0; at < 24000; at += 512)
+        fx->process (l.data() + at, r.data() + at, std::min (512, 24000 - at), p, 120.0);
+    return { l, r };
+}
+inline double maxDiff (const std::vector<float>& a, const std::vector<float>& b)
+{
+    double m = 0.0;
+    for (std::size_t i = 4800; i < a.size(); ++i) m = std::max (m, (double) std::abs (a[i] - b[i]));
+    return m;
+}
+inline double peakOf (const std::vector<float>& a)
+{
+    double m = 0.0;
+    for (std::size_t i = 4800; i < a.size(); ++i) m = std::max (m, (double) std::abs (a[i]));
+    return m;
+}
+} // namespace p147b
+
+TEST (ember_saturn_channel_mode_drive_pan_band_pan_round147b)
+{
+    using namespace lynx;
+    namespace em = mixsuite::ember;
+    auto base = makeEffectSlot (EffectKind::ember).params;
+    CHECK (effectInfo (EffectKind::ember).params.size() == (std::size_t) em::count);
+    // defaults: left / right, every pan centred (the old sound)
+    CHECK (! em::midSide (base));
+    for (int b = 0; b < em::maxBands; ++b)
+    {
+        CHECK (base[(std::size_t) em::bandDrivePanParam (b)] == 0.5f && base[(std::size_t) em::bandPanParam (b)] == 0.5f);
+    }
+    CHECK (em::panScales (0.0) == std::make_pair (1.0f, 1.0f));
+    CHECK (em::panScales (-0.5) == std::make_pair (1.0f, 0.5f));  // [EXEC] pan −0.5: the right −6.02 dB
+    CHECK (em::panScales (1.0) == std::make_pair (0.0f, 1.0f));
+    CHECK (formatEffectParam (EffectKind::ember, em::channelMode, 1.0f, 120.0) == "Mid/Side");
+    CHECK (formatEffectParam (EffectKind::ember, em::band1Pan, 0.25f, 120.0) == "0.0 / -6.0 dB");
+    CHECK (formatEffectParam (EffectKind::ember, em::band2DrivePan, 0.5f, 120.0) == "centre");
+
+    base[em::drive] = 0.5f;
+    base[em::autoGain] = 0.0f;
+    // drive pan fully left [EXEC: the far side's drive × (1 − |pan|)]: left = the full drive, right = no drive
+    {
+        auto p = base;
+        p[(std::size_t) em::bandDrivePanParam (0)] = 0.0f;
+        const auto [l, r] = p147b::emberRun (p, 1.0f, 1.0f);
+        const auto [fl, fr] = p147b::emberRun (base, 1.0f, 1.0f);
+        auto q = base;
+        q[em::drive] = 0.0f;
+        const auto [zl, zr] = p147b::emberRun (q, 1.0f, 1.0f);
+        CHECK (p147b::maxDiff (l, fl) < 1e-6);
+        CHECK (p147b::maxDiff (r, zr) < 1e-6);
+        CHECK (p147b::maxDiff (r, fr) > 1e-3);
+    }
+    // half left: the right channel's drive is half the dB
+    {
+        auto p = base;
+        p[(std::size_t) em::bandDrivePanParam (0)] = 0.25f;
+        auto q = base;
+        q[em::drive] = 0.25f;
+        const auto [l, r] = p147b::emberRun (p, 1.0f, 1.0f);
+        const auto [hl, hr] = p147b::emberRun (q, 1.0f, 1.0f);
+        CHECK (p147b::maxDiff (r, hr) < 1e-6);
+    }
+    // band pan fully right: the left channel is silent (mix 100 %)
+    {
+        auto p = base;
+        p[(std::size_t) em::bandPanParam (0)] = 1.0f;
+        const auto [l, r] = p147b::emberRun (p, 1.0f, 1.0f);
+        CHECK (p147b::peakOf (l) < 1e-6 && p147b::peakOf (r) > 0.1);
+    }
+    // mid / side: a mid-only input gives the left / right result (S = 0), a side-only input is shaped on its own
+    {
+        auto p = base;
+        p[em::channelMode] = 1.0f;
+        const auto [ml, mr] = p147b::emberRun (p, 1.0f, 1.0f);
+        const auto [ll, lr] = p147b::emberRun (base, 1.0f, 1.0f);
+        CHECK (p147b::maxDiff (ml, ll) < 1e-5 && p147b::maxDiff (mr, lr) < 1e-5);
+        // pan fully left in M/S = the mid only: a side-only input disappears
+        p[(std::size_t) em::bandPanParam (0)] = 0.0f;
+        const auto [sl, sr] = p147b::emberRun (p, 1.0f, -1.0f);
+        CHECK (p147b::peakOf (sl) < 1e-6 && p147b::peakOf (sr) < 1e-6);
+        // a left-only tone in M/S with the drive panned to the mid: the right gets distortion products
+        p[(std::size_t) em::bandPanParam (0)] = 0.5f;
+        p[(std::size_t) em::bandDrivePanParam (0)] = 0.0f;
+        const auto [al, ar] = p147b::emberRun (p, 1.0f, 0.0f);
+        CHECK (p147b::peakOf (ar) > 1e-3);
+    }
+    // multiband: band 2's pan right silences its part on the left
+    {
+        auto p = base;
+        p[em::bands] = 1.0f / 3.0f;
+        p[em::xover1] = em::crossoverValue (300.0);
+        p[(std::size_t) em::bandPanParam (1)] = 1.0f;
+        const auto [l, r] = p147b::emberRun (p, 1.0f, 1.0f); // 1 kHz sits in band 2
+        CHECK (p147b::peakOf (l) < 0.2 * p147b::peakOf (r));
+    }
+}
+
+TEST (ember_saturn2_channel_mode_and_pans_translated_round147b)
+{
+    using namespace lynx;
+    PluginIdentity id;
+    id.name = "FabFilter Saturn 2";
+    // [EXEC] the trial's state: 695 = channel mode, band b drive pan at 7 + 17b + 5, band pan at + 12 (−1 … +1)
+    id.state = dyn108::ffbs (951, { { 5, 100.0f }, { 6, 1.0f }, { 7 + 5, -0.5f }, { 7 + 10, 100.0f }, { 7 + 12, 0.5f }, { 7 + 13, 1.0f },
+                                    { 695, 1.0f } });
+    const auto* entry = findPluginSubstitute (id, false);
+    CHECK (entry != nullptr);
+    if (entry == nullptr) return;
+    const auto slot = makeSubstituteSlot (*entry, &id);
+    namespace e = mixsuite::ember;
+    CHECK (e::midSide (slot.params));
+    CHECK (std::abs (e::panOf (slot.params[(std::size_t) e::bandDrivePanParam (0)]) + 0.5) < 1e-4);
+    CHECK (std::abs (e::panOf (slot.params[(std::size_t) e::bandPanParam (0)]) - 0.5) < 1e-4);
+}
+
+TEST (lynx_tune_note_status_directions_and_range_round147b)
+{
+    using namespace lynx;
+    namespace t = lynxtune;
+    CHECK ((int) effectInfo (EffectKind::lynxTune).params.size() == t::count);
+    auto p = makeEffectSlot (EffectKind::lynxTune).params;
+    // defaults: every direction "nearest", the range the whole keyboard (the old behaviour)
+    for (int k = 0; k < 12; ++k) CHECK (t::noteDir (p[(std::size_t) (t::noteDirC + k)]) == t::NoteDir::nearest);
+    CHECK (t::rangeNote (p[t::rangeLow]) == 0 && t::rangeNote (p[t::rangeHigh]) == 127);
+    CHECK (formatEffectParam (EffectKind::lynxTune, t::rangeHigh, t::rangeNoteValue (60), 120.0) == "C4");
+    CHECK (formatEffectParam (EffectKind::lynxTune, t::noteDirC + 3, 0.5f, 120.0) == "Up");
+    CHECK (t::rangePresetNotes (6) == std::make_pair (0, 127));
+    for (int k = 0; k + 1 < t::rangePresets; ++k)
+        CHECK (t::rangePresetNotes (k).first < t::rangePresetNotes (k).second && t::rangePresetNotes (k).second - t::rangePresetNotes (k).first >= 24);
+
+    // the target with an illegal note: C major without E (legal C D F G A B): 63.9 (≈ E4 − 0.1) goes to the nearest
+    // legal note by default (64 is illegal: D# / F — 65 F is nearer than 62 D), up = F4, down = D4
+    const std::uint16_t legal = (1u << 0) | (1u << 2) | (1u << 5) | (1u << 7) | (1u << 9) | (1u << 11);
+    std::array<t::NoteDir, 12> dirs {};
+    CHECK (t::targetNote (64.2, legal, -1, 0.0, dirs.data()) == 65);
+    dirs[4] = t::NoteDir::down;
+    CHECK (t::targetNote (64.2, legal, -1, 0.0, dirs.data()) == 62);
+    dirs[4] = t::NoteDir::up;
+    CHECK (t::targetNote (63.8, legal, -1, 0.0, dirs.data()) == 65);
+    CHECK (t::targetNote (60.1, legal, -1, 0.0, dirs.data()) == 60); // a legal note is untouched
+
+    // the range: a 450 Hz tone (A4 + 39 c) is pulled to 440 Hz; with the range ending at G4 it passes as sung
+    auto freqOut = [] (const EffectParams& q) {
+        auto fx = makeEffect (EffectKind::lynxTune);
+        fx->prepare (48000.0);
+        const int len = 96000;
+        std::vector<float> l (len), r (len);
+        for (int i = 0; i < len; ++i) l[(std::size_t) i] = r[(std::size_t) i] = 0.3f * (float) std::sin (2.0 * 3.14159265358979 * 450.0 * i / 48000.0);
+        for (int at = 0; at < len; at += 512)
+            fx->process (l.data() + at, r.data() + at, std::min (512, len - at), q, 120.0);
+        int crossings = 0, first = -1, last = -1;
+        for (int i = 60000; i < len; ++i)
+            if (l[(std::size_t) i - 1] < 0.0f && l[(std::size_t) i] >= 0.0f)
+            {
+                if (first < 0) first = i;
+                last = i;
+                ++crossings;
+            }
+        return crossings > 1 ? 48000.0 * (crossings - 1) / (double) (last - first) : 0.0;
+    };
+    const auto corrected = freqOut (p);
+    p[t::rangeHigh] = t::rangeNoteValue (67);
+    const auto outside = freqOut (p);
+    CHECK (std::abs (corrected - 440.0) < 3.0);
+    CHECK (std::abs (outside - 450.0) < 3.0);
+}

+ 1 - 0
tests/tests.cpp

@@ -15804,6 +15804,7 @@ TEST (plugin_layout_options_match_the_engine_values)
 #include "Parity144Tests.inc"
 #include "Parity144aTests.inc"
 #include "Parity144bTests.inc"
+#include "Parity147bTests.inc"
 #include "Patcher141Tests.inc"
 #include "Vox138Tests.inc"
 #include "Natives142Tests.inc"