Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.
C# audioaudio-unitavaloniacpp20cross-platformdawdigital-audio-workstationdspjucelinux-audiomcp-servermidimusicmusic-productionpiano-rollplugin-hostsequencersynthesizervstvst3
(fix) Playback no longer stutters while an audio clip is open in the Clip panel (#142) (#398)
Chris Laupama40b324d8d0e4
diff --git a/.specify/bugs/audio-editor-playhead-redraw/assessment.md b/.specify/bugs/audio-editor-playhead-redraw/assessment.mdnew file mode 100644index 00000000..cee31c8b--- /dev/null+++ b/.specify/bugs/audio-editor-playhead-redraw/assessment.md@@ -0,0 +1,100 @@+# Bug Assessment: playback stutters once the playhead reaches an audio clip++- **Slug**: audio-editor-playhead-redraw+- **Created**: 2026-10-30+- **Source**: https://github.com/nota-daw/nota/issues/142 (host `github.com`, allowlisted)+- **Verdict**: valid+- **Severity**: medium++## Report (verbatim or summarized)++> **Windows: FPS drops and the playhead stutters when it reaches a looped audio clip**+>+> An audio clip on a track with loop enabled on the clip. As soon as the playhead reaches the+> clip, the UI frame rate drops sharply and the playhead moves in jerks.+>+> 1. Arrangement, an audio track with an audio clip+> 2. Turn on Loop for the clip and extend it over several repeats+> 3. Play from before the clip — when the playhead enters it, the UI stutters+>+> Nota 0.55.1, Windows 11 x64. Suspect the looped waveform being redrawn (or re-computed)+> every frame during playback.++No comments on the issue.++## Symptom++During playback the UI frame rate drops, and the playhead moves in jerks, from the moment the+playhead enters an audio clip. Expected: playing through an audio clip costs the UI no more+than playing through empty bars.++## Reproduction++1. Arrangement, an audio track with an audio clip (a long one makes it worse).+2. Open the clip in the Clip panel: double-click it, or select it and press the Clip tab.+3. Play from before the clip. Once the playhead enters the clip, the UI stutters.++Arrangement audio clips have no per-clip Loop switch, in 0.55.1 or now. The only clip+"Loop" switch is a disabled placeholder in the MIDI clip inspector (`ClipPropsView`); the+clip menu's "Loop selection" sets the transport loop to the clip. Looking for the switch+opens the clip in the Clip panel, which is the condition that triggers the bug.+[NEEDS CLARIFICATION: whether the reporter's Clip panel was open — very likely, see above.]++## Suspected Code Paths++- `src/managed/Nota.App/MainWindow.axaml.cs` (`PlayheadUpdated` handler): every UI tick+ (~30 Hz) calls `_audioEditor.OnPlayhead(beats, playing)` while the editor is visible.+- `src/managed/Nota.App/AudioClipEditorView.cs` `OnPlayhead`: −1 outside the clip; inside it,+ a fraction that changes every tick.+- `AudioClipEditorView.WaveformView.SetPlayhead`: any change calls `InvalidateVisual()` on+ the whole waveform view.+- `AudioClipEditorView.WaveformView.Render`: repaints everything — background, ruler with+ formatted labels, snap grid, a `FillRectangle` per visible peak bucket (one per pixel+ column or more), warp markers and BPM chips, envelope, ADSR — just to move the 1px line+ drawn at the end.++Not the cause, but checked: the arrangement lanes don't repaint on a tick (the playhead lives+on `LaneOverlayControl`, #55) unless Follow scrolls the view, and that doesn't depend on+reaching a clip. The piano roll's `SetPlayhead` repaints only its grid and ruler.++## Root Cause Hypothesis++The audio clip editor draws its playhead inside the same `Render` as everything else. Outside+the clip `SetPlayhead(-1)` is a no-op, so nothing repaints. From the moment the playhead+enters the open clip, every transport tick invalidates and fully re-renders the editor. Its+`Render` emits thousands of draw operations and allocates `FormattedText` for the ruler.+That load, on the UI thread at 30 Hz, starves the rest of the window, so it starts exactly when+the playhead "reaches the clip". Confidence: high for the mechanism; medium that it is the+reporter's only trigger (not reproduced on Windows).++## Proposed Remediation++**Preferred**: move the playhead line onto its own hit-transparent layer stacked over the+waveform view (the arrangement's `LaneOverlayControl` pattern). `SetPlayhead` invalidates only+the layer. Every existing full repaint of the view (zoom, scroll, edits, region changes) also+invalidates the layer, so the line can never lag the content it sits on.++**Alternatives**:+- Cache the waveform into a bitmap and blit it each tick. Same effect, but needs dirty+ tracking for every input of `Render` and holds a bitmap per editor.+- Throttle the editor's playhead to a lower rate. Hides the cost and makes the cursor choppy.++**Files likely to change**:+- `src/managed/Nota.App/AudioClipEditorView.cs`+- `CHANGELOG.md`++**Tests to add or update**:+- No UI test harness exists (the smoke test drives the engine through the C ABI). Verify by+ hand: playback through an open audio clip before/after (UI-thread CPU), and the playhead+ line still tracks zoom, scroll, reverse and trim; ruler / playhead-line scrubbing still seeks.++## Risks & Considerations++- The layer must be repainted whenever the line's position inputs change (zoom, scroll,+ placement, region, reverse, size). Routing every existing invalidation of the view through+ one `Redraw()` that also invalidates the layer covers them; a resize re-renders both.+- UI-thread only; no engine or audio-thread change.++## Open Questions++- Was the Clip panel open in the report? The fix only changes behaviour when it is.diff --git a/.specify/bugs/audio-editor-playhead-redraw/fix.md b/.specify/bugs/audio-editor-playhead-redraw/fix.mdnew file mode 100644index 00000000..d24483a2--- /dev/null+++ b/.specify/bugs/audio-editor-playhead-redraw/fix.md@@ -0,0 +1,50 @@+# Bug Fix: playback stutters once the playhead reaches an audio clip++- **Slug**: audio-editor-playhead-redraw+- **Fixed**: 2026-10-30+- **Assessment**: ./assessment.md+- **Status**: applied++## Summary++The audio clip editor's playhead line now lives on its own hit-transparent layer stacked+over the waveform view. A transport tick repaints only that layer, not the whole editor.+Every existing full repaint of the waveform view also repaints the layer, so the line follows+zoom, scroll, trims, reverse and resizes as before.++## Changes++| File | Change | Notes |+|------|--------|-------|+| `src/managed/Nota.App/AudioClipEditorView.cs` | modified | `WaveformView.PlayheadLayer` (nested `PlayheadOverlay`), `Redraw()` replaces the view's `InvalidateVisual()` calls, `SetPlayhead` invalidates only the layer, the line moved out of `Render`; the host adds the layer between the view and the BPM-box canvas |+| `CHANGELOG.md` | modified | `Fixed` entry under `[Unreleased]` |++The layer follows the arrangement's `LaneOverlayControl` (#55): the moving decoration is+drawn by a separate control, so a tick doesn't re-record the expensive surface underneath.+The piano roll already does the same thing in a different way (`PianoRollView.SetPlayhead`+repaints only its grid and ruler).++## Tests Added or Updated++- None automated. The smoke test has no UI harness and doesn't compile+ `AudioClipEditorView.cs`, and the engine is untouched, so a `RenderPoolTests` guard+ couldn't fail on the old code (the maintainer agreed to skip it for this fix). The+ before/after benchmark is a UI render count instead (see `test.md`).++## Local Verification++- Ubuntu 24.04 x64 (Xvfb), .NET SDK 10, GCC 13:+ - `scripts/build-linux.sh`: the build is clean, and the smoke test passes apart from the two+ render-pool timing checks, which are flaky on this 4-core VM (see `test.md`).+- Benchmark and manual checks are in `test.md`.++## Deviations from Assessment++- None.++## Follow-ups++- With Follow on, the arrangement lanes repaint every tick while the view scrolls, and+ `EnsureDetailPeaks` re-fetches the visible slice's peaks each time the slice shifts by more+ than half a pixel. That cost doesn't depend on reaching a clip, so it isn't this bug, but+ it's worth measuring on Windows.diff --git a/.specify/bugs/audio-editor-playhead-redraw/test.md b/.specify/bugs/audio-editor-playhead-redraw/test.mdnew file mode 100644index 00000000..9a9fdb6b--- /dev/null+++ b/.specify/bugs/audio-editor-playhead-redraw/test.md@@ -0,0 +1,51 @@+# Bug Verification: playback stutters while an audio clip is open in the Clip panel++- **Slug**: audio-editor-playhead-redraw+- **Tested**: 2026-10-30+- **Assessment**: ./assessment.md+- **Fix**: ./fix.md+- **Result**: verified on Linux; not tested on Windows++## Summary++With the fix, playing through a clip that's open in the Clip panel no longer repaints the+audio editor's waveform view: full waveform repaints drop from about 29 per second to none,+and the playhead line still moves across the editor. The smoke test passes. The reporter's+platform (Windows) wasn't available, so the fix targets the likely cause rather than a+reproduced stutter.++## Checks Performed++| Check | Command / Action | Result | Notes |+|-------|------------------|--------|-------|+| Repaint count, before | `develop` (db9990a) with a temporary counter in `WaveformView.Render`; 60 s audio clip open in the Clip panel; 8 s samples stopped, playing outside the clip, playing inside it | 0 / 0 / 29.9 and 0 / 0 / 28.0 per s (2 runs) | The counter isn't committed |+| Repaint count, after | Same on this branch | 0 / 0 / 0 per s (2 runs) | |+| Playhead still drawn | Seek into the clip, play, screenshot the editor | pass | Line moves across the waveform in step with the arrangement |+| Editor looks the same | Screenshot with the clip open and stopped, before vs after | pass | Identical |+| New / updated tests | none | not-run | No UI test harness; the engine is untouched, so no `RenderPoolTests` guard |+| Build + regression suite | `scripts/build-linux.sh` (`CC=gcc-13 CXX=g++-13`) | pass | `SMOKE TEST PASSED` |++## Output Excerpts++```+SMOKE TEST PASSED+BUILD_DONE=0+```++An earlier run on the same change failed two `overloaded: ... blocks late with render+threads` timing checks. Rerunning `--perf` alone on the same binary passed once and failed+once, so the timing guards are flaky on this 4-core VM. This change doesn't touch the+engine, and the final full run passed.++## Residual Risks++- Windows untested. The change is platform-neutral Avalonia drawing, but the reporter's+ stutter wasn't reproduced, and their "loop on the clip" doesn't exist as a feature. Most+ likely they had the clip open in the Clip panel.+- Process CPU under Xvfb was too noisy to measure (Avalonia's X11 loop busy-polls), so the+ benchmark counts repaints instead of measuring time.++## Recommendation++Merge, and ask the reporter to confirm on Windows. Reopen if the stutter persists with the+Clip panel closed. That would point at the follow-ups in `fix.md`.diff --git a/CHANGELOG.md b/CHANGELOG.mdindex baba0a03..5bb3605f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -124,6 +124,10 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.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.+- **Playback no longer stutters while an audio clip is open in the Clip panel** (#142): once+ the playhead reached the open clip, every tick repainted the whole audio editor — the+ waveform, ruler, warp markers and envelope — to move one line. The editor's playhead is now+ drawn on its own layer, so playing through the clip repaints just that line.## [0.58.1] — 2026-10-29diff --git a/src/managed/Nota.App/AudioClipEditorView.cs b/src/managed/Nota.App/AudioClipEditorView.csindex 3e5b7379..8210b44d 100644--- a/src/managed/Nota.App/AudioClipEditorView.cs+++ b/src/managed/Nota.App/AudioClipEditorView.cs@@ -201,6 +201,7 @@ public sealed class AudioClipEditorView : UserControlvar waveHost = new Grid();waveHost.Children.Add(_wave);+ waveHost.Children.Add(_wave.PlayheadLayer);waveHost.Children.Add(_overlay);var col1 = new Grid { RowDefinitions = new RowDefinitions("*,Auto"), Background = NotaPalette.BgSunken };col1.Children.Add(waveHost);@@ -732,7 +733,7 @@ public sealed class AudioClipEditorView : UserControlpublic void SetPlacement(double startBeat, double lengthBeats, bool isSlot){_placeStart = startBeat; _placeLen = Math.Max(1e-6, lengthBeats); _slot = isSlot;- InvalidateVisual();+ Redraw();}private ClipTimeMap Map=> _srcMode && _srcTotal > 0@@ -742,6 +743,31 @@ public sealed class AudioClipEditorView : UserControl: new ClipTimeMap(_placeStart, _placeLen, ClipContentDomain.WarpBeats, 1, 0, 1, _reversed, _slot);private double PlayheadX(double w) => FracToX(Map.ContentAtPlayFrac(_frac), w);private bool PlayheadShown => _frac >= 0 && _frac <= 1;++ // The playback cursor is drawn on its own hit-transparent layer stacked over this view+ // (the host adds it), so a transport tick repaints one line instead of the whole wave,+ // ruler and markers (#142). Anything that repaints the view repaints the layer too.+ public Control PlayheadLayer { get; }+ public WaveformView() => PlayheadLayer = new PlayheadOverlay(this);+ private void Redraw()+ {+ InvalidateVisual();+ PlayheadLayer.InvalidateVisual();+ }++ private sealed class PlayheadOverlay : Control+ {+ private readonly WaveformView _v;+ public PlayheadOverlay(WaveformView v) { _v = v; IsHitTestVisible = false; ClipToBounds = true; }+ public override void Render(DrawingContext ctx)+ {+ if (!_v.PlayheadShown) return;+ // _frac runs over the PLAYED window, so on a reversed clip it walks the region+ // from its end back to its start (which the mirror then draws left-to-right).+ double x = _v.PlayheadX(_v.Bounds.Width);+ ctx.DrawLine(PlayheadPen, new Point(x, 0), new Point(x, _v.Bounds.Height));+ }+ }private bool OnPlayheadLine(double x, double w) => PlayheadShown && Math.Abs(x - PlayheadX(w)) <= PlayheadGrabPx;private double _srcSR; // source sample rate (for per-marker BPM)@@ -779,18 +805,18 @@ public sealed class AudioClipEditorView : UserControlprivate double SnapWarp(double beat) => SnapOn(beat, WarpGrid);private double SnapEnv(double beat) => SnapOn(beat, EnvGrid);- private void OnGrid(EditorKind k) { if (k == EditorKind.PianoRoll) InvalidateVisual(); }+ private void OnGrid(EditorKind k) { if (k == EditorKind.PianoRoll) Redraw(); }protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e){base.OnAttachedToVisualTree(e);EditorGrids.Shared.Changed += OnGrid;- RulerDisplay.Changed += InvalidateVisual;+ RulerDisplay.Changed += Redraw;}protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e){base.OnDetachedFromVisualTree(e);EditorGrids.Shared.Changed -= OnGrid;- RulerDisplay.Changed -= InvalidateVisual;+ RulerDisplay.Changed -= Redraw;}private const double MinSrcFrames = 256;private static readonly Cursor ArrowCur = new(StandardCursorType.Arrow);@@ -834,12 +860,12 @@ public sealed class AudioClipEditorView : UserControl/// <summary>Raised when an ADSR handle drag ends (or a handle is reset) with the new shape.</summary>public Action<ClipAdsr>? AdsrCommitted;- public void SetAdsrMode(bool on) { _adsrMode = on; _adsrHover = AdsrHandle.None; Cursor = ArrowCur; _curKind = StandardCursorType.Arrow; InvalidateVisual(); }+ public void SetAdsrMode(bool on) { _adsrMode = on; _adsrHover = AdsrHandle.None; Cursor = ArrowCur; _curKind = StandardCursorType.Arrow; Redraw(); }public void SetAdsr(ClipAdsr a, double lenBeats, double bpm){if (_adsrDrag != AdsrHandle.None) return; // don't yank a handle out from under the hand_adsr = a; _adsrLen = Math.Max(1e-6, lenBeats); _bpm = bpm;- InvalidateVisual();+ Redraw();}// The played region on screen (left→right in playing order) over the wave's value axis.@@ -868,7 +894,7 @@ public sealed class AudioClipEditorView : UserControl_trimStart = playStart;_trimEnd = playEnd > 0 ? Math.Min(playEnd, warpBeats) : warpBeats;_trimMode = warpBeats > 0;- InvalidateVisual();+ Redraw();}/// <summary>Raised on a click on a segment BPM label: (segmentIndex, currentBpm, xCenterPx, yTopPx).</summary>public Action<int, double, double, double>? BpmEditRequested;@@ -888,7 +914,7 @@ public sealed class AudioClipEditorView : UserControldouble newBeatSpan = Math.Max(0.05, bpm * srcSpan / (60.0 * _srcSR));double delta = newBeatSpan - (_mk[seg + 1].beat - _mk[seg].beat);for (int j = seg + 1; j < _mk.Count; j++) _mk[j] = (_mk[j].src, _mk[j].beat + delta);- if (commit) Commit(); else InvalidateVisual();+ if (commit) Commit(); else Redraw();}public void SetSegmentBpm(int seg, double bpm) => ApplySegmentBpm(seg, bpm, commit: true);@@ -898,7 +924,7 @@ public sealed class AudioClipEditorView : UserControl{_srcTotal = totalFrames; _srcOff = offsetFrames; _srcLen = lengthFrames;_srcMode = totalFrames > 0;- InvalidateVisual();+ Redraw();}// Horizontal zoom/scroll over a normalised clip axis (frac 0..1 spans the whole@@ -915,7 +941,7 @@ public sealed class AudioClipEditorView : UserControlpublic double Zoom => _zoom;public double ScrollFrac => _scrollFrac;public double MaxScrollFrac => Math.Max(0, 1.0 - 1.0 / _zoom);- public void SetScroll(double frac) { _scrollFrac = Math.Clamp(frac, 0, MaxScrollFrac); InvalidateVisual(); }+ public void SetScroll(double frac) { _scrollFrac = Math.Clamp(frac, 0, MaxScrollFrac); Redraw(); }// Reverse: the clip is drawn MIRRORED, so the screen always reads left-to-right in// playing order — a reversed clip's audible head (the region's end) sits on the left.@@ -924,7 +950,7 @@ public sealed class AudioClipEditorView : UserControl// every hit-test/drag keeps working in content coordinates. The zoom/scroll window// lives in VIEW space, hence the separate …View pair.private bool _reversed;- public void SetReversed(bool on) { if (_reversed == on) return; _reversed = on; InvalidateVisual(); }+ public void SetReversed(bool on) { if (_reversed == on) return; _reversed = on; Redraw(); }private double Mirror(double f) => _reversed ? 1.0 - f : f; // involution: content <-> viewprivate double FracToXView(double vf, double w) => (vf - _scrollFrac) * _zoom * w;private double XToFracView(double x, double w) => x / Math.Max(1, _zoom * w) + _scrollFrac;@@ -934,14 +960,14 @@ public sealed class AudioClipEditorView : UserControlprivate double SrcToX(double frame, double w) => _srcTotal > 0 ? FracToX(frame / _srcTotal, w) : 0;private double XToSrc(double x, double w) => Math.Clamp(XToFrac(x, w), 0, 1) * _srcTotal;- public void SetEnvMode(bool on) { _envMode = on; InvalidateVisual(); }+ public void SetEnvMode(bool on) { _envMode = on; Redraw(); }public void SetEnvelope(double[] beats, double[] values, float[] curves, double clipBeats, double min, double max){_clipBeats = Math.Max(1e-6, clipBeats);_envMin = min; _envMax = max;_env.Clear();for (int i = 0; i < beats.Length; i++) _env.Add(new EnvPt { beat = beats[i], val = values[i], curve = curves[i] });- InvalidateVisual();+ Redraw();}// The clip envelope is authored in PLAYED time (the renderer evaluates it against the// timeline position), so it always runs left-to-right — it must NOT mirror with the@@ -989,12 +1015,12 @@ public sealed class AudioClipEditorView : UserControlEnvelopeCommitted?.Invoke(beats, vals, curves);}- public void SetColor(IBrush b) { _wave = b; InvalidateVisual(); }- public void SetPeaks(float[] peaks, float[]? rms, int count) { _peaks = peaks; _rms = rms; _count = count; ClearDetail(); InvalidateVisual(); }+ public void SetColor(IBrush b) { _wave = b; Redraw(); }+ public void SetPeaks(float[] peaks, float[]? rms, int count) { _peaks = peaks; _rms = rms; _count = count; ClearDetail(); Redraw(); }public void SetPlayhead(double frac){if (Math.Abs(frac - _frac) < 1e-4) return;- _frac = frac; InvalidateVisual();+ _frac = frac; PlayheadLayer.InvalidateVisual();}public void SetMarkers(double[] src, double[] beat, int count){@@ -1004,9 +1030,9 @@ public sealed class AudioClipEditorView : UserControl_cSrc = src[..count]; _cBeat = beat[..count];if (_lBeat.Length != count) _lBeat = new double[count];if (_selMk >= _mk.Count) _selMk = -1;- InvalidateVisual();+ Redraw();}- public void SetGain(double g) { if (Math.Abs(g - _gain) < 1e-4) return; _gain = g; InvalidateVisual(); }+ public void SetGain(double g) { if (Math.Abs(g - _gain) < 1e-4) return; _gain = g; Redraw(); }// Live warp preview (#140): while markers move (a marker drag, a segment-tempo scrub, the// Tempo field) the peaks the engine laid out under the committed markers are re-timed on@@ -1027,7 +1053,7 @@ public sealed class AudioClipEditorView : UserControl{if (beats.Length != _mk.Count) return;for (int i = 0; i < beats.Length; i++) _mk[i] = (_mk[i].src, beats[i]);- InvalidateVisual();+ Redraw();}/// <summary>Drop a marker drag or segment-tempo scrub: back to the committed markers.</summary>public bool CancelGesture()@@ -1043,7 +1069,7 @@ public sealed class AudioClipEditorView : UserControlfor (int i = 0; i < _mk.Count; i++) _mk[i] = (_cSrc[i], _cBeat[i]);var p = _gesturePointer; _gesturePointer = null;p?.Capture(null);- InvalidateVisual();+ Redraw();}// Markers map in the BEAT domain, matching the warped waveform drawn across@@ -1119,7 +1145,7 @@ public sealed class AudioClipEditorView : UserControle.Pointer.Capture(this);}e.Handled = true;- InvalidateVisual();+ Redraw();return;}@@ -1152,14 +1178,14 @@ public sealed class AudioClipEditorView : UserControlint hit = HitEnv(p.X, p.Y, W, H);if (hit >= 0){- if (right || e.ClickCount == 2) { _env.RemoveAt(hit); CommitEnv(); InvalidateVisual(); }+ if (right || e.ClickCount == 2) { _env.RemoveAt(hit); CommitEnv(); Redraw(); }else { _envDrag = hit; e.Pointer.Capture(this); }e.Handled = true;return;}if (HitEnvSegment(p.X, p.Y, W, H) is { } seg) // bend / reset a segment (M9-D){- if (right || e.ClickCount == 2) { seg.curve = 0f; CommitEnv(); InvalidateVisual(); }+ if (right || e.ClickCount == 2) { seg.curve = 0f; CommitEnv(); Redraw(); }else { _envBend = seg; e.Pointer.Capture(this); }e.Handled = true;return;@@ -1170,7 +1196,7 @@ public sealed class AudioClipEditorView : UserControl_envDrag = _env.IndexOf(np);e.Pointer.Capture(this);e.Handled = true;- InvalidateVisual();+ Redraw();return;}@@ -1209,7 +1235,7 @@ public sealed class AudioClipEditorView : UserControlreturn;}int h = HitMarker(x, w);- if (h != _selMk) { _selMk = h; InvalidateVisual(); } // a click picks a marker (or clears the pick)+ if (h != _selMk) { _selMk = h; Redraw(); } // a click picks a marker (or clears the pick)if (h > 0 && h < _mk.Count - 1) { _drag = h; e.Pointer.Capture(this); _gesturePointer = e.Pointer; e.Handled = true; }}@@ -1234,7 +1260,7 @@ public sealed class AudioClipEditorView : UserControl_scrollFrac = Math.Clamp(_scrollFrac - WheelInput.Notches(d) * 0.12 / _zoom, 0, MaxScrollFrac);}ViewChanged?.Invoke();- InvalidateVisual();+ Redraw();e.Handled = true;}@@ -1257,13 +1283,13 @@ public sealed class AudioClipEditorView : UserControldouble beat = _adsrAnchorBeat + dx / Math.Max(1, f.Right - f.Left) * _adsrLen;double level = _adsrAnchorLevel - dy / Math.Max(1, f.Bottom - f.Top);_adsr = ClipAdsrKit.Drag(_adsrDrag, _adsrStart, beat, level, _adsrLen);- InvalidateVisual();+ Redraw();return;}if (_adsrMode) // ADSR mode: light the handle under the pointer{var hv = ClipAdsrKit.Hit(e.GetPosition(this), AdsrFrameNow(Bounds.Width, Bounds.Height), _adsr);- if (hv != _adsrHover) { _adsrHover = hv; InvalidateVisual(); }+ if (hv != _adsrHover) { _adsrHover = hv; Redraw(); }Cursor = hv != AdsrHandle.None ? HandCur : ArrowCur;_curKind = StandardCursorType.Arrow;return;@@ -1282,7 +1308,7 @@ public sealed class AudioClipEditorView : UserControlvar p = e.GetPosition(this);_env[_envDrag].beat = SnapEnv(EnvXToBeat(p.X, Bounds.Width));_env[_envDrag].val = EnvYToVal(p.Y, Bounds.Height);- InvalidateVisual();+ Redraw();return;}if (_envBend is { } bl)@@ -1300,7 +1326,7 @@ public sealed class AudioClipEditorView : UserControldouble ee = Math.Log(frac) / Math.Log(0.5);bl.curve = (float)Math.Clamp(-Math.Log2(ee) / 4.0, -1.0, 1.0);}- InvalidateVisual();+ Redraw();}return;}@@ -1310,7 +1336,7 @@ public sealed class AudioClipEditorView : UserControldouble f = XToSrc(e.GetPosition(this).X, sw);if (_srcDrag == 0) _srcOff = Math.Clamp(f, 0, _srcOff + _srcLen - MinSrcFrames);else { double end = Math.Clamp(f, _srcOff + MinSrcFrames, _srcTotal); _srcLen = end - _srcOff; }- InvalidateVisual();+ Redraw();return;}if (_trimDrag >= 0) // warped trim brackets (beat domain)@@ -1320,14 +1346,14 @@ public sealed class AudioClipEditorView : UserControlbt = SnapWarp(bt); // land the edge exactly on the grid (Alt / snap off: free)if (_trimDrag == 0) _trimStart = Math.Clamp(bt, 0, _trimEnd - minBeat);else _trimEnd = Math.Clamp(bt, _trimStart + minBeat, _trimTotal);- InvalidateVisual();+ Redraw();return;}if (_envMode && _drag < 0) // envelope mode: light the node under the pointer{var ep = e.GetPosition(this);int hv = HitEnv(ep.X, ep.Y, Bounds.Width, Bounds.Height);- if (hv != _envHover) { _envHover = hv; InvalidateVisual(); }+ if (hv != _envHover) { _envHover = hv; Redraw(); }return;}if (_drag < 0) // no active drag: track hover for marker/bracket highlight + cursor@@ -1339,7 +1365,7 @@ public sealed class AudioClipEditorView : UserControldouble b = SnapWarp(XToBeat(e.GetPosition(this).X, w)); // align to the griddouble lo = _mk[_drag - 1].beat + 1e-3, hi = _mk[_drag + 1].beat - 1e-3; // stay between neighbours_mk[_drag] = (_mk[_drag].src, Math.Clamp(b, lo, hi)); // source fixed; beat moves (warp)- InvalidateVisual();+ Redraw();}protected override void OnPointerReleased(PointerReleasedEventArgs e)@@ -1350,7 +1376,7 @@ public sealed class AudioClipEditorView : UserControl_adsrDrag = AdsrHandle.None;e.Pointer.Capture(null);if (!_adsr.Equals(_adsrStart)) AdsrCommitted?.Invoke(_adsr);- InvalidateVisual();+ Redraw();return;}if (_bpmScrubSeg >= 0) // push the scrubbed warp (one undo step) — only if it was dragged@@ -1358,7 +1384,7 @@ public sealed class AudioClipEditorView : UserControl_bpmScrubSeg = -1; _gesturePointer = null; e.Pointer.Capture(null);if (_bpmScrubMoved) Commit();_bpmScrubMoved = false;- InvalidateVisual();+ Redraw();return;}if (_envDrag >= 0 || _envBend is not null) { _envDrag = -1; _envBend = null; e.Pointer.Capture(null); CommitEnv(); return; }@@ -1381,7 +1407,7 @@ public sealed class AudioClipEditorView : UserControlprotected override void OnPointerExited(PointerEventArgs e){if (_hoverMk != -1 || _bpmHoverSeg != -1 || _envHover != -1 || _adsrHover != AdsrHandle.None)- { _hoverMk = -1; _bpmHoverSeg = -1; _envHover = -1; _adsrHover = AdsrHandle.None; InvalidateVisual(); }+ { _hoverMk = -1; _bpmHoverSeg = -1; _envHover = -1; _adsrHover = AdsrHandle.None; Redraw(); }SetCursorKind(StandardCursorType.Arrow);base.OnPointerExited(e);}@@ -1406,7 +1432,7 @@ public sealed class AudioClipEditorView : UserControldouble x = p.X;int bpmHover = -1;foreach (var b in _bpmHot) if (b.rect.Contains(p)) { bpmHover = b.seg; break; }- if (bpmHover != _bpmHoverSeg) { _bpmHoverSeg = bpmHover; InvalidateVisual(); }+ if (bpmHover != _bpmHoverSeg) { _bpmHoverSeg = bpmHover; Redraw(); }if (bpmHover >= 0) { SetCursorKind(StandardCursorType.SizeNorthSouth); return; }bool overHandle = false;@@ -1425,10 +1451,10 @@ public sealed class AudioClipEditorView : UserControlif (!overHandle && _mk.Count >= 2){int hv = HitMarker(x, w);- if (hv != _hoverMk) { _hoverMk = hv; InvalidateVisual(); }+ if (hv != _hoverMk) { _hoverMk = hv; Redraw(); }overHandle = hv > 0 && hv < _mk.Count - 1; // only interior markers drag}- else if (overHandle && _hoverMk != -1) { _hoverMk = -1; InvalidateVisual(); }+ else if (overHandle && _hoverMk != -1) { _hoverMk = -1; Redraw(); }}SetCursorKind(overHandle ? StandardCursorType.SizeWestEast : StandardCursorType.Arrow);}@@ -1546,7 +1572,7 @@ public sealed class AudioClipEditorView : UserControlvar (pk, rms, cnt) = DetailPeaks(p0, p1, n);if (cnt <= 0) return;_dPeaks = pk; _dRms = rms; _dCount = cnt; _dF0 = p0; _dF1 = p1;- InvalidateVisual();+ Redraw();}, DispatcherPriority.Background);}private const int MaxDetail = 8192; // the engine's range-peaks cap@@ -1867,14 +1893,6 @@ public sealed class AudioClipEditorView : UserControl}else if (shaped && !_envMode)ClipAdsrKit.DrawCurve(ctx, adsrF, adsrFit, EnvPenDim);-- if (_frac >= 0 && _frac <= 1)- {- // _frac runs over the PLAYED window, so on a reversed clip it walks the region- // from its end back to its start (which the mirror then draws left-to-right).- double x = PlayheadX(w);- ctx.DrawLine(PlayheadPen, new Point(x, 0), new Point(x, h));- }}// Local ruler (a Session slot): bar.beat over the warp's beats, or seconds over the source when unwarped.