Skip to content

armgit / nota

Public Imported from GitHub
0

Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.

(feat) Link a group's tracks for arming and editing (#184) (#475)

Egor Khindikaynen7b58fe881bc6
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e585c276..88e91f1b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,13 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
## [Unreleased]
### Added
+- **Link a group's tracks** (#184): the Link key (a chain link) on a group's header, its
+ Mixer strip and its menu ties the tracks in the group together — for a dry and an amped
+ guitar recorded side by side, say. Arming one arms them all; clicking a clip selects the
+ clips at the same place on the other tracks too; moving, trimming, fading, splitting,
+ duplicating, copying, cutting or deleting it does the same to them, as one undo step; a
+ time range drawn on one track spans the whole group. ⌥-click (Alt-click) a clip or an arm
+ to act on one track. Saved with the project; MCP `set_group_link` / `get_group_link`.
- **Rearrange the song by its sections** (#192): drag a section in the Sections lane and it
moves with everything in it — audio and MIDI clips (cut at its edges), automation on every
track and the master, take lanes — to the boundary marked while you drag; the sections in
diff --git a/FEATURES.md b/FEATURES.md
index aa65cef1..abf2c837 100644
--- a/FEATURES.md
+++ b/FEATURES.md
@@ -234,6 +234,15 @@ docks as a panel under any of the three, or floats in its own window — see
- **Track types**: Audio, MIDI/Instrument, Return, Master, **Group** (nestable submixes —
⌘/Ctrl+G to group, ⌘/Ctrl+Shift+G to ungroup).
+- **Linked groups** — a group's **Link** key (a chain link on its header, its Mixer and
+ Session strip, and **Link tracks** in its menu) ties the tracks below it together, nested
+ groups included. Arming one arms them all; clicking a clip also selects the clips with the
+ same start and end on the other tracks, and moving, trimming, fading, splitting,
+ duplicating, copying, cutting or deleting it acts on them too, as one undo step (a clip
+ moved to another track takes its partners along in time only); a time range on one track
+ spans the group. ⌥-click (Alt-click) a clip or an arm to act on one track. Linked tracks
+ show a chain link before their name. Saved with the project; MCP `set_group_link` /
+ `get_group_link`.
- **Adding a track**: the `+ Instrument` / `+ Audio` / `+ Return` buttons above the
arrangement, or the context menu — right-click the empty space below the tracks, or use
`Add track ▸` in a track's own menu (the new track goes right after that track, or inside
@@ -1434,7 +1443,7 @@ Coverage:
`duplicate_section_with_content`, `delete_section_with_content`); version history — `list_versions` (with what
each changed), `save_version` with a note, `switch_version`, `annotate_version` (name, note,
star). Deleting versions stays with the user.
-- **Tracks**: add and remove, volume/pan/mute/solo, groups, sends.
+- **Tracks**: add and remove, volume/pan/mute/solo, groups and their Link, sends.
- **Instruments**: add by kind, read and write parameters (by index or by stable id), turn
on or off (`set_device_bypass` with device index -1; `get_overview` shows it), replace with
another built-in or an empty rack (`set_track_instrument`); read / shape Nota Keys in
diff --git a/specs/076-group-link/checklists/requirements.md b/specs/076-group-link/checklists/requirements.md
new file mode 100644
index 00000000..08a68f6a
--- /dev/null
+++ b/specs/076-group-link/checklists/requirements.md
@@ -0,0 +1,36 @@
+# Specification Quality Checklist: Linked editing on group tracks
+
+**Purpose**: Validate specification completeness and quality before proceeding to planning
+**Created**: 2026-11-03
+**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
+
+- FR-012 resolved 2026-11-04: a held bypass modifier (user's choice).
+- Keyboard shortcuts and "MCP server" are named because they are user-facing surfaces in
+ Nota, not implementation choices.
diff --git a/specs/076-group-link/contracts/c-abi.md b/specs/076-group-link/contracts/c-abi.md
new file mode 100644
index 00000000..050e2ba2
--- /dev/null
+++ b/specs/076-group-link/contracts/c-abi.md
@@ -0,0 +1,33 @@
+# Contract: C ABI (`include/nota/nota_engine.h`)
+
+Placed after `nota_track_get_piano_fold`.
+
+```c
+/* Group Link (specs/076, #184): a group track's "link its tracks for editing and recording"
+ * flag. Saved with the project, copied with the group, and an undo step when changed; the
+ * audio thread never reads it — the app applies the link to arming and clip edits.
+ * set: NOTA_ERR_INVALID_ARG for an unknown track or one that is not a group.
+ * get: 1 linked, 0 not, -1 unknown track (0 for a track that is not a group). */
+NOTA_API NotaResult nota_track_set_edit_link(NotaEngine* engine, int32_t track_id, int32_t on);
+NOTA_API int32_t nota_track_get_edit_link(NotaEngine* engine, int32_t track_id);
+```
+
+Behaviour the smoke test asserts:
+
+| Case | Expected |
+|------|----------|
+| set on a group, get | 1 |
+| set on an audio track | `NOTA_ERR_INVALID_ARG`, get = 0 |
+| set the same value twice | `NOTA_OK`, no extra undo step |
+| set on, `nota_engine_undo` | get = 0; redo → 1 |
+| duplicate / copy-paste the group | the copy reads 1 |
+| null engine / unknown id | set → error, get → -1 |
+
+Managed mirror (`IAudioEngine`):
+
+```csharp
+/// <summary>Group Link (specs/076): links a group's tracks for arming and clip edits. One undo
+/// step; false for a track that is not a group.</summary>
+bool SetTrackEditLink(int trackId, bool on);
+bool GetTrackEditLink(int trackId);
+```
diff --git a/specs/076-group-link/contracts/mcp.md b/specs/076-group-link/contracts/mcp.md
new file mode 100644
index 00000000..97d8e69d
--- /dev/null
+++ b/specs/076-group-link/contracts/mcp.md
@@ -0,0 +1,10 @@
+# Contract: MCP tools (`Nota.Mcp/Tools/TrackTools.cs`)
+
+| Tool | Parameters | Returns | Description (as registered) |
+|------|------------|---------|-----------------------------|
+| `set_group_link` | `trackId` (group track id), `on` (bool) | bool — false when the track is not a group | "Link a group's tracks for editing and recording (Link): arming one arms them all, and clips selected or edited in the Arrangement take the clips at the same position on the other tracks along. One undo step." |
+| `get_group_link` | `trackId` | bool | "Whether a group's Link is on." |
+
+MCP clip-edit tools keep acting on exactly the clips they name — the link is an Arrangement
+interaction rule, so an agent edits each track explicitly (stated in the `set_group_link`
+description: "MCP edits are not linked; they act on the clips they name").
diff --git a/specs/076-group-link/contracts/ui.md b/specs/076-group-link/contracts/ui.md
new file mode 100644
index 00000000..6d3cbad9
--- /dev/null
+++ b/specs/076-group-link/contracts/ui.md
@@ -0,0 +1,36 @@
+# Contract: UI
+
+Follows [`DESIGN.md`](../../../DESIGN.md) (Studio): neutral keys, orange accent only while on.
+
+## Link key (group tracks)
+
+| Place | Position | Look |
+|-------|----------|------|
+| Arrangement group header, slim bar | right of M / S | `ChainLink` glyph key, same size as M / S; accent fill when on |
+| Arrangement group header, full row | in the M / S row | same |
+| Mixer group strip (full and compact), Session mixer group column | in the M / S row | same |
+| Group header context menu | after the grouping items | checkable **Link tracks** |
+
+- Tooltip: "Link tracks — arming and clip edits act on every track of the group ·
+ ⌥-click a clip or an arm to act on one track" (⌥ spelled per platform via `MenuKit.Keys`).
+- Click: toggle, one undo step; every view repaints (Arrangement, Mixer, Session).
+
+## Member mark
+
+- A linked member's Arrangement header shows a small `ChainLink` glyph (10 px) before its
+ name, in the secondary text colour — membership, not a live state, so no accent.
+- Tooltip on the glyph: "Linked with {group name}".
+
+## Selection
+
+- Matches draw as selected clips (existing selection look); no extra decoration.
+
+## Shortcuts (Preferences → Shortcuts, Arrangement section)
+
+- "⌥-click a clip — select it alone in a linked group"
+- "⌥-click Arm — arm one track of a linked group"
+
+## Strings (English source + French in `Languages/fr.json`, checked by the smoke test)
+
+"Link tracks", "Linked with {0}", the Link tooltip above, the extended arm tooltip, and the
+status line "The group's tracks are linked" shown after toggling on.
diff --git a/specs/076-group-link/data-model.md b/specs/076-group-link/data-model.md
new file mode 100644
index 00000000..1c15612e
--- /dev/null
+++ b/specs/076-group-link/data-model.md
@@ -0,0 +1,47 @@
+# Data model: Linked editing on group tracks
+
+## Track (engine `Track`, managed `NotaTrackInfo` / `TrackVM` / `TrackDto`)
+
+| Field | Type | Where | Rule |
+|-------|------|-------|------|
+| `editLink` | bool, default false | engine `Track.h` | Meaningful on group tracks only; `setTrackEditLink` refuses other kinds. Copied by `cloneTrack`. Changing it is an undo step. |
+| `EditLink` | `bool?` | `TrackDto` (project JSON) | Written `true` or omitted. Applied on load after the hierarchy (`GroupId`) is set. |
+| `EditLink` | bool | `TrackVM` (Arrangement) | Read from the engine on `Refresh`. |
+
+Existing fields used: `Id`, `Type` (`IsGroup`, `IsReturn`, `IsInstrument`), `GroupId`
+(parent group id or -1), `Armed`.
+
+## Link set (derived, never stored)
+
+- For a non-group, non-return track **T**: walk `GroupId` up to the root; the **outermost**
+ ancestor group with `editLink` is T's *link root*. None → T is unlinked.
+- The set of a link root **G**: every non-group, non-return track whose link root is G.
+- Membership changes as soon as the hierarchy or a flag changes (moving a track in / out,
+ ungrouping, toggling, undo) — it is recomputed from the current tracks on each use.
+
+## Match (derived)
+
+- Clip **c'** on member **T'** matches source clip **c** on **T** (T ≠ T', same set) when
+ `|c'.start − c.start| ≤ 1/256` and `|c'.end − c.end| ≤ 1/256` (beats).
+- Kind does not matter (audio and MIDI clips can match).
+- A clip may have at most one match per member track in practice (clips on one track don't
+ overlap); if several qualify, all are taken.
+
+## Selection state (Arrangement view)
+
+| State | Meaning |
+|-------|---------|
+| `_sel` | every selected clip (unchanged meaning) |
+| `_selLinked` ⊆ `_sel` | the clips that are selected **because** they match a clip the user chose; used by vertical moves and by trim / ADSR to find the grabbed clip's partners |
+
+Transitions:
+
+- plain click / drag start on unselected clip → `_sel = {c} ∪ matches(c)`, `_selLinked = matches(c)`.
+- ⌥-click → `_sel = {c}`, `_selLinked = ∅`.
+- ⌘-click on unselected c → add c and matches; on selected c → remove c and its matches
+ that are in `_selLinked`.
+- `SetSelection(list)` (marquee, ⌘A, reselect after an edit) → `_sel = list`; `_selLinked`
+ = clips in the list that match another clip of the list on a different member of the same
+ set and were not the user's direct target (for reselect, the source clips' new positions are
+ known, so the rest are linked).
+- Any clear → both empty.
diff --git a/specs/076-group-link/plan.md b/specs/076-group-link/plan.md
new file mode 100644
index 00000000..ccb0b1fc
--- /dev/null
+++ b/specs/076-group-link/plan.md
@@ -0,0 +1,221 @@
+# Implementation Plan: Linked editing on group tracks
+
+**Branch**: `feat/folder-track-groups` | **Date**: 2026-11-04 | **Spec**: [spec.md](spec.md)
+
+**Input**: Feature specification from `specs/076-group-link/spec.md` (issue
+[nota-daw/nota#184](https://github.com/nota-daw/nota/issues/184))
+
+## Summary
+
+A Group track gets a **Link** flag. While it is on, the non-group tracks below it form a
+*link set*: arming one arms the set, selecting a clip also selects its *matching* clips
+(same start and end) on the other members, a time range touching a member spans every
+member, and Arrangement clip edits act on the matches as one undo step.
+
+The approach keeps the change small by making **selection the carrier of the link**: the
+Arrangement's existing multi-selection (`_sel`) and the block edits built on it (move
+block, nudge, duplicate, copy, cut, delete) already act on every selected clip, so adding
+the matches to the selection links those edits for free. Only the edits that act on one
+grabbed clip (trim, clip ADSR / fades), split at the playhead, time ranges, vertical moves
+and arming need their own linking code. The flag itself is engine-side track metadata —
+the same pattern as `pianoFold` / `colorIndex` — so it is undoable, copied with the group
+and saved with the project, and the audio thread never reads it.
+
+## Nota: Read Before Planning
+
+- **Engine work** → [`ARCHITECTURE.md`](../../ARCHITECTURE.md): the change is one authoring
+ flag on `Track` published through the usual clone-and-republish path (AR-5); nothing on
+ the audio thread (AR-6); one new ABI pair in `nota_engine.h` (AR-7).
+- **UI work** → [`DESIGN.md`](../../DESIGN.md) and the `nota-design` skill: the Link key
+ is a small header key like M / S; orange accent only while on.
+- **Anything** → [`CONTRIBUTING.md`](../../CONTRIBUTING.md).
+
+## Technical Context
+
+**Language/Version**: C++20 (engine: one flag + ABI), C# / .NET 10 (managed app: the bulk).
+
+**Primary Dependencies**: Avalonia (existing). No new dependency.
+
+**Storage**: project JSON — `TrackDto.EditLink` (`bool?`, written only when on, like
+`PianoFold`); no format-version bump (an absent field reads as off; older builds ignore it).
+
+**Audio-Thread Impact**: None. `Track::editLink` is authoring metadata copied on clone; the
+render path never reads it. Setting it goes through `republishWithTrack` on the message
+thread (AR-5), like the track colour.
+
+**Testing**: `tests/Nota.SmokeTest` (engine via C ABI: set / get / undo / duplicate group /
+save-load round-trip); pure-logic tests for link-set and matching rules
+(`Nota.Presentation` / `Nota.Application.Editing` classes, run from the smoke test like
+`ArrangementMoves`); in-app verification with the headless harness (memory: UI verify recipe).
+
+**Target Platform**: macOS, Windows, Linux (desktop app).
+
+**Project Type**: desktop app (engine + managed UI).
+
+**Performance Goals**: link-set and match computation per click/edit is O(tracks × clips of
+the set) on the UI thread — trivially below a frame for realistic projects (hundreds of clips).
+
+**Constraints**: no change in behaviour while every group's Link is off (FR-014); each
+linked edit one undo step (SC-003).
+
+**Scale/Scope**: ~1 engine flag + ABI pair, ~8 managed files touched, 1 new Application
+class, MCP tool pair, docs.
+
+## Constitution Check
+
+*GATE: Must pass before Phase 0 research. Re-check after Phase 1 design.*
+
+| Principle | Status |
+|-----------|--------|
+| 0. Approved issue | ✅ #184 carries `approved` (2026-11-04). |
+| I. Real-time safety | ✅ Flag never read on the audio thread; set via clone + republish (AR-5). |
+| II. Boundary discipline | ✅ One `nota_track_set_edit_link` / `get` pair in `nota_engine.h`; no JUCE. |
+| III. Licensing | ✅ No dependency; new files carry the SPDX header. |
+| IV. Verification gate | ✅ Smoke test extended for the new ABI (set/get/undo/dup/save-load). |
+| V. One logical change | ✅ One feature; the shared rule lives in one new class. |
+| VI. Docs in sync | ✅ CHANGELOG, FEATURES.md (nota-features), user docs (nota-docs), Shortcuts (nota-shortcuts: ⌥-click bypass). |
+| VII. Spec-first | ✅ This run. |
+| VIII. No weakening | ✅ Nothing bent. |
+
+Post-design re-check (after Phase 1): unchanged — the design adds no audio-thread code and
+one ABI pair. **PASS.**
+
+## Design overview
+
+### 1. The flag (engine → ABI → managed)
+
+- `Track.h`: `bool editLink = false;` beside `pianoFold`; copied by `cloneTrack` (so
+ duplicating / copy-pasting a group keeps it).
+- `Engine::setTrackEditLink(id, on)` — group tracks only (false otherwise), clone +
+ `republishWithTrack` (**an undo step**, unlike `pianoFold`'s raw republish);
+ `trackEditLink(id)` → 1 / 0 / -1.
+- ABI: `nota_track_set_edit_link` / `nota_track_get_edit_link` (see
+ [contracts/c-abi.md](contracts/c-abi.md)).
+- Managed: `NativeMethods.Tracks.cs`, `NotaEngine.Tracks.cs`,
+ `IAudioEngine.SetTrackEditLink / GetTrackEditLink` (`NotaEngine` is the only
+ implementation; the smoke test drives the real engine).
+- Persistence: `TrackDto.EditLink` written as `true` or omitted; applied after the track
+ hierarchy is rebuilt on load.
+
+### 2. The rule (one class, pure)
+
+`Nota.Application.Editing.GroupLink` (new), fed with plain track and clip records so it is
+testable without the engine:
+
+- `LinkSets(tracks)` → for every non-group, non-return track: the id of its outermost
+ linked ancestor group (or none). Built from `GroupId` / `IsGroup` / `EditLink`.
+- `Members(trackId)` → the other tracks of its set (empty when unlinked).
+- `Matches(source clip, member clips)` → clips with |Δstart| and |Δend| ≤ 1/256 beat
+ (FR-006).
+- `ExpandTracks(trackIds)` → the set closed under membership (for ranges and split).
+
+`ArrangementView` builds it from its `_tracks` (which already carry `GroupId`, `IsGroup`;
+`EditLink` is added to the track VM on `Refresh`), and `TrackArm` builds it from
+`IAudioEngine.TryGetTrackInfo` + `GetTrackEditLink`.
+
+### 3. Selection carries the link
+
+- `Select(track, clip)` (plain click, drag start on an unselected clip) adds the matches;
+ they go into `_sel` and into a parallel `_selLinked` set marking them as *added by the
+ link* (not chosen by the user).
+- `ToggleSelect` (⌘-click) adds or removes the clip with its matches.
+- `SetSelection` (marquee, ⌘A, reselect after paste/move): unchanged — it already contains
+ what it covers; `ReselectPlaced` after a linked move re-derives `_selLinked` by matching.
+- Bypass (FR-012): a ⌥-click that releases without dragging selects the clip alone (no
+ matches). The lane already tracks the modifiers of the press (`_lastMods`).
+- Visual: linked matches draw selected like any selected clip; nothing new.
+
+With that, **move block, nudge, duplicate, copy, cut, delete** need no change.
+
+### 4. Edits that need their own linking
+
+| Edit | Where | Change |
+|------|-------|--------|
+| Trim / resize | `LaneControl.OnPointerReleased` (single `_dragClip`) | Apply the same new start/length to the grabbed clip's matches **that are in the selection**, in one undo group. |
+| Clip ADSR / fades | `LaneControl.CommitAdsr` | Same: matches in the selection get the same `ClipAdsr` (audio clips only), one undo group. |
+| Split at playhead (⌘E) | `SplitSelectedAtPlayhead` | Add, for each link set touched by the selection, the clips of the members spanning the playhead (FR-010); wrap the loop in one undo group. |
+| Split here (clip menu) | LaneControl context menu | Route through the same linked split at the menu's beat. |
+| Delete (multi) | `DeleteSelectedClips` | Wrap in an undo group (today: one step per clip) so a linked delete is one step. |
+| Time range | `TimeSelectionTrackIds` | Return `GroupLink.ExpandTracks(rows lo..hi)`; the drawn range spans the member rows (`_timeSelRowLo/Hi` widened to the set's row extent, a set's rows being contiguous in hierarchy order). |
+| Vertical move (drag) | group move commit | Entries in `_selLinked` keep their own track (`destTrack = m.track`) but take the time shift; the drag preview keeps them on their rows. |
+| Vertical move (⌥↑/⌥↓) | `MoveSelectedClipsToTrack` | Row shift computed from the non-linked entries only; `_selLinked` entries are left out of the move (their time shift is 0). |
+| Arm | `TrackArm.Set` / `FollowSelection` | Arm/disarm the track's whole set; exclusive arm disarms tracks outside the set; ⌥-click arms the one track (bypass). Arm-on-select treats a set as one track. |
+
+Session-View arming goes through `TrackArming.Set` too, so it is linked (spec edge case);
+Session clips are not.
+
+### 5. UI
+
+- **Link key** on the group's Arrangement header — slim bar (next to M / S) and full row —
+ using the existing `ChainLink` glyph; accent when on; tooltip "Link the group's tracks for
+ editing and recording · ⌥-click a clip to edit one track". Click toggles via
+ `SetTrackEditLink` (one undo step) and refreshes.
+- **Mixer strip** of a group (`MixerView` full + compact): the same key in the group's
+ M / S row. Session-View mixer group columns get it as well (same strip builder).
+- **Member mark**: a linked member's header shows a small `ChainLink` glyph before its name
+ in the group's hue (no accent: it states membership, not a live state).
+- Context menu of the group header: **Link tracks** checkable item.
+
+### 6. MCP
+
+`set_group_link(trackId, on)` / `get_group_link(trackId)` in `TrackTools` (see
+[contracts/mcp.md](contracts/mcp.md)); MCP edit tools stay per-track (they name the clips
+they act on), documented in the tool description.
+
+## Project Structure
+
+### Documentation (this feature)
+
+```text
+specs/076-group-link/
+├── spec.md
+├── plan.md # this file
+├── research.md
+├── data-model.md
+├── quickstart.md
+├── contracts/
+│ ├── c-abi.md
+│ ├── mcp.md
+│ └── ui.md
+├── checklists/requirements.md
+└── tasks.md # /speckit-tasks
+```
+
+### Source Code (repository root)
+
+```text
+src/native/nota.engine/
+├── include/nota/nota_engine.h # + nota_track_set_edit_link / get
+├── src/engine/Track.h # + bool editLink
+├── src/engine/Engine.h # + setTrackEditLink / trackEditLink
+├── src/engine/Engine_Tracks.cpp # implementation (undoable republish)
+└── src/abi/nota_engine_track.cpp # ABI wrappers
+src/managed/
+├── Nota.Application/Engine/IAudioEngine.cs # + SetTrackEditLink / GetTrackEditLink
+├── Nota.Application/Editing/GroupLink.cs # NEW: link sets + matching
+├── Nota.Infrastructure/Interop/NativeMethods.Tracks.cs
+├── Nota.Infrastructure/Interop/NotaEngine.Tracks.cs
+├── Nota.Infrastructure/Persistence/ProjectModel.cs # + TrackDto.EditLink
+├── Nota.Infrastructure/Persistence/ProjectService.cs
+├── Nota.Presentation/TrackArm.cs # linked arm
+├── Nota.App/ArrangementView.cs # selection, split, delete, range
+├── Nota.App/ArrangementView.Groups.cs # Link key, member mark, menu
+├── Nota.App/ArrangementView.LaneControl.cs # trim, ADSR, ⌥-click, drag preview/commit
+├── Nota.App/ArrangementView.KeyMoves.cs # ⌥↑/⌥↓
+├── Nota.App/ArrangementView.Vms.cs # TrackVM.EditLink
+├── Nota.App/MixerView.cs, MixerView.Compact.cs # group strip Link key
+├── Nota.App/TrackArming.cs # ⌥ bypass helper, tooltip
+├── Nota.App/PreferencesWindow (Shortcuts list) # ⌥-click entry (nota-shortcuts)
+└── Nota.Mcp/Tools/TrackTools.cs # set/get_group_link
+tests/Nota.SmokeTest/
+├── GroupLinkTests.cs # NEW: ABI + GroupLink rules + linked TrackArm
+└── Program.cs # runs GroupLinkTests.Run()
+CHANGELOG.md, FEATURES.md, ../nota-docs (EN + RU)
+```
+
+**Structure Decision**: Engine change is limited to metadata + ABI; all behaviour lives in
+the managed app, centred on one pure rule class shared by the Arrangement and the arm logic.
+
+## Complexity Tracking
+
+No constitution violations.
diff --git a/specs/076-group-link/quickstart.md b/specs/076-group-link/quickstart.md
new file mode 100644
index 00000000..fc0beb0f
--- /dev/null
+++ b/specs/076-group-link/quickstart.md
@@ -0,0 +1,36 @@
+# Quickstart: validating Linked editing on group tracks
+
+## Prerequisites
+
+- macOS build: `scripts/build.sh` (builds the engine in `build/` Release, the app, and runs
+ the smoke test).
+
+## 1. Automated
+
+```bash
+scripts/build.sh
+```
+
+Expected: the smoke test passes, including the `GroupLinkTests` checks —
+the ABI table in [contracts/c-abi.md](contracts/c-abi.md), the link-set and match rules
+([data-model.md](data-model.md)), and linked arming against the real engine.
+
+## 2. In the app (manual or the headless capture harness)
+
+Setup: two audio tracks *Dry* and *Wet*, each with a clip at bars 1–5 (record both, or
+drop one sample on both), grouped with ⌘G. A third audio track *Other* outside the group.
+
+| # | Action | Expected |
+|---|--------|----------|
+| 1 | Click the group's Link key | Key turns accent; Dry and Wet headers show the link glyph |
+| 2 | Click Dry's clip | Wet's clip is selected too |
+| 3 | Move the playhead to bar 3, ⌘E | Both clips split at bar 3; one ⌘Z joins both back |
+| 4 | Drag Dry's second half one bar later | Wet's second half follows |
+| 5 | Trim Dry's first half end by a beat | Wet's first half gets the same end |
+| 6 | ⌥-click Wet's first half, Delete | Only Wet's clip is deleted |
+| 7 | ⇧-drag a range over Dry only, Delete | The range is removed on Dry and Wet |
+| 8 | Arm *Other*, then click Dry's arm | Dry and Wet armed, Other disarmed |
+| 9 | ⌥-click Wet's arm | Only Wet disarms |
+| 10 | Save, close, reopen | Link still on |
+| 11 | Turn Link off, click Dry's clip | Only Dry's clip is selected (today's behaviour) |
+| 12 | Drag Dry's clip down onto *Other* | Dry's clip changes track; Wet's clip takes the same time shift and stays on Wet |
diff --git a/specs/076-group-link/research.md b/specs/076-group-link/research.md
new file mode 100644
index 00000000..5a869f24
--- /dev/null
+++ b/specs/076-group-link/research.md
@@ -0,0 +1,94 @@
+# Research: Linked editing on group tracks
+
+Phase 0 of [plan.md](plan.md). Every open point of the Technical Context is resolved here.
+
+## R1. Where the Link flag lives
+
+- **Decision**: an authoring flag on the engine's `Track` (`editLink`), set through a new
+ C ABI pair, persisted by `ProjectService` as `TrackDto.EditLink`.
+- **Rationale**: track metadata already lives there (`name`, `colorIndex`, `pianoFold`);
+ `cloneTrack` copies it, so duplicate / copy-paste of a group keeps it; setting it via
+ `republishWithTrack` makes the toggle an undo step for free (spec FR-003); undo of a
+ group delete restores it. The audio thread never reads it.
+- **Alternatives**: a managed-only sidecar like the fold state (`GroupFold`, specs/070) —
+ rejected: fold is view state with no undo, while Link changes what edits do and must
+ undo, copy and travel with the track; a flag on the managed `Track` domain object —
+ rejected: the engine is the source of truth for tracks at runtime.
+
+## R2. How linked edits are carried
+
+- **Decision**: through the selection. Selecting a clip adds its matches to `_sel`
+ (tracked in `_selLinked`); the block edits already act on the whole selection.
+- **Rationale**: move block, nudge, duplicate, copy, cut and delete are all
+ selection-driven (`SelectionBlock`, `SelectedClipStarts`), and `MoveClipBlock` /
+ `DuplicateClipBlock` / `CutClipBlock` are already single undo steps. The user also sees
+ what an edit will touch before making it (spec Story 2).
+- **Alternatives**: expand at each edit call site — rejected: ~10 call sites, each a place
+ to forget, and the selection would not show what moves.
+
+## R3. Matching tolerance
+
+- **Decision**: |Δstart| ≤ 1/256 beat and |Δend| ≤ 1/256 beat.
+- **Rationale**: simultaneous takes start and end on the same beat values exactly; a beat
+ tolerance needs no tempo (the spec's first draft mixed ms and notes, which needs the
+ tempo map); 1/256 beat ≈ 2 ms at 120 BPM — far below any grid step the user can snap to,
+ so two clips placed on different grid lines never match.
+- **Alternatives**: exact equality — rejected: a clip moved by key and back could pick up
+ float error; overlap — rejected by the user in clarification.
+
+## R4. The single-track bypass gesture
+
+- **Decision**: ⌥-click (Alt-click) on a clip selects it alone; ⌥-click on an arm button
+ arms that track alone. ⌥-drag stays "move without snap" and stays linked.
+- **Rationale**: ⌃-click is the macOS context-menu click (`IsPrimaryDown` comment);
+ ⌘ / Ctrl toggles the selection, ⇧ extends it / starts a range; a ⌥ *click* (press and
+ release without crossing the drag threshold) currently does the same as a plain click,
+ so giving it a meaning breaks nothing. Because linked edits follow the selection,
+ selecting one clip alone is enough to make the following edits single-track.
+- **Alternatives**: a new held key (e.g. a letter) — rejected: letters type notes on the
+ computer keyboard; ⌘⌥-click — workable but harder to discover; turning Link off and on —
+ rejected by the user.
+- **Note**: some Linux window managers grab Alt-click for moving windows; there the user
+ can still turn Link off. Recorded in the docs.
+
+## R5. Vertical moves
+
+- **Decision**: the matches added by the link (`_selLinked`) take the time shift of a drag
+ but keep their own track; ⌥↑ / ⌥↓ leave them out (their time shift is 0).
+- **Rationale**: the user's clarification; the partners would otherwise need target
+ tracks of their own.
+
+## R6. Split at the playhead and ranges
+
+- **Decision**: split adds, per touched link set, every member clip spanning the playhead
+ (spec FR-010); ranges widen `TimeSelectionTrackIds` to whole link sets and the drawn row
+ span to the set's rows.
+- **Rationale**: these are time-based edits, so they act on the members' material at that
+ time, matched or not — the dry / wet tracks are cut at the same place even after a
+ partner was trimmed. A group's subtree is contiguous in `HierarchyOrder`, so the set's rows
+ form one span (when the group is folded its rows are hidden and the engine-level track
+ list still includes them — `TimeSelectionTrackIds` takes ids from the set, not rows).
+
+## R7. One undo step per linked edit
+
+- **Decision**: wrap the loops that call per-clip engine edits (split, delete, trim,
+ ADSR) in `BeginUndoGroup` / `EndUndoGroup`; block edits already are one step.
+- **Rationale**: the engine's undo group API nests and is already used by the app
+ (device replace, recent instruments).
+
+## R8. Arming
+
+- **Decision**: extend `Nota.Presentation.TrackArm.Set` / `FollowSelection` to the link set;
+ all arm buttons (Arrangement, Mixer, compact Mixer, Session mixer, inspector) call it via
+ `TrackArming.Set`, so one change covers every view. MCP `set_track_armed` stays per track.
+- **Rationale**: single choke point; the logic is already tested against the real engine in
+ `SessionInputTests`.
+- Non-recordable members (none today: every non-group, non-return track can arm) are
+ skipped.
+
+## R9. Persistence and compatibility
+
+- **Decision**: `TrackDto.EditLink` (`bool?`), written only when true; no
+ `CurrentFormatVersion` bump.
+- **Rationale**: same as `PianoFold` (specs/045): old projects read as unlinked (SC-005);
+ older builds ignore the unknown field (`JsonExtensionData` keeps it round-tripping).
diff --git a/specs/076-group-link/spec.md b/specs/076-group-link/spec.md
new file mode 100644
index 00000000..2b44605c
--- /dev/null
+++ b/specs/076-group-link/spec.md
@@ -0,0 +1,274 @@
+# Feature Specification: Linked editing on group tracks
+
+**Feature Branch**: `feat/folder-track-groups`
+
+**Created**: 2026-11-03
+
+**Status**: Draft
+
+**Input**: User description: "Group button on folder tracks (issue #184): a toggle on a folder track that links the editing and recording behaviour of all tracks inside the folder. While the group is on, record-arming one track arms the others; cutting, splitting or moving a clip on one track performs the matching action on clips at the same timeline position on the other grouped tracks; selecting a clip or a range on one track selects the matching material on the others. Use case: dry and wet guitar recorded on separate tracks, edited as one."
+
+**Issue**: [nota-daw/nota#184](https://github.com/nota-daw/nota/issues/184) (approved)
+
+## 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
+
+**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).
+
+In Nota the "folder track" of the issue is the **Group** track (a nestable submix that
+owns child tracks). Nota already uses the word *group* for that track type, so the toggle
+this spec adds is called **Link** (it links the editing of the group's tracks), to avoid
+"the group button of a group".
+
+## Clarifications
+
+### Session 2026-11-04
+
+- Q: Is a way needed to edit one track of a linked group without turning Link off? → A: Yes, a modifier: ⌥-click / Alt-click (gesture picked in planning — ⌃-click is the macOS context click, ⌘ and ⇧ already toggle and extend the selection) (FR-012).
+- Q: Which clip on another linked track counts as the matching one? → A: Same start and same end, within tolerance (FR-006).
+- Q: Should Mute and Solo also be linked? → A: No — only record arm, selection and clip edits.
+- Q: What happens when a linked clip is moved to another track? → A: The partners take the same time shift but stay on their own tracks; only the source clip changes track.
+
+## User Scenarios & Testing *(mandatory)*
+
+### User Story 1 - Edit two takes of one performance as one (Priority: P1)
+
+A guitarist records the same performance onto two tracks — the dry DI and the amped
+sound — and puts both in a group. They switch the group's **Link** on. From then on,
+splitting, moving, trimming, duplicating or deleting a clip on either track does the same
+to the clip recorded alongside it on the other track, so the two takes never drift apart
+and they edit one track's worth of clips instead of two.
+
+**Why this priority**: This is the core value of the issue: keeping parallel recordings
+in step while editing. Without it the toggle does nothing useful.
+
+**Independent Test**: Put two audio tracks with clips at the same positions in a group,
+turn Link on, split one clip at the cursor, move one of the halves by two bars and delete
+another — the second track shows the same cuts, positions and deletions, and one undo
+reverts each edit on both tracks.
+
+**Acceptance Scenarios**:
+
+1. **Given** a linked group with tracks A and B whose clips start and end together,
+ **When** the user splits A's clip at the cursor (⌘E), **Then** B's clip is split at
+ the same position too, as one undo step.
+2. **Given** the same group, **When** the user drags A's clip two bars later,
+ **Then** B's matching clip moves two bars later as well, and the two land at the same
+ position after snapping.
+3. **Given** the same group, **When** the user trims the start or end of A's clip, or
+ changes its fade, **Then** B's matching clip gets the same new edge or fade.
+4. **Given** the same group, **When** the user deletes, duplicates (⌘D), nudges (← / →),
+ cuts or copies A's clip, **Then** the same happens to B's matching clip, and a paste
+ puts both back on their own tracks at the paste position.
+5. **Given** Link is off on the group, **When** the user edits A's clip, **Then** B is
+ untouched (today's behaviour).
+
+---
+
+### User Story 2 - Select once, see the whole group selected (Priority: P1)
+
+Clicking a clip on one linked track also selects the matching clips on the group's other
+tracks, and drawing a time range on one linked track spans every track of the group. The
+user sees what the next edit will act on before they make it.
+
+**Why this priority**: Selection is what makes the linked edits predictable; it ships
+together with Story 1 (every linked edit goes through the selection) but can be tested on
+its own.
+
+**Independent Test**: In a linked group, click a clip on one track — the matching clips
+on the other tracks are highlighted as selected; ⇧-drag a range on one track — the range
+covers all of the group's tracks; Delete removes the covered part on all of them.
+
+**Acceptance Scenarios**:
+
+1. **Given** a linked group, **When** the user clicks a clip on one of its tracks,
+ **Then** the matching clips on the group's other tracks are selected with it.
+2. **Given** a linked group, **When** the user ⇧-drags a time range starting on one of its
+ tracks, **Then** the range extends over every track of the group (and over any other
+ tracks the drag itself crosses).
+3. **Given** a linked selection, **When** the user ⌘-clicks one of the selected clips,
+ **Then** it and its matching clips leave the selection together.
+
+---
+
+### User Story 3 - Arm the group with one click (Priority: P2)
+
+Arming any track of a linked group for recording arms all of the group's recordable
+tracks, and disarming one disarms them all, so both sides of the guitar are always
+recorded together.
+
+**Why this priority**: A clear quality-of-life gain named in the issue, but recording
+already works by ⌘-clicking each arm; editing is the bigger daily pain.
+
+**Independent Test**: In a linked group of two audio tracks, click the arm on one —
+both are armed and any armed track outside the group is disarmed (exclusive arm, as
+today); record — both get a take; click an arm again — both are disarmed.
+
+**Acceptance Scenarios**:
+
+1. **Given** a linked group of tracks A and B and an armed track C outside it, **When**
+ the user clicks A's arm, **Then** A and B are armed and C is disarmed.
+2. **Given** the same state, **When** the user ⌘-clicks A's arm (additive), **Then** A and
+ B are armed and C stays armed.
+3. **Given** A and B armed, **When** the user disarms B, **Then** A is disarmed too.
+4. **Given** Link is off, **When** the user arms A, **Then** only A is armed (today's
+ behaviour).
+
+---
+
+### User Story 4 - Turn the link on, see it, keep it (Priority: P2)
+
+The user turns Link on or off from the group's header (and the Mixer strip of the group),
+sees at a glance which groups are linked and which tracks belong to a linked group, and
+finds the setting again after reopening the project.
+
+**Why this priority**: The entry point and its feedback; small but required for the other
+stories to be usable and discoverable.
+
+**Independent Test**: Toggle Link on a group, save, reopen — it is still on; the toggle
+reads as on in the header and the Mixer; undo turns it back off.
+
+**Acceptance Scenarios**:
+
+1. **Given** a group, **When** the user clicks its Link toggle, **Then** the toggle shows
+ as on (accent colour) in the Arrangement header and the Mixer, and the group's child
+ track headers show they are linked.
+2. **Given** a linked group, **When** the project is saved and reopened, **Then** the group
+ is still linked.
+3. **Given** the user toggled Link, **When** they undo, **Then** Link goes back to its
+ previous state.
+
+---
+
+### Edge Cases
+
+- **No matching clip** on another track (only one side was recorded there): the edit acts
+ on the tracks that have a match; the others are left as they are. Time-based edits
+ (split at a position, a range delete) act on whatever each track has at that time.
+- **Clips that only partly overlap** on another track: not a match — see FR-006; they are
+ only touched by time-based edits.
+- **Nested groups**: a linked group links every track below it, including the tracks of
+ groups nested inside it; a nested group's own Link adds nothing while its parent is
+ linked. A track inside an unlinked group inside a linked one is still linked through
+ the outer group.
+- **Mixed track kinds** (audio and instrument tracks in one linked group): edits act on
+ matching clips of any kind; a pasted clip only lands on a track that takes its kind.
+- **Moving a clip to another track** (dragging vertically, ⌥↑ / ⌥↓): the time shift is
+ linked, the track change is not — the partners move by the same amount in time and stay
+ on their own tracks; only the source clip changes track (and stops matching them).
+- **Dropping clips below the last track** (New track per source track): the linked
+ partners are not dragged along unless they were selected explicitly.
+- **Moving a track out of a linked group** (ungroup, drag out): it stops being linked
+ immediately; moving one in links it.
+- **Group tracks themselves** have no clips and no arm; Link affects only the tracks inside.
+- **Return and master tracks** cannot be in a group and are never linked.
+- **While recording**: changing Link does not disarm or arm anything mid-take; the arm rule
+ applies to the next arm click.
+- **Clip-content edits** (notes in the piano roll, warp markers, gain envelope inside a
+ clip, clip properties like transpose or name) are not linked — they are specific to one
+ track's material.
+- **Session View** clips and slots are not linked (scope is the Arrangement); arming from
+ the Session View is linked, since arm is a track property.
+
+## Requirements *(mandatory)*
+
+### Functional Requirements
+
+- **FR-001**: Every Group track MUST have a **Link** toggle, off by default for new and
+ existing groups, shown in the group's Arrangement header (slim and full rows) and its
+ Mixer strip.
+- **FR-002**: While a group is linked, every track below it (recursively, excluding group
+ tracks, return and master) MUST be a **linked member** of that group; a track's link set
+ is the members of its outermost linked ancestor group.
+- **FR-003**: The linked state MUST be saved with the project, restored on open, and every
+ Link toggle MUST be one undo step.
+- **FR-004**: Linked members MUST be marked in their Arrangement headers so the user sees
+ which tracks will follow an edit.
+- **FR-005**: Arming a linked member MUST arm every recordable linked member of the same
+ set, following today's exclusive / additive rule for tracks outside the set (a plain
+ click disarms tracks outside the set, ⌘-click leaves them); disarming one MUST disarm the
+ whole set. Arm-on-select MUST treat the set as one track.
+- **FR-006**: A clip on another linked member **matches** a source clip when it starts and
+ ends at the same timeline positions, within 1/256 of a beat, so clips recorded together
+ match exactly.
+- **FR-007**: Selecting a clip on a linked member MUST also select its matching clips on
+ the other members; removing it from the selection removes them too. ⌘A selection and
+ rubber-band selection need no change (they already select everything they cover).
+- **FR-008**: A time range started on a linked member MUST cover every member of the set.
+- **FR-009**: These Arrangement clip edits MUST apply to the matching clips of linked
+ members, as one undo step together with the source edit: move in time (drag, nudge;
+ a move to another track shifts the partners in time only, on their own tracks),
+ trim start / end, fade in / out changes, delete, duplicate, cut, copy (pasting puts each
+ clip back on its own track).
+- **FR-010**: Split at the cursor and split across a selection MUST split every linked
+ member at the same position(s), whatever clip each one has there.
+- **FR-011**: Range edits (copy, cut, duplicate, delete, paste over a range) on a range
+ that covers linked members MUST act on all members, as they do today for tracks the
+ range covers.
+- **FR-012**: The user MUST be able to act on a single linked track without turning Link
+ off: ⌥-click (Alt-click on Windows / Linux) on a clip selects that clip alone, without its
+ matches, and the edits that follow act on it alone; ⌥-click on a linked track's arm arms
+ or disarms that track alone. ⌥-*drag* keeps its meaning (move without snapping) and stays
+ linked. Time ranges have no bypass — they follow Link. The gesture is listed in
+ Preferences → Shortcuts.
+- **FR-013**: The Link state MUST be readable and settable through the MCP server, like
+ other track properties.
+- **FR-014**: With Link off on every group, editing and arming MUST behave exactly as
+ today.
+
+### Key Entities
+
+- **Group link**: an on/off property of a Group track, saved with the project.
+- **Link set**: the non-group tracks under a group's outermost linked ancestor; derived,
+ not stored.
+- **Matching clips**: clips on other members of a link set with the same start and end
+ positions as a source clip (within tolerance).
+
+## Success Criteria *(mandatory)*
+
+### Measurable Outcomes
+
+- **SC-001**: With two linked tracks recorded together, a split + move + delete sequence
+ takes the same number of user actions as on one track (half of today's).
+- **SC-002**: After any sequence of linked edits on clips recorded together, the clips on
+ every member of the set start and end at identical positions.
+- **SC-003**: Every linked edit, and every Link toggle, is undone by a single undo.
+- **SC-004**: One click arms or disarms every recordable track of a linked group.
+- **SC-005**: Projects saved before this feature open unchanged, with every group unlinked.
+
+## Assumptions
+
+- The issue's "folder track" is Nota's Group track; Link lives on Group tracks only (no
+ separate track-group object without a submix).
+- Linking covers recording arm, Arrangement clip selection and Arrangement clip edits
+ only (confirmed 2026-11-04). Mute, solo, volume, pan, sends, devices and automation are not linked (mixer
+ linking / VCA is a separate feature).
+- Clip-content editors (piano roll, audio clip editor) and the Session View clip grid are
+ out of scope.
+- Matching by identical start and end (FR-006, confirmed 2026-11-04) is chosen because it is predictable
+ and fits the main use case (simultaneously recorded takes); partly overlapping clips are
+ only affected by time-based edits.
+- Nested linked groups merge into the outermost linked one (FR-002).
+- The toggle follows DESIGN.md: a small key in the header controls, orange accent when on.
+
+## Nota Compliance Checklist *(review before implementation; re-check in tasks.md)*
+
+- [ ] Every new source file will carry the AGPL-3.0-only SPDX header (two lines, see CONTRIBUTING.md)
+- [ ] No new dependency — or: license checked, AGPL-compatible, `LICENSES/third-party.md` row planned
+- [ ] Audio-thread impact considered: no alloc / lock / I/O on the audio thread (AR-6), command queue for data in (AR-4), immutable snapshots for structural edits (AR-5)
+- [ ] Managed/native crossings go through the pure C ABI in `nota_engine.h` only (AR-7); no JUCE outside `pluginhost/`
+- [ ] Smoke-test impact assessed: engine behaviour change → extend `tests/Nota.SmokeTest`
+- [ ] User-visible change → `CHANGELOG.md` `[Unreleased]` entry planned (and FEATURES.md / user docs via the nota-features / nota-docs skills when working with an agent that has them)
+- [ ] UI change → follows `DESIGN.md` (Studio design language)
diff --git a/specs/076-group-link/tasks.md b/specs/076-group-link/tasks.md
new file mode 100644
index 00000000..cc3716b8
--- /dev/null
+++ b/specs/076-group-link/tasks.md
@@ -0,0 +1,155 @@
+---
+
+description: "Tasks for Linked editing on group tracks (specs/076, #184)"
+---
+
+# Tasks: Linked editing on group tracks
+
+**Input**: Design documents from `specs/076-group-link/`
+
+**Prerequisites**: [plan.md](plan.md), [spec.md](spec.md), [research.md](research.md),
+[data-model.md](data-model.md), [contracts/](contracts/), [quickstart.md](quickstart.md)
+
+**Tests**: The constitution (IV) requires the smoke test to cover the new C ABI; the pure
+rule class and linked arming are covered there too (`tests/Nota.SmokeTest/GroupLinkTests.cs`,
+run from `Program.cs` like `ArrangementMovesTests`). UI behaviour is checked with the
+quickstart scenarios.
+
+**Organization**: by user story. US2 (selection) is implemented before US1 (edits) because
+the linked edits ride on the linked selection (plan § 3); both are P1.
+
+## Format: `[ID] [P?] [Story] Description`
+
+- **[P]**: Can run in parallel (different files, no dependencies)
+- **[Story]**: US1 edits · US2 selection · US3 arming · US4 toggle / visibility / persistence
+
+---
+
+## Phase 1: Setup
+
+- [X] T001 Confirm the branch `feat/folder-track-groups` is based on `develop` and the engine build dir `build/` is Release (memory: engine build dirs); no code change
+
+---
+
+## Phase 2: Foundational (blocks every story)
+
+**Purpose**: the Link flag end to end and the shared rule class.
+
+- [X] T002 Add `bool editLink = false;` beside `pianoFold` in `src/native/nota.engine/src/engine/Track.h` (comment: specs/076, authoring only, never read on the audio thread) and make sure `cloneTrack` copies it (check the clone helper in `src/native/nota.engine/src/engine/Engine_Tracks.cpp`)
+- [X] T003 Declare `bool setTrackEditLink(int32_t trackId, bool on); int32_t trackEditLink(int32_t trackId) const;` in `src/native/nota.engine/src/engine/Engine.h` and implement them in `src/native/nota.engine/src/engine/Engine_Tracks.cpp` after `trackPianoFold`: refuse non-group tracks (return false), return true without republishing when unchanged, else clone + `republishWithTrack` (an undo step); getter returns 1 / 0 / -1 for unknown
+- [X] T004 Add `nota_track_set_edit_link` / `nota_track_get_edit_link` with the doc comment from [contracts/c-abi.md](contracts/c-abi.md) after `nota_track_get_piano_fold` in `src/native/nota.engine/include/nota/nota_engine.h`, and their wrappers in `src/native/nota.engine/src/abi/nota_engine_track.cpp` (null engine → `NOTA_ERR_INVALID_ARG` / -1)
+- [X] T005 [P] Add the P/Invoke pair `TrackSetEditLink` / `TrackGetEditLink` in `src/managed/Nota.Infrastructure/Interop/NativeMethods.Tracks.cs`
+- [X] T006 Add `bool SetTrackEditLink(int trackId, bool on); bool GetTrackEditLink(int trackId);` with the doc comment from the contract to `src/managed/Nota.Application/Engine/IAudioEngine.cs` and implement them in `src/managed/Nota.Infrastructure/Interop/NotaEngine.Tracks.cs` (set returns `result == NOTA_OK`, get returns `== 1`)
+- [X] T007 Persist: add `public bool? EditLink { get; set; } // group Link (specs/076); written only when on` to `TrackDto` in `src/managed/Nota.Infrastructure/Persistence/ProjectModel.cs`; in `src/managed/Nota.Infrastructure/Persistence/ProjectService.cs` write `EditLink = engine.GetTrackEditLink(ti.Id) ? true : null` and on load call `engine.SetTrackEditLink(id, true)` for `EditLink == true` after group parents are restored, without leaving an undo step (load clears history — verify)
+- [X] T008 Create `src/managed/Nota.Application/Editing/GroupLink.cs` (SPDX header): `readonly record struct LinkTrack(int Id, int GroupId, bool IsGroup, bool IsReturn, bool EditLink)`; `GroupLink.Build(IEnumerable<LinkTrack>)`; `int RootOf(int trackId)` (outermost linked ancestor group, -1 none); `IReadOnlyList<int> Members(int trackId)` (the other non-group, non-return tracks with the same root; empty when unlinked); `IReadOnlyList<int> ExpandTracks(IEnumerable<int>)` (closure under membership, input order kept, then members); `static bool Matches(double startA, double lenA, double startB, double lenB)` with `public const double MatchTolerance = 1.0 / 256` applied to start and end ("within 1/256 of a beat", FR-006); `bool IsLinked(int trackId)`; `bool AnyLinked`
+- [X] T009 Create `tests/Nota.SmokeTest/GroupLinkTests.cs` (SPDX header) with `Run()` and register it in `tests/Nota.SmokeTest/Program.cs` next to `ArrangementMovesTests` (both places it is listed). First checks — the ABI table of [contracts/c-abi.md](contracts/c-abi.md) against the real engine: set/get on a group, refused on an audio track, idempotent set adds no undo step, undo/redo, duplicate group keeps it, unknown id → false; save → load round trip keeps it and an old project (no field) loads unlinked
+- [X] T010 [P] Add `GroupLink` rule checks to `tests/Nota.SmokeTest/GroupLinkTests.cs`: unlinked group → no members; linked group with A, B → members of A = [B]; nested: outer linked + inner unlinked → inner's tracks in the outer set; inner linked alone → own set; group and return tracks never members; `Matches` true at exact and 1/512-off edges, false at 1/128 off or different length; `ExpandTracks([A, X])` = [A, X, B]
+
+**Checkpoint**: `scripts/build.sh` green with the flag and rules in place; no UI change yet.
+
+---
+
+## Phase 3: User Story 2 — Select once, see the whole group selected (P1)
+
+**Goal**: selecting a clip or a range on a linked track selects the matching material.
+
+**Independent Test**: quickstart rows 2, 7 and 11.
+
+- [X] T011 [US2] Add `public bool EditLink;` to the track VM in `src/managed/Nota.App/ArrangementView.Vms.cs` and fill it in `Refresh` from `_engine.GetTrackEditLink` for group tracks (`src/managed/Nota.App/ArrangementView.cs`); add a cached `GroupLink _link` rebuilt at the end of `Refresh` from `_tracks` (`ArrangementView.Groups.cs`)
+- [X] T012 [US2] In `src/managed/Nota.App/ArrangementView.cs`: add `private readonly HashSet<(int track, int clip)> _selLinked = new();` and a helper `IEnumerable<(int,int)> MatchesOf(int trackId, int clipIndex)` that looks up the clip VM and returns the matching clips on `_link.Members(trackId)` (`GroupLink.Matches` on `StartBeat` / `LengthBeats`); every place that clears `_sel` clears `_selLinked`
+- [X] T013 [US2] Make `Select(trackId, clipIndex, keepTrackSet, linked = true)` add `MatchesOf` to `_sel` and `_selLinked` when `linked` (`src/managed/Nota.App/ArrangementView.cs`); `ToggleSelect` adds the clip with its matches, and removing a clip removes its matches that are in `_selLinked`
+- [X] T014 [US2] ⌥-click bypass (FR-012): in `src/managed/Nota.App/ArrangementView.LaneControl.cs` remember the press modifiers for the pending click and, on release of a pending click with Alt held, call `_o.Select(track, clip, linked: false)`; ⌥-drag behaviour unchanged
+- [X] T015 [US2] `SetSelection` / `ReselectPlaced`: after replacing `_sel`, recompute `_selLinked` — for `ReselectPlaced` mark as linked the placed clips that came from `_selLinked` entries (map by request order of the move/duplicate), for marquee / ⌘A leave `_selLinked` empty (`src/managed/Nota.App/ArrangementView.cs`, `ArrangementView.KeyMoves.cs`)
+- [X] T016 [US2] Time ranges (FR-008): `TimeSelectionTrackIds()` returns `_link.ExpandTracks(...)` of the row span (non-return rows); `SetTimeSelection` widens `_timeSelRowLo/Hi` to cover the visible rows of every touched set so the range draws over all members (`src/managed/Nota.App/ArrangementView.cs`)
+
+**Checkpoint**: selection and ranges link; edits on the selection (delete, duplicate, copy, cut, nudge, block drag) already follow.
+
+---
+
+## Phase 4: User Story 1 — Edit two takes as one (P1) 🎯 MVP (with US2)
+
+**Goal**: split, move, trim, fades, delete, duplicate, nudge, cut / copy act on matches as one undo step.
+
+**Independent Test**: quickstart rows 3, 4, 5, 6 and 12.
+
+- [X] T017 [US1] Split at playhead (FR-010): in `SplitSelectedAtPlayhead` (`src/managed/Nota.App/ArrangementView.cs`) add, for each linked track of the selection, every clip of its members spanning the playhead; run the split loop inside `_engine.BeginUndoGroup()` / `EndUndoGroup()` (try/finally)
+- [X] T018 [US1] Clip menu **Split here** (`src/managed/Nota.App/ArrangementView.LaneControl.cs`, the `MenuKit.Item(Loc.T("Split here")…)`): when the track is linked, split the clip and every member clip spanning `at` in one undo group (factor a `SplitLinkedAt(trackId, clipIndex, at)` helper in `ArrangementView.cs` shared with T017)
+- [X] T019 [US1] `DeleteSelectedClips` (`src/managed/Nota.App/ArrangementView.cs`): wrap the delete loop in one undo group so a linked delete is one step
+- [X] T020 [US1] Trim / resize: in `OnPointerReleased` (`src/managed/Nota.App/ArrangementView.LaneControl.cs`) collect the grabbed clip's matches that are in `_selLinked` **before** committing (matched on the pre-drag `_origStart` / `_origLen`), then apply the same `TrimClip` / `ResizeAudioClip` (by each clip's kind) to all of them inside one undo group; raise `RaiseClipGeometryChanged` for each
+- [X] T021 [US1] Clip ADSR / fades: `CommitAdsr` (`src/managed/Nota.App/ArrangementView.LaneControl.cs`) sets the same `ClipAdsr` on the grabbed clip's audio matches in `_selLinked`, in one undo group
+- [X] T022 [US1] Vertical drag move (research R5): in the group-move commit, entries whose `(track, clip)` is in `_selLinked` keep `destTrack = m.track` while taking the time shift; in the drag preview (`UpdateActiveDrag` / the `_groupMove` row drawing in `ArrangementView.LaneControl.cs`) those entries stay on their own rows; the `rowDelta` validity check ignores them
+- [X] T023 [US1] ⌥↑ / ⌥↓ (`MoveSelectedClipsToTrack` in `src/managed/Nota.App/ArrangementView.KeyMoves.cs`): compute the row shift from entries not in `_selLinked` and leave the linked entries out of the move
+- [X] T024 [US1] Verify (read the code paths, no change expected) that nudge, duplicate, copy, cut, paste and block drag act on `_sel` including the matches and are single undo steps; note any exception in this file
+
+**Checkpoint**: Stories 1 + 2 = the MVP; quickstart rows 2–7, 11, 12 pass.
+
+---
+
+## Phase 5: User Story 3 — Arm the group with one click (P2)
+
+**Goal**: arming one member arms the set; ⌥-click arms one track.
+
+**Independent Test**: quickstart rows 8 and 9.
+
+- [X] T025 [US3] In `src/managed/Nota.Presentation/TrackArm.cs`: build a `GroupLink` from `TryGetTrackInfo` + `GetTrackEditLink`; `Set(engine, trackId, on, additive, linked = true)` applies `on` to the track and (when `linked`) its members; the exclusive pass skips the set; return true when any track other than `trackId` changed. `FollowSelection` treats the set as one track (an armed set counts as one, arming arms the set)
+- [X] T026 [US3] In `src/managed/Nota.App/TrackArming.cs`: `Set(engine, trackId, on, additive, linked = true)` forwards; add `IsBypass(KeyModifiers)` (Alt held); update `Tip` to mention "⌥-click to arm one track of a linked group" via `MenuKit.Keys`
+- [X] T027 [US3] Pass `linked: !TrackArming.IsBypass(mods)` at every arm button: `src/managed/Nota.App/ArrangementView.cs` (arm chip), `MixerView.cs`, `MixerView.Compact.cs`, `SessionView.Mixer.cs`, `TrackInspectorView.cs` (each already has the click modifiers)
+- [X] T028 [US3] Add linked-arm checks to `tests/Nota.SmokeTest/GroupLinkTests.cs` with the real engine: linked A, B + C outside: plain arm A → A, B on, C off; additive → C stays; disarm B → A off; `linked: false` → only that track; Link off → today's behaviour
+
+**Checkpoint**: arming works from every view.
+
+---
+
+## Phase 6: User Story 4 — Turn the link on, see it, keep it (P2)
+
+**Goal**: the Link key, member marks, menu item, MCP.
+
+**Independent Test**: quickstart rows 1 and 10; ⌘Z after toggling restores it.
+
+- [X] T029 [US4] Link key on the group header (slim bar and full row) in `src/managed/Nota.App/ArrangementView.cs` / `ArrangementView.Groups.cs`, built like the M / S keys with `GlyphKind.ChainLink`, accent when on, tooltip from [contracts/ui.md](contracts/ui.md); click → `SetTrackEditLink(id, !on)`, status "The group's tracks are linked" when turned on, `Refresh()`; raise the event the Mixer listens to for track-state changes
+- [X] T030 [US4] Member mark: a 10 px `ChainLink` glyph before the name in a linked member's header, secondary text colour, tooltip "Linked with {0}" (`src/managed/Nota.App/ArrangementView.cs` header builder)
+- [X] T031 [US4] Group header context menu: checkable **Link tracks** item (`src/managed/Nota.App/ArrangementView.Groups.cs` or wherever the group header menu is built)
+- [X] T032 [P] [US4] Mixer: the Link key on group strips in `src/managed/Nota.App/MixerView.cs` and `MixerView.Compact.cs`, and the Session mixer group column in `src/managed/Nota.App/SessionView.Mixer.cs`; repaint on undo / external change like M / S
+- [X] T033 [P] [US4] MCP `set_group_link` / `get_group_link` in `src/managed/Nota.Mcp/Tools/TrackTools.cs` with the descriptions from [contracts/mcp.md](contracts/mcp.md)
+- [X] T034 [P] [US4] Localise the new strings (French entries; English is the key) in `src/managed/Nota.App/Languages/fr.json` per contracts/ui.md, and satisfy the DesignTokenCheck allow-lists if they flag the new labels
+
+**Checkpoint**: all stories done.
+
+---
+
+## Phase 7: Polish & Cross-Cutting
+
+- [X] T035 Run the quickstart scenarios in the app (headless harness per memory recipe) and capture a before/after shot of a linked group header for the PR
+- [X] T036 [P] Preferences → Shortcuts: add the two ⌥-click lines via the `nota-shortcuts` skill
+- [X] T037 [P] FEATURES.md via `nota-features` (Tracks and mixer → Group; Arrangement editing), user docs EN + RU via `nota-docs`
+
+### Nota closing tasks
+
+- [X] T038 Run `scripts/build.sh` until native + managed + smoke test are green — green except the render-pool `overloaded` burst check, which flakes on `develop` too (alternating base/branch rounds 2026-11-04: base failed 1 of 4, branch 1 of 4 under load; unrelated to this change, which adds no audio-thread code)
+- [X] T039 AGPL-3.0-only SPDX two-line header on `GroupLink.cs` and `GroupLinkTests.cs`
+- [X] T040 New dependency: N/A (none added)
+- [X] T041 `CHANGELOG.md` `[Unreleased]` → Added: group Link (#184)
+- [X] T042 Engine behaviour change → smoke test covers the ABI (T009) — confirm green
+
+---
+
+## Dependencies & Execution Order
+
+- Phase 2 blocks everything (T002 → T003 → T004 → T005/T006 → T007; T008 independent of the engine tasks; T009 after T006/T007; T010 after T008).
+- US2 (Phase 3) before US1 (Phase 4): US1's trim / ADSR / vertical-move code reads `_selLinked`.
+- US3 (Phase 5) needs only Phase 2 — can run in parallel with Phases 3–4 (different files: `TrackArm.cs`, `TrackArming.cs`, arm call sites).
+- US4 (Phase 6) needs Phase 2; T029–T031 touch `ArrangementView*.cs`, so run them after Phase 4 to avoid conflicts; T032–T034 are parallel.
+- Polish after all stories.
+
+### Parallel examples
+
+```text
+After Phase 2: Phase 3 (ArrangementView) ‖ Phase 5 (TrackArm / TrackArming) ‖ T033 (MCP)
+In Phase 6: T032 (Mixer) ‖ T033 (MCP) ‖ T034 (strings)
+```
+
+## Implementation Strategy
+
+1. Phase 2 → build green (flag + rules + smoke).
+2. Phases 3 + 4 → MVP: linked selection and edits (Link can be toggled through MCP until T029).
+3. Phase 5 → arming. 4. Phase 6 → UI entry points. 5. Polish, docs, build.
diff --git a/src/managed/Nota.App/ArrangementView.KeyMoves.cs b/src/managed/Nota.App/ArrangementView.KeyMoves.cs
index 3dcf7e36..c2b804ef 100644
--- a/src/managed/Nota.App/ArrangementView.KeyMoves.cs
+++ b/src/managed/Nota.App/ArrangementView.KeyMoves.cs
@@ -28,7 +28,7 @@ public partial class ArrangementView
if (delta == 0) return true; // already at the song start: the key is still ours
if (MoveBlock(block.Select(b => (b.track, b.clip, b.track, b.start + delta)).ToArray()) is not { } move) return true;
Refresh();
- ReselectPlaced();
+ ReselectPlaced(move);
ClipsMoved?.Invoke(move); // open editors follow their clips (index and START read-out)
return true;
}
@@ -39,7 +39,9 @@ public partial class ArrangementView
public bool MoveSelectedClipsToTrack(int dir)
{
if (_engine is null || _sel.Count == 0) return false;
- var block = SelectedClipStarts().Select(b => (b.track, b.clip, b.start, row: RowOfTrack(b.track))).ToList();
+ // A group Link's partners (specs/076) stay on their own tracks: only the picked clips move.
+ var block = SelectedClipStarts().Where(b => !IsLinkedPartner(b.track, b.clip))
+ .Select(b => (b.track, b.clip, b.start, row: RowOfTrack(b.track))).ToList();
if (block.Count == 0) return false;
if (block.Any(b => b.row < 0))
{
@@ -59,7 +61,7 @@ public partial class ArrangementView
if (_engine.LastMoveKeptDeviceAutomation())
StatusMessage?.Invoke(Loc.T("Moved across tracks — device automation stayed on the source"));
Refresh();
- ReselectPlaced();
+ ReselectPlaced(move);
ClipsMoved?.Invoke(move);
if (SelTrackId > 0) RevealTrack(SelTrackId);
AnnounceSelectedTrack(); // the destination track is now the active one
diff --git a/src/managed/Nota.App/ArrangementView.LaneControl.cs b/src/managed/Nota.App/ArrangementView.LaneControl.cs
index 77371ced..f0deaaa8 100644
--- a/src/managed/Nota.App/ArrangementView.LaneControl.cs
+++ b/src/managed/Nota.App/ArrangementView.LaneControl.cs
@@ -142,6 +142,7 @@ public sealed partial class ArrangementView
private int _pendingTrackId, _pendingClipIndex;
private double _pendingGrabBeat;
private bool _pendingWasSelected; // grabbed clip already in the multi-selection
+ private KeyModifiers _pendingMods; // the press's modifiers: ⌥-click bypasses a group Link (specs/076)
private Point _lastPos; // last pointer position (drag-tooltip anchor)
// Clip-edge resize hover: which edge (if any) a resize would grab, so it's
@@ -154,6 +155,15 @@ public sealed partial class ArrangementView
// Group move (drag a clip that's part of the multi-selection → move all).
private List<(int track, int clip, ClipVM vm, double origStart, int origRow)>? _groupMove;
+ // The group-move clips a group Link added (specs/076): they follow the time shift but stay
+ // on their own tracks, and a drop onto new tracks leaves them be.
+ private readonly HashSet<(int track, int clip)> _groupPartners = new();
+ private bool IsPartner((int track, int clip, ClipVM vm, double origStart, int origRow) m) => _groupPartners.Contains((m.track, m.clip));
+ // Trim / resize of a linked clip: its selected partners, previewed with it (specs/076).
+ // Hidden ones (a folded inner group's tracks) have no ClipVM: edited from engine data, not previewed.
+ private List<(int track, int clip, bool midi, ClipVM? vm)> _trimPartners = new();
+ // Selected clips on rows not shown (a folded group's tracks): they take the move's time shift.
+ private List<(int track, int clip, double origStart)> _groupHidden = new();
private double _grabOrigStart; // grabbed clip's original start (delta reference)
private int _grabRow; // grabbed clip's row (vertical delta reference)
private int _moveRowDelta; // rows to shift the group (instrument→instrument only)
@@ -281,7 +291,8 @@ public sealed partial class ArrangementView
CommitAdsr(ah.track.Id, ah.clip, ClipAdsrKit.Reset(ah.handle, ah.clip.Adsr.Fit(ah.clip.LengthBeats)));
return;
}
- _o.Select(ah.track.Id, ah.clip.ClipIndex);
+ bool alone = _o.IsPickedAlone(ah.track.Id, ah.clip.ClipIndex); // picked alone (⌥-click)
+ _o.Select(ah.track.Id, ah.clip.ClipIndex, linked: !alone && !ArrangementView.IsLinkBypass(e.KeyModifiers));
_adsrDrag = ah.handle;
_adsrClip = ah.clip;
_adsrTrackId = ah.track.Id;
@@ -342,6 +353,7 @@ public sealed partial class ArrangementView
_pendingClipIndex = hh.clip.ClipIndex;
_pendingGrabBeat = beat;
_pendingWasSelected = _o.IsSelected(hh.track.Id, hh.clip.ClipIndex);
+ _pendingMods = e.KeyModifiers;
_pressArgs = e;
_dragOutTried = false;
e.Pointer.Capture(this);
@@ -356,13 +368,33 @@ public sealed partial class ArrangementView
_grabOrigStart = grabbedStart;
_moveRowDelta = 0;
_groupMove = new List<(int, int, ClipVM, double, int)>();
+ _groupPartners.Clear();
+ _groupHidden = new();
+ // Grabbing a clip the link added (another clip's partner) swaps their roles (specs/076): the
+ // grabbed one is picked and its matches become its partners. Clips picked by hand — a
+ // marquee, ⌘A, ⌘-click — stay picked.
+ int grabIdx = _grabClip?.ClipIndex ?? -1;
+ bool grabIsPartner = grabIdx >= 0 && _o.IsLinkedPartner(grabTrackId, grabIdx);
+ var grabMatches = grabIsPartner ? new HashSet<(int, int)>(_o.MatchesOf(grabTrackId, grabIdx)) : new HashSet<(int, int)>();
for (int r = 0; r < _o._tracks.Count; r++)
{
var t = _o._tracks[r];
if (t.Id == grabTrackId) _grabRow = r;
foreach (var c in t.Clips)
if (_o.IsSelected(t.Id, c.ClipIndex))
+ {
_groupMove.Add((t.Id, c.ClipIndex, c, c.StartBeat, r));
+ bool grabbed = t.Id == grabTrackId && c.ClipIndex == grabIdx;
+ if (!grabbed && (grabMatches.Contains((t.Id, c.ClipIndex)) || _o.IsLinkedPartner(t.Id, c.ClipIndex)))
+ _groupPartners.Add((t.Id, c.ClipIndex));
+ }
+ }
+ if (_o._engine is { } eng)
+ {
+ var shown = new HashSet<(int, int)>(_groupMove.Select(m => (m.track, m.clip)));
+ foreach (var s in _o.Selection)
+ if (!shown.Contains(s) && eng.TryGetClipInfo(s.track, s.clip, out var ci))
+ _groupHidden.Add((s.track, s.clip, ci.StartBeat));
}
// Magnetic-snap targets: every other clip's edges + markers (exclude the group).
_snapTargets = _o.SnapTargets(new HashSet<(int, int)>(_groupMove.Select(m => (m.track, m.clip))));
@@ -375,6 +407,7 @@ public sealed partial class ArrangementView
if (delta == 0 || _groupMove is null) return 0;
foreach (var m in _groupMove)
{
+ if (IsPartner(m)) continue; // a linked partner keeps its own track
int tr = m.origRow + delta;
if (tr < 0 || tr >= _o._tracks.Count) return 0;
if (_o._tracks[tr].IsInstrument != _o._tracks[m.origRow].IsInstrument) return 0;
@@ -457,7 +490,15 @@ public sealed partial class ArrangementView
}
else
{
- _o.Select(_pendingTrackId, _pendingClipIndex); // trims act on a single clip
+ // A trim acts on its clip — and on a linked group, on the clips paired with it (specs/076).
+ // A clip picked alone (⌥-click) stays alone.
+ bool alone = _o.IsPickedAlone(_pendingTrackId, _pendingClipIndex);
+ _o.Select(_pendingTrackId, _pendingClipIndex, linked: !alone);
+ var trimEng = _o._engine;
+ _trimPartners = _o.SelectedPartnersOf(_pendingTrackId, _pendingClipIndex)
+ .Select(p => (p.track, p.clip,
+ midi: trimEng is not null && trimEng.TryGetClipInfo(p.track, p.clip, out var pci) && pci.IsMidi,
+ vm: _o.FindClipVM(p.track, p.clip))).ToList();
_drag = _pendingMode;
_dragTrackId = _pendingTrackId; _dragClipIndex = _pendingClipIndex;
_dragClip = _pendingClip; _origStart = _pendingClip!.StartBeat; _origLen = _pendingClip.LengthBeats;
@@ -517,11 +558,13 @@ public sealed partial class ArrangementView
case Drag.TrimR:
double newEnd = _o.SnapMagnetic(_origStart + _origLen + d, mods, _snapTargets);
_dragClip.LengthBeats = Math.Max(0.25, newEnd - _dragClip.StartBeat);
+ foreach (var p in _trimPartners) if (p.vm is { } pv) { pv.StartBeat = _dragClip.StartBeat; pv.LengthBeats = _dragClip.LengthBeats; }
break;
case Drag.TrimL:
double ns = Math.Clamp(_o.SnapMagnetic(_origStart + d, mods, _snapTargets), 0, _origStart + _origLen - 0.25);
_dragClip.StartBeat = ns;
_dragClip.LengthBeats = (_origStart + _origLen) - ns;
+ foreach (var p in _trimPartners) if (p.vm is { } pv) { pv.StartBeat = _dragClip.StartBeat; pv.LengthBeats = _dragClip.LengthBeats; }
break;
}
InvalidateVisual();
@@ -577,13 +620,18 @@ public sealed partial class ArrangementView
{
_pending = false;
e.Pointer.Capture(null);
- if (!_pendingWasSelected || _o.SelectionCount > 1)
+ bool bypass = ArrangementView.IsLinkBypass(_pendingMods);
+ // A plain click on a clip picked alone with ⌥ links it again (specs/076).
+ if (!_pendingWasSelected || _o.SelectionCount > 1 || (_o.IsPickedAlone(_pendingTrackId, _pendingClipIndex) && !bypass))
{
// The first click of a double-click narrows too; keep what it narrowed so the
// double-click can open the whole selection together (specs/029).
_o.RememberNarrowed(_pendingTrackId, _pendingClipIndex, _pendingWasSelected);
_o.Select(_pendingTrackId, _pendingClipIndex);
}
+ // ⌥-click: this clip alone, without the clips a group Link pairs it with (specs/076).
+ if (bypass && (_o.SelectionCount > 1 || !_o.IsPickedAlone(_pendingTrackId, _pendingClipIndex)))
+ _o.Select(_pendingTrackId, _pendingClipIndex, linked: false);
// Also drop the playhead where the user clicked (same as clicking empty lane) —
// but not during playback: scrubbing off the grid is disruptive, use the ruler.
if (_o._engine is not { IsPlaying: true })
@@ -638,7 +686,7 @@ public sealed partial class ArrangementView
if (_drag == Drag.Move && _groupMove is not null && _newTrackSources is { } sources)
{
- var clips = _groupMove.Select(m => (m.track, m.clip, m.vm.StartBeat)).ToList();
+ var clips = _groupMove.Where(m => !IsPartner(m)).Select(m => (m.track, m.clip, m.vm.StartBeat)).ToList();
SetNewTrackRows(false);
_groupMove = null; _drag = Drag.None; _moveRowDelta = 0;
e.Pointer.Capture(null);
@@ -661,11 +709,16 @@ public sealed partial class ArrangementView
var moves = _groupMove.Select(m =>
{
int destRow = m.origRow + rowDelta;
- int destTrack = (rowDelta != 0 && destRow >= 0 && destRow < _o._tracks.Count)
+ int destTrack = (rowDelta != 0 && !IsPartner(m) && destRow >= 0 && destRow < _o._tracks.Count)
? _o._tracks[destRow].Id : m.track;
return (m.track, m.clip, destTrack, m.vm.StartBeat);
- }).ToArray();
- move = _o.MoveBlock(moves);
+ }).ToList();
+ // Clips on hidden rows (a folded group's tracks, partners included) take the same
+ // time shift on their own tracks, so linked takes stay in step.
+ double shift = _grabClip is { } gcv ? gcv.StartBeat - _grabOrigStart : 0;
+ if (Math.Abs(shift) > 1e-9)
+ foreach (var h in _groupHidden) moves.Add((h.track, h.clip, h.track, Math.Max(0, h.origStart + shift)));
+ move = _o.MoveBlock(moves.ToArray());
committed = move is not null;
if (committed && eng.LastMoveKeptDeviceAutomation()) // explicit hint: only Volume/Pan followed across tracks (req 8.3.4)
_o.StatusMessage?.Invoke(Loc.T("Moved across tracks — device automation stayed on the source"));
@@ -675,7 +728,7 @@ public sealed partial class ArrangementView
if (moved)
{
_o.Refresh(); // also restores the preview if the engine rejected the move
- if (committed) _o.ReselectPlaced(); // a move can change clip indices
+ if (committed) _o.ReselectPlaced(move); // a move can change clip indices; ⌥-picks stay alone
if (move is not null) _o.RaiseClipsMoved(move); // so can open editors' clips
if (committed && rowDelta != 0) _o.AnnounceSelectedTrack(); // the destination track is now the active one
}
@@ -691,14 +744,21 @@ public sealed partial class ArrangementView
{
// Audio clips resize the grid-relative way: warped clips (or unwarped clips
// dragged past their source) stretch, otherwise trim — the engine picks.
- // MIDI clips trim as before.
- if (_dragClip.IsMidi)
- eng.TrimClip(_dragTrackId, _dragClipIndex, _dragClip.StartBeat, _dragClip.LengthBeats);
- else
- eng.ResizeAudioClip(_dragTrackId, _dragClipIndex, _dragClip.StartBeat, _dragClip.LengthBeats);
- // An editor open on this clip still holds the pre-drag geometry.
- _o.RaiseClipGeometryChanged(_dragTrackId, _dragClipIndex);
+ // MIDI clips trim as before. A linked clip's partners get the same edges, all
+ // in one undo step (specs/076).
+ var targets = new List<(int track, int clip, bool midi)> { (_dragTrackId, _dragClipIndex, _dragClip.IsMidi) };
+ foreach (var p in _trimPartners) targets.Add((p.track, p.clip, p.midi));
+ double start = _dragClip.StartBeat, len = _dragClip.LengthBeats;
+ _o.OneUndoStep(() =>
+ {
+ foreach (var (track, clip, midi) in targets)
+ if (midi) eng.TrimClip(track, clip, start, len);
+ else eng.ResizeAudioClip(track, clip, start, len);
+ });
+ // An editor open on these clips still holds the pre-drag geometry.
+ foreach (var (track, clip, _) in targets) _o.RaiseClipGeometryChanged(track, clip);
}
+ _trimPartners = new();
_drag = Drag.None;
_dragClip = null;
_rpPeaks = null; // drop the resize-preview peaks
@@ -721,6 +781,7 @@ public sealed partial class ArrangementView
|| _takeSwipe is not null;
if (!active) return false;
_pending = false; _drag = Drag.None; _groupMove = null; _moveRowDelta = 0; _dragClip = null; _rpPeaks = null;
+ _trimPartners = new(); _groupPartners.Clear(); _groupHidden = new();
_takeSwipe = null; _takeMoved = false; // an abandoned take swipe never comps
_marqueeArmed = false; _rangeActive = false; _marquee = null; _shiftClipTrack = -1; _shiftClipIndex = -1;
_auto.Cancel();
@@ -799,8 +860,16 @@ public sealed partial class ArrangementView
private void CommitAdsr(int trackId, ClipVM clip, ClipAdsr adsr)
{
if (_o._engine is not { } eng) return;
- eng.SetClipAdsr(trackId, clip.ClipIndex, adsr);
+ // A linked clip's selected audio partners take the same shape, as one step (specs/076).
+ var partners = _o.SelectedPartnersOf(trackId, clip.ClipIndex)
+ .Where(p => eng.TryGetClipInfo(p.track, p.clip, out var ci) && !ci.IsMidi).ToList();
+ _o.OneUndoStep(() =>
+ {
+ eng.SetClipAdsr(trackId, clip.ClipIndex, adsr);
+ foreach (var p in partners) eng.SetClipAdsr(p.track, p.clip, adsr);
+ });
_o.RaiseClipGeometryChanged(trackId, clip.ClipIndex);
+ foreach (var p in partners) _o.RaiseClipGeometryChanged(p.track, p.clip);
_o.Refresh();
}
@@ -963,7 +1032,7 @@ public sealed partial class ArrangementView
var edits = new List<Control>
{
- MenuKit.Item(Loc.T("Split here"), GlyphKind.Split, () => { _o._engine?.SplitClip(trackId, idx, at); _o.Refresh(); _o.ClipsSplit?.Invoke(); }, MenuKit.SplitKey),
+ MenuKit.Item(Loc.T("Split here"), GlyphKind.Split, () => { if (_o.SplitLinkedAt(new[] { (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))
@@ -1182,6 +1251,7 @@ public sealed partial class ArrangementView
using (ctx.PushOpacity(0.5))
foreach (var m in _groupMove)
{
+ if (IsPartner(m)) continue; // drawn in place on its own lane
int destRow = m.origRow + _moveRowDelta;
if (destRow < 0 || destRow >= _o._tracks.Count) continue;
var dest = _o._tracks[destRow];
@@ -1390,6 +1460,7 @@ public sealed partial class ArrangementView
private bool IsDraggingCrossTrack(int track, int clip)
=> _groupMove is not null && (_moveRowDelta != 0 || _newTrackSources is not null)
+ && !_groupPartners.Contains((track, clip))
&& _groupMove.Any(m => m.track == track && m.clip == clip);
// Shows or drops the new-track ghost rows below the lanes (#301), growing the lanes
@@ -1397,7 +1468,7 @@ public sealed partial class ArrangementView
private void SetNewTrackRows(bool on)
{
List<int>? sources = on && _groupMove is not null
- ? _groupMove.OrderBy(m => m.origRow).Select(m => m.track).Distinct().ToList()
+ ? _groupMove.Where(m => !IsPartner(m)).OrderBy(m => m.origRow).Select(m => m.track).Distinct().ToList()
: null;
if (sources is { Count: 0 }) sources = null;
if ((sources?.Count ?? 0) == (_newTrackSources?.Count ?? 0)) { _newTrackSources = sources; return; }
@@ -1423,6 +1494,7 @@ public sealed partial class ArrangementView
using (ctx.PushOpacity(0.5))
foreach (var m in _groupMove!)
{
+ if (IsPartner(m)) continue;
int k = sources.IndexOf(m.track);
var src = _o._tracks.FirstOrDefault(t => t.Id == m.track);
if (k < 0 || src is null) continue;
diff --git a/src/managed/Nota.App/ArrangementView.Link.cs b/src/managed/Nota.App/ArrangementView.Link.cs
new file mode 100644
index 00000000..ee7d727e
--- /dev/null
+++ b/src/managed/Nota.App/ArrangementView.Link.cs
@@ -0,0 +1,237 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Arrangement · group Link (specs/076, #184). A linked group ties its tracks together: picking
+// a clip also picks the clips at the same place on the other tracks (GroupLink.Matches), so
+// the block edits that act on the selection — move, nudge, duplicate, copy, cut, delete — take
+// them along. This file holds that selection rule and the helpers the edits that act on one
+// clip (split, trim, fades) and on time ranges use. The link sets come from the engine, not the
+// shown rows, so a folded group's tracks still follow.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Input;
+using Avalonia.Layout;
+using Nota.Application.Localization;
+using Nota.Application.Editing;
+using Nota.Presentation;
+
+namespace Nota.App;
+
+public sealed partial class ArrangementView
+{
+ // The clips in _sel that are there because they match a clip the user picked, not because
+ // they were picked: they take a move's time shift but keep their own track, and they are
+ // the partners a trim or a fade on the picked clip passes on to. Read through LinkedSel.
+ private readonly HashSet<(int track, int clip)> _selLinked = new();
+
+ // Rebuilt lazily after every Refresh (a toggle, a regroup and undo all refresh). _linkSeen
+ // keeps the last one built, so a Refresh can tell when the link sets changed.
+ private GroupLink? _link, _linkSeen;
+ private GroupLink Link => _link ??= _linkSeen = _engine is { } e ? TrackArm.Links(e) : GroupLink.None;
+
+ // Clips picked with ⌥ on a linked track (one track alone): split, trim and fades on them stay
+ // on their track, and no partners join them. Per clip, so a ⌘-click on another clip still
+ // brings that clip's partners along.
+ private readonly HashSet<(int track, int clip)> _selAlone = new();
+
+ private void ClearLinkState() { _selLinked.Clear(); _selAlone.Clear(); }
+
+ /// <summary>True when the clip is selected and was picked alone with ⌥ on a linked track.</summary>
+ internal bool IsPickedAlone(int trackId, int clipIndex)
+ => _selAlone.Contains((trackId, clipIndex)) && _sel.Contains((trackId, clipIndex));
+
+ // The link sets changed under a selection: drop the partners that no longer pair with a picked
+ // clip (only those — other groups keep theirs), and add the new ones unless the selection was
+ // picked alone.
+ private void ReconcileLinkedSelection()
+ {
+ var picked = _sel.Where(c => !_selLinked.Contains(c)).ToList();
+ var pickedSet = new HashSet<(int track, int clip)>(picked);
+ var want = new HashSet<(int track, int clip)>();
+ foreach (var p in picked)
+ if (!_selAlone.Contains(p))
+ foreach (var m in MatchesOf(p.track, p.clip))
+ if (!pickedSet.Contains(m)) want.Add(m);
+ foreach (var c in _selLinked.ToList())
+ if (!want.Contains(c)) { _selLinked.Remove(c); _sel.Remove(c); }
+ foreach (var m in want)
+ if (_sel.Add(m)) _selLinked.Add(m);
+ UpdateHeaderSelection();
+ Redraw();
+ }
+
+ /// <summary>True when the clip is in the selection because the link added it.</summary>
+ internal bool IsLinkedPartner(int trackId, int clipIndex)
+ => _selLinked.Contains((trackId, clipIndex)) && _sel.Contains((trackId, clipIndex));
+
+ /// <summary>The clips on the other tracks of a linked group that are the same material as
+ /// this one (same start and end). Empty when the track isn't linked.</summary>
+ internal List<(int track, int clip)> MatchesOf(int trackId, int clipIndex)
+ {
+ var found = new List<(int, int)>();
+ if (_engine is not { } eng) return found;
+ var members = Link.Members(trackId);
+ if (members.Count == 0 || !eng.TryGetClipInfo(trackId, clipIndex, out var src)) return found;
+ foreach (var m in members)
+ for (int i = 0; eng.TryGetClipInfo(m, i, out var ci); i++)
+ if (GroupLink.Matches(src.StartBeat, src.LengthBeats, ci.StartBeat, ci.LengthBeats))
+ found.Add((m, i));
+ return found;
+ }
+
+ // Adds the clip's matches to the selection as linked partners.
+ private void AddMatches(int trackId, int clipIndex)
+ {
+ foreach (var m in MatchesOf(trackId, clipIndex))
+ if (_sel.Add(m)) _selLinked.Add(m);
+ }
+
+ /// <summary>The grabbed clip's partners that are selected with it — what a trim or a fade on
+ /// it passes on to.</summary>
+ internal List<(int track, int clip)> SelectedPartnersOf(int trackId, int clipIndex)
+ => MatchesOf(trackId, clipIndex).Where(m => _sel.Contains(m)).ToList();
+
+ /// <summary>The given tracks widened to every track of their link sets (a time range or a
+ /// split acts on all of them).</summary>
+ internal int[] LinkTracks(IEnumerable<int> trackIds) => Link.ExpandTracks(trackIds).ToArray();
+
+ /// <summary>Clips on the given tracks that strictly span <paramref name="beat"/>.</summary>
+ private List<(int track, int clip)> ClipsSpanning(IEnumerable<int> trackIds, double beat)
+ {
+ var found = new List<(int, int)>();
+ if (_engine is not { } eng) return found;
+ foreach (var t in trackIds)
+ for (int i = 0; eng.TryGetClipInfo(t, i, out var ci); i++)
+ if (beat > ci.StartBeat + 1e-6 && beat < ci.StartBeat + ci.LengthBeats - 1e-6) found.Add((t, i));
+ return found;
+ }
+
+ /// <summary>Splits the given clips at <paramref name="beat"/>, plus — on linked tracks —
+ /// whatever the other tracks of the set have there, as one undo step. True when anything split.</summary>
+ internal bool SplitLinkedAt(IEnumerable<(int track, int clip)> clips, double beat, bool linked = true)
+ {
+ if (_engine is not { } eng) return false;
+ var targets = new HashSet<(int track, int clip)>(clips);
+ if (linked)
+ {
+ // Clips picked alone with ⌥ cut only their own track.
+ var linkedTracks = targets.Where(c => !_selAlone.Contains(c)).Select(c => c.track).Distinct().Where(Link.IsLinked).ToList();
+ if (linkedTracks.Count > 0)
+ foreach (var c in ClipsSpanning(LinkTracks(linkedTracks).Except(linkedTracks), beat)) targets.Add(c);
+ }
+ bool any = false;
+ eng.BeginUndoGroup();
+ try
+ {
+ // Descending clip index: SplitClip inserts a clip, so a higher index first never
+ // shifts a lower one still to visit on the same track.
+ foreach (var (track, clip) in targets.OrderByDescending(c => c.clip).ToList())
+ if (eng.TryGetClipInfo(track, clip, out var ci)
+ && beat > ci.StartBeat + 1e-6 && beat < ci.StartBeat + ci.LengthBeats - 1e-6)
+ { eng.SplitClip(track, clip, beat); any = true; }
+ }
+ finally { eng.EndUndoGroup(); }
+ return any;
+ }
+
+ // A time range drawn over a linked group's track covers every shown row of the group: a
+ // group's subtree is one run of rows, so widening to its first and last member row is enough.
+ private void WidenRangeToLinkSets()
+ {
+ if (_timeSelRowLo < 0 || _timeSelRowHi < _timeSelRowLo || !Link.AnyLinked) return;
+ var ids = new List<int>();
+ for (int r = _timeSelRowLo; r <= _timeSelRowHi && r < _tracks.Count; r++) ids.Add(_tracks[r].Id);
+ foreach (var id in LinkTracks(ids))
+ {
+ int row = RowOfTrack(id);
+ if (row < 0) continue; // a folded group's track: no row, still in TimeSelectionTrackIds
+ if (row < _timeSelRowLo) _timeSelRowLo = row;
+ if (row > _timeSelRowHi) _timeSelRowHi = row;
+ }
+ }
+
+ // After an edit re-selects what it placed, tell the picked clips from their partners again:
+ // per link set, the clips on the primary's track (or the set's first selected track) are the
+ // picked ones, and a clip on another member that matches one of them is a partner.
+ private void RelinkSelection()
+ {
+ _selLinked.Clear();
+ if (!Link.AnyLinked || _engine is not { } eng) return;
+ foreach (var bySet in _sel.Where(c => Link.IsLinked(c.track)).GroupBy(c => Link.RootOf(c.track)))
+ {
+ int pickedTrack = bySet.Any(c => c.track == SelTrackId) ? SelTrackId : bySet.First().track;
+ foreach (var picked in bySet.Where(c => c.track == pickedTrack))
+ foreach (var m in MatchesOf(picked.track, picked.clip))
+ if (_sel.Contains(m)) _selLinked.Add(m);
+ }
+ }
+
+ /// <summary>The tooltip of every Link key (Arrangement and Mixer).</summary>
+ internal static string LinkTip => MenuKit.Keys(Loc.T("Link tracks — arming and clip edits act on every track of the group · ⌥-click a clip or an arm to act on one track"));
+
+ /// <summary>Turns a group's Link on or off (one undo step) and says so.</summary>
+ internal void SetGroupLink(int groupId, bool on)
+ {
+ if (_engine is null) return;
+ _ = Link; // what the selection was linked by, so Refresh can reconcile it with the new sets
+ if (!_engine.SetTrackEditLink(groupId, on)) return;
+ Refresh();
+ if (on) StatusMessage?.Invoke(Loc.T("The group's tracks are linked"));
+ }
+
+ /// <summary>The group header's Link key: a chain-link chip, accent-filled while on.</summary>
+ private Control LinkToggle(TrackVM t)
+ {
+ var glyph = new Glyph(GlyphKind.ChainLink, 10);
+ var chip = new Border
+ {
+ Width = 18, Height = 16, CornerRadius = NotaRadius.Control, BorderThickness = new Thickness(1),
+ Child = glyph, Cursor = new Cursor(StandardCursorType.Hand),
+ };
+ ToolTip.SetTip(chip, LinkTip);
+ PaintLinkChip(chip, glyph, t.EditLink);
+ chip.PointerPressed += (_, e) =>
+ {
+ if (!e.GetCurrentPoint(chip).Properties.IsLeftButtonPressed) return;
+ e.Handled = true;
+ SetGroupLink(t.Id, !t.EditLink);
+ };
+ return chip;
+ }
+
+ internal static void PaintLinkChip(Border chip, Glyph glyph, bool on)
+ {
+ chip.Background = on ? NotaPalette.Accent : NotaPalette.SurfaceRaised;
+ chip.BorderBrush = on ? NotaPalette.Accent : NotaPalette.Seam;
+ glyph.Foreground = on ? NotaPalette.TextOnAccent : NotaPalette.TextSecondary;
+ }
+
+ /// <summary>A linked track's header mark: a small chain-link before the name (membership, so no accent).</summary>
+ private Control? LinkMemberMark(TrackVM t)
+ {
+ if (t.IsGroup || t.IsReturn || !Link.IsLinked(t.Id)) return null;
+ var mark = new Glyph(GlyphKind.ChainLink, 10)
+ {
+ Foreground = NotaPalette.TextSecondary, Margin = new Thickness(0, 0, 4, 0), VerticalAlignment = VerticalAlignment.Center,
+ };
+ string group = _engine is { } eng ? eng.GetTrackName(Link.RootOf(t.Id)) : "";
+ ToolTip.SetTip(mark, Loc.F("Linked with {0}", group.Length > 0 ? group : Loc.T("Group")));
+ return mark;
+ }
+
+ /// <summary>Runs <paramref name="edit"/> as one undo step.</summary>
+ internal void OneUndoStep(Action edit)
+ {
+ if (_engine is not { } eng) { edit(); return; }
+ eng.BeginUndoGroup();
+ try { edit(); }
+ finally { eng.EndUndoGroup(); }
+ }
+
+ /// <summary>Whether the click modifiers bypass the link (⌥ / Alt: act on one track).</summary>
+ internal static bool IsLinkBypass(Avalonia.Input.KeyModifiers mods) => TrackArming.IsBypass(mods);
+}
diff --git a/src/managed/Nota.App/ArrangementView.Vms.cs b/src/managed/Nota.App/ArrangementView.Vms.cs
index 3a216d2a..ce154924 100644
--- a/src/managed/Nota.App/ArrangementView.Vms.cs
+++ b/src/managed/Nota.App/ArrangementView.Vms.cs
@@ -28,6 +28,7 @@ public sealed partial class ArrangementView
public bool IsReturn;
public bool IsGroup; // a group (submix) track — has children, no clips
public int GroupId = -1; // parent group track id, or -1 (top-level)
+ public bool EditLink; // a group's Link (specs/076): its tracks arm and edit together
public int Depth; // hierarchy indent level (0 = top-level) for the header/lane row
public int ColorIndex; // index into the track palette (returns → 8/9)
public bool Muted;
diff --git a/src/managed/Nota.App/ArrangementView.cs b/src/managed/Nota.App/ArrangementView.cs
index f8d69a45..28822b9d 100644
--- a/src/managed/Nota.App/ArrangementView.cs
+++ b/src/managed/Nota.App/ArrangementView.cs
@@ -1029,7 +1029,14 @@ public sealed partial class ArrangementView : UserControl
/// take's row. Owned and updated by the window on its recording tick.</summary>
internal RecordPreview? RecordPreview { get; set; }
- public void Refresh(bool rebuildHeaders = true) => Refresh(rebuildHeaders, movedOnly: false);
+ public void Refresh(bool rebuildHeaders = true)
+ {
+ var linkBefore = _linkSeen;
+ Refresh(rebuildHeaders, movedOnly: false);
+ // A Link turned on or off anywhere (header, Mixer, Session, undo, MCP): the selected
+ // clips' partners follow the new link sets (specs/076).
+ if (rebuildHeaders && _sel.Count > 0 && linkBefore is not null && !linkBefore.SameSets(Link)) ReconcileLinkedSelection();
+ }
/// <summary>After an edit that only moved, cut or removed clips (a section rearrange,
/// specs/073): reload clip and automation data without rebuilding the track headers — the
@@ -1066,6 +1073,7 @@ public sealed partial class ArrangementView : UserControl
if (rebuildHeaders) ReloadSections(); // sections live in the engine's project (specs/016)
_tracks.Clear();
_returns.Clear();
+ _link = null; // group Link sets (specs/076): rebuilt on next use
var takePeaks = new Dictionary<(int, int, long), (float[], int)>();
if (_engine is { } eng)
{
@@ -1093,6 +1101,7 @@ public sealed partial class ArrangementView : UserControl
Name = IsProcessingTrack(ti.Id) ? Loc.T("Processing…") : TrackNames.Of(eng, ti),
Volume = ti.Volume,
Pan = ti.Pan,
+ EditLink = ti.IsGroup && eng.GetTrackEditLink(ti.Id), // group Link (specs/076)
};
if (_automationMode)
{
@@ -1349,11 +1358,27 @@ public sealed partial class ArrangementView : UserControl
}
// Re-select exactly the clips the last block paste/duplicate produced.
- private void ReselectPlaced()
+ // A move passes its map (old clip → new clip), so each clip picked alone with ⌥ stays alone
+ // (specs/076); without one (duplicate, paste) the choice carries over when every clip had it.
+ private void ReselectPlaced(ClipBlockMove? move = null)
{
if (_engine is null) return;
var placed = _engine.LastPlacedClips();
- if (placed.Length > 0) SetSelection(placed);
+ if (placed.Length > 0)
+ {
+ var aloneBefore = _selAlone.Where(c => _sel.Contains(c)).ToList();
+ bool allAlone = _sel.Count > 0 && _sel.All(c => _selAlone.Contains(c));
+ SetSelection(placed);
+ var placedSet = new HashSet<(int track, int clip)>(placed);
+ if (move is not null)
+ {
+ foreach (var c in aloneBefore)
+ if (move.Map.TryGetValue((c.track, c.clip), out var to) && to is { } n && placedSet.Contains((n.Track, n.Clip)))
+ _selAlone.Add((n.Track, n.Clip));
+ }
+ else if (allAlone) foreach (var c in placed) _selAlone.Add(c);
+ RelinkSelection();
+ }
}
// Tell the window the primary track changed under a clip selection (devices / clip tab follow).
@@ -1683,7 +1708,10 @@ public sealed partial class ArrangementView : UserControl
TrackSelected?.Invoke(trackId);
}
- internal void Select(int trackId, int clipIndex, bool keepTrackSet = false)
+ /// <summary>Selects one clip (or just a track, clipIndex -1). On a linked group's track the
+ /// clips at the same place on the group's other tracks come along (specs/076) unless
+ /// <paramref name="linked"/> is false (⌥-click).</summary>
+ internal void Select(int trackId, int clipIndex, bool keepTrackSet = false, bool linked = true)
{
if (HasTimeSelection) ClearTimeSelection(); // clip- and time-selection are exclusive (1.2.5)
if (!keepTrackSet) _selTracks.Clear(); // any other selection resets the header multi-selection
@@ -1692,7 +1720,13 @@ public sealed partial class ArrangementView : UserControl
SelClipIndex = clipIndex;
if (trackId > 0) FocusTrackId = trackId;
_sel.Clear();
- if (trackId > 0 && clipIndex >= 0) _sel.Add((trackId, clipIndex));
+ ClearLinkState();
+ if (trackId > 0 && clipIndex >= 0)
+ {
+ _sel.Add((trackId, clipIndex));
+ if (linked) AddMatches(trackId, clipIndex);
+ else if (Link.IsLinked(trackId)) _selAlone.Add((trackId, clipIndex)); // ⌥-click: the edits that follow stay on this track
+ }
// Selecting into or out of a group changes that row's height, so the rows below it
// move: re-lay them before the headers repaint their selection.
if (prev != trackId && (IsGroupTrack(prev) || IsGroupTrack(trackId))) RelayoutRows();
@@ -1738,6 +1772,11 @@ public sealed partial class ArrangementView : UserControl
if (HasAutoSelection) ClearAutoSelection();
if (_sel.Remove((trackId, clipIndex)))
{
+ // Its partners leave with it — those the link added, not ones picked by hand.
+ _selLinked.Remove((trackId, clipIndex));
+ _selAlone.Remove((trackId, clipIndex));
+ foreach (var m in MatchesOf(trackId, clipIndex))
+ if (_selLinked.Remove(m)) _sel.Remove(m);
// Removed: keep the primary stable unless we just removed it.
if (SelTrackId == trackId && SelClipIndex == clipIndex)
{
@@ -1748,6 +1787,9 @@ public sealed partial class ArrangementView : UserControl
else
{
_sel.Add((trackId, clipIndex));
+ _selLinked.Remove((trackId, clipIndex));
+ _selAlone.Remove((trackId, clipIndex));
+ AddMatches(trackId, clipIndex);
SelTrackId = trackId; SelClipIndex = clipIndex; FocusTrackId = trackId; // the just-clicked clip is the primary
}
UpdateHeaderSelection();
@@ -1794,7 +1836,8 @@ public sealed partial class ArrangementView : UserControl
_timeSelEnd = Math.Max(a, b);
_timeSelRowLo = Math.Max(0, Math.Min(rowA, rowB));
_timeSelRowHi = Math.Min(Math.Max(0, _tracks.Count - 1), Math.Max(rowA, rowB));
- if (_sel.Count > 0) { _sel.Clear(); SelClipIndex = -1; UpdateHeaderSelection(); }
+ WidenRangeToLinkSets();
+ if (_sel.Count > 0) { _sel.Clear(); ClearLinkState(); SelClipIndex = -1; UpdateHeaderSelection(); }
if (HasTimeSelection) BounceSource = (TimeSelectionTrackIds(), _timeSelStart, _timeSelEnd);
Redraw();
}
@@ -1845,7 +1888,7 @@ public sealed partial class ArrangementView : UserControl
var ids = new List<int>();
for (int r = _timeSelRowLo; r <= _timeSelRowHi && r >= 0 && r < _tracks.Count; r++)
if (!_tracks[r].IsReturn) ids.Add(_tracks[r].Id);
- return ids.ToArray();
+ return LinkTracks(ids); // a range on a linked group's track spans the whole group (specs/076)
}
@@ -1990,6 +2033,7 @@ public sealed partial class ArrangementView : UserControl
double bhi = Math.Max(anchor.StartBeat + anchor.LengthBeats, target.StartBeat + target.LengthBeats);
ClearTimeSelection();
_sel.Clear();
+ ClearLinkState();
for (int r = rlo; r <= rhi && r < _tracks.Count; r++)
foreach (var c in _tracks[r].Clips)
if (c.StartBeat < bhi - 1e-6 && c.StartBeat + c.LengthBeats > blo + 1e-6)
@@ -2005,16 +2049,9 @@ public sealed partial class ArrangementView : UserControl
{
if (_engine is null || _sel.Count == 0) return false;
double at = Math.Max(0, _playheadBeats);
- bool any = false;
- // Descending clip index per track: SplitClip inserts a new clip, so splitting a
- // higher index first never invalidates a lower one we still need to visit.
- foreach (var (track, clip) in _sel.OrderByDescending(c => c.clip).ToList())
- {
- var vm = FindClipVM(track, clip);
- if (vm is null) continue;
- if (at > vm.StartBeat + 1e-6 && at < vm.StartBeat + vm.LengthBeats - 1e-6)
- { _engine.SplitClip(track, clip, at); any = true; }
- }
+ // One undo step; on a linked group the other tracks are cut at the playhead too, whatever
+ // clip they have there (specs/076).
+ bool any = SplitLinkedAt(_sel.ToList(), at);
if (any) { Select(-1, -1); Refresh(); ClipsSplit?.Invoke(); }
return any;
}
@@ -2035,6 +2072,7 @@ public sealed partial class ArrangementView : UserControl
{
if (HasTimeSelection) ClearTimeSelection();
_sel.Clear();
+ ClearLinkState();
foreach (var c in clips) _sel.Add(c);
if (_sel.Count > 0) { var f = _sel.First(); SelTrackId = f.track; SelClipIndex = f.clip; FocusTrackId = f.track; }
else { SelTrackId = -1; SelClipIndex = -1; }
@@ -2108,9 +2146,13 @@ public sealed partial class ArrangementView : UserControl
// (it survives edits and isn't cleared in automation mode), so tolerate an index
// the engine rejects rather than throwing out of the keystroke handler.
bool any = false;
- foreach (var (track, clip) in _sel.OrderByDescending(c => c.clip))
- any |= _engine.TryDeleteClip(track, clip);
+ OneUndoStep(() => // a linked delete is one step (specs/076)
+ {
+ foreach (var (track, clip) in _sel.OrderByDescending(c => c.clip))
+ any |= _engine.TryDeleteClip(track, clip);
+ });
_sel.Clear();
+ ClearLinkState();
SelTrackId = -1; SelClipIndex = -1;
Refresh();
return any; // false when the selection was entirely stale — don't claim a delete
@@ -2198,6 +2240,7 @@ public sealed partial class ArrangementView : UserControl
{
ChipToggle("M", t.Muted, NotaPalette.Mute, v => { t.Muted = v; _engine?.SetTrackMute(t.Id, v); }),
ChipToggle("S", t.Soloed, NotaPalette.Solo, v => { t.Soloed = v; _engine?.SetTrackSolo(t.Id, v); }),
+ LinkToggle(t),
},
};
@@ -2293,9 +2336,18 @@ public sealed partial class ArrangementView : UserControl
Grid.SetColumn(badge, 0);
nameRow.Children.Add(badge);
}
- Grid.SetColumn(name, 1);
+ Control nameCell = name;
+ if (LinkMemberMark(t) is { } mark) // linked with its group (specs/076)
+ {
+ var dock = new DockPanel { LastChildFill = true };
+ DockPanel.SetDock(mark, Dock.Left);
+ dock.Children.Add(mark);
+ dock.Children.Add(name);
+ nameCell = dock;
+ }
+ Grid.SetColumn(nameCell, 1);
Grid.SetColumn(typeTag, 2);
- nameRow.Children.Add(name);
+ nameRow.Children.Add(nameCell);
nameRow.Children.Add(typeTag);
// M / S / ● (record-arm) and, on audio tracks, the monitor chip — 18×16 chips held
@@ -2309,6 +2361,7 @@ public sealed partial class ArrangementView : UserControl
// without re-reading the engine, and a stale VM put the old state back (#255).
btnRow.Children.Add(ChipToggle("M", t.Muted, NotaPalette.Mute, v => { t.Muted = v; _engine?.SetTrackMute(t.Id, v); }));
btnRow.Children.Add(ChipToggle("S", t.Soloed, NotaPalette.Solo, v => { t.Soloed = v; _engine?.SetTrackSolo(t.Id, v); }));
+ if (t.IsGroup) btnRow.Children.Add(LinkToggle(t)); // group Link (specs/076)
// Record-arm applies to instrument (MIDI capture) + audio (input capture) tracks;
// return and group tracks have no input, so they get no arm chip.
if (!t.IsReturn && !t.IsGroup)
@@ -2686,6 +2739,8 @@ public sealed partial class ArrangementView : UserControl
int ungroupId = GroupToUngroupFor(trackId);
if (ungroupId > 0)
create.Add(MenuKit.Item(Loc.T("Ungroup"), GlyphKind.Ungroup, () => UngroupGroup(ungroupId), MenuKit.UngroupKey));
+ if (vm is { IsGroup: true } gvm) // group Link (specs/076)
+ create.Add(MenuKit.SwitchItem(Loc.T("Link tracks"), GlyphKind.ChainLink, gvm.EditLink, () => SetGroupLink(gvm.Id, !gvm.EditLink)));
// Clipboard + lifecycle go through the same set commands as the keys (a group carries
// its children); paste lands right after this track.
@@ -2889,8 +2944,8 @@ public sealed partial class ArrangementView : UserControl
// toggle's own colour — mute amber, solo blue, arm red — with
// derived ink. Record-arm: at rest a neutral key with a red disc; armed, solid red with a
// white disc.
- // onChanged(armed, additive): additive = ⌘/Ctrl held, arm without disarming the others (#332).
- private Control ArmToggle(bool initial, Action<bool, bool> onChanged)
+ // onChanged(armed, modifiers): ⌘/Ctrl arms without disarming the others (#332), ⌥ bypasses a group Link (specs/076).
+ private Control ArmToggle(bool initial, Action<bool, KeyModifiers> onChanged)
{
bool state = initial;
var disc = new Glyph(GlyphKind.Record, 7);
@@ -2906,7 +2961,7 @@ public sealed partial class ArrangementView : UserControl
chip.PointerPressed += (_, e) =>
{
if (!e.GetCurrentPoint(chip).Properties.IsLeftButtonPressed) return;
- e.Handled = true; state = !state; Paint(); onChanged(state, TrackArming.IsAdditive(e.KeyModifiers));
+ e.Handled = true; state = !state; Paint(); onChanged(state, e.KeyModifiers);
};
return chip;
}
diff --git a/src/managed/Nota.App/Languages/fr.json b/src/managed/Nota.App/Languages/fr.json
index 3082d3f8..3d417e64 100644
--- a/src/managed/Nota.App/Languages/fr.json
+++ b/src/managed/Nota.App/Languages/fr.json
@@ -1638,7 +1638,15 @@
"No cloud while the track is muted.": "Pas de nuage tant que la piste est en sourdine.",
"Below −60 dBFS, so the cloud is hidden.": "Sous −60 dBFS : le nuage est masqué.",
"Silent": "Silence",
- "Arm for recording · ⌘-click to arm several tracks": "Armer pour l’enregistrement · ⌘-clic pour armer plusieurs pistes",
+ "Arm for recording · ⌘-click to arm several tracks · ⌥-click to arm one track of a linked group": "Armer pour l’enregistrement · ⌘-clic pour armer plusieurs pistes · ⌥-clic pour armer une seule piste d’un groupe lié",
+ "Link tracks — arming and clip edits act on every track of the group · ⌥-click a clip or an arm to act on one track": "Lier les pistes — l’armement et l’édition des clips agissent sur toutes les pistes du groupe · ⌥-clic sur un clip ou un bouton d’armement pour n’agir que sur une piste",
+ "Link tracks": "Lier les pistes",
+ "Linked with {0}": "Liée à {0}",
+ "The group's tracks are linked": "Les pistes du groupe sont liées",
+ "Click a group's Link key": "Clic sur la touche Link d’un groupe",
+ "Link the group's tracks: arming one arms them all, and clip edits act on the clips at the same place on each": "Lier les pistes du groupe : en armer une les arme toutes, et l’édition d’un clip agit sur les clips au même endroit sur chacune",
+ "⌥-click a clip or Arm": "⌥-clic sur un clip ou sur Armer",
+ "In a linked group: select that clip alone, or arm that track alone": "Dans un groupe lié : sélectionner ce clip seul, ou armer cette piste seule",
"No track selected": "Aucune piste sélectionnée",
"Audio track": "Piste audio",
"MIDI track": "Piste MIDI",
diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.cs
index 7b813050..0ca543e2 100644
--- a/src/managed/Nota.App/MainWindow.axaml.cs
+++ b/src/managed/Nota.App/MainWindow.axaml.cs
@@ -492,6 +492,7 @@ public partial class MainWindow : Window
},
};
_mixer.MinContentHeightChanged += OnMixerMinHeightChanged;
+ _mixer.GroupLinkChanged += () => { Timeline.Refresh(); _session?.Refresh(); }; // a group's Link key (specs/076)
// Modular: signal-graph view of the selected track (mockup 1a). Follows track
// selection like the Detail device chain does.
diff --git a/src/managed/Nota.App/MixerView.Compact.cs b/src/managed/Nota.App/MixerView.Compact.cs
index 48727a2c..b92d0ab3 100644
--- a/src/managed/Nota.App/MixerView.Compact.cs
+++ b/src/managed/Nota.App/MixerView.Compact.cs
@@ -201,6 +201,8 @@ public sealed partial class MixerView
stack.Children.Add(Wide(mute));
stack.Children.Add(Wide(solo));
if (!isReturn) stack.Children.Add(Wide(ArmToggle(ti.Armed != 0, (v, additive) => TrackArming.Set(_engine, id, v, additive), out sync.Arm)));
+ if (ti.IsGroup) { stack.Children.Add(Wide(LinkKey(id, out var linkSync))); sync.Link = linkSync; } // group Link (specs/076)
+ else sync.Link = null;
return new Border { Height = ButtonsH, BorderBrush = BorderInner, BorderThickness = new Thickness(0, 1, 0, 0), Child = stack };
}
diff --git a/src/managed/Nota.App/MixerView.cs b/src/managed/Nota.App/MixerView.cs
index 40b86470..f6d6b505 100644
--- a/src/managed/Nota.App/MixerView.cs
+++ b/src/managed/Nota.App/MixerView.cs
@@ -99,7 +99,7 @@ public sealed partial class MixerView : UserControl
public DragNumber? Db;
public PanKnob? Pan;
public PanBar? PanBar; // compact strips
- public Action<bool>? Mute, Solo, Arm;
+ public Action<bool>? Mute, Solo, Arm, Link; // Link: a group's Link key (specs/076)
}
private readonly Dictionary<int, StripSync> _syncs = new();
private StripSync SyncOf(int id) => _syncs.TryGetValue(id, out var s) ? s : _syncs[id] = new StripSync();
@@ -192,6 +192,29 @@ public sealed partial class MixerView : UserControl
/// fit its width to them.</summary>
public event Action? StripsChanged;
+ /// <summary>Raised after a group strip's Link key changed the group's Link (specs/076).</summary>
+ public event Action? GroupLinkChanged;
+
+ // A group strip's Link key: the chain-link chip of the Arrangement's group header.
+ private Border LinkKey(int id, out Action<bool> sync)
+ {
+ bool on = _engine.GetTrackEditLink(id);
+ var glyph = new Glyph(GlyphKind.ChainLink, 10);
+ var b = new Border { Width = 20, Height = 17, CornerRadius = NotaRadius.Control, BorderThickness = new Thickness(1), Child = glyph, Cursor = new Cursor(StandardCursorType.Hand) };
+ ToolTip.SetTip(b, ArrangementView.LinkTip);
+ ArrangementView.PaintLinkChip(b, glyph, on);
+ b.PointerPressed += (_, e) =>
+ {
+ if (!e.GetCurrentPoint(b).Properties.IsLeftButtonPressed) return;
+ e.Handled = true;
+ if (!_engine.SetTrackEditLink(id, !on)) return;
+ on = !on; ArrangementView.PaintLinkChip(b, glyph, on);
+ GroupLinkChanged?.Invoke();
+ };
+ sync = v => { if (v == on) return; on = v; ArrangementView.PaintLinkChip(b, glyph, on); };
+ return b;
+ }
+
/// <summary>Raised when <see cref="MinContentHeight"/> changed, so a host can update its
/// own minimum.</summary>
public event Action? MinContentHeightChanged;
@@ -526,6 +549,7 @@ public sealed partial class MixerView : UserControl
s.Mute?.Invoke(ti.Muted != 0);
s.Solo?.Invoke(ti.Soloed != 0);
s.Arm?.Invoke(ti.Armed != 0);
+ if (ti.IsGroup) s.Link?.Invoke(_engine.GetTrackEditLink(ti.Id));
}
}
@@ -1070,11 +1094,13 @@ public sealed partial class MixerView : UserControl
row.Children.Add(mute);
row.Children.Add(solo);
if (!isReturn) row.Children.Add(ArmToggle(ti.Armed != 0, (v, additive) => TrackArming.Set(_engine, id, v, additive), out sync.Arm));
+ if (ti.IsGroup) { row.Children.Add(LinkKey(id, out var linkSync)); sync.Link = linkSync; } // group Link (specs/076)
+ else sync.Link = null;
return new Border { Height = 28, BorderBrush = BorderInner, BorderThickness = new Thickness(0, 1, 0, 0), Child = row };
}
// Record-arm: neutral with a red disc at rest, solid record red with a pale disc when armed.
- private Border ArmToggle(bool initial, Action<bool, bool> set, out Action<bool> sync) // (armed, ⌘/Ctrl held) — #332
+ private Border ArmToggle(bool initial, Action<bool, KeyModifiers> set, out Action<bool> sync) // (armed, modifiers) — #332, specs/076
{
bool on = initial;
var disc = new Glyph(GlyphKind.Record, 7);
@@ -1086,7 +1112,7 @@ public sealed partial class MixerView : UserControl
b.BorderBrush = on ? NotaPalette.Record : NotaPalette.Seam;
disc.Foreground = on ? NotaPalette.RecordInk : NotaPalette.Record;
}
- b.PointerPressed += (_, e) => { if (!e.GetCurrentPoint(b).Properties.IsLeftButtonPressed) return; e.Handled = true; on = !on; set(on, TrackArming.IsAdditive(e.KeyModifiers)); Paint(); };
+ b.PointerPressed += (_, e) => { if (!e.GetCurrentPoint(b).Properties.IsLeftButtonPressed) return; e.Handled = true; on = !on; set(on, e.KeyModifiers); Paint(); };
sync = v => { if (v == on) return; on = v; Paint(); };
Paint();
return b;
diff --git a/src/managed/Nota.App/PreferencesWindow.cs b/src/managed/Nota.App/PreferencesWindow.cs
index 096cb41e..6b72880c 100644
--- a/src/managed/Nota.App/PreferencesWindow.cs
+++ b/src/managed/Nota.App/PreferencesWindow.cs
@@ -1595,6 +1595,8 @@ public sealed partial class PreferencesWindow : NotaWindow
(Loc.T("Right-click the metronome"), Loc.T("Count-in before Play / Record: off · 1 · 2 · 4 bars")),
(Loc.T("Drag an audio clip's ADSR handle"), Loc.T("Shape attack · decay + sustain · release (top corners and the dot on hover) · ⌥-click types the stage · double-click resets it")),
(Loc.T("⇧-click track header"), Loc.T("Add the track to the selection · again to remove it")),
+ (Loc.T("Click a group's Link key"), Loc.T("Link the group's tracks: arming one arms them all, and clip edits act on the clips at the same place on each")),
+ (Loc.T("⌥-click a clip or Arm"), Loc.T("In a linked group: select that clip alone, or arm that track alone")),
(Loc.T("Right-click track headers"), Loc.T("A multi-selection gets its own menu: colour, height, freeze, group, copy, duplicate, delete")),
(Loc.T("Drag a track's bottom edge"), Loc.T("Resize the track (header or lane) · snaps to compact / standard / large · a multi-selection resizes together")),
(Loc.T("Drag a track's bottom edge + ⌥"), Loc.T("Resize every track at once")),
diff --git a/src/managed/Nota.App/SessionView.Mixer.cs b/src/managed/Nota.App/SessionView.Mixer.cs
index 4919f89f..0871af36 100644
--- a/src/managed/Nota.App/SessionView.Mixer.cs
+++ b/src/managed/Nota.App/SessionView.Mixer.cs
@@ -11,6 +11,7 @@ using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
+using Avalonia.Input;
using Avalonia.Layout;
using Avalonia.Media;
using Nota.Application;
@@ -202,6 +203,24 @@ public sealed partial class SessionView
}, out var syncArm));
follow.Add(t => syncArm(t.Armed != 0));
}
+ else if (c.Kind == ColKind.Group) // a group's Link key (specs/076)
+ {
+ bool linkOn = _engine.GetTrackEditLink(id);
+ var glyph = new Glyph(GlyphKind.ChainLink, 10);
+ var key = new Border { Height = 17, Margin = new Thickness(1, 0), CornerRadius = NotaRadius.Control, BorderThickness = new Thickness(1), Child = glyph, Cursor = new Cursor(StandardCursorType.Hand) };
+ ToolTip.SetTip(key, ArrangementView.LinkTip);
+ ArrangementView.PaintLinkChip(key, glyph, linkOn);
+ key.PointerPressed += (_, e) =>
+ {
+ if (!e.GetCurrentPoint(key).Properties.IsLeftButtonPressed) return;
+ e.Handled = true;
+ if (!_engine.SetTrackEditLink(id, !linkOn)) return;
+ linkOn = !linkOn; ArrangementView.PaintLinkChip(key, glyph, linkOn);
+ ArrangementChanged?.Invoke(); // the Arrangement repaints its headers
+ };
+ btns.Children.Add(key);
+ follow.Add(_ => { bool v = _engine.GetTrackEditLink(id); if (v != linkOn) { linkOn = v; ArrangementView.PaintLinkChip(key, glyph, v); } });
+ }
}
root.Children.Add(Section(panRow, FaderRow(vol, db), meters, btns));
}
@@ -243,7 +262,7 @@ public sealed partial class SessionView
// M / S / record-arm: a 20px key. Engaged mute fills amber, solo blue, arm the record red
// with its white disc (DESIGN.md § Controls), each with derived ink.
// set(on, additive): additive = ⌘/Ctrl held (the arm button arms without disarming the others, #332).
- private static Control MixToggle(string? label, bool initial, bool arm, Action<bool, bool> set, out Action<bool> sync)
+ private static Control MixToggle(string? label, bool initial, bool arm, Action<bool, KeyModifiers> set, out Action<bool> sync)
{
bool on = initial;
var text = new TextBlock { Text = label ?? "", FontSize = 10, FontWeight = FontWeight.SemiBold, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center };
@@ -273,7 +292,7 @@ public sealed partial class SessionView
{
if (!e.GetCurrentPoint(b).Properties.IsLeftButtonPressed) return;
e.Handled = true;
- on = !on; set(on, TrackArming.IsAdditive(e.KeyModifiers)); Paint();
+ on = !on; set(on, e.KeyModifiers); Paint();
};
sync = v => { if (v == on) return; on = v; Paint(); };
Paint();
diff --git a/src/managed/Nota.App/TrackArming.cs b/src/managed/Nota.App/TrackArming.cs
index 21e2c68c..1e2988d0 100644
--- a/src/managed/Nota.App/TrackArming.cs
+++ b/src/managed/Nota.App/TrackArming.cs
@@ -19,11 +19,16 @@ internal static class TrackArming
public static event Action? OthersChanged;
/// <summary>Arms or disarms a track, exclusively unless <paramref name="additive"/> (see TrackArm).</summary>
- public static void Set(IAudioEngine engine, int trackId, bool on, bool additive)
+ public static void Set(IAudioEngine engine, int trackId, bool on, bool additive, bool linked = true)
{
- if (TrackArm.Set(engine, trackId, on, additive)) OthersChanged?.Invoke();
+ if (TrackArm.Set(engine, trackId, on, additive, linked)) OthersChanged?.Invoke();
}
+ /// <summary>An arm click with its modifiers: ⌘ / Ctrl adds to the armed set, ⌥ / Alt arms
+ /// one track of a linked group alone (specs/076).</summary>
+ public static void Set(IAudioEngine engine, int trackId, bool on, Avalonia.Input.KeyModifiers mods)
+ => Set(engine, trackId, on, IsAdditive(mods), linked: !IsBypass(mods));
+
private static int _followed = -1;
/// <summary>Arm-on-select is on (Transport ▸ Auto-arm selected track, a saved preference;
@@ -44,9 +49,12 @@ internal static class TrackArming
public static void ForgetSelection() => _followed = -1;
/// <summary>The arm buttons' tooltip, with the platform's modifier spelled out.</summary>
- public static string Tip => MenuKit.Keys(Loc.T("Arm for recording · ⌘-click to arm several tracks"));
+ public static string Tip => MenuKit.Keys(Loc.T("Arm for recording · ⌘-click to arm several tracks · ⌥-click to arm one track of a linked group"));
/// <summary>⌘ on macOS, Ctrl elsewhere: the "add to the armed set" modifier.</summary>
public static bool IsAdditive(Avalonia.Input.KeyModifiers m)
=> (m & (OperatingSystem.IsMacOS() ? Avalonia.Input.KeyModifiers.Meta : Avalonia.Input.KeyModifiers.Control)) != 0;
+
+ /// <summary>⌥ (Alt): act on one track of a linked group, bypassing the link (specs/076).</summary>
+ public static bool IsBypass(Avalonia.Input.KeyModifiers m) => (m & Avalonia.Input.KeyModifiers.Alt) != 0;
}
diff --git a/src/managed/Nota.App/TrackInspectorView.cs b/src/managed/Nota.App/TrackInspectorView.cs
index 1cdb46e0..0e63c2f7 100644
--- a/src/managed/Nota.App/TrackInspectorView.cs
+++ b/src/managed/Nota.App/TrackInspectorView.cs
@@ -178,7 +178,7 @@ internal sealed class TrackInspectorView : UserControl
(on, _) => { _engine.SetTrackSolo(id, on); Edited(); }));
if (audio || ti.IsInstrument)
state.Children.Add(Toggle(Loc.T("Arm"), ti.Armed != 0, NotaPalette.Record, TrackArming.Tip,
- (on, mods) => { TrackArming.Set(_engine, id, on, TrackArming.IsAdditive(mods)); Edited(); }));
+ (on, mods) => { TrackArming.Set(_engine, id, on, mods); Edited(); }));
s.Children.Add(state);
if (audio) s.Children.Add(Section(Loc.T("Input"), InputRows(id)));
diff --git a/src/managed/Nota.Application/Editing/GroupLink.cs b/src/managed/Nota.Application/Editing/GroupLink.cs
new file mode 100644
index 00000000..44e6f6b2
--- /dev/null
+++ b/src/managed/Nota.Application/Editing/GroupLink.cs
@@ -0,0 +1,110 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Group Link (specs/076, #184): which tracks a linked group ties together, and which clips on
+// them count as the same material. The Arrangement (selection, edits, ranges) and the arm
+// buttons (TrackArm) both ask this one rule. Pure and UI-free: the smoke test drives it directly.
+
+using System;
+using System.Collections.Generic;
+
+namespace Nota.Application.Editing;
+
+/// <summary>What the rule needs to know about a track.</summary>
+public readonly record struct LinkTrack(int Id, int GroupId, bool IsGroup, bool IsReturn, bool EditLink);
+
+public sealed class GroupLink
+{
+ /// <summary>Two clips match when their starts and their ends lie within this many beats
+ /// (1/256 of a beat, about 2 ms at 120 BPM — far finer than any grid line).</summary>
+ public const double MatchTolerance = 1.0 / 256;
+
+ public static readonly GroupLink None = new(new Dictionary<int, int>(), new Dictionary<int, List<int>>());
+
+ private readonly IReadOnlyDictionary<int, int> _rootOf; // member track → link root group
+ private readonly IReadOnlyDictionary<int, List<int>> _members; // link root → members, track order
+
+ private GroupLink(IReadOnlyDictionary<int, int> rootOf, IReadOnlyDictionary<int, List<int>> members)
+ {
+ _rootOf = rootOf;
+ _members = members;
+ }
+
+ /// <summary>Builds the link sets: a non-group, non-return track belongs to the set of its
+ /// outermost ancestor group whose Link is on; members keep the given track order.</summary>
+ public static GroupLink Build(IEnumerable<LinkTrack> tracks)
+ {
+ var list = new List<LinkTrack>(tracks);
+ var byId = new Dictionary<int, LinkTrack>(list.Count);
+ foreach (var t in list) byId[t.Id] = t;
+ var rootOf = new Dictionary<int, int>();
+ var members = new Dictionary<int, List<int>>();
+ foreach (var t in list)
+ {
+ if (t.IsGroup || t.IsReturn) continue;
+ int root = -1;
+ int g = t.GroupId;
+ for (int guard = 0; g >= 0 && guard < list.Count && byId.TryGetValue(g, out var p) && p.IsGroup; guard++)
+ {
+ if (p.EditLink) root = p.Id; // keep climbing: the outermost linked group wins
+ g = p.GroupId;
+ }
+ if (root < 0) continue;
+ rootOf[t.Id] = root;
+ if (!members.TryGetValue(root, out var m)) members[root] = m = new List<int>();
+ m.Add(t.Id);
+ }
+ return new GroupLink(rootOf, members);
+ }
+
+ /// <summary>True when some group links two or more tracks.</summary>
+ public bool AnyLinked
+ {
+ get { foreach (var m in _members.Values) if (m.Count > 1) return true; return false; }
+ }
+
+ /// <summary>True when both tie the same tracks to the same link roots.</summary>
+ public bool SameSets(GroupLink other)
+ {
+ if (_rootOf.Count != other._rootOf.Count) return false;
+ foreach (var (t, r) in _rootOf)
+ if (!other._rootOf.TryGetValue(t, out var o) || o != r) return false;
+ return true;
+ }
+
+ /// <summary>The track's link root group id, or -1 when it isn't linked.</summary>
+ public int RootOf(int trackId) => _rootOf.TryGetValue(trackId, out var r) ? r : -1;
+
+ /// <summary>True when the track shares a link set with at least one other track.</summary>
+ public bool IsLinked(int trackId) => Members(trackId).Count > 0;
+
+ /// <summary>The other tracks of the track's link set (empty when it isn't linked).</summary>
+ public IReadOnlyList<int> Members(int trackId)
+ {
+ if (!_rootOf.TryGetValue(trackId, out var root)) return Array.Empty<int>();
+ var all = _members[root];
+ var others = new List<int>(all.Count - 1);
+ foreach (var id in all) if (id != trackId) others.Add(id);
+ return others;
+ }
+
+ /// <summary>The given tracks plus every member of their link sets: the given ones first, in
+ /// their order, then the added members, each once.</summary>
+ public IReadOnlyList<int> ExpandTracks(IEnumerable<int> trackIds)
+ {
+ var seen = new HashSet<int>();
+ var result = new List<int>();
+ var given = new List<int>();
+ foreach (var id in trackIds) if (seen.Add(id)) { result.Add(id); given.Add(id); }
+ foreach (var id in given)
+ foreach (var m in Members(id))
+ if (seen.Add(m)) result.Add(m);
+ return result;
+ }
+
+ /// <summary>Whether clip B is the same material as clip A on a linked track: the same start
+ /// and the same end, within <see cref="MatchTolerance"/>.</summary>
+ public static bool Matches(double startA, double lengthA, double startB, double lengthB)
+ => Math.Abs(startA - startB) <= MatchTolerance
+ && Math.Abs(startA + lengthA - (startB + lengthB)) <= MatchTolerance;
+}
diff --git a/src/managed/Nota.Application/Engine/IAudioEngine.cs b/src/managed/Nota.Application/Engine/IAudioEngine.cs
index 7e56cf56..a95c8164 100644
--- a/src/managed/Nota.Application/Engine/IAudioEngine.cs
+++ b/src/managed/Nota.Application/Engine/IAudioEngine.cs
@@ -322,6 +322,10 @@ public interface IAudioEngine : IDisposable
/// <summary>Sets/gets a track's piano roll Fold (specs/045): a view flag saved with the project.</summary>
void SetTrackPianoFold(int trackId, bool on);
bool GetTrackPianoFold(int trackId);
+ /// <summary>Group Link (specs/076): links a group's tracks for arming and clip edits. One undo
+ /// step; false for a track that is not a group.</summary>
+ bool SetTrackEditLink(int trackId, bool on);
+ bool GetTrackEditLink(int trackId);
/// <summary>Copies a whole track to the clipboard; pastes it as a new track (-1 on fail).</summary>
bool CopyTrack(int trackId);
int PasteTrack();
diff --git a/src/managed/Nota.Infrastructure/Interop/NativeMethods.Tracks.cs b/src/managed/Nota.Infrastructure/Interop/NativeMethods.Tracks.cs
index 64741d61..08135d09 100644
--- a/src/managed/Nota.Infrastructure/Interop/NativeMethods.Tracks.cs
+++ b/src/managed/Nota.Infrastructure/Interop/NativeMethods.Tracks.cs
@@ -288,6 +288,12 @@ internal static partial class NativeMethods
[LibraryImport(Lib, EntryPoint = "nota_track_get_piano_fold")]
internal static partial int TrackGetPianoFold(IntPtr engine, int trackId);
+ [LibraryImport(Lib, EntryPoint = "nota_track_set_edit_link")]
+ internal static partial NotaResult TrackSetEditLink(IntPtr engine, int trackId, int on);
+
+ [LibraryImport(Lib, EntryPoint = "nota_track_get_edit_link")]
+ internal static partial int TrackGetEditLink(IntPtr engine, int trackId);
+
[LibraryImport(Lib, EntryPoint = "nota_track_copy")]
internal static partial NotaResult TrackCopy(IntPtr engine, int trackId);
diff --git a/src/managed/Nota.Infrastructure/Interop/NotaEngine.Tracks.cs b/src/managed/Nota.Infrastructure/Interop/NotaEngine.Tracks.cs
index b57f5354..b3b34099 100644
--- a/src/managed/Nota.Infrastructure/Interop/NotaEngine.Tracks.cs
+++ b/src/managed/Nota.Infrastructure/Interop/NotaEngine.Tracks.cs
@@ -475,6 +475,14 @@ public sealed partial class NotaEngine
public bool GetTrackPianoFold(int trackId)
{ ThrowIfDisposed(); return NativeMethods.TrackGetPianoFold(_handle, trackId) == 1; }
+ /// <summary>Sets a group's Link (specs/076); one undo step, false for a non-group track.</summary>
+ public bool SetTrackEditLink(int trackId, bool on)
+ { ThrowIfDisposed(); return NativeMethods.TrackSetEditLink(_handle, trackId, on ? 1 : 0) == NativeMethods.NotaResult.Ok; }
+
+ /// <summary>Whether a group's Link is on (false for an unknown or non-group track).</summary>
+ public bool GetTrackEditLink(int trackId)
+ { ThrowIfDisposed(); return NativeMethods.TrackGetEditLink(_handle, trackId) == 1; }
+
/// <summary>Copies a whole track (incl. devices/clips/automation) to the clipboard.</summary>
public bool CopyTrack(int trackId)
{ ThrowIfDisposed(); return NativeMethods.TrackCopy(_handle, trackId) == NativeMethods.NotaResult.Ok; }
diff --git a/src/managed/Nota.Infrastructure/Persistence/ProjectModel.cs b/src/managed/Nota.Infrastructure/Persistence/ProjectModel.cs
index b5f5c639..02393d99 100644
--- a/src/managed/Nota.Infrastructure/Persistence/ProjectModel.cs
+++ b/src/managed/Nota.Infrastructure/Persistence/ProjectModel.cs
@@ -123,6 +123,7 @@ public sealed class TrackDto
public int GroupId { get; set; } = -1; // parent group's doc index, or -1 (top-level)
public int ColorIndex { get; set; } = -1; // palette slot; -1 = auto by position
public bool? PianoFold { get; set; } // piano roll Fold (specs/045); written only when on
+ public bool? EditLink { get; set; } // group Link (specs/076); written only when on
// Record input: 0 hardware, -1 master, or (2 + track-list index) for another track's
// output (encoded so it survives id reassignment across save/load).
public int RecordInput { get; set; }
diff --git a/src/managed/Nota.Infrastructure/Persistence/ProjectService.cs b/src/managed/Nota.Infrastructure/Persistence/ProjectService.cs
index 5b201679..ad1c99c3 100644
--- a/src/managed/Nota.Infrastructure/Persistence/ProjectService.cs
+++ b/src/managed/Nota.Infrastructure/Persistence/ProjectService.cs
@@ -109,6 +109,7 @@ public sealed class ProjectService
GroupId = ti.GroupId >= 0 && idToIndex.TryGetValue(ti.GroupId, out var gix) ? gix : -1, // parent → doc index
ColorIndex = engine.GetTrackColorIndex(ti.Id),
PianoFold = engine.GetTrackPianoFold(ti.Id) ? true : null,
+ EditLink = ti.IsGroup && engine.GetTrackEditLink(ti.Id) ? true : null,
RecordInput = engine.GetTrackRecordInput(ti.Id) is var rin && rin > 0
? (idToIndex.TryGetValue(rin, out var rix) ? rix + 2 : 0) // track source → doc index + 2
: rin, // 0 hardware / -1 master
@@ -742,6 +743,7 @@ public sealed class ProjectService
if (t.Name is { Length: > 0 } trackName) engine.SetTrackName(id, trackName);
if (t.ColorIndex >= 0) engine.SetTrackColorIndex(id, t.ColorIndex);
if (t.PianoFold == true) engine.SetTrackPianoFold(id, true);
+ if (t.EditLink == true) engine.SetTrackEditLink(id, true); // group Link (specs/076)
if (t.RecordInput != 0) recInputDeferred.Add((id, t.RecordInput)); // resolve after all tracks exist
if (t.Monitor) monitorDeferred.Add((id, true)); // after record inputs resolve
engine.SetTrackInputChannels(id, (InputChannels)(t.InputChannels ?? 0)); // older files: the stereo pair
diff --git a/src/managed/Nota.Mcp/Tools/TrackTools.cs b/src/managed/Nota.Mcp/Tools/TrackTools.cs
index 94d9963f..f00bdcbd 100644
--- a/src/managed/Nota.Mcp/Tools/TrackTools.cs
+++ b/src/managed/Nota.Mcp/Tools/TrackTools.cs
@@ -38,6 +38,12 @@ public sealed class TrackTools(IAudioEngine engine, IEngineDispatch dispatch, IA
[McpServerTool(Name = "get_piano_fold"), Description("Whether a track's piano roll is folded.")]
public Task<bool> GetPianoFold(int trackId) => Read(() => E.GetTrackPianoFold(trackId));
+ [McpServerTool(Name = "set_group_link"), Description("Link a group's tracks for editing and recording (Link): arming one arms them all, and clips selected or edited in the Arrangement take the clips at the same position on the other tracks along. One undo step. MCP edits are not linked; they act on the clips they name. Returns false when the track is not a group.")]
+ public Task<bool> SetGroupLink([Description("Group track id")] int trackId, bool on) => Mutate(() => E.SetTrackEditLink(trackId, on));
+
+ [McpServerTool(Name = "get_group_link"), Description("Whether a group's Link is on.")]
+ public Task<bool> GetGroupLink([Description("Group track id")] int trackId) => Read(() => E.GetTrackEditLink(trackId));
+
[McpServerTool(Name = "set_track_volume"), Description("Set a track's fader level (0..1 linear).")]
public Task SetTrackVolume(int trackId, [Description("Linear gain 0..1")] float volume)
=> Mutate(() => MixEdit.Step(E, () => E.SetTrackVolume(trackId, Math.Clamp(volume, 0f, 1f)), MixTarget.Volume(trackId))); // one undo step
diff --git a/src/managed/Nota.Presentation/TrackArm.cs b/src/managed/Nota.Presentation/TrackArm.cs
index fb0fa695..32b15376 100644
--- a/src/managed/Nota.Presentation/TrackArm.cs
+++ b/src/managed/Nota.Presentation/TrackArm.cs
@@ -6,26 +6,39 @@
// Ctrl-click on Windows / Linux) arms or disarms one track and leaves the others as they are.
// With arm-on-select on (Transport ▸ Auto-arm selected track, off by default), selecting an
// instrument track arms it the same way, while the arms are still the one the selection picked.
+// A linked group (specs/076) arms as one track: arming or disarming a member does the same to
+// every member of its link set, unless the click bypasses the link (⌥-click).
+using System.Collections.Generic;
using Nota.Application;
+using Nota.Application.Editing;
namespace Nota.Presentation;
public static class TrackArm
{
- /// <summary>Arms or disarms <paramref name="trackId"/>. Arming without
- /// <paramref name="additive"/> disarms every other track first — except while recording,
- /// where disarming would end another track's take. Returns true when other tracks changed.</summary>
- public static bool Set(IAudioEngine engine, int trackId, bool on, bool additive)
+ /// <summary>Arms or disarms <paramref name="trackId"/> — and, when <paramref name="linked"/>,
+ /// the other members of its link set. Arming without <paramref name="additive"/> disarms every
+ /// track outside the set first — except while recording, where disarming would end another
+ /// track's take. Returns true when tracks other than <paramref name="trackId"/> changed.</summary>
+ public static bool Set(IAudioEngine engine, int trackId, bool on, bool additive, bool linked = true)
{
+ var set = new HashSet<int> { trackId };
+ if (linked) foreach (var m in Links(engine).Members(trackId)) set.Add(m);
bool others = false;
- if (on && !additive && !engine.IsRecording)
- for (int i = 0; i < engine.TrackCount; i++)
- if (engine.TryGetTrackInfo(i, out var t) && t.Id != trackId && t.Armed != 0)
- {
- engine.SetTrackArmed(t.Id, false);
- others = true;
- }
+ for (int i = 0; i < engine.TrackCount; i++)
+ {
+ if (!engine.TryGetTrackInfo(i, out var t) || t.Id == trackId) continue;
+ if (set.Contains(t.Id))
+ {
+ if ((t.Armed != 0) != on) { engine.SetTrackArmed(t.Id, on); others = true; }
+ }
+ else if (on && !additive && !engine.IsRecording && t.Armed != 0)
+ {
+ engine.SetTrackArmed(t.Id, false);
+ others = true;
+ }
+ }
engine.SetTrackArmed(trackId, on);
return others;
}
@@ -33,12 +46,14 @@ public static class TrackArm
/// <summary>Arm-on-select: selecting an instrument track arms it alone, so the keyboard
/// plays the track you're on. The arms are left as they are while recording, when the
/// track is already armed, and when they're a set built by hand — several tracks, or an
- /// audio track. Returns true when any arm changed.</summary>
+ /// audio track. A linked set counts as one track. Returns true when any arm changed.</summary>
public static bool FollowSelection(IAudioEngine engine, int trackId)
{
if (engine.IsRecording) return false;
+ var links = Links(engine);
+ var own = new HashSet<int>(links.Members(trackId)) { trackId };
bool isInstrument = false;
- int armedOthers = 0;
+ var armedOthers = new HashSet<int>(); // link roots (or track ids) of armed tracks outside the set
for (int i = 0; i < engine.TrackCount; i++)
{
if (!engine.TryGetTrackInfo(i, out var t)) continue;
@@ -48,14 +63,30 @@ public static class TrackArm
if (t.Armed != 0) return false;
isInstrument = inst;
}
+ else if (own.Contains(t.Id)) continue;
else if (t.Armed != 0)
{
if (!inst) return false;
- armedOthers++;
+ int root = links.RootOf(t.Id);
+ armedOthers.Add(root >= 0 ? -root : t.Id); // a linked set is one track
}
}
- if (!isInstrument || armedOthers > 1) return false;
+ if (!isInstrument || armedOthers.Count > 1) return false;
Set(engine, trackId, true, additive: false);
return true;
}
+
+ /// <summary>The link sets as the engine has them now.</summary>
+ public static GroupLink Links(IAudioEngine engine)
+ {
+ var tracks = new List<LinkTrack>(engine.TrackCount);
+ bool anyGroup = false;
+ for (int i = 0; i < engine.TrackCount; i++)
+ if (engine.TryGetTrackInfo(i, out var t))
+ {
+ anyGroup |= t.IsGroup;
+ tracks.Add(new LinkTrack(t.Id, t.GroupId, t.IsGroup, t.IsReturn, t.IsGroup && engine.GetTrackEditLink(t.Id)));
+ }
+ return anyGroup ? GroupLink.Build(tracks) : GroupLink.None;
+ }
}
diff --git a/src/native/nota.engine/include/nota/nota_engine.h b/src/native/nota.engine/include/nota/nota_engine.h
index 4e254d93..694d9ea2 100644
--- a/src/native/nota.engine/include/nota/nota_engine.h
+++ b/src/native/nota.engine/include/nota/nota_engine.h
@@ -1490,6 +1490,13 @@ NOTA_API int32_t nota_track_get_color(NotaEngine* engine, int32_t track_id);
never reads it. get returns 1 folded, 0 not, -1 for an unknown track. */
NOTA_API NotaResult nota_track_set_piano_fold(NotaEngine* engine, int32_t track_id, int32_t on);
NOTA_API int32_t nota_track_get_piano_fold(NotaEngine* engine, int32_t track_id);
+/* Group Link (specs/076, #184): a group track's "link its tracks for editing and recording"
+ * flag. Saved with the project, copied with the group, and an undo step when changed; the
+ * audio thread never reads it — the app applies the link to arming and clip edits.
+ * set: NOTA_ERR_INVALID_ARG for an unknown track or one that is not a group.
+ * get: 1 linked, 0 not, -1 unknown track (0 for a track that is not a group). */
+NOTA_API NotaResult nota_track_set_edit_link(NotaEngine* engine, int32_t track_id, int32_t on);
+NOTA_API int32_t nota_track_get_edit_link(NotaEngine* engine, int32_t track_id);
/* Track clipboard: copy stores independent clones (a group brings its children), paste
* appends fresh copies (new ids) top-level. copy_many / paste_after are the multi-track forms:
* paste_after lands the copies after after_track_id inside its group (-1 = top-level at the
diff --git a/src/native/nota.engine/src/abi/nota_engine_track.cpp b/src/native/nota.engine/src/abi/nota_engine_track.cpp
index 730f7541..075ce40b 100644
--- a/src/native/nota.engine/src/abi/nota_engine_track.cpp
+++ b/src/native/nota.engine/src/abi/nota_engine_track.cpp
@@ -683,6 +683,13 @@ NotaResult nota_track_set_piano_fold(NotaEngine* e, int32_t track_id, int32_t on
int32_t nota_track_get_piano_fold(NotaEngine* e, int32_t track_id) {
return e ? CENG(e)->trackPianoFold(track_id) : -1;
}
+NotaResult nota_track_set_edit_link(NotaEngine* e, int32_t track_id, int32_t on) {
+ if (!e) return NOTA_ERR_INVALID_ARG;
+ return ENG(e)->setTrackEditLink(track_id, on != 0) ? NOTA_OK : NOTA_ERR_INVALID_ARG;
+}
+int32_t nota_track_get_edit_link(NotaEngine* e, int32_t track_id) {
+ return e ? CENG(e)->trackEditLink(track_id) : -1;
+}
NotaResult nota_track_copy(NotaEngine* e, int32_t track_id) {
if (!e) return NOTA_ERR_INVALID_ARG;
return ENG(e)->copyTrack(track_id) ? NOTA_OK : NOTA_ERR_INVALID_ARG;
diff --git a/src/native/nota.engine/src/engine/Engine.cpp b/src/native/nota.engine/src/engine/Engine.cpp
index 617d2ecc..7397d525 100644
--- a/src/native/nota.engine/src/engine/Engine.cpp
+++ b/src/native/nota.engine/src/engine/Engine.cpp
@@ -696,6 +696,7 @@ std::shared_ptr<Track> Engine::cloneTrack(const Track& t) const {
nt->name = t.name; // UI metadata
nt->colorIndex = t.colorIndex;
nt->pianoFold = t.pianoFold;
+ nt->editLink = t.editLink;
return nt;
}
diff --git a/src/native/nota.engine/src/engine/Engine.h b/src/native/nota.engine/src/engine/Engine.h
index 0c32948d..1fee532a 100644
--- a/src/native/nota.engine/src/engine/Engine.h
+++ b/src/native/nota.engine/src/engine/Engine.h
@@ -653,6 +653,8 @@ class Engine {
// Piano roll Fold (specs/045): a per-track view flag, saved with the project.
bool setTrackPianoFold(int32_t trackId, bool on);
int32_t trackPianoFold(int32_t trackId) const; // 1 / 0, -1 unknown track
+ bool setTrackEditLink(int32_t trackId, bool on); // group tracks only (specs/076); undoable
+ int32_t trackEditLink(int32_t trackId) const; // 1 / 0, -1 unknown track
// Track clipboard (copy/cut/paste). copyTracks stores fully independent clones of the
// expanded set (a group brings its children); pasteTracks inserts fresh copies (new ids +
diff --git a/src/native/nota.engine/src/engine/Engine_Tracks.cpp b/src/native/nota.engine/src/engine/Engine_Tracks.cpp
index c22160cd..265695f9 100644
--- a/src/native/nota.engine/src/engine/Engine_Tracks.cpp
+++ b/src/native/nota.engine/src/engine/Engine_Tracks.cpp
@@ -3512,6 +3512,19 @@ int32_t Engine::trackPianoFold(int32_t trackId) const {
auto t = findTrackAuthoring(trackId);
return t ? (t->pianoFold ? 1 : 0) : -1;
}
+bool Engine::setTrackEditLink(int32_t trackId, bool on) {
+ auto old = findTrackAuthoring(trackId);
+ if (!old || old->type() != TrackType::Group) return false;
+ if (old->editLink == on) return true; // no change, no undo step
+ auto nt = cloneTrack(*old);
+ nt->editLink = on;
+ republishWithTrack(trackId, nt); // changes what edits do: an undo step (unlike pianoFold)
+ return true;
+}
+int32_t Engine::trackEditLink(int32_t trackId) const {
+ auto t = findTrackAuthoring(trackId);
+ return t ? (t->editLink ? 1 : 0) : -1;
+}
bool Engine::deleteClip(int32_t trackId, int32_t clipIndex) {
auto old = findTrackAuthoring(trackId);
@@ -3555,6 +3568,7 @@ std::shared_ptr<Track> Engine::deepCloneTrack(const Track& src, int32_t newId, b
nt->name = src.name;
nt->colorIndex = src.colorIndex;
nt->pianoFold = src.pianoFold;
+ nt->editLink = src.editLink;
nt->instrument = cloneInstrument(src);
if (nt->instrument && src.instrument) nt->instrument->setBypassed(src.instrument->bypassed());
for (auto& m : src.midiEffects)
diff --git a/src/native/nota.engine/src/engine/Track.h b/src/native/nota.engine/src/engine/Track.h
index ca8292ad..f8da19ec 100644
--- a/src/native/nota.engine/src/engine/Track.h
+++ b/src/native/nota.engine/src/engine/Track.h
@@ -345,6 +345,8 @@ class Track {
std::string name;
int32_t colorIndex = -1;
bool pianoFold = false; // piano roll Fold (specs/045): the editor shows the folded rows
+ bool editLink = false; // group Link (specs/076): the app links the group's tracks for arming
+ // and clip edits; group tracks only, never read by the audio thread
// Stable across snapshots (voice/DSP state must survive structural edits).
std::shared_ptr<Instrument> instrument; // instrument tracks
diff --git a/tests/Nota.SmokeTest/GroupLinkTests.cs b/tests/Nota.SmokeTest/GroupLinkTests.cs
new file mode 100644
index 00000000..608d16f9
--- /dev/null
+++ b/tests/Nota.SmokeTest/GroupLinkTests.cs
@@ -0,0 +1,136 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// Group Link (specs/076, #184): the group flag through the C ABI (undo, copy, save / load),
+// the rule that decides which tracks a linked group ties together and which clips match, and
+// arming a linked group from one arm button.
+
+using Nota.Application;
+using Nota.Application.Editing;
+using Nota.Infrastructure;
+using Nota.Presentation;
+
+namespace Nota.SmokeTest;
+
+internal static class GroupLinkTests
+{
+ public static IEnumerable<(bool, string)> Run()
+ {
+ foreach (var r in Flag()) yield return r;
+ foreach (var r in Persisted()) yield return r;
+ foreach (var r in Sets()) yield return r;
+ foreach (var r in Matching()) yield return r;
+ foreach (var r in LinkedArm()) yield return r;
+ }
+
+ private static IEnumerable<(bool, string)> Flag()
+ {
+ using var e = new NotaEngine();
+ int a = e.AddAudioTrack(), b = e.AddAudioTrack();
+ int g = e.CreateGroup(new[] { a, b });
+ yield return (g > 0 && !e.GetTrackEditLink(g), "a new group starts unlinked");
+ yield return (e.SetTrackEditLink(g, true) && e.GetTrackEditLink(g), "Link turns on on a group");
+ yield return (!e.SetTrackEditLink(a, true) && !e.GetTrackEditLink(a), "Link is refused on an audio track");
+ yield return (!e.SetTrackEditLink(99999, true) && !e.GetTrackEditLink(99999), "Link is refused on an unknown track");
+ // Setting the same value again adds no undo step: one undo turns it off.
+ e.SetTrackEditLink(g, true);
+ yield return (e.Undo() && !e.GetTrackEditLink(g), "Link is one undo step (and a repeat set adds none)");
+ yield return (e.Redo() && e.GetTrackEditLink(g), "redo turns Link back on");
+ int[] copies = e.DuplicateTracks(new[] { g });
+ int copy = copies.FirstOrDefault(id => e.GetTrackEditLink(id));
+ yield return (copy > 0 && copy != g, "a duplicated group keeps its Link");
+ }
+
+ private static IEnumerable<(bool, string)> Persisted()
+ {
+ using var src = new NotaEngine();
+ int a = src.AddAudioTrack(), b = src.AddAudioTrack();
+ int g = src.CreateGroup(new[] { a, b });
+ src.SetTrackEditLink(g, true);
+ var doc = ProjectService.Capture(src, new TransportState(120.0, 1.0, false, false), new List<string>());
+ yield return (doc.Tracks.Count(t => t.EditLink == true) == 1 && doc.Tracks.Count(t => t.EditLink is not null) == 1,
+ "only the linked group writes EditLink");
+ string dir = Path.Combine(Path.GetTempPath(), "nota-smoke-link-" + Guid.NewGuid().ToString("N"));
+ Directory.CreateDirectory(dir);
+ try
+ {
+ using (var dst = new NotaEngine())
+ {
+ ProjectService.Apply(doc, dst, dir);
+ yield return (Groups(dst).Count(dst.GetTrackEditLink) == 1, "Link survives save and load");
+ }
+ foreach (var t in doc.Tracks) t.EditLink = null; // as written before specs/076
+ using (var old = new NotaEngine())
+ {
+ ProjectService.Apply(doc, old, dir);
+ yield return (Groups(old).Count > 0 && !Groups(old).Any(old.GetTrackEditLink), "an older project opens unlinked");
+ }
+ }
+ finally { Directory.Delete(dir, true); }
+ }
+
+ private static List<int> Groups(NotaEngine e)
+ {
+ var ids = new List<int>();
+ for (int i = 0; i < e.TrackCount; i++) if (e.TryGetTrackInfo(i, out var t) && t.IsGroup) ids.Add(t.Id);
+ return ids;
+ }
+
+ private static IEnumerable<(bool, string)> Sets()
+ {
+ // outer(1) ⊃ {A(2), inner(3) ⊃ {B(4), C(5)}}, D(6) top-level, return R(7)
+ LinkTrack[] Tree(bool outer, bool inner) => new[]
+ {
+ new LinkTrack(1, -1, true, false, outer),
+ new LinkTrack(2, 1, false, false, false),
+ new LinkTrack(3, 1, true, false, inner),
+ new LinkTrack(4, 3, false, false, false),
+ new LinkTrack(5, 3, false, false, false),
+ new LinkTrack(6, -1, false, false, false),
+ new LinkTrack(7, -1, false, true, false),
+ };
+ var off = GroupLink.Build(Tree(false, false));
+ yield return (!off.AnyLinked && off.Members(2).Count == 0 && off.RootOf(2) == -1, "unlinked groups link nothing");
+ var outer = GroupLink.Build(Tree(true, false));
+ yield return (outer.Members(2).SequenceEqual(new[] { 4, 5 }) && outer.RootOf(5) == 1,
+ "a linked group links every track below it, nested groups included");
+ yield return (!outer.IsLinked(6) && !outer.IsLinked(7) && outer.Members(1).Count == 0 && outer.Members(3).Count == 0,
+ "tracks outside, returns and group tracks are never members");
+ var inner = GroupLink.Build(Tree(false, true));
+ yield return (inner.Members(4).SequenceEqual(new[] { 5 }) && !inner.IsLinked(2), "a linked inner group links only its own tracks");
+ var both = GroupLink.Build(Tree(true, true));
+ yield return (both.RootOf(4) == 1 && both.Members(4).SequenceEqual(new[] { 2, 5 }), "the outermost linked group wins");
+ yield return (outer.ExpandTracks(new[] { 4, 6 }).SequenceEqual(new[] { 4, 6, 2, 5 }), "a range widens to whole link sets");
+ }
+
+ private static IEnumerable<(bool, string)> Matching()
+ {
+ yield return (GroupLink.Matches(4, 8, 4, 8), "clips at the same place match");
+ yield return (GroupLink.Matches(4, 8, 4 + 1.0 / 512, 8), "a hair's difference still matches");
+ yield return (!GroupLink.Matches(4, 8, 4 + 1.0 / 128, 8 - 1.0 / 128), "a 128th apart does not match");
+ yield return (!GroupLink.Matches(4, 8, 4, 6), "the same start but another end does not match");
+ }
+
+ private static IEnumerable<(bool, string)> LinkedArm()
+ {
+ using var e = new NotaEngine();
+ int a = e.AddAudioTrack(), b = e.AddAudioTrack(), c = e.AddAudioTrack();
+ int g = e.CreateGroup(new[] { a, b });
+ bool Armed(int id) { for (int i = 0; i < e.TrackCount; i++) if (e.TryGetTrackInfo(i, out var t) && t.Id == id) return t.Armed != 0; return false; }
+
+ TrackArm.Set(e, a, true, additive: false);
+ yield return (Armed(a) && !Armed(b), "unlinked, an arm click arms that track alone");
+ TrackArm.Set(e, a, false, additive: false);
+
+ e.SetTrackEditLink(g, true);
+ TrackArm.Set(e, c, true, additive: false);
+ bool changed = TrackArm.Set(e, a, true, additive: false);
+ yield return (changed && Armed(a) && Armed(b) && !Armed(c), "a plain arm click arms the linked set and disarms the rest");
+ TrackArm.Set(e, c, true, additive: true);
+ yield return (Armed(a) && Armed(b) && Armed(c), "⌘-click outside the set keeps the set armed");
+ TrackArm.Set(e, b, false, additive: false);
+ yield return (!Armed(a) && !Armed(b) && Armed(c), "disarming one member disarms the set");
+ TrackArm.Set(e, b, true, additive: true, linked: false);
+ yield return (Armed(b) && !Armed(a), "the ⌥ bypass arms one member alone");
+ }
+}
diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.cs
index cf56ce2b..97e18f30 100644
--- a/tests/Nota.SmokeTest/Program.cs
+++ b/tests/Nota.SmokeTest/Program.cs
@@ -710,6 +710,14 @@ if (args.Length >= 1 && args[0] == "--session-input")
Console.WriteLine(failures == 0 ? "SESSION INPUT PASSED" : $"SESSION INPUT FAILED ({failures})");
return failures == 0 ? 0 : 1;
}
+// Group Link alone (fast iteration): `--group-link`. Also part of the full run.
+if (args.Length >= 1 && args[0] == "--group-link")
+{
+ Console.WriteLine("-- group link --");
+ foreach (var (ok, label) in GroupLinkTests.Run()) Check(ok, label);
+ Console.WriteLine(failures == 0 ? "GROUP LINK PASSED" : $"GROUP LINK FAILED ({failures})");
+ return failures == 0 ? 0 : 1;
+}
// Live MIDI recording alone (fast iteration): `--live-record`. Also part of the full run.
if (args.Length >= 1 && args[0] == "--live-record")
{
@@ -15419,6 +15427,8 @@ Console.WriteLine("-- take lanes --");
foreach (var (ok, label) in TakeLaneTests.Run()) Check(ok, label);
Console.WriteLine("-- session launch + record input --");
foreach (var (ok, label) in SessionInputTests.Run()) Check(ok, label);
+Console.WriteLine("-- group link --");
+foreach (var (ok, label) in GroupLinkTests.Run()) Check(ok, label);
Console.WriteLine("-- tempo follow --");
foreach (var (ok, label) in TempoFollowTests.Run()) Check(ok, label);
Console.WriteLine("-- nota keys --");