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) Clip editor track mode: every MIDI clip of the track (#49) (#395)
Chris Laupamab14e293c58dc
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 90366a91..80459c57 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -23,6 +23,14 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.## [Unreleased]### Added+- **Clip editor track mode** (#49): a **Clip | Track** switch at the top of the Clip editor's+ inspector (and *Toggle clip editor track mode* in the command palette). Track shows every MIDI clip of the+ track on the arrangement's timeline from bar 1, each clip's borders marked in the clip strip,+ so you can scroll through the whole part and edit any note without re-selecting clips —+ moves across clip seams, rubber band across clips, reference locks and one-step undo work as+ in multi-clip editing. Selecting another clip of the track makes it active and scrolls to it;+ a clip on another track opens that track; clips drawn, pasted or recorded on the track join.+ Nota remembers the mode; Clip opens one clip as before.- **Automatic section names and Reset to default** (#106): new arrangement sections are named"Section N" for their place in the song — left to right, custom-named sections counted — andrenumber when sections are added, moved, duplicated or deleted; custom names stay as typed.diff --git a/FEATURES.md b/FEATURES.mdindex ed53839d..9003abcd 100644--- a/FEATURES.md+++ b/FEATURES.md@@ -353,6 +353,12 @@ docks as a panel under any of the three, or floats in its own window — seeclick its lock to keep it as a dimmed, read-only reference. While the Clip tab isopen it follows the arrangement selection. ⌘D copies that run past a clip's end continueinto the next open clip; past the last one they are left out.+ - **Track mode**: the **Clip | Track** switch at the top of the inspector (also *Toggle+ clip editor track mode* in the command palette) opens every MIDI clip of the track on the+ arrangement's bars from bar 1, each clip marked in the clip strip, with the same editing+ as several clips at once. Selecting a clip of the track makes it active and scrolls to it;+ a clip on another track opens that track; new clips on the track join. The mode is+ remembered.- **Clip tools (generate and transform)**: a **Tools** rail beside the piano roll withfifteen tools that write or rewrite notes. Six **generators** — *Rhythm* (a pattern thatleans on the strong beats), *Seed* (learns the clip's own intervals and rhythm, thendiff --git a/specs/059-clip-editor-track-mode/checklists/requirements.md b/specs/059-clip-editor-track-mode/checklists/requirements.mdnew file mode 100644index 00000000..132cf557--- /dev/null+++ b/specs/059-clip-editor-track-mode/checklists/requirements.md@@ -0,0 +1,35 @@+# Specification Quality Checklist: Clip Editor Track Mode++**Purpose**: Validate specification completeness and quality before proceeding to planning+**Created**: 2026-10-30+**Feature**: [spec.md](../spec.md)++## Content Quality++- [x] No implementation details (languages, frameworks, APIs)+- [x] Focused on user value and business needs+- [x] Written for non-technical stakeholders+- [x] All mandatory sections completed++## Requirement Completeness++- [x] No [NEEDS CLARIFICATION] markers remain+- [x] Requirements are testable and unambiguous+- [x] Success criteria are measurable+- [x] Success criteria are technology-agnostic (no implementation details)+- [x] All acceptance scenarios are defined+- [x] Edge cases are identified+- [x] Scope is clearly bounded+- [x] Dependencies and assumptions identified++## Feature Readiness++- [x] All functional requirements have clear acceptance criteria+- [x] User scenarios cover primary flows+- [x] Feature meets measurable outcomes defined in Success Criteria+- [x] No implementation details leak into specification++## Notes++- Open questions in the issue (switch placement, persistence, axis, gaps) were answered with+ defaults recorded under Clarifications in the spec.diff --git a/specs/059-clip-editor-track-mode/plan.md b/specs/059-clip-editor-track-mode/plan.mdnew file mode 100644index 00000000..8d4bbd57--- /dev/null+++ b/specs/059-clip-editor-track-mode/plan.md@@ -0,0 +1,68 @@+# Implementation Plan: Clip Editor Track Mode++**Branch**: `cursor/clip-editor-track-mode-6414` | **Date**: 2026-10-30 | **Spec**: [spec.md](spec.md)++## Summary++Track mode is a spec 029 open clip set holding every MIDI clip of one track, on the+arrangement axis. `ClipSet` gains a `TrackMode` flag (origin at arrangement beat 0, reads as+multi-clip even with one clip) and `Add` (a clip that appeared on the track joins without a+rebuild). `MainWindow` expands the set to the track when the mode is on, follows the selection+by switching the active clip, and saves the mode in settings. The inspector's Clip section gets a+Clip | Track segmented control (the header has no room left at the default window width).++## Technical Context++- **Language**: C# / .NET 10, Avalonia. No engine change, no new C ABI call.+- **Touched**: `Nota.Application/Editing/ClipSet.cs`, `Nota.Application/Settings.cs`,+ `Nota.Application/Palette/CommandCatalog.cs`, `Nota.App/MainWindow.Detail.cs`,+ `Nota.App/MainWindow.Commands.cs`, `Nota.App/ClipEditorView.cs`, `Nota.App/ClipPropsView.cs`,+ `Nota.App/PianoRollView.cs`.+- **Primary Dependencies**: none new (Avalonia as today).+- **Storage**: one new app setting, `ClipEditorTrackMode` (settings JSON); nothing in the+ project file.+- **Audio-Thread Impact**: None. The change is UI-thread only: which clips the editor opens and+ how it lays them out. Note edits still reach the engine through the existing+ `SetClipNotes` / `SetClipNotesLive` C ABI calls, grouped with `BeginUndoGroup` /+ `EndUndoGroup` as in spec 029; the engine publishes its snapshot for them as before (AR-5).+ No allocation, lock, I/O or logging is added on the audio thread (AR-6), no command-queue+ change (AR-4), and the playhead / seek still convert through `Transport` beats (AR-9).+- **Testing**: `tests/Nota.SmokeTest/MultiClipTests.cs` (`--multiclip`), full smoke via+ `scripts/build-linux.sh`.++## Nota: Read Before Planning++UI work → [`DESIGN.md`](../../DESIGN.md): the switch is the existing `segmented` control, the+active clip keeps the orange accent in the clip strip, no new colours.+[`CONTRIBUTING.md`](../../CONTRIBUTING.md): no new dependency, no new source file.++## Constitution Check++| Principle | Status |+|---|---|+| I. Real-time audio safety | Pass — no audio-thread code touched (see Audio-Thread Impact) |+| II. Boundary discipline | Pass — no new C ABI call, no JUCE change |+| III. Licensing hygiene | Pass — no new dependency, no new source file |+| IV. Verification gate | Pass — no engine behaviour change; `ClipSet` track-mode rules added to the smoke test |+| V. One logical change | Pass — one feature |+| VI. Docs in sync | CHANGELOG `[Unreleased]` and FEATURES.md in this change; the user manual (`../nota-docs`, piano-roll page EN + RU) follows in a nota-docs change; no new shortcut, so the Shortcuts pane is unchanged |+| VII. Spec-first | Pass — this spec |+| VIII. Rules not weakened | Pass |++## Design++- `ClipSet(..., trackMode)`: `Origin = 0`, `IsMulti = Count > 1 || TrackMode`. Every multi-clip+ path in the roll (clip strip, per-slot colours, envelope offset, rescroll, seek/playhead via+ `Origin`) then works for a one-clip track too.+- `ClipSet.Add(OpenClip)`: inserts in start order and keeps the active clip; the host reloads+ the roll's notes right after, so note owners are rebuilt from the engine.+- `MainWindow`: `ClipTrackMode` (setting), `SetClipTrackMode` (switch + rebuild on the active+ clip), `MidiClipsOf(track)`, `FocusTrackClip` (same-track selection → `SetActiveClip` ++ `RevealClip`, no rebuild), `AddNewTrackClips` in `ReloadEditorNotes` and on a geometry change+ of a clip not yet open. `BuildClipEditor` swaps its clip list for the track's in track mode,+ so every caller (double-click, Clip tab, retarget after moves) gets it for free.+- `PianoRollView.RevealClip(slot)`: scrolls a clip's start into view when it is off screen.++## Complexity Tracking++None.diff --git a/specs/059-clip-editor-track-mode/spec.md b/specs/059-clip-editor-track-mode/spec.mdnew file mode 100644index 00000000..c061e102--- /dev/null+++ b/specs/059-clip-editor-track-mode/spec.md@@ -0,0 +1,184 @@+# Feature Specification: Clip Editor Track Mode++**Feature Branch**: `cursor/clip-editor-track-mode-6414`++**Created**: 2026-10-30++**Status**: Implemented++**Input**: User description: "Clip editor: track mode showing every clip on the track (GitHub issue nota-daw/nota#49). See and edit the whole track's MIDI in the clip editor, not one clip at a time. A track mode for the clip editor next to the current clip mode: the piano roll spans the arrangement timeline and shows every MIDI clip on the selected track, with clip borders marked, so you can scroll through the part and edit any note without re-selecting clips. Today the clip editor only has a clip mode: it opens the one selected clip. Related: #48 (multi-clip editing)."++## Nota Context *(fill in — drives plan and tasks)*++**Feature area** *(pick the main one)*:++- [ ] Engine (C++, `src/native/nota.engine`) — real-time audio rules apply, see `ARCHITECTURE.md` AR table+- [x] Managed app (C#, `src/managed/*`) — domain, application, infrastructure, presentation+- [x] UI (Avalonia, `src/managed/Nota.Presentation`) — follow `DESIGN.md` (Studio)+- [ ] Plugin hosting (`pluginhost/`) — the only place JUCE is allowed+- [ ] Build / packaging / CI (`scripts/`, `.github/`) — see `BUILD.md`+- [ ] Docs only++The engine is untouched. Track mode is the open clip set of spec 029+([`../029-multi-clip-editing/spec.md`](../029-multi-clip-editing/spec.md)) filled with every+MIDI clip of one track: editing, moving notes across clip seams, reference locks, the clip strip+and one-step undo all come from there.++**Nota docs to keep in mind** *(links relative to `specs/<slug>/`, where this file lands)*:+[`ARCHITECTURE.md`](../../ARCHITECTURE.md) (AR rules),+[`CONTRIBUTING.md`](../../CONTRIBUTING.md) (licensing, dependency policy, PR+expectations), [`BUILD.md`](../../BUILD.md), [`DESIGN.md`](../../DESIGN.md),+[`FEATURES.md`](../../FEATURES.md).++**Current state (for reference)**:++- The Clip editor opens the selected clip (clip mode), or — spec 029 — several selected MIDI+ clips together on a shared timeline, with a clip strip under the ruler.+- There is no way to see every clip of a track without selecting them all by hand.++## Clarifications++The issue leaves these open; each was answered with the default below (no blocking product+question remained). Reviewers can overturn any of them without reworking the design.++- Q: Where is the switch? → A: A **Clip | Track** segmented control at the top of the+ inspector's Clip section (the header is full at the default 1200 px window), plus a palette command "Toggle clip editor track mode". No default+ shortcut.+- Q: Does the mode stick? → A: Yes, it is an app setting (saved like note audition): once on,+ every arrangement MIDI clip opens in track mode until switched back.+- Q: What does the timeline cover? → A: The arrangement's own axis from bar 1 to the end of the+ track's last MIDI clip; bar numbers match the arrangement. The editor opens scrolled to the+ clicked clip.+- Q: What happens when drawing in a gap between clips? → A: Nothing, as in spec 029 (FR-007).+ Making clips stays an arrangement edit.+- Q: Which track? → A: The track of the clip that was double-clicked / selected. Selecting a+ clip of the same track makes it active and scrolls to it; a clip on another track switches the+ editor to that track.++## User Scenarios & Testing *(mandatory)*++### User Story 1 - See every clip of a track in the Clip editor (Priority: P1)++A user has a bass line spread over six clips. They switch the Clip editor to Track: the piano+roll now shows all six clips' notes at their arrangement positions, each clip's span marked in+the clip strip, and they scroll through the whole part.++**Why this priority**: The core of the request.++**Independent Test**: Make two MIDI clips on one track at bars 3 and 9, open one, press Track;+the roll's ruler starts at bar 1, both clips' notes show at their bars, the strip marks both.++**Acceptance Scenarios**:++1. **Given** a MIDI clip open in clip mode, **When** the user picks Track, **Then** the editor+ shows every MIDI clip of that track on the arrangement timeline, the clip that was open is+ active, and the strip marks each clip's borders.+2. **Given** track mode, **When** the user double-clicks any MIDI clip, **Then** its whole track+ opens with that clip active and in view.+3. **Given** a track with a single MIDI clip, **When** it opens in track mode, **Then** the clip+ sits at its arrangement position and its borders are marked.+4. **Given** track mode, **When** the user picks Clip, **Then** the editor shows the active clip+ alone, as before this feature.+5. **Given** the app is restarted, **Then** the editor opens in the mode last chosen.++---++### User Story 2 - Edit any note without re-selecting clips (Priority: P1)++In track mode the user clicks and edits notes in any clip, rubber-bands across clips and+transposes, drags a note across a seam into the next clip — all without touching the+arrangement.++**Why this priority**: The issue's "edit any note without re-selecting clips".++**Independent Test**: In track mode, rubber-band notes in two clips and press ↑; both move and+one Undo reverts both.++**Acceptance Scenarios**:++1. **Given** track mode, **Then** every editing rule of spec 029 applies to the track's clips+ (selection, moves, seams, overwrite within a clip, paste, one undo step, reference locks).+2. **Given** track mode, **When** the user clicks a note of another clip, **Then** that clip+ becomes active (header, inspector, envelopes follow).++---++### User Story 3 - The editor follows the track (Priority: P2)++With track mode on and the Clip editor on screen, the user clicks clips in the arrangement: a+clip of the same track becomes active and scrolls into view; a clip on another track opens that+track. A clip drawn, pasted or recorded on the track joins the editor.++**Acceptance Scenarios**:++1. **Given** track mode on track A, **When** the user selects another clip of A, **Then** it+ becomes active and in view, the editor is not rebuilt (reference locks and zoom stay).+2. **Given** track mode on track A, **When** the user selects a MIDI clip on track B, **Then**+ the editor shows track B's clips.+3. **Given** track mode, **When** a new MIDI clip appears on the track (drawn, pasted,+ duplicated, recorded), **Then** it joins the editor once the arrangement refreshes or the+ clip is selected.+4. **Given** track mode, **When** the user runs "Edit selected clips together", **Then** the+ editor leaves track mode and shows the selection (spec 029).++### Edge Cases++- Audio clips on the track are not shown; track mode is MIDI only.+- Session slots have no track mode (the switch is not shown there).+- A track whose last MIDI clip is deleted closes the editor, as in spec 029.+- Clips far apart: the timeline covers bar 1 to the last clip's end; the editor opens at the+ active clip.++## Requirements *(mandatory)*++### Functional Requirements++- **FR-001**: The arrangement Clip editor MUST offer a Clip | Track switch at the top of its inspector and a+ palette command toggling it. Session slot editors MUST NOT show it.+- **FR-002**: In track mode the editor MUST open every MIDI clip of the edited track (the track+ of the double-clicked / selected clip), with that clip active.+- **FR-003**: In track mode the horizontal axis MUST be the arrangement's: editor beat 0 is bar 1,+ and it runs to the end of the track's last MIDI clip. The clip strip MUST mark each clip, even+ when the track has only one.+- **FR-004**: All spec 029 editing behaviour (FR-003 to FR-013 there) MUST apply to the open+ track clips.+- **FR-005**: The mode MUST persist as an app setting and apply to every arrangement MIDI clip+ opened afterwards.+- **FR-006**: While the editor is on screen in track mode, selecting a MIDI clip of the same track+ MUST make it active and scroll it into view without rebuilding the editor; selecting a MIDI clip+ of another track MUST show that track.+- **FR-007**: MIDI clips that appear on the track while it is open MUST join the editor.+- **FR-008**: "Edit selected clips together" MUST switch to clip mode before opening the selection.+- **FR-009**: CHANGELOG and FEATURES.md MUST describe track mode.++### Key Entities++- **Track clip set**: the open clip set of spec 029 holding every MIDI clip of one track, on the+ arrangement axis; marked as track mode.++## Success Criteria *(mandatory)*++### Measurable Outcomes++- **SC-001**: Editing notes in N clips of one track takes one open of the editor, versus N opens+ (or a hand-made selection) today.+- **SC-002**: The ruler's bar numbers in track mode equal the arrangement's in 100% of cases.+- **SC-003**: Users who never pick Track see no change in behaviour.++## Assumptions++- The open clip set, clip strip and editing rules of spec 029 are reused unchanged.+- Notes cannot be drawn in gaps between clips; creating or extending clips from the editor is+ out of scope.+- No new keyboard shortcut; the Shortcuts pane is unchanged (the palette command is bindable+ through the shortcut builder like any other).++## Nota Compliance Checklist *(review before implementation; re-check in tasks.md)*++- [x] Every new source file will carry the AGPL-3.0-only SPDX header (two lines, see CONTRIBUTING.md) — no new source files+- [x] No new dependency+- [x] Audio-thread impact considered: none — note edits use the existing per-clip commit path+- [x] Managed/native crossings go through the pure C ABI in `nota_engine.h` only (AR-7); no new calls+- [x] Smoke-test impact assessed: `ClipSet` track-mode rules added to `tests/Nota.SmokeTest/MultiClipTests.cs`+- [x] User-visible change → `CHANGELOG.md` `[Unreleased]` entry and FEATURES.md+- [x] UI change → follows `DESIGN.md` (Studio design language): the existing segmented control, no new coloursdiff --git a/specs/059-clip-editor-track-mode/tasks.md b/specs/059-clip-editor-track-mode/tasks.mdnew file mode 100644index 00000000..7c2d6a1f--- /dev/null+++ b/specs/059-clip-editor-track-mode/tasks.md@@ -0,0 +1,40 @@+# Tasks: Clip Editor Track Mode++**Input**: [spec.md](spec.md), [plan.md](plan.md)++## Phase 1: Foundational++- [X] T001 `ClipSet` track mode: `trackMode` constructor flag, `TrackMode`, `IsMulti`, origin at 0 in `src/managed/Nota.Application/Editing/ClipSet.cs`+- [X] T002 `ClipSet.Add` for clips that appear on the track in `src/managed/Nota.Application/Editing/ClipSet.cs`+- [X] T003 [P] `ClipEditorTrackMode` setting in `src/managed/Nota.Application/Settings.cs`+- [X] T004 [P] Smoke tests for T001–T002 in `tests/Nota.SmokeTest/MultiClipTests.cs`++## Phase 2: User Story 1 — see every clip of a track (P1)++- [X] T005 [US1] `BuildClipEditor` opens the active clip's whole track in track mode; `MidiClipsOf` in `src/managed/Nota.App/MainWindow.Detail.cs`+- [X] T006 [US1] Clip | Track segmented control (`ModeControl`) at the top of the inspector's Clip section in `src/managed/Nota.App/ClipEditorView.cs` and `ClipPropsView.cs`; header count uses the clip count+- [X] T007 [US1] `SetClipTrackMode` saves the setting and reopens the editor in `src/managed/Nota.App/MainWindow.Detail.cs`+- [X] T008 [US1] Palette command `roll.trackMode` in `CommandCatalog.cs` and `MainWindow.Commands.cs`++## Phase 3: User Story 2 — edit any note (P1)++- [X] T009 [US2] No new code: spec 029 editing applies to the track set (covered by `--multiclip`)++## Phase 4: User Story 3 — follow the track (P2)++- [X] T010 [US3] `FocusTrackClip` + `PianoRollView.RevealClip`: same-track selection makes the clip active without a rebuild (double-click, Clip tab, `FollowClipSelection`)+- [X] T011 [US3] `AddNewTrackClips` in `ReloadEditorNotes` and `OnClipGeometryChanged`+- [X] T012 [US3] "Edit selected clips together" leaves track mode++## Phase 5: Polish++- [X] T013 CHANGELOG `[Unreleased]` and FEATURES.md entries++### Nota closing tasks++- [X] T014 `scripts/build-linux.sh` passes (smoke test included)+- [X] T015 No new source files (SPDX n/a); no new dependency++## Phase 6: Convergence++- [X] T016 Get the smoke test green on CI (macOS, Windows, Linux) — locally `scripts/build-linux.sh` fails only the two render-pool overload timing guards, which fail the same way on unmodified `develop` on the 4-core VM — per Constitution IV / T014 (partial). CI run 41124206352 passed on all three platforms.diff --git a/src/managed/Nota.App/ArrangementView.LaneControl.cs b/src/managed/Nota.App/ArrangementView.LaneControl.csindex 2bb129ed..60f56955 100644--- a/src/managed/Nota.App/ArrangementView.LaneControl.cs+++ b/src/managed/Nota.App/ArrangementView.LaneControl.cs@@ -957,7 +957,7 @@ public sealed partial class ArrangementViewvar edits = new List<Control>{- MenuKit.Item("Split here", GlyphKind.Split, () => { _o._engine?.SplitClip(trackId, idx, at); _o.Refresh(); }, MenuKit.SplitKey),+ MenuKit.Item("Split here", GlyphKind.Split, () => { _o._engine?.SplitClip(trackId, idx, at); _o.Refresh(); _o.ClipsSplit?.Invoke(); }, MenuKit.SplitKey),};// Reverse (audio only): non-destructive, so the label reflects the clicked clip.if (!clip.IsMidi && _o._engine is { } rev && rev.TryGetAudioClipInfo(trackId, idx, out var rai))diff --git a/src/managed/Nota.App/ArrangementView.cs b/src/managed/Nota.App/ArrangementView.csindex bd2e0ce2..d3027d71 100644--- a/src/managed/Nota.App/ArrangementView.cs+++ b/src/managed/Nota.App/ArrangementView.cs@@ -263,6 +263,10 @@ public sealed partial class ArrangementView : UserControl/// all, delete). Raised once per change, after the arrangement has settled its own state;/// the Clip editor follows it (specs/029).</summary>public event Action? ClipSelectionChanged;+ /// <summary>Clips were split (Cmd+E, a time range, the clip menu's "Split here"). A split+ /// inserts the right half after the left, so the clips after it change index: a track-mode+ /// Clip editor reopens the track's clips (specs/059). Raised after the arrangement refreshed.</summary>+ public event Action? ClipsSplit;private (int, int)[] _notifiedSel = Array.Empty<(int, int)>();private bool _selNotifyQueued;@@ -1799,6 +1803,7 @@ public sealed partial class ArrangementView : UserControlvar ids = TimeSelectionTrackIds();if (ids.Length == 0 || !_engine.SplitClipsInRange(ids, _timeSelStart, _timeSelEnd)) return false;Refresh();+ ClipsSplit?.Invoke();return true;}@@ -1936,7 +1941,7 @@ public sealed partial class ArrangementView : UserControlif (at > vm.StartBeat + 1e-6 && at < vm.StartBeat + vm.LengthBeats - 1e-6){ _engine.SplitClip(track, clip, at); any = true; }}- if (any) { Select(-1, -1); Refresh(); }+ if (any) { Select(-1, -1); Refresh(); ClipsSplit?.Invoke(); }return any;}diff --git a/src/managed/Nota.App/ClipEditorView.cs b/src/managed/Nota.App/ClipEditorView.csindex 1d5b922c..12473fdc 100644--- a/src/managed/Nota.App/ClipEditorView.cs+++ b/src/managed/Nota.App/ClipEditorView.cs@@ -36,7 +36,8 @@ public sealed class ClipEditorView : UserControlprivate bool _envMode;public ClipEditorView(PianoRollView roll, string clipName, double startBeat,- IAudioEngine? engine = null, int trackId = -1, int clipIndex = -1, double lengthBeats = 4)+ IAudioEngine? engine = null, int trackId = -1, int clipIndex = -1, double lengthBeats = 4,+ Action<bool>? setTrackMode = null){Roll = roll;_engine = engine;@@ -50,7 +51,7 @@ public sealed class ClipEditorView : UserControl// tab because its whole point is watching the roll change while you turn a knob.// Docked in this order, the inspector picks its columns first, then the tools panel// from what is left, and the roll takes the rest (specs/055).- _props = new ClipPropsView(roll, startBeat);+ _props = new ClipPropsView(roll, startBeat, ModeControl(roll, setTrackMode));DockPanel.SetDock(_props, Dock.Left);_tools = new MidiToolsView(roll) { IsVisible = false };DockPanel.SetDock(_tools, Dock.Right);@@ -81,7 +82,18 @@ public sealed class ClipEditorView : UserControl// "Bass 2 · +2 clips" while several clips are open.private string HeaderName(string name)- => Roll.Clips.IsMulti ? $"{name} · +{Roll.Clips.Count - 1} {(Roll.Clips.Count == 2 ? "clip" : "clips")}" : name;+ => Roll.Clips.Count > 1 ? $"{name} · +{Roll.Clips.Count - 1} {(Roll.Clips.Count == 2 ? "clip" : "clips")}" : name;++ // Clip | Track (specs/059), at the top of the inspector: one clip, or every MIDI clip of its+ // track on the arrangement's timeline. The host rebuilds the editor on a switch. Arrangement+ // clips only.+ private static Control? ModeControl(PianoRollView roll, Action<bool>? setTrackMode)+ {+ if (setTrackMode is null) return null;+ var seg = Segments(new[] { "Clip", "Track" }, roll.Clips.TrackMode ? 1 : 0, i => setTrackMode(i == 1), out _, fill: true);+ ToolTip.SetTip(seg, "Clip: the selected clip · Track: every clip on the track");+ return seg;+ }// Another clip became active: name, colour, start and the envelope target follow it.private void OnActiveClipChanged()diff --git a/src/managed/Nota.App/ClipPropsView.cs b/src/managed/Nota.App/ClipPropsView.csindex 66607c1a..529d9907 100644--- a/src/managed/Nota.App/ClipPropsView.cs+++ b/src/managed/Nota.App/ClipPropsView.cs@@ -2,7 +2,8 @@// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.//// The 232px inspector beside the piano roll (nota-design "Nota Clip Editor" 1a): CLIP-// (Start / Length in bars.beats.16ths, the Loop switch and its length), QUANTIZE (its step,+// (the Clip | Track switch for arrangement clips, Start / Length in bars.beats.16ths, the Loop+// switch and its length), QUANTIZE (its step,// Quantize, strength — the snap grid itself is the header chip), TRANSPOSE (− value +) and SELECTION (the selected note's// pitch / start / length / velocity, or the range of several), ending in one hint line.// Edits drive the PianoRollView; read-outs follow its Changed event.@@ -42,7 +43,9 @@ public sealed class ClipPropsView : UserControlpublic ColumnFlow Flow { get; }- public ClipPropsView(PianoRollView roll, double startBeat)+ /// <param name="mode">The Clip | Track switch (specs/059) heading the CLIP section; none for+ /// a Session slot.</param>+ public ClipPropsView(PianoRollView roll, double startBeat, Control? mode = null){_roll = roll;_startText.Text = Position(startBeat);@@ -52,9 +55,8 @@ public sealed class ClipPropsView : UserControlvar loop = SwitchRow("Loop", () => true, () => { }, out _, _loopText);loop.IsEnabled = false;ToolTip.SetTip(loop, "Clips always loop");- var clip = Section("Clip",- Pair(Labeled("Start", Field(_startText)), Labeled("Length", Field(_lengthText))),- loop);+ var pair = Pair(Labeled("Start", Field(_startText)), Labeled("Length", Field(_lengthText)));+ var clip = mode is null ? Section("Clip", pair, loop) : Section("Clip", mode, pair, loop);// QUANTIZE — its own step (not the snap grid, which follows the zoom), one-tap// Quantize at the strength below.diff --git a/src/managed/Nota.App/MainWindow.Commands.cs b/src/managed/Nota.App/MainWindow.Commands.csindex 4883144b..32b59c63 100644--- a/src/managed/Nota.App/MainWindow.Commands.cs+++ b/src/managed/Nota.App/MainWindow.Commands.cs@@ -137,6 +137,7 @@ public partial class MainWindowB("roll.fold", () => { if (_editorRoll is { } r) r.SetFold(!r.Folded, user: true); }, Roll);B("roll.editSelected", () => EditSelectedClips(),_ => Need(Timeline.SelectedMidiClips().Count >= 2, "Select two or more MIDI clips"));+ B("roll.trackMode", () => SetClipTrackMode(!ClipTrackMode));B("roll.removeOutOfScale", () => _editorRoll?.RemoveOutOfScaleNotes(),c => Need(c.HasOpenMidiClip && _editorRoll?.HasOutOfScaleNotes == true, "No notes outside the scale"));diff --git a/src/managed/Nota.App/MainWindow.Detail.cs b/src/managed/Nota.App/MainWindow.Detail.csindex c8090aae..f7fac457 100644--- a/src/managed/Nota.App/MainWindow.Detail.cs+++ b/src/managed/Nota.App/MainWindow.Detail.cs@@ -384,25 +384,111 @@ public partial class MainWindow// Double-click on a MIDI clip: that clip — or, when it is one of two or more selected MIDI// clips, all of them together with it active (specs/029-multi-clip-editing).+ // In track mode (specs/059) it opens the clip's whole track instead.private void OpenClipEditor(int trackId, int clipIndex){- var sel = Timeline.SelectedMidiClips();- if (sel.Count >= 2 && sel.Contains((trackId, clipIndex))) BuildClipEditor(sel, trackId, clipIndex);- else BuildClipEditor(trackId, clipIndex);+ if (!FocusTrackClip(trackId, clipIndex))+ {+ var sel = Timeline.SelectedMidiClips();+ if (!ClipTrackMode && sel.Count >= 2 && sel.Contains((trackId, clipIndex))) BuildClipEditor(sel, trackId, clipIndex);+ else BuildClipEditor(trackId, clipIndex);+ }ShowClipPanel();}/// <summary>"Edit selected clips": every selected MIDI clip in one editor, the first in time- /// active. False with fewer than two selected.</summary>+ /// active. False with fewer than two selected. Asking for the selection leaves track mode.</summary>internal bool EditSelectedClips(){var sel = Timeline.SelectedMidiClips();if (sel.Count < 2) return false;+ SetClipTrackMode(false, reopen: false);BuildClipEditor(sel, sel[0].TrackId, sel[0].ClipIndex);ShowClipPanel();return true;}+ // --- track mode (specs/059-clip-editor-track-mode, #49) ------------------------------------++ private bool ClipTrackMode => _vm?.Settings.Current.ClipEditorTrackMode == true;++ /// <summary>The Clip | Track switch: saves the mode and reopens an arrangement clip editor in+ /// it on the clip it has active (clip mode shows that clip alone).</summary>+ internal void SetClipTrackMode(bool on, bool reopen = true)+ {+ if (_vm is null || ClipTrackMode == on) return;+ _vm.Settings.Current.ClipEditorTrackMode = on;+ _vm.Settings.Save();+ _vm.StatusText = on ? "Clip editor: every clip on the track" : "Clip editor: one clip";+ if (!reopen || _editorRoll is not { } roll || _clipEditor is null || _editorTrackId <= 0) return;+ bool shown = ClipEditorShown(_clipEditor);+ var a = roll.ActiveClip;+ BuildClipEditor(a.TrackId, a.ClipIndex);+ if (shown) ShowClipPanel();+ }++ // The track's MIDI clips in index order.+ private List<(int TrackId, int ClipIndex)> MidiClipsOf(int trackId)+ {+ var list = new List<(int, int)>();+ if (!ChipTrackInfo(trackId, out var ti)) return list;+ for (int c = 0; c < ti.ClipCount; c++)+ if (Engine.TryGetClipInfo(trackId, c, out var ci) && ci.IsMidi) list.Add((trackId, c));+ return list;+ }++ /// <summary>A track-mode editor already open on this clip's track makes the clip active and+ /// brings it into view instead of being rebuilt. False when there is no such editor.</summary>+ private bool FocusTrackClip(int trackId, int clipIndex)+ {+ if (!ClipTrackMode || _editorRoll is not { Clips.TrackMode: true } roll || _clipEditor is null+ || roll.ActiveClip.TrackId != trackId) return false;+ SyncTrackClips(roll); // an arrangement edit may have added or re-indexed clips+ int slot = roll.Clips.IndexOf(trackId, clipIndex);+ if (slot < 0) return false;+ roll.SetActiveClip(slot);+ roll.RevealClip(slot);+ return true;+ }++ /// <summary>Reopens a track-mode editor's clips from the engine when they no longer match the+ /// track's MIDI clips: one appeared (drawn, pasted, recorded) or an edit re-indexed them (a+ /// split puts the right half after the left, so the later clips shift). The roll keeps its+ /// zoom, scroll and note selection; the active clip is the one still at its start beat.+ /// Whether the roll was reloaded.</summary>+ private bool SyncTrackClips(PianoRollView roll)+ {+ var old = roll.Clips;+ if (!old.TrackMode) return false;+ var a = roll.ActiveClip;+ var now = MidiClipsOf(a.TrackId);+ if (now.Count == 0 || (now.Count == old.Count && now.All(x => old.IndexOf(x.TrackId, x.ClipIndex) >= 0))) return false;+ var items = new List<OpenClip>();+ foreach (var (t, c) in now)+ if (Engine.TryGetClipInfo(t, c, out var info))+ items.Add(new OpenClip(t, c, info.StartBeat, info.LengthBeats > 0 ? info.LengthBeats : 4));+ if (items.Count == 0) return false;+ var sameStart = items.Where(i => Math.Abs(i.StartBeat - a.StartBeat) < 1e-6).ToList();+ var active = sameStart.FirstOrDefault(i => i.ClipIndex == a.ClipIndex) ?? sameStart.FirstOrDefault() ?? items[0];+ var set = new ClipSet(items, a.TrackId, active.ClipIndex, Timeline.BeatsPerBar, trackMode: true);+ // Reference locks stay on the clips that are still where they were.+ foreach (var o in old.Clips)+ {+ if (!o.IsReference) continue;+ int slot = set.IndexOf(o.TrackId, o.ClipIndex);+ if (slot >= 0 && Math.Abs(set.Clips[slot].StartBeat - o.StartBeat) < 1e-6) set.SetReference(slot, true);+ }+ roll.SetClips(set, ClipNotesOf(set), TrackBrush);+ return true;+ }++ // An arrangement edit that re-indexes the track's clips (a split) while no clip is selected.+ private void SyncTrackModeClips()+ {+ if (_editorRoll is { Clips.TrackMode: true } roll && _clipEditor is not null && _editorTrackId > 0)+ SyncTrackClips(roll);+ }+/// <summary>A Clip editor with several arrangement clips open.</summary>private bool MultiClipEditorOpen => _editorRoll is { Clips.IsMulti: true } && _clipEditor is not null && _editorTrackId > 0;@@ -417,6 +503,19 @@ public partial class MainWindow? _clipEditor is not null && ReferenceEquals(_lastClipEditor, _clipEditor): DetailPanel.IsVisible && DetailBody.Content is ClipEditorView;if (!shown) return;+ // Track mode follows the clicked clip: its track, with it active.+ if (ClipTrackMode)+ {+ if (!SelectedClip(out int t, out int c, out bool isMidi) || !isMidi)+ {+ SyncTrackModeClips(); // e.g. a split cleared the selection: the editor still follows the track+ return;+ }+ if (FocusTrackClip(t, c)) return;+ BuildClipEditor(t, c);+ ShowClipPanel();+ return;+ }var midi = Timeline.SelectedMidiClips();if (midi.Count >= 2){@@ -488,10 +587,13 @@ public partial class MainWindow=> BuildClipEditor(new[] { (trackId, clipIndex) }, trackId, clipIndex);// Build the piano-roll editor for a set of arrangement MIDI clips, (activeTrack, activeClip)- // active (no panel switch). One clip is the classic single-clip editor.+ // active (no panel switch). One clip is the classic single-clip editor. In track mode the set+ // is every MIDI clip of the active clip's track.private void BuildClipEditor(IReadOnlyList<(int TrackId, int ClipIndex)> clips, int activeTrack, int activeClip){if (_vm is null) return;+ bool trackMode = ClipTrackMode;+ if (trackMode && MidiClipsOf(activeTrack) is { Count: > 0 } all) clips = all;var open = new List<OpenClip>();foreach (var (t, c) in clips)if (Engine.TryGetClipInfo(t, c, out var info) && info.IsMidi)@@ -500,7 +602,7 @@ public partial class MainWindow// The editor being replaced lets its pending placement go into its own clips first (it// may never have had focus to lose, e.g. after a menu paste)._editorRoll?.SettlePlacement();- var set = new ClipSet(open, activeTrack, activeClip, Timeline.BeatsPerBar);+ var set = new ClipSet(open, activeTrack, activeClip, Timeline.BeatsPerBar, trackMode);PianoRollView roll = null!;roll = new PianoRollView{@@ -557,7 +659,8 @@ public partial class MainWindow_editorClipIndex = set.ActiveClip.ClipIndex;_editorRoll = roll;_clipEditor = new ClipEditorView(roll, $"Track {_editorTrackId} clip", set.ActiveClip.StartBeat, Engine,- _editorTrackId, _editorClipIndex, set.ActiveClip.LengthBeats);+ _editorTrackId, _editorClipIndex, set.ActiveClip.LengthBeats,+ on => SetClipTrackMode(on));// The active clip drives the detail chip, the playhead's live check and the envelopes.roll.ActiveClipChanged += () =>{@@ -676,7 +779,10 @@ public partial class MainWindowif (_patternView is not null && _patternTrackId == trackId && _patternClipIndex == clipIndex && _patternScene < 0)_patternView.Reload();- if (_editorRoll is { } roll && _editorTrackId > 0 && roll.Clips.IndexOf(trackId, clipIndex) >= 0)+ if (_editorRoll is { Clips.TrackMode: true } trackRoll && trackRoll.ActiveClip.TrackId == trackId+ && trackRoll.Clips.IndexOf(trackId, clipIndex) < 0 && ci.IsMidi)+ SyncTrackClips(trackRoll);+ else if (_editorRoll is { } roll && _editorTrackId > 0 && roll.Clips.IndexOf(trackId, clipIndex) >= 0){double len = ci.LengthBeats > 0 ? ci.LengthBeats : 4;var set = roll.Clips;@@ -824,6 +930,7 @@ public partial class MainWindow// Every open clip, as the engine now holds it (undo/redo, recording); clips that are// gone leave the set, and their lengths/starts are re-read.var roll = _editorRoll;+ SyncTrackClips(roll); // a track-mode editor takes clips that appeared or were re-indexed (undo, record)if (!PruneDeadClips(roll)) return;var set = roll.Clips;foreach (var c in set.Clips.ToList())@@ -882,7 +989,7 @@ public partial class MainWindow}if (isMidi){- if (_clipEditor is null || _editorTrackId != tid || _editorClipIndex != ci)+ if (!FocusTrackClip(tid, ci) && (_clipEditor is null || _editorTrackId != tid || _editorClipIndex != ci))BuildClipEditor(tid, ci);ShowClipPanel();}diff --git a/src/managed/Nota.App/MainWindow.Menu.cs b/src/managed/Nota.App/MainWindow.Menu.csindex 44cc31c6..3beec7ed 100644--- a/src/managed/Nota.App/MainWindow.Menu.cs+++ b/src/managed/Nota.App/MainWindow.Menu.cs@@ -134,6 +134,7 @@ public partial class MainWindowprivate void OnMenuSplit(object? sender, EventArgs e){if (_vm is null) return;+ _editorRoll?.SettlePlacement(); // lands in the clips as they are numbered now, before the split re-indexes them// In the piano roll Cmd+E has no note meaning; only split arrangement clips.// A time-range selection wins: split every covered track at the range edges.if (Timeline.SplitTimeSelection()) { _session?.Refresh(); _vm.StatusText = "Split at selection"; return; }diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.csindex f770398f..db00df63 100644--- a/src/managed/Nota.App/MainWindow.axaml.cs+++ b/src/managed/Nota.App/MainWindow.axaml.cs@@ -430,6 +430,7 @@ public partial class MainWindow : WindowHookDeviceMoves(); // Replace… / Delete track on the instrument, Move to track (specs/043)Timeline.TrackSelected += OnTrackSelected;Timeline.ClipGeometryChanged += OnClipGeometryChanged; // clip trimmed/moved → follow it in the open editor+ Timeline.ClipsSplit += SyncTrackModeClips; // a split re-indexes the track's later clipsTimeline.ClipsMoved += OnClipsMoved; // a block move can re-index the open editor's clipsTimeline.StatusMessage += msg => { if (_vm is not null) _vm.StatusText = msg; }; // automation-follow hints etc.diff --git a/src/managed/Nota.App/PianoRollView.cs b/src/managed/Nota.App/PianoRollView.csindex 7a67b25e..b5f0b280 100644--- a/src/managed/Nota.App/PianoRollView.cs+++ b/src/managed/Nota.App/PianoRollView.cs@@ -298,6 +298,17 @@ public sealed partial class PianoRollView : UserControlSyncScroll(); Invalidate(); SaveView();}+ /// <summary>Scrolls clip <paramref name="slot"/>'s start into view when it is off screen.</summary>+ public void RevealClip(int slot)+ {+ if (slot < 0 || slot >= _set.Count) return;+ double start = _set.EditorStart(slot);+ if (_pixelsPerBeat <= 0) { _pendingScrollTo = start; return; }+ double vpBeats = _gridControl.Bounds.Width / _pixelsPerBeat;+ if (start >= _scrollBeats && start < _scrollBeats + vpBeats) return;+ SetScrollBeats(start);+ }+internal void ScrollByBeats(double delta) => SetScrollBeats(_scrollBeats + delta);internal void ZoomAt(double factor, double beatAnchor)@@ -665,7 +676,12 @@ public sealed partial class PianoRollView : UserControl/// exactly the single-clip editor.</summary>public void SetClips(ClipSet set, IReadOnlyList<ClipNotes> perClip, Func<int, ISolidColorBrush> brushOf){- bool rescroll = !ReferenceEquals(set, _set) && set.IsMulti;+ // A track-mode set refreshed for the same track (a clip drawn, split, pasted; undo)+ // keeps the zoom, scroll and note selection the user is working with (specs/059).+ bool keepView = _set.TrackMode && set.TrackMode && _pixelsPerBeat > 0+ && _set.ActiveClip.TrackId == set.ActiveClip.TrackId;+ var kept = keepView ? SelectedNotesAbsolute() : null;+ bool rescroll = !keepView && !ReferenceEquals(set, _set) && set.IsMulti;_set = set;_slotBrushes.Clear();foreach (var c in set.Clips) _slotBrushes.Add(brushOf(c.TrackId));@@ -674,12 +690,46 @@ public sealed partial class PianoRollView : UserControlset.Merge(perClip, notes, owners);// Multi-clip view state is not remembered per clip: fit the span, then show the active clip.if (set.IsMulti) _clipKey = (int.MinValue, int.MinValue);- Load(notes, owners, Math.Max(1, set.SpanBeats));+ _keepViewOnLoad = keepView;+ try { Load(notes, owners, Math.Max(1, set.SpanBeats)); }+ finally { _keepViewOnLoad = false; }+ if (kept is not null) RestoreSelection(kept);if (rescroll) _pendingScrollTo = set.EditorStart(set.Active);ActiveClipChanged?.Invoke();}private double? _pendingScrollTo; // editor beat to bring into view once the zoom is fitted+ private bool _keepViewOnLoad; // Load keeps the current zoom, scroll and rows (SetClips)++ // The selected notes as (clip, arrangement start, pitch, length): they survive a reload that+ // renumbers the notes, as long as the clip they sit in keeps its index.+ private List<((int Track, int Clip) Clip, double Start, int Pitch, double Length)> SelectedNotesAbsolute()+ {+ var list = new List<((int Track, int Clip) Clip, double Start, int Pitch, double Length)>();+ foreach (int i in _selection)+ {+ if (i < 0 || i >= _notes.Count || _owner[i] >= _set.Count) continue;+ var c = _set.Clips[_owner[i]];+ list.Add(((c.TrackId, c.ClipIndex), _set.Origin + _notes[i].StartBeat, _notes[i].Pitch, _notes[i].LengthBeats));+ }+ return list;+ }++ private void RestoreSelection(List<((int Track, int Clip) Clip, double Start, int Pitch, double Length)> kept)+ {+ if (kept.Count == 0) return;+ for (int i = 0; i < _notes.Count; i++)+ {+ var c = _set.Clips[_owner[i]];+ foreach (var k in kept)+ if (k.Clip == (c.TrackId, c.ClipIndex) && k.Pitch == _notes[i].Pitch+ && Math.Abs(k.Start - (_set.Origin + _notes[i].StartBeat)) < 1e-9+ && Math.Abs(k.Length - _notes[i].LengthBeats) < 1e-9)+ { _selection.Add(i); break; }+ }+ Invalidate();+ Changed?.Invoke(); // Load announced an empty selection: the inspector shows these notes again+ }/// <summary>Makes clip <paramref name="slot"/> the active one (a locked clip is unlocked)./// A pending placement lands first.</summary>@@ -732,11 +782,18 @@ public sealed partial class PianoRollView : UserControl// fitted or zoomed by hand. The saved height is the keyboard's, for unfolding.bool reload = _clipKey.Item1 != int.MinValue && _clipKey == _loadedKey;_loadedKey = _clipKey;- bool keepKitRows = reload && _fold && _rowsArePads;+ bool keepKitRows = (reload && _fold && _rowsArePads) || _keepViewOnLoad;if (!keepKitRows) _rowH = saved ? Math.Clamp(vs.RowH, MinRowH, MaxRowH) : DefaultRowH;_keys.Height = RangeH;_gridControl.Height = RangeH;- if (saved)+ if (_keepViewOnLoad)+ {+ // The same track's clips refreshed: stay where the user is (the span may have changed).+ _scrollBeats = Math.Min(_scrollBeats, MaxScrollBeats);+ _pendingVOffset = _bodyScroll.Offset.Y; _pendingCenter = false;+ SyncScroll();+ }+ else if (saved){_pixelsPerBeat = Math.Clamp(vs.Ppb, MinPpb, MaxPpb);_scrollBeats = Math.Max(0, vs.Scroll);diff --git a/src/managed/Nota.Application/Editing/ClipSet.cs b/src/managed/Nota.Application/Editing/ClipSet.csindex 587ec09e..8fe0b541 100644--- a/src/managed/Nota.Application/Editing/ClipSet.cs+++ b/src/managed/Nota.Application/Editing/ClipSet.cs@@ -35,10 +35,13 @@ public sealed class ClipSet/// (activeTrack, activeClip) is active, or the first in time when it is not among them./// With <paramref name="barBeats"/> > 0 a multi-clip set puts editor beat 0 on the bar/// line at or before the earliest clip, so the editor's grid is the arrangement's; a single- /// clip always starts at editor beat 0.</summary>- public ClipSet(IEnumerable<OpenClip> clips, int activeTrack, int activeClip, double barBeats = 0)+ /// clip always starts at editor beat 0. A <paramref name="trackMode"/> set (specs/059) holds+ /// every MIDI clip of one track and lies on the arrangement's own axis: editor beat 0 is+ /// arrangement beat 0, and it reads as several clips even when the track has only one.</summary>+ public ClipSet(IEnumerable<OpenClip> clips, int activeTrack, int activeClip, double barBeats = 0, bool trackMode = false){_barBeats = barBeats;+ TrackMode = trackMode;_clips = clips.Select(c => c with { IsReference = false }).GroupBy(c => (c.TrackId, c.ClipIndex)).Select(g => g.First()).OrderBy(c => c.StartBeat).ThenBy(c => c.TrackId).ToList();@@ -53,7 +56,10 @@ public sealed class ClipSetpublic IReadOnlyList<OpenClip> Clips => _clips;public int Count => _clips.Count;public bool IsEmpty => _clips.Count == 0;- public bool IsMulti => _clips.Count > 1;+ /// <summary>The set is a whole track's MIDI clips on the arrangement axis (specs/059).</summary>+ public bool TrackMode { get; }+ /// <summary>The editor works on the shared timeline: several clips, or track mode.</summary>+ public bool IsMulti => _clips.Count > 1 || TrackMode;/// <summary>Slot of the active clip: it receives new notes and drives header, inspector and envelopes.</summary>public int Active { get; private set; }public OpenClip ActiveClip => _clips[Active];@@ -65,8 +71,8 @@ public sealed class ClipSetprivate void Measure(){if (_clips.Count == 0) { Origin = 0; SpanBeats = 0; return; }- Origin = _clips.Min(c => c.StartBeat);- if (_clips.Count > 1 && _barBeats > 0) Origin = Math.Floor(Origin / _barBeats + 1e-9) * _barBeats;+ Origin = TrackMode ? 0 : _clips.Min(c => c.StartBeat);+ if (!TrackMode && _clips.Count > 1 && _barBeats > 0) Origin = Math.Floor(Origin / _barBeats + 1e-9) * _barBeats;SpanBeats = _clips.Max(c => c.EndBeat) - Origin;}@@ -115,6 +121,22 @@ public sealed class ClipSetreturn slot;}+ /// <summary>Opens one more clip (a clip that appeared on a track-mode editor's track), in+ /// start order; the active clip stays active. False when it is already open. Slots after it+ /// shift, so the roll must reload its notes.</summary>+ public bool Add(OpenClip clip)+ {+ if (IndexOf(clip.TrackId, clip.ClipIndex) >= 0) return false;+ var active = _clips.Count > 0 ? _clips[Active] : clip;+ var sorted = _clips.Append(clip with { IsReference = false })+ .OrderBy(c => c.StartBeat).ThenBy(c => c.TrackId).ToList();+ _clips.Clear();+ _clips.AddRange(sorted);+ Active = IndexOf(active.TrackId, active.ClipIndex);+ Measure();+ return true;+ }+/// <summary>A clip moved or was trimmed in the arrangement. Slots stay put.</summary>public bool UpdateGeometry(int trackId, int clipIndex, double startBeat, double lengthBeats){diff --git a/src/managed/Nota.Application/Palette/CommandCatalog.cs b/src/managed/Nota.Application/Palette/CommandCatalog.csindex bc5d4620..016b5203 100644--- a/src/managed/Nota.Application/Palette/CommandCatalog.cs+++ b/src/managed/Nota.Application/Palette/CommandCatalog.cs@@ -104,6 +104,7 @@ public static class CommandCatalogC("roll.fitNotes", "Fit to notes", "Piano roll", Shortcut.Shift('F'), "zoom vertical rows height"),C("roll.fold", "Fold the piano roll", "Piano roll", Shortcut.Alt('F').WithShift(), "fold scale rows drum pads names hide keys"),C("roll.editSelected", "Edit selected clips together", "Piano roll", "", "multi clip several open piano roll", view: "Arrangement"),+ C("roll.trackMode", "Toggle clip editor track mode", "Piano roll", "", "track mode whole track all clips every clip piano roll", view: "Arrangement"),// ---- Grid (the arrangement or the piano roll — whichever was used last) -----------C("grid.narrower", "Narrow grid", "Grid", Shortcut.Cmd('1'), "finer smaller snap"),diff --git a/src/managed/Nota.Application/Settings.cs b/src/managed/Nota.Application/Settings.csindex bb01c116..3be6361a 100644--- a/src/managed/Nota.Application/Settings.cs+++ b/src/managed/Nota.Application/Settings.cs@@ -172,6 +172,10 @@ public sealed class Settings/// <summary>Piano-roll note audition (#46): notes sound while they are placed, clicked or/// dragged. The speaker chip in the clip editor's header; on by default.</summary>public bool PianoRollAudition { get; set; } = true;+ /// <summary>Clip editor track mode (specs/059, #49): the piano roll shows every MIDI clip of+ /// the edited track on the arrangement's timeline. The Clip | Track switch at the top of+ /// the clip editor's inspector; off (clip mode) by default.</summary>+ public bool ClipEditorTrackMode { get; set; }/// <summary>Arm-on-select (#332): selecting an instrument track arms it alone, so the/// keyboard plays the track you're on. Transport ▸ Auto-arm selected track; off by default.</summary>public bool ArmOnSelect { get; set; }diff --git a/tests/Nota.SmokeTest/MultiClipTests.cs b/tests/Nota.SmokeTest/MultiClipTests.csindex d35a4004..1ba4e408 100644--- a/tests/Nota.SmokeTest/MultiClipTests.cs+++ b/tests/Nota.SmokeTest/MultiClipTests.cs@@ -24,6 +24,24 @@ internal static class MultiClipTestsforeach (var r in Moves()) yield return r;foreach (var r in Paste()) yield return r;foreach (var r in GroupedUndo()) yield return r;+ foreach (var r in TrackMode()) yield return r;+ }++ // Track mode (specs/059): a track's clips on the arrangement axis, joined by new ones.+ private static IEnumerable<(bool, string)> TrackMode()+ {+ var lone = new ClipSet(new[] { new OpenClip(3, 0, 24, 8) }, 3, 0, barBeats: 4, trackMode: true);+ yield return (lone.IsMulti && lone.TrackMode && Near(lone.Origin, 0) && Near(lone.EditorStart(0), 24) && Near(lone.SpanBeats, 32),+ "trackmode: a lone clip sits at its arrangement beat on the shared timeline");++ var t = new ClipSet(new[] { new OpenClip(3, 0, 8, 8), new OpenClip(3, 1, 32, 8) }, 3, 1, barBeats: 4, trackMode: true);+ yield return (Near(t.Origin, 0) && Near(t.ToEditor(1, 2), 34), "trackmode: editor beats are arrangement beats");+ yield return (t.Add(new OpenClip(3, 2, 16, 8)) && t.Count == 3 && t.Clips[1].ClipIndex == 2+ && t.ActiveClip is { TrackId: 3, ClipIndex: 1 } && Near(t.SpanBeats, 40),+ "trackmode: a new clip joins in start order and the active clip stays active");+ yield return (!t.Add(new OpenClip(3, 2, 16, 8)), "trackmode: a clip already open is not added twice");+ var (lo, hi) = t.Reach(0);+ yield return (Near(lo, 8) && Near(hi, 24), "trackmode: a note reaches the touching clip, not across a gap");}// Track 1: A (bars 1–4 = beats 0–16), B (16–32). Track 2: C (8–40).