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.

(fix) Session clips open in the Clip editor (#334) (#402)

Chris Laupama04727019be3f
diff --git a/.specify/bugs/session-clip-editor/assessment.md b/.specify/bugs/session-clip-editor/assessment.md
new file mode 100644
index 00000000..b97edbee
--- /dev/null
+++ b/.specify/bugs/session-clip-editor/assessment.md
@@ -0,0 +1,95 @@
+# Bug Assessment: Session clip editor — Clip tab, selection follow, playhead (#334)
+
+- **Slug**: session-clip-editor
+- **Created**: 2026-10-30
+- **Source**: https://github.com/nota-daw/nota/issues/334 (host `github.com`, allowlisted)
+- **Verdict**: valid (items 1–4); items 5–9 are feature requests that need product decisions
+- **Severity**: medium — the Session clip editor can only be reached through a context menu
+
+## Report (summarized)
+
+"Clip edit bugs", macOS (Apple silicon), Nota 0.57.1. The reporter was working in Session view:
+
+1. Clicking a clip in Session should switch the detail panel to the Clip editor, not Devices.
+2. The **Clip** button of the Devices | Clip switch does nothing; the only way into the editor is
+ right-click ▸ Edit.
+3. With the clip editor open, selecting another clip in Session should bring that clip into view.
+4. The playback marker doesn't show in the clip editor while the clip plays.
+5. MIDI clip inspector: Start / Length, the Loop switch don't work; there are no loop in/out
+ points (they should show even with Loop off) and no clip start/end points.
+6. Notes / Envelopes switch does nothing.
+7. Audio clips: show left and right waveforms stacked, or at least a toggle (the reporter likes
+ the single combined view).
+8. Audio clips have no loop on/off and no loop points.
+9. The Texture warp mode lacks its two extra parameters.
+
+## Symptom
+
+In Session view a single click on a slot selects its track and hands the detail panel to
+Devices; the Clip tab is disabled at that point, so neither the click nor the tab opens the clip.
+
+## Reproduction
+
+1. Session view, a MIDI track with a filled slot.
+2. Click the slot → the detail panel shows Devices, the Clip tab is greyed.
+3. Click Clip → nothing.
+4. Right-click ▸ Edit opens the piano roll. Click another filled slot → the panel drops back to
+ Devices (another track) or stays on the old clip (same track).
+
+## Suspected Code Paths
+
+- `src/managed/Nota.App/MainWindow.axaml.cs` — `SlotSelected` only calls `Timeline.Select`.
+- `src/managed/Nota.App/SessionView.cs:Select` — `SlotSelected` fires only when the *track*
+ changes, so a slot on the same track is never followed.
+- `src/managed/Nota.App/MainWindow.Detail.cs:OnTrackSelected` — a Session MIDI editor keeps
+ `_editorTrackId = -1`, so every slot selection calls `ResetClipEditor()`; `keepClipTab` looks
+ only at the arrangement selection, so Session always takes the panel over to Devices.
+- `MainWindow.Detail.cs:SyncClipTab` / `OnDetailClip` — in Session the Clip tab is enabled only
+ while an editor is open, which the reset above just cleared.
+- Playhead (item 4): the tick in `MainWindow.axaml.cs` follows `SessionSlotPlayhead` for the open
+ slot; it reads `_sessionSlotTrack/_sessionSlotScene`, which `ResetClipEditor()` clears.
+
+## Root Cause Hypothesis
+
+Session slot selection was wired as "select the track" only, and the track-selection path assumes
+the arrangement (clip identity in `_editorTrackId`, clip selection in the timeline). Confidence: high
+for items 1–3; medium for item 4 (needs a run to confirm what clears the slot identity).
+
+## Proposed Remediation
+
+**Preferred**: Route Session slot selection through its own handler. A filled slot opens (or
+re-shows) its editor in the Clip tab — MIDI roll or audio editor — then selects the track; an empty
+slot keeps today's "select the track, show Devices". Fire `SlotSelected` on any slot change. Teach
+`OnTrackSelected` that a Session editor on the selected track is the clip to keep. Enable the Clip
+tab when the selected slot holds a clip, and let it open that slot.
+
+**Files likely to change**: `MainWindow.Detail.cs`, `MainWindow.axaml.cs`, `MainWindow.axaml`
+(tab tooltip), `SessionView.cs`.
+
+**Tests**: the wiring lives in `MainWindow` (not linked into the smoke test); verify by running
+the app (before/after screenshots). Smoke test must stay green.
+
+## Risks & Considerations
+
+- A Drum Rack user on the Pattern tab should stay on Pattern when the selection moves.
+- The floating Devices/Clip window must keep its clip pane in step.
+
+## Open Questions (items 5–9 — product decisions, not wiring bugs)
+
+- [NEEDS CLARIFICATION: Clip loop model (items 5 and 8). Today a clip plays its whole length on
+ repeat ("Clips always loop" in `ClipPropsView`); the engine has no per-clip loop region or
+ start/end markers (`MidiClip.lengthBeats` only; Session slots have a Loop flag and a length).
+ Should Nota adopt separate clip Start/End markers plus a Loop region (Loop start, Loop length,
+ Loop on/off) for MIDI and audio clips, Arrangement and Session alike? If so, in the Arrangement
+ is "Start" the clip's position on the timeline (as now) or the start marker inside the clip, and
+ what plays with Loop off when the clip is longer than its end marker — silence?]
+- [NEEDS CLARIFICATION: Session slot envelopes (item 6). Clip envelopes (Velocity / Volume) exist
+ only for Arrangement MIDI clips; the switch is deliberately inactive for Session slots. Add
+ envelopes to Session slots (engine + project file), or hide the switch there?]
+- [NEEDS CLARIFICATION: Stereo waveform (item 7). Peaks are one mono min/max series. A split
+ L/R view needs per-channel peaks in the ABI. Default view (combined, per the reporter), and
+ should the toggle be per clip, per editor or an app preference (like the arrangement's
+ Waveform style)?]
+- [NEEDS CLARIFICATION: Texture warp (item 9). Texture uses a fixed 220 ms window / 55 ms hop
+ (`WarpStream.cpp`). The two parameters are presumably Grain Size and Flux — confirm, with
+ ranges and defaults, and whether existing projects keep today's sound at the default.]
diff --git a/.specify/bugs/session-clip-editor/fix.md b/.specify/bugs/session-clip-editor/fix.md
new file mode 100644
index 00000000..ea693e4e
--- /dev/null
+++ b/.specify/bugs/session-clip-editor/fix.md
@@ -0,0 +1,48 @@
+# Bug Fix: Session clip editor — Clip tab, selection follow, playhead (#334)
+
+- **Slug**: session-clip-editor
+- **Fixed**: 2026-10-30
+- **Assessment**: ./assessment.md
+- **Status**: partial
+
+## Summary
+
+A Session slot that holds a clip now opens in the Clip tab on click, the Clip button opens the
+selected slot, and the open editor follows the selection onto another clip. The playhead was
+already drawn for the open slot; clicking a slot used to drop that editor, so the marker went
+with it.
+
+## Changes
+
+| File | Change | Notes |
+|------|--------|-------|
+| `src/managed/Nota.App/SessionView.cs` | modified | `SlotSelected` fires when the slot changes, not only the track |
+| `src/managed/Nota.App/MainWindow.axaml.cs` | modified | slot selection goes to `OnSessionSlotSelected` |
+| `src/managed/Nota.App/MainWindow.Detail.cs` | modified | open / follow the slot; keep a Session editor across its own track's selection |
+| `src/managed/Nota.App/MainWindow.axaml` | modified | Clip tab tooltip covers audio clips |
+| `CHANGELOG.md` | modified | Unreleased fixed entry |
+
+## Tests Added or Updated
+
+- None in the smoke suite. The wiring lives on `MainWindow`, which the smoke test does not link.
+ Checked by running the app (see `test.md`).
+
+## Local Verification
+
+- `scripts/build-linux.sh` on unmodified `develop`, then `dotnet build` of `Nota.App` and
+ `dotnet run --project tests/Nota.SmokeTest` on this branch. The only failure in both runs is
+ the render-pool "late blocks" guard; this change does not touch the engine. `--perf` rerun
+ recorded in `test.md`.
+- App, Linux, PulseAudio null sink: click, Clip button, same-track and other-track follow,
+ playhead while a slot plays (editor open before and after launch).
+
+## Deviations from Assessment
+
+Items 5–9 of the report (loop markers, Session envelopes, split stereo waveform, Texture warp
+parameters) are not in this change. Each needs a product decision and, for most, an engine
+change. They stay open on the issue.
+
+## Follow-ups
+
+- Loop region, Session envelopes, per-channel peaks, Texture parameters — blocked on the
+ questions in `assessment.md`.
diff --git a/.specify/bugs/session-clip-editor/test.md b/.specify/bugs/session-clip-editor/test.md
new file mode 100644
index 00000000..072e7146
--- /dev/null
+++ b/.specify/bugs/session-clip-editor/test.md
@@ -0,0 +1,51 @@
+# Bug Verification: Session clip editor — Clip tab, selection follow, playhead (#334)
+
+- **Slug**: session-clip-editor
+- **Tested**: 2026-10-30
+- **Assessment**: ./assessment.md
+- **Fix**: ./fix.md
+- **Result**: partial
+
+## Summary
+
+Items 1–4 no longer reproduce on Linux: a click opens the slot in the Clip tab, the Clip
+button does the same, the editor follows another clip, and the playhead moves while that
+slot plays. Items 5–9 were not changed.
+
+## Checks Performed
+
+| Check | Command / Action | Result | Notes |
+|-------|------------------|--------|-------|
+| Click a filled slot | App, Session, single click on the slot body | pass | Detail panel shows the piano roll; before, it stayed on Devices |
+| Clip button | Click Clip with a filled slot selected | pass | Opens that slot. Before, it stayed on Devices |
+| Another slot, same track | Click scene 2 while scene 1's editor is open | pass | Header and notes follow |
+| Another track | Click a filled slot on a second instrument | pass | Header changes to that track |
+| Playhead, editor already open | Launch the slot (PulseAudio null sink) | pass | Accent line moves across the roll |
+| Playhead, open while playing | Launch, then click the slot | pass | Line is at the slot position immediately |
+| Empty slot, other track | Click the centre of an empty slot | pass (unchanged) | Centre click is the record/stop target and does not move the selection, so the editor stays. Selecting an empty slot still shows Devices |
+| Smoke test | `dotnet run --project tests/Nota.SmokeTest -c Release` | fail (pre-existing) | One render-pool timing guard, same failure on unmodified develop |
+| `--perf` alone | `Nota.SmokeTest.dll --perf` | pass | Same engine as develop (no native change). The full-run failure above does not reproduce on its own |
+
+## Output Excerpts
+
+Develop (`scripts/build-linux.sh`) and this branch (smoke test) both end with:
+
+```
+[FAIL] overloaded: at most N late blocks within 50 ms (<= 4: no bursts when the pool re-checks the load)
+SMOKE TEST FAILED (1)
+```
+
+N was 9 on develop and 5 on this branch, both while the machine was busy. No other check failed.
+Alone, `Nota.SmokeTest.dll --perf` printed `PERF PASSED`.
+
+## Residual Risks
+
+- macOS and Windows were not run here. CI covers them.
+- A Drum Rack Pattern grid was not exercised in the GUI pass; the code keeps Pattern when the
+ panel is already on it and the new slot is a Drum Rack clip.
+- Items 5–9 remain.
+
+## Recommendation
+
+Do not close #334. The Session navigation and playhead items are fixed; the loop, envelope,
+waveform and Texture items are waiting on product decisions.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c2b76b8d..7143ec4c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -97,6 +97,10 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
returns, then the master.
### Fixed
+- **Session clips open in the Clip editor** (#334): a click on a slot that holds a clip shows
+ that clip in the Clip tab instead of the track's devices, the **Clip** button opens the
+ selected slot, and with the editor open, clicking another clip — on the same track or
+ another — brings that clip into the editor. Selecting an empty slot still shows that track's devices.
- **View ▸ Toggle detail panel** no longer leaves an empty band where the hidden panel was;
showing it again brings back its height.
diff --git a/src/managed/Nota.App/MainWindow.Detail.cs b/src/managed/Nota.App/MainWindow.Detail.cs
index 2f7af2b7..039acbb7 100644
--- a/src/managed/Nota.App/MainWindow.Detail.cs
+++ b/src/managed/Nota.App/MainWindow.Detail.cs
@@ -158,16 +158,18 @@ public partial class MainWindow
// Switching to a different track abandons the previously edited clip. Reset the clip
// editor to empty so a stale editor from the old track doesn't linger — most visible
// in the popped-out Devices/Clip window, whose top pane isn't touched by ShowDevices.
- if (_editorTrackId != trackId && _audioEditorTrackId != trackId)
+ bool session = _session?.IsVisible == true;
+ if (_editorTrackId != trackId && _audioEditorTrackId != trackId && !(session && _sessionSlotTrack == trackId))
ResetClipEditor();
// Selecting a clip in the arrangement also selects its track — including the select
// that an edge-drag does before it trims. That must not pull a user who is working in
// the Clip tab over to Devices, so refresh the chain underneath and re-point the Clip
// tab at the newly selected clip. With no clip to show, Devices takes the panel as before.
+ // In Session the clip is the slot the editor already holds (OnSessionSlotSelected).
bool keepClipTab = !DetailFloating && DetailPanel.IsVisible
&& DetailBody.Content is ClipEditorView or AudioClipEditorView or DrumPatternView
- && SelectedClip(out _, out _, out _);
+ && (session ? SessionEditorTrack == trackId : SelectedClip(out _, out _, out _));
bool wasPattern = keepClipTab && DetailBody.Content is DrumPatternView;
ShowDevices(trackId, takeOverPanel: !keepClipTab);
@@ -212,13 +214,58 @@ public partial class MainWindow
return false;
}
+ // The Session slot selected in the grid, when it holds a clip.
+ private bool SelectedSessionClip(out int trackId, out int scene)
+ {
+ (trackId, scene) = _session?.SelectedSlot ?? (-1, -1);
+ return trackId > 0 && scene >= 0 && Engine.SessionSlotState(trackId, scene) != 0;
+ }
+
+ // The track of the Session slot whose editor the Clip / Pattern tab last showed, or -1.
+ private int SessionEditorTrack =>
+ _lastClipEditor is null ? -1
+ : ReferenceEquals(_lastClipEditor, _audioEditor) ? (SessionAudioEditorOpen ? _audioEditorTrackId : -1)
+ : ReferenceEquals(_lastClipEditor, _clipEditor) && _editorTrackId < 0 ? _sessionSlotTrack
+ : ReferenceEquals(_lastClipEditor, _patternView) && _patternScene >= 0 ? _patternTrackId
+ : -1;
+
+ // A Session MIDI roll keeps _editorTrackId at -1; an arrangement one sets it.
+ private bool SessionMidiEditorOpen(int trackId, int scene)
+ => _clipEditor is not null && _editorTrackId < 0 && _sessionSlotTrack == trackId && _sessionSlotScene == scene;
+
+ private bool SessionAudioEditorOn(int trackId, int scene)
+ => SessionAudioEditorOpen && _audioEditorTrackId == trackId && _audioEditorClipIndex == SessionClip.Index(scene);
+
+ // Selecting a Session slot selects its track everywhere (devices below, the arrangement
+ // header); a slot holding a clip opens it in the Clip tab, and the tab follows the
+ // selection from clip to clip (#334). A Pattern grid stays a Pattern grid on a Drum Rack.
+ private void OnSessionSlotSelected(int trackId, int scene)
+ {
+ if (scene >= 0 && Engine.SessionSlotState(trackId, scene) != 0)
+ {
+ bool pattern = !DetailFloating && DetailPanel.IsVisible && DetailBody.Content is DrumPatternView;
+ ShowSessionSlot(trackId, scene);
+ if (Timeline.SelectedTrackId != trackId) Timeline.Select(trackId, -1);
+ if (pattern && DetailPatternBtn.IsEnabled) OnDetailPattern(this, new RoutedEventArgs());
+ }
+ else if (Timeline.SelectedTrackId != trackId)
+ Timeline.Select(trackId, -1);
+ }
+
+ private void ShowSessionSlot(int trackId, int scene)
+ {
+ if (SessionAudioEditorOn(trackId, scene)) ShowAudioClipPanel();
+ else if (SessionMidiEditorOpen(trackId, scene)) ShowClipPanel();
+ else OpenSessionClipEditor(trackId, scene);
+ }
+
// Enable the Clip tab for the current context: in the arrangement, whenever a
- // clip is selected; in Session, when a slot editor has been opened. The Pattern tab
- // rides along on the same target, narrowed to Drum Rack MIDI.
+ // clip is selected; in Session, when a filled slot is selected or a slot editor is open.
+ // The Pattern tab rides along on the same target, narrowed to Drum Rack MIDI.
internal void SyncClipTab()
{
DetailClipBtn.IsEnabled = _session?.IsVisible == true
- ? _clipEditor is not null || SessionAudioEditorOpen
+ ? _clipEditor is not null || SessionAudioEditorOpen || SelectedSessionClip(out _, out _)
: SelectedClip(out _, out _, out _);
DetailPatternBtn.IsEnabled = PatternTarget(out _, out _, out _);
// Pattern only means something on a Drum Rack track, so elsewhere the tab is hidden
@@ -759,7 +806,7 @@ public partial class MainWindow
{
_lastClipEditor = _clipEditor;
SetHost(ClipDetailHost, _clipEditor);
- SetDetailChip(_editorTrackId);
+ SetDetailChip(EditedTrack()); // a Session roll keeps _editorTrackId at -1
if (DetailFloating) return; // floating: top pane only
DetailClipBtn.IsEnabled = true;
DetailClipBtn.IsChecked = true;
@@ -974,13 +1021,14 @@ public partial class MainWindow
private void OnDetailClip(object? sender, RoutedEventArgs e)
{
- // Session: show the opened slot editor. Arrangement: always target the
- // currently selected clip, rebuilding if the selection moved tracks.
+ // Session: the selected slot's clip, else the slot editor already open. Arrangement:
+ // always target the currently selected clip, rebuilding if the selection moved tracks.
if (_session?.IsVisible == true)
{
- if (_clipEditor is not null) ShowClipPanel();
+ if (SelectedSessionClip(out int st, out int ss)) ShowSessionSlot(st, ss);
+ else if (_clipEditor is not null) ShowClipPanel();
else if (SessionAudioEditorOpen) ShowAudioClipPanel();
- else RejectClipTab("Double-click a slot to edit it.");
+ else RejectClipTab("Select a clip to edit it.");
return;
}
if (!SelectedClip(out int tid, out int ci, out bool isMidi))
diff --git a/src/managed/Nota.App/MainWindow.axaml b/src/managed/Nota.App/MainWindow.axaml
index 8e02faa7..ba577d8b 100644
--- a/src/managed/Nota.App/MainWindow.axaml
+++ b/src/managed/Nota.App/MainWindow.axaml
@@ -541,7 +541,7 @@
ToolTip.Tip="Step the selected MIDI clip on a Drum Rack track"
Click="OnDetailPattern"/>
<ToggleButton x:Name="DetailClipBtn" Classes="seg" Content="Clip" IsEnabled="False"
- ToolTip.Tip="Select a MIDI clip to edit it" Click="OnDetailClip"/>
+ ToolTip.Tip="Select a clip to edit it" Click="OnDetailClip"/>
</StackPanel>
</Border>
<ContentControl x:Name="DetailChipHost" Grid.Column="1" Margin="14,0,0,0" VerticalAlignment="Center"/>
diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.cs
index d16160fe..84e80237 100644
--- a/src/managed/Nota.App/MainWindow.axaml.cs
+++ b/src/managed/Nota.App/MainWindow.axaml.cs
@@ -457,8 +457,7 @@ public partial class MainWindow : Window
else AddTrack(kind, anchor);
};
HookRecentInstruments(); // "Add track ▸ Recent" in both views' menus
- // Selecting a slot selects its track everywhere: devices below, arrangement header.
- _session.SlotSelected += (trackId, _) => Timeline.Select(trackId, -1);
+ _session.SlotSelected += OnSessionSlotSelected;
Timeline.SessionChanged += () => _session?.Refresh(); // M5-6
MainContent.Children.Add(_session);
diff --git a/src/managed/Nota.App/SessionView.Grid.cs b/src/managed/Nota.App/SessionView.Grid.cs
index bad5b21e..d4becbea 100644
--- a/src/managed/Nota.App/SessionView.Grid.cs
+++ b/src/managed/Nota.App/SessionView.Grid.cs
@@ -455,7 +455,7 @@ public sealed partial class SessionView
return;
}
- _o.Select(new Selection(SelKind.Slot, _c.TrackId, _scene));
+ _o.Select(new Selection(SelKind.Slot, _c.TrackId, _scene), renotify: _filled && e.ClickCount == 1);
if (e.ClickCount == 2)
{
if (_filled) _o.SlotEditRequested?.Invoke(_c.TrackId, _scene);
diff --git a/src/managed/Nota.App/SessionView.cs b/src/managed/Nota.App/SessionView.cs
index 76143ae1..100fefc5 100644
--- a/src/managed/Nota.App/SessionView.cs
+++ b/src/managed/Nota.App/SessionView.cs
@@ -83,7 +83,7 @@ public sealed partial class SessionView : UserControl
/// <summary>Raised to edit a filled slot's notes / audio (trackId, scene).</summary>
public event Action<int, int>? SlotEditRequested;
- /// <summary>Raised when the selection lands on a track's slot, or on a Return / Master column
+ /// <summary>Raised when the selection lands on another slot, or on a Return / Master column
/// (trackId, scene).</summary>
public event Action<int, int>? SlotSelected;
/// <summary>Raised after slots are copied / moved into the arrangement (M5-6) or a track is renamed.</summary>
@@ -356,14 +356,16 @@ public sealed partial class SessionView : UserControl
// ---- selection + commands -----------------------------------------------------
- private void Select(Selection sel)
+ // renotify: a click on the slot that is already selected still raises SlotSelected, so a
+ // filled slot can reopen its clip after the detail panel moved to Devices (#334).
+ private void Select(Selection sel, bool renotify = false)
{
var prev = _sel;
_sel = sel;
InvalidateAll();
RebuildInspector();
bool selectable = sel.Kind == SelKind.Slot ? ColumnFor(sel.TrackId) is not null : sel.Kind == SelKind.Bus && BusColumn(sel.TrackId) is not null;
- if (selectable && (prev.Kind != sel.Kind || prev.TrackId != sel.TrackId))
+ if (selectable && (prev != sel || renotify))
SlotSelected?.Invoke(sel.TrackId, sel.Scene);
}