Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.
C# audioaudio-unitavaloniacpp20cross-platformdawdigital-audio-workstationdspjucelinux-audiomcp-servermidimusicmusic-productionpiano-rollplugin-hostsequencersynthesizervstvst3
(feat) EQ-8 band labels and notes (#369)
Chris Laupamaba20a32ab100
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 328607d4..73b922b2 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -23,6 +23,12 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.## [Unreleased]### Added+- **Band labels and notes in EQ-8** (#135): name a band in the band panel's new **Label** field+ and the name shows next to its node in the graph (and on its chip); click the label, or+ **Note**, for a multiline note on what the band is for. Labels that would overlap move apart,+ **Labels** next to Peak hides them, and they are saved with the project, in user presets and+ in copies, each edit one undo step. The sound is unchanged. MCP `read_eq8` returns each band's+ label and note and `set_eq8_band` sets them.- **A proper spectrum analyzer in EQ-8 and EQ-3** (#265): the spectrum behind the curve is nowa smooth, filled area that rises at once and falls back over about 300 ms, read from 256points in 1/6-octave bands, so a tone reads at its own level and pink noise reads flat. EQ-8diff --git a/specs/049-eq-band-labels/plan.md b/specs/049-eq-band-labels/plan.mdnew file mode 100644index 00000000..3bb6188d--- /dev/null+++ b/specs/049-eq-band-labels/plan.md@@ -0,0 +1,69 @@+# Implementation Plan: EQ band labels and notes++**Branch**: `feat/eq-band-labels` | **Spec**: [spec.md](spec.md) | **Issue**: nota-daw/nota#135++## Summary++EQ-8 gets a label and a note per band slot, kept by the device (message-thread data, never read+by `process()`), saved through the device's state blob, and edited through one engine call that+is one undo step. The graph draws the labels next to their nodes with a simple collision pass;+a click on a label opens a note popup. A new display-only parameter, **Labels**, hides them.++## Technical Context++- **Engine**: `Eq` (`devices/effects/Eq.h/.cpp`) keeps `label_[8]`, `note_[8]` as `std::string`.+ `getState()` returns them (empty when there are none, so a plain EQ-8 saves exactly as before);+ `setState()` reads them. The audio thread never touches them.+- **State format**: `"NEQ1"`, then for each of 8 bands: u16 label length, label bytes (UTF-8),+ u16 note length, note bytes. Unknown magic or a short blob reads as "no annotations".+- **Undo**: a new `MixKind::DeviceNotes` (7). `Engine::setEqBandText(track, device, band, label,+ note)` appends the device's whole annotation blob before and after the edit to an+ append-only table (`noteStates_`, index 0 = empty) and pushes a mix-only `UndoEntry` whose+ before/after are those indices. `applyMix` restores the blob with `Device::setState`. This is+ the preset-tag pattern (specs/048) without a per-device tag: the device's own text is the+ current value, so loading a project needs no table entry.+- **Copies**: device copy / duplicate and track duplicate already copy `getState()` for built-ins+ (`Engine_Devices.cpp`), so annotations follow with no change.+- **Presets**: `PresetService.Capture` saves an EQ-8's labels and notes as a readable+ `BandText` list (band, label, note) in the preset JSON; `Apply` / `ApplyInPlace` give the+ device exactly that list (none for a factory preset), and `ResetInPlace` (Init) clears it.+ Other built-ins keep today's preset format.+- **Labels switch**: `Eq::Labels` appended as param 62 (0/1, default 1, display only, like+ AnaPeak). Older projects lack it and get the default.+- **C ABI**: `nota_eq_set_band_text(engine, track, device, band, label, note)` and+ `nota_eq_band_text(engine, track, device, band, which /*0 label, 1 note*/, buf, cap)` (UTF-8,+ returns the required size). Wrapped as `IAudioEngine.EqSetBandText` / `EqBandText`.+- **MCP**: `Eq::deviceText` lists labelled bands and their notes.+- **UI** (`Eq8Views.cs`, `EqDeviceBody.cs`):+ - `Eq8Curve` draws labels: each label is a pill above its node (below for nodes in the top+ third); a greedy pass in frequency order moves a label up/down by its height until it no+ longer overlaps a placed one, clamps it inside the graph, ellipsizes if still no room, and+ draws a leader line when it moved off its node. Note mark = small dot at the pill's right.+ - Hit-testing a label happens before node hit-testing only for a click (press + release without+ a move); drags start on nodes as before.+ - Note popup: a `Popup` with a label `TextBox` (MaxLength 24, no line breaks) and a note+ `TextBox` (AcceptsReturn, MaxLength 2000); commit on close / Ctrl-Cmd+Enter; Escape closes.+ - Band panel: Label field + Note button; chips show the label in place of the type.+ - Labels switch next to Peak in the analyzer bar.+- **Empty-space bell**: `Eq8Curve.AddBandAt` clears the chosen slot's annotation in the same undo+ group as the band's params.++## Constitution Check++- Audio thread: no new audio-thread work; `process()` unchanged. ✓+- C ABI stays pure C (char pointers, ints). ✓+- No new dependency. ✓+- Docs EN + RU, CHANGELOG entry. ✓++## Testing++- Smoke test `--eq-labels`:+ - set labels/notes on bands, read them back;+ - get/set state round trip (byte-identical);+ - an empty EQ-8 has an empty state blob;+ - undo / redo of an edit;+ - device duplicate keeps them;+ - render a signal with and without annotations: identical output;+ - UTF-8 (Cyrillic) round trip; over-long text is truncated to the limits.+- Project round trip via `ProjectService` in the same test.+- Preset capture / apply round trip.diff --git a/specs/049-eq-band-labels/spec.md b/specs/049-eq-band-labels/spec.mdnew file mode 100644index 00000000..268de4a3--- /dev/null+++ b/specs/049-eq-band-labels/spec.md@@ -0,0 +1,177 @@+# Feature Specification: EQ band labels and notes++**Feature Branch**: `feat/eq-band-labels`++**Created**: 2026-10-28++**Status**: Draft++**Input**: User description: "Always-visible custom EQ band labels with expandable notes+(nota-daw/nota#135). Every EQ band gets an optional short label shown next to its node in the+graph, and clicking the label opens a larger multiline note. Labels and notes save with the+project and preset, stay with their band when it moves, avoid colliding with each other, can be+hidden all at once, and don't touch the DSP."++## User Scenarios & Testing *(mandatory)*++### User Story 1 - Name a band so its purpose is visible at a glance (Priority: P1)++A mixer cuts a narrow resonance at 2.4 kHz on a vocal EQ-8. They name band 4 "Resonance" and it+shows next to the node in the graph. Weeks later they open the project and know straight away+what that dip is for.++**Why this priority**: The label in the graph is the heart of the request; notes and the toggle+build on it.++**Independent Test**: Name a band, see the label next to its node, drag the node and see the+label follow, save, reopen, and see it again.++**Acceptance Scenarios**:++1. **Given** an EQ-8 with band 4 selected, **When** the user types "Resonance" into the band's+ Label field in the band panel, **Then** "Resonance" appears next to band 4's node in the graph+ and on band 4's chip in place of the band type.+2. **Given** a labelled band, **When** the user drags its node, changes its type, gain, Q, slope+ or channel, or switches it off, **Then** the label stays with that band (dimmed while the band+ is off) and follows the node.+3. **Given** a labelled band, **When** the project is saved and reopened, **Then** the label comes+ back on the same band.+4. **Given** a labelled band, **When** the user saves the EQ as a preset and loads that preset+ onto another EQ-8, **Then** the label comes with it. **When** they load a factory preset or+ Init, **Then** the labels are those of that preset (none for factory presets).+5. **Given** a labelled EQ-8, **When** the user duplicates the device or the track, or copies it+ to another track, **Then** the copy has the same labels.+6. **Given** a band label field, **When** the user clears it, **Then** the node shows no label and+ the chip shows the band type again.+7. **Given** a label longer than 24 characters, **Then** the field stops accepting more; leading+ and trailing spaces are trimmed, and a pasted line break becomes a space.++---++### User Story 2 - Write a longer note on a band (Priority: P2)++The user wants to remember why: "Narrow cut for the ring on sustained notes. Don't go past −6 dB+or it gets hollow." They click the band's label in the graph and a note box opens beside it;+they type the note and click away.++**Why this priority**: Notes are the "expandable" half of the request; useful, but a label alone+already answers "what is this band?".++**Independent Test**: Click a label in the graph, type a multiline note, close it, reopen the+project and click the label again to read the note.++**Acceptance Scenarios**:++1. **Given** a labelled band, **When** the user clicks its label in the graph, **Then** a note+ popup opens next to the label with the band's label (editable) and a multiline note field, and+ the band becomes the selected band.+2. **Given** the note popup, **When** the user types and then presses Escape, clicks outside or+ presses Ctrl/Cmd+Enter, **Then** the popup closes and the text is kept.+3. **Given** a band with a note, **Then** its label in the graph shows a small note mark, and+ hovering the label shows the first lines of the note as a tooltip.+4. **Given** a band with a note but no label, **Then** the graph shows the note mark alone next to+ the node, so the note can still be opened.+5. **Given** the band panel, **Then** it has a "Note" button that opens the same popup for the+ selected band, with or without a label, so the popup can be reached with the keyboard.+6. **Given** a note up to 2000 characters, **Then** it is saved and restored exactly (line breaks+ included); the field stops accepting more past that.++---++### User Story 3 - Keep the graph readable (Priority: P2)++Two labelled bands sit close together around 200 Hz. Their labels don't overlap. When the user+is doing detailed curve work they hide all labels with one switch, and show them again later.++**Why this priority**: Without collision handling and a hide switch, labels get in the way on+busy curves.++**Independent Test**: Label three bands within half an octave of each other and see three+readable, non-overlapping labels; switch Labels off and see none; switch them on again.++**Acceptance Scenarios**:++1. **Given** labels that would overlap, **Then** the graph moves them apart vertically (above or+ below their nodes, then further out) so no two labels overlap and each one stays connected to+ its node by position or a thin leader line.+2. **Given** a label near the graph's edge, **Then** it stays fully inside the graph.+3. **Given** the Labels switch in the EQ-8's analyzer bar, **When** the user turns it off,+ **Then** no labels or note marks are drawn in the graph (chips and the band panel still show+ them); turning it on brings them back. The switch is saved with the device and is on by+ default.+4. **Given** labels shown, **Then** dragging a node, double-clicking a node or empty space, the+ wheel over a node and the right-click menu work exactly as before; only a click on a label+ itself opens the note.++### Edge Cases++- **New band from empty space**: double-clicking empty space turns on a free (off) band as a+ bell. If that band still has a label or note from earlier, they are cleared, since it is now a+ new band.+- **Reset / Init**: loading Init or a factory preset replaces labels and notes with that preset's+ (none). Resetting a single band's parameters (double-click on a knob) leaves its label alone.+- **Older projects and presets**: an EQ-8 saved before this change opens with no labels and+ Labels on; nothing else changes.+- **Undo**: a label or note edit is one undo step, committed when the field loses focus or the+ popup closes, not one step per keystroke.+- **Automation, MIDI learn, A/B**: labels are not parameters and can't be automated or learned.+ A/B compare swaps parameter values only and leaves labels as they are.+- **Text content**: any Unicode text is allowed, including Cyrillic; a tab becomes a space, a+ line break is kept in a note and becomes a space in a label, and other control characters are+ dropped.+- **Narrow card / small graph**: when a label can't be placed without overlapping after moving+ it apart, it is shortened with an ellipsis; the full label is in the tooltip.++## Requirements *(mandatory)*++### Functional Requirements++- **FR-001**: Each of the EQ-8's eight bands MUST have an optional label (up to 24 characters,+ one line) and an optional note (up to 2000 characters, multiline), tied to the band's slot so+ they follow it through every parameter change.+- **FR-002**: Labels, notes and the Labels switch MUST be saved and restored with the project, with+ user presets, and carried by device copy, device duplicate and track duplicate.+- **FR-003**: Labels and notes MUST NOT change the audio, automation or latency, and MUST NOT be+ parameters; the EQ's processing MUST be identical with and without them.+- **FR-004**: The graph MUST draw each band's label next to its node, avoid overlaps between labels+ and keep them inside the graph, and draw a note mark for bands with a note.+- **FR-005**: Clicking a label or note mark MUST open a note popup for that band with editable+ label and note; the band panel MUST have a Label field and a Note button for the selected band.+- **FR-006**: A band chip MUST show the band's label (shortened to fit) in place of its type when+ it has one.+- **FR-007**: A Labels switch MUST hide or show all labels and note marks in the graph; it is a+ display-only device parameter like Peak (saved with the device, on by default).+- **FR-008**: A label or note edit MUST be a single undo step.+- **FR-009**: Turning on a free band from empty space MUST clear any label and note left on it.+- **FR-010**: The engine MUST expose the labels and notes to MCP through the EQ-8's device text,+ so an agent can read what each band is for.+- **FR-011**: The user guide (EN and RU) MUST describe band labels and notes.++### Key Entities++- **Band annotation**: label and note text for one EQ-8 band slot (1–8).+- **EQ-8 annotations**: the eight band annotations plus the Labels switch, saved with the device.++## Success Criteria *(mandatory)*++### Measurable Outcomes++- **SC-001**: A project with labels and notes on all eight bands reopens with every label and note+ byte-identical.+- **SC-002**: Rendering a test signal through an EQ-8 with and without annotations gives+ bit-identical output.+- **SC-003**: With all eight bands labelled and packed within one octave, no two labels overlap in+ the graph at the card's normal size.+- **SC-004**: Naming a band takes no more than a click and typing (select the band, type the label);+ opening its note is one click on the label.++## Assumptions++- Scope is EQ-8 (device kind 0), the EQ with a node graph and eight fixed band slots. EQ-3 has no+ nodes, and Dynamic EQ-8 can reuse this later with the same design.+- An EQ-8 inside an Audio Effect Rack chain keeps its params only (like every chain device+ today), so its card shows no Label field, Note button or Labels switch.+- Bands are fixed slots in EQ-8, so "renumbering" doesn't happen; the slot is the band's identity.+- Labels are a device setting, not a parameter, so they ride on the device's saved state rather+ than the parameter list.+- Touch editing is whatever Avalonia gives text fields and taps on the platforms Nota ships on.diff --git a/specs/049-eq-band-labels/tasks.md b/specs/049-eq-band-labels/tasks.mdnew file mode 100644index 00000000..d508242e--- /dev/null+++ b/specs/049-eq-band-labels/tasks.md@@ -0,0 +1,12 @@+# Tasks: EQ band labels and notes++- [x] T1 Engine: `Eq` label/note storage, `getState`/`setState`, `deviceText`, `Labels` param (62)+- [x] T2 Engine: `MixKind::DeviceNotes`, `Engine::setEqBandText`, the `noteStates_` table, `applyMix`+- [x] T3 C ABI + managed interop (`EqSetBandText`, `EqBandText`)+- [x] T4 Presets: EQ-8 `BandText` in user presets (capture + apply)+- [x] T5 UI: labels in `Eq8Curve` (placement, collisions, note mark, click → popup)+- [x] T6 UI: note popup, band panel Label field + Note button, chips, Labels switch+- [x] T7 UI: new bell from empty space clears the slot's annotation+- [x] T8 Smoke test `--eq-labels` (engine, undo, copy, state, project, preset, audio identical)+- [x] T9 CHANGELOG, user guide EN + RU (nota-docs)+- [x] T10 Screenshots, macOS checkdiff --git a/src/managed/Nota.App/Controls/Eq8Views.cs b/src/managed/Nota.App/Controls/Eq8Views.csindex 25e30b80..c87c6e38 100644--- a/src/managed/Nota.App/Controls/Eq8Views.cs+++ b/src/managed/Nota.App/Controls/Eq8Views.cs@@ -17,6 +17,7 @@// stereo bell; right-click a node — type, slope, channel and on. The maths mirrors Eq.h.using System;+using System.Collections.Generic;using System.Globalization;using Avalonia;using Avalonia.Controls;@@ -32,7 +33,7 @@ internal static class Eq8public const int Bands = 8, PerBand = 5;public const int On = 0, TypeF = 1, FreqF = 2, GainF = 3, QF = 4;public const int SlopeBase = 40, ChannelBase = 48, ScaleP = 56, OutputP = 57, AutoGainP = 58, AnalyzerP = 59,- AnaRangeP = 60, AnaPeakP = 61, ParamCount = 62;+ AnaRangeP = 60, AnaPeakP = 61, LabelsP = 62, ParamCount = 63;public const int LowCut = 0, LowShelf = 1, Bell = 2, Notch = 3, HighShelf = 4, HighCut = 5;public const int St = 0, Mid = 1, Side = 2, Left = 3, Right = 4;public const int AnaPre = 0, AnaPost = 1, AnaOff = 2;@@ -127,6 +128,11 @@ public sealed class Eq8Curve : Controlpublic event Action? SelectionChanged;/// <summary>Raised after a gesture on the graph wrote params (so the card repaints).</summary>public event Action? Edited;+ /// <summary>A band's label (or note mark) was clicked: open its note (specs/049).</summary>+ public event Action<int>? NoteRequested;++ // Band labels drawn last frame (specs/049), for hit-testing; an empty rect = none.+ private readonly Rect[] _labelBox = new Rect[Eq8.Bands];public Eq8Curve(IAudioEngine engine, int track, int device){@@ -184,6 +190,37 @@ public sealed class Eq8Curve : Controlprivate double RangeDb => Eq8.RangeDb(_engine.DeviceParamCount(_track, _device) > Eq8.AnaRangeP ? (int)Math.Round(Pd(Eq8.AnaRangeP)) : 1);private bool PeakOn => _engine.DeviceParamCount(_track, _device) > Eq8.AnaPeakP && Pd(Eq8.AnaPeakP) >= 0.5f;private double Sr => _engine.SampleRate > 0 ? _engine.SampleRate : 48000;+ private bool LabelsOn => _engine.DeviceParamCount(_track, _device) <= Eq8.LabelsP || Pd(Eq8.LabelsP) >= 0.5f;+ private string Label(int b) => _engine.EqBandText(_track, _device, b, 0);+ private bool HasNote(int b) => _engine.EqBandText(_track, _device, b, 1).Length > 0;++ /// <summary>The graph's own help tooltip; over a label it shows that band's label and note.</summary>+ public string DefaultTip { get; set; } = "";+ private string? _tipShown;+ private void ShowTip(string tip)+ {+ if (tip == _tipShown) return;+ _tipShown = tip;+ ToolTip.SetTip(this, tip.Length > 0 ? tip : null);+ }+ private string LabelTip(int b)+ {+ string label = Label(b), note = _engine.EqBandText(_track, _device, b, 1);+ var lines = note.Split('\n');+ string head = string.Join("\n", lines.Length > 6 ? lines[..6] : lines);+ if (head.Length > 400) head = head[..400] + "…";+ else if (lines.Length > 6) head += "\n…";+ string title = NotaNum.F($"Band {b + 1}") + (label.Length > 0 ? " · " + label : "");+ return (note.Length > 0 ? title + "\n" + head : title) + "\nClick to edit the label and note";+ }++ private int HitLabel(Point p)+ {+ if (!LabelsOn) return -1;+ for (int b = 0; b < Eq8.Bands; b++)+ if (_labelBox[b].Width > 0 && _labelBox[b].Inflate(1).Contains(p)) return b;+ return -1;+ }// ---- geometry: the plot is the whole control ----private double X(double f) => Eq8.FreqToN(f) * Bounds.Width;@@ -215,7 +252,13 @@ public sealed class Eq8Curve : Control{base.OnPointerMoved(e);var p = e.GetPosition(this);- if (_drag < 0) { Cursor = Hit(p) >= 0 ? new Cursor(StandardCursorType.Hand) : Cursor.Default; return; }+ if (_drag < 0)+ {+ int lb = Hit(p) < 0 ? HitLabel(p) : -1;+ Cursor = Hit(p) >= 0 || lb >= 0 ? new Cursor(StandardCursorType.Hand) : Cursor.Default;+ ShowTip(lb >= 0 ? LabelTip(lb) : DefaultTip);+ return;+ }SetP(_drag, Eq8.FreqF, Eq8.NToFreq(p.X / Math.Max(1, Bounds.Width)));if (_gestGain) SetP(_drag, Eq8.GainF, GainAtY(p.Y));Edited?.Invoke();@@ -234,6 +277,13 @@ public sealed class Eq8Curve : Controlreturn;}if (!props.IsLeftButtonPressed) return;+ // A click on a label opens its note; the nodes keep every gesture they had (specs/049).+ if (hit < 0 && HitLabel(p) is var lb and >= 0)+ {+ if (e.ClickCount == 1) { SelectedBand = lb; NoteRequested?.Invoke(lb); }+ e.Handled = true;+ return;+ }if (e.ClickCount == 2){if (hit >= 0) Gesture(Eq8.P(hit, Eq8.On), () => SetP(hit, Eq8.On, BandOn(hit) ? 0 : 1));@@ -300,13 +350,19 @@ public sealed class Eq8Curve : Control{if (BandOn(b)) continue;double f = Eq8.NToFreq(p.X / Math.Max(1, Bounds.Width)), g = GainAtY(p.Y);- Gesture(Eq8.P(b, Eq8.TypeF), () => SetP(b, Eq8.TypeF, Eq8.Bell));- Gesture(Eq8.P(b, Eq8.FreqF), () => SetP(b, Eq8.FreqF, f));- Gesture(Eq8.P(b, Eq8.GainF), () => SetP(b, Eq8.GainF, g));- Gesture(Eq8.P(b, Eq8.QF), () => SetP(b, Eq8.QF, 1.0));- if (_engine.DeviceParamCount(_track, _device) > Eq8.ChannelBase + b)- Gesture(Eq8.ChannelBase + b, () => SetRaw(Eq8.ChannelBase + b, Eq8.St));- Gesture(Eq8.P(b, Eq8.On), () => SetP(b, Eq8.On, 1));+ _engine.BeginUndoGroup(); // one step: undo brings the old band back with its text+ try+ {+ _engine.EqSetBandText(_track, _device, b, "", ""); // a new band: an old label no longer applies+ Gesture(Eq8.P(b, Eq8.TypeF), () => SetP(b, Eq8.TypeF, Eq8.Bell));+ Gesture(Eq8.P(b, Eq8.FreqF), () => SetP(b, Eq8.FreqF, f));+ Gesture(Eq8.P(b, Eq8.GainF), () => SetP(b, Eq8.GainF, g));+ Gesture(Eq8.P(b, Eq8.QF), () => SetP(b, Eq8.QF, 1.0));+ if (_engine.DeviceParamCount(_track, _device) > Eq8.ChannelBase + b)+ Gesture(Eq8.ChannelBase + b, () => SetRaw(Eq8.ChannelBase + b, Eq8.St));+ Gesture(Eq8.P(b, Eq8.On), () => SetP(b, Eq8.On, 1));+ }+ finally { _engine.EndUndoGroup(); }SelectedBand = b;return;}@@ -461,11 +517,106 @@ public sealed class Eq8Curve : Controlctx.DrawText(t, new Point(c.X - t.Width / 2, c.Y - t.Height / 2));}- DrawTip(ctx, w, h);+ var tip = DrawTip(ctx, w, h);+ DrawLabels(ctx, w, h, tip);+ }++ // ---- band labels (specs/049) ----+ private const double LabelH = 13, NoteDot = 4;+ private static readonly double[] LabelWidths = [112, 64, 36, 22];+ private static readonly IBrush LabelFill = NotaPalette.Wash(NotaPalette.SurfaceCard, 0xE8);+ private static readonly IPen LabelEdge = new Pen(NotaPalette.BorderStrong, 1);+ private static readonly IPen LeaderPen = new Pen(NotaPalette.Wash(NotaPalette.TextTertiary, 0xA0), 1);++ // Each label is a pill centred over its node (under it when the node is near the top).+ // In frequency order, a label that would overlap one already placed (or the selected+ // band's reading) tries the other side, then steps further out on both, then shorter; it+ // stays inside the graph, and one moved away from its node gets a thin leader line back to it.+ /// <summary>Space over the graph that labels keep clear of (the card's analyzer bar).</summary>+ public Rect Reserved { get; set; }++ private void DrawLabels(DrawingContext ctx, double w, double h, Rect tip)+ {+ Array.Clear(_labelBox);+ if (!LabelsOn) return;+ var order = new List<(int B, double X)>();+ for (int b = 0; b < Eq8.Bands; b++)+ if (Label(b).Length > 0 || HasNote(b)) order.Add((b, NodeAt(b).X));+ order.Sort((a, c) => a.X.CompareTo(c.X));+ var placed = new List<Rect> { tip, Reserved };+ var chips = new List<(int B, Rect Box, FormattedText? Ft, bool Note, bool On, Point N, double R)>();+ foreach (var (b, _) in order)+ {+ bool on = BandOn(b), note = HasNote(b);+ string text = Label(b);+ IBrush ink = on ? NotaPalette.TextPrimary : NotaPalette.TextDisabled;+ var n = NodeAt(b);+ double r = NodeD / 2 + 3;+ bool below = n.Y < h * 0.34;+ // Full width first; where no spot is free, the label is shortened (down to "…") and+ // tried again. One that still can't be placed isn't drawn: its band's panel has it.+ FormattedText? ft = null;+ Rect box = default;+ bool found = false;+ foreach (double maxW in LabelWidths)+ {+ ft = text.Length > 0 ? Fit(text, ink, maxW - 10 - (note ? NoteDot + 3 : 0)) : null;+ double bw = (ft?.Width ?? 0) + (ft is null ? 0 : 10) + (note ? NoteDot + (ft is null ? 8 : 3) : 0);+ double x = Math.Clamp(n.X - bw / 2, 2, Math.Max(2, w - bw - 2));+ Rect At(bool under, int step)+ {+ double y = under ? n.Y + r + step * (LabelH + 2) : n.Y - r - LabelH - step * (LabelH + 2);+ return new Rect(x, Math.Clamp(y, 2, Math.Max(2, h - LabelH - 2)), bw, LabelH);+ }+ // Out on both sides as far as the graph's height allows (a pass clamped at the edge repeats).+ int maxTries = 2 * ((int)(h / (LabelH + 2)) + 1);+ for (int step = 0, tries = 0; tries < maxTries && !found; tries++)+ {+ var cand = At(tries % 2 == 0 ? below : !below, step);+ if (!placed.Exists(q => q.Intersects(cand))) { box = cand; found = true; }+ if (tries % 2 == 1) step++;+ }+ if (found || ft is null) break; // a note dot alone can't shrink+ }+ if (!found) continue;+ placed.Add(box);+ _labelBox[b] = box;+ chips.Add((b, box, ft, note, on, n, r));+ }+ // Leader lines first, so a chip in a stack covers the lines that run past it to outer chips.+ foreach (var (_, box, _, _, _, n, r) in chips)+ if (Math.Abs(box.Center.Y - n.Y) > r + LabelH)+ {+ var end = new Point(Math.Clamp(n.X, box.Left + 3, box.Right - 3), box.Center.Y < n.Y ? box.Bottom : box.Top);+ ctx.DrawLine(LeaderPen, new Point(n.X, n.Y + (box.Center.Y < n.Y ? -r + 2 : r - 2)), end);+ }+ foreach (var (b, box, ft, note, on, _, _) in chips)+ {+ ctx.DrawRectangle(LabelFill, b == _selected ? new Pen(NotaPalette.Wash(NotaPalette.AccentBright, 0xB0), 1) : LabelEdge,+ new RoundedRect(box.Deflate(0.5), LabelH / 2));+ double tx = box.X + (ft is null ? 4 : 5);+ if (ft is not null) { ctx.DrawText(ft, new Point(tx, box.Y + (LabelH - ft.Height) / 2)); tx += ft.Width + 3; }+ if (note)+ ctx.DrawEllipse(on ? NotaPalette.AccentBright : NotaPalette.TextDisabled, null,+ new Point(tx + NoteDot / 2, box.Center.Y), NoteDot / 2, NoteDot / 2);+ }+ }++ // The label at 7.5 px, shortened with an ellipsis to fit maxW.+ private static FormattedText Fit(string s, IBrush ink, double maxW)+ {+ var ft = Text(s, ink, 7.5, bold: true, mono: false);+ if (ft.Width <= maxW) return ft;+ for (int n = s.Length - 1; n > 0; n--)+ {+ ft = Text(s[..n].TrimEnd() + "…", ink, 7.5, bold: true, mono: false);+ if (ft.Width <= maxW) return ft;+ }+ return ft;}// The selected band's reading beside its node, clear of the node and inside the window.- private void DrawTip(DrawingContext ctx, double w, double h)+ private Rect DrawTip(DrawingContext ctx, double w, double h){int b = _selected, ty = BandType(b), chn = Chan(b);bool bOn = BandOn(b), g = Eq8.HasGain(ty);@@ -482,5 +633,6 @@ public sealed class Eq8Curve : Controlctx.DrawRectangle(NotaPalette.SurfaceCard, new Pen(NotaPalette.BorderStrong, 1), new RoundedRect(box.Deflate(0.5), 3));ctx.DrawText(a, new Point(x + 6, y + 3));ctx.DrawText(l2, new Point(x + 6, y + 3 + a.Height));+ return box;}}diff --git a/src/managed/Nota.App/DeviceCards/Bodies/EqDeviceBody.cs b/src/managed/Nota.App/DeviceCards/Bodies/EqDeviceBody.csindex c2d0004d..cee52aef 100644--- a/src/managed/Nota.App/DeviceCards/Bodies/EqDeviceBody.cs+++ b/src/managed/Nota.App/DeviceCards/Bodies/EqDeviceBody.cs@@ -76,6 +76,16 @@ internal sealed class EqDeviceBody : IDeviceBodybool Capable(int b) => Eq8.HasGain(TypeOf(b));bool Cut(int b) => Eq8.IsCut(TypeOf(b));bool AutoOn() => P(Eq8.AutoGainP) >= 0.5f;+ // Band labels and notes (specs/049): text on the device, each edit one undo step. A rack+ // chain's EQ-8 (hosted through a proxy engine) keeps params only, so it has none.+ bool textOk = engine is not System.Reflection.DispatchProxy;+ string LabelOf(int b) => engine.EqBandText(track, di, b, 0);+ string NoteOf(int b) => engine.EqBandText(track, di, b, 1);+ void SetText(int b, string label, string note)+ {+ engine.EqSetBandText(track, di, b, label, note);+ RefreshAll();+ }// ---- small builders ---------------------------------------------------------static TextBlock Caps(string t, IBrush? c = null, double fs = NotaType.KnobLabel) => new()@@ -93,10 +103,12 @@ internal sealed class EqDeviceBody : IDeviceBody{int bb = b;var num = Mono((b + 1).ToString(), 8, TextSecondary); num.FontWeight = FontWeight.Bold;- var type = new TextBlock { FontSize = 7, FontWeight = FontWeight.SemiBold, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(3, 0, 0, 0) };+ var type = new TextBlock { FontSize = 7, FontWeight = FontWeight.SemiBold, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(3, 0, 0, 0),+ TextTrimming = TextTrimming.CharacterEllipsis };var chn = new TextBlock { FontSize = 7, FontWeight = FontWeight.Medium, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(3, 0, 0, 0) };- var hz = Mono("", 7, TextPrimary); hz.HorizontalAlignment = HorizontalAlignment.Right;- var inner = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,Auto,Auto,*"), Margin = new Thickness(4, 0) };+ var hz = Mono("", 7, TextPrimary); hz.HorizontalAlignment = HorizontalAlignment.Right; hz.Margin = new Thickness(3, 0, 0, 0);+ // The type (or the band's label) takes what the frequency leaves, shortened to fit.+ var inner = new Grid { ColumnDefinitions = new ColumnDefinitions("Auto,*,Auto,Auto"), ColumnSpacing = 0, Margin = new Thickness(4, 0) };inner.Children.Add(num); inner.Children.Add(Col(type, 1)); inner.Children.Add(Col(chn, 2)); inner.Children.Add(Col(hz, 3));var chip = new Border{@@ -116,8 +128,9 @@ internal sealed class EqDeviceBody : IDeviceBodybool on = BandOn(bb), sel = bb == Sel();int c = ChanOf(bb);num.Foreground = !on ? TextDisabled : sel ? AccentBright : TextSecondary;- type.Text = Eq8.TypeShort[TypeOf(bb)];- type.Foreground = on ? TextSecondary : TextDisabled;+ string lab = LabelOf(bb);+ type.Text = lab.Length > 0 ? lab : Eq8.TypeShort[TypeOf(bb)]; // the band's label in place of its type+ type.Foreground = !on ? TextDisabled : lab.Length > 0 ? TextPrimary : TextSecondary;chn.Text = c == Eq8.St ? "" : Eq8.ChannelShort[c];chn.IsVisible = c != Eq8.St;chn.Foreground = on ? Eq8.ChannelInk(c, bright: true) ?? TextSecondary : TextDisabled;@@ -130,8 +143,9 @@ internal sealed class EqDeviceBody : IDeviceBody}var chipStrip = new Border { Height = 20, BorderBrush = BorderDef, BorderThickness = new Thickness(0, 0, 0, 1), Child = chipRow };DockPanel.SetDock(chipStrip, Dock.Top);- ToolTip.SetTip(curve, "Drag a node — frequency and gain · wheel over a node — Q · double-click a node — band on / off · "- + "double-click empty space — a new bell there · right-click a node — type, slope, channel");+ curve.DefaultTip = "Drag a node — frequency and gain · wheel over a node — Q · double-click a node — band on / off · "+ + "double-click empty space — a new bell there · right-click a node — type, slope, channel · click a label — its note";+ ToolTip.SetTip(curve, curve.DefaultTip);// ANALYZER Pre / Post / Off over the graph's top-left corner.var anaSeg = Segments(Eq8.AnalyzerSeg, () => Math.Clamp((int)Math.Round(P(Eq8.AnalyzerP)), 0, 2),@@ -150,13 +164,25 @@ internal sealed class EqDeviceBody : IDeviceBodyLearn(peakSw, Eq8.AnaPeakP);ToolTip.SetTip(peakSw, "Peak hold — a thin line at each frequency's highest level of the last moments");readouts.Add(() => { rangeSync(); peakSync(); rangeSeg.IsVisible = peakSw.IsVisible = AnaOn() && pc > Eq8.AnaPeakP; });+ bool LabelsOn() => pc <= Eq8.LabelsP || P(Eq8.LabelsP) >= 0.5f;+ var labelsSw = Switch("Labels", LabelsOn, () => { SetP(Eq8.LabelsP, LabelsOn() ? 0 : 1); RefreshAll(); }, out var labelsSync);+ labelsSw.Margin = new Thickness(6, 0, 0, 0);+ Learn(labelsSw, Eq8.LabelsP);+ ToolTip.SetTip(labelsSw, "Labels — show the bands' labels and note marks in the graph (the chips and the band panel keep them)");+ readouts.Add(() => { labelsSync(); labelsSw.IsVisible = textOk && pc > Eq8.LabelsP; });var anaBar = new StackPanel{Orientation = Orientation.Horizontal, Spacing = 5, Margin = new Thickness(5, 3), HorizontalAlignment = HorizontalAlignment.Left,- VerticalAlignment = VerticalAlignment.Top, Children = { Caps("ANALYZER"), anaSeg, rangeSeg, peakSw },+ VerticalAlignment = VerticalAlignment.Top, Children = { Caps("ANALYZER"), anaSeg, rangeSeg, peakSw, labelsSw },};anaBar.RenderTransform = new ScaleTransform(0.85, 0.85);anaBar.RenderTransformOrigin = new RelativePoint(0, 0, RelativeUnit.Relative);+ // Band labels stay clear of the bar (drawn at 85 %, from its margin's corner).+ anaBar.LayoutUpdated += (_, _) =>+ {+ var r = new Rect(0, 0, anaBar.Margin.Left + anaBar.Bounds.Width * 0.85 + 2, anaBar.Margin.Top + anaBar.Bounds.Height * 0.85 + 2);+ if (r != curve.Reserved) { curve.Reserved = r; curve.InvalidateVisual(); }+ };var graphPanel = new RuleSection{Margin = new Thickness(0, 0, 5, 0),@@ -169,6 +195,52 @@ internal sealed class EqDeviceBody : IDeviceBody// ======================================================================var bandHost = new ContentControl();+ // The note popup (specs/049): the band's label and a multiline note. Text is kept when it+ // closes (Escape, a click outside, Ctrl / Cmd+Enter), as one undo step.+ // A label box takes Return so a pasted multi-line text arrives whole (a single-line box keeps+ // only its first line); its breaks and tabs become spaces as it lands.+ static void FlattenLabel(TextBox box) => box.TextChanged += (_, _) =>+ {+ var t = box.Text;+ if (t is null || t.IndexOfAny(['\r', '\n', '\t']) < 0) return;+ int caret = box.CaretIndex;+ var flat = t.Replace("\r\n", " ").Replace('\r', ' ').Replace('\n', ' ').Replace('\t', ' ');+ box.Text = flat;+ box.CaretIndex = Math.Clamp(caret - (t.Length - flat.Length), 0, flat.Length);+ };++ void OpenNote(int b, Control anchor, bool atPointer)+ {+ var labelBox = new TextBox { Text = LabelOf(b), MaxLength = 24, AcceptsReturn = true, FontSize = 11, Watermark = "Label" };+ FlattenLabel(labelBox);+ var noteBox = new TextBox+ {+ Text = NoteOf(b), MaxLength = 2000, AcceptsReturn = true, TextWrapping = TextWrapping.Wrap, FontSize = 11,+ Height = 96, Watermark = "What this band is for",+ };+ var head = new TextBlock { Text = NotaNum.F($"BAND {b + 1} · {Eq8.TypeNames[TypeOf(b)]}"), FontSize = NotaType.KnobLabel, FontWeight = FontWeight.Medium, Foreground = TextTertiary };+ var hint = new TextBlock { Text = (OperatingSystem.IsMacOS() ? "⌘" : "Ctrl+") + "Enter or Esc to close", FontSize = 9, Foreground = TextTertiary };+ var fly = new Flyout+ {+ Content = new StackPanel { Width = 230, Spacing = 5, Children = { head, labelBox, noteBox, hint } },+ // From the graph it opens beside it, so the nodes stay in view.+ Placement = atPointer ? PlacementMode.RightEdgeAlignedTop : PlacementMode.BottomEdgeAlignedLeft,+ };+ void Key(object? _, KeyEventArgs ke)+ {+ bool cmd = (ke.KeyModifiers & (KeyModifiers.Control | KeyModifiers.Meta)) != 0;+ if (ke.Key == Avalonia.Input.Key.Escape || (ke.Key == Avalonia.Input.Key.Enter && (cmd || ke.Source == labelBox)))+ { fly.Hide(); ke.Handled = true; }+ }+ labelBox.AddHandler(InputElement.KeyDownEvent, Key, Avalonia.Interactivity.RoutingStrategies.Tunnel);+ noteBox.AddHandler(InputElement.KeyDownEvent, Key, Avalonia.Interactivity.RoutingStrategies.Tunnel);+ fly.Closed += (_, _) => SetText(b, labelBox.Text ?? "", noteBox.Text ?? "");+ fly.ShowAt(anchor);+ Avalonia.Threading.Dispatcher.UIThread.Post(() => { var f = LabelOf(b).Length == 0 ? labelBox : noteBox; f.Focus(); f.CaretIndex = f.Text?.Length ?? 0; },+ Avalonia.Threading.DispatcherPriority.Input);+ }+ if (textOk) curve.NoteRequested += b => OpenNote(b, curve, atPointer: true);+Control BandPanel(int b){bandReadouts.Clear();@@ -241,6 +313,39 @@ internal sealed class EqDeviceBody : IDeviceBodyliveLabel: () => Cut(b) ? "Reso" : "Q"), 2),} };+ // ---- label + note ----+ var labelField = new TextBox+ {+ // AcceptsReturn and FlattenLabel, so a pasted multi-line text arrives whole; Enter commits.+ Text = LabelOf(b), MaxLength = 24, AcceptsReturn = true, FontSize = 9, MinHeight = 18, Height = 18,+ Padding = new Thickness(4, 1), VerticalContentAlignment = VerticalAlignment.Center, Watermark = "Name this band",+ };+ void Unfocus() { curve.Focusable = true; curve.Focus(); } // hand the keys back to the card+ void CommitLabel() { if ((labelField.Text ?? "") != LabelOf(b)) SetText(b, labelField.Text ?? "", NoteOf(b)); }+ labelField.LostFocus += (_, _) => CommitLabel();+ labelField.AddHandler(InputElement.KeyDownEvent, (_, ke) =>+ {+ // Enter keeps the text, Escape reverts it; both hand focus back to the card.+ // Tunnelled, so Enter is ours before the box would take it as a line break.+ if (ke.Key == Avalonia.Input.Key.Enter) { CommitLabel(); ke.Handled = true; Unfocus(); }+ else if (ke.Key == Avalonia.Input.Key.Escape) { labelField.Text = LabelOf(b); ke.Handled = true; Unfocus(); }+ }, Avalonia.Interactivity.RoutingStrategies.Tunnel);+ FlattenLabel(labelField);+ ToolTip.SetTip(labelField, "Label — a short name shown next to the band's node (up to 24 characters)");+ var noteBtn = new Button+ {+ Content = "Note", FontSize = 8, Height = 18, MinHeight = 18, Padding = new Thickness(6, 0), Margin = new Thickness(4, 0, 0, 0),+ VerticalContentAlignment = VerticalAlignment.Center,+ };+ noteBtn.Click += (_, _) => { CommitLabel(); OpenNote(b, noteBtn, atPointer: false); };+ ToolTip.SetTip(noteBtn, "Note — a longer note on what this band is for");+ bandReadouts.Add(() =>+ {+ if (!labelField.IsFocused && (labelField.Text ?? "") != LabelOf(b)) labelField.Text = LabelOf(b);+ noteBtn.Foreground = NoteOf(b).Length > 0 ? AccentBright : TextSecondary;+ });+ var labelRow = new DockPanel { IsVisible = textOk, Children = { Docked(new Border { Width = 40, Child = Caps("LABEL") }, Dock.Left), Docked(noteBtn, Dock.Right), labelField } };+// ---- slope + channel ----Control SegRow(string label, Control seg, Func<bool>? dim = null, bool rule = false){@@ -310,13 +415,13 @@ internal sealed class EqDeviceBody : IDeviceBodyvar body = new Grid{- RowDefinitions = new RowDefinitions("Auto,*,Auto,*,Auto,4,Auto,*,Auto,5,Auto"), Margin = new Thickness(8, 6, 8, 6),+ RowDefinitions = new RowDefinitions("Auto,4,Auto,*,Auto,*,Auto,4,Auto,*,Auto,5,Auto"), Margin = new Thickness(8, 6, 8, 6),};void Row(Control c, int r) { Grid.SetRow(c, r); body.Children.Add(c); }- Row(typeSeg, 0); Row(knobs, 2);- Row(SegRow("SLOPE", slopeSeg, () => !Cut(b), rule: true), 4);- Row(SegRow("CHANNEL", chanSeg), 6);- Row(globalRow, 8); Row(sliders, 10);+ Row(labelRow, 0); Row(typeSeg, 2); Row(knobs, 4);+ Row(SegRow("SLOPE", slopeSeg, () => !Cut(b), rule: true), 6);+ Row(SegRow("CHANNEL", chanSeg), 8);+ Row(globalRow, 10); Row(sliders, 12);var panel = new DockPanel { LastChildFill = true, Children = { Docked(headBorder, Dock.Top), body } };for (int i = 0; i < bandReadouts.Count; i++) bandReadouts[i]();return panel;diff --git a/src/managed/Nota.App/DeviceCards/Rack/RackCardView.cs b/src/managed/Nota.App/DeviceCards/Rack/RackCardView.csindex d0fa766a..4bebdd42 100644--- a/src/managed/Nota.App/DeviceCards/Rack/RackCardView.cs+++ b/src/managed/Nota.App/DeviceCards/Rack/RackCardView.cs@@ -883,6 +883,8 @@ internal class RackChainDeviceEngineProxy : System.Reflection.DispatchProxycase nameof(Nota.Application.IAudioEngine.DeviceBypassed): return Access.ChainDeviceBypassed(Chain, Dev);case nameof(Nota.Application.IAudioEngine.SetDeviceBypassed): Access.SetChainDeviceBypassed(Chain, Dev, (bool)args![2]!); return null;case nameof(Nota.Application.IAudioEngine.DeviceLoadFile): return false; // chain devices keep params only+ case nameof(Nota.Application.IAudioEngine.EqSetBandText): return false; // … and no EQ-8 band labels (specs/049)+ case nameof(Nota.Application.IAudioEngine.EqBandText): return "";// Live telemetry (meters, scopes, curves) comes from the chain device itself —// passing through would read/command the track's top-level device at the same index.case nameof(Nota.Application.IAudioEngine.DeviceGainReduction): return Access.ChainDeviceGainReduction(Chain, Dev);diff --git a/src/managed/Nota.Application/Engine/IAudioEngine.cs b/src/managed/Nota.Application/Engine/IAudioEngine.csindex d2863402..c141cd2a 100644--- a/src/managed/Nota.Application/Engine/IAudioEngine.cs+++ b/src/managed/Nota.Application/Engine/IAudioEngine.cs@@ -631,6 +631,11 @@ public interface IAudioEngine : IDisposable/// <summary>A device's resource text (Nota Chamber: 0 IR name, 1 IR category, 2 user IR/// name, 10 the built-in IR list as "name\tcategory\tseconds" lines); "" when none.</summary>string DeviceText(int trackId, int deviceIndex, int id);+ /// <summary>Nota EQ-8 band labels and notes (specs/049): replace band 0..7's label (≤ 24+ /// characters, one line) and note (≤ 2000) as one undo step; false when nothing changed or the+ /// device isn't an EQ-8. EqBandText: which 0 = label, 1 = note ("" when none).</summary>+ bool EqSetBandText(int trackId, int deviceIndex, int band, string label, string note);+ string EqBandText(int trackId, int deviceIndex, int band, int which);/// <summary>Sidechain routing: point a device's detector at another track's signal (-1 clears).</summary>void SetDeviceSidechainSource(int trackId, int deviceIndex, int sourceTrackId);int DeviceSidechainSource(int trackId, int deviceIndex);diff --git a/src/managed/Nota.Infrastructure/Interop/NativeMethods.Devices.cs b/src/managed/Nota.Infrastructure/Interop/NativeMethods.Devices.csindex 21d186e1..4e150b78 100644--- a/src/managed/Nota.Infrastructure/Interop/NativeMethods.Devices.cs+++ b/src/managed/Nota.Infrastructure/Interop/NativeMethods.Devices.cs@@ -168,6 +168,10 @@ internal static partial class NativeMethodsinternal static partial NotaResult DeviceLoadFile(IntPtr engine, int trackId, int deviceIndex, string path);[LibraryImport(Lib, EntryPoint = "nota_device_text")]internal static partial int DeviceText(IntPtr engine, int trackId, int deviceIndex, int id, [Out] byte[]? outBytes, int cap);+ [LibraryImport(Lib, EntryPoint = "nota_eq_set_band_text", StringMarshalling = StringMarshalling.Utf8)]+ internal static partial int EqSetBandText(IntPtr engine, int trackId, int deviceIndex, int band, string label, string note);+ [LibraryImport(Lib, EntryPoint = "nota_eq_band_text")]+ internal static partial int EqBandText(IntPtr engine, int trackId, int deviceIndex, int band, int which, [Out] byte[]? outBytes, int cap);// --- MIDI effects ---[LibraryImport(Lib, EntryPoint = "nota_track_add_midi_effect")]diff --git a/src/managed/Nota.Infrastructure/Interop/NotaEngine.Devices.cs b/src/managed/Nota.Infrastructure/Interop/NotaEngine.Devices.csindex 974cc172..55537ee6 100644--- a/src/managed/Nota.Infrastructure/Interop/NotaEngine.Devices.cs+++ b/src/managed/Nota.Infrastructure/Interop/NotaEngine.Devices.cs@@ -207,6 +207,17 @@ public sealed partial class NotaEngineNativeMethods.DeviceText(_handle, trackId, deviceIndex, id, buf, buf.Length);return System.Text.Encoding.UTF8.GetString(buf, 0, n);}+ public bool EqSetBandText(int trackId, int deviceIndex, int band, string label, string note)+ { ThrowIfDisposed(); return NativeMethods.EqSetBandText(_handle, trackId, deviceIndex, band, label ?? "", note ?? "") != 0; }+ public string EqBandText(int trackId, int deviceIndex, int band, int which)+ {+ ThrowIfDisposed();+ int n = NativeMethods.EqBandText(_handle, trackId, deviceIndex, band, which, null, 0);+ if (n <= 0) return "";+ var buf = new byte[n + 1];+ NativeMethods.EqBandText(_handle, trackId, deviceIndex, band, which, buf, buf.Length);+ return System.Text.Encoding.UTF8.GetString(buf, 0, n);+ }// --- MIDI effects ---public int AddMidiEffect(int trackId, int kind) { ThrowIfDisposed(); return NativeMethods.AddMidiEffect(_handle, trackId, kind); }diff --git a/src/managed/Nota.Infrastructure/Persistence/PresetModel.cs b/src/managed/Nota.Infrastructure/Persistence/PresetModel.csindex ff7df5b9..e50162f8 100644--- a/src/managed/Nota.Infrastructure/Persistence/PresetModel.cs+++ b/src/managed/Nota.Infrastructure/Persistence/PresetModel.cs@@ -48,6 +48,11 @@ public sealed class PresetDocument[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]public string? MosaicProgram { get; set; }+ /// <summary>Nota EQ-8: the user's band labels and notes (specs/049), one entry per annotated+ /// band. Null = none (a factory preset, or one saved before labels existed).</summary>+ [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]+ public System.Collections.Generic.List<PresetBandText>? BandText { get; set; }+// Plugin: stable identity + base64-encoded state blob.public string PluginId { get; set; } = "";public string StateBase64 { get; set; } = "";@@ -55,3 +60,11 @@ public sealed class PresetDocument/// <summary>Forward-compat: unknown fields from newer versions round-trip.</summary>[JsonExtensionData] public System.Collections.Generic.Dictionary<string, System.Text.Json.JsonElement>? Extra { get; set; }}++/// <summary>One EQ-8 band's label and note in a preset (band 1..8).</summary>+public sealed class PresetBandText+{+ public int Band { get; set; }+ public string Label { get; set; } = "";+ public string Note { get; set; } = "";+}diff --git a/src/managed/Nota.Infrastructure/Persistence/PresetService.cs b/src/managed/Nota.Infrastructure/Persistence/PresetService.csindex d941b3d9..27ac0f9a 100644--- a/src/managed/Nota.Infrastructure/Persistence/PresetService.cs+++ b/src/managed/Nota.Infrastructure/Persistence/PresetService.cs@@ -73,6 +73,7 @@ public static class PresetServicedoc.NamedParams = new Dictionary<string, float>(pc);for (int i = 0; i < pc; i++)doc.NamedParams[engine.DeviceParamName(trackId, deviceIndex, i)] = engine.DeviceGetParam(trackId, deviceIndex, i);+ if (bk == EqKind) doc.BandText = CaptureBandText(engine, trackId, deviceIndex);return doc;}@@ -219,6 +220,7 @@ public static class PresetServicefor (int i = 0; i < doc.Params.Length; i++)engine.DeviceSetParam(targetTrackId, di, i, doc.Params[i]);LegacyRange(doc, engine, targetTrackId, di);+ if (doc.BuiltinKind == EqKind) ApplyBandText(doc.BandText, engine, targetTrackId, di);return "";}case "builtin-midi-effect":@@ -349,10 +351,35 @@ public static class PresetServiceint pc = engine.DeviceParamCount(trackId, deviceIndex);for (int i = 0; i < pc; i++)engine.DeviceSetParam(trackId, deviceIndex, i, engine.DeviceParamDefault(trackId, deviceIndex, i));+ if (engine.TrackDeviceBuiltinKind(trackId, deviceIndex) == EqKind) ApplyBandText(null, engine, trackId, deviceIndex);}return "";}+ private const int EqKind = 0; // Nota EQ-8++ /// <summary>An EQ-8's band labels and notes for a preset (specs/049); null when it has none.</summary>+ private static List<PresetBandText>? CaptureBandText(IAudioEngine engine, int trackId, int deviceIndex)+ {+ List<PresetBandText>? list = null;+ for (int b = 0; b < 8; b++)+ {+ string label = engine.EqBandText(trackId, deviceIndex, b, 0), note = engine.EqBandText(trackId, deviceIndex, b, 1);+ if (label.Length > 0 || note.Length > 0) (list ??= new()).Add(new PresetBandText { Band = b + 1, Label = label, Note = note });+ }+ return list;+ }++ /// <summary>Give an EQ-8 exactly the preset's band labels and notes (null clears them all).</summary>+ private static void ApplyBandText(List<PresetBandText>? text, IAudioEngine engine, int trackId, int deviceIndex)+ {+ for (int b = 0; b < 8; b++)+ {+ var t = text?.Find(x => x.Band == b + 1);+ engine.EqSetBandText(trackId, deviceIndex, b, t?.Label ?? "", t?.Note ?? "");+ }+ }+/// <summary>Applies a preset to an EXISTING instrument/device in place (no new track//// device is created) — for the in-header preset picker. Built-in instruments reset all/// params to default first so the patch is clean; effects set the preset's named params.</summary>@@ -401,6 +428,8 @@ public static class PresetServiceengine.DeviceSetParam(trackId, deviceIndex, i, doc.Params[i]);}LegacyRange(doc, engine, trackId, deviceIndex);+ // The preset's band labels replace the device's (none for a factory preset).+ if (engine.TrackDeviceBuiltinKind(trackId, deviceIndex) == EqKind) ApplyBandText(doc.BandText, engine, trackId, deviceIndex);return "";}case "builtin-midi-effect":diff --git a/src/managed/Nota.Mcp/Tools/DeviceTools.cs b/src/managed/Nota.Mcp/Tools/DeviceTools.csindex 01103674..75b0b5a1 100644--- a/src/managed/Nota.Mcp/Tools/DeviceTools.cs+++ b/src/managed/Nota.Mcp/Tools/DeviceTools.cs@@ -1406,7 +1406,7 @@ public sealed class DeviceTools(IAudioEngine engine, IEngineDispatch dispatch, I});public sealed record Eq8Band(int Band, bool On, string Type, double FreqHz, double GainDb, double EffectiveGainDb, double Q,- int SlopeDbPerOct, string Channel);+ int SlopeDbPerOct, string Channel, string Label, string Note);public sealed record Eq8Reading(string Summary, string Live, double ScalePercent, double OutputDb, bool AutoGain, double AutoGainNowDb,string Analyzer, int AnalyzerRangeDb, bool AnalyzerPeak, double InputPeakDb, double OutputPeakDb, double SampleRate, Eq8Band[] Bands,bool SpectrumValid, DynEqSpectrumBand[] InputSpectrum, DynEqSpectrumBand[] OutputSpectrum);@@ -1441,7 +1441,8 @@ public sealed class DeviceTools(IAudioEngine engine, IEngineDispatch dispatch, Idouble scale = Math.Clamp(Pm(56), 0, 200) / 100;return new Eq8Band(b + 1, Pm(o) > 0.5f, DynEqTypes[ty], Math.Round(Pm(o + 2)), gain ? Math.Round(Pm(o + 3), 1) : 0,gain ? Math.Round(Pm(o + 3) * scale, 1) : 0, Math.Round(Pm(o + 4), 2),- cut ? 12 << Math.Clamp((int)Math.Round(Pm(40 + b)), 0, 2) : 12, Eq8Channels[Math.Clamp((int)Math.Round(Pm(48 + b)), 0, 4)]);+ cut ? 12 << Math.Clamp((int)Math.Round(Pm(40 + b)), 0, 2) : 12, Eq8Channels[Math.Clamp((int)Math.Round(Pm(48 + b)), 0, 4)],+ E.EqBandText(trackId, deviceIndex, b, 0), E.EqBandText(trackId, deviceIndex, b, 1));}private Eq8Reading Eq8Read(int trackId, int deviceIndex, bool spectrum)@@ -1470,7 +1471,8 @@ public sealed class DeviceTools(IAudioEngine engine, IEngineDispatch dispatch, I+ "output, whether Auto gain is on and the gain it adds now, the analyzer mode the card shows (Pre / Post / Off) with its range "+ "(60 / 90 / 120 dB) and peak hold, in / out "+ "peaks; per band: on, type, frequency, gain, the effective gain after Scale, Q (the resonance on the cuts), slope "- + "(12 / 24 / 48 dB/oct, cuts only) and channel (Stereo / Mid / Side / Left / Right); plus the input and output spectra "+ + "(12 / 24 / 48 dB/oct, cuts only), channel (Stereo / Mid / Side / Left / Right) and the user's label and note for "+ + "the band (what it is for; \"\" when none); plus the input and output spectra "+ "in 24 log bands (dB, the loudest 1/6-octave reading in each). Levels read −120 while silent; they move only while audio runs through the track. "+ "set_eq8_band edits a band, set_eq8 the globals.")]public Task<Eq8Reading> ReadEq8(int trackId, int deviceIndex) => Read(() => Eq8Read(trackId, deviceIndex, true));@@ -1479,11 +1481,13 @@ public sealed class DeviceTools(IAudioEngine engine, IEngineDispatch dispatch, I"Edit one band of a Nota EQ-8 (built-in effect kind 0) in one call — only the fields you pass change; each change is "+ "recorded like a hand edit. type: \"Low cut\" | \"Low shelf\" | \"Bell\" | \"Notch\" | \"High shelf\" | \"High cut\" "+ "(only shelves and bells take gain). slope: 12, 24 or 48 dB/oct (cuts only). channel: \"Stereo\" | \"Mid\" | \"Side\" | "- + "\"Left\" | \"Right\". Setting any field of an off band does not switch it on — pass on true. Returns the band as read back.")]+ + "\"Left\" | \"Right\". Setting any field of an off band does not switch it on — pass on true. label (≤ 24 characters, one "+ + "line) and note (≤ 2000, multiline) are the band's text shown on the card; \"\" clears one. Returns the band as read back.")]public Task<Eq8Band> SetEq8Band(int trackId, int deviceIndex, [Description("Band 1..8")] int band,bool? on = null, string? type = null, [Description("20..20000 Hz")] double? freqHz = null, [Description("−18..+18 dB")] double? gainDb = null,[Description("0.1..18 (0.71 = flat on the cuts)")] double? q = null, [Description("12, 24 or 48")] int? slope = null,- string? channel = null) => Mutate(() =>+ string? channel = null, [Description("The band's label, ≤ 24 characters")] string? label = null,+ [Description("The band's note, ≤ 2000 characters")] string? note = null) => Mutate(() =>{if (E.TrackDeviceBuiltinKind(trackId, deviceIndex) != 0) throw new ArgumentException("not a Nota EQ-8 (kind 0)");if (band < 1 || band > 8) throw new ArgumentException("band is 1..8");@@ -1501,16 +1505,19 @@ public sealed class DeviceTools(IAudioEngine engine, IEngineDispatch dispatch, Iif (i < 0) throw new ArgumentException($"{what} must be one of: {string.Join(", ", names)}");return i;}- if (type is not null) S(o + 1, Idx(DynEqTypes, type, "type"));+ // Check every argument before changing anything, so a refused call leaves the band as it was.+ int? ti = type is null ? null : Idx(DynEqTypes, type, "type");+ int? ci = channel is null ? null : Idx(Eq8Channels, channel, "channel");+ if (slope is { } bad && bad is not (12 or 24 or 48)) throw new ArgumentException("slope is 12, 24 or 48");+ if (label is not null || note is not null)+ E.EqSetBandText(trackId, deviceIndex, band - 1, label ?? E.EqBandText(trackId, deviceIndex, band - 1, 0),+ note ?? E.EqBandText(trackId, deviceIndex, band - 1, 1));+ if (ti is { } tv) S(o + 1, tv);if (freqHz is { } f) S(o + 2, Math.Clamp(f, 20, 20000));if (gainDb is { } g) S(o + 3, Math.Clamp(g, -18, 18));if (q is { } qq) S(o + 4, Math.Clamp(qq, 0.1, 18));- if (slope is { } sl)- {- if (sl is not (12 or 24 or 48)) throw new ArgumentException("slope is 12, 24 or 48");- S(40 + band - 1, sl == 12 ? 0 : sl == 24 ? 1 : 2);- }- if (channel is not null) S(48 + band - 1, Idx(Eq8Channels, channel, "channel"));+ if (slope is { } sl) S(40 + band - 1, sl == 12 ? 0 : sl == 24 ? 1 : 2);+ if (ci is { } cv) S(48 + band - 1, cv);if (on is { } onv) S(o, onv ? 1 : 0);return Eq8BandRead(trackId, deviceIndex, band - 1);});diff --git a/src/native/nota.engine/include/nota/nota_engine.h b/src/native/nota.engine/include/nota/nota_engine.hindex bc9b825c..01cd3c8b 100644--- a/src/native/nota.engine/include/nota/nota_engine.h+++ b/src/native/nota.engine/include/nota/nota_engine.h@@ -1744,6 +1744,13 @@ NOTA_API NotaResult nota_device_load_file(NotaEngine* engine, int32_t track_id,/* A device's resource text (Chamber: 0 IR name, 1 category, 2 user IR name, 10 built-in IR list).Returns the full UTF-8 length; copies up to cap-1 bytes + NUL when out is non-null. */NOTA_API int32_t nota_device_text(const NotaEngine* engine, int32_t track_id, int32_t device_index, int32_t id, char* out, int32_t cap);+/* Nota EQ-8 band labels and notes (specs/049): UTF-8 text attached to band 0..7, kept with+ * the device's state (project, user preset, copies). set replaces one band's label (max 24+ * characters, one line) and note (max 2000, line breaks kept) as one undo step; NULL = "".+ * Returns 1 when something changed, 0 otherwise (not an EQ-8, bad band, same text).+ * get: which 0 = label, 1 = note; returns the full length and copies up to cap-1 bytes + NUL. */+NOTA_API int32_t nota_eq_set_band_text(NotaEngine* engine, int32_t track_id, int32_t device_index, int32_t band, const char* label, const char* note);+NOTA_API int32_t nota_eq_band_text(const NotaEngine* engine, int32_t track_id, int32_t device_index, int32_t band, int32_t which, char* out, int32_t cap);/* Sidechain routing (Phase B): point a device's detector at another track's signal.* source_track_id -1 clears it; get returns the current source (-1 = none). */NOTA_API void nota_device_set_sidechain_source(NotaEngine* engine, int32_t track_id, int32_t device_index, int32_t source_track_id);diff --git a/src/native/nota.engine/src/abi/nota_engine_device.cpp b/src/native/nota.engine/src/abi/nota_engine_device.cppindex 330c0a98..dddd95d2 100644--- a/src/native/nota.engine/src/abi/nota_engine_device.cpp+++ b/src/native/nota.engine/src/abi/nota_engine_device.cpp@@ -210,6 +210,24 @@ int32_t nota_device_text(return n; // full length (probe with a null buffer, then fetch)}+int32_t nota_eq_set_band_text(+ NotaEngine* e, int32_t track_id, int32_t device_index, int32_t band, const char* label, const char* note) {+ if (!e) return 0;+ return ENG(e)->setEqBandText(track_id, device_index, band, label ? label : "", note ? note : "") ? 1 : 0;+}+int32_t nota_eq_band_text(+ const NotaEngine* e, int32_t track_id, int32_t device_index, int32_t band, int32_t which, char* out, int32_t cap) {+ if (!e) return 0;+ const std::string s = CENG(e)->eqBandText(track_id, device_index, band, which);+ const int32_t n = static_cast<int32_t>(s.size());+ if (out && cap > 0) {+ const int32_t m = std::min(n, cap - 1);+ std::memcpy(out, s.data(), static_cast<size_t>(m));+ out[m] = '\0';+ }+ return n;+}+// --- MIDI effects ---int32_t nota_track_add_midi_effect(NotaEngine* e, int32_t t, int32_t kind) {return e ? ENG(e)->addTrackMidiEffect(t, kind) : -1;diff --git a/src/native/nota.engine/src/devices/effects/Eq.cpp b/src/native/nota.engine/src/devices/effects/Eq.cppindex 6d33eccd..28cc80f6 100644--- a/src/native/nota.engine/src/devices/effects/Eq.cpp+++ b/src/native/nota.engine/src/devices/effects/Eq.cpp@@ -11,6 +11,8 @@#include "dsp/math/FastMath.h"#include "dsp/math/SimdAudio.h"+#include <cstring>+namespace nota {namespace {@@ -38,6 +40,7 @@ Eq::Eq() {p_[Analyzer].store((float)AnaPost);p_[AnaRange].store(1.0f);p_[AnaPeak].store(0.0f);+ p_[Labels].store(1.0f);setSampleRate(44100.0, 0);}@@ -363,6 +366,7 @@ const char* Eq::paramName(int32_t i) const {if (i == Analyzer) return "Analyzer";if (i == AnaRange) return "Analyzer Range";if (i == AnaPeak) return "Analyzer Peak";+ if (i == Labels) return "Labels";static thread_local char buf[16];if (i >= SlopeBase && i < ChannelBase) {std::snprintf(buf, sizeof(buf), "%d Slope", i - SlopeBase + 1);@@ -400,6 +404,7 @@ float Eq::paramMax(int32_t i) const {if (i == Analyzer) return 2.0f;if (i == AnaRange) return 2.0f;if (i == AnaPeak) return 1.0f;+ if (i == Labels) return 1.0f;switch (i % kPerBand) {case On: return 1.0f;case Type: return kNumTypes - 1;@@ -489,6 +494,14 @@ std::string Eq::deviceText(int32_t id) const {std::snprintf(b, sizeof b, " | output %+.1f dB%s | analyzer %s", get(Output),get(AutoGain) >= 0.5f ? " + auto gain" : "", anas[std::clamp((int)std::lround(get(Analyzer)), 0, 2)]);s += b;+ // The user's band labels and notes (specs/049): what each band is for.+ for (int k = 0; k < kBands; ++k) {+ if (label_[k].empty() && note_[k].empty()) continue;+ std::snprintf(b, sizeof b, " | B%d", k + 1);+ s += b;+ if (!label_[k].empty()) s += " label \"" + label_[k] + "\"";+ if (!note_[k].empty()) s += " note \"" + note_[k] + "\"";+ }return s;}if (id == 1) {@@ -519,11 +532,104 @@ std::string Eq::deviceText(int32_t id) const {"the ""shelves and bells (cuts and notches do not count; max +-12 dB). 59 Analyzer 0 Pre, 1 Post, 2 Off ""(display only). 60 Analyzer Range 0 = 60, 1 = 90, 2 = 120 dB (display only). 61 Analyzer Peak "- "0/1 peak hold (display only).";+ "0/1 peak hold (display only). 62 Labels 0/1 shows the band labels in the graph (display only). "+ "Band labels and notes are text, not params: set them with the band-text tool.";}return {};}+namespace {++// Keep at most `max` UTF-8 code points, drop control characters (line breaks too unless+// `multiline`) and trim a label's surrounding spaces (a blank note is empty). Invalid bytes are dropped.+std::string cleanText(const std::string& in, size_t max, bool multiline) {+ std::string out;+ size_t cps = 0;+ for (size_t i = 0; i < in.size() && cps < max;) {+ const auto c = static_cast<unsigned char>(in[i]);+ const size_t len = c < 0x80 ? 1 : (c >> 5) == 0x6 ? 2 : (c >> 4) == 0xE ? 3 : (c >> 3) == 0x1E ? 4 : 0;+ if (len == 0 || i + len > in.size()) {+ ++i;+ continue;+ }+ bool ok = true;+ for (size_t k = 1; k < len; ++k)+ if ((static_cast<unsigned char>(in[i + k]) & 0xC0) != 0x80) ok = false;+ if (!ok) {+ ++i;+ continue;+ }+ if (len == 1 && (c < 0x20 || c == 0x7F)) { // control characters: only a note keeps line breaks+ i += 1;+ if (c == '\t' || c == '\n') { // a tab, or a line break in a label, reads as a space+ out += multiline && c == '\n' ? '\n' : ' ';+ ++cps;+ }+ continue;+ }+ out.append(in, i, len);+ i += len;+ ++cps;+ }+ const auto first = out.find_first_not_of(" \n");+ if (first == std::string::npos) return {};+ if (multiline) return out; // a note is kept exactly+ const auto last = out.find_last_not_of(" \n");+ return out.substr(first, last - first + 1);+}++} // namespace++void Eq::setBandText(int b, const std::string& label, const std::string& note) {+ if (b < 0 || b >= kBands) return;+ label_[b] = cleanText(label, kLabelMax, false);+ note_[b] = cleanText(note, kNoteMax, true);+}++// "NEQ1", then per band: u16 label length, label bytes, u16 note length, note bytes (UTF-8).+std::vector<uint8_t> Eq::getState() const {+ bool any = false;+ for (int b = 0; b < kBands; ++b) any |= !label_[b].empty() || !note_[b].empty();+ if (!any) return {};+ std::vector<uint8_t> v{'N', 'E', 'Q', '1'};+ auto put = [&v](const std::string& s) {+ const auto n = static_cast<uint16_t>(std::min<size_t>(s.size(), 0xFFFF));+ v.push_back(static_cast<uint8_t>(n & 0xFF));+ v.push_back(static_cast<uint8_t>(n >> 8));+ v.insert(v.end(), s.begin(), s.begin() + n);+ };+ for (int b = 0; b < kBands; ++b) {+ put(label_[b]);+ put(note_[b]);+ }+ return v;+}++void Eq::setState(const uint8_t* data, int32_t size) {+ std::string lab[kBands], nt[kBands];+ if (data && size >= 4 && std::memcmp(data, "NEQ1", 4) == 0) {+ size_t at = 4;+ const auto n = static_cast<size_t>(size);+ auto get = [&](std::string& out) {+ if (at + 2 > n) return false;+ const size_t len = data[at] | (static_cast<size_t>(data[at + 1]) << 8);+ at += 2;+ if (at + len > n) return false;+ out.assign(reinterpret_cast<const char*>(data + at), len);+ at += len;+ return true;+ };+ for (int b = 0; b < kBands; ++b)+ if (!get(lab[b]) || !get(nt[b])) {+ lab[b].clear();+ nt[b].clear();+ break;+ }+ }+ // Anything else (an empty blob, an unknown format) reads as no annotations.+ for (int b = 0; b < kBands; ++b) setBandText(b, lab[b], nt[b]);+}+bool Eq::analyse() const {const int mode = analyzerMode();if (ring_[0].empty() || mode == AnaOff) return false;diff --git a/src/native/nota.engine/src/devices/effects/Eq.h b/src/native/nota.engine/src/devices/effects/Eq.hindex 260499a8..6acc04d2 100644--- a/src/native/nota.engine/src/devices/effects/Eq.h+++ b/src/native/nota.engine/src/devices/effects/Eq.h@@ -48,8 +48,9 @@ class Eq : public Device {Analyzer,AnaRange, // 0 = 60, 1 = 90, 2 = 120 dB below 0 dBFS (display only)AnaPeak, // 0 / 1 peak hold (display only)+ Labels, // 0 / 1 band labels shown in the graph (display only, specs/049)kNumParams- }; // 62+ }; // 63enum { AnaPre = 0, AnaPost = 1, AnaOff = 2 };// Telemetry slots (scopeRead).@@ -95,7 +96,20 @@ class Eq : public Device {void deviceAction(int32_t id, int32_t iarg, float farg) override;std::string deviceText(int32_t id) const override;+ // Band labels and notes (specs/049): text the user attaches to a band slot. Message thread+ // only — process() never reads them. They are the device's saved state (empty when none,+ // so a plain EQ-8 saves exactly as before); Engine::setDeviceAnnotation edits them as+ // one undo step.+ static constexpr size_t kLabelMax = 24, kNoteMax = 2000; // UTF-8 code points+ std::vector<uint8_t> getState() const override;+ void setState(const uint8_t* data, int32_t size) override;+ const std::string& bandLabel(int b) const { return label_[std::clamp(b, 0, kBands - 1)]; }+ const std::string& bandNote(int b) const { return note_[std::clamp(b, 0, kBands - 1)]; }+ void setBandText(int b, const std::string& label, const std::string& note);+private:+ std::string label_[kBands], note_[kBands];+static constexpr int kMaxSec = 4;static constexpr int kCtrl = 16; // control-rate cascade re-build while a band glidesstatic constexpr int kAutoKeys = Scale + 1; // band params, slopes, channels and Scale shape the curvediff --git a/src/native/nota.engine/src/engine/Engine.cpp b/src/native/nota.engine/src/engine/Engine.cppindex f4f8d662..07a3794c 100644--- a/src/native/nota.engine/src/engine/Engine.cpp+++ b/src/native/nota.engine/src/engine/Engine.cpp@@ -4,6 +4,7 @@// Engine — lifecycle, audio/MIDI device config, preview, tone/transport setters, immutable-graph publish/clone/undo/reset, post-fader meters. Definitions of the rest of the class live in the sibling Engine_*.cpp slices.#include "Engine.h"+#include "devices/effects/Eq.h"#include "devices/racks/RackCore.h"#include "audio_io/AudioBackendFactory.h"#include "media/AudioFile.h"@@ -809,6 +810,14 @@ bool Engine::applyMix(const MixChange& c, bool after) {const float v = after ? c.after : c.before;if (c.kind == MixKind::PresetTag)return setPresetTagIndex(c.trackId, c.paramIndex, c.deviceIndex, static_cast<int32_t>(v)); // gone: skip+ if (c.kind == MixKind::DeviceNotes) { // specs/049: an EQ-8's labels and notes+ auto* eq = dynamic_cast<Eq*>(deviceAt(c.trackId, c.deviceIndex));+ const auto at = static_cast<size_t>(v);+ if (!eq || at >= noteStates_.size()) return false; // gone (or no longer an EQ-8): skip+ const auto& st = noteStates_[at];+ eq->setState(st.data(), static_cast<int32_t>(st.size()));+ return true;+ }if (c.kind == MixKind::MasterVolume) {setMasterVolume(v);return true;diff --git a/src/native/nota.engine/src/engine/Engine.h b/src/native/nota.engine/src/engine/Engine.hindex d52e8b4e..8c25766e 100644--- a/src/native/nota.engine/src/engine/Engine.h+++ b/src/native/nota.engine/src/engine/Engine.h@@ -821,6 +821,12 @@ class Engine {// Load an auxiliary file into a device (the Chamber's user IR) / read its resource text.bool deviceLoadFile(int32_t trackId, int32_t deviceIndex, const std::string& path);std::string deviceText(int32_t trackId, int32_t deviceIndex, int32_t id) const;+ // EQ-8 band labels and notes (specs/049). set replaces one band's label and note (cleaned+ // to their limits) as one undo step; false when the device isn't an EQ-8, the band is out+ // of range or nothing changed. get: which 0 = label, 1 = note ("" when none).+ bool setEqBandText(int32_t trackId, int32_t deviceIndex, int32_t band, const std::string& label,+ const std::string& note);+ std::string eqBandText(int32_t trackId, int32_t deviceIndex, int32_t band, int32_t which) const;int32_t deviceParamCount(int32_t trackId, int32_t deviceIndex) const;const char* deviceParamName(int32_t trackId, int32_t deviceIndex, int32_t paramIndex) const;float deviceParamMin(int32_t trackId, int32_t deviceIndex, int32_t paramIndex) const;@@ -1642,6 +1648,9 @@ class Engine {bool presetTagSelfTest();private:+ // The EQ-8 annotation states undo steps point at (specs/049): append-only, 0 = none. A step+ // holds the indices of the device's whole state before and after the edit.+ std::vector<std::vector<uint8_t>> noteStates_ = std::vector<std::vector<uint8_t>>(1);bool applyMix(const MixChange& c, bool after); // write before/after; false = gonestatic void mergeMix(std::vector<MixChange>& into, const std::vector<MixChange>& later);static constexpr size_t kMaxUndoDepth = 128;diff --git a/src/native/nota.engine/src/engine/EngineTypes.h b/src/native/nota.engine/src/engine/EngineTypes.hindex 5d4fce67..a392c7e5 100644--- a/src/native/nota.engine/src/engine/EngineTypes.h+++ b/src/native/nota.engine/src/engine/EngineTypes.h@@ -101,7 +101,8 @@ enum class MixKind : int32_t {DeviceParam = 3,MidiDeviceParam = 4,PluginParam = 5,- PresetTag = 6 // a device's preset tag (specs/048): deviceIndex as above, paramIndex = the surface+ PresetTag = 6, // a device's preset tag (specs/048): deviceIndex as above, paramIndex = the surface+ DeviceNotes = 7 // an EQ-8's band labels and notes (specs/049): the value indexes Engine::noteStates_};struct MixTarget {MixKind kind;diff --git a/src/native/nota.engine/src/engine/Engine_Devices.cpp b/src/native/nota.engine/src/engine/Engine_Devices.cppindex 5503f2bd..eed2b1fe 100644--- a/src/native/nota.engine/src/engine/Engine_Devices.cpp+++ b/src/native/nota.engine/src/engine/Engine_Devices.cpp@@ -1450,6 +1450,33 @@ void Engine::deviceSetState(int32_t trackId, int32_t deviceIndex, const uint8_t*if (auto* d = deviceAt(trackId, deviceIndex)) d->setState(data, size);}+bool Engine::setEqBandText(+ int32_t trackId, int32_t deviceIndex, int32_t band, const std::string& label, const std::string& note) {+ auto* eq = dynamic_cast<Eq*>(deviceAt(trackId, deviceIndex));+ if (!eq || band < 0 || band >= Eq::kBands) return false;+ auto before = eq->getState();+ eq->setBandText(band, label, note);+ auto after = eq->getState();+ if (after == before) return false;+ // One mix-only undo step that swaps the device's annotation state (specs/049).+ noteStates_.push_back(std::move(before));+ noteStates_.push_back(std::move(after));+ const auto at = static_cast<float>(noteStates_.size() - 2);+ undoStack_.push_back({nullptr, {MixChange{MixKind::DeviceNotes, trackId, at, at + 1.0f, deviceIndex, -1}}});+ if (undoStack_.size() > kMaxUndoDepth) {+ undoStack_.erase(undoStack_.begin());+ if (undoGroupDepth_ > 0 && undoGroupBase_ > 0) --undoGroupBase_;+ }+ redoStack_.clear();+ return true;+}++std::string Engine::eqBandText(int32_t trackId, int32_t deviceIndex, int32_t band, int32_t which) const {+ auto* eq = dynamic_cast<Eq*>(deviceAt(trackId, deviceIndex));+ if (!eq || band < 0 || band >= Eq::kBands) return {};+ return which == 1 ? eq->bandNote(band) : eq->bandLabel(band);+}+bool Engine::deviceLoadFile(int32_t trackId, int32_t deviceIndex, const std::string& path) {auto* d = deviceAt(trackId, deviceIndex);return d && d->loadFile(path);diff --git a/tests/Nota.SmokeTest/EqAnalyzerTests.cs b/tests/Nota.SmokeTest/EqAnalyzerTests.csindex 3bfbe330..7c137277 100644--- a/tests/Nota.SmokeTest/EqAnalyzerTests.cs+++ b/tests/Nota.SmokeTest/EqAnalyzerTests.cs@@ -409,7 +409,7 @@ internal static class EqAnalyzerTestsint t = e.AddAudioTrack();e.AddAudioClip(t, wav, 0.0);int d = e.AddBuiltinDevice(t, Eq8Kind);- yield return (e.DeviceParamCount(t, d) == 62 && e.DeviceGetParam(t, d, AnaRange) == 1f && e.DeviceGetParam(t, d, AnaPeak) == 0f+ yield return (e.DeviceParamCount(t, d) >= 62 && e.DeviceGetParam(t, d, AnaRange) == 1f && e.DeviceGetParam(t, d, AnaPeak) == 0f&& e.DeviceParamName(t, d, AnaRange) == "Analyzer Range" && e.DeviceParamName(t, d, AnaPeak) == "Analyzer Peak","EQ-8 appends Analyzer Range (default 90 dB) and Analyzer Peak (default off)");@@ -430,7 +430,7 @@ internal static class EqAnalyzerTestsvar doc = ProjectService.Capture(e, new TransportState(120.0, 1.0, false, false), new List<string>());var dev = doc.Tracks.SelectMany(tr => tr.Devices).First(x => x.BuiltinKind == Eq8Kind);- bool saved = dev.Params.Length == 62 && dev.Params[AnaRange] == 2f && dev.Params[AnaPeak] == 1f;+ bool saved = dev.Params.Length >= 62 && dev.Params[AnaRange] == 2f && dev.Params[AnaPeak] == 1f;dev.Params = dev.Params[..60]; // as written before 0.58.1string dir = Path.Combine(Path.GetTempPath(), "nota-smoke-eqa-" + Guid.NewGuid().ToString("N"));Directory.CreateDirectory(dir);diff --git a/tests/Nota.SmokeTest/EqLabelTests.cs b/tests/Nota.SmokeTest/EqLabelTests.csnew file mode 100644index 00000000..7f9d79e4--- /dev/null+++ b/tests/Nota.SmokeTest/EqLabelTests.cs@@ -0,0 +1,233 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// EQ-8 band labels and notes (specs/049, #135): each band keeps a label and a note, cleaned to+// their limits; an edit is one undo step; they ride on the device's state through a project, a+// user preset, a device duplicate and a track duplicate; a factory preset / Init clears them; a+// plain EQ-8 still saves no state; MCP reads them; and the sound is bit-identical with or+// without them. Also runnable alone: `--eq-labels`.++using Nota.Application;+using Nota.Infrastructure;++namespace Nota.SmokeTest;++internal static class EqLabelTests+{+ private const int Eq8Kind = 0, LabelsP = 62, Rate = 44100;++ public static IEnumerable<(bool, string)> Run()+ {+ var tmp = new List<string>();+ try+ {+ foreach (var r in Text()) yield return r;+ foreach (var r in Undo()) yield return r;+ foreach (var r in Copies()) yield return r;+ foreach (var r in Project()) yield return r;+ foreach (var r in Presets()) yield return r;+ foreach (var r in Sound(tmp)) yield return r;+ }+ finally { foreach (var f in tmp) try { File.Delete(f); } catch (IOException) { } }+ }++ private static (NotaEngine E, int T, int D) NewEq()+ {+ var e = new NotaEngine();+ int t = e.AddAudioTrack();+ return (e, t, e.AddBuiltinDevice(t, Eq8Kind));+ }++ private static string L(IAudioEngine e, int t, int d, int b) => e.EqBandText(t, d, b, 0);+ private static string N(IAudioEngine e, int t, int d, int b) => e.EqBandText(t, d, b, 1);++ private static IEnumerable<(bool, string)> Text()+ {+ var (e, t, d) = NewEq();+ using var _ = e;+ yield return (e.DeviceParamCount(t, d) == 63 && e.DeviceParamName(t, d, LabelsP) == "Labels" && e.DeviceGetParam(t, d, LabelsP) == 1f+ && e.DeviceGetState(t, d).Length == 0 && L(e, t, d, 0) == "",+ "EQ-8 appends Labels (on by default); a fresh EQ-8 has no labels and saves no state");++ bool set = e.EqSetBandText(t, d, 3, " Resonance ", "Narrow cut for the ring.\nDon't go past −6 dB.");+ yield return (set && L(e, t, d, 3) == "Resonance" && N(e, t, d, 3) == "Narrow cut for the ring.\nDon't go past −6 dB."+ && L(e, t, d, 2) == "",+ $"a band takes a label (trimmed) and a multiline note: \"{L(e, t, d, 3)}\"");++ e.EqSetBandText(t, d, 0, "Гул\nснизу\tи", "");+ string longLabel = new string('x', 40), longNote = new string('n', 2500);+ e.EqSetBandText(t, d, 1, longLabel, longNote);+ yield return (L(e, t, d, 0) == "Гул снизу и" && L(e, t, d, 1).Length == 24 && N(e, t, d, 1).Length == 2000,+ $"labels keep Cyrillic, turn line breaks into spaces (\"{L(e, t, d, 0)}\") and stop at 24 characters, notes at 2000");++ e.EqSetBandText(t, d, 2, " x ", " - indented\nlast line\n\n");+ string exact = N(e, t, d, 2);+ e.EqSetBandText(t, d, 2, "", " \n ");+ yield return (exact == " - indented\nlast line\n\n" && N(e, t, d, 2) == "",+ "a note is kept exactly (leading spaces, blank lines) and a blank note is empty");++ bool same = e.EqSetBandText(t, d, 3, "Resonance", N(e, t, d, 3));+ bool bad = e.EqSetBandText(t, d, 8, "x", "") || e.EqSetBandText(t, d, -1, "x", "");+ int other = e.AddBuiltinDevice(t, 3); // a Delay+ bool notEq = e.EqSetBandText(t, other, 0, "x", "");+ yield return (!same && !bad && !notEq && L(e, t, other, 0) == "",+ "the same text changes nothing; bands outside 1–8 and other devices are refused");++ string summary = e.DeviceText(t, d, 0);+ yield return (summary.Contains("B4 label \"Resonance\"") && summary.Contains("note \"Narrow cut"),+ "the device text (MCP) lists the labels and notes");+ }++ private static IEnumerable<(bool, string)> Undo()+ {+ var (e, t, d) = NewEq();+ using var _ = e;+ e.EqSetBandText(t, d, 2, "Mud", "");+ e.EqSetBandText(t, d, 2, "Mud", "200 Hz build-up");+ bool u1 = e.Undo();+ bool afterOne = L(e, t, d, 2) == "Mud" && N(e, t, d, 2) == "";+ bool u2 = e.Undo();+ bool afterTwo = L(e, t, d, 2) == "" && e.DeviceGetState(t, d).Length == 0;+ bool r = e.Redo() && e.Redo();+ yield return (u1 && afterOne && u2 && afterTwo && r && N(e, t, d, 2) == "200 Hz build-up",+ "each label or note edit is one undo step, and redo brings it back");++ // A band param edit in between keeps its own step.+ e.DeviceSetParam(t, d, 2 * 5 + 2, 250f);+ e.EqSetBandText(t, d, 2, "Mud 250", "200 Hz build-up");+ e.Undo();+ yield return (L(e, t, d, 2) == "Mud" && e.DeviceGetParam(t, d, 2 * 5 + 2) == 250f,+ "undoing a label leaves the band's params as they are");+ }++ private static IEnumerable<(bool, string)> Copies()+ {+ var (e, t, d) = NewEq();+ using var _ = e;+ e.EqSetBandText(t, d, 5, "Air", "Gentle lift");+ int dd = e.DuplicateDevice(t, d);+ int t2 = e.DuplicateTrack(t);+ int d2 = -1;+ for (int i = 0; t2 > 0 && i < e.TrackDeviceCount(t2); i++)+ if (e.TrackDeviceBuiltinKind(t2, i) == Eq8Kind) { d2 = i; break; }+ yield return (dd >= 0 && L(e, t, dd, 5) == "Air" && N(e, t, dd, 5) == "Gentle lift" && d2 >= 0 && L(e, t2, d2, 5) == "Air",+ "a duplicated device and a duplicated track keep the labels and notes");+ e.EqSetBandText(t, dd, 5, "Copy", "");+ yield return (L(e, t, d, 5) == "Air", "editing the copy leaves the original alone");+ }++ private static IEnumerable<(bool, string)> Project()+ {+ var (e, t, d) = NewEq();+ using var _ = e;+ for (int b = 0; b < 8; b++) e.EqSetBandText(t, d, b, $"Band {b + 1} ✓", $"Line one of {b + 1}\nЛиния два");+ e.DeviceSetParam(t, d, LabelsP, 0f);+ var doc = ProjectService.Capture(e, new TransportState(120.0, 1.0, false, false), new List<string>());+ string dir = Path.Combine(Path.GetTempPath(), "nota-smoke-eql-" + Guid.NewGuid().ToString("N"));+ Directory.CreateDirectory(dir);+ try+ {+ ProjectService.Save(doc, dir, e);+ doc = ProjectService.Load(dir);+ using var back = new NotaEngine();+ ProjectService.Apply(doc, back, dir);+ int bt = -1;+ for (int i = 0; i < back.TrackCount; i++)+ if (back.TryGetTrackInfo(i, out var ti) && !ti.IsInstrument && !ti.IsReturn && !ti.IsGroup) { bt = ti.Id; break; }+ bool all = bt >= 0;+ for (int b = 0; b < 8 && all; b++)+ all = L(back, bt, 0, b) == L(e, t, d, b) && N(back, bt, 0, b) == N(e, t, d, b);+ yield return (all && back.DeviceGetParam(bt, 0, LabelsP) == 0f+ && back.DeviceGetState(bt, 0).AsSpan().SequenceEqual(e.DeviceGetState(t, d)),+ "all eight labels and notes and the Labels switch come back byte-identical from a saved project");++ // An EQ-8 saved before labels: 62 params, no state.+ var dev = doc.Tracks.SelectMany(tr => tr.Devices).First(x => x.BuiltinKind == Eq8Kind);+ dev.Params = dev.Params[..62];+ dev.State = null;+ using var old = new NotaEngine();+ ProjectService.Apply(doc, old, dir);+ int ot = -1;+ for (int i = 0; i < old.TrackCount; i++)+ if (old.TryGetTrackInfo(i, out var ti) && !ti.IsInstrument && !ti.IsReturn && !ti.IsGroup) { ot = ti.Id; break; }+ yield return (ot >= 0 && L(old, ot, 0, 0) == "" && old.DeviceGetParam(ot, 0, LabelsP) == 1f,+ "an older project opens with no labels and Labels on");+ }+ finally { Directory.Delete(dir, true); }+ }++ private static IEnumerable<(bool, string)> Presets()+ {+ var (e, t, d) = NewEq();+ using var _ = e;+ e.EqSetBandText(t, d, 1, "Body", "Warmth around 300 Hz");+ e.DeviceSetParam(t, d, 1 * 5 + 3, 3f);+ var doc = PresetService.Capture(e, t, d, "Vocal");+ yield return (doc?.BandText is { Count: 1 } bt && bt[0].Band == 2 && bt[0].Label == "Body",+ "a user preset of an EQ-8 saves its band labels and notes");++ // Through the file format, then onto a new EQ-8 and in place onto another one.+ string json = System.Text.Json.JsonSerializer.Serialize(doc);+ var loaded = System.Text.Json.JsonSerializer.Deserialize<PresetDocument>(json)!;+ int t2 = e.AddAudioTrack();+ PresetService.Apply(loaded, e, t2);+ int nd = e.TrackDeviceCount(t2) - 1;+ int other = e.AddBuiltinDevice(t2, Eq8Kind);+ e.EqSetBandText(t2, other, 6, "Old", "left over");+ PresetService.ApplyInPlace(loaded, e, t2, other);+ yield return (L(e, t2, nd, 1) == "Body" && N(e, t2, nd, 1) == "Warmth around 300 Hz"+ && L(e, t2, other, 1) == "Body" && L(e, t2, other, 6) == "",+ "loading it, new or in place, gives the EQ-8 exactly the preset's labels");++ // A preset without labels (a factory one) and Init clear them.+ var plain = new PresetDocument { Type = "builtin-effect", BuiltinKind = Eq8Kind, NamedParams = new() };+ PresetService.ApplyInPlace(plain, e, t, d);+ bool clearedByPreset = L(e, t, d, 1) == "";+ e.EqSetBandText(t, d, 4, "Again", "");+ PresetService.ResetInPlace(e, t, d, false);+ yield return (clearedByPreset && L(e, t, d, 4) == "", "a factory preset and Init clear the labels");++ var tools = new Nota.Mcp.Tools.DeviceTools(e, new SyncDispatch(), new NoRefresh());+ var band = tools.SetEq8Band(t, d, 3, label: "Presence", note: "Keep it subtle").GetAwaiter().GetResult();+ yield return (band.Label == "Presence" && band.Note == "Keep it subtle" && L(e, t, d, 2) == "Presence",+ "MCP set_eq8_band sets a band's label and note, and read_eq8 reads them back");++ float freqBefore = e.DeviceGetParam(t, d, 2 * 5 + 2);+ bool refused = false;+ try { tools.SetEq8Band(t, d, 3, label: "Changed", freqHz: 5000, slope: 36).GetAwaiter().GetResult(); }+ catch (ArgumentException) { refused = true; }+ yield return (refused && L(e, t, d, 2) == "Presence" && e.DeviceGetParam(t, d, 2 * 5 + 2) == freqBefore,+ "a refused set_eq8_band (bad slope) changes neither the text nor the params");+ }++ private static IEnumerable<(bool, string)> Sound(List<string> tmp)+ {+ var path = Path.Combine(Path.GetTempPath(), $"nota-eql-{Guid.NewGuid():N}.wav");+ int n = Rate * 2;+ var x = new float[n * 2];+ for (int i = 0; i < n; i++) x[2 * i] = x[2 * i + 1] = (float)(0.25 * Math.Sin(2 * Math.PI * 220 * i / Rate) + 0.1 * Math.Sin(2 * Math.PI * 3100 * i / Rate));+ using (var w = new Nota.Infrastructure.WavWriter(path, Rate, 2, WavBitDepth.Float32)) w.WriteFrames(x, n);+ tmp.Add(path);++ float[] RenderWith(bool labelled)+ {+ using var e = new NotaEngine();+ int t = e.AddAudioTrack();+ e.AddAudioClip(t, path, 0.0);+ int d = e.AddBuiltinDevice(t, Eq8Kind);+ e.DeviceSetParam(t, d, 1 * 5 + 3, 6f); // band 2 bell +6 dB, so the EQ does something+ if (labelled)+ {+ for (int b = 0; b < 8; b++) e.EqSetBandText(t, d, b, $"B{b}", "note");+ e.DeviceSetParam(t, d, LabelsP, 0f);+ }+ var buf = new float[16384 * 2];+ e.Seek(0); e.Play(); e.RenderOffline(buf, 16384); e.StopTransport();+ return buf;+ }+ var plain = RenderWith(false);+ var labelled = RenderWith(true);+ yield return (plain.AsSpan().SequenceEqual(labelled) && plain.Any(v => Math.Abs(v) > 0.01f),+ "labels, notes and the Labels switch leave the sound bit-identical");+ }+}diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.csindex 629d0492..a43fbc6c 100644--- a/tests/Nota.SmokeTest/Program.cs+++ b/tests/Nota.SmokeTest/Program.cs@@ -477,6 +477,14 @@ if (args.Length >= 1 && args[0] == "--eq-analyzer")Console.WriteLine(failures == 0 ? "EQ ANALYZER PASSED" : $"EQ ANALYZER FAILED ({failures})");return failures == 0 ? 0 : 1;}+// EQ-8 band labels and notes alone (specs/049): `--eq-labels`. Also part of the full run.+if (args.Length >= 1 && args[0] == "--eq-labels")+{+ Console.WriteLine("-- eq labels --");+ foreach (var (ok, label) in EqLabelTests.Run()) Check(ok, label);+ Console.WriteLine(failures == 0 ? "EQ LABELS PASSED" : $"EQ LABELS FAILED ({failures})");+ return failures == 0 ? 0 : 1;+}// Preset state alone: `--preset-state` (specs/048). Also part of the full run.if (args.Length >= 1 && args[0] == "--preset-state"){@@ -4355,7 +4363,7 @@ Check(m4Dry > 1e-4f, $"instrument audible (rms={m4Dry:0.0000})");int eqDev = engine.AddBuiltinDevice(fxT, 0); // 0 = EQ-8 (flat by default = passthrough)Check(eqDev >= 0, "add built-in EQ-8");Check(engine.DeviceName(fxT, eqDev) == "Nota EQ-8", "EQ-8 device name");-Check(engine.DeviceParamCount(fxT, eqDev) == 62, "EQ-8 exposes 62 params (8 bands × 5, slopes, channels, globals, analyzer range and peak)");+Check(engine.DeviceParamCount(fxT, eqDev) == 63, "EQ-8 exposes 63 params (8 bands × 5, slopes, channels, globals, analyzer range and peak, labels)");engine.Seek(0);engine.RenderOffline(buf, frames);Check(Rms(buf, frames) > 1e-4f, $"audio flows through flat EQ-8 (rms={Rms(buf, frames):0.0000})");@@ -6980,7 +6988,7 @@ Console.WriteLine("-- EQ-8 --");engine.AddMidiClip(et, 0.0, 4.0);engine.SetClipNotes(et, 0, new[] { new NotaNote(69, 0.0, 3.0, 0.9f) }); // A4 = 440 Hz + harmonicsint eq = engine.AddBuiltinDevice(et, 0);- Check(engine.DeviceParamCount(et, eq) == 62, "EQ-8 has 62 params on a fresh track");+ Check(engine.DeviceParamCount(et, eq) == 63, "EQ-8 has 63 params on a fresh track");// Band 3 (index 2) is a bell; param base = 2*5. On=+0, Type=+1, Freq=+2, Gain=+3, Q=+4.int b2 = 2 * 5;@@ -15221,6 +15229,8 @@ foreach (var (ok, label) in PresetStateTests.Run()) Check(ok, label);Console.WriteLine("-- eq analyzer --");foreach (var (ok, label) in EqAnalyzerTests.Run()) Check(ok, label);+Console.WriteLine("-- eq labels --");+foreach (var (ok, label) in EqLabelTests.Run()) Check(ok, label);Console.WriteLine("-- scope view --");foreach (var (ok, label) in ScopeViewTests.Run()) Check(ok, label);