Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.
C# audioaudio-unitavaloniacpp20cross-platformdawdigital-audio-workstationdspjucelinux-audiomcp-servermidimusicmusic-productionpiano-rollplugin-hostsequencersynthesizervstvst3
(feat) Audio dropouts in the status bar (#271) (#409)
Asish55c3c29f5b7d
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 58cbb1c4..7d7e6769 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -38,6 +38,13 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`."48 kHz · 256". Click it to pick another buffer size — Device default or 64 to 2048 frames,each with its latency — or to open Settings → Audio. Playback carries on across the change.Under ASIO the menu offers the driver's settings instead, since the driver sets the buffer.+- **Audio dropouts in the status bar** (#271): from the first dropout the audio device+ reports, a red counter beside the sample rate shows how many there have been since it+ started ("1 dropout", "3 dropouts"); while there are none it stays hidden. Click it to+ reset the count, e.g. after raising the buffer size, and see whether it comes back; a new+ device, sample rate or buffer size resets it too. The tooltip says what a dropout is and+ what usually helps. Core Audio (macOS) and ASIO report dropouts; the PulseAudio / ALSA and+ WASAPI backends don't yet.- **Track inspector** (#186): a new tab at the bottom of the browser's left rail shows theselected track's settings in one place — name, Mute / Solo / Arm, record input and inputmonitoring or MIDI from, colour, row height and the freeze commands — so they no longerdiff --git a/FEATURES.md b/FEATURES.mdindex 982c742d..9f3d1d80 100644--- a/FEATURES.md+++ b/FEATURES.md@@ -1288,6 +1288,11 @@ audio effects after it keep running and keep their settings; saved with the projAudio settings…; picking a size restarts the device and playback carries on. Under ASIOthe menu offers Driver settings… instead (the driver owns the buffer); in WASAPI exclusivemode it says the device's own buffer is used.+- **Audio dropouts in the status bar** ("3 dropouts" in red, left of the sample rate): the+ dropouts the audio device reported since it started, shown from the first one and hidden+ while there are none; a click resets the count, and so does a new device, sample rate or+ buffer size. Core Audio (macOS) and ASIO report dropouts; the PulseAudio / ALSA and WASAPI+ backends don't yet, so there it never appears.- **About** — the app and engine versions, the copyright notice, and a pointer to thethird-party attribution notices (`LICENSES/THIRD-PARTY-NOTICES.md`).- **Settings** — a larger window with a sidebar grouped into Devices, Plug-ins and Generaldiff --git a/specs/068-status-bar-dropouts/plan.md b/specs/068-status-bar-dropouts/plan.mdnew file mode 100644index 00000000..04785086--- /dev/null+++ b/specs/068-status-bar-dropouts/plan.md@@ -0,0 +1,43 @@+# Implementation Plan: Audio dropouts in the status bar++**Branch**: `068-status-bar-dropouts` | **Date**: 2026-11-01 | **Spec**: [spec.md](spec.md)++## Summary++Put a ghost button counting dropouts left of the status bar's sample-rate readout. The+existing `MainWindowViewModel.ReportDropouts` poll feeds a small `DropoutCounter` that holds+the reset point, so the button shows the dropouts since the device started or the user last+clicked it. It appears in the danger ink from the first dropout and is hidden at 0.++## Technical Context++**Language/Version**: C# / .NET 10, Avalonia.++**Primary Dependencies**: none new.++**Audio-Thread Impact**: None. The count is the engine's existing atomic xrun counter+(`nota_engine_xrun_count`), already read on the UI thread by the ~30 Hz playhead clock; nothing+is added to the audio thread or the C ABI.++**Testing**: `tests/Nota.SmokeTest/DropoutCounterTests.cs` (text, counting, change detection,+reset, never negative); the design checks (labels, tokens) scan the new XAML; manual check in+the running app.++## Design++- `Nota.Presentation/ViewModels/DropoutCounter.cs` — `Observe(engineCount)` returns whether+ the count since the reset point changed; `Reset(engineCount)` moves the reset point;+ `Text(count)` reads "0 dropouts" / "1 dropout" / "N dropouts".+- `MainWindowViewModel` — `DropoutText` and `HasDropouts`, updated by `ReportDropouts` only+ when the count changes (every dropout is still logged); `ResetDropouts()` for the click and+ after every successful `ApplyAudioSettings` (device, rate or buffer change, ASIO reset).+- `MainWindow.axaml` — `DropoutButton` (ghost, caption mono text, tooltip), visible while+ `HasDropouts`, in a new status bar column before `AudioFormatButton`; `MainWindow.axaml.cs`+ wires its click to `ResetDropouts`.+- `Theme/NotaTheme.axaml` — `TextBlock.Caption.alert` takes `Brush.DangerBright`, the overload+ readout ink.++## Constitution Check++UI-only, no engine or ABI change, no dependency, sentence-case labels, danger ink only while+something is wrong (DESIGN.md § semantics by purpose).diff --git a/specs/068-status-bar-dropouts/spec.md b/specs/068-status-bar-dropouts/spec.mdnew file mode 100644index 00000000..1c0ca6c9--- /dev/null+++ b/specs/068-status-bar-dropouts/spec.md@@ -0,0 +1,114 @@+# Feature Specification: Audio dropouts in the status bar++**Feature Branch**: `068-status-bar-dropouts`++**Created**: 2026-11-01++**Status**: Implemented++**Input**: GitHub issue nota-daw/nota#271: "A simple xruns counter/indicator in the bottom+margin next to the sample rate would be a useful addition to see if something is wrong or+if the buffer size is set too low for the system to handle."++## Nota Context++**Feature area**:++- [ ] Engine (C++, `src/native/nota.engine`)+- [x] Managed app (C#, `src/managed/*`) — presentation view model+- [x] UI (Avalonia) — follow `DESIGN.md` (Studio)+- [ ] Plugin hosting+- [ ] Build / packaging / CI+- [ ] Docs only++**Nota docs to keep in mind**: [`ARCHITECTURE.md`](../../ARCHITECTURE.md),+[`CONTRIBUTING.md`](../../CONTRIBUTING.md), [`DESIGN.md`](../../DESIGN.md),+[`FEATURES.md`](../../FEATURES.md).++**Existing behaviour this builds on**: the engine counts device dropouts since launch+(`nota_engine_xrun_count`, M7-8). `MainWindowViewModel.ReportDropouts` polls it on the+playhead clock, logs each new one and flashes "⚠ Audio dropout (n)" in the status text,+which the next message replaces. Settings → Audio's CPU check counts dropouts over its five+seconds. The status bar's right side shows the sample rate and buffer ("48 kHz · 256",+specs/061) and the version.++## User Scenarios & Testing++### User Story 1 - See whether the system keeps up (Priority: P1)++A producer hears a click and wants to know whether the audio device actually missed a+buffer, without opening Settings.++**Independent Test**: Start Nota; the status bar shows no dropout counter. Force a dropout+(a tiny buffer under heavy load); the counter appears and reads "1 dropout" in red.++**Acceptance Scenarios**:++1. **Given** no dropout since the device started, **Then** the status bar shows no+ counter, so a healthy session adds nothing to read.+2. **When** the device reports a dropout, **Then** the counter appears beside the sample+ rate in the danger ink and counts up ("1 dropout", "3 dropouts").+3. **When** the user hovers the counter, **Then** the tooltip says what a dropout is, what+ usually helps, and that a click resets it.++### User Story 2 - Check whether a change helped (Priority: P1)++After raising the buffer size or freezing a track, the producer wants to see whether+dropouts stop.++**Independent Test**: With dropouts counted, click the counter; it disappears and comes+back only for new ones.++**Acceptance Scenarios**:++1. **When** the user clicks the counter, **Then** it resets to 0 and hides until the next+ dropout, which reads "1 dropout".+2. **When** the audio device, sample rate or buffer size changes (Settings → Audio, the+ status bar's buffer menu, an ASIO driver reset), **Then** the counter resets to 0 and+ hides.++### Edge Cases++- **A failed apply**: the device didn't restart, so the count stays.+- **Dropouts between the last clock tick and a reset**: they don't count, but the next tick+ still logs them, so the log never misses one.+- **Backends that don't report dropouts** (miniaudio: PulseAudio / ALSA, WASAPI): the count+ stays at 0, so the counter never appears. The engine's count only moves where the backend+ reports dropouts (Core Audio, ASIO).++## Requirements++### Functional Requirements++- **FR-001**: The status bar MUST show the number of dropouts since the device started or+ the last reset ("1 dropout", "N dropouts"), left of the sample rate, and MUST hide it+ while that number is 0.+- **FR-002**: The count MUST use the danger ink (DESIGN.md: red is overload).+- **FR-003**: Clicking the counter MUST reset it to 0.+- **FR-004**: Every audio apply that restarts the device MUST reset it to 0.+- **FR-005**: The tooltip MUST explain a dropout and the usual fix (a larger buffer,+ freezing heavy tracks) and say that a click resets it.+- **FR-006**: The text MUST change only when the count does (no per-tick relayout).++## Success Criteria++- **SC-001**: Whether the device has dropped out is visible without opening any window.+- **SC-002**: A setting change can be judged by one click and watching the count.++## Assumptions++- No engine or C ABI change: the engine's running count is reused and the reset point is+ kept on the managed side, so the CPU check and the MCP `get_engine_info` tool keep+ reading the count since launch.+- Teaching the miniaudio backends to report dropouts is engine work for another change.++## Nota Compliance Checklist++- [x] Every new source file carries the AGPL-3.0-only SPDX header+- [x] No new dependency+- [x] Audio-thread impact: none — the UI thread reads an existing atomic counter+- [x] No new managed/native crossings+- [x] Smoke-test impact: counting, reset and text covered by `DropoutCounterTests`+- [x] User-visible change → `CHANGELOG.md` `[Unreleased]` entry and FEATURES.md+- [x] UI change → follows `DESIGN.md` (ghost button like its neighbours, caption text,+ shown in danger ink only while something is wrong)diff --git a/specs/068-status-bar-dropouts/tasks.md b/specs/068-status-bar-dropouts/tasks.mdnew file mode 100644index 00000000..7eb1a0ce--- /dev/null+++ b/specs/068-status-bar-dropouts/tasks.md@@ -0,0 +1,23 @@+# Tasks: Audio dropouts in the status bar++**Input**: [spec.md](spec.md), [plan.md](plan.md)++## Phase 1: Foundation++- [x] T001 Add `DropoutCounter` (count since a reset point, change detection, text) in `src/managed/Nota.Presentation/ViewModels/DropoutCounter.cs`++## Phase 2: User Story 1 — see the dropouts (P1)++- [x] T002 `DropoutText` / `HasDropouts`, fed by `ReportDropouts` in `src/managed/Nota.Presentation/ViewModels/MainWindowViewModel.cs` (FR-001, FR-006)+- [x] T003 Ghost `DropoutButton` with tooltip, left of the sample rate and hidden at 0, in `src/managed/Nota.App/MainWindow.axaml` (FR-001, FR-005)+- [x] T004 `TextBlock.Caption.alert` (danger ink) in `src/managed/Nota.App/Theme/NotaTheme.axaml` (FR-002)++## Phase 3: User Story 2 — reset (P1)++- [x] T005 `ResetDropouts`, called by the button in `src/managed/Nota.App/MainWindow.axaml.cs` and after every audio apply in `MainWindowViewModel.ApplyAudioSettings` (FR-003, FR-004)++## Phase 4: Polish++- [x] T006 Smoke test `tests/Nota.SmokeTest/DropoutCounterTests.cs`, registered in `Program.cs`+- [x] T007 `CHANGELOG.md` `[Unreleased]` and `FEATURES.md` entries+- [x] T008 `scripts/build-linux.sh` passes (engine, managed, smoke test incl. design checks)diff --git a/src/managed/Nota.App/MainWindow.axaml b/src/managed/Nota.App/MainWindow.axamlindex 08192309..0c708a0c 100644--- a/src/managed/Nota.App/MainWindow.axaml+++ b/src/managed/Nota.App/MainWindow.axaml@@ -408,7 +408,7 @@<Border x:Name="StatusBar" DockPanel.Dock="Bottom" Background="{DynamicResource Brush.BgApp}"BorderBrush="{DynamicResource Brush.Seam}" BorderThickness="0,1,0,0"Height="22" Padding="16,0">- <Grid ColumnDefinitions="*,Auto,Auto,Auto,Auto,Auto">+ <Grid ColumnDefinitions="*,Auto,Auto,Auto,Auto,Auto,Auto"><TextBlock Classes="Caption" VerticalAlignment="Center" Text="{Binding StatusText}"/><!-- Settings → Downloads job (MainWindow.Downloads.cs): it keeps running after Settings closes. --><Panel x:Name="DownloadHost" Grid.Column="1" VerticalAlignment="Center"/>@@ -426,14 +426,20 @@</StackPanel><!-- A newer Nota release: available / downloading / ready to install (MainWindow.Updates.cs). --><Panel x:Name="UpdateHost" Grid.Column="3" VerticalAlignment="Center"/>+ <!-- Audio dropouts since the device started, in red and hidden at 0; a click resets it (#271). -->+ <Button x:Name="DropoutButton" Grid.Column="4" Classes="ghost" IsVisible="{Binding HasDropouts}"+ VerticalAlignment="Center" Margin="0" Padding="6,1" MinHeight="0" Cursor="Hand"+ ToolTip.Tip="Audio dropouts since the device started: buffers Nota couldn't fill in time, heard as clicks or gaps. If they keep coming, raise the buffer size or freeze heavy tracks. Click to reset">+ <TextBlock Classes="Caption Mono alert" Text="{Binding DropoutText}"/>+ </Button><!-- Sample rate · buffer size: opens the buffer menu (MainWindow.AudioFormat.cs, #373). -->- <Button x:Name="AudioFormatButton" Grid.Column="4" Classes="ghost"+ <Button x:Name="AudioFormatButton" Grid.Column="5" Classes="ghost"VerticalAlignment="Center" Margin="0" Padding="6,1" MinHeight="0" Cursor="Hand"ToolTip.Tip="Sample rate and buffer size. Click to change the buffer size"><TextBlock Classes="Caption Mono" Text="{Binding EngineInfo}"/></Button><!-- The installed version: opens its release notes (What's New), never an update (#127). -->- <Button x:Name="VersionButton" Grid.Column="5" Classes="ghost"+ <Button x:Name="VersionButton" Grid.Column="6" Classes="ghost"VerticalAlignment="Center" Margin="0,0,-6,0" Padding="6,1" MinHeight="0"Cursor="Hand" ToolTip.Tip="View release notes"><TextBlock x:Name="VersionText" Classes="Caption Mono"/>diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.csindex 28b9cb93..f1d634a2 100644--- a/src/managed/Nota.App/MainWindow.axaml.cs+++ b/src/managed/Nota.App/MainWindow.axaml.cs@@ -560,6 +560,7 @@ public partial class MainWindow : WindowVersionText.Text = $"v{AppInfo.Version}";VersionButton.Click += (_, _) => ShowWhatsNew();SetUpAudioFormatButton();+ DropoutButton.Click += (_, _) => vm.ResetDropouts(); // count again from zero (#271)Closed += (_, _) => vm.Dispose();SetUpCpuTip(vm.Engine);diff --git a/src/managed/Nota.App/Theme/NotaTheme.axaml b/src/managed/Nota.App/Theme/NotaTheme.axamlindex f960594b..034bd0f0 100644--- a/src/managed/Nota.App/Theme/NotaTheme.axaml+++ b/src/managed/Nota.App/Theme/NotaTheme.axaml@@ -913,6 +913,10 @@<Setter Property="LineHeight" Value="16"/><Setter Property="Foreground" Value="{DynamicResource Brush.TextSecondary}"/></Style>+ <!-- A caption reporting something wrong (the status bar's dropout count): overload readout ink. -->+ <Style Selector="TextBlock.Caption.alert">+ <Setter Property="Foreground" Value="{DynamicResource Brush.DangerBright}"/>+ </Style><Style Selector="TextBlock.SectionLabel"> <!-- panel group heading: 11 / 600, muted, sentence case --><Setter Property="FontSize" Value="11"/><Setter Property="FontWeight" Value="SemiBold"/>diff --git a/src/managed/Nota.Presentation/ViewModels/DropoutCounter.cs b/src/managed/Nota.Presentation/ViewModels/DropoutCounter.csnew file mode 100644index 00000000..71952179--- /dev/null+++ b/src/managed/Nota.Presentation/ViewModels/DropoutCounter.cs@@ -0,0 +1,36 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// The status bar's dropout counter (#271, specs/068). The engine counts device dropouts+// (xruns) since launch and never resets; the counter shows those since the device last+// started or since the user reset it, so a setting change can be judged by whether the+// count stays at zero.++namespace Nota.Presentation;++public sealed class DropoutCounter+{+ private int _baseline; // the engine's count when the counter last read zero++ /// <summary>Dropouts since the last reset.</summary>+ public int Count { get; private set; }++ /// <summary>Follow the engine's running count. True when <see cref="Count"/> changed.</summary>+ public bool Observe(int engineCount)+ {+ int count = Math.Max(0, engineCount - _baseline);+ if (count == Count) return false;+ Count = count;+ return true;+ }++ /// <summary>Start counting again from zero at the engine's current count.</summary>+ public void Reset(int engineCount)+ {+ _baseline = engineCount;+ Count = 0;+ }++ /// <summary>"0 dropouts", "1 dropout", "3 dropouts".</summary>+ public static string Text(int count) => count == 1 ? "1 dropout" : $"{count} dropouts";+}diff --git a/src/managed/Nota.Presentation/ViewModels/MainWindowViewModel.cs b/src/managed/Nota.Presentation/ViewModels/MainWindowViewModel.csindex de8cc81f..a42eb6b9 100644--- a/src/managed/Nota.Presentation/ViewModels/MainWindowViewModel.cs+++ b/src/managed/Nota.Presentation/ViewModels/MainWindowViewModel.cs@@ -17,6 +17,7 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposableprivate readonly IPeriodicTimer _autosave;private readonly ILogSink _log;private int _lastXrunCount;+ private readonly DropoutCounter _dropouts = new();public IAudioEngine Engine { get; }public TransportViewModel Transport { get; }@@ -48,6 +49,11 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable}[ObservableProperty] private string _engineInfo = "";+ /// <summary>The status bar's dropout count (#271): "1 dropout", "3 dropouts".</summary>+ [ObservableProperty] private string _dropoutText = DropoutCounter.Text(0);+ /// <summary>At least one dropout since the device started or the count was reset; the+ /// status bar shows the count only then.</summary>+ [ObservableProperty] private bool _hasDropouts;[ObservableProperty] private string _statusText = "";[ObservableProperty] private ToolbarSide _toolbarSide = ToolbarSide.Left;@@ -149,8 +155,9 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposableif (!SuspendEnginePolling && Engine.TrackCount > 0) AutosaveRequested?.Invoke();}- // Surface any new audio dropouts (M7-8): log to stderr + a non-fatal status- // message. Playback is never interrupted — the counter is passive.+ // Surface any new audio dropouts (M7-8): log to stderr, count them in the status bar+ // (#271) and show a non-fatal status message. Playback is never interrupted — the+ // counter is passive.private void ReportDropouts(){int count = Engine.XrunCount;@@ -158,7 +165,24 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposable_lastXrunCount = count;Console.Error.WriteLine($"[xrun] audio dropout #{count} at {DateTime.Now:o}");_log.Warn($"Audio dropout #{count}");- StatusText = $"⚠ Audio dropout ({count})";+ if (!_dropouts.Observe(count)) return; // all from before the last reset: logged only+ ShowDropouts();+ StatusText = $"⚠ Audio dropout ({_dropouts.Count})";+ }++ /// <summary>Count dropouts from zero again (#271): a click on the status bar's counter,+ /// and every device (re)start — a new device, rate or buffer is a fresh measurement.+ /// The log still gets every dropout.</summary>+ public void ResetDropouts()+ {+ _dropouts.Reset(Engine.XrunCount);+ ShowDropouts();+ }++ private void ShowDropouts()+ {+ DropoutText = DropoutCounter.Text(_dropouts.Count);+ HasDropouts = _dropouts.Count > 0;}/// <summary>@@ -203,6 +227,7 @@ public sealed partial class MainWindowViewModel : ObservableObject, IDisposableRefusedSampleRate = askedRate > 0 && Engine.ActiveAudioSystem == AudioSystem.Asio&& Engine.GetAudioConfig().SampleRate == 0 ? askedRate : 0;UpdateEngineInfo();+ ResetDropouts();int buf = Engine.NegotiatedBufferFrames;_log.Info($"Audio applied · {Engine.NegotiatedSampleRate:0}\u2009Hz · {buf} frames");if (NoAudioOutput is { } why)diff --git a/tests/Nota.SmokeTest/DropoutCounterTests.cs b/tests/Nota.SmokeTest/DropoutCounterTests.csnew file mode 100644index 00000000..b5ade14f--- /dev/null+++ b/tests/Nota.SmokeTest/DropoutCounterTests.cs@@ -0,0 +1,33 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Status bar dropout counter (#271, specs/068): it counts the engine's dropouts since the+// device started or the user reset it, reports only real changes (the view updates its+// text then, not every tick), and reads "1 dropout" / "N dropouts".++using Nota.Presentation;++namespace Nota.SmokeTest;++internal static class DropoutCounterTests+{+ public static IEnumerable<(bool Ok, string Label)> Run()+ {+ yield return (DropoutCounter.Text(0) == "0 dropouts", "no dropouts reads \"0 dropouts\"");+ yield return (DropoutCounter.Text(1) == "1 dropout", "one dropout is singular");+ yield return (DropoutCounter.Text(3) == "3 dropouts", "several dropouts are plural");++ var c = new DropoutCounter();+ yield return (c.Count == 0 && !c.Observe(0), "a fresh counter reads zero and an idle engine changes nothing");+ yield return (c.Observe(2) && c.Count == 2, "new engine dropouts are counted");+ yield return (!c.Observe(2) && c.Count == 2, "an unchanged engine count reports no change");++ c.Reset(2);+ yield return (c.Count == 0, "a reset counts from zero again");+ yield return (!c.Observe(2), "the dropouts before the reset stay forgotten");+ yield return (c.Observe(3) && c.Count == 1, "a dropout after the reset counts as the first");++ c.Reset(10);+ yield return (!c.Observe(4) && c.Count == 0, "an engine count below the reset point never goes negative");+ }+}diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.csindex 233e8127..2cc046db 100644--- a/tests/Nota.SmokeTest/Program.cs+++ b/tests/Nota.SmokeTest/Program.cs@@ -15303,6 +15303,9 @@ foreach (var (ok, label) in VelocityWheelTests.Run()) Check(ok, label);Console.WriteLine("-- status bar audio format --");foreach (var (ok, label) in AudioFormatStatusTests.Run()) Check(ok, label);+Console.WriteLine("-- status bar dropout counter --");+foreach (var (ok, label) in DropoutCounterTests.Run()) Check(ok, label);+Console.WriteLine("-- process cpu --");foreach (var (ok, label) in ProcessCpuTests.Run()) Check(ok, label);