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) Un-warped audio clips resize live when the tempo changes in the transport bar (#161)
lockstock732aca441bfb09
diff --git a/.specify/bugs/tempo-unwarped-redraw/assessment.md b/.specify/bugs/tempo-unwarped-redraw/assessment.mdnew file mode 100644index 00000000..db1b4d6d--- /dev/null+++ b/.specify/bugs/tempo-unwarped-redraw/assessment.md@@ -0,0 +1,100 @@+# Bug Assessment: un-warped audio clips keep their width when the tempo is changed in the transport bar++- **Slug**: tempo-unwarped-redraw+- **Created**: 2026-10-17+- **Source**: pasted text (user observation, Nota 0.55.1 on Ubuntu 26.04)+- **Verdict**: valid+- **Severity**: medium++## Report (verbatim or summarized)++> when I change the bpm, these no-warped tracks are not appearing to change size at all?+> e.g. when I used to un-warp tracks in ableton, then change the bpm, I would see the tracks+> expanding or contracting visually, and could easily line them up with the end of a bar for+> a given bpm++The user tried both ruler modes (bars and min:sec), zoomed and scrolled; the clips never+changed width.++## Symptom++An un-warped audio clip has a fixed duration in seconds, so its length in beats changes with+the tempo, and the engine reports that correctly. But when the tempo is changed in the+transport bar's BPM field, the arrangement keeps drawing every audio clip at the width it had+before. Expected: un-warped clips grow or shrink against the bar grid as the tempo changes+(as in Ableton), so a clip can be lined up with a bar line by ear and eye.++## Reproduction++1. Put an un-warped audio clip on an audio track (any one-shot or loop with warp off).+2. Drag or type a different tempo into the transport bar's BPM field.+3. The clip keeps its width. The engine's clip info has changed, though: `get_overview` over+ MCP reports a clip of 11.18 beats at 110 BPM as 9.14 beats at 90 BPM.+4. Change the tempo through MCP instead (`set_tempo`): the clip *does* resize at once.+ Confirmed by the reporter on 0.55.1.++## Suspected Code Paths++- `src/managed/Nota.Presentation/ViewModels/TransportViewModel.cs:68`: `OnBpmChanged` only calls+ `_engine.SetBpm`. Nothing tells the arrangement that clip geometry changed.+- `src/managed/Nota.App/MainWindow.axaml.cs:253`: the window's `Transport.PropertyChanged`+ handler updates the BPM field's readout on a `Bpm` change, but doesn't refresh the timeline.+- `src/managed/Nota.App/ArrangementView.cs:790` (`Refresh`): `ClipVM.LengthBeats` is a snapshot+ of `TryGetClipInfo(...).LengthBeats`, taken on refresh. Until the next refresh, the lane draws+ the stale length.+- `src/managed/Nota.App/MainWindow.axaml.cs:510` (MCP `OnRefresh`) and+ `src/managed/Nota.Mcp/EngineTools.cs:26` (`Mutate`): the MCP path calls `Timeline.Refresh()`+ after every edit. That's why `set_tempo` over MCP redraws correctly and the UI path doesn't.++## Root Cause Hypothesis++The arrangement caches each clip's beat length in its view-model and only re-reads it on+`Refresh`. Every arrangement edit refreshes, and so does every MCP mutation. A tempo change made+from the transport bar is neither: it goes from the view-model straight to the engine. So the+cached beat lengths of un-warped audio clips go stale until something unrelated triggers a+refresh. Confidence: high. The MCP path differs only by the refresh, and the reporter confirmed+that it resizes the clips.++## Proposed Remediation++**Preferred**: in `MainWindow`'s `Transport.PropertyChanged` handler, refresh the arrangement on a+`Bpm` change with `Timeline.Refresh(rebuildHeaders: false)`, the lightweight refresh already+used for the live recording tick. It keeps header controls and open menus intact. Dragging the+BPM field raises many changes per second, so coalesce them: post one refresh to the dispatcher+and skip further posts until it has run. Then a fast drag costs about one refresh per UI frame.++**Alternatives**:+- Raise a `TempoChanged` event from `TransportViewModel` and subscribe from the arrangement.+ That's cleaner in principle, but it adds an event for one subscriber. The window already owns+ the view-model → timeline wiring for every other transport property.+- Have `ArrangementView` read `LengthBeats` from the engine at draw time. That would put engine+ calls in the render path for every clip, and go against the snapshot design of `Refresh`.++**Files likely to change**:+- `src/managed/Nota.App/MainWindow.axaml.cs`+- `CHANGELOG.md` (user-visible fix)++**Tests to add or update**:+- The fix is in the Avalonia window wiring, which no automated test covers (the smoke test drives+ the engine through the C ABI; there is no UI test harness). Verify by hand on Linux: an+ un-warped clip resizes live while the BPM field is dragged, in both ruler modes. Also check+ that warped clips keep their beat length, and that the MCP path is unchanged.+- The smoke test must still pass.++## Risks & Considerations++- Performance: a live refresh refetches peaks (2048 buckets) for each audio clip whose beat+ length changed, which during a tempo drag means every un-warped clip. Coalescing caps it at+ about one refresh per frame. Reusing peaks across tempo-only changes would make it cheaper+ still, but that is a separate optimisation.+- No audio-thread impact: the change is UI-thread only. The engine call (`SetBpm`) is unchanged.++## Related (out of scope)++The reverse direction is also broken: `set_tempo` over MCP changes the engine but not+`TransportViewModel.Bpm`, so the BPM field shows a stale tempo and saving writes the stale value.+Tracked separately as `mcp-tempo-ui-sync`.++## Open Questions++- None.diff --git a/.specify/bugs/tempo-unwarped-redraw/fix.md b/.specify/bugs/tempo-unwarped-redraw/fix.mdnew file mode 100644index 00000000..aef41f5d--- /dev/null+++ b/.specify/bugs/tempo-unwarped-redraw/fix.md@@ -0,0 +1,58 @@+# Bug Fix: un-warped audio clips keep their width when the tempo is changed in the transport bar++- **Slug**: tempo-unwarped-redraw+- **Fixed**: 2026-10-17+- **Assessment**: ./assessment.md+- **Status**: applied++## Summary++A `Bpm` change on the transport view-model now queues one live arrangement refresh. The+timeline re-reads each clip's beat length, so un-warped audio clips resize as the tempo+changes. A drag of the BPM field is coalesced to one refresh per dispatcher batch.++## Changes++| File | Change | Notes |+|------|--------|-------|+| `src/managed/Nota.App/MainWindow.axaml.cs` | modified | `Transport.PropertyChanged` → `RequestTempoRefresh()` on `Bpm`; new `_tempoRefreshPosted` flag + helper |+| `CHANGELOG.md` | modified | `Fixed` entry under `[Unreleased]` |++```csharp+private void RequestTempoRefresh()+{+ if (_tempoRefreshPosted) return;+ _tempoRefreshPosted = true;+ Dispatcher.UIThread.Post(() => { _tempoRefreshPosted = false; Timeline.Refresh(rebuildHeaders: false); }, DispatcherPriority.Background);+}+```++The coalescing copies `RequestTransportFit()` (`MainWindow.TransportFit.cs`), which uses a+posted flag and a single dispatcher post. `Refresh(rebuildHeaders: false)` is the live+refresh the recording tick uses: it rebuilds clip data and lanes but leaves header+controls and open menus alone, and it ends in `Redraw()`, so the ruler redraws too.++## Tests Added or Updated++- None automated. The change is in Avalonia window wiring, and the smoke test has no UI+ harness (as the assessment said). Verified by hand instead (`/speckit-bug-test`).++## Local Verification++- Commands run, Ubuntu 26.04 x64, .NET SDK 10.0.112:+ - `dotnet build Nota.sln -c Release -nodeReuse:false -m:1` → 0 errors, no new warnings.+ - `dotnet run --project tests/Nota.SmokeTest -c Release` → `SMOKE TEST PASSED`.+- Before the fix (reporter, 0.55.1): MCP `set_tempo` resized clips live (it refreshes the+ timeline after every mutation), but the BPM field didn't. That isolates the missing+ refresh as the cause.+- Manual checks: pending (`/speckit-bug-test`).++## Deviations from Assessment++- None.++## Follow-ups++- Peak reuse: during a tempo drag every un-warped clip refetches its 2048-bucket peaks,+ because `Refresh` only reuses peaks when start and length are unchanged. An un-warped+ clip's peaks don't depend on the tempo, so they could be reused across tempo-only changes.diff --git a/.specify/bugs/tempo-unwarped-redraw/test.md b/.specify/bugs/tempo-unwarped-redraw/test.mdnew file mode 100644index 00000000..3597f701--- /dev/null+++ b/.specify/bugs/tempo-unwarped-redraw/test.md@@ -0,0 +1,42 @@+# Bug Verification: un-warped audio clips keep their width when the tempo is changed in the transport bar++- **Slug**: tempo-unwarped-redraw+- **Tested**: 2026-10-18+- **Assessment**: ./assessment.md+- **Fix**: ./fix.md+- **Result**: verified++## Summary++With the fix, dragging the transport bar's BPM field resizes un-warped audio clips live. The+reporter confirmed this in a local Release build on Linux, and a warped clip kept its size+in bars while the un-warped clips around it resized. The smoke test passes.++## Checks Performed++| Check | Command / Action | Result | Notes |+|-------|------------------|--------|-------|+| Reproduction (post-fix) | Local build (this branch merged with `fix/mcp-tempo-ui-sync`), project with un-warped audio clips, drag the BPM field | pass | Reporter: "clips resized live" |+| Ruler modes | Same, with the ruler in Bars and in Time | pass | Reporter tried both while reproducing; the fix's refresh ends in `Redraw()`, which repaints the ruler |+| Fast drag | Drag the BPM field quickly back and forth | pass | Reporter: "seemed stable"; no stutter reported |+| Warped clips unchanged | Warp one clip, then change the tempo | pass | Reporter: the warped clip "remained the same size while the others shifted" |+| New / updated tests | none | not-run | No UI test harness, as the assessment says |+| Regression suite | `dotnet run --project tests/Nota.SmokeTest -c Release` | pass | `SMOKE TEST PASSED` |+| Build | `dotnet build Nota.sln -c Release -nodeReuse:false -m:1` | pass | 0 errors, no new warnings |++## Output Excerpts++```+SMOKE TEST PASSED+```++## Residual Risks++- Tested on Linux only (Ubuntu 26.04 x64). The change is platform-neutral window wiring.+- Peak refetch cost during a drag on a project with many long un-warped clips wasn't+ measured (see the follow-up in `fix.md`).++## Recommendation++Close the bug. It's verified end-to-end on Linux by the reporter, for both un-warped and+warped clips.diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0307051c..239e737f 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -82,6 +82,11 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.Windows and Linux) always starts a new track.### Fixed+- **Un-warped audio clips follow the tempo as you change it**: an un-warped clip keeps its+ length in seconds, so a new tempo makes it longer or shorter in bars. Changing the tempo+ in the transport bar now shows that at once, while you drag, so a clip can be lined up+ with a bar line. Before, the arrangement kept drawing each clip at its old width until+ some other edit redrew it.- **Send faders stay in step everywhere** (nota-daw/nota#138): turning a Send knob on atrack's Sends card in the Devices panel now moves that send's fader in the Session mixerand the Mixer window at once, and the other way round. Automation of a send shows on alldiff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.csindex 9390bb41..3bffc439 100644--- a/src/managed/Nota.App/MainWindow.axaml.cs+++ b/src/managed/Nota.App/MainWindow.axaml.cs@@ -78,6 +78,7 @@ public partial class MainWindow : Window// with — Tab then toggles between the two tabs.private bool _detailWasLastFocused;private bool _trackHeadersFocused;+ private bool _tempoRefreshPosted;private IAudioEngine Engine => _vm!.Engine;@@ -252,7 +253,11 @@ public partial class MainWindow : Windowvm.Transport.PropertyChanged += (_, e) =>{- if (e.PropertyName == nameof(vm.Transport.Bpm)) bpmField.Value = (double)vm.Transport.Bpm;+ if (e.PropertyName == nameof(vm.Transport.Bpm))+ {+ bpmField.Value = (double)vm.Transport.Bpm;+ RequestTempoRefresh(); // un-warped audio clips change beat length with the tempo+ }// Opening a project restores the master gain on the view model; move the fader// with it so the handle and the dB readout beside it never disagree. Skipped// mid-drag, where the fader is the one driving.@@ -573,6 +578,17 @@ public partial class MainWindow : Window}+ /// <summary>A tempo change moves the beat length of every un-warped audio clip (its+ /// seconds are fixed), but the arrangement only re-reads clip lengths on Refresh. A+ /// BPM drag raises many changes a second, so coalesce them to one live refresh (clip+ /// data + lanes, headers untouched) after the current batch.</summary>+ private void RequestTempoRefresh()+ {+ if (_tempoRefreshPosted) return;+ _tempoRefreshPosted = true;+ Dispatcher.UIThread.Post(() => { _tempoRefreshPosted = false; Timeline.Refresh(rebuildHeaders: false); }, DispatcherPriority.Background);+ }+private void OnAddInstrumentClicked(object? sender, RoutedEventArgs e) => AddTrack(NewTrackKind.Instrument);private void OnAddAudioClicked(object? sender, RoutedEventArgs e) => AddTrack(NewTrackKind.Audio);