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

Merge main (Facet EQ round 103) into feature/valh100

Ka1-S 1 месяц назад
Родитель
Сommit
412ea25238

+ 1 - 0
CMakeLists.txt

@@ -223,6 +223,7 @@ if(LYNX_BUILD_APP)
         src/ui/PluginWindow.cpp
         src/ui/WindowOwner.cpp
         src/ui/ParametricEqEditor.cpp
+        src/ui/FacetEqEditor.cpp
         src/ui/PluginEditors.cpp
         src/ui/ExportDialog.cpp
         src/ui/AutomationUi.cpp

+ 11 - 1
docs/PLUGINS.md

@@ -276,11 +276,21 @@ Valhalla, ValhallaVintageVerb, ValhallaRoom, ValhallaPlate, Supermassive, Valhal
 trademarks of Valhalla DSP, LLC; they are named only to say which plugin each LYNX reverb is inspired by and stands in
 for. LYNX is not affiliated with, endorsed or sponsored by Valhalla DSP.
 
+## LYNX originals: precision EQ
+
+| LYNX engine | In the role of | What it is |
+|---|---|---|
+| Facet EQ | surgical / mastering parametric EQs, e.g. FabFilter Pro-Q | 8 bands (bell, shelves, cuts 6–96 dB/oct, notch, band pass, tilt) on analog prototypes; its own editor with a live pre / post spectrum analyser, draggable nodes (double-click adds, wheel = Q, right-click = shape menu), band solo; per-band dynamic EQ (threshold and range, attack / release, detector on the input or a sidechain track); zero-latency, natural-phase (320 samples) and linear-phase (4608 samples) modes with the latency compensated by PDC |
+
+Facet EQ's curve shapes and dynamic law follow black-box measurements of the reference EQ's official trial
+(docs/analise/MEASURE_fabfilter.md, REA_rodada103.md): only its audio output was measured. FabFilter and Pro-Q are
+trademarks of FabFilter; LYNX is not affiliated with them.
+
 ## LYNX originals: vocal pitch
 
 | LYNX engine | In the role of | What it is |
 |---|---|---|
-| LYNX Tune | automatic vocal pitch correctors, e.g. Antares Auto-Tune, Waves Tune Real-Time | real-time pitch correction on every mixer insert (*Insert*): key and scale (13 scales + custom), per-note switches on a keyboard strip, retune speed (0 ms = the hard "robot" effect … 400 ms), humanize (lets held notes keep their vibrato), formant preserve and formant shift, transpose, A4 reference 430–450 Hz, voice range, low-latency mode (≈ 16 ms instead of ≈ 25 ms for alto / tenor), MIDI target notes (the notes held on a Channel Rack channel — played live or from a pattern — become the targets), mix |
+| LYNX Tune | automatic vocal pitch correctors, e.g. Antares Auto-Tune, Waves Tune Real-Time | real-time pitch correction on every mixer insert (*Insert*): key and scale (13 scales + custom), per-note switches on a keyboard strip, retune speed (0 ms = the hard "robot" effect … 400 ms), humanize (lets held notes keep their vibrato), formant preserve and formant shift, transpose, A4 reference 430–450 Hz, voice range, low-latency mode (≈ 16 ms instead of ≈ 25 ms for alto / tenor), MIDI target notes (the notes held on a Channel Rack channel — played live or from a pattern — become the targets), mix; a live pitch display (detected note, cents and Hz, target note, correction meter, 8-second scrolling graph of the input and corrected pitch) |
 
 LYNX Tune is LYNX's own design, written only from published DSP: YIN pitch detection (de Cheveigné & Kawahara, 2002)
 and TD-PSOLA pitch shifting (Moulines & Charpentier, 1990), which keeps the formants in place. No third-party plugin was

+ 104 - 0
docs/analise/REA_rodada103.md

@@ -0,0 +1,104 @@
+# REA round 103 — Facet EQ editor, dynamic EQ and phase modes; LYNX Tune live pitch display
+
+Branch `feature/facet103`. English-first; clean-room. The reference EQ (FabFilter Pro-Q 4, official trial installed by
+the user) was only **hosted** with `tools/fxmeasure` (VST3 parameters in, audio out) — no disassembly, no strings, no
+graphics or manual text. Raw captures stay in `tmp/r103` (never in git). Scripts: `tools/fxmeasure/py/pqdyn.py`.
+
+## 1. Goal
+1. Facet EQ (core/FacetEq.*, round 99): a dedicated interactive editor (analyser, draggable nodes, add / remove bands,
+   Q on the wheel, shape menu, solo), per-band dynamic EQ (threshold / range, sidechain-able) and phase modes (zero
+   latency / natural / linear, latency reported to PDC).
+2. LYNX Tune (round 95): the live pitch display (detected pitch, target note, correction, scrolling pitch graph).
+
+## 2. Measurements of the reference's dynamic EQ [EXEC]
+Setup: one Bell band, 1 kHz, Q 1, gain 0 dB, Zero Latency, 48 kHz; 1 kHz sine stair −60 … 0 dBFS (sine peak), 2 dB
+steps of 0.6 s, level read over the last 0.3 s of each step; bursts −50 → −6 → −50 dBFS for timing.
+
+### 2.1 Static curve
+- The per-band switch whose texts read "Dynamics Auto" (normalized < 0.5) / "Dynamics Manual" (≥ 0.5) behaves the
+  other way round from its text: only with "Auto" (< 0.5) is the **threshold knob** used; with "Manual" (the default)
+  the threshold is set automatically from the signal (−60 / −30 / −10 dB thresholds all gave the same curve). The
+  measurements below use the knob.
+- With threshold T and range R (−12 dB): gain change at T−4: −0.1 dB, T−2: −0.5, T: −1.3, T+2: −2.5, T+4: −4.1,
+  T+6: −6.0, T+8: −8.0, T+10: −10.0, T+12: −12.0 (= R, then flat). So: **1 dB of gain per dB over the threshold (an
+  infinite ratio), a ≈10 dB soft knee centred on T, clamped at the range**. A quadratic knee of width 10 dB
+  ((x+5)²/20 for |x| < 5, x = level − T) reproduces every step within 0.1 dB [fit].
+- Positive range mirrors it (+0.1 … +12.0 dB at the same levels): the band is boosted as the level rises.
+- The static gain adds to it (gain +6, range −12: +6.0 below, −6.0 above).
+- An off-centre tone (500 Hz, one octave below) starts acting ≈ 6 dB later and reaches the bell's −5.7 dB there: the
+  detector listens through a band filter around the band (a 2nd-order band pass with the band's Q gives −5.1 dB one
+  octave away) [fit, approximate].
+
+### 2.2 Timing (gain envelope = |analytic(out)| / |analytic(in)|)
+- Attack % → time to 63 % of the 12 dB move: 0 %: 1.2 ms, 25 %: 1.4 ms, 50 %: 3.5 ms, 75 %: 13 ms, 100 %: 38 ms
+  (≈ 0.4 ms · 96^p, the bottom limited by the detector).
+- Release % → exponential recovery time constant (from the dB curve after the drop): 0 %: ≈ 115 ms, 25 %: ≈ 160 ms,
+  50 %: ≈ 270 ms, 75 %: ≈ 440 ms, 100 %: ≈ 720 ms.
+
+### 2.3 Phase modes (from round 99, MEASURE_fabfilter §1.3)
+Zero latency 0; natural phase 320 samples at 48 kHz (analog magnitude and phase); linear phase (medium) 5120.
+
+## 3. LYNX's design (own) [model]
+- Parameters appended at 42 … 63 (older projects load with every new control at the old behaviour: range 0 dB =
+  static band, phase = zero latency, solo off, detector = input).
+- Dynamic band (bell, shelves, tilt with range ≠ 0): detector = mid of the EQ input, or of the slot's sidechain
+  when "Detector: Sidechain" is chosen and a sidechain track is routed (mixer slot menu "Sidechain from"); filtered
+  by an RBJ band pass at the band frequency / Q (low pass for low shelf, high pass for high shelf), mean square
+  over max(1 ms, 1.5 periods), level in sine-peak dB; gain law of §2.1; gain smoothed with attack 0.25 … 50 ms
+  (default 3.5 ms) and release 20 ms … 4 s (default 283 ms). Zero-latency mode re-designs the band's sections every
+  32 samples when the dynamic gain moved more than 0.01 dB.
+- Natural phase: FIR (8192 taps at 48 kHz) of the analog prototype's complex response delayed by 192 samples,
+  windowed by a half-Hann rise before the delay and a half-Hann decay after it, run as a uniformly partitioned FFT
+  convolution with 128-sample blocks → latency 320 at 48 kHz (×2 up to 96 kHz, ×4 above).
+- Linear phase: FIR of the analog magnitude, delay 4096, Hann window, 512-sample blocks → latency 4608 at 48 kHz.
+- In the FIR modes the kernel is redesigned at most every 1024 samples (parameter changes, dynamic movement
+  > 0.05 dB) and cross-faded over one convolution block.
+- Solo: the band's region alone (the detector filter on the input), delayed by the mode's latency.
+
+## 4. Facet EQ editor (src/ui/FacetEqEditor.*) — own drawing, the reference's ergonomics
+Reference study (user request, UI rule): the official Pro-Q 4 trial was opened in a small VST3 GUI host
+(tmp/r103/host/proqview.cpp, a copy of tools/fxmeasure with a `show` command that plays a test loop through the
+plugin while its editor is on screen) and screenshotted in several states (default, bands added, selected band, hover
+read-out, right-click menus, dynamic band, analyser, bottom bar); shots in tmp/facet103/ref (not in git). Observed
+layout logic, reproduced in LYNX's own colours, fonts and knobs (no graphics, logos or trade dress copied):
+- the whole window is the graph: curves over the pre / post analyser, gain labels and analyser dBFS labels in two
+  columns on the right, a gain-range button at the top right (LYNX: 3 / 6 / 12 / 30 dB), frequency labels along the
+  bottom or a piano-key scale (toggle at the bottom left);
+- nodes coloured per band, the sum as one strong curve (LYNX: white with a red glow), each band's own curve faint;
+  dynamic bands show their range as a second curve with a handle (LYNX: shaded span + square handle);
+- hovering a node shows a small read-out (frequency, gain, Q) with solo and remove buttons;
+- selecting a band opens a floating panel over the bottom of the graph: shape + slope, FREQ, a large GAIN, the dynamic
+  controls, Q, previous / next band, close; clicking the empty graph closes it;
+- double-click on the graph = new band; drag = frequency + gain, Shift = one direction, Ctrl = fine; wheel = Q;
+  Alt-click = delete; right-click on a node = band menu (shape, slope, dynamic, solo, invert gain, delete), on the
+  graph = all-band menu (invert gains, remove all);
+- the bottom bar holds the global settings: processing mode (with latency), analyser mode, detector / sidechain,
+  gain scale, output.
+Not reproduced: spectrum grab, mid/side placement, per-band enable, band copy / paste, preset bar, level meters.
+Analyser tap: `ProcessTimes::analyzer` — the editor in use claims the slot key, the audio thread writes the slot's
+input and output (mono mid) into two 16384-sample rings (8192-point FFT, max per column, 4.5 dB/oct display tilt).
+Live dynamic gains: `ProcessTimes::effectMeters` (meterOutputs raised from 2 to 8; published for the mixing suite,
+Facet EQ and LYNX Tune). Solo is a listening aid, cleared (not undoable) when the editor closes. The mixer insert
+panel shows "Open Facet EQ" and a curve thumbnail; "Sidechain from" is in the slot menu.
+
+## 5. LYNX Tune live pitch display
+A "LIVE PITCH" section on top of LYNX Tune's page (layout +170 px): the detected note (large), cents and Hz; the target
+note (red); the correction in cents with a ±100 c centre meter; the last 8 s (30 points / s) of the input pitch
+(grey) and the corrected pitch (input + applied correction, red with a glow) over note lanes — the key's scale notes
+switched on are brighter and labelled — centred on the recent pitch (follows the voice, ±7.5 semitones). Data:
+LYNX Tune's controlOutput 0 – 2 (round 95) published through the live meters at 30 Hz.
+
+## 6. Tests (tests/FacetTests103.inc)
+Backward compatibility of the 22 new controls; the dynamic law vs the measured steps (≤ 0.12 dB); a dynamic band in
+the three modes (−50 / −24 / −6 dBFS → 0 / −6 / −12 dB, ≤ 0.45 dB, live meter); sidechain ducking, unrouted
+sidechain, out-of-band sidechain; FIR modes vs the analog magnitude (≤ 0.2 dB, 100 Hz – 15 kHz), linear-phase
+symmetry and peak at the latency, natural-phase causality, run-time latency change; solo; meters / tap / Tune layout.
+CPU (one instance, 48 kHz, 8 dynamic bands, noise): zero latency ≈ 3 %, natural ≈ 10 %, linear ≈ 7–9 % of a core.
+
+## 7. Where I stopped / next steps
+- Done: everything in §3–§6; snapshots from `LYNX.exe --plugui` (Facet EQ.png, LYNX Tune.png).
+- Not done / ideas: per-band sidechain choice (one detector switch for the whole EQ: 64 parameters is the slot
+  maximum), mid/side and left/right band placement, flat tilt / all pass / brickwall shapes, the reference's
+  auto-threshold mode, spectral dynamics, analyser freeze / peak hold, a resolution setting for the FIR modes
+  (8192 taps smear very low narrow bands slightly: −23.8 vs −24.1 dB at 50 Hz in linear mode), Facet EQ
+  substitutes reading Pro-Q's dynamic parameters.

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

@@ -2269,6 +2269,63 @@ countries: br
 "TARGET NOTES" = "NOTAS-ALVO"
 "MIDI channel" = "Canal MIDI"
 
+# --- Facet EQ editor and LYNX Tune pitch display (round 103)
+"LIVE PITCH" = "AFINAÇÃO AO VIVO"
+"Tilt shelf" = "Tilt shelf"
+"Zero latency" = "Latência zero"
+"Natural phase" = "Fase natural"
+"Linear phase" = "Fase linear"
+"Analyzer off" = "Analisador desligado"
+"Analyzer: pre" = "Analisador: pré"
+"Analyzer: post" = "Analisador: pós"
+"Analyzer: pre + post" = "Analisador: pré + pós"
+"Slope" = "Inclinação"
+"Dynamic range" = "Faixa dinâmica"
+"Solo band" = "Solo da banda"
+"Reset gain" = "Zerar ganho"
+"Remove band" = "Remover banda"
+"Detect the EQ's input" = "Detectar a entrada do EQ"
+"Detect the sidechain" = "Detectar o sidechain"
+"Processing: zero latency (minimum phase), natural phase (the analog curve's phase) or linear phase (no phase shift); the latency is reported to PDC" = "Processamento: latência zero (fase mínima), fase natural (a fase da curva analógica) ou fase linear (sem desvio de fase); a latência é informada ao PDC"
+"What the dynamic bands listen to: the EQ's input or a sidechain track" = "O que as bandas dinâmicas escutam: a entrada do EQ ou uma faixa de sidechain"
+"Remove the band (Delete)" = "Remover a banda (Delete)"
+"Solo: hear only this band's region (S)" = "Solo: ouvir só a região desta banda (S)"
+"Dynamic EQ: the band's gain moves by up to its range when its region goes over the threshold" = "EQ dinâmico: o ganho da banda se move até a sua faixa quando a região dela passa do limiar"
+"Band shape" = "Formato da banda"
+"Dynamic range: drag up or down" = "Faixa dinâmica: arraste para cima ou para baixo"
+"Double-click to add a band; mouse wheel = Q of the selected band" = "Duplo clique para adicionar uma banda; roda do mouse = Q da banda selecionada"
+"OUT" = "SAÍDA"
+"SCALE" = "ESCALA"
+"latency {0} samples" = "latência {0} amostras"
+"Double-click to add a band" = "Duplo clique para adicionar uma banda"
+"Dynamic" = "Dinâmico"
+"FREQ" = "FREQ"
+"GAIN" = "GANHO"
+"RANGE" = "FAIXA"
+"THRESHOLD" = "LIMIAR"
+"ATTACK" = "ATAQUE"
+"RELEASE" = "RELEASE"
+"Open Facet EQ" = "Abrir o Facet EQ"
+"Target" = "Alvo"
+"Correction" = "Correção"
+"Play a voice or an instrument through the insert to see its pitch" = "Toque uma voz ou um instrumento por este insert para ver a afinação"
+"input" = "entrada"
+"corrected" = "corrigido"
+"Pre + Post" = "Pré + Pós"
+"Invert all gains" = "Inverter todos os ganhos"
+"Remove all bands" = "Remover todas as bandas"
+"Spectrum analyzer: off, pre, post or pre + post" = "Analisador de espectro: desligado, pré, pós ou pré + pós"
+"Frequency scale: numbers or a piano keyboard" = "Escala de frequência: números ou um teclado de piano"
+"Previous / next band" = "Banda anterior / próxima"
+"Close the band panel (click on the empty graph does the same)" = "Fechar o painel da banda (um clique no gráfico vazio faz o mesmo)"
+"Graph scale: click to switch between 3, 6, 12 and 30 dB" = "Escala do gráfico: clique para alternar entre 3, 6, 12 e 30 dB"
+"drag = frequency and gain (Ctrl fine, Shift one direction only); wheel = Q; Alt-click or double-click = remove; right-click = menu" = "arrastar = frequência e ganho (Ctrl fino, Shift só uma direção); roda = Q; Alt+clique ou duplo clique = remover; botão direito = menu"
+"Double-click: new band  -  drag: frequency / gain  -  wheel: Q  -  right-click: menu" = "Duplo clique: nova banda  -  arrastar: frequência / ganho  -  roda: Q  -  botão direito: menu"
+"Processing:" = "Processamento:"
+"Analyzer:" = "Analisador:"
+"Detector:" = "Detector:"
+"Dynamic EQ: the gain follows the level of the band's region (threshold, range)" = "EQ dinâmico: o ganho segue o nível da região da banda (limiar, faixa)"
+
 # LYNX's reverbs (round 100)
 "Concert Hall|Plate|Room|Chamber|Random Space|Chorus Space|Ambience|Bright Hall|Nave|Grit Hall|Grit Plate|Smooth Plate|Smooth Room|Smooth Space|Gated|Drift Chamber|Drift Hall|Drift Space|Cathedral|Grand Hall|Vintage Chamber|Vintage Hall" = "Sala de concerto|Placa|Sala|Câmara|Espaço aleatório|Espaço chorus|Ambiência|Salão brilhante|Nave|Salão sujo|Placa suja|Placa suave|Sala suave|Espaço suave|Gated|Câmara à deriva|Salão à deriva|Espaço à deriva|Catedral|Grande salão|Câmara vintage|Salão vintage"
 "1970s|1980s|Now" = "Anos 70|Anos 80|Atual"

+ 1 - 1
scripts/build-windows-zig.sh

@@ -77,7 +77,7 @@ fi
 APP_SOURCES=(src/Main.cpp
              src/engine/AudioEngine.cpp src/engine/ChannelRackProcessor.cpp src/engine/Metronome.cpp
              src/engine/SampleLibrary.cpp src/engine/WavPackFormat.cpp src/engine/ProjectFile.cpp src/engine/PluginHost.cpp src/engine/PluginSandbox.cpp src/engine/Exporter.cpp src/engine/StreamPrefetcher.cpp src/engine/DllAsioDevice.cpp src/engine/ClapFormat.cpp src/engine/Vst2Format.cpp src/engine/MidiFileIo.cpp src/engine/PreviewPlayer.cpp
-             src/ui/MainComponent.cpp src/ui/ChannelRackComponent.cpp src/ui/PianoRollComponent.cpp src/ui/PlaylistComponent.cpp src/ui/MixerComponent.cpp src/ui/PluginWindow.cpp src/ui/WindowOwner.cpp src/ui/ParametricEqEditor.cpp src/ui/ExportDialog.cpp src/ui/AutomationUi.cpp src/ui/ChannelSettings.cpp src/ui/BrowserComponent.cpp src/ui/Theme.cpp src/ui/Icons.cpp src/ui/I18n.cpp src/ui/EditorTools.cpp
+             src/ui/MainComponent.cpp src/ui/ChannelRackComponent.cpp src/ui/PianoRollComponent.cpp src/ui/PlaylistComponent.cpp src/ui/MixerComponent.cpp src/ui/PluginWindow.cpp src/ui/WindowOwner.cpp src/ui/ParametricEqEditor.cpp src/ui/FacetEqEditor.cpp src/ui/ExportDialog.cpp src/ui/AutomationUi.cpp src/ui/ChannelSettings.cpp src/ui/BrowserComponent.cpp src/ui/Theme.cpp src/ui/Icons.cpp src/ui/I18n.cpp src/ui/EditorTools.cpp
              src/core/Song.cpp src/core/Scheduler.cpp src/core/Instruments.cpp src/core/RackRenderer.cpp
              src/core/FlpImport.cpp src/core/Effects.cpp src/core/NoteEdit.cpp src/core/Recorder.cpp src/core/Pdc.cpp src/core/WorkerPool.cpp src/core/TimeStretch.cpp src/core/Arpeggiator.cpp src/core/SynthPresets.cpp src/core/Slicer.cpp src/core/Templates.cpp src/core/FlWrapper.cpp src/core/FlEffects.cpp src/core/Effector.cpp src/core/VintagePhaser.cpp src/core/Reeverb2.cpp src/core/LuxeVerb.cpp src/core/IldspMath.cpp src/core/ConvolverFx.cpp src/core/EquoFx.cpp src/core/PitchShifterFl.cpp src/core/SimSynth.cpp src/core/Wasp.cpp src/core/Granulizer.cpp src/core/Drumaxx.cpp src/core/FruityFilters.cpp src/core/NewtoneFx.cpp src/core/VocalPitch.cpp src/core/LynxTune.cpp src/core/LynxVerbs.cpp src/core/MixSuite.cpp src/core/LovePhilter.cpp src/core/DistructorFx.cpp src/core/MultibandDelayFx.cpp src/core/FrequencySplitter.cpp src/core/Slayer.cpp src/core/FlangusFastDist.cpp src/core/FruityPhaser.cpp src/core/FruityDelayBank.cpp src/core/FruityMultiband.cpp src/core/Vocodex.cpp src/core/FruityVocoder.cpp src/core/DelphiMath.cpp src/core/MaximusFx.cpp src/core/ParametricEqFl.cpp src/core/ParametricEqLinear.cpp src/core/FruityBasicFx.cpp src/core/TransistorBass.cpp src/core/GrossBeat.cpp src/core/StereoFx.cpp src/core/FruityDelay.cpp src/core/FruityShapers.cpp src/core/ChorusFx.cpp src/core/FruityDynamics.cpp src/core/FlSamplers.cpp src/core/FlSynths.cpp src/core/FlSytrus.cpp src/core/FlGenerators.cpp src/core/PhysicalModels.cpp src/core/DrumSynthLive.cpp src/core/SytrusEngine.cpp src/core/Harmless.cpp src/core/HarmlessFx.cpp src/core/Harmor.cpp src/core/Gms.cpp src/core/Morphine.cpp src/core/Ogun.cpp src/core/Toxic.cpp src/core/ToxicFx.cpp src/core/FruitKick.cpp src/core/BassDrum.cpp src/core/MiniSynth.cpp src/core/Dx10.cpp src/core/Kepler.cpp src/core/PoiZone.cpp src/core/FlPatcher.cpp src/core/Inflate.cpp src/core/WavPack.cpp src/flp/Flp.cpp
              src/platform/MingwFixes.cpp)

+ 48 - 0
src/Main.cpp

@@ -40,6 +40,8 @@
 #include "ui/EventEditor.h"
 #include "ui/AudioEditor.h"
 #include "core/EventEdit.h"
+#include "core/FacetEq.h"
+#include "ui/FacetEqEditor.h"
 #include "ui/ParametricEqEditor.h"
 #include "ui/PluginEditors.h"
 #include "core/PluginLayout.h"
@@ -1653,6 +1655,52 @@ private:
                 }
             }
 
+            // LYNX's own editors with live displays (round 103): Facet EQ (a mixing curve, one dynamic band, demo analyser)
+            // and LYNX Tune (demo pitch phrase)
+            {
+                lynx::setNativeEditorDemo (true);
+                using namespace lynx::facet;
+                auto eq = lynx::makeEffectSlot (lynx::EffectKind::facetEq);
+                const struct { Shape s; double f, g, q; int slope; double range; } bandsDemo[] = {
+                    { Shape::lowCut, 32, 0, 1, 24, 0 }, { Shape::bell, 110, 3, 1.2, 12, 0 }, { Shape::bell, 380, -3.5, 1.6, 12, 0 },
+                    { Shape::bell, 3200, 0, 2.5, 12, -6 }, { Shape::highShelf, 9000, 2.5, 0.8, 12, 0 }
+                };
+                for (int b = 0; b < 5; ++b)
+                {
+                    eq.params[(std::size_t) param (b, 0)] = shapeValue (bandsDemo[b].s);
+                    eq.params[(std::size_t) param (b, 1)] = hzValue (bandsDemo[b].f);
+                    eq.params[(std::size_t) param (b, 2)] = gainValue (bandsDemo[b].g);
+                    eq.params[(std::size_t) param (b, 3)] = qValue (bandsDemo[b].q);
+                    eq.params[(std::size_t) param (b, 4)] = slopeValue (bandsDemo[b].slope);
+                    eq.params[(std::size_t) (rangeParam0 + b)] = rangeValue (bandsDemo[b].range);
+                }
+                eq.params[(std::size_t) phaseParam] = phaseValue (Phase::natural);
+                const auto own = [&] (const lynx::EffectSlot& fx, const juce::String& file, bool facetEditor) {
+                    lynx::Song song;
+                    song.mixer.resize (2);
+                    song.mixer[0].name = "Master";
+                    song.mixer[1].name = "Vocal";
+                    song.mixer[1].effects.push_back (fx);
+                    offline.setSong (std::move (song));
+                    offline.dispatchPendingMessages();
+                    auto editor = facetEditor ? lynx::makeFacetEqEditor (offline, 1, 0, true) : lynx::makeNativeEffectEditor (offline, 1, 0, 1.25f, 0);
+                    juce::Image image (juce::Image::ARGB, editor->getWidth(), editor->getHeight(), true);
+                    {
+                        juce::Graphics g (image);
+                        g.fillAll (lynx::theme::panel);
+                        editor->paintEntireComponent (g, false);
+                    }
+                    const auto f = out.getChildFile (file);
+                    f.deleteFile();
+                    juce::PNGImageFormat png;
+                    if (auto stream = f.createOutputStream())
+                        png.writeImageToStream (image, *stream);
+                };
+                own (eq, "Facet EQ.png", true);
+                own (lynx::makeEffectSlot (lynx::EffectKind::lynxTune), "LYNX Tune.png", false);
+                lynx::setNativeEditorDemo (false);
+            }
+
             // generators in FL's arrangement: the channel's plugin page with the FL preset's settings
             const auto generators = juce::File (juce::String::fromUTF8 (roots.data.c_str())).getChildFile ("Patches/Plugin presets/Generators");
             for (auto [folder, preset] : std::vector<std::pair<const char*, const char*>> { { "3x Osc", "Default.fst" }, { "FL Keys", "Grand Piano.fst" }, { "BooBass", "" }, { "Sytrus", "Default.fst" }, { "Harmor", "Default.fst" } })

+ 2 - 0
src/core/Effects.cpp

@@ -2953,6 +2953,8 @@ std::unique_ptr<Effect> makeEffect (const EffectSlot& slot)
         return std::make_unique<ParametricEq> (slot.params);
     if (slot.kind == EffectKind::frequencySplitter)
         return fsplit::make (slot.params);
+    if (slot.kind == EffectKind::facetEq) // its phase mode (latency) known before the first block
+        return facet::make (&slot.params);
     if (slot.kind == EffectKind::hyperChorus)
         return hyperchorusfx::make (hyperchorusfx::instanceOf (slot.state));
     if (slot.kind == EffectKind::vintageChorus)

+ 613 - 27
src/core/FacetEq.cpp

@@ -1,9 +1,11 @@
 #include "core/FacetEq.h"
 
 #include <algorithm>
+#include <atomic>
 #include <cmath>
 #include <complex>
 #include <cstdio>
+#include <vector>
 
 namespace lynx::facet
 {
@@ -127,11 +129,11 @@ int butterworthQs (int n, double* qs) noexcept
 }
 
 // analog sections of one band (normalized to the band frequency); returns the count
-int analogSections (const EffectParams& p, int b, Analog* out) noexcept
+int analogSections (const EffectParams& p, int b, Analog* out, double extraDb = 0.0, bool keepFlat = false) noexcept
 {
     const auto sh = shape (p[(std::size_t) param (b, 0)]);
     const double scale = gainScale (p[(std::size_t) scaleParam]);
-    const double g = gainDb (p[(std::size_t) param (b, 2)]) * scale;
+    const double g = (gainDb (p[(std::size_t) param (b, 2)]) + extraDb) * scale;
     const double Q = bandQ (p, b);
     const int slope = slopeDb (p[(std::size_t) param (b, 4)]);
 
@@ -141,7 +143,7 @@ int analogSections (const EffectParams& p, int b, Analog* out) noexcept
         case Shape::bell:
         {
             // symmetric bell: (s² + s·A/Qb + 1) / (s² + s/(A·Qb) + 1), Qb = Q/√2 (measured convention)
-            if (std::abs (g) < 1e-9) return 0;
+            if (std::abs (g) < 1e-9 && ! keepFlat) return 0;
             const double A = std::pow (10.0, g / 40.0), qb = Q / std::sqrt (2.0);
             out[0] = { 1.0, A / qb, 1.0, 1.0, 1.0 / (A * qb), 1.0 };
             return 1;
@@ -150,7 +152,7 @@ int analogSections (const EffectParams& p, int b, Analog* out) noexcept
         case Shape::highShelf:
         case Shape::tiltShelf:
         {
-            if (std::abs (g) < 1e-9) return 0;
+            if (std::abs (g) < 1e-9 && ! keepFlat) return 0;
             const bool tilt = sh == Shape::tiltShelf;
             const double gg = tilt ? 2.0 * g : g;
             const double A = std::pow (10.0, gg / 40.0), sa = std::sqrt (A);
@@ -200,41 +202,440 @@ int analogSections (const EffectParams& p, int b, Analog* out) noexcept
     return 0;
 }
 
+
 cd evalDigital (const Section& s, double w) noexcept
 {
     const cd z1 = std::polar (1.0, -w), z2 = z1 * z1;
     return (s.b0 + s.b1 * z1 + s.b2 * z2) / (1.0 + s.a1 * z1 + s.a2 * z2);
 }
 
+// the FIR grid factor of a phase mode: 1 up to 48 kHz, 2 up to 96 kHz, 4 above
+int rateFactor (double sr) noexcept { return sr <= 50000.0 ? 1 : sr <= 100000.0 ? 2 : 4; }
+constexpr int naturalBlock = 128, naturalDelay = 192, linearBlock = 512, firTaps = 8192;
+
+// --- FFT and the partitioned convolver (the FIR phase modes) ------------------------------------------------------
+
+struct Fft
+{
+    int n = 0;
+    std::vector<cd> tw;
+    std::vector<int> rev;
+
+    void init (int size)
+    {
+        n = size;
+        tw.resize ((std::size_t) n / 2);
+        for (int k = 0; k < n / 2; ++k) tw[(std::size_t) k] = std::polar (1.0, -2.0 * pi * k / n);
+        rev.resize ((std::size_t) n);
+        int bits = 0;
+        while ((1 << bits) < n) ++bits;
+        for (int i = 0; i < n; ++i)
+        {
+            int r = 0;
+            for (int b = 0; b < bits; ++b) r |= ((i >> b) & 1) << (bits - 1 - b);
+            rev[(std::size_t) i] = r;
+        }
+    }
+
+    // in place, unscaled (the inverse is n times too large)
+    void run (cd* a, bool inverse) const noexcept
+    {
+        for (int i = 0; i < n; ++i)
+            if (i < rev[(std::size_t) i]) std::swap (a[i], a[rev[(std::size_t) i]]);
+        for (int len = 2; len <= n; len <<= 1)
+        {
+            const int half = len / 2, step = n / len;
+            for (int i = 0; i < n; i += len)
+                for (int j = 0; j < half; ++j)
+                {
+                    const double wr = tw[(std::size_t) (j * step)].real(), wi = inverse ? -tw[(std::size_t) (j * step)].imag() : tw[(std::size_t) (j * step)].imag();
+                    const double xr = a[i + j + half].real(), xi = a[i + j + half].imag();
+                    const cd u = a[i + j], v (xr * wr - xi * wi, xr * wi + xi * wr);
+                    a[i + j] = u + v;
+                    a[i + j + half] = u - v;
+                }
+        }
+    }
+};
+
+// Uniformly partitioned overlap-save convolution of a stereo signal (left + j·right) with a real FIR; block P, latency
+// P. Buffers are sized once for the largest configuration; a new kernel is cross-faded in over one block.
+class Convolver
+{
+public:
+    void allocate (int maxTaps, int maxBlock)
+    {
+        fdl.assign ((std::size_t) maxTaps * 2, {});
+        kern[0].assign ((std::size_t) maxTaps * 2, {});
+        kern[1].assign ((std::size_t) maxTaps * 2, {});
+        timeBuf.assign ((std::size_t) maxBlock * 2, {});
+        acc.assign ((std::size_t) maxBlock * 2, {});
+        acc2.assign ((std::size_t) maxBlock * 2, {});
+        in.assign ((std::size_t) maxBlock, {});
+        out.assign ((std::size_t) maxBlock, {});
+    }
+
+    // P must be a power of two whose FFT (2P) is `fft`
+    void configure (const Fft& f, int blockSize, int taps) noexcept
+    {
+        fft = &f;
+        P = blockSize;
+        K = taps / blockSize;
+        reset();
+    }
+
+    void reset() noexcept
+    {
+        std::fill (fdl.begin(), fdl.end(), cd {});
+        std::fill (timeBuf.begin(), timeBuf.end(), cd {});
+        std::fill (in.begin(), in.end(), cd {});
+        std::fill (out.begin(), out.end(), cd {});
+        pos = head = 0;
+        pending = -1;
+    }
+
+    // a new FIR (K·P taps); the first one is used at once, later ones fade in over the next block
+    void load (const double* h, bool immediate) noexcept
+    {
+        const int next = immediate ? active : 1 - active;
+        auto* frame = acc2.data();
+        for (int k = 0; k < K; ++k)
+        {
+            for (int i = 0; i < P; ++i) frame[i] = cd (h[k * P + i], 0.0);
+            for (int i = P; i < 2 * P; ++i) frame[i] = {};
+            fft->run (frame, false);
+            std::copy (frame, frame + 2 * P, kern[(std::size_t) next].begin() + (std::ptrdiff_t) k * 2 * P);
+        }
+        pending = immediate ? -1 : next;
+    }
+
+    bool fading() const noexcept { return pending >= 0; }
+
+    void step (float& l, float& r) noexcept
+    {
+        in[(std::size_t) pos] = cd (l, r);
+        const auto y = out[(std::size_t) pos];
+        l = (float) y.real();
+        r = (float) y.imag();
+        if (++pos == P) block();
+    }
+
+private:
+    void accumulate (int which, cd* dst) noexcept
+    {
+        const int n2 = 2 * P;
+        std::fill (dst, dst + n2, cd {});
+        const auto* kr = kern[(std::size_t) which].data();
+        for (int k = 0; k < K; ++k)
+        {
+            const auto* x = fdl.data() + (std::ptrdiff_t) (((head - k + K) % K) * n2);
+            const auto* hk = kr + (std::ptrdiff_t) k * n2;
+            // plain products (std::complex's operator* checks for infinities, several times slower)
+            for (int i = 0; i < n2; ++i)
+            {
+                const double xr = x[i].real(), xi = x[i].imag(), hr = hk[i].real(), hi = hk[i].imag();
+                dst[i] += cd (xr * hr - xi * hi, xr * hi + xi * hr);
+            }
+        }
+        fft->run (dst, true);
+    }
+
+    void block() noexcept
+    {
+        const int n2 = 2 * P;
+        auto* tb = timeBuf.data();
+        std::copy (tb + P, tb + n2, tb);
+        std::copy (in.begin(), in.begin() + P, tb + P);
+        auto* x = fdl.data() + (std::ptrdiff_t) head * n2;
+        std::copy (tb, tb + n2, x);
+        fft->run (x, false);
+        const double scale = 1.0 / n2;
+        accumulate (active, acc.data());
+        if (pending >= 0)
+        {
+            accumulate (pending, acc2.data());
+            for (int i = 0; i < P; ++i)
+            {
+                const double t = (i + 0.5) / P;
+                out[(std::size_t) i] = (acc[(std::size_t) (P + i)] * (1.0 - t) + acc2[(std::size_t) (P + i)] * t) * scale;
+            }
+            active = pending;
+            pending = -1;
+        }
+        else
+            for (int i = 0; i < P; ++i) out[(std::size_t) i] = acc[(std::size_t) (P + i)] * scale;
+        head = (head + 1) % K;
+        pos = 0;
+    }
+
+    const Fft* fft = nullptr;
+    int P = 128, K = 1, pos = 0, head = 0, active = 0, pending = -1;
+    std::vector<cd> fdl, kern[2], timeBuf, acc, acc2, in, out;
+};
+
+// a biquad on doubles (detector / solo filters)
+struct Biquad
+{
+    double b0 = 1, b1 = 0, b2 = 0, a1 = 0, a2 = 0;
+    double z1[2] {}, z2[2] {};
+    double run (double x, int ch) noexcept
+    {
+        const double y = b0 * x + z1[ch];
+        z1[ch] = b1 * x - a1 * y + z2[ch];
+        z2[ch] = b2 * x - a2 * y;
+        return y;
+    }
+    void clear() noexcept { z1[0] = z1[1] = z2[0] = z2[1] = 0.0; }
+};
+
+// the band's region: band pass at its frequency and Q (low pass / high pass for the shelves and cuts)
+void regionFilter (Biquad& f, const EffectParams& p, int b, double sr) noexcept
+{
+    const auto sh = shape (p[(std::size_t) param (b, 0)]);
+    const double f0 = std::min (hz (p[(std::size_t) param (b, 1)]), 0.45 * sr);
+    const double w0 = 2.0 * pi * f0 / sr, cw = std::cos (w0), sw = std::sin (w0);
+    const bool low = sh == Shape::lowShelf || sh == Shape::highCut;
+    const bool high = sh == Shape::highShelf || sh == Shape::lowCut;
+    const double Q = low || high ? std::sqrt (0.5) : std::clamp (q (p[(std::size_t) param (b, 3)]), 0.1, 40.0);
+    const double alpha = sw / (2.0 * Q), a0 = 1.0 + alpha;
+    if (low) { f.b0 = (1.0 - cw) * 0.5 / a0; f.b1 = (1.0 - cw) / a0; f.b2 = f.b0; }
+    else if (high) { f.b0 = (1.0 + cw) * 0.5 / a0; f.b1 = -(1.0 + cw) / a0; f.b2 = f.b0; }
+    else { f.b0 = alpha / a0; f.b1 = 0.0; f.b2 = -alpha / a0; }
+    f.a1 = -2.0 * cw / a0;
+    f.a2 = (1.0 - alpha) / a0;
+}
+
 class FacetEqEffect final : public Effect
 {
 public:
-    void prepare (double sr) noexcept override { sampleRate = sr; cached.fill (-1.0f); reset(); }
+    explicit FacetEqEffect (const EffectParams* initial)
+    {
+        if (initial != nullptr) mode = phase ((*initial)[(std::size_t) phaseParam]);
+    }
+
+    void prepare (double sr) noexcept override
+    {
+        sampleRate = sr;
+        const int fct = rateFactor (sr);
+        taps = firTaps * fct;
+        fftNatural.init (2 * naturalBlock * fct);
+        fftLinear.init (2 * linearBlock * fct);
+        fftDesign.init (taps);
+        conv.allocate (taps, linearBlock * fct);
+        spec.assign ((std::size_t) taps, {});
+        fir.assign ((std::size_t) taps, 0.0);
+        delayLen = latencyFor (Phase::linear, sr) + 1;
+        delay[0].assign ((std::size_t) delayLen, 0.0f);
+        delay[1].assign ((std::size_t) delayLen, 0.0f);
+        cached.fill (-1.0f);
+        configureMode (mode);
+        reset();
+    }
+
     void reset() noexcept override
     {
         for (auto& band : state)
             for (auto& st : band)
                 st = {};
+        for (auto& d : det) { d.filter.clear(); d.ms = 0.0; d.gain = 0.0; }
+        solo.clear();
+        conv.reset();
+        firLoaded = false;
+        for (auto& d : delay) std::fill (d.begin(), d.end(), 0.0f);
+        delayPos = 0;
+        dynUsed.fill (0.0);
+        for (auto& m : meters) m.store (0.0f, std::memory_order_relaxed);
+    }
+
+    void setSidechain (const float* left, const float* right) noexcept override
+    {
+        sideL = left;
+        sideR = right;
+        sideGiven = true;
     }
 
+    float controlOutput (int o) const noexcept override
+    {
+        return o >= 0 && o < bands ? meters[(std::size_t) o].load (std::memory_order_relaxed) / 60.0f : 0.0f;
+    }
+
+    int latencySamples() const noexcept override { return latencyNow.load (std::memory_order_relaxed); }
+
     void process (float* left, float* right, int n, const EffectParams& params, double) noexcept override
     {
         bool changed = false;
         for (int i = 0; i < paramCount; ++i)
             if (params[(std::size_t) i] != cached[(std::size_t) i]) { changed = true; break; }
         if (changed)
+            update (params);
+
+        // the detector: the slot's sidechain when asked for and routed (nullptr = a silent source), else the input
+        const bool useSide = sideGiven && sidechainDetector (params[(std::size_t) detectorParam]);
+        const float* dl = useSide ? sideL : left;
+        const float* dr = useSide ? (sideR != nullptr ? sideR : sideL) : right;
+        sideGiven = false;
+        sideL = sideR = nullptr;
+
+        constexpr int chunk = 32;
+        for (int off = 0; off < n; off += chunk)
+        {
+            const int m = std::min (chunk, n - off);
+            if (anyDynamic)
+                detect (dl != nullptr ? dl + off : nullptr, dr != nullptr ? dr + off : nullptr, left + off, right + off, m, useSide);
+
+            if (soloOn)
+            {
+                runSolo (left + off, right + off, m);
+                continue;
+            }
+            if (mode == Phase::zeroLatency)
+            {
+                if (anyDynamic) redesignDynamic();
+                runIir (left + off, right + off, m);
+            }
+            else
+            {
+                sinceDesign += m;
+                if (! firLoaded || (sinceDesign >= updateEvery && ! conv.fading() && (firDirty || (anyDynamic && dynamicMoved()))))
+                    loadFir();
+                for (int i = 0; i < m; ++i) conv.step (left[off + i], right[off + i]);
+            }
+        }
+
+        if (outGain != 1.0f)
+            for (int i = 0; i < n; ++i) { left[i] *= outGain; right[i] *= outGain; }
+        for (int b = 0; b < bands; ++b) meters[(std::size_t) b].store ((float) det[(std::size_t) b].gain, std::memory_order_relaxed);
+    }
+
+private:
+    struct State { double z1[2] {}, z2[2] {}; };
+    struct Detector
+    {
+        Biquad filter;
+        double ms = 0.0, gain = 0.0, msCoef = 0.0, threshold = -20.0, range = 0.0;
+        bool on = false;
+    };
+
+    void configureMode (Phase p) noexcept
+    {
+        mode = p;
+        const int fct = rateFactor (sampleRate);
+        if (p == Phase::natural) conv.configure (fftNatural, naturalBlock * fct, taps);
+        else if (p == Phase::linear) conv.configure (fftLinear, linearBlock * fct, taps);
+        updateEvery = std::max (1024 * fct, p == Phase::linear ? linearBlock * fct : naturalBlock * fct);
+        firLoaded = false;
+        latencyNow.store (latencyFor (p, sampleRate), std::memory_order_relaxed);
+    }
+
+    void update (const EffectParams& params) noexcept
+    {
+        for (int i = 0; i < paramCount; ++i) cached[(std::size_t) i] = params[(std::size_t) i];
+        current = params;
+        const auto newMode = phase (params[(std::size_t) phaseParam]);
+        if (newMode != mode)
         {
-            for (int i = 0; i < paramCount; ++i) cached[(std::size_t) i] = params[(std::size_t) i];
-            for (int b = 0; b < bands; ++b)
+            configureMode (newMode);
+            conv.reset();
+            for (auto& d : delay) std::fill (d.begin(), d.end(), 0.0f);
+        }
+        anyDynamic = false;
+        for (int b = 0; b < bands; ++b)
+        {
+            auto& d = det[(std::size_t) b];
+            const bool was = d.on;
+            d.on = isDynamic (params, b);
+            d.threshold = thresholdDb (params[(std::size_t) (thresholdParam0 + b)]);
+            d.range = rangeDb (params[(std::size_t) (rangeParam0 + b)]);
+            if (d.on)
             {
-                const int before = counts[(std::size_t) b];
-                counts[(std::size_t) b] = design (params, b, sampleRate, sections[(std::size_t) b]);
-                if (counts[(std::size_t) b] != before) // the structure changed: start this band clean
-                    for (auto& st : state[(std::size_t) b]) st = {};
+                regionFilter (d.filter, params, b, sampleRate);
+                const double f0 = hz (params[(std::size_t) param (b, 1)]);
+                d.msCoef = 1.0 - std::exp (-1.0 / (std::max (0.001, 1.5 / f0) * sampleRate));
+                anyDynamic = true;
+                if (! was) { d.filter.clear(); d.ms = 0.0; }
             }
-            outGain = (float) std::pow (10.0, outputDb (params[(std::size_t) outputParam]) / 20.0);
+            else
+                d.gain = 0.0;
+
+            const int before = counts[(std::size_t) b];
+            counts[(std::size_t) b] = facet::design (params, b, sampleRate, sections[(std::size_t) b], d.gain);
+            if (d.on && counts[(std::size_t) b] == 0) // a dynamic band at 0 dB keeps its (flat) section to move it later
+                counts[(std::size_t) b] = designKeep (b, d.gain);
+            if (counts[(std::size_t) b] != before) // the structure changed: start this band clean
+                for (auto& st : state[(std::size_t) b]) st = {};
+            dynUsed[(std::size_t) b] = d.gain;
         }
+        attackCoef = 1.0 - std::exp (-1.0 / (attackMs (params[(std::size_t) attackParam]) * 0.001 * sampleRate));
+        releaseCoef = 1.0 - std::exp (-1.0 / (releaseMs (params[(std::size_t) releaseParam]) * 0.001 * sampleRate));
+        outGain = (float) std::pow (10.0, outputDb (params[(std::size_t) outputParam]) / 20.0);
+
+        const int sb = soloBand (params[(std::size_t) soloParam]);
+        const bool wasSolo = soloOn;
+        soloOn = sb >= 0 && shape (params[(std::size_t) param (sb, 0)]) != Shape::off;
+        if (soloOn) regionFilter (solo, params, sb, sampleRate);
+        if (soloOn && ! wasSolo) solo.clear();
+        firDirty = true;
+    }
 
+    int designKeep (int b, double extra) noexcept
+    {
+        Analog a[maxSections];
+        const int n = analogSections (current, b, a, extra, true);
+        const double f0 = std::min (hz (current[(std::size_t) param (b, 1)]), 0.4999 * sampleRate);
+        const double w0 = 2.0 * pi * f0 / sampleRate;
+        for (int k = 0; k < n; ++k) sections[(std::size_t) b][(std::size_t) k] = matched (a[k], w0);
+        return n;
+    }
+
+    // detector levels and the dynamic gains, sample by sample over one chunk
+    void detect (const float* dl, const float* dr, const float* inL, const float* inR, int m, bool side) noexcept
+    {
+        for (int b = 0; b < bands; ++b)
+        {
+            auto& d = det[(std::size_t) b];
+            if (! d.on) continue;
+            for (int i = 0; i < m; ++i)
+            {
+                double x = 0.0;
+                if (side) x = dl != nullptr ? 0.5 * ((double) dl[i] + (double) dr[i]) : 0.0;
+                else x = 0.5 * ((double) inL[i] + (double) inR[i]);
+                if (! std::isfinite (x)) x = 0.0;
+                const double y = d.filter.run (x, 0);
+                d.ms += d.msCoef * (y * y - d.ms);
+                const double level = 10.0 * std::log10 (2.0 * d.ms + 1e-20);
+                const double target = dynamicGainDb (level, d.threshold, d.range);
+                d.gain += (std::abs (target) > std::abs (d.gain) ? attackCoef : releaseCoef) * (target - d.gain);
+            }
+            if (std::abs (d.ms) < 1e-30) d.ms = 0.0;
+        }
+    }
+
+    void redesignDynamic() noexcept
+    {
+        for (int b = 0; b < bands; ++b)
+        {
+            const auto& d = det[(std::size_t) b];
+            if (! d.on || std::abs (d.gain - dynUsed[(std::size_t) b]) < 0.01) continue;
+            const int before = counts[(std::size_t) b];
+            const int c = designKeep (b, d.gain);
+            if (c != before)
+            {
+                for (auto& st : state[(std::size_t) b]) st = {};
+                counts[(std::size_t) b] = c;
+            }
+            dynUsed[(std::size_t) b] = d.gain;
+        }
+    }
+
+    bool dynamicMoved() const noexcept
+    {
+        for (int b = 0; b < bands; ++b)
+            if (det[(std::size_t) b].on && std::abs (det[(std::size_t) b].gain - dynUsed[(std::size_t) b]) > 0.05) return true;
+        return false;
+    }
+
+    void runIir (float* left, float* right, int n) noexcept
+    {
         for (int b = 0; b < bands; ++b)
             for (int k = 0; k < counts[(std::size_t) b]; ++k)
             {
@@ -257,22 +658,109 @@ public:
                     st.z2[ch] = std::abs (z2) < 1e-30 ? 0.0 : z2;
                 }
             }
+    }
 
-        if (outGain != 1.0f)
-            for (int i = 0; i < n; ++i) { left[i] *= outGain; right[i] *= outGain; }
+    // solo: the band's region alone (delayed like the FIR modes so switching does not jump)
+    void runSolo (float* left, float* right, int n) noexcept
+    {
+        const int lat = mode == Phase::zeroLatency ? 0 : latencyFor (mode, sampleRate);
+        for (int i = 0; i < n; ++i)
+        {
+            const float yl = (float) solo.run (left[i], 0), yr = (float) solo.run (right[i], 1);
+            if (lat == 0) { left[i] = yl; right[i] = yr; continue; }
+            delay[0][(std::size_t) delayPos] = yl;
+            delay[1][(std::size_t) delayPos] = yr;
+            const int rd = (delayPos - lat + delayLen) % delayLen;
+            left[i] = delay[0][(std::size_t) rd];
+            right[i] = delay[1][(std::size_t) rd];
+            delayPos = (delayPos + 1) % delayLen;
+        }
+    }
+
+    // the FIR of the current response (analog magnitude; analog phase in natural mode), windowed around its delay
+    void loadFir() noexcept
+    {
+        const int M = taps;
+        const bool natural = mode == Phase::natural;
+        const int fct = rateFactor (sampleRate);
+        const int D = natural ? naturalDelay * fct : M / 2;
+        // every band's analog sections once, then the product of their responses on the FFT grid
+        Analog a[bands * maxSections];
+        double f0[bands * maxSections];
+        int used = 0;
+        for (int b = 0; b < bands; ++b)
+        {
+            if (shape (current[(std::size_t) param (b, 0)]) == Shape::off) continue;
+            const int c = analogSections (current, b, a + used, det[(std::size_t) b].on ? det[(std::size_t) b].gain : 0.0);
+            for (int k = 0; k < c; ++k) f0[used + k] = hz (current[(std::size_t) param (b, 1)]);
+            used += c;
+        }
+        const cd rot = std::polar (1.0, -2.0 * pi * D / M);
+        cd phasor (1.0, 0.0);
+        for (int k = 0; k <= M / 2; ++k)
+        {
+            const double f = std::max ((double) k * sampleRate / M, 0.01);
+            double hr = 1.0, hi = 0.0;
+            for (int j = 0; j < used; ++j)
+            {
+                const auto& s = a[j];
+                const double w = f / f0[j], w2 = w * w;
+                const double nr = s.n0 - s.n2 * w2, ni = s.n1 * w, dr = s.d0 - s.d2 * w2, di = s.d1 * w;
+                const double dd = dr * dr + di * di;
+                const double qr = (nr * dr + ni * di) / dd, qi = (ni * dr - nr * di) / dd;
+                const double tr = hr * qr - hi * qi;
+                hi = hr * qi + hi * qr;
+                hr = tr;
+            }
+            cd h = natural ? cd (hr, hi) : cd (std::sqrt (hr * hr + hi * hi), 0.0);
+            h = cd (h.real() * phasor.real() - h.imag() * phasor.imag(), h.real() * phasor.imag() + h.imag() * phasor.real());
+            if ((k & 255) == 255) phasor = std::polar (1.0, -2.0 * pi * (double) (k + 1) * D / M); // no drift
+            else phasor *= rot;
+            if (k == M / 2 || k == 0) h = cd (h.real(), 0.0);
+            spec[(std::size_t) k] = h;
+            if (k > 0 && k < M / 2) spec[(std::size_t) (M - k)] = std::conj (h);
+        }
+        fftDesign.run (spec.data(), true);
+        for (int i = 0; i < M; ++i)
+        {
+            const double w = i < D ? 0.5 * (1.0 - std::cos (pi * (i + 0.5) / D)) : 0.5 * (1.0 + std::cos (pi * (i - D) / (double) (M - D)));
+            fir[(std::size_t) i] = spec[(std::size_t) i].real() / M * w;
+        }
+        conv.load (fir.data(), ! firLoaded);
+        firLoaded = true;
+        firDirty = false;
+        sinceDesign = 0;
+        for (int b = 0; b < bands; ++b) dynUsed[(std::size_t) b] = det[(std::size_t) b].gain;
     }
 
-private:
-    struct State { double z1[2] {}, z2[2] {}; };
     double sampleRate = 48000.0;
+    Phase mode = Phase::zeroLatency;
+    EffectParams current {};
     std::array<float, paramCount> cached {};
     std::array<std::array<Section, maxSections>, bands> sections {};
     std::array<std::array<State, maxSections>, bands> state {};
     std::array<int, bands> counts {};
+    std::array<Detector, bands> det {};
+    std::array<double, bands> dynUsed {};
+    std::array<std::atomic<float>, bands> meters {};
+    double attackCoef = 0.1, releaseCoef = 0.001;
     float outGain = 1.0f;
+    bool anyDynamic = false, soloOn = false, firLoaded = false, firDirty = true, sideGiven = false;
+    Biquad solo;
+    const float* sideL = nullptr;
+    const float* sideR = nullptr;
+    Fft fftNatural, fftLinear, fftDesign;
+    Convolver conv;
+    int taps = firTaps, updateEvery = 1024, sinceDesign = 0;
+    std::vector<cd> spec;
+    std::vector<double> fir;
+    std::vector<float> delay[2];
+    int delayLen = 1, delayPos = 0;
+    std::atomic<int> latencyNow { 0 };
 };
 } // namespace
 
+
 Shape shape (float v) noexcept { return (Shape) std::clamp ((int) std::lround (v * (shapeCount - 1)), 0, shapeCount - 1); }
 float shapeValue (Shape s) noexcept { return (float) (int) s / (float) (shapeCount - 1); }
 double hz (float v) noexcept { return 10.0 * std::pow (3000.0, (double) std::clamp (v, 0.0f, 1.0f)); }
@@ -314,6 +802,19 @@ const EffectInfo& info()
             }
         e.params.push_back ({ "Output", 0.5f });
         e.params.push_back ({ "Gain Scale", 0.5f });
+        static std::array<std::array<char, 24>, bands * 2> dynNames {};
+        for (int k = 0; k < bands * 2; ++k)
+        {
+            auto& n = dynNames[(std::size_t) k];
+            std::snprintf (n.data(), n.size(), k < bands ? "%d Range" : "%d Threshold", k % bands + 1);
+            e.params.push_back ({ n.data(), k < bands ? 0.5f : thresholdValue (-20.0) });
+        }
+        e.params.push_back ({ "Attack", 0.5f });
+        e.params.push_back ({ "Release", 0.5f });
+        e.params.push_back ({ "Phase", 0.0f });
+        e.params.push_back ({ "Solo", 0.0f });
+        e.params.push_back ({ "Detector", 0.0f });
+        e.params.push_back ({ "Analyzer", 1.0f });
         return e;
     }();
     return i;
@@ -324,6 +825,14 @@ std::string paramText (int p, float v)
     char t[48];
     if (p == outputParam) { std::snprintf (t, sizeof (t), "%+.2f dB", outputDb (v)); return t; }
     if (p == scaleParam) { std::snprintf (t, sizeof (t), "%.0f%%", gainScale (v) * 100.0); return t; }
+    if (p >= rangeParam0 && p < rangeParam0 + bands) { std::snprintf (t, sizeof (t), "%+.2f dB", rangeDb (v)); return t; }
+    if (p >= thresholdParam0 && p < thresholdParam0 + bands) { std::snprintf (t, sizeof (t), "%.1f dB", thresholdDb (v)); return t; }
+    if (p == attackParam) { std::snprintf (t, sizeof (t), attackMs (v) < 10.0 ? "%.2f ms" : "%.1f ms", attackMs (v)); return t; }
+    if (p == releaseParam) { const auto ms = releaseMs (v); std::snprintf (t, sizeof (t), ms < 1000.0 ? "%.0f ms" : "%.2f s", ms < 1000.0 ? ms : ms / 1000.0); return t; }
+    if (p == phaseParam) return phaseName (phase (v));
+    if (p == soloParam) { const auto b = soloBand (v); if (b < 0) return "Off"; std::snprintf (t, sizeof (t), "Band %d", b + 1); return t; }
+    if (p == detectorParam) return sidechainDetector (v) ? "Sidechain" : "Input";
+    if (p == analyzerParam) { static const char* a[] = { "Off", "Pre", "Post", "Pre + Post" }; return a[(int) analyzer (v)]; }
     switch (p % fieldsPerBand)
     {
         case 0: return shapeName (shape (v));
@@ -334,10 +843,10 @@ std::string paramText (int p, float v)
     }
 }
 
-int design (const EffectParams& params, int band, double sampleRate, std::array<Section, maxSections>& out) noexcept
+int design (const EffectParams& params, int band, double sampleRate, std::array<Section, maxSections>& out, double extraDb) noexcept
 {
     Analog a[maxSections];
-    const int n = analogSections (params, band, a);
+    const int n = analogSections (params, band, a, extraDb);
     const double f0 = std::min (hz (params[(std::size_t) param (band, 1)]), 0.4999 * sampleRate);
     const double w0 = 2.0 * pi * f0 / sampleRate;
     for (int k = 0; k < n; ++k)
@@ -345,28 +854,105 @@ int design (const EffectParams& params, int band, double sampleRate, std::array<
     return n;
 }
 
-double analogDb (const EffectParams& params, int band, double f) noexcept
+double analogDb (const EffectParams& params, int band, double f, double extraDb) noexcept
 {
     Analog a[maxSections];
-    const int n = analogSections (params, band, a);
+    const int n = analogSections (params, band, a, extraDb);
     const double w = f / hz (params[(std::size_t) param (band, 1)]);
     double m = 1.0;
     for (int k = 0; k < n; ++k) m *= std::sqrt (mag2 (a[k], w));
     return 20.0 * std::log10 (std::max (m, 1e-15));
 }
 
-double responseDb (const EffectParams& params, double sampleRate, double f) noexcept
+double bandResponseDb (const EffectParams& params, int band, double sampleRate, double f, double extraDb) noexcept
 {
-    const double w = 2.0 * pi * f / sampleRate;
+    if (phase (params[(std::size_t) phaseParam]) != Phase::zeroLatency)
+        return analogDb (params, band, f, extraDb);
+    std::array<Section, maxSections> s;
+    const int n = design (params, band, sampleRate, s, extraDb);
+    const double w = 2.0 * pi * std::min (f, 0.5 * sampleRate) / sampleRate;
     double m = 1.0;
+    for (int k = 0; k < n; ++k) m *= std::abs (evalDigital (s[(std::size_t) k], w));
+    return 20.0 * std::log10 (std::max (m, 1e-15));
+}
+
+void bandCurveDb (const EffectParams& params, int band, double sampleRate, const double* f, int n, double* out, double extraDb) noexcept
+{
+    if (phase (params[(std::size_t) phaseParam]) != Phase::zeroLatency)
+    {
+        Analog a[maxSections];
+        const int c = analogSections (params, band, a, extraDb);
+        const double f0 = hz (params[(std::size_t) param (band, 1)]);
+        for (int i = 0; i < n; ++i)
+        {
+            double m = 1.0;
+            for (int k = 0; k < c; ++k) m *= mag2 (a[k], f[i] / f0);
+            out[i] = 10.0 * std::log10 (std::max (m, 1e-30));
+        }
+        return;
+    }
+    std::array<Section, maxSections> s;
+    const int c = design (params, band, sampleRate, s, extraDb);
+    for (int i = 0; i < n; ++i)
+    {
+        const double w = 2.0 * pi * std::min (f[i], 0.5 * sampleRate) / sampleRate;
+        double m = 1.0;
+        for (int k = 0; k < c; ++k) m *= std::abs (evalDigital (s[(std::size_t) k], w));
+        out[i] = 20.0 * std::log10 (std::max (m, 1e-15));
+    }
+}
+
+double responseDb (const EffectParams& params, double sampleRate, double f, const float* dynamicDb) noexcept
+{
+    double db = outputDb (params[(std::size_t) outputParam]);
     for (int b = 0; b < bands; ++b)
+        db += bandResponseDb (params, b, sampleRate, f, dynamicDb != nullptr && isDynamic (params, b) ? (double) dynamicDb[b] : 0.0);
+    return db;
+}
+
+bool hasGain (Shape s) noexcept { return s == Shape::bell || s == Shape::lowShelf || s == Shape::highShelf || s == Shape::tiltShelf; }
+double rangeDb (float v) noexcept { return ((double) std::clamp (v, 0.0f, 1.0f) - 0.5) * 60.0; }
+float rangeValue (double db) noexcept { return (float) std::clamp (db / 60.0 + 0.5, 0.0, 1.0); }
+double thresholdDb (float v) noexcept { return -80.0 + 80.0 * (double) std::clamp (v, 0.0f, 1.0f); }
+float thresholdValue (double db) noexcept { return (float) std::clamp ((db + 80.0) / 80.0, 0.0, 1.0); }
+double attackMs (float v) noexcept { return 0.25 * std::pow (200.0, (double) std::clamp (v, 0.0f, 1.0f)); }
+double releaseMs (float v) noexcept { return 20.0 * std::pow (200.0, (double) std::clamp (v, 0.0f, 1.0f)); }
+Phase phase (float v) noexcept { return (Phase) std::clamp ((int) std::lround (v * (phaseCount - 1)), 0, phaseCount - 1); }
+float phaseValue (Phase p) noexcept { return (float) (int) p / (float) (phaseCount - 1); }
+int soloBand (float v) noexcept { return std::clamp ((int) std::lround (v * bands), 0, bands) - 1; }
+float soloValue (int band) noexcept { return band < 0 ? 0.0f : (float) (band + 1) / (float) bands; }
+bool sidechainDetector (float v) noexcept { return v >= 0.5f; }
+Analyzer analyzer (float v) noexcept { return (Analyzer) std::clamp ((int) std::lround (v * 3.0f), 0, 3); }
+float analyzerValue (Analyzer a) noexcept { return (float) (int) a / 3.0f; }
+const char* phaseName (Phase p) noexcept
+{
+    static const char* names[] = { "Zero Latency", "Natural Phase", "Linear Phase" };
+    return names[(int) p];
+}
+
+bool isDynamic (const EffectParams& p, int b) noexcept
+{
+    return hasGain (shape (p[(std::size_t) param (b, 0)])) && std::abs (rangeDb (p[(std::size_t) (rangeParam0 + b)])) > 0.01;
+}
+
+double dynamicGainDb (double level, double threshold, double range) noexcept
+{
+    const double x = level - threshold;
+    constexpr double knee = 10.0; // fitted to the reference (REA_rodada103 §2.1)
+    const double over = x <= -0.5 * knee ? 0.0 : x < 0.5 * knee ? (x + 0.5 * knee) * (x + 0.5 * knee) / (2.0 * knee) : x;
+    return range < 0.0 ? -std::min (-range, over) : std::min (range, over);
+}
+
+int latencyFor (Phase p, double sampleRate) noexcept
+{
+    const int f = rateFactor (sampleRate);
+    switch (p)
     {
-        std::array<Section, maxSections> s;
-        const int n = design (params, b, sampleRate, s);
-        for (int k = 0; k < n; ++k) m *= std::abs (evalDigital (s[(std::size_t) k], w));
+        case Phase::natural: return (naturalBlock + naturalDelay) * f;
+        case Phase::linear: return linearBlock * f + firTaps * f / 2;
+        default: return 0;
     }
-    return 20.0 * std::log10 (std::max (m, 1e-15)) + outputDb (params[(std::size_t) outputParam]);
 }
 
-std::unique_ptr<Effect> make() { return std::make_unique<FacetEqEffect>(); }
+std::unique_ptr<Effect> make (const EffectParams* initial) { return std::make_unique<FacetEqEffect> (initial); }
 } // namespace lynx::facet

+ 61 - 7
src/core/FacetEq.h

@@ -9,7 +9,18 @@
 // slope law follow our black-box measurements of the reference EQ (docs/analise/MEASURE_fabfilter.md §1).
 //
 // Parameters (0..1, EffectKind::facetEq): band b uses [5b .. 5b+4] = shape, frequency, gain, Q, slope;
-// [40] output gain, [41] gain scale.
+// [40] output gain, [41] gain scale; (round 103, appended so older projects load unchanged — every default is the old
+// behaviour) [42 + b] dynamic range of band b (0.5 = 0 dB = a static band), [50 + b] its threshold, [58] attack,
+// [59] release, [60] phase mode (zero latency / natural / linear), [61] solo band (0 = none), [62] dynamics detector
+// (the EQ's input / the slot's sidechain), [63] analyser display (editor only: off, pre, post, pre + post).
+//
+// Dynamic EQ (docs/analise/REA_rodada103.md §2, measured on the reference): each band with a gain (bell, shelves,
+// tilt) whose range is not 0 listens to its own region of the detector signal (band pass at the band frequency and
+// Q; low pass / high pass for the shelves) and moves its gain by up to `range` dB as that level rises over the
+// threshold — 1 dB per dB above it (an infinite ratio) with a 10 dB soft knee, clamped at the range, smoothed by the
+// attack / release times. Phase modes: zero latency (the IIR sections), natural phase (the analog prototype's
+// magnitude and phase as an FIR, 320 samples at 48 kHz) and linear phase (the analog magnitude, zero phase, 4608
+// samples at 48 kHz), both run as a uniformly partitioned FFT convolution and reported to PDC.
 
 #include <array>
 #include <memory>
@@ -23,7 +34,15 @@ constexpr int bands = 8;
 constexpr int fieldsPerBand = 5;
 constexpr int outputParam = 40;
 constexpr int scaleParam = 41;
-constexpr int paramCount = 42;
+constexpr int rangeParam0 = 42;     // + band
+constexpr int thresholdParam0 = 50; // + band
+constexpr int attackParam = 58;
+constexpr int releaseParam = 59;
+constexpr int phaseParam = 60;
+constexpr int soloParam = 61;
+constexpr int detectorParam = 62;
+constexpr int analyzerParam = 63;
+constexpr int paramCount = 64;
 constexpr int maxSections = 8; // 96 dB/oct = 16th order
 
 enum class Shape { off, bell, lowShelf, highShelf, lowCut, highCut, notch, bandPass, tiltShelf };
@@ -45,6 +64,33 @@ float slopeValue (int dbPerOct) noexcept;
 double outputDb (float v) noexcept;    // ±24 dB
 double gainScale (float v) noexcept;   // 0 .. 200 %
 const char* shapeName (Shape s) noexcept;
+bool hasGain (Shape s) noexcept;       // bell, shelves, tilt: the shapes a gain (and dynamics) applies to
+
+enum class Phase { zeroLatency, natural, linear };
+constexpr int phaseCount = 3;
+enum class Analyzer { off, pre, post, both };
+
+double rangeDb (float v) noexcept;     // dynamic range ±30 dB (0.5 = 0 = static)
+float rangeValue (double db) noexcept;
+double thresholdDb (float v) noexcept; // −80 … 0 dB (sine peak)
+float thresholdValue (double db) noexcept;
+double attackMs (float v) noexcept;    // 0.25 … 50 ms
+double releaseMs (float v) noexcept;   // 20 … 4000 ms
+Phase phase (float v) noexcept;
+float phaseValue (Phase p) noexcept;
+int soloBand (float v) noexcept;       // −1 = none
+float soloValue (int band) noexcept;
+bool sidechainDetector (float v) noexcept;
+Analyzer analyzer (float v) noexcept;
+float analyzerValue (Analyzer a) noexcept;
+bool isDynamic (const EffectParams& params, int band) noexcept;
+const char* phaseName (Phase p) noexcept;
+
+// The dynamic gain (dB) a band applies for a detector level (dB, sine peak): 0 below the knee, then 1 dB per dB over the
+// threshold (10 dB soft knee), clamped at the range; the sign follows the range.
+double dynamicGainDb (double levelDb, double thresholdDb, double rangeDb) noexcept;
+// Latency (samples) of a phase mode at a sample rate
+int latencyFor (Phase p, double sampleRate) noexcept;
 
 const EffectInfo& info();
 std::string paramText (int param, float v);
@@ -53,11 +99,19 @@ std::string paramText (int param, float v);
 struct Section { double b0 = 1, b1 = 0, b2 = 0, a1 = 0, a2 = 0; };
 
 // The sections of one band at a sample rate; returns how many were written (0 = the band is off / flat).
-int design (const EffectParams& params, int band, double sampleRate, std::array<Section, maxSections>& out) noexcept;
+// `extraDb` is added to the band's gain (before the gain scale): the dynamic EQ's movement.
+int design (const EffectParams& params, int band, double sampleRate, std::array<Section, maxSections>& out, double extraDb = 0.0) noexcept;
 // The analog prototype's response of one band (dB) — the target the digital design matches.
-double analogDb (const EffectParams& params, int band, double hz) noexcept;
-// Response of the whole EQ (digital, dB) at hz.
-double responseDb (const EffectParams& params, double sampleRate, double hz) noexcept;
+double analogDb (const EffectParams& params, int band, double hz, double extraDb = 0.0) noexcept;
+// Response of the whole EQ (dB) at hz: the digital sections in zero-latency mode, the analog prototype in the FIR
+// modes. `dynamicDb` (optional, 8 values) are the bands' live dynamic gains.
+double responseDb (const EffectParams& params, double sampleRate, double hz, const float* dynamicDb = nullptr) noexcept;
+// One band's response (dB) at `n` frequencies at once (designed once; for the editor's curves), same rules
+void bandCurveDb (const EffectParams& params, int band, double sampleRate, const double* hz, int n, double* outDb, double extraDb = 0.0) noexcept;
+// One band's own response (dB) at hz, same rules
+double bandResponseDb (const EffectParams& params, int band, double sampleRate, double hz, double extraDb = 0.0) noexcept;
 
-std::unique_ptr<Effect> make();
+// The effect; with the slot's parameters its latency is known from the start (PDC plans it before the first block).
+std::unique_ptr<Effect> make (const EffectParams* initial = nullptr);
+// controlOutput (b), b = 0 … 7: band b's live dynamic gain in dB / 60 (signed: 0 = no movement, also when cleared)
 } // namespace lynx::facet

+ 7 - 0
src/core/PluginLayout.cpp

@@ -1027,6 +1027,13 @@ Layout lynxTune()
     for (int k = 0; k < 12; ++k)
         v.push_back (toggle (8.0f + 40.0f * (float) k, 194, 36, 22, notes[k], notes[k]));
     v.push_back (stepper (500, 192, 92, 24, "MIDI", TR_NOOP ("MIDI channel"), 129));
+    // round 103: the live pitch display on top (detected pitch, target note, correction, scrolling pitch graph)
+    constexpr float top = 170.0f;
+    for (auto& item : v)
+        item.y += top;
+    l.height += (int) top;
+    v.insert (v.begin(), section (0, 0, 600, top - 4.0f, TR_NOOP ("LIVE PITCH")));
+    v.insert (v.begin() + 1, display (6, 22, 588, top - 30.0f, "pitchgraph"));
     return l;
 }
 

+ 31 - 4
src/core/RackRenderer.cpp

@@ -1045,6 +1045,12 @@ void RackRenderer::applyTrackEq (const MixerTrack& track, int t, float* l, float
     }
 }
 
+// effects whose controlOutput() an editor shows live
+static bool hasLiveMeters (EffectKind kind) noexcept
+{
+    return mixsuite::isSuiteKind (kind) || kind == EffectKind::lynxTune || kind == EffectKind::facetEq;
+}
+
 void RackRenderer::setSidechain (const RackState& state, const EffectSlot& slot, Effect& effect, int track) noexcept
 {
     // the source was already processed in this pass (earlier layer); silent = no signal in the detector
@@ -1102,7 +1108,7 @@ void RackRenderer::runEffects (const RackState& state, int track, int n) noexcep
 
         if (! slots[i].enabled || wet <= 0.0f)
         {
-            if (mixsuite::isSuiteKind (slots[i].kind))
+            if (hasLiveMeters (slots[i].kind))
                 clearMeters();
             continue;
         }
@@ -1130,7 +1136,7 @@ void RackRenderer::runEffects (const RackState& state, int track, int n) noexcep
                 sd.silentSamples = 0;
             else if (sd.silentSamples >= hold)
             {
-                if (mixsuite::isSuiteKind (slots[i].kind))
+                if (hasLiveMeters (slots[i].kind))
                     clearMeters();
                 continue;
             }
@@ -1138,6 +1144,16 @@ void RackRenderer::runEffects (const RackState& state, int track, int n) noexcep
                 sd.silentSamples += n;
         }
 
+        // the editor's spectrum analyser listens to this slot: its input
+        const auto tapped = times->analyzer.key.load (std::memory_order_relaxed) == (int) key;
+        if (tapped)
+        {
+            auto& tap = times->analyzer;
+            const auto w = tap.written.load (std::memory_order_relaxed);
+            for (int k = 0; k < n; ++k)
+                tap.pre[(std::size_t) ((w + (std::uint32_t) k) & (ProcessTimes::AnalyzerTap::size - 1))].store (0.5f * (l[k] + r[k]), std::memory_order_relaxed);
+        }
+
         // dry/wet: keep the dry signal to mix later
         const auto partial = wet < 0.999f;
 
@@ -1187,8 +1203,19 @@ void RackRenderer::runEffects (const RackState& state, int track, int n) noexcep
             }
         }
 
-        // live meters for the editor (the mixing suite's gain reduction)
-        if (mixsuite::isSuiteKind (slots[i].kind) && key < (std::size_t) maxMixerTracks * maxEffectSlots)
+        // ... and its output
+        if (tapped)
+        {
+            auto& tap = times->analyzer;
+            const auto w = tap.written.load (std::memory_order_relaxed);
+            for (int k = 0; k < n; ++k)
+                tap.post[(std::size_t) ((w + (std::uint32_t) k) & (ProcessTimes::AnalyzerTap::size - 1))].store (0.5f * (l[k] + r[k]), std::memory_order_relaxed);
+            tap.sampleRate.store (sampleRate, std::memory_order_relaxed);
+            tap.written.store (w + (std::uint32_t) n, std::memory_order_release);
+        }
+
+        // live meters for the editor (the mixing suite's gain reduction, LYNX Tune's pitch, Facet EQ's dynamic gains)
+        if (hasLiveMeters (slots[i].kind) && key < (std::size_t) maxMixerTracks * maxEffectSlots)
             for (int o = 0; o < ProcessTimes::meterOutputs; ++o)
                 times->effectMeters[key * ProcessTimes::meterOutputs + (std::size_t) o].store (effects[i]->controlOutput (o), std::memory_order_relaxed);
 

+ 16 - 2
src/core/RackRenderer.h

@@ -145,11 +145,25 @@ struct ProcessTimes
     std::array<std::atomic<std::uint64_t>, maxMixerTracks * maxEffectSlots> effectNs {}; // [track * maxEffectSlots + slot]
     std::atomic<std::uint64_t> audioNs { 0 };  // duration of the audio rendered while enabled
     std::atomic<std::uint64_t> wallNs { 0 };   // time the whole rack took for it
-    // Live meters of the effects that have them (the mixing suite's gain reduction, REA round 96), always published:
+    // Live meters of the effects that have them (the mixing suite's gain reduction, REA round 96; LYNX Tune's pitch and
+    // Facet EQ's dynamic gains, round 103), always published:
     // [(track * maxEffectSlots + slot) * meterOutputs + output] = Effect::controlOutput (output) after the last block.
-    static constexpr int meterOutputs = 2;
+    static constexpr int meterOutputs = 8;
     std::array<std::atomic<float>, (std::size_t) maxMixerTracks * maxEffectSlots * meterOutputs> effectMeters {};
 
+    // Audio of one effect slot for an editor's spectrum analyser (Facet EQ, round 103): the editor sets `key`
+    // (track * maxEffectSlots + slot, −1 = none); the audio thread then writes the slot's input (pre) and output
+    // (post), as mono mid samples, into the rings and advances `written`. Reads may tear; the analyser tolerates it.
+    struct AnalyzerTap
+    {
+        static constexpr int size = 16384; // power of two
+        std::atomic<int> key { -1 };
+        std::atomic<std::uint32_t> written { 0 };
+        std::atomic<double> sampleRate { 48000.0 };
+        std::array<std::atomic<float>, size> pre {}, post {};
+    };
+    AnalyzerTap analyzer;
+
     static std::uint64_t now() noexcept
     {
         return (std::uint64_t) std::chrono::duration_cast<std::chrono::nanoseconds> (std::chrono::steady_clock::now().time_since_epoch()).count();

+ 1477 - 0
src/ui/FacetEqEditor.cpp

@@ -0,0 +1,1477 @@
+#include "ui/FacetEqEditor.h"
+
+#include <juce_dsp/juce_dsp.h>
+
+#include <cmath>
+#include <map>
+
+#include "core/Effects.h"
+#include "core/FacetEq.h"
+#include "core/RackRenderer.h"
+#include "engine/Text.h"
+#include "ui/I18n.h"
+#include "ui/Theme.h"
+#include "ui/ValueControl.h"
+#include "ui/WindowOwner.h"
+
+namespace lynx
+{
+namespace
+{
+using namespace facet;
+
+constexpr double minHz = 10.0, maxHz = 30000.0;      // the graph's frequency axis (the bands' whole range)
+constexpr double specTop = 0.0, specBottom = -96.0;  // analyser scale (dBFS, tilted 4.5 dB/oct around 1 kHz)
+constexpr int fftOrder = 13, fftSize = 1 << fftOrder;
+
+juce::Colour bandColour (int band)
+{
+    // one hue per band at the same lightness; the first is LYNX's red
+    static const juce::Colour colours[] = { juce::Colour (0xffef5b5f), juce::Colour (0xfff2a46b), juce::Colour (0xffe8cf6a),
+                                            juce::Colour (0xff86d993), juce::Colour (0xff62cfd0), juce::Colour (0xff7aa9f5),
+                                            juce::Colour (0xffb59af2), juce::Colour (0xffef7fc0) };
+    return colours[band & 7];
+}
+
+// display names of facet::Shape (core names, translated here)
+const char* const shapeNames[] = { TR_NOOP ("Off"), TR_NOOP ("Bell"), TR_NOOP ("Low shelf"), TR_NOOP ("High shelf"), TR_NOOP ("Low cut"),
+                                   TR_NOOP ("High cut"), TR_NOOP ("Notch"), TR_NOOP ("Band pass"), TR_NOOP ("Tilt shelf") };
+const char* const phaseNames[] = { TR_NOOP ("Zero latency"), TR_NOOP ("Natural phase"), TR_NOOP ("Linear phase") };
+const char* const analyzerShort[] = { TR_NOOP ("Off"), TR_NOOP ("Pre"), TR_NOOP ("Post"), TR_NOOP ("Pre + Post") };
+const char* const analyzerNames[] = { TR_NOOP ("Analyzer off"), TR_NOOP ("Analyzer: pre"), TR_NOOP ("Analyzer: post"), TR_NOOP ("Analyzer: pre + post") };
+
+juce::String noteName (double hz)
+{
+    static const char* names[] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
+    const auto n = 69.0 + 12.0 * std::log2 (hz / 440.0);
+    const auto k = (int) std::lround (n);
+    const auto cents = (int) std::lround ((n - k) * 100.0);
+    return juce::String (names[((k % 12) + 12) % 12]) + juce::String (k / 12 - 1) + (cents == 0 ? juce::String() : (cents > 0 ? " +" : " ") + juce::String (cents));
+}
+
+juce::String hzText (double hz)
+{
+    return hz < 1000.0 ? juce::String (hz, hz < 100.0 ? 1 : 0) + " Hz" : juce::String (hz / 1000.0, hz < 10000.0 ? 2 : 1) + " kHz";
+}
+
+class FacetEqEditor final : public juce::Component,
+                            public ui::HintSource,
+                            private juce::ChangeListener,
+                            private juce::Timer
+{
+public:
+    FacetEqEditor (AudioEngine& e, int t, int s, bool demoSpectrum)
+        : engine (e),
+          track (t),
+          slot (s),
+          demo (demoSpectrum),
+          fft (fftOrder)
+    {
+        fftData.assign ((std::size_t) fftSize * 2, 0.0f);
+        window.resize ((std::size_t) fftSize);
+        for (int i = 0; i < fftSize; ++i)
+            window[(std::size_t) i] = 0.5f - 0.5f * std::cos (2.0f * juce::MathConstants<float>::pi * (float) i / (float) fftSize);
+        if (const auto* fx = current())
+            for (int b = 0; b < bands; ++b)
+                if (shape (fx->params[(std::size_t) param (b, 0)]) != Shape::off) { selected = b; break; }
+        engine.addChangeListener (this);
+        setWantsKeyboardFocus (true);
+        setSize (960, 560);
+        if (demo)
+        {
+            for (int b = bands; --b >= 0;) // show a dynamic band, if any
+                if (current() != nullptr && isDynamic (current()->params, b)) { selected = b; break; }
+            updateSpectrum();
+        }
+        claimTap();
+        startTimerHz (30);
+    }
+
+    ~FacetEqEditor() override
+    {
+        stopTimer();
+        engine.removeChangeListener (this);
+        if (auto* times = engine.getProcessTimes(); times != nullptr && times->analyzer.key.load() == tapKey())
+            times->analyzer.key.store (-1);
+        // solo is a listening aid: it never stays on once the editor is gone
+        if (const auto* fx = current(); fx != nullptr && soloBand (fx->params[(std::size_t) soloParam]) >= 0)
+            engine.editSong ([tk = track, sl = slot] (Song& song) { song.mixer[(std::size_t) tk].effects[(std::size_t) sl].params[(std::size_t) soloParam] = 0.0f; }, false);
+        ui::hideValueTip();
+    }
+
+    const EffectSlot* current() const
+    {
+        const auto& mixer = engine.getSong().mixer;
+        if (track < 0 || track >= (int) mixer.size() || slot < 0 || slot >= (int) mixer[(std::size_t) track].effects.size())
+            return nullptr;
+        const auto& fx = mixer[(std::size_t) track].effects[(std::size_t) slot];
+        return fx.kind == EffectKind::facetEq ? &fx : nullptr;
+    }
+
+    // --- geometry ------------------------------------------------------------------------------------
+
+    // the whole window is the graph (curves over the analyser); a slim title bar on top, the global bar at the bottom,
+    // and the selected band's controls float over the bottom of the graph
+    juce::Rectangle<float> headerArea() const { return { 0.0f, 0.0f, (float) getWidth(), 30.0f }; }
+    juce::Rectangle<float> barArea() const { return { 0.0f, (float) getHeight() - 30.0f, (float) getWidth(), 30.0f }; }
+    juce::Rectangle<float> graphArea() const { return { 0.0f, 30.0f, (float) getWidth(), barArea().getY() - 30.0f }; }
+    juce::Rectangle<float> plotArea() const { return graphArea().withTrimmedRight (64.0f).withTrimmedBottom (20.0f).withTrimmedTop (6.0f); }
+    juce::Rectangle<float> panelArea() const
+    {
+        const auto w = hasGain (bandShape (selected)) ? 690.0f : 368.0f;
+        constexpr float h = 118.0f;
+        return { juce::jmax (4.0f, plotArea().getCentreX() - w / 2.0f), plotArea().getBottom() - h - 4.0f, w, h };
+    }
+    bool panelShown() const { return bandOn (selected); }
+    // the small read-out box next to a hovered node (frequency, gain, Q, solo, remove)
+    juce::Rectangle<float> tipArea (int b) const
+    {
+        const auto n = nodePosition (b);
+        auto r = juce::Rectangle<float> (n.x - 62.0f, n.y - 74.0f, 124.0f, 58.0f);
+        if (r.getY() < plotArea().getY()) r.setY (n.y + 16.0f);
+        return r.constrainedWithin (plotArea());
+    }
+
+    float xForHz (double f) const
+    {
+        const auto a = plotArea();
+        return a.getX() + a.getWidth() * (float) (std::log (juce::jlimit (minHz, maxHz, f) / minHz) / std::log (maxHz / minHz));
+    }
+    double hzForX (float x) const
+    {
+        const auto a = plotArea();
+        return minHz * std::pow (maxHz / minHz, juce::jlimit (0.0, 1.0, (double) ((x - a.getX()) / a.getWidth())));
+    }
+    float yForDb (double db) const
+    {
+        const auto a = plotArea();
+        return a.getCentreY() - a.getHeight() * 0.5f * (float) (juce::jlimit (-rangeDb * 1.1, rangeDb * 1.1, db) / rangeDb) * 0.92f;
+    }
+    double dbForY (float y) const
+    {
+        const auto a = plotArea();
+        return (double) ((a.getCentreY() - y) / (a.getHeight() * 0.5f * 0.92f)) * rangeDb;
+    }
+    float yForSpectrum (double db) const
+    {
+        const auto a = plotArea();
+        return a.getY() + a.getHeight() * (float) ((specTop - juce::jlimit (specBottom, specTop, db)) / (specTop - specBottom));
+    }
+
+    float param01 (int p) const
+    {
+        const auto* fx = current();
+        return fx != nullptr && p >= 0 && p < maxEffectParams ? fx->params[(std::size_t) p] : 0.0f;
+    }
+
+    Shape bandShape (int b) const { return shape (param01 (param (b, 0))); }
+    bool bandOn (int b) const { return b >= 0 && b < bands && bandShape (b) != Shape::off; }
+
+    // the live dynamic gain of a band (dB), from the audio thread
+    double liveDynamic (int b) const
+    {
+        const auto* times = engine.getProcessTimes();
+        const auto key = (std::size_t) (track * maxEffectSlots + slot) * ProcessTimes::meterOutputs + (std::size_t) b;
+        if (times == nullptr || key >= times->effectMeters.size()) return 0.0;
+        return (double) times->effectMeters[key].load (std::memory_order_relaxed) * 60.0;
+    }
+
+    juce::Point<float> nodePosition (int b) const
+    {
+        const auto f = hz (param01 (param (b, 1)));
+        const auto db = hasGain (bandShape (b)) ? gainDb (param01 (param (b, 2))) * gainScale (param01 (scaleParam)) : 0.0;
+        return { xForHz (f), yForDb (db) };
+    }
+
+    // the range handle of a dynamic band: at static gain + range
+    juce::Point<float> rangeHandle (int b) const
+    {
+        const auto scale = gainScale (param01 (scaleParam));
+        const auto db = (gainDb (param01 (param (b, 2))) + rangeDb_ (b)) * scale;
+        return { nodePosition (b).x, yForDb (db) };
+    }
+
+    double rangeDb_ (int b) const { return facet::rangeDb (param01 (rangeParam0 + b)); }
+
+    int nodeAt (juce::Point<float> p) const
+    {
+        int best = -1;
+        float bestDistance = 11.0f;
+        for (int b = 0; b < bands; ++b)
+            if (bandOn (b))
+                if (const auto d = nodePosition (b).getDistanceFrom (p); d < bestDistance)
+                {
+                    best = b;
+                    bestDistance = d;
+                }
+        return best;
+    }
+
+    int rangeHandleAt (juce::Point<float> p) const
+    {
+        for (int b = 0; b < bands; ++b)
+            if (bandOn (b) && hasGain (bandShape (b)) && b == selected && rangeHandle (b).getDistanceFrom (p) < 8.0f)
+                return b;
+        return -1;
+    }
+
+    // --- controls of the bottom strip and the header -------------------------------------------------
+
+    enum class Ctl { none, shapeMenu, freq, gain, q, slopeMenu, range, threshold, solo, dynamic, remove, attack, release,
+                     phase, analyzer, detector, output, scale, scaleDb, prevBand, nextBand, close, piano, tipSolo, tipRemove };
+    struct Control { Ctl type; juce::Rectangle<float> r; int param = -1; int index = 0; };
+
+    std::vector<Control> controls() const
+    {
+        std::vector<Control> out;
+        // the bottom bar: piano / frequency scale, processing mode, analyser, detector … gain scale and output on the right
+        const auto bar = barArea();
+        const auto cy = bar.getCentreY();
+        out.push_back ({ Ctl::piano, { 8.0f, cy - 10.0f, 26.0f, 20.0f } });
+        out.push_back ({ Ctl::phase, { 44.0f, cy - 11.0f, 150.0f, 22.0f }, phaseParam });
+        out.push_back ({ Ctl::analyzer, { 202.0f, cy - 11.0f, 170.0f, 22.0f }, analyzerParam });
+        out.push_back ({ Ctl::detector, { 380.0f, cy - 11.0f, 150.0f, 22.0f }, detectorParam });
+        out.push_back ({ Ctl::output, { bar.getRight() - 100.0f, cy - 11.0f, 92.0f, 22.0f }, outputParam });
+        out.push_back ({ Ctl::scale, { bar.getRight() - 190.0f, cy - 11.0f, 84.0f, 22.0f }, scaleParam });
+        // the graph's dB range (top right: ±3 / 6 / 12 / 30)
+        const auto plot = plotArea();
+        out.push_back ({ Ctl::scaleDb, { plot.getRight() + 6.0f, plot.getY() + 2.0f, 50.0f, 18.0f } });
+
+        // the hovered node's read-out: solo and remove
+        if (tipBand >= 0 && bandOn (tipBand) && dragging == Drag::none)
+        {
+            const auto t = tipArea (tipBand);
+            out.push_back ({ Ctl::tipSolo, { t.getRight() - 42.0f, t.getY() + 4.0f, 18.0f, 18.0f }, -1, tipBand });
+            out.push_back ({ Ctl::tipRemove, { t.getRight() - 22.0f, t.getY() + 4.0f, 18.0f, 18.0f }, -1, tipBand });
+        }
+
+        // the floating band panel: shape | FREQ | GAIN | dynamics | Q | band navigation, solo, remove
+        if (panelShown())
+        {
+            const auto p = panelArea();
+            const auto b = selected;
+            const auto sh = bandShape (b);
+            const auto y = p.getY();
+            auto x = p.getX();
+            out.push_back ({ Ctl::shapeMenu, { x + 12.0f, y + 30.0f, 108.0f, 26.0f }, param (b, 0) });
+            if (sh == Shape::lowCut || sh == Shape::highCut || sh == Shape::lowShelf || sh == Shape::highShelf || sh == Shape::tiltShelf)
+                out.push_back ({ Ctl::slopeMenu, { x + 12.0f, y + 62.0f, 108.0f, 22.0f }, param (b, 4) });
+            x += 126.0f;
+            out.push_back ({ Ctl::freq, { x, y + 8.0f, 70.0f, 104.0f }, param (b, 1) });
+            x += 72.0f;
+            if (hasGain (sh))
+            {
+                out.push_back ({ Ctl::gain, { x, y + 2.0f, 96.0f, 112.0f }, param (b, 2) });
+                x += 104.0f;
+                out.push_back ({ Ctl::dynamic, { x + 4.0f, y + 8.0f, 86.0f, 20.0f }, rangeParam0 + b });
+                if (isDynamic (current()->params, b))
+                {
+                    out.push_back ({ Ctl::range, { x - 2.0f, y + 34.0f, 56.0f, 80.0f }, rangeParam0 + b });
+                    out.push_back ({ Ctl::threshold, { x + 54.0f, y + 34.0f, 56.0f, 80.0f }, thresholdParam0 + b });
+                    out.push_back ({ Ctl::attack, { x + 110.0f, y + 34.0f, 52.0f, 80.0f }, attackParam });
+                    out.push_back ({ Ctl::release, { x + 162.0f, y + 34.0f, 52.0f, 80.0f }, releaseParam });
+                }
+                x += 218.0f;
+            }
+            out.push_back ({ Ctl::q, { x, y + 8.0f, 70.0f, 104.0f }, param (b, 3) });
+            x += 78.0f;
+            out.push_back ({ Ctl::prevBand, { x + 2.0f, y + 6.0f, 20.0f, 20.0f } });
+            out.push_back ({ Ctl::nextBand, { x + 44.0f, y + 6.0f, 20.0f, 20.0f } });
+            out.push_back ({ Ctl::close, { x + 66.0f, y + 6.0f, 20.0f, 20.0f } });
+            out.push_back ({ Ctl::solo, { x + 4.0f, y + 44.0f, 80.0f, 24.0f }, soloParam });
+            out.push_back ({ Ctl::remove, { x + 4.0f, y + 76.0f, 80.0f, 24.0f } });
+        }
+        return out;
+    }
+
+    const Control* controlAt (juce::Point<float> p, std::vector<Control>& all) const
+    {
+        all = controls();
+        for (const auto& c : all)
+            if (c.r.contains (p)) return &c;
+        return nullptr;
+    }
+
+    juce::Rectangle<float> knobCircle (const Control& c) const
+    {
+        const auto d = juce::jmin (c.r.getWidth() - 12.0f, c.r.getHeight() - 44.0f);
+        return { c.r.getCentreX() - d / 2.0f, c.r.getY() + 4.0f, d, d };
+    }
+
+    juce::String trackName() const
+    {
+        const auto& mixer = engine.getSong().mixer;
+        if (track == 0) return tr ("Master");
+        const auto name = track < (int) mixer.size() ? juce::String::fromUTF8 (mixer[(std::size_t) track].name.c_str()) : juce::String();
+        return name.isNotEmpty() ? name : tr ("Insert {0}", { juce::String (track) });
+    }
+
+    ui::ValueSpec specFor (int prm) const
+    {
+        ui::ValueSpec spec;
+        const auto& in = info();
+        if (prm < 0 || prm >= (int) in.params.size()) return spec;
+        spec.name = trackName() + " - Facet EQ - " + utf8 (in.params[(std::size_t) prm].name);
+        spec.defaultValue = in.params[(std::size_t) prm].defaultValue;
+        spec.pixelsForRange = 200.0;
+        spec.toText = [prm] (double v) { return utf8 (paramText (prm, (float) v).c_str()); };
+        spec.fromText = ui::inverseOf (spec.toText, 0.0, 1.0);
+        spec.target = AutomationTarget { AutomationTargetKind::effectParam, track, slot, prm };
+        return spec;
+    }
+
+    juce::String valueText (int prm) const { return utf8 (paramText (prm, param01 (prm)).c_str()); }
+
+    // --- editing -------------------------------------------------------------------------------------
+
+    void set (std::vector<std::pair<int, float>> changes, bool undoable = true)
+    {
+        if (current() == nullptr) return;
+        engine.editSong ([tk = track, sl = slot, changes] (Song& song) {
+            auto& params = song.mixer[(std::size_t) tk].effects[(std::size_t) sl].params;
+            for (const auto& [p, v] : changes)
+                if (p >= 0 && p < maxEffectParams) params[(std::size_t) p] = juce::jlimit (0.0f, 1.0f, v);
+        }, undoable);
+    }
+
+    void addBand (juce::Point<float> at)
+    {
+        for (int b = 0; b < bands; ++b)
+            if (! bandOn (b))
+            {
+                const auto f = hzForX (at.x);
+                // the ends of the spectrum get cuts, as a quick start; anything else is a bell at the clicked gain
+                const auto sh = f < 25.0 ? Shape::lowCut : f > 18000.0 ? Shape::highCut : Shape::bell;
+                const auto scale = juce::jmax (0.01, gainScale (param01 (scaleParam)));
+                set ({ { param (b, 0), shapeValue (sh) }, { param (b, 1), hzValue (f) }, { param (b, 2), sh == Shape::bell ? gainValue (dbForY (at.y) / scale) : 0.5f },
+                       { param (b, 3), qValue (1.0) }, { param (b, 4), slopeValue (sh == Shape::bell ? 12 : 24) }, { rangeParam0 + b, 0.5f } });
+                selected = b;
+                return;
+            }
+    }
+
+    void removeBand (int b)
+    {
+        std::vector<std::pair<int, float>> c { { param (b, 0), 0.0f }, { rangeParam0 + b, 0.5f } };
+        if (soloBand (param01 (soloParam)) == b) c.push_back ({ soloParam, 0.0f });
+        set (c);
+        if (selected == b)
+        {
+            selected = -1;
+            for (int k = 0; k < bands; ++k)
+                if (k != b && bandOn (k)) { selected = k; break; }
+        }
+    }
+
+    void toggleSolo (int b)
+    {
+        set ({ { soloParam, soloBand (param01 (soloParam)) == b ? 0.0f : soloValue (b) } }, false);
+    }
+
+    void showBandMenu (int b)
+    {
+        juce::PopupMenu menu;
+        menu.addSectionHeader (tr ("Band {0}", { juce::String (b + 1) }));
+        const auto sh = bandShape (b);
+        for (int k = 1; k < shapeCount; ++k)
+            menu.addItem (tr (shapeNames[k]), true, (int) sh == k, [this, b, k] { set ({ { param (b, 0), shapeValue ((Shape) k) } }); });
+        if (sh == Shape::lowCut || sh == Shape::highCut || sh == Shape::lowShelf || sh == Shape::highShelf || sh == Shape::tiltShelf)
+        {
+            juce::PopupMenu slopes;
+            for (const auto d : facet::slopes)
+                slopes.addItem (juce::String (d) + " dB/oct", true, slopeDb (param01 (param (b, 4))) == d, [this, b, d] { set ({ { param (b, 4), slopeValue (d) } }); });
+            menu.addSubMenu (tr ("Slope"), slopes);
+        }
+        if (hasGain (sh))
+        {
+            juce::PopupMenu dyn;
+            for (const auto r : { 0.0, -3.0, -6.0, -12.0, 3.0, 6.0 })
+                dyn.addItem (r == 0.0 ? tr ("Off") : juce::String (r > 0 ? "+" : "") + juce::String ((int) r) + " dB", true, std::abs (rangeDb_ (b) - r) < 0.05,
+                             [this, b, r] { set ({ { rangeParam0 + b, rangeValue (r) } }); });
+            menu.addSubMenu (tr ("Dynamic range"), dyn);
+        }
+        menu.addSeparator();
+        menu.addItem (tr ("Solo band"), true, soloBand (param01 (soloParam)) == b, [this, b] { toggleSolo (b); });
+        menu.addItem (tr ("Reset gain"), hasGain (sh), false, [this, b] { set ({ { param (b, 2), 0.5f } }); });
+        menu.addItem (tr ("Remove band"), [this, b] { removeBand (b); });
+        menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
+    }
+
+    void showDetectorMenu()
+    {
+        juce::PopupMenu menu;
+        const auto* fx = current();
+        if (fx == nullptr) return;
+        const auto side = sidechainDetector (param01 (detectorParam));
+        menu.addItem (tr ("Detect the EQ's input"), true, ! side, [this] { set ({ { detectorParam, 0.0f } }); });
+        menu.addItem (tr ("Detect the sidechain"), true, side, [this] { set ({ { detectorParam, 1.0f } }); });
+        juce::PopupMenu from;
+        const auto assign = [this] (int source) {
+            engine.editSong ([tk = track, sl = slot, source] (Song& s) {
+                auto& target = s.mixer[(std::size_t) tk].effects[(std::size_t) sl];
+                target.sidechain = source;
+                if (source >= 0) target.params[(std::size_t) detectorParam] = 1.0f;
+            });
+        };
+        from.addItem (tr ("None"), true, fx->sidechain < 0, [assign] { assign (-1); });
+        const auto& song = engine.getSong();
+        for (int t = 1; t < (int) song.mixer.size(); ++t)
+            if (t != track)
+                from.addItem (juce::String (t) + " " + juce::String::fromUTF8 (song.mixer[(std::size_t) t].name.c_str()), true, fx->sidechain == t, [assign, t] { assign (t); });
+        menu.addSubMenu (tr ("Sidechain from"), from);
+        menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
+    }
+
+    void showAnalyzerMenu()
+    {
+        juce::PopupMenu menu;
+        const auto a = (int) analyzer (param01 (analyzerParam));
+        for (int k = 0; k < 4; ++k)
+            menu.addItem (tr (analyzerNames[k]), true, a == k, [this, k] { set ({ { analyzerParam, analyzerValue ((Analyzer) k) } }, false); });
+        menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
+    }
+
+    void showShapeMenu (int b)
+    {
+        juce::PopupMenu menu;
+        const auto sh = bandShape (b);
+        for (int k = 1; k < shapeCount; ++k)
+            menu.addItem (tr (shapeNames[k]), true, (int) sh == k, [this, b, k] { set ({ { param (b, 0), shapeValue ((Shape) k) } }); });
+        menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
+    }
+
+    void showSlopeMenu (int b)
+    {
+        juce::PopupMenu menu;
+        for (const auto d : facet::slopes)
+            menu.addItem (juce::String (d) + " dB/oct", true, slopeDb (param01 (param (b, 4))) == d, [this, b, d] { set ({ { param (b, 4), slopeValue (d) } }); });
+        menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
+    }
+
+    // --- mouse ---------------------------------------------------------------------------------------
+
+    void showPhaseMenu()
+    {
+        juce::PopupMenu menu;
+        const auto m = (int) phase (param01 (phaseParam));
+        for (int k = 0; k < phaseCount; ++k)
+            menu.addItem (tr (phaseNames[k]) + (k == 0 ? juce::String() : "  (" + tr ("latency {0} samples", { juce::String (latencyFor ((Phase) k, displayRate())) }) + ")"),
+                          true, m == k, [this, k] { set ({ { phaseParam, phaseValue ((Phase) k) } }); });
+        menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
+    }
+
+    // right-click on the graph away from the nodes: every band at once
+    void showGraphMenu()
+    {
+        juce::PopupMenu menu;
+        menu.addItem (tr ("Invert all gains"), [this] {
+            std::vector<std::pair<int, float>> c;
+            for (int b = 0; b < bands; ++b)
+                if (bandOn (b)) c.push_back ({ param (b, 2), 1.0f - param01 (param (b, 2)) });
+            set (c);
+        });
+        menu.addItem (tr ("Remove all bands"), [this] {
+            std::vector<std::pair<int, float>> c { { soloParam, 0.0f } };
+            for (int b = 0; b < bands; ++b) { c.push_back ({ param (b, 0), 0.0f }); c.push_back ({ rangeParam0 + b, 0.5f }); }
+            set (c);
+            selected = -1;
+        });
+        menu.showMenuAsync (juce::PopupMenu::Options().withTargetComponent (this).withMousePosition());
+    }
+
+    void stepBand (int dir)
+    {
+        for (int k = 1; k <= bands; ++k)
+        {
+            const auto b = ((selected < 0 ? 0 : selected) + dir * k + bands * 2) % bands;
+            if (bandOn (b)) { selected = b; repaint(); return; }
+        }
+    }
+
+    void mouseDown (const juce::MouseEvent& e) override
+    {
+        const auto p = e.position;
+        dragging = Drag::none;
+        std::vector<Control> all;
+        if (const auto* c = controlAt (p, all))
+        {
+            const auto type = c->type;
+            const auto prm = c->param;
+            const auto index = c->index;
+            if (e.mods.isPopupMenu())
+            {
+                if (type == Ctl::analyzer) { showAnalyzerMenu(); return; }
+                if (type == Ctl::detector) { showDetectorMenu(); return; }
+                if (type == Ctl::phase) { showPhaseMenu(); return; }
+                if (prm >= 0 && type != Ctl::solo && type != Ctl::dynamic && type != Ctl::shapeMenu && type != Ctl::slopeMenu)
+                    ui::showValueMenu (*this, &engine, specFor (prm), param01 (prm), [this, prm] (double v) { set ({ { prm, (float) v } }); });
+                return;
+            }
+            switch (type)
+            {
+                case Ctl::shapeMenu: showShapeMenu (selected); return;
+                case Ctl::slopeMenu: showSlopeMenu (selected); return;
+                case Ctl::remove: removeBand (selected); return;
+                case Ctl::solo: toggleSolo (selected); return;
+                case Ctl::tipSolo: toggleSolo (index); return;
+                case Ctl::tipRemove: removeBand (index); tipBand = -1; return;
+                case Ctl::prevBand: stepBand (-1); return;
+                case Ctl::nextBand: stepBand (1); return;
+                case Ctl::close: selected = -1; repaint(); return;
+                case Ctl::piano: piano = ! piano; repaint(); return;
+                case Ctl::dynamic: set ({ { prm, isDynamic (current()->params, selected) ? 0.5f : rangeValue (-6.0) } }); return;
+                case Ctl::phase: showPhaseMenu(); return;
+                case Ctl::analyzer: showAnalyzerMenu(); return;
+                case Ctl::detector: showDetectorMenu(); return;
+                case Ctl::scaleDb:
+                    rangeDb = rangeDb >= 30.0 ? 3.0 : rangeDb >= 12.0 ? 30.0 : rangeDb >= 6.0 ? 12.0 : 6.0;
+                    repaint();
+                    return;
+                default: break;
+            }
+            if (prm >= 0)
+            {
+                if (ui::isResetClick (e))
+                {
+                    set ({ { prm, (float) specFor (prm).defaultValue } });
+                    return;
+                }
+                dragging = Drag::control;
+                dragParam = prm;
+                dragRect = c->r;
+                valueDrag.begin (e, param01 (prm));
+            }
+            return;
+        }
+
+        if (panelShown() && panelArea().contains (p)) return; // the panel's background
+        if (! plotArea().contains (p)) return;
+        if (const auto rb = rangeHandleAt (p); rb >= 0 && ! e.mods.isPopupMenu())
+        {
+            dragging = Drag::range;
+            dragBand = rb;
+            return;
+        }
+        const auto b = nodeAt (p);
+        if (b >= 0)
+        {
+            selected = b;
+            if (e.mods.isPopupMenu()) { showBandMenu (b); return; }
+            if (e.mods.isAltDown()) { removeBand (b); return; } // Alt-click deletes, as in the common EQs
+            if (e.mods.isMiddleButtonDown()) { set ({ { param (b, 2), 0.5f } }); return; }
+            dragging = Drag::node;
+            dragBand = b;
+            dragOffset = nodePosition (b) - p;
+            dragStart = p;
+            repaint();
+            return;
+        }
+        if (e.mods.isPopupMenu()) { showGraphMenu(); return; }
+        selected = -1; // a click on the empty graph closes the band panel
+        repaint();
+    }
+
+    void mouseDrag (const juce::MouseEvent& e) override
+    {
+        if (dragging == Drag::control && dragParam >= 0)
+        {
+            const auto spec = specFor (dragParam);
+            const auto v = valueDrag.update (e, spec);
+            set ({ { dragParam, (float) v } });
+            ui::showValueTip (*this, dragRect.toNearestInt(), spec.text (v));
+            return;
+        }
+        if (dragging == Drag::node && bandOn (dragBand))
+        {
+            auto p = e.position + dragOffset;
+            const auto b = dragBand;
+            std::vector<std::pair<int, float>> c;
+            const auto fine = e.mods.isCtrlDown() || e.mods.isCommandDown();
+            if (fine) // fine: a quarter of the mouse movement
+                p = nodePosition (b) + (p - nodePosition (b)) * 0.25f;
+            const auto d = e.position - dragStart;
+            const auto lockX = e.mods.isShiftDown() && std::abs (d.y) > std::abs (d.x); // Shift: only the main direction
+            const auto lockY = e.mods.isShiftDown() && ! lockX;
+            if (! lockX) c.push_back ({ param (b, 1), hzValue (hzForX (p.x)) });
+            if (hasGain (bandShape (b)) && ! lockY)
+            {
+                const auto scale = juce::jmax (0.01, gainScale (param01 (scaleParam)));
+                c.push_back ({ param (b, 2), gainValue (juce::jlimit (-30.0, 30.0, dbForY (p.y) / scale)) });
+            }
+            set (c);
+            ui::showValueTip (*this, juce::Rectangle<int> (16, 16).withCentre (nodePosition (b).toInt()), bandSummary (b));
+            return;
+        }
+        if (dragging == Drag::range && bandOn (dragBand))
+        {
+            const auto b = dragBand;
+            const auto scale = juce::jmax (0.01, gainScale (param01 (scaleParam)));
+            const auto r = dbForY (e.position.y) / scale - gainDb (param01 (param (b, 2)));
+            set ({ { rangeParam0 + b, rangeValue (juce::jlimit (-30.0, 30.0, r)) } });
+            ui::showValueTip (*this, juce::Rectangle<int> (16, 16).withCentre (rangeHandle (b).toInt()), tr ("Range") + " " + valueText (rangeParam0 + b));
+        }
+    }
+
+    void mouseUp (const juce::MouseEvent&) override
+    {
+        dragging = Drag::none;
+        valueDrag.end();
+        ui::hideValueTip();
+    }
+
+    void mouseDoubleClick (const juce::MouseEvent& e) override
+    {
+        if (! plotArea().contains (e.position)) return;
+        if (const auto b = nodeAt (e.position); b >= 0) removeBand (b);
+        else addBand (e.position);
+    }
+
+    void mouseWheelMove (const juce::MouseEvent& e, const juce::MouseWheelDetails& wheel) override
+    {
+        std::vector<Control> all;
+        if (const auto* c = controlAt (e.position, all); c != nullptr && c->param >= 0 && c->type != Ctl::phase)
+        {
+            const auto prm = c->param;
+            const auto spec = specFor (prm);
+            if (const auto v = ui::wheelValue (param01 (prm), e, wheel, spec))
+            {
+                set ({ { prm, (float) *v } });
+                ui::flashValueTip (*this, c->r.toNearestInt(), spec.text (*v));
+            }
+            return;
+        }
+        // over the graph: the Q of the band under the mouse (or the selected one)
+        if (! plotArea().contains (e.position)) return;
+        auto b = nodeAt (e.position);
+        if (b < 0) b = selected;
+        if (! bandOn (b) || wheel.deltaY == 0.0f) return;
+        const auto step = (e.mods.isCtrlDown() ? 0.04 : 0.15) * (wheel.deltaY > 0 ? 1.0 : -1.0);
+        const auto q0 = q (param01 (param (b, 3)));
+        set ({ { param (b, 3), qValue (juce::jlimit (0.025, 40.0, q0 * std::exp (step * 2.0))) } });
+        ui::flashValueTip (*this, juce::Rectangle<int> (16, 16).withCentre (nodePosition (b).toInt()), "Q " + valueText (param (b, 3)));
+    }
+
+    void mouseMove (const juce::MouseEvent& e) override
+    {
+        mouse = e.position;
+        const auto h = nodeAt (e.position);
+        if (h != hover) hover = h;
+        // the read-out box stays while the mouse is on its node or inside the box (to reach solo / remove)
+        if (h >= 0) tipBand = h;
+        else if (tipBand >= 0 && ! (bandOn (tipBand) && tipArea (tipBand).expanded (4.0f).contains (e.position))) tipBand = -1;
+        repaint();
+    }
+
+    void mouseExit (const juce::MouseEvent&) override
+    {
+        mouse = { -1.0f, -1.0f };
+        hover = -1;
+        tipBand = -1;
+        repaint();
+    }
+
+    bool keyPressed (const juce::KeyPress& key) override
+    {
+        if ((key == juce::KeyPress::deleteKey || key == juce::KeyPress::backspaceKey) && bandOn (selected))
+        {
+            removeBand (selected);
+            return true;
+        }
+        if (key.getTextCharacter() == 's' && bandOn (selected))
+        {
+            toggleSolo (selected);
+            return true;
+        }
+        return false;
+    }
+
+    juce::String bandSummary (int b) const
+    {
+        juce::String t = tr (shapeNames[(int) bandShape (b)]) + "  " + hzText (hz (param01 (param (b, 1))));
+        if (hasGain (bandShape (b))) t << "  " << valueText (param (b, 2));
+        t << "  Q " << valueText (param (b, 3));
+        return t;
+    }
+
+    ui::Hint hintAt (juce::Point<int> position) override
+    {
+        ui::Hint h;
+        const auto p = position.toFloat();
+        std::vector<Control> all;
+        if (const auto* c = controlAt (p, all))
+        {
+            switch (c->type)
+            {
+                case Ctl::phase: h.text = tr ("Processing: zero latency (minimum phase), natural phase (the analog curve's phase) or linear phase (no phase shift); the latency is reported to PDC"); h.hasMenu = true; return h;
+                case Ctl::analyzer: h.text = tr ("Spectrum analyzer: off, pre, post or pre + post"); h.hasMenu = true; return h;
+                case Ctl::piano: h.text = tr ("Frequency scale: numbers or a piano keyboard"); return h;
+                case Ctl::prevBand: case Ctl::nextBand: h.text = tr ("Previous / next band"); return h;
+                case Ctl::close: h.text = tr ("Close the band panel (click on the empty graph does the same)"); return h;
+                case Ctl::tipSolo: h.text = tr ("Solo: hear only this band's region (S)"); return h;
+                case Ctl::tipRemove: h.text = tr ("Remove the band (Delete)"); return h;
+                case Ctl::detector: h.text = tr ("What the dynamic bands listen to: the EQ's input or a sidechain track"); h.hasMenu = true; return h;
+                case Ctl::scaleDb: h.text = tr ("Graph scale: click to switch between 3, 6, 12 and 30 dB"); return h;
+                case Ctl::remove: h.text = tr ("Remove the band (Delete)"); return h;
+                case Ctl::solo: h.text = tr ("Solo: hear only this band's region (S)"); return h;
+                case Ctl::dynamic: h.text = tr ("Dynamic EQ: the band's gain moves by up to its range when its region goes over the threshold"); return h;
+                case Ctl::shapeMenu: h.text = tr ("Band shape"); h.hasMenu = true; return h;
+                case Ctl::slopeMenu: h.text = tr ("Slope"); h.hasMenu = true; return h;
+                default: break;
+            }
+            if (c->param >= 0)
+                return ui::valueHint (specFor (c->param), param01 (c->param));
+            return h;
+        }
+        if (plotArea().contains (p))
+        {
+            if (const auto b = nodeAt (p); b >= 0)
+                h.text = tr ("Band {0}", { juce::String (b + 1) }) + ": " + bandSummary (b) + " - "
+                         + tr ("drag = frequency and gain (Ctrl fine, Shift one direction only); wheel = Q; Alt-click or double-click = remove; right-click = menu");
+            else if (rangeHandleAt (p) >= 0)
+                h.text = tr ("Dynamic range: drag up or down");
+            else
+                h.text = tr ("Double-click to add a band; mouse wheel = Q of the selected band");
+            h.hasMenu = true;
+        }
+        return h;
+    }
+
+    // --- painting ------------------------------------------------------------------------------------
+
+    void paint (juce::Graphics& g) override
+    {
+        using namespace theme;
+        g.fillAll (colour::bg0);
+        const auto* fx = current();
+        if (fx == nullptr)
+        {
+            g.setColour (colour::textSecondary);
+            g.setFont (font (type::body));
+            g.drawText (tr ("The effect was removed from this slot."), getLocalBounds(), juce::Justification::centred);
+            return;
+        }
+        auto all = controls();
+        paintGraph (g, *fx);
+        paintHeader (g, *fx);
+        paintBar (g, *fx, all);
+        if (panelShown()) paintPanel (g, *fx, all);
+        if (tipBand >= 0 && bandOn (tipBand) && dragging == Drag::none) paintTip (g, *fx, tipBand);
+    }
+
+    void paintHeader (juce::Graphics& g, const EffectSlot& fx)
+    {
+        using namespace theme;
+        const auto h = headerArea();
+        g.setColour (colour::bg2);
+        g.fillRect (h);
+        g.setColour (colour::border);
+        g.drawHorizontalLine ((int) h.getBottom() - 1, 0.0f, h.getRight());
+        g.setColour (fx.enabled ? colour::ledOn : colour::ledOff);
+        g.fillEllipse (juce::Rectangle<float> (8.0f, 8.0f).withCentre ({ 14.0f, h.getCentreY() }));
+        g.setColour (colour::textPrimary);
+        g.setFont (font (type::title, true));
+        g.drawText ("Facet EQ", juce::Rectangle<float> (26.0f, 0.0f, 90.0f, h.getHeight()), juce::Justification::centredLeft);
+        g.setColour (colour::accent);
+        g.fillRect (juce::Rectangle<float> (26.0f, h.getBottom() - 3.0f, 72.0f, 2.0f));
+        g.setColour (colour::textSecondary);
+        g.setFont (font (type::small));
+        g.drawText (trackName() + "  -  " + tr ("slot {0}", { juce::String (slot + 1) }), juce::Rectangle<float> (120.0f, 0.0f, 300.0f, h.getHeight()),
+                    juce::Justification::centredLeft, true);
+        // the hint for the graph's gestures, on the right of the title bar
+        g.setColour (colour::textDisabled);
+        g.setFont (font (type::caption));
+        g.drawText (tr ("Double-click: new band  -  drag: frequency / gain  -  wheel: Q  -  right-click: menu"),
+                    h.withTrimmedLeft (420.0f).withTrimmedRight (12.0f), juce::Justification::centredRight, true);
+    }
+
+    void paintBar (juce::Graphics& g, const EffectSlot& fx, const std::vector<Control>& all)
+    {
+        using namespace theme;
+        const auto bar = barArea();
+        g.setColour (colour::bg2);
+        g.fillRect (bar);
+        g.setColour (colour::border);
+        g.drawHorizontalLine ((int) bar.getY(), 0.0f, bar.getRight());
+        for (const auto& c : all)
+        {
+            const auto hover = c.r.contains (mouse);
+            if (c.type == Ctl::piano)
+            {
+                g.setColour (piano ? colour::accent : (hover ? colour::textPrimary : colour::textSecondary));
+                const auto k = c.r.reduced (4.0f, 4.0f);
+                for (int i = 0; i < 4; ++i)
+                    g.drawRect (juce::Rectangle<float> (k.getX() + k.getWidth() * (float) i / 4.0f, k.getY(), k.getWidth() / 4.0f, k.getHeight()), 1.0f);
+                for (int i = 1; i < 4; ++i)
+                    g.fillRect (juce::Rectangle<float> (k.getX() + k.getWidth() * (float) i / 4.0f - 1.5f, k.getY(), 3.0f, k.getHeight() * 0.55f));
+            }
+            else if (c.type == Ctl::phase || c.type == Ctl::analyzer || c.type == Ctl::detector)
+            {
+                juce::String caption, value;
+                if (c.type == Ctl::phase) { caption = tr ("Processing:"); value = tr (phaseNames[(int) phase (param01 (phaseParam))]); }
+                else if (c.type == Ctl::analyzer) { caption = tr ("Analyzer:"); value = tr (analyzerShort[(int) analyzer (param01 (analyzerParam))]); }
+                else
+                {
+                    caption = tr ("Detector:");
+                    const auto side = sidechainDetector (param01 (detectorParam));
+                    value = side ? tr ("Sidechain") : tr ("Input");
+                    if (side && fx.sidechain > 0 && fx.sidechain < (int) engine.getSong().mixer.size()) value << " " << juce::String (fx.sidechain);
+                }
+                if (hover)
+                {
+                    g.setColour (colour::bg4);
+                    g.fillRoundedRectangle (c.r, radius::md);
+                }
+                g.setFont (font (type::small));
+                g.setColour (colour::textDisabled);
+                const auto cw = juce::GlyphArrangement::getStringWidth (g.getCurrentFont(), caption) + 6.0f;
+                g.drawText (caption, c.r.withWidth (cw).translated (6.0f, 0.0f), juce::Justification::centredLeft);
+                g.setColour (colour::textPrimary);
+                g.drawText (value + juce::String::fromUTF8 (" \xe2\x96\xbe"), c.r.withTrimmedLeft (cw + 6.0f), juce::Justification::centredLeft, true);
+            }
+            else if (c.type == Ctl::output || c.type == Ctl::scale)
+            {
+                g.setColour (hover ? colour::bg4 : colour::bg1);
+                g.fillRoundedRectangle (c.r, radius::md);
+                g.setColour (colour::textDisabled);
+                g.setFont (font (type::caption));
+                g.drawText (c.type == Ctl::output ? tr ("OUT") : tr ("SCALE"), c.r.reduced (6.0f, 0.0f), juce::Justification::centredLeft);
+                g.setColour (colour::textPrimary);
+                g.setFont (font (type::small, true));
+                g.drawText (valueText (c.param), c.r.reduced (6.0f, 0.0f), juce::Justification::centredRight);
+            }
+        }
+        // latency of the processing mode (PDC compensates it)
+        const auto lat = latencyFor (phase (param01 (phaseParam)), displayRate());
+        if (lat > 0)
+        {
+            g.setColour (colour::textDisabled);
+            g.setFont (font (type::caption));
+            g.drawText (tr ("latency {0} samples", { juce::String (lat) }), juce::Rectangle<float> (540.0f, bar.getY(), 160.0f, bar.getHeight()),
+                        juce::Justification::centredLeft, true);
+        }
+    }
+
+    // the read-out box of a hovered node
+    void paintTip (juce::Graphics& g, const EffectSlot& fx, int b)
+    {
+        using namespace theme;
+        const auto r = tipArea (b);
+        g.setColour (colour::bg3.withAlpha (0.94f));
+        g.fillRoundedRectangle (r, radius::lg);
+        g.setColour (bandColour (b).withAlpha (0.8f));
+        g.drawRoundedRectangle (r.reduced (0.5f), radius::lg, 1.0f);
+        g.setFont (font (type::small, true));
+        g.setColour (colour::textPrimary);
+        auto t = r.reduced (8.0f, 4.0f);
+        g.drawText (hzText (hz (param01 (param (b, 1)))), t.removeFromTop (17.0f).withTrimmedRight (40.0f), juce::Justification::centredLeft);
+        g.setFont (font (type::small));
+        g.drawText (hasGain (bandShape (b)) ? valueText (param (b, 2)) : tr (shapeNames[(int) bandShape (b)]), t.removeFromTop (16.0f), juce::Justification::centredLeft);
+        g.setColour (colour::textSecondary);
+        g.drawText ("Q " + valueText (param (b, 3)), t.removeFromTop (16.0f), juce::Justification::centredLeft);
+        // solo (headphones) and remove (×)
+        const auto solo = juce::Rectangle<float> (r.getRight() - 42.0f, r.getY() + 4.0f, 18.0f, 18.0f);
+        const auto rm = juce::Rectangle<float> (r.getRight() - 22.0f, r.getY() + 4.0f, 18.0f, 18.0f);
+        const auto soloOn = soloBand (fx.params[(std::size_t) soloParam]) == b;
+        g.setColour (soloOn ? colour::warning : (solo.contains (mouse) ? colour::textPrimary : colour::textSecondary));
+        juce::Path phones;
+        const auto pc = solo.reduced (3.0f);
+        phones.addCentredArc (pc.getCentreX(), pc.getCentreY() + 1.0f, pc.getWidth() * 0.45f, pc.getHeight() * 0.45f, 0.0f,
+                              -juce::MathConstants<float>::halfPi, juce::MathConstants<float>::halfPi, true);
+        g.strokePath (phones, juce::PathStrokeType (1.5f));
+        g.fillRoundedRectangle (juce::Rectangle<float> (pc.getX() - 0.5f, pc.getCentreY(), 3.5f, 6.0f), 1.0f);
+        g.fillRoundedRectangle (juce::Rectangle<float> (pc.getRight() - 3.0f, pc.getCentreY(), 3.5f, 6.0f), 1.0f);
+        g.setColour (rm.contains (mouse) ? colour::accent : colour::textSecondary);
+        g.drawLine (rm.getX() + 5.0f, rm.getY() + 5.0f, rm.getRight() - 5.0f, rm.getBottom() - 5.0f, 1.5f);
+        g.drawLine (rm.getRight() - 5.0f, rm.getY() + 5.0f, rm.getX() + 5.0f, rm.getBottom() - 5.0f, 1.5f);
+    }
+
+    double displayRate() const
+    {
+        const auto* times = engine.getProcessTimes();
+        const auto sr = times != nullptr ? times->analyzer.sampleRate.load (std::memory_order_relaxed) : 48000.0;
+        return sr > 8000.0 ? sr : 48000.0;
+    }
+
+    void paintGraph (juce::Graphics& g, const EffectSlot& fx)
+    {
+        using namespace theme;
+        const auto area = graphArea();
+        const auto plot = plotArea();
+        g.setGradientFill (juce::ColourGradient (colour::bg1, 0.0f, area.getY(), colour::bg0, 0.0f, area.getBottom(), false));
+        g.fillRect (area);
+
+        // grid: frequencies (numbers or a piano keyboard along the bottom)
+        g.setFont (font (type::caption));
+        for (double f : { 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 200.0, 300.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0, 1000.0, 2000.0,
+                          3000.0, 4000.0, 5000.0, 6000.0, 7000.0, 8000.0, 9000.0, 10000.0, 20000.0 })
+        {
+            const auto major = f == 20.0 || f == 50.0 || f == 100.0 || f == 200.0 || f == 500.0 || f == 1000.0 || f == 2000.0 || f == 5000.0 || f == 10000.0 || f == 20000.0;
+            const auto x = xForHz (f);
+            g.setColour (major ? colour::gridBeat.brighter (0.15f) : colour::gridStep);
+            g.drawVerticalLine ((int) x, plot.getY(), plot.getBottom());
+            if (major && ! piano)
+            {
+                g.setColour (colour::textDisabled);
+                g.drawText (f >= 1000.0 ? juce::String ((int) (f / 1000.0)) + "k" : juce::String ((int) f),
+                            juce::Rectangle<float> (x - 20.0f, plot.getBottom() + 3.0f, 40.0f, 14.0f), juce::Justification::centred);
+            }
+        }
+        if (piano) // one key per semitone; C labelled
+        {
+            const auto strip = juce::Rectangle<float> (plot.getX(), plot.getBottom() + 2.0f, plot.getWidth(), 16.0f);
+            for (int n = 12; n < 136; ++n)
+            {
+                const auto f0 = 440.0 * std::pow (2.0, (n - 69.5) / 12.0), f1 = 440.0 * std::pow (2.0, (n - 68.5) / 12.0);
+                const auto x0 = xForHz (f0), x1 = xForHz (f1);
+                if (x1 < strip.getX() || x0 > strip.getRight()) continue;
+                const auto pc = n % 12;
+                const auto black = pc == 1 || pc == 3 || pc == 6 || pc == 8 || pc == 10;
+                g.setColour (black ? colour::keyBlack : colour::keyWhite.withAlpha (0.75f));
+                g.fillRect (juce::Rectangle<float> (x0, strip.getY(), juce::jmax (1.0f, x1 - x0 - 0.5f), strip.getHeight()));
+                if (pc == 0 && x1 - x0 > 2.0f)
+                {
+                    g.setColour (colour::bg0);
+                    g.drawText ("C" + juce::String (n / 12 - 1), juce::Rectangle<float> (x0 - 2.0f, strip.getY(), 30.0f, strip.getHeight()), juce::Justification::centredLeft);
+                }
+            }
+        }
+        // gain lines with their labels (warm), the analyser's dBFS beside them (grey)
+        const auto step = rangeDb <= 3.0 ? 1.0 : rangeDb <= 6.0 ? 2.0 : rangeDb <= 12.0 ? 3.0 : 6.0;
+        for (double db = -rangeDb; db <= rangeDb + 0.01; db += step)
+        {
+            const auto y = yForDb (db);
+            g.setColour (std::abs (db) < 0.01 ? colour::gridBar : colour::gridBeat);
+            g.drawHorizontalLine ((int) y, plot.getX(), plot.getRight());
+            g.setColour (std::abs (db) < 0.01 ? colour::textPrimary : colour::accentHover.withAlpha (0.85f));
+            if (y > plot.getY() + 22.0f)
+                g.drawText ((db > 0 ? "+" : "") + juce::String (db, step < 1.5 && std::abs (db - std::round (db)) > 0.01 ? 1 : 0),
+                        juce::Rectangle<float> (plot.getRight() + 4.0f, y - 7.0f, 28.0f, 14.0f), juce::Justification::centredRight);
+        }
+        g.setColour (colour::textDisabled);
+        for (double db = -10.0; db >= specBottom + 5.0; db -= 10.0)
+        {
+            const auto y = yForSpectrum (db);
+            if (y > plot.getY() + 24.0f)
+                g.drawText (juce::String ((int) db), juce::Rectangle<float> (plot.getRight() + 34.0f, y - 7.0f, 28.0f, 14.0f), juce::Justification::centredRight);
+        }
+        {
+            const auto r = juce::Rectangle<float> (plot.getRight() + 6.0f, plot.getY() + 2.0f, 50.0f, 18.0f);
+            g.setColour (r.contains (mouse) ? colour::bg5 : colour::bg4);
+            g.fillRoundedRectangle (r, radius::md);
+            g.setColour (colour::accentHover);
+            g.setFont (font (type::small, true));
+            g.drawText (juce::String ((int) rangeDb) + " dB", r, juce::Justification::centred);
+        }
+
+        // analyser (behind the curves)
+        const auto mode = analyzer (param01 (analyzerParam));
+        if (mode != Analyzer::off && ! specPre.empty())
+        {
+            auto spectrumPath = [&] (const std::vector<float>& db, bool closed) {
+                juce::Path p;
+                const auto n = (int) db.size();
+                for (int i = 0; i < n; ++i)
+                {
+                    const auto x = plot.getX() + plot.getWidth() * (float) i / (float) (n - 1);
+                    const auto y = yForSpectrum (db[(std::size_t) i]);
+                    if (i == 0) p.startNewSubPath (x, closed ? plot.getBottom() : y);
+                    if (i == 0 && closed) p.lineTo (x, y);
+                    else p.lineTo (x, y);
+                }
+                if (closed)
+                {
+                    p.lineTo (plot.getRight(), plot.getBottom());
+                    p.closeSubPath();
+                }
+                return p;
+            };
+            g.saveState();
+            g.reduceClipRegion (plot.toNearestInt());
+            if (mode == Analyzer::pre || mode == Analyzer::both)
+            {
+                g.setColour (colour::bg5.withAlpha (0.55f));
+                g.fillPath (spectrumPath (specPre, true));
+            }
+            if (mode == Analyzer::post || mode == Analyzer::both)
+            {
+                const auto p = spectrumPath (specPost, true);
+                g.setGradientFill (juce::ColourGradient (colour::accent.withAlpha (0.13f), 0.0f, plot.getY(), colour::accent.withAlpha (0.01f), 0.0f, plot.getBottom(), false));
+                g.fillPath (p);
+                g.setColour (colour::accent.withAlpha (0.55f));
+                g.strokePath (spectrumPath (specPost, false), juce::PathStrokeType (1.0f));
+            }
+            g.restoreState();
+        }
+
+        // curves: each band (its own colour, faint), the dynamic span, then the sum
+        const auto columns = juce::jmax (64, (int) plot.getWidth() / 2);
+        std::vector<double> freqs ((std::size_t) columns + 1), sum ((std::size_t) columns + 1, outputDb (fx.params[(std::size_t) outputParam])), band ((std::size_t) columns + 1),
+            span ((std::size_t) columns + 1);
+        for (int i = 0; i <= columns; ++i)
+            freqs[(std::size_t) i] = hzForX (plot.getX() + plot.getWidth() * (float) i / (float) columns);
+        const auto sr = displayRate();
+        const auto solo = soloBand (fx.params[(std::size_t) soloParam]);
+        g.saveState();
+        g.reduceClipRegion (plot.toNearestInt());
+        for (int b = 0; b < bands; ++b)
+        {
+            if (! bandOn (b)) continue;
+            const auto dyn = isDynamic (fx.params, b);
+            const auto live = dyn ? liveDynamic (b) : 0.0;
+            bandCurveDb (fx.params, b, sr, freqs.data(), columns + 1, band.data(), live);
+            for (int i = 0; i <= columns; ++i) sum[(std::size_t) i] += band[(std::size_t) i];
+            const auto colour = bandColour (b);
+            const auto isSel = b == selected || b == hover;
+            juce::Path p;
+            for (int i = 0; i <= columns; ++i)
+            {
+                const auto x = plot.getX() + plot.getWidth() * (float) i / (float) columns;
+                const auto y = yForDb (band[(std::size_t) i]);
+                if (i == 0) p.startNewSubPath (x, y);
+                else p.lineTo (x, y);
+            }
+            if (isSel)
+            {
+                auto fill = p;
+                fill.lineTo (plot.getRight(), yForDb (0.0));
+                fill.lineTo (plot.getX(), yForDb (0.0));
+                fill.closeSubPath();
+                g.setColour (colour.withAlpha (solo == b ? 0.30f : 0.16f));
+                g.fillPath (fill);
+            }
+            if (dyn) // the range the band can move through: static curve ↔ static + range
+            {
+                std::vector<double> lo ((std::size_t) columns + 1), hi ((std::size_t) columns + 1);
+                bandCurveDb (fx.params, b, sr, freqs.data(), columns + 1, lo.data(), 0.0);
+                bandCurveDb (fx.params, b, sr, freqs.data(), columns + 1, hi.data(), rangeDb_ (b));
+                juce::Path area2;
+                for (int i = 0; i <= columns; ++i)
+                {
+                    const auto x = plot.getX() + plot.getWidth() * (float) i / (float) columns;
+                    if (i == 0) area2.startNewSubPath (x, yForDb (lo[0]));
+                    else area2.lineTo (x, yForDb (lo[(std::size_t) i]));
+                }
+                for (int i = columns; i >= 0; --i)
+                    area2.lineTo (plot.getX() + plot.getWidth() * (float) i / (float) columns, yForDb (hi[(std::size_t) i]));
+                area2.closeSubPath();
+                g.setColour (colour.withAlpha (0.12f));
+                g.fillPath (area2);
+            }
+            g.setColour (colour.withAlpha (isSel ? 0.9f : 0.45f));
+            g.strokePath (p, juce::PathStrokeType (isSel ? 1.6f : 1.0f));
+        }
+
+        // the sum
+        juce::Path total;
+        for (int i = 0; i <= columns; ++i)
+        {
+            const auto x = plot.getX() + plot.getWidth() * (float) i / (float) columns;
+            const auto y = yForDb (sum[(std::size_t) i]);
+            if (i == 0) total.startNewSubPath (x, y);
+            else total.lineTo (x, y);
+        }
+        const auto curveColour = fx.enabled ? colour::textPrimary : colour::textDisabled;
+        g.setColour (colour::accent.withAlpha (fx.enabled ? 0.25f : 0.0f));
+        g.strokePath (total, juce::PathStrokeType (5.0f, juce::PathStrokeType::curved, juce::PathStrokeType::rounded));
+        g.setColour (curveColour);
+        g.strokePath (total, juce::PathStrokeType (2.0f, juce::PathStrokeType::curved, juce::PathStrokeType::rounded));
+        g.restoreState();
+
+        // nodes
+        for (int b = 0; b < bands; ++b)
+        {
+            if (! bandOn (b)) continue;
+            const auto pos = nodePosition (b);
+            const auto colour = bandColour (b);
+            const auto isSel = b == selected;
+            if (hasGain (bandShape (b)) && isDynamic (fx.params, b))
+            {
+                // the live position and the range handle
+                const auto scale = gainScale (param01 (scaleParam));
+                const auto liveY = yForDb ((gainDb (param01 (param (b, 2))) + liveDynamic (b)) * scale);
+                const auto rh = rangeHandle (b);
+                g.setColour (colour.withAlpha (0.5f));
+                g.drawLine (pos.x, pos.y, rh.x, rh.y, 1.0f);
+                juce::Path diamond;
+                diamond.addPolygon (rh, 4, 5.0f, juce::MathConstants<float>::pi * 0.25f);
+                g.setColour (isSel ? colour : colour.withAlpha (0.6f));
+                g.fillPath (diamond);
+                g.setColour (colour.withAlpha (0.9f));
+                g.drawEllipse (juce::Rectangle<float> (8.0f, 8.0f).withCentre ({ pos.x, liveY }), 1.5f);
+            }
+            const auto r = isSel ? 9.0f : 7.5f;
+            if (isSel)
+            {
+                g.setColour (colour.withAlpha (0.25f));
+                g.fillEllipse (juce::Rectangle<float> (r * 3.2f, r * 3.2f).withCentre (pos));
+            }
+            g.setColour (soloBand (fx.params[(std::size_t) soloParam]) == b ? colour::warning : colour);
+            g.fillEllipse (juce::Rectangle<float> (r * 2.0f, r * 2.0f).withCentre (pos));
+            g.setColour (colour::bg0);
+            g.setFont (font (type::caption, true));
+            g.drawText (juce::String (b + 1), juce::Rectangle<float> (r * 2.0f, r * 2.0f).withCentre (pos), juce::Justification::centred);
+            if (b == hover || isSel)
+            {
+                g.setColour (colour::textPrimary);
+                g.drawEllipse (juce::Rectangle<float> (r * 2.0f + 3.0f, r * 2.0f + 3.0f).withCentre (pos), 1.2f);
+            }
+        }
+
+        // what is under the mouse: frequency, note, gain of the curve
+        if (plot.contains (mouse))
+        {
+            const auto f = hzForX (mouse.x);
+            g.setColour (colour::textSecondary);
+            g.setFont (font (type::caption));
+            g.drawText (hzText (f) + "  " + noteName (f) + "   " + juce::String (dbForY (mouse.y), 1) + " dB",
+                        juce::Rectangle<float> (plot.getX() + 8.0f, plot.getY() + 6.0f, 260.0f, 14.0f), juce::Justification::centredLeft);
+        }
+        bool any = false;
+        for (int b = 0; b < bands; ++b) any = any || bandOn (b);
+        if (! any)
+        {
+            g.setColour (colour::textDisabled);
+            g.setFont (font (type::body));
+            g.drawText (tr ("Double-click to add a band"), plot, juce::Justification::centred);
+        }
+    }
+
+    // the selected band's floating panel (over the bottom of the graph)
+    void paintPanel (juce::Graphics& g, const EffectSlot& fx, const std::vector<Control>& all)
+    {
+        using namespace theme;
+        const auto panel = panelArea();
+        const auto colourB = bandColour (selected);
+        juce::DropShadow (juce::Colours::black.withAlpha (0.6f), 14, { 0, 4 }).drawForRectangle (g, panel.toNearestInt());
+        g.setColour (colour::bg2.withAlpha (0.97f));
+        g.fillRoundedRectangle (panel, 10.0f);
+        g.setColour (colourB.withAlpha (0.55f));
+        g.drawRoundedRectangle (panel.reduced (0.5f), 10.0f, 1.2f);
+        g.setColour (colourB);
+        g.fillRoundedRectangle (juce::Rectangle<float> (panel.getX() + 14.0f, panel.getY() - 1.0f, 46.0f, 3.0f), 1.5f);
+        const auto solo = soloBand (fx.params[(std::size_t) soloParam]);
+
+        auto drawButton = [&] (juce::Rectangle<float> r, const juce::String& text, bool on, juce::Colour onColour) {
+            g.setColour (on ? onColour.withAlpha (0.25f) : (r.contains (mouse) ? colour::bg5 : colour::bg4));
+            g.fillRoundedRectangle (r, radius::md);
+            g.setColour (on ? onColour : colour::borderStrong);
+            g.drawRoundedRectangle (r.reduced (0.5f), radius::md, 1.0f);
+            g.setColour (on ? colour::textPrimary : colour::textSecondary);
+            g.setFont (font (type::small, on));
+            g.drawText (text, r.reduced (6.0f, 0.0f), juce::Justification::centred, true);
+        };
+        auto drawArrow = [&] (juce::Rectangle<float> r, bool left) {
+            juce::Path a;
+            const auto c = r.getCentre();
+            if (left) a.addTriangle (c.x + 3.0f, c.y - 5.0f, c.x + 3.0f, c.y + 5.0f, c.x - 3.0f, c.y);
+            else a.addTriangle (c.x - 3.0f, c.y - 5.0f, c.x - 3.0f, c.y + 5.0f, c.x + 3.0f, c.y);
+            g.setColour (r.contains (mouse) ? colour::textPrimary : colour::textSecondary);
+            g.fillPath (a);
+        };
+
+        // band number and its colour
+        g.setColour (colourB);
+        g.fillEllipse (juce::Rectangle<float> (16.0f, 16.0f).withCentre ({ panel.getX() + 22.0f, panel.getY() + 16.0f }));
+        g.setColour (colour::bg0);
+        g.setFont (font (type::caption, true));
+        g.drawText (juce::String (selected + 1), juce::Rectangle<float> (16.0f, 16.0f).withCentre ({ panel.getX() + 22.0f, panel.getY() + 16.0f }), juce::Justification::centred);
+        g.setColour (colour::textSecondary);
+        g.setFont (font (type::small));
+        g.drawText (tr ("Band {0}", { juce::String (selected + 1) }), juce::Rectangle<float> (panel.getX() + 36.0f, panel.getY() + 6.0f, 90.0f, 20.0f), juce::Justification::centredLeft);
+
+        for (const auto& c : all)
+        {
+            switch (c.type)
+            {
+                case Ctl::shapeMenu:
+                    drawButton (c.r, tr (shapeNames[(int) bandShape (selected)]) + juce::String::fromUTF8 (" \xe2\x96\xbe"), true, colourB);
+                    break;
+                case Ctl::slopeMenu:
+                    drawButton (c.r, juce::String (slopeDb (param01 (c.param))) + " dB/oct" + juce::String::fromUTF8 (" \xe2\x96\xbe"), false, colourB);
+                    break;
+                case Ctl::remove: drawButton (c.r, tr ("Remove"), false, colour::accent); break;
+                case Ctl::solo: drawButton (c.r, tr ("Solo"), solo == selected, colour::warning); break;
+                case Ctl::dynamic: drawButton (c.r, tr ("Dynamic"), isDynamic (fx.params, selected), colourB); break;
+                case Ctl::prevBand: drawArrow (c.r, true); break;
+                case Ctl::nextBand: drawArrow (c.r, false); break;
+                case Ctl::close:
+                {
+                    g.setColour (c.r.contains (mouse) ? colour::textPrimary : colour::textSecondary);
+                    const auto r = c.r.reduced (5.0f);
+                    g.drawLine (r.getX(), r.getY(), r.getRight(), r.getBottom(), 1.5f);
+                    g.drawLine (r.getRight(), r.getY(), r.getX(), r.getBottom(), 1.5f);
+                    // the band number between the arrows
+                    g.setColour (colour::textPrimary);
+                    g.setFont (font (type::small, true));
+                    g.drawText (juce::String (selected + 1), c.r.translated (-44.0f, 0.0f).withWidth (22.0f), juce::Justification::centred);
+                    break;
+                }
+                case Ctl::freq: case Ctl::gain: case Ctl::q: case Ctl::range: case Ctl::threshold: case Ctl::attack: case Ctl::release:
+                {
+                    static const std::map<Ctl, const char*> captions { { Ctl::freq, TR_NOOP ("FREQ") }, { Ctl::gain, TR_NOOP ("GAIN") }, { Ctl::q, "Q" },
+                                                                       { Ctl::range, TR_NOOP ("RANGE") }, { Ctl::threshold, TR_NOOP ("THRESHOLD") },
+                                                                       { Ctl::attack, TR_NOOP ("ATTACK") }, { Ctl::release, TR_NOOP ("RELEASE") } };
+                    const auto bipolar = c.type == Ctl::gain || c.type == Ctl::range;
+                    const auto active = dragging == Drag::control && dragParam == c.param;
+                    const auto global = c.type == Ctl::attack || c.type == Ctl::release;
+                    const auto knob = knobCircle (c);
+                    drawKnob (g, knob, param01 (c.param), bipolar, active ? colour::accent : (global ? colour::knobArc : colourB), c.r.contains (mouse));
+                    if (c.type == Ctl::gain && isDynamic (fx.params, selected))
+                    {
+                        // the dynamic range as an outer arc from the gain, and the live position as a dot
+                        const auto scale = (float) (juce::MathConstants<float>::pi * 1.5f);
+                        const auto start = -juce::MathConstants<float>::pi * 0.75f;
+                        const auto g0 = param01 (param (selected, 2));
+                        const auto g1 = juce::jlimit (0.0f, 1.0f, gainValue (gainDb (g0) + rangeDb_ (selected)));
+                        const auto rr = knob.getWidth() * 0.5f + 4.0f;
+                        juce::Path arc;
+                        arc.addCentredArc (knob.getCentreX(), knob.getCentreY(), rr, rr, 0.0f, start + scale * juce::jmin (g0, g1), start + scale * juce::jmax (g0, g1), true);
+                        g.setColour (colourB.withAlpha (0.8f));
+                        g.strokePath (arc, juce::PathStrokeType (2.0f));
+                        const auto live = juce::jlimit (0.0f, 1.0f, gainValue (gainDb (g0) + liveDynamic (selected)));
+                        const auto ang = start + scale * live;
+                        g.setColour (colour::textPrimary);
+                        g.fillEllipse (juce::Rectangle<float> (5.0f, 5.0f).withCentre ({ knob.getCentreX() + rr * std::sin (ang), knob.getCentreY() - rr * std::cos (ang) }));
+                    }
+                    g.setColour (colour::textDisabled);
+                    g.setFont (font (type::caption, true));
+                    g.drawText (tr (captions.at (c.type)), c.r.withY (c.r.getBottom() - 34.0f).withHeight (14.0f), juce::Justification::centred);
+                    g.setColour (colour::textPrimary);
+                    g.setFont (font (type::small));
+                    g.drawText (valueText (c.param), c.r.withTop (c.r.getBottom() - 20.0f), juce::Justification::centred, true);
+                    break;
+                }
+                default: break;
+            }
+        }
+        if (hasGain (bandShape (selected)) && ! isDynamic (fx.params, selected))
+        {
+            g.setColour (colour::textDisabled);
+            g.setFont (font (type::caption));
+            g.drawFittedText (tr ("Dynamic EQ: the gain follows the level of the band's region (threshold, range)"),
+                              juce::Rectangle<float> (panel.getX() + 306.0f, panel.getY() + 40.0f, 200.0f, 60.0f).toNearestInt(), juce::Justification::centredLeft, 3);
+        }
+    }
+
+private:
+    enum class Drag { none, node, range, control };
+
+    int tapKey() const { return track * maxEffectSlots + slot; }
+
+    void claimTap()
+    {
+        if (auto* times = engine.getProcessTimes()) times->analyzer.key.store (tapKey());
+    }
+
+    void changeListenerCallback (juce::ChangeBroadcaster*) override
+    {
+        if (current() == nullptr) selected = -1;
+        repaint();
+    }
+
+    void timerCallback() override
+    {
+        updateSpectrum();
+        if (isShowing()) repaint (graphArea().toNearestInt());
+    }
+
+    void updateSpectrum()
+    {
+        const auto columns = juce::jmax (64, (int) plotArea().getWidth() / 3);
+        if ((int) specPre.size() != columns)
+        {
+            specPre.assign ((std::size_t) columns, (float) specBottom);
+            specPost.assign ((std::size_t) columns, (float) specBottom);
+        }
+        if (analyzer (param01 (analyzerParam)) == Analyzer::off) return;
+        if (demo)
+        {
+            for (int i = 0; i < columns; ++i)
+            {
+                const auto f = hzForX (plotArea().getX() + plotArea().getWidth() * (float) i / (float) (columns - 1));
+                // a mix's typical spectrum: pink-ish slope, a kick bump, a presence region, roll-off
+                const auto db = -40.0 - 9.0 * std::log2 (juce::jmax (20.0, f) / 1000.0) * 0.5 + 9.0 * std::exp (-std::pow (std::log2 (f / 60.0), 2.0))
+                                + 4.0 * std::sin (f * 0.0021) - (f > 14000.0 ? (f - 14000.0) * 0.004 : 0.0) + tiltDb (f);
+                specPre[(std::size_t) i] = (float) db;
+                const auto* fx = current();
+                specPost[(std::size_t) i] = (float) (db + (fx != nullptr ? responseDb (fx->params, 48000.0, f) : 0.0));
+            }
+            return;
+        }
+        auto* times = engine.getProcessTimes();
+        if (times == nullptr) return;
+        auto& tap = times->analyzer;
+        if (tap.key.load (std::memory_order_relaxed) != tapKey())
+        {
+            if (hasKeyboardFocus (true) || isMouseOver (true)) claimTap(); // the editor in use takes the analyser
+            decay();
+            return;
+        }
+        const auto written = tap.written.load (std::memory_order_acquire);
+        if (written == lastWritten) { decay(); return; }
+        lastWritten = written;
+        const auto sr = displayRate();
+        for (int which = 0; which < 2; ++which)
+        {
+            auto& ring = which == 0 ? tap.pre : tap.post;
+            std::fill (fftData.begin(), fftData.end(), 0.0f);
+            for (int i = 0; i < fftSize; ++i)
+                fftData[(std::size_t) i] = ring[(std::size_t) ((written - (std::uint32_t) fftSize + (std::uint32_t) i) & (ProcessTimes::AnalyzerTap::size - 1))]
+                                               .load (std::memory_order_relaxed) * window[(std::size_t) i];
+            fft.performFrequencyOnlyForwardTransform (fftData.data(), true);
+            auto& out = which == 0 ? specPre : specPost;
+            const auto norm = 4.0f / (float) fftSize; // Hann (coherent gain ½) and one side
+            for (int i = 0; i < columns; ++i)
+            {
+                const auto f0 = hzForX (plotArea().getX() + plotArea().getWidth() * ((float) i - 0.5f) / (float) (columns - 1));
+                const auto f1 = hzForX (plotArea().getX() + plotArea().getWidth() * ((float) i + 0.5f) / (float) (columns - 1));
+                auto k0 = (int) std::floor (f0 * fftSize / sr), k1 = (int) std::ceil (f1 * fftSize / sr);
+                k0 = juce::jlimit (1, fftSize / 2 - 1, k0);
+                k1 = juce::jlimit (k0, fftSize / 2 - 1, k1);
+                float m = 0.0f;
+                for (int k = k0; k <= k1; ++k) m = juce::jmax (m, fftData[(std::size_t) k]);
+                const auto f = hzForX (plotArea().getX() + plotArea().getWidth() * (float) i / (float) (columns - 1));
+                const auto db = (float) (20.0 * std::log10 (m * norm + 1e-9) + tiltDb (f));
+                auto& v = out[(std::size_t) i];
+                v = db > v ? db : juce::jmax (db, v - 1.5f); // fast up, ~45 dB/s down
+            }
+        }
+    }
+
+    static double tiltDb (double f) { return 4.5 * std::log2 (juce::jmax (10.0, f) / 1000.0); }
+
+    void decay()
+    {
+        for (auto* v : { &specPre, &specPost })
+            for (auto& x : *v) x = juce::jmax ((float) specBottom, x - 1.5f);
+    }
+
+    AudioEngine& engine;
+    int track, slot;
+    bool demo = false;
+    int selected = -1, hover = -1, tipBand = -1, dragBand = -1, dragParam = -1;
+    bool piano = false;
+    double rangeDb = 12.0;
+    Drag dragging = Drag::none;
+    juce::Point<float> dragOffset, dragStart, mouse { -1.0f, -1.0f };
+    juce::Rectangle<float> dragRect;
+    ui::ValueDrag valueDrag;
+    juce::dsp::FFT fft;
+    std::vector<float> fftData, window, specPre, specPost;
+    std::uint32_t lastWritten = 0;
+};
+
+class FacetEqWindow final : public juce::DocumentWindow
+{
+public:
+    FacetEqWindow (AudioEngine& engine, int track, int slot, const juce::String& title)
+        : DocumentWindow (title, theme::colour::bg1, DocumentWindow::closeButton | DocumentWindow::minimiseButton)
+    {
+        setUsingNativeTitleBar (true);
+        setContentOwned (new FacetEqEditor (engine, track, slot, false), true);
+        setResizable (true, false);
+        if (auto* c = getConstrainer())
+        {
+            c->setMinimumSize (860, 440);
+            c->setMaximumSize (2400, 1400);
+        }
+        centreWithSize (getWidth(), getHeight());
+        setVisible (true);
+        keepAboveMainWindow (*this);
+    }
+
+    void closeButtonPressed() override;
+};
+
+std::map<std::pair<int, int>, std::unique_ptr<FacetEqWindow>>& windows()
+{
+    static std::map<std::pair<int, int>, std::unique_ptr<FacetEqWindow>> open;
+    return open;
+}
+
+void FacetEqWindow::closeButtonPressed()
+{
+    for (auto& [key, window] : windows())
+        if (window.get() == this)
+        {
+            juce::MessageManager::callAsync ([k = key] { windows().erase (k); });
+            return;
+        }
+}
+} // namespace
+
+void drawFacetEqCurve (juce::Graphics& g, juce::Rectangle<float> area, const EffectParams& params, double sampleRate, bool enabled)
+{
+    using namespace theme;
+    g.setColour (colour::bg0);
+    g.fillRoundedRectangle (area, radius::md);
+    const auto xFor = [&] (double f) { return area.getX() + area.getWidth() * (float) (std::log (f / 20.0) / std::log (1000.0)); };
+    g.setColour (colour::gridBeat);
+    for (double f : { 100.0, 1000.0, 10000.0 }) g.drawVerticalLine ((int) xFor (f), area.getY(), area.getBottom());
+    g.setColour (colour::gridBar);
+    g.drawHorizontalLine ((int) area.getCentreY(), area.getX(), area.getRight());
+    const int n = juce::jmax (32, (int) area.getWidth() / 2);
+    std::vector<double> freqs ((std::size_t) n + 1), sum ((std::size_t) n + 1, outputDb (params[(std::size_t) outputParam])), band ((std::size_t) n + 1);
+    for (int i = 0; i <= n; ++i) freqs[(std::size_t) i] = 20.0 * std::pow (1000.0, (double) i / n);
+    for (int b = 0; b < bands; ++b)
+    {
+        if (shape (params[(std::size_t) param (b, 0)]) == Shape::off) continue;
+        bandCurveDb (params, b, sampleRate, freqs.data(), n + 1, band.data());
+        for (int i = 0; i <= n; ++i) sum[(std::size_t) i] += band[(std::size_t) i];
+    }
+    juce::Path p;
+    for (int i = 0; i <= n; ++i)
+    {
+        const auto x = area.getX() + area.getWidth() * (float) i / (float) n;
+        const auto y = area.getCentreY() - area.getHeight() * 0.45f * (float) (juce::jlimit (-24.0, 24.0, sum[(std::size_t) i]) / 24.0);
+        if (i == 0) p.startNewSubPath (x, y);
+        else p.lineTo (x, y);
+    }
+    g.setColour (enabled ? colour::accent : colour::textDisabled);
+    g.strokePath (p, juce::PathStrokeType (2.0f));
+    for (int b = 0; b < bands; ++b)
+    {
+        const auto sh = shape (params[(std::size_t) param (b, 0)]);
+        if (sh == Shape::off) continue;
+        const auto f = juce::jlimit (20.0, 20000.0, hz (params[(std::size_t) param (b, 1)]));
+        const auto db = hasGain (sh) ? gainDb (params[(std::size_t) param (b, 2)]) * gainScale (params[(std::size_t) scaleParam]) : 0.0;
+        g.setColour (bandColour (b));
+        g.fillEllipse (juce::Rectangle<float> (7.0f, 7.0f).withCentre ({ xFor (f), area.getCentreY() - area.getHeight() * 0.45f * (float) (juce::jlimit (-24.0, 24.0, db) / 24.0) }));
+    }
+}
+
+std::unique_ptr<juce::Component> makeFacetEqEditor (AudioEngine& engine, int track, int slot, bool demo)
+{
+    return std::make_unique<FacetEqEditor> (engine, track, slot, demo);
+}
+
+namespace FacetEqWindows
+{
+void open (AudioEngine& engine, int track, int slot)
+{
+    const auto& mixer = engine.getSong().mixer;
+    if (track < 0 || track >= (int) mixer.size() || slot < 0 || slot >= (int) mixer[(std::size_t) track].effects.size())
+        return;
+    auto& open = windows();
+    const auto key = std::make_pair (track, slot);
+    if (auto it = open.find (key); it != open.end())
+    {
+        if (auto* editor = dynamic_cast<FacetEqEditor*> (it->second->getContentComponent()); editor != nullptr && editor->current() != nullptr)
+        {
+            it->second->toFront (true);
+            return;
+        }
+        open.erase (it);
+    }
+    const auto name = track == 0 ? tr ("Master") : juce::String::fromUTF8 (mixer[(std::size_t) track].name.c_str());
+    const auto title = juce::String ("Facet EQ - ") + (name.isNotEmpty() ? name : tr ("Insert {0}", { juce::String (track) })) + " ("
+                       + tr ("slot {0}", { juce::String (slot + 1) }) + ")";
+    open[key] = std::make_unique<FacetEqWindow> (engine, track, slot, title);
+}
+
+void closeAll()
+{
+    windows().clear();
+}
+} // namespace FacetEqWindows
+} // namespace lynx

+ 26 - 0
src/ui/FacetEqEditor.h

@@ -0,0 +1,26 @@
+#pragma once
+
+#include <juce_gui_basics/juce_gui_basics.h>
+
+#include "engine/AudioEngine.h"
+
+namespace lynx
+{
+// Facet EQ's own editor (REA round 103): a large response graph over a live spectrum analyser (the slot's input and
+// output), one node per band — drag = frequency and gain, mouse wheel = Q, double-click on the graph = new band,
+// double-click on a node = remove it, right-click = shape / slope / dynamics / solo menu, the small diamond under a
+// dynamic band's node = its range —, a strip with the selected band's controls (shape, frequency, gain, Q, slope,
+// dynamic range and threshold, solo) and the global ones (phase mode with its latency, analyser, attack / release,
+// detector and sidechain, output, gain scale).
+namespace FacetEqWindows
+{
+void open (AudioEngine& engine, int track, int slot);
+void closeAll();
+} // namespace FacetEqWindows
+
+// The response curve alone (the mixer panel's thumbnail)
+void drawFacetEqCurve (juce::Graphics& g, juce::Rectangle<float> area, const EffectParams& params, double sampleRate, bool enabled);
+
+// The editor alone (for --plugui / --snapshot); `demo` fills the analyser with a synthetic spectrum.
+std::unique_ptr<juce::Component> makeFacetEqEditor (AudioEngine& engine, int track, int slot, bool demo = false);
+} // namespace lynx

+ 152 - 0
src/ui/I18nData.h

@@ -5971,6 +5971,158 @@ inline constexpr unsigned char ptBR[] = {
 116, 195, 170, 110, 99, 105, 97, 34, 10, 34, 84, 65, 82, 71, 69, 84, 32, 78, 79, 84, 69, 83, 34, 32,
 61, 32, 34, 78, 79, 84, 65, 83, 45, 65, 76, 86, 79, 34, 10, 34, 77, 73, 68, 73, 32, 99, 104, 97,
 110, 110, 101, 108, 34, 32, 61, 32, 34, 67, 97, 110, 97, 108, 32, 77, 73, 68, 73, 34, 10, 10, 35, 32,
+45, 45, 45, 32, 70, 97, 99, 101, 116, 32, 69, 81, 32, 101, 100, 105, 116, 111, 114, 32, 97, 110, 100, 32,
+76, 89, 78, 88, 32, 84, 117, 110, 101, 32, 112, 105, 116, 99, 104, 32, 100, 105, 115, 112, 108, 97, 121, 32,
+40, 114, 111, 117, 110, 100, 32, 49, 48, 51, 41, 10, 34, 76, 73, 86, 69, 32, 80, 73, 84, 67, 72, 34,
+32, 61, 32, 34, 65, 70, 73, 78, 65, 195, 135, 195, 131, 79, 32, 65, 79, 32, 86, 73, 86, 79, 34, 10,
+34, 84, 105, 108, 116, 32, 115, 104, 101, 108, 102, 34, 32, 61, 32, 34, 84, 105, 108, 116, 32, 115, 104, 101,
+108, 102, 34, 10, 34, 90, 101, 114, 111, 32, 108, 97, 116, 101, 110, 99, 121, 34, 32, 61, 32, 34, 76, 97,
+116, 195, 170, 110, 99, 105, 97, 32, 122, 101, 114, 111, 34, 10, 34, 78, 97, 116, 117, 114, 97, 108, 32, 112,
+104, 97, 115, 101, 34, 32, 61, 32, 34, 70, 97, 115, 101, 32, 110, 97, 116, 117, 114, 97, 108, 34, 10, 34,
+76, 105, 110, 101, 97, 114, 32, 112, 104, 97, 115, 101, 34, 32, 61, 32, 34, 70, 97, 115, 101, 32, 108, 105,
+110, 101, 97, 114, 34, 10, 34, 65, 110, 97, 108, 121, 122, 101, 114, 32, 111, 102, 102, 34, 32, 61, 32, 34,
+65, 110, 97, 108, 105, 115, 97, 100, 111, 114, 32, 100, 101, 115, 108, 105, 103, 97, 100, 111, 34, 10, 34, 65,
+110, 97, 108, 121, 122, 101, 114, 58, 32, 112, 114, 101, 34, 32, 61, 32, 34, 65, 110, 97, 108, 105, 115, 97,
+100, 111, 114, 58, 32, 112, 114, 195, 169, 34, 10, 34, 65, 110, 97, 108, 121, 122, 101, 114, 58, 32, 112, 111,
+115, 116, 34, 32, 61, 32, 34, 65, 110, 97, 108, 105, 115, 97, 100, 111, 114, 58, 32, 112, 195, 179, 115, 34,
+10, 34, 65, 110, 97, 108, 121, 122, 101, 114, 58, 32, 112, 114, 101, 32, 43, 32, 112, 111, 115, 116, 34, 32,
+61, 32, 34, 65, 110, 97, 108, 105, 115, 97, 100, 111, 114, 58, 32, 112, 114, 195, 169, 32, 43, 32, 112, 195,
+179, 115, 34, 10, 34, 83, 108, 111, 112, 101, 34, 32, 61, 32, 34, 73, 110, 99, 108, 105, 110, 97, 195, 167,
+195, 163, 111, 34, 10, 34, 68, 121, 110, 97, 109, 105, 99, 32, 114, 97, 110, 103, 101, 34, 32, 61, 32, 34,
+70, 97, 105, 120, 97, 32, 100, 105, 110, 195, 162, 109, 105, 99, 97, 34, 10, 34, 83, 111, 108, 111, 32, 98,
+97, 110, 100, 34, 32, 61, 32, 34, 83, 111, 108, 111, 32, 100, 97, 32, 98, 97, 110, 100, 97, 34, 10, 34,
+82, 101, 115, 101, 116, 32, 103, 97, 105, 110, 34, 32, 61, 32, 34, 90, 101, 114, 97, 114, 32, 103, 97, 110,
+104, 111, 34, 10, 34, 82, 101, 109, 111, 118, 101, 32, 98, 97, 110, 100, 34, 32, 61, 32, 34, 82, 101, 109,
+111, 118, 101, 114, 32, 98, 97, 110, 100, 97, 34, 10, 34, 68, 101, 116, 101, 99, 116, 32, 116, 104, 101, 32,
+69, 81, 39, 115, 32, 105, 110, 112, 117, 116, 34, 32, 61, 32, 34, 68, 101, 116, 101, 99, 116, 97, 114, 32,
+97, 32, 101, 110, 116, 114, 97, 100, 97, 32, 100, 111, 32, 69, 81, 34, 10, 34, 68, 101, 116, 101, 99, 116,
+32, 116, 104, 101, 32, 115, 105, 100, 101, 99, 104, 97, 105, 110, 34, 32, 61, 32, 34, 68, 101, 116, 101, 99,
+116, 97, 114, 32, 111, 32, 115, 105, 100, 101, 99, 104, 97, 105, 110, 34, 10, 34, 80, 114, 111, 99, 101, 115,
+115, 105, 110, 103, 58, 32, 122, 101, 114, 111, 32, 108, 97, 116, 101, 110, 99, 121, 32, 40, 109, 105, 110, 105,
+109, 117, 109, 32, 112, 104, 97, 115, 101, 41, 44, 32, 110, 97, 116, 117, 114, 97, 108, 32, 112, 104, 97, 115,
+101, 32, 40, 116, 104, 101, 32, 97, 110, 97, 108, 111, 103, 32, 99, 117, 114, 118, 101, 39, 115, 32, 112, 104,
+97, 115, 101, 41, 32, 111, 114, 32, 108, 105, 110, 101, 97, 114, 32, 112, 104, 97, 115, 101, 32, 40, 110, 111,
+32, 112, 104, 97, 115, 101, 32, 115, 104, 105, 102, 116, 41, 59, 32, 116, 104, 101, 32, 108, 97, 116, 101, 110,
+99, 121, 32, 105, 115, 32, 114, 101, 112, 111, 114, 116, 101, 100, 32, 116, 111, 32, 80, 68, 67, 34, 32, 61,
+32, 34, 80, 114, 111, 99, 101, 115, 115, 97, 109, 101, 110, 116, 111, 58, 32, 108, 97, 116, 195, 170, 110, 99,
+105, 97, 32, 122, 101, 114, 111, 32, 40, 102, 97, 115, 101, 32, 109, 195, 173, 110, 105, 109, 97, 41, 44, 32,
+102, 97, 115, 101, 32, 110, 97, 116, 117, 114, 97, 108, 32, 40, 97, 32, 102, 97, 115, 101, 32, 100, 97, 32,
+99, 117, 114, 118, 97, 32, 97, 110, 97, 108, 195, 179, 103, 105, 99, 97, 41, 32, 111, 117, 32, 102, 97, 115,
+101, 32, 108, 105, 110, 101, 97, 114, 32, 40, 115, 101, 109, 32, 100, 101, 115, 118, 105, 111, 32, 100, 101, 32,
+102, 97, 115, 101, 41, 59, 32, 97, 32, 108, 97, 116, 195, 170, 110, 99, 105, 97, 32, 195, 169, 32, 105, 110,
+102, 111, 114, 109, 97, 100, 97, 32, 97, 111, 32, 80, 68, 67, 34, 10, 34, 87, 104, 97, 116, 32, 116, 104,
+101, 32, 100, 121, 110, 97, 109, 105, 99, 32, 98, 97, 110, 100, 115, 32, 108, 105, 115, 116, 101, 110, 32, 116,
+111, 58, 32, 116, 104, 101, 32, 69, 81, 39, 115, 32, 105, 110, 112, 117, 116, 32, 111, 114, 32, 97, 32, 115,
+105, 100, 101, 99, 104, 97, 105, 110, 32, 116, 114, 97, 99, 107, 34, 32, 61, 32, 34, 79, 32, 113, 117, 101,
+32, 97, 115, 32, 98, 97, 110, 100, 97, 115, 32, 100, 105, 110, 195, 162, 109, 105, 99, 97, 115, 32, 101, 115,
+99, 117, 116, 97, 109, 58, 32, 97, 32, 101, 110, 116, 114, 97, 100, 97, 32, 100, 111, 32, 69, 81, 32, 111,
+117, 32, 117, 109, 97, 32, 102, 97, 105, 120, 97, 32, 100, 101, 32, 115, 105, 100, 101, 99, 104, 97, 105, 110,
+34, 10, 34, 82, 101, 109, 111, 118, 101, 32, 116, 104, 101, 32, 98, 97, 110, 100, 32, 40, 68, 101, 108, 101,
+116, 101, 41, 34, 32, 61, 32, 34, 82, 101, 109, 111, 118, 101, 114, 32, 97, 32, 98, 97, 110, 100, 97, 32,
+40, 68, 101, 108, 101, 116, 101, 41, 34, 10, 34, 83, 111, 108, 111, 58, 32, 104, 101, 97, 114, 32, 111, 110,
+108, 121, 32, 116, 104, 105, 115, 32, 98, 97, 110, 100, 39, 115, 32, 114, 101, 103, 105, 111, 110, 32, 40, 83,
+41, 34, 32, 61, 32, 34, 83, 111, 108, 111, 58, 32, 111, 117, 118, 105, 114, 32, 115, 195, 179, 32, 97, 32,
+114, 101, 103, 105, 195, 163, 111, 32, 100, 101, 115, 116, 97, 32, 98, 97, 110, 100, 97, 32, 40, 83, 41, 34,
+10, 34, 68, 121, 110, 97, 109, 105, 99, 32, 69, 81, 58, 32, 116, 104, 101, 32, 98, 97, 110, 100, 39, 115,
+32, 103, 97, 105, 110, 32, 109, 111, 118, 101, 115, 32, 98, 121, 32, 117, 112, 32, 116, 111, 32, 105, 116, 115,
+32, 114, 97, 110, 103, 101, 32, 119, 104, 101, 110, 32, 105, 116, 115, 32, 114, 101, 103, 105, 111, 110, 32, 103,
+111, 101, 115, 32, 111, 118, 101, 114, 32, 116, 104, 101, 32, 116, 104, 114, 101, 115, 104, 111, 108, 100, 34, 32,
+61, 32, 34, 69, 81, 32, 100, 105, 110, 195, 162, 109, 105, 99, 111, 58, 32, 111, 32, 103, 97, 110, 104, 111,
+32, 100, 97, 32, 98, 97, 110, 100, 97, 32, 115, 101, 32, 109, 111, 118, 101, 32, 97, 116, 195, 169, 32, 97,
+32, 115, 117, 97, 32, 102, 97, 105, 120, 97, 32, 113, 117, 97, 110, 100, 111, 32, 97, 32, 114, 101, 103, 105,
+195, 163, 111, 32, 100, 101, 108, 97, 32, 112, 97, 115, 115, 97, 32, 100, 111, 32, 108, 105, 109, 105, 97, 114,
+34, 10, 34, 66, 97, 110, 100, 32, 115, 104, 97, 112, 101, 34, 32, 61, 32, 34, 70, 111, 114, 109, 97, 116,
+111, 32, 100, 97, 32, 98, 97, 110, 100, 97, 34, 10, 34, 68, 121, 110, 97, 109, 105, 99, 32, 114, 97, 110,
+103, 101, 58, 32, 100, 114, 97, 103, 32, 117, 112, 32, 111, 114, 32, 100, 111, 119, 110, 34, 32, 61, 32, 34,
+70, 97, 105, 120, 97, 32, 100, 105, 110, 195, 162, 109, 105, 99, 97, 58, 32, 97, 114, 114, 97, 115, 116, 101,
+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, 68, 111, 117, 98, 108, 101, 45, 99, 108, 105, 99, 107, 32, 116, 111, 32, 97, 100, 100, 32, 97,
+32, 98, 97, 110, 100, 59, 32, 109, 111, 117, 115, 101, 32, 119, 104, 101, 101, 108, 32, 61, 32, 81, 32, 111,
+102, 32, 116, 104, 101, 32, 115, 101, 108, 101, 99, 116, 101, 100, 32, 98, 97, 110, 100, 34, 32, 61, 32, 34,
+68, 117, 112, 108, 111, 32, 99, 108, 105, 113, 117, 101, 32, 112, 97, 114, 97, 32, 97, 100, 105, 99, 105, 111,
+110, 97, 114, 32, 117, 109, 97, 32, 98, 97, 110, 100, 97, 59, 32, 114, 111, 100, 97, 32, 100, 111, 32, 109,
+111, 117, 115, 101, 32, 61, 32, 81, 32, 100, 97, 32, 98, 97, 110, 100, 97, 32, 115, 101, 108, 101, 99, 105,
+111, 110, 97, 100, 97, 34, 10, 34, 79, 85, 84, 34, 32, 61, 32, 34, 83, 65, 195, 141, 68, 65, 34, 10,
+34, 83, 67, 65, 76, 69, 34, 32, 61, 32, 34, 69, 83, 67, 65, 76, 65, 34, 10, 34, 108, 97, 116, 101,
+110, 99, 121, 32, 123, 48, 125, 32, 115, 97, 109, 112, 108, 101, 115, 34, 32, 61, 32, 34, 108, 97, 116, 195,
+170, 110, 99, 105, 97, 32, 123, 48, 125, 32, 97, 109, 111, 115, 116, 114, 97, 115, 34, 10, 34, 68, 111, 117,
+98, 108, 101, 45, 99, 108, 105, 99, 107, 32, 116, 111, 32, 97, 100, 100, 32, 97, 32, 98, 97, 110, 100, 34,
+32, 61, 32, 34, 68, 117, 112, 108, 111, 32, 99, 108, 105, 113, 117, 101, 32, 112, 97, 114, 97, 32, 97, 100,
+105, 99, 105, 111, 110, 97, 114, 32, 117, 109, 97, 32, 98, 97, 110, 100, 97, 34, 10, 34, 68, 121, 110, 97,
+109, 105, 99, 34, 32, 61, 32, 34, 68, 105, 110, 195, 162, 109, 105, 99, 111, 34, 10, 34, 70, 82, 69, 81,
+34, 32, 61, 32, 34, 70, 82, 69, 81, 34, 10, 34, 71, 65, 73, 78, 34, 32, 61, 32, 34, 71, 65, 78,
+72, 79, 34, 10, 34, 82, 65, 78, 71, 69, 34, 32, 61, 32, 34, 70, 65, 73, 88, 65, 34, 10, 34, 84,
+72, 82, 69, 83, 72, 79, 76, 68, 34, 32, 61, 32, 34, 76, 73, 77, 73, 65, 82, 34, 10, 34, 65, 84,
+84, 65, 67, 75, 34, 32, 61, 32, 34, 65, 84, 65, 81, 85, 69, 34, 10, 34, 82, 69, 76, 69, 65, 83,
+69, 34, 32, 61, 32, 34, 82, 69, 76, 69, 65, 83, 69, 34, 10, 34, 79, 112, 101, 110, 32, 70, 97, 99,
+101, 116, 32, 69, 81, 34, 32, 61, 32, 34, 65, 98, 114, 105, 114, 32, 111, 32, 70, 97, 99, 101, 116, 32,
+69, 81, 34, 10, 34, 84, 97, 114, 103, 101, 116, 34, 32, 61, 32, 34, 65, 108, 118, 111, 34, 10, 34, 67,
+111, 114, 114, 101, 99, 116, 105, 111, 110, 34, 32, 61, 32, 34, 67, 111, 114, 114, 101, 195, 167, 195, 163, 111,
+34, 10, 34, 80, 108, 97, 121, 32, 97, 32, 118, 111, 105, 99, 101, 32, 111, 114, 32, 97, 110, 32, 105, 110,
+115, 116, 114, 117, 109, 101, 110, 116, 32, 116, 104, 114, 111, 117, 103, 104, 32, 116, 104, 101, 32, 105, 110, 115,
+101, 114, 116, 32, 116, 111, 32, 115, 101, 101, 32, 105, 116, 115, 32, 112, 105, 116, 99, 104, 34, 32, 61, 32,
+34, 84, 111, 113, 117, 101, 32, 117, 109, 97, 32, 118, 111, 122, 32, 111, 117, 32, 117, 109, 32, 105, 110, 115,
+116, 114, 117, 109, 101, 110, 116, 111, 32, 112, 111, 114, 32, 101, 115, 116, 101, 32, 105, 110, 115, 101, 114, 116,
+32, 112, 97, 114, 97, 32, 118, 101, 114, 32, 97, 32, 97, 102, 105, 110, 97, 195, 167, 195, 163, 111, 34, 10,
+34, 105, 110, 112, 117, 116, 34, 32, 61, 32, 34, 101, 110, 116, 114, 97, 100, 97, 34, 10, 34, 99, 111, 114,
+114, 101, 99, 116, 101, 100, 34, 32, 61, 32, 34, 99, 111, 114, 114, 105, 103, 105, 100, 111, 34, 10, 34, 80,
+114, 101, 32, 43, 32, 80, 111, 115, 116, 34, 32, 61, 32, 34, 80, 114, 195, 169, 32, 43, 32, 80, 195, 179,
+115, 34, 10, 34, 73, 110, 118, 101, 114, 116, 32, 97, 108, 108, 32, 103, 97, 105, 110, 115, 34, 32, 61, 32,
+34, 73, 110, 118, 101, 114, 116, 101, 114, 32, 116, 111, 100, 111, 115, 32, 111, 115, 32, 103, 97, 110, 104, 111,
+115, 34, 10, 34, 82, 101, 109, 111, 118, 101, 32, 97, 108, 108, 32, 98, 97, 110, 100, 115, 34, 32, 61, 32,
+34, 82, 101, 109, 111, 118, 101, 114, 32, 116, 111, 100, 97, 115, 32, 97, 115, 32, 98, 97, 110, 100, 97, 115,
+34, 10, 34, 83, 112, 101, 99, 116, 114, 117, 109, 32, 97, 110, 97, 108, 121, 122, 101, 114, 58, 32, 111, 102,
+102, 44, 32, 112, 114, 101, 44, 32, 112, 111, 115, 116, 32, 111, 114, 32, 112, 114, 101, 32, 43, 32, 112, 111,
+115, 116, 34, 32, 61, 32, 34, 65, 110, 97, 108, 105, 115, 97, 100, 111, 114, 32, 100, 101, 32, 101, 115, 112,
+101, 99, 116, 114, 111, 58, 32, 100, 101, 115, 108, 105, 103, 97, 100, 111, 44, 32, 112, 114, 195, 169, 44, 32,
+112, 195, 179, 115, 32, 111, 117, 32, 112, 114, 195, 169, 32, 43, 32, 112, 195, 179, 115, 34, 10, 34, 70, 114,
+101, 113, 117, 101, 110, 99, 121, 32, 115, 99, 97, 108, 101, 58, 32, 110, 117, 109, 98, 101, 114, 115, 32, 111,
+114, 32, 97, 32, 112, 105, 97, 110, 111, 32, 107, 101, 121, 98, 111, 97, 114, 100, 34, 32, 61, 32, 34, 69,
+115, 99, 97, 108, 97, 32, 100, 101, 32, 102, 114, 101, 113, 117, 195, 170, 110, 99, 105, 97, 58, 32, 110, 195,
+186, 109, 101, 114, 111, 115, 32, 111, 117, 32, 117, 109, 32, 116, 101, 99, 108, 97, 100, 111, 32, 100, 101, 32,
+112, 105, 97, 110, 111, 34, 10, 34, 80, 114, 101, 118, 105, 111, 117, 115, 32, 47, 32, 110, 101, 120, 116, 32,
+98, 97, 110, 100, 34, 32, 61, 32, 34, 66, 97, 110, 100, 97, 32, 97, 110, 116, 101, 114, 105, 111, 114, 32,
+47, 32, 112, 114, 195, 179, 120, 105, 109, 97, 34, 10, 34, 67, 108, 111, 115, 101, 32, 116, 104, 101, 32, 98,
+97, 110, 100, 32, 112, 97, 110, 101, 108, 32, 40, 99, 108, 105, 99, 107, 32, 111, 110, 32, 116, 104, 101, 32,
+101, 109, 112, 116, 121, 32, 103, 114, 97, 112, 104, 32, 100, 111, 101, 115, 32, 116, 104, 101, 32, 115, 97, 109,
+101, 41, 34, 32, 61, 32, 34, 70, 101, 99, 104, 97, 114, 32, 111, 32, 112, 97, 105, 110, 101, 108, 32, 100,
+97, 32, 98, 97, 110, 100, 97, 32, 40, 117, 109, 32, 99, 108, 105, 113, 117, 101, 32, 110, 111, 32, 103, 114,
+195, 161, 102, 105, 99, 111, 32, 118, 97, 122, 105, 111, 32, 102, 97, 122, 32, 111, 32, 109, 101, 115, 109, 111,
+41, 34, 10, 34, 71, 114, 97, 112, 104, 32, 115, 99, 97, 108, 101, 58, 32, 99, 108, 105, 99, 107, 32, 116,
+111, 32, 115, 119, 105, 116, 99, 104, 32, 98, 101, 116, 119, 101, 101, 110, 32, 51, 44, 32, 54, 44, 32, 49,
+50, 32, 97, 110, 100, 32, 51, 48, 32, 100, 66, 34, 32, 61, 32, 34, 69, 115, 99, 97, 108, 97, 32, 100,
+111, 32, 103, 114, 195, 161, 102, 105, 99, 111, 58, 32, 99, 108, 105, 113, 117, 101, 32, 112, 97, 114, 97, 32,
+97, 108, 116, 101, 114, 110, 97, 114, 32, 101, 110, 116, 114, 101, 32, 51, 44, 32, 54, 44, 32, 49, 50, 32,
+101, 32, 51, 48, 32, 100, 66, 34, 10, 34, 100, 114, 97, 103, 32, 61, 32, 102, 114, 101, 113, 117, 101, 110,
+99, 121, 32, 97, 110, 100, 32, 103, 97, 105, 110, 32, 40, 67, 116, 114, 108, 32, 102, 105, 110, 101, 44, 32,
+83, 104, 105, 102, 116, 32, 111, 110, 101, 32, 100, 105, 114, 101, 99, 116, 105, 111, 110, 32, 111, 110, 108, 121,
+41, 59, 32, 119, 104, 101, 101, 108, 32, 61, 32, 81, 59, 32, 65, 108, 116, 45, 99, 108, 105, 99, 107, 32,
+111, 114, 32, 100, 111, 117, 98, 108, 101, 45, 99, 108, 105, 99, 107, 32, 61, 32, 114, 101, 109, 111, 118, 101,
+59, 32, 114, 105, 103, 104, 116, 45, 99, 108, 105, 99, 107, 32, 61, 32, 109, 101, 110, 117, 34, 32, 61, 32,
+34, 97, 114, 114, 97, 115, 116, 97, 114, 32, 61, 32, 102, 114, 101, 113, 117, 195, 170, 110, 99, 105, 97, 32,
+101, 32, 103, 97, 110, 104, 111, 32, 40, 67, 116, 114, 108, 32, 102, 105, 110, 111, 44, 32, 83, 104, 105, 102,
+116, 32, 115, 195, 179, 32, 117, 109, 97, 32, 100, 105, 114, 101, 195, 167, 195, 163, 111, 41, 59, 32, 114, 111,
+100, 97, 32, 61, 32, 81, 59, 32, 65, 108, 116, 43, 99, 108, 105, 113, 117, 101, 32, 111, 117, 32, 100, 117,
+112, 108, 111, 32, 99, 108, 105, 113, 117, 101, 32, 61, 32, 114, 101, 109, 111, 118, 101, 114, 59, 32, 98, 111,
+116, 195, 163, 111, 32, 100, 105, 114, 101, 105, 116, 111, 32, 61, 32, 109, 101, 110, 117, 34, 10, 34, 68, 111,
+117, 98, 108, 101, 45, 99, 108, 105, 99, 107, 58, 32, 110, 101, 119, 32, 98, 97, 110, 100, 32, 32, 45, 32,
+32, 100, 114, 97, 103, 58, 32, 102, 114, 101, 113, 117, 101, 110, 99, 121, 32, 47, 32, 103, 97, 105, 110, 32,
+32, 45, 32, 32, 119, 104, 101, 101, 108, 58, 32, 81, 32, 32, 45, 32, 32, 114, 105, 103, 104, 116, 45, 99,
+108, 105, 99, 107, 58, 32, 109, 101, 110, 117, 34, 32, 61, 32, 34, 68, 117, 112, 108, 111, 32, 99, 108, 105,
+113, 117, 101, 58, 32, 110, 111, 118, 97, 32, 98, 97, 110, 100, 97, 32, 32, 45, 32, 32, 97, 114, 114, 97,
+115, 116, 97, 114, 58, 32, 102, 114, 101, 113, 117, 195, 170, 110, 99, 105, 97, 32, 47, 32, 103, 97, 110, 104,
+111, 32, 32, 45, 32, 32, 114, 111, 100, 97, 58, 32, 81, 32, 32, 45, 32, 32, 98, 111, 116, 195, 163, 111,
+32, 100, 105, 114, 101, 105, 116, 111, 58, 32, 109, 101, 110, 117, 34, 10, 34, 80, 114, 111, 99, 101, 115, 115,
+105, 110, 103, 58, 34, 32, 61, 32, 34, 80, 114, 111, 99, 101, 115, 115, 97, 109, 101, 110, 116, 111, 58, 34,
+10, 34, 65, 110, 97, 108, 121, 122, 101, 114, 58, 34, 32, 61, 32, 34, 65, 110, 97, 108, 105, 115, 97, 100,
+111, 114, 58, 34, 10, 34, 68, 101, 116, 101, 99, 116, 111, 114, 58, 34, 32, 61, 32, 34, 68, 101, 116, 101,
+99, 116, 111, 114, 58, 34, 10, 34, 68, 121, 110, 97, 109, 105, 99, 32, 69, 81, 58, 32, 116, 104, 101, 32,
+103, 97, 105, 110, 32, 102, 111, 108, 108, 111, 119, 115, 32, 116, 104, 101, 32, 108, 101, 118, 101, 108, 32, 111,
+102, 32, 116, 104, 101, 32, 98, 97, 110, 100, 39, 115, 32, 114, 101, 103, 105, 111, 110, 32, 40, 116, 104, 114,
+101, 115, 104, 111, 108, 100, 44, 32, 114, 97, 110, 103, 101, 41, 34, 32, 61, 32, 34, 69, 81, 32, 100, 105,
+110, 195, 162, 109, 105, 99, 111, 58, 32, 111, 32, 103, 97, 110, 104, 111, 32, 115, 101, 103, 117, 101, 32, 111,
+32, 110, 195, 173, 118, 101, 108, 32, 100, 97, 32, 114, 101, 103, 105, 195, 163, 111, 32, 100, 97, 32, 98, 97,
+110, 100, 97, 32, 40, 108, 105, 109, 105, 97, 114, 44, 32, 102, 97, 105, 120, 97, 41, 34, 10, 10, 35, 32,
 76, 89, 78, 88, 39, 115, 32, 114, 101, 118, 101, 114, 98, 115, 32, 40, 114, 111, 117, 110, 100, 32, 49, 48,
 48, 41, 10, 34, 67, 111, 110, 99, 101, 114, 116, 32, 72, 97, 108, 108, 124, 80, 108, 97, 116, 101, 124, 82,
 111, 111, 109, 124, 67, 104, 97, 109, 98, 101, 114, 124, 82, 97, 110, 100, 111, 109, 32, 83, 112, 97, 99, 101,

+ 19 - 2
src/ui/MixerComponent.cpp

@@ -10,6 +10,7 @@
 
 #include "core/Effects.h"
 #include "engine/Text.h"
+#include "ui/FacetEqEditor.h"
 #include "ui/ParametricEqEditor.h"
 #include "ui/PluginEditors.h"
 #include "ui/PluginWindow.h"
@@ -1760,7 +1761,7 @@ int EffectsPanel::knobAt (juce::Point<int> p) const
     if (s == nullptr || selectedSlot < 0 || selectedSlot >= (int) s->size())
         return -1;
 
-    if ((*s)[(std::size_t) selectedSlot].kind == EffectKind::parametricEq)
+    if ((*s)[(std::size_t) selectedSlot].kind == EffectKind::parametricEq || (*s)[(std::size_t) selectedSlot].kind == EffectKind::facetEq)
         return -1; // edited in its own window
 
     const auto count = shownParams ((*s)[(std::size_t) selectedSlot]);
@@ -1962,6 +1963,15 @@ void EffectsPanel::paint (juce::Graphics& g)
         return;
     }
 
+    if (slot.kind == EffectKind::facetEq)
+    {
+        const auto button = pluginButtonBounds();
+        drawButton (button, tr ("Open Facet EQ"), Icon::settings);
+        const auto curve = juce::Rectangle<int> (button.getX(), button.getBottom() + 10, button.getWidth(), 120).toFloat();
+        drawFacetEqCurve (g, curve, slot.params, juce::jmax (8000.0, engine.getTransport().sampleRate.load()), slot.enabled);
+        return;
+    }
+
     if (slot.kind == EffectKind::parallel) // container: list the branches
     {
         auto y = knobBounds (0).getY() - 28;
@@ -2213,6 +2223,13 @@ void EffectsPanel::mouseDown (const juce::MouseEvent& e)
         return;
     }
 
+    if (selectedSlot >= 0 && selectedSlot < (int) s->size() && (*s)[(std::size_t) selectedSlot].kind == EffectKind::facetEq
+        && pluginButtonBounds().withHeight (170).contains (e.getPosition()))
+    {
+        FacetEqWindows::open (engine, track, selectedSlot);
+        return;
+    }
+
     if (selectedSlot >= 0 && selectedSlot < (int) s->size() && (*s)[(std::size_t) selectedSlot].kind != EffectKind::volumeGate
         && ! vocoderSelected() && NativeEffectWindows::canOpen ((*s)[(std::size_t) selectedSlot].kind)
         && editorButtonBounds().contains (e.getPosition()))
@@ -2850,7 +2867,7 @@ void EffectsPanel::showSlotMenu (int slot)
                               [assign, t] { assign (t); });
         menu.addSubMenu (title, side);
     };
-    if (kind == EffectKind::compressor || kind == EffectKind::fruityLimiter || kind == EffectKind::fruityCompressor)
+    if (kind == EffectKind::compressor || kind == EffectKind::fruityLimiter || kind == EffectKind::fruityCompressor || kind == EffectKind::facetEq)
         sideMenu (tr ("Sidechain from"), false);
     if (kind == EffectKind::vocoder || kind == EffectKind::vocodex)
     {

+ 181 - 1
src/ui/PluginEditors.cpp

@@ -9,13 +9,16 @@
 #include "core/FlEffects.h"
 #include "core/FruityShapers.h"
 #include "core/GrossBeat.h"
+#include "core/LynxTune.h"
 #include "core/MaximusFx.h"
 #include "core/MixSuite.h"
 #include "core/ParametricEqFl.h"
+#include "core/VocalPitch.h"
 #include "core/PluginLayout.h"
 #include "engine/Text.h"
 #include "ui/I18n.h"
 #include "ui/Icons.h"
+#include "ui/FacetEqEditor.h"
 #include "ui/ParametricEqEditor.h"
 #include "ui/Theme.h"
 #include "ui/ValueControl.h"
@@ -25,6 +28,8 @@ namespace lynx
 {
 namespace
 {
+bool demoDisplays = false; // --plugui: live displays show a synthetic signal
+
 using plugui::Item;
 using plugui::LayoutItem;
 
@@ -70,7 +75,7 @@ public:
         engine.addChangeListener (this);
         const auto& l = activeLayout();
         for (const auto& item : l.items) // live meters (the mixing suite's gain reduction): refreshed at 30 Hz
-            if (item.type == Item::display && item.display != nullptr && std::strcmp (item.display, "grmeter") == 0)
+            if (item.type == Item::display && item.display != nullptr && (std::strcmp (item.display, "grmeter") == 0 || std::strcmp (item.display, "pitchgraph") == 0))
             {
                 startTimerHz (30);
                 break;
@@ -721,6 +726,151 @@ public:
 
     float param01 (const char* name) const { return valueOf (plugui::paramIndex (kind, name)); }
 
+    // LYNX Tune's live display: the read-out on the left (note, cents, Hz, target, correction meter), the last 8 s of
+    // sung (white) and corrected (accent) pitch on the right over the key's note lines
+    void paintPitchDisplay (juce::Graphics& g, juce::Rectangle<float> r, const EffectSlot& fx)
+    {
+        using namespace theme;
+        const auto s = scale();
+        static const char* names[] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
+        auto noteText = [] (int n) { return juce::String (names[((n % 12) + 12) % 12]) + juce::String (n / 12 - 1); };
+
+        std::vector<PitchPoint> history = pitchHistory;
+        if (demoDisplays && history.empty()) // a sung phrase with vibrato and scoops, corrected toward the scale
+            for (std::size_t i = 0; i < pitchHistoryLength; ++i)
+            {
+                const auto t = (float) i / 30.0f;
+                const auto phrase = std::fmod (t, 2.7f);
+                const auto base = t < 2.7f ? 64.0f : t < 5.4f ? 67.0f : 69.0f;
+                const auto sung = phrase < 0.15f ? 0.0f : base - 0.6f * std::exp (-phrase * 5.0f) + 0.35f * std::sin (t * 20.0f) * juce::jmin (1.0f, phrase) + 0.18f;
+                const auto shift = sung > 0.0f ? (base - sung) * (1.0f - std::exp (-phrase * 12.0f)) : 0.0f;
+                history.push_back ({ sung, sung > 0.0f ? base : 0.0f, shift });
+            }
+
+        const auto last = history.empty() ? PitchPoint { 0.0f, 0.0f, 0.0f } : history.back();
+        const auto voiced = last.sung > 0.5f;
+        const auto ref = lynxtune::referenceHz (fx.params[(std::size_t) lynxtune::reference]);
+
+        // --- read-out
+        auto left = r.removeFromLeft (juce::jmin (176.0f * s, r.getWidth() * 0.34f)).reduced (8.0f * s, 6.0f * s);
+        const auto noteArea = left.removeFromTop (left.getHeight() * 0.42f);
+        g.setFont (font (juce::jmax (12.0f, 34.0f * s), true));
+        g.setColour (voiced ? colour::textPrimary : colour::textDisabled);
+        const auto nearest = (int) std::lround (last.sung);
+        g.drawText (voiced ? noteText (nearest) : juce::String ("--"), noteArea.withTrimmedRight (noteArea.getWidth() * 0.4f), juce::Justification::centredLeft);
+        g.setFont (font (juce::jmax (8.0f, 12.0f * s)));
+        g.setColour (colour::textSecondary);
+        if (voiced)
+        {
+            const auto cents = (int) std::lround ((last.sung - (float) nearest) * 100.0f);
+            const auto hzNow = ref * std::exp2 ((last.sung - 69.0f) / 12.0f);
+            const auto side = noteArea.withTrimmedLeft (noteArea.getWidth() * 0.6f);
+            g.drawText ((cents > 0 ? "+" : "") + juce::String (cents) + " c", side.withHeight (side.getHeight() * 0.5f), juce::Justification::bottomLeft);
+            g.drawText (juce::String (hzNow, 1) + " Hz", side.withTrimmedTop (side.getHeight() * 0.5f), juce::Justification::topLeft);
+        }
+        auto row = [&] (const juce::String& caption, const juce::String& value, juce::Colour c) {
+            auto line = left.removeFromTop (juce::jmax (12.0f, 18.0f * s));
+            g.setColour (colour::textDisabled);
+            g.setFont (font (juce::jmax (7.0f, 10.0f * s), true));
+            g.drawText (caption, line, juce::Justification::centredLeft);
+            g.setColour (c);
+            g.setFont (font (juce::jmax (8.0f, 12.0f * s), true));
+            g.drawText (value, line, juce::Justification::centredRight);
+        };
+        row (caps (tr ("Target")), voiced && last.target > 0.5f ? noteText ((int) std::lround (last.target)) : juce::String ("--"), colour::accent);
+        const auto corrCents = (int) std::lround (last.shift * 100.0f);
+        row (caps (tr ("Correction")), voiced ? (corrCents > 0 ? "+" : "") + juce::String (corrCents) + " c" : juce::String ("--"), colour::textPrimary);
+        // the correction meter: ±100 cents from the centre
+        auto bar = left.removeFromTop (juce::jmax (6.0f, 9.0f * s)).reduced (0.0f, 1.0f);
+        g.setColour (colour::bg3);
+        g.fillRoundedRectangle (bar, radius::sm);
+        g.setColour (colour::gridBar);
+        g.drawVerticalLine ((int) bar.getCentreX(), bar.getY() - 2.0f, bar.getBottom() + 2.0f);
+        if (voiced)
+        {
+            const auto amount = juce::jlimit (-1.0f, 1.0f, last.shift);
+            const auto x0 = bar.getCentreX(), x1 = bar.getCentreX() + bar.getWidth() * 0.5f * amount;
+            g.setColour ((fx.enabled ? colour::accent : colour::textDisabled).withAlpha (0.9f));
+            g.fillRoundedRectangle (juce::Rectangle<float> (juce::jmin (x0, x1), bar.getY(), std::abs (x1 - x0) + 1.0f, bar.getHeight()), radius::sm);
+        }
+
+        // --- graph
+        auto graph = r.reduced (6.0f * s, 6.0f * s);
+        g.setColour (colour::bg1);
+        g.fillRoundedRectangle (graph, radius::sm * s);
+        // vertical range: ±7 semitones around the recent pitch (follows the voice)
+        float centre = 0.0f;
+        int count = 0;
+        for (auto i = history.size() > 60 ? history.size() - 60 : 0; i < history.size(); ++i)
+            if (history[i].sung > 0.5f) { centre += history[i].sung; ++count; }
+        centre = count > 0 ? std::round (centre / (float) count) : (displayCentre > 0.0f ? displayCentre : 60.0f);
+        displayCentre = displayCentre <= 0.0f ? centre : displayCentre + 0.15f * (centre - displayCentre);
+        const auto span = 7.5f;
+        auto yFor = [&] (float note) { return graph.getCentreY() - (note - displayCentre) / span * graph.getHeight() * 0.5f; };
+        // note lanes: the scale's notes brighter, C labelled
+        const auto mask = vocal::scaleMask ((vocal::Scale) lynxtune::scaleIndex (fx.params[(std::size_t) lynxtune::scale]),
+                                            lynxtune::keyIndex (fx.params[(std::size_t) lynxtune::key]), 0xfff);
+        g.saveState();
+        g.reduceClipRegion (graph.toNearestInt());
+        g.setFont (font (juce::jmax (7.0f, 9.0f * s)));
+        for (int n = (int) std::floor (displayCentre - span) - 1; n <= (int) std::ceil (displayCentre + span) + 1; ++n)
+        {
+            const auto inScale = ((mask >> (((n % 12) + 12) % 12)) & 1) != 0;
+            const auto on = fx.params[(std::size_t) (lynxtune::noteC + ((n % 12) + 12) % 12)] >= 0.5f;
+            const auto y = yFor ((float) n);
+            g.setColour (inScale && on ? colour::gridBar : colour::gridStep);
+            g.drawHorizontalLine ((int) y, graph.getX(), graph.getRight());
+            if (inScale && on)
+            {
+                g.setColour (colour::textDisabled);
+                g.drawText (noteText (n), juce::Rectangle<float> (graph.getX() + 3.0f, y - 7.0f, 30.0f * s, 12.0f), juce::Justification::centredLeft);
+            }
+        }
+        // the curves, newest on the right
+        const auto stepX = graph.getWidth() / (float) (pitchHistoryLength - 1);
+        const auto x0 = graph.getRight() - stepX * (float) (history.size() - 1);
+        for (int which = 0; which < 2; ++which)
+        {
+            juce::Path p;
+            bool open = false;
+            for (std::size_t i = 0; i < history.size(); ++i)
+            {
+                const auto& h = history[i];
+                if (h.sung <= 0.5f) { open = false; continue; }
+                const auto x = x0 + stepX * (float) i;
+                const auto y = yFor (which == 0 ? h.sung : h.sung + h.shift);
+                if (! open) p.startNewSubPath (x, y);
+                else p.lineTo (x, y);
+                open = true;
+            }
+            if (which == 0)
+            {
+                g.setColour (colour::textSecondary.withAlpha (0.8f));
+                g.strokePath (p, juce::PathStrokeType (1.2f * s));
+            }
+            else
+            {
+                g.setColour (colour::accent.withAlpha (0.25f));
+                g.strokePath (p, juce::PathStrokeType (5.0f * s, juce::PathStrokeType::curved, juce::PathStrokeType::rounded));
+                g.setColour (fx.enabled ? colour::accent : colour::textDisabled);
+                g.strokePath (p, juce::PathStrokeType (2.0f * s, juce::PathStrokeType::curved, juce::PathStrokeType::rounded));
+            }
+        }
+        g.restoreState();
+        if (history.empty() || std::none_of (history.begin(), history.end(), [] (const PitchPoint& h) { return h.sung > 0.5f; }))
+        {
+            g.setColour (colour::textDisabled);
+            g.setFont (font (juce::jmax (8.0f, 12.0f * s)));
+            g.drawText (tr ("Play a voice or an instrument through the insert to see its pitch"), graph, juce::Justification::centred, true);
+        }
+        // legend
+        g.setFont (font (juce::jmax (7.0f, 9.0f * s)));
+        g.setColour (colour::textSecondary);
+        g.drawText (tr ("input"), graph.removeFromTop (14.0f * s).removeFromRight (120.0f * s).withTrimmedRight (6.0f), juce::Justification::centredLeft);
+        g.setColour (colour::accent);
+        g.drawText (tr ("corrected"), graph.withHeight (14.0f * s).withY (graph.getY() - 14.0f * s).removeFromRight (64.0f * s), juce::Justification::centredLeft);
+    }
+
     // the live meter `output` of this slot's effect (published by the audio thread; 0 when not playing)
     float liveMeter (int output) const
     {
@@ -1053,6 +1203,11 @@ public:
                 return 0.6f + bump - (x > cutoff ? (x - cutoff) * 2.2f : 0.0f);
             }, inner, true);
         }
+        else if (id == "pitchgraph") // LYNX Tune: detected pitch, target, correction and the scrolling pitch graph
+        {
+            paintPitchDisplay (g, r, fx);
+            return;
+        }
         else if (id == "grmeter") // live gain reduction of the mixing suite (0..30 dB, from the right like a VU's GR)
         {
             const auto amount = juce::jlimit (0.0f, 1.0f, liveMeter (item.steps));
@@ -1909,8 +2064,18 @@ private:
     void timerCallback() override
     {
         for (const auto& item : activeLayout().items)
+        {
+            if (item.type == Item::display && item.display != nullptr && std::strcmp (item.display, "pitchgraph") == 0 && visible (item))
+            {
+                // LYNX Tune's pitch history (30 points a second)
+                pitchHistory.push_back ({ liveMeter (0) * 127.0f, liveMeter (1) * 127.0f, (liveMeter (2) - 0.5f) * 4.0f });
+                if (pitchHistory.size() > pitchHistoryLength)
+                    pitchHistory.erase (pitchHistory.begin(), pitchHistory.begin() + (std::ptrdiff_t) (pitchHistory.size() - pitchHistoryLength));
+                repaint (rectOf (item).getSmallestIntegerContainer());
+            }
             if (item.type == Item::display && item.display != nullptr && std::strcmp (item.display, "grmeter") == 0 && visible (item))
                 repaint (rectOf (item).getSmallestIntegerContainer());
+        }
     }
 
     AudioEngine& engine;
@@ -1923,6 +2088,10 @@ private:
     juce::String presetName;
     int eqSelected = -1;
     bool eqDragging = false, xyDragging = false, sgDragging = false;
+    struct PitchPoint { float sung, target, shift; }; // MIDI note numbers (0 = none) and the applied correction in semitones
+    static constexpr std::size_t pitchHistoryLength = 240; // 8 s
+    std::vector<PitchPoint> pitchHistory;
+    float displayCentre = 0.0f;
     float sgStart = 0.0f;
     std::array<std::vector<std::uint8_t>, 4> sgPresets {}; // the installation's preset files A–D (read on demand)
     juce::Point<float> eqDragOffset;
@@ -1972,6 +2141,11 @@ void NativeEffectWindow::closeButtonPressed()
 }
 } // namespace
 
+void setNativeEditorDemo (bool on)
+{
+    demoDisplays = on;
+}
+
 std::unique_ptr<juce::Component> makeNativeEffectEditor (AudioEngine& engine, int track, int slot, float scale, int page)
 {
     return std::make_unique<NativeEffectEditor> (engine, track, slot, scale, page);
@@ -1998,6 +2172,11 @@ void open (AudioEngine& engine, int track, int slot)
         ParametricEqWindows::open (engine, track, slot);
         return;
     }
+    if (kind == EffectKind::facetEq) // its own editor (analyser, nodes, dynamics; REA round 103)
+    {
+        FacetEqWindows::open (engine, track, slot);
+        return;
+    }
 
     auto& open = windows();
     const auto key = std::make_pair (track, slot);
@@ -2021,6 +2200,7 @@ void open (AudioEngine& engine, int track, int slot)
 void closeAll()
 {
     windows().clear();
+    FacetEqWindows::closeAll();
 }
 } // namespace NativeEffectWindows
 } // namespace lynx

+ 2 - 0
src/ui/PluginEditors.h

@@ -21,4 +21,6 @@ void closeAll();
 
 // The editor alone at `scale` (1 = FL's size; for --snapshot / --plugui).
 std::unique_ptr<juce::Component> makeNativeEffectEditor (AudioEngine& engine, int track, int slot, float scale = 1.0f, int page = 0);
+// --plugui: live displays (LYNX Tune's pitch graph) draw a synthetic signal instead of waiting for audio
+void setNativeEditorDemo (bool on);
 } // namespace lynx

+ 253 - 0
tests/FacetTests103.inc

@@ -0,0 +1,253 @@
+// --- Facet EQ round 103: dynamic EQ, phase modes, solo, sidechain detector (core/FacetEq.h, REA_rodada103) -----------
+
+namespace facet103
+{
+using namespace lynx::facet;
+
+lynx::EffectParams defaults()
+{
+    lynx::EffectParams p {};
+    const auto& in = info();
+    for (std::size_t i = 0; i < in.params.size(); ++i) p[i] = in.params[i].defaultValue;
+    return p;
+}
+
+lynx::EffectParams bell (double f, double g, double qq)
+{
+    auto p = defaults();
+    p[(std::size_t) param (0, 0)] = shapeValue (Shape::bell);
+    p[(std::size_t) param (0, 1)] = hzValue (f);
+    p[(std::size_t) param (0, 2)] = gainValue (g);
+    p[(std::size_t) param (0, 3)] = qValue (qq);
+    return p;
+}
+
+// level (dB re `amp`) of the tone `f` in the last 0.2 s of the processed signal, phase-aligned to the latency
+double toneDb (lynx::Effect& e, const lynx::EffectParams& p, double f, double amp, double secs, const std::vector<float>* side = nullptr,
+               double sideAmp = 0.0, double sideHz = 0.0)
+{
+    const double sr = 48000.0;
+    const int n = (int) (secs * sr);
+    std::vector<float> l ((std::size_t) n), r ((std::size_t) n), sl ((std::size_t) n), sr2 ((std::size_t) n);
+    for (int i = 0; i < n; ++i)
+    {
+        l[(std::size_t) i] = r[(std::size_t) i] = (float) (amp * std::sin (2.0 * 3.14159265358979 * f * i / sr));
+        sl[(std::size_t) i] = sr2[(std::size_t) i] = (float) (sideAmp * std::sin (2.0 * 3.14159265358979 * sideHz * i / sr));
+    }
+    (void) side;
+    for (int o = 0; o < n; o += 480)
+    {
+        const int m = std::min (480, n - o);
+        if (sideAmp > 0.0) e.setSidechain (sl.data() + o, sr2.data() + o);
+        e.process (l.data() + o, r.data() + o, m, p, 120.0);
+    }
+    const int lat = e.latencySamples();
+    const int w = (int) (0.2 * sr);
+    double c = 0.0, s = 0.0;
+    for (int i = n - w; i < n; ++i)
+    {
+        const double ph = 2.0 * 3.14159265358979 * f * (i - lat) / sr;
+        c += l[(std::size_t) i] * std::cos (ph);
+        s += l[(std::size_t) i] * std::sin (ph);
+    }
+    return 20.0 * std::log10 (2.0 * std::sqrt (c * c + s * s) / w / amp + 1e-12);
+}
+} // namespace facet103
+
+TEST (facet_eq_new_parameters_keep_old_behaviour_round103)
+{
+    using namespace lynx::facet;
+    // the 22 appended controls default to the round-99 behaviour, so older projects load unchanged
+    const auto p = facet103::defaults();
+    CHECK (info().params.size() == 64 && paramCount == 64 && paramCount <= lynx::maxEffectParams);
+    for (int b = 0; b < bands; ++b)
+    {
+        CHECK (std::abs (rangeDb (p[(std::size_t) (rangeParam0 + b)])) < 1e-6);
+        CHECK (! isDynamic (p, b));
+    }
+    CHECK (phase (p[(std::size_t) phaseParam]) == Phase::zeroLatency);
+    CHECK (soloBand (p[(std::size_t) soloParam]) == -1);
+    CHECK (! sidechainDetector (p[(std::size_t) detectorParam]));
+    auto e = make (&p);
+    e->prepare (48000.0);
+    CHECK (e->latencySamples() == 0);
+    // laws round-trip
+    CHECK (std::abs (rangeDb (rangeValue (-12.0)) + 12.0) < 0.01);
+    CHECK (std::abs (thresholdDb (thresholdValue (-30.0)) + 30.0) < 0.01);
+    CHECK (soloBand (soloValue (3)) == 3 && soloBand (soloValue (-1)) == -1);
+    for (int m = 0; m < phaseCount; ++m) CHECK ((int) phase (phaseValue ((Phase) m)) == m);
+    CHECK (std::abs (attackMs (0.5f) - 3.54) < 0.05 && std::abs (releaseMs (0.5f) - 282.8) < 1.0);
+    CHECK (lynx::formatEffectParam (lynx::EffectKind::facetEq, phaseParam, phaseValue (Phase::linear), 120.0) == "Linear Phase");
+    CHECK (lynx::formatEffectParam (lynx::EffectKind::facetEq, rangeParam0 + 2, rangeValue (-6.0), 120.0) == "-6.00 dB");
+}
+
+TEST (facet_eq_dynamic_gain_law_matches_measured_reference_round103)
+{
+    // REA_rodada103 §2.1: threshold −30, range −12; measured steps (dB of gain change at sine-peak levels)
+    const std::pair<double, double> measured[] = { { -40, 0.0 }, { -34, -0.1 }, { -32, -0.5 }, { -30, -1.3 }, { -28, -2.5 }, { -26, -4.1 },
+                                                   { -24, -6.0 }, { -22, -8.0 }, { -20, -10.0 }, { -18, -12.0 }, { -6, -12.0 } };
+    for (const auto& [level, gain] : measured)
+        CHECK (std::abs (lynx::facet::dynamicGainDb (level, -30.0, -12.0) - gain) < 0.12);
+    // a positive range mirrors it; the range clamps
+    CHECK (std::abs (lynx::facet::dynamicGainDb (-24.0, -30.0, 12.0) - 6.0) < 1e-9);
+    CHECK (std::abs (lynx::facet::dynamicGainDb (0.0, -30.0, -6.0) + 6.0) < 1e-9);
+}
+
+TEST (facet_eq_dynamic_band_in_every_phase_mode_round103)
+{
+    using namespace lynx::facet;
+    auto p = facet103::bell (1000.0, 0.0, 1.0);
+    p[(std::size_t) rangeParam0] = rangeValue (-12.0);
+    p[(std::size_t) thresholdParam0] = thresholdValue (-30.0);
+    CHECK (isDynamic (p, 0));
+    for (int m = 0; m < phaseCount; ++m)
+    {
+        p[(std::size_t) phaseParam] = phaseValue ((Phase) m);
+        for (const auto& [level, expect] : { std::pair { -50.0, 0.0 }, { -24.0, -6.0 }, { -6.0, -12.0 } })
+        {
+            auto e = make (&p);
+            e->prepare (48000.0);
+            CHECK (e->latencySamples() == latencyFor ((Phase) m, 48000.0));
+            const auto got = facet103::toneDb (*e, p, 1000.0, std::pow (10.0, level / 20.0), 1.2);
+            if (std::abs (got - expect) >= 0.45) std::printf ("  facet dyn mode %d level %.0f: %.2f vs %.2f\n", m, level, got, expect);
+            CHECK (std::abs (got - expect) < 0.45);
+            CHECK (std::abs (e->controlOutput (0) * 60.0f - (float) expect) < 0.5f); // the live meter the editor shows
+        }
+    }
+    // static gain + dynamic range: +6 below the threshold, −6 above (as measured)
+    p = facet103::bell (1000.0, 6.0, 1.0);
+    p[(std::size_t) rangeParam0] = rangeValue (-12.0);
+    p[(std::size_t) thresholdParam0] = thresholdValue (-30.0);
+    auto e = make (&p);
+    e->prepare (48000.0);
+    CHECK (std::abs (facet103::toneDb (*e, p, 1000.0, std::pow (10.0, -50.0 / 20.0), 1.0) - 6.0) < 0.2);
+    CHECK (std::abs (facet103::toneDb (*e, p, 1000.0, std::pow (10.0, -6.0 / 20.0), 1.0) + 6.0) < 0.4);
+}
+
+TEST (facet_eq_sidechain_detector_round103)
+{
+    using namespace lynx::facet;
+    auto p = facet103::bell (1000.0, 0.0, 1.0);
+    p[(std::size_t) rangeParam0] = rangeValue (-12.0);
+    p[(std::size_t) thresholdParam0] = thresholdValue (-30.0);
+    p[(std::size_t) detectorParam] = 1.0f;
+    // a quiet input (below the threshold) ducked by a loud sidechain in the band
+    auto e = make (&p);
+    e->prepare (48000.0);
+    const auto ducked = facet103::toneDb (*e, p, 1000.0, 0.003, 1.0, nullptr, 0.5, 1000.0);
+    CHECK (std::abs (ducked + 12.0) < 0.5);
+    // the detector set to the sidechain but nothing routed: the input is detected
+    auto e2 = make (&p);
+    e2->prepare (48000.0);
+    CHECK (std::abs (facet103::toneDb (*e2, p, 1000.0, 0.003, 1.0)) < 0.2);
+    // a sidechain outside the band does not trigger it
+    auto e3 = make (&p);
+    e3->prepare (48000.0);
+    CHECK (std::abs (facet103::toneDb (*e3, p, 1000.0, 0.003, 1.0, nullptr, 0.05, 8000.0)) < 0.3); // −26 dB three octaves away: under the threshold
+}
+
+TEST (facet_eq_phase_modes_round103)
+{
+    using namespace lynx::facet;
+    // magnitude: the analog prototype in both FIR modes (also near Nyquist, where zero latency deviates)
+    auto p = facet103::bell (10000.0, 6.0, 2.0);
+    p[(std::size_t) param (1, 0)] = shapeValue (Shape::lowCut);
+    p[(std::size_t) param (1, 1)] = hzValue (100.0);
+    p[(std::size_t) param (1, 4)] = slopeValue (24);
+    CHECK (latencyFor (Phase::natural, 48000.0) == 320 && latencyFor (Phase::natural, 96000.0) == 640);
+    CHECK (latencyFor (Phase::linear, 48000.0) == 4608 && latencyFor (Phase::zeroLatency, 44100.0) == 0);
+    for (const auto m : { Phase::natural, Phase::linear })
+    {
+        p[(std::size_t) phaseParam] = phaseValue (m);
+        for (const double f : { 100.0, 1000.0, 5000.0, 10000.0, 15000.0 })
+        {
+            auto e = make (&p);
+            e->prepare (48000.0);
+            const auto got = facet103::toneDb (*e, p, f, 0.1, 0.6);
+            const auto want = analogDb (p, 0, f) + analogDb (p, 1, f);
+            if (std::abs (got - want) >= 0.2) std::printf ("  facet mode %d %.0f Hz: %.3f vs %.3f\n", (int) m, f, got, want);
+            CHECK (std::abs (got - want) < 0.2);
+            CHECK (std::abs (bandResponseDb (p, 0, 48000.0, f) - analogDb (p, 0, f)) < 1e-9); // the editor's curve
+        }
+    }
+    // linear phase: a symmetric impulse response centred on the latency
+    {
+        auto lp = facet103::bell (1000.0, 9.0, 3.0);
+        lp[(std::size_t) phaseParam] = phaseValue (Phase::linear);
+        auto e = make (&lp);
+        e->prepare (48000.0);
+        const int lat = e->latencySamples(), n = lat * 2 + 2048;
+        std::vector<float> l ((std::size_t) n, 0.0f), r ((std::size_t) n, 0.0f);
+        l[0] = r[0] = 1.0f;
+        for (int o = 0; o < n; o += 256) e->process (l.data() + o, r.data() + o, std::min (256, n - o), lp, 120.0);
+        float peak = 0.0f;
+        int at = 0;
+        for (int i = 0; i < n; ++i)
+            if (std::abs (l[(std::size_t) i]) > peak) { peak = std::abs (l[(std::size_t) i]); at = i; }
+        CHECK (at == lat);
+        double asym = 0.0;
+        for (int k = 1; k < 1500; ++k) asym = std::max (asym, (double) std::abs (l[(std::size_t) (lat + k)] - l[(std::size_t) (lat - k)]));
+        CHECK (asym < 1e-4);
+        CHECK (std::abs (l[(std::size_t) lat] - r[(std::size_t) lat]) < 1e-6f);
+    }
+    // natural phase: nothing comes out before the latency minus its short pre-ring
+    {
+        auto np = facet103::bell (1000.0, 9.0, 3.0);
+        np[(std::size_t) phaseParam] = phaseValue (Phase::natural);
+        auto e = make (&np);
+        e->prepare (48000.0);
+        const int n = 4096;
+        std::vector<float> l ((std::size_t) n, 0.0f), r ((std::size_t) n, 0.0f);
+        l[0] = r[0] = 1.0f;
+        for (int o = 0; o < n; o += 128) e->process (l.data() + o, r.data() + o, 128, np, 120.0);
+        double before = 0.0, total = 0.0;
+        for (int i = 0; i < n; ++i)
+        {
+            total += (double) l[(std::size_t) i] * l[(std::size_t) i];
+            if (i < 128) before += (double) l[(std::size_t) i] * l[(std::size_t) i];
+        }
+        CHECK (before < 1e-12 && total > 0.5);
+    }
+    // switching mode at run time changes the reported latency (PDC re-plans)
+    {
+        auto sp = facet103::bell (1000.0, 3.0, 1.0);
+        auto e = make (&sp);
+        e->prepare (48000.0);
+        std::vector<float> l (256, 0.0f), r (256, 0.0f);
+        e->process (l.data(), r.data(), 256, sp, 120.0);
+        CHECK (e->latencySamples() == 0);
+        sp[(std::size_t) phaseParam] = phaseValue (Phase::natural);
+        e->process (l.data(), r.data(), 256, sp, 120.0);
+        CHECK (e->latencySamples() == 320);
+    }
+}
+
+TEST (facet_eq_solo_band_round103)
+{
+    using namespace lynx::facet;
+    auto p = facet103::bell (1000.0, 6.0, 2.0);
+    p[(std::size_t) soloParam] = soloValue (0);
+    auto e = make (&p);
+    e->prepare (48000.0);
+    CHECK (std::abs (facet103::toneDb (*e, p, 1000.0, 0.25, 0.5)) < 0.3); // the band's centre passes
+    auto e2 = make (&p);
+    e2->prepare (48000.0);
+    CHECK (facet103::toneDb (*e2, p, 8000.0, 0.25, 0.5) < -15.0);         // far away is gone
+    // solo of a band that is off: no effect
+    p[(std::size_t) param (0, 0)] = 0.0f;
+    auto e3 = make (&p);
+    e3->prepare (48000.0);
+    CHECK (std::abs (facet103::toneDb (*e3, p, 8000.0, 0.25, 0.5)) < 0.05);
+}
+
+TEST (live_meters_cover_facet_and_tune_round103)
+{
+    // Facet EQ publishes 8 dynamic gains, LYNX Tune 3 pitch values; the analyser tap ring is a power of two
+    CHECK (lynx::ProcessTimes::meterOutputs >= 8);
+    CHECK ((lynx::ProcessTimes::AnalyzerTap::size & (lynx::ProcessTimes::AnalyzerTap::size - 1)) == 0);
+    const auto& l = lynx::plugui::layoutFor (lynx::EffectKind::lynxTune);
+    bool graph = false;
+    for (const auto& item : l.items)
+        graph = graph || (item.type == lynx::plugui::Item::display && item.display != nullptr && std::string (item.display) == "pitchgraph");
+    CHECK (graph);
+}

+ 1 - 0
tests/tests.cpp

@@ -15607,3 +15607,4 @@ TEST (plugin_layout_options_match_the_engine_values)
 #include "FabMeasureTests99.inc"
 #include "LynxTuneTests95.inc"
 #include "LynxVerbTests100.inc"
+#include "FacetTests103.inc"