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) Transport meter: label it DSP and show process CPU in its tooltip (#79)
Egor Khindikaynen3d38e2f4ac56
diff --git a/.specify/bugs/cpu-meter-dsp-only/assessment.md b/.specify/bugs/cpu-meter-dsp-only/assessment.mdnew file mode 100644index 00000000..85eb2b0d--- /dev/null+++ b/.specify/bugs/cpu-meter-dsp-only/assessment.md@@ -0,0 +1,170 @@+# Bug Assessment: CPU meter shows DSP load only, far below the OS process figure++- **Slug**: cpu-meter-dsp-only+- **Created**: 2026-10-15+- **Source**: https://github.com/nota-daw/nota/issues/54 (host: `github.com`, policy: allowlisted)+- **Verdict**: valid+- **Severity**: low++## Report (summarized)++**#54 — "CPU meter shows 5–10 % while the system monitor shows 35–45 % for Nota"** (Linux x86_64,+version not reported, reported by a user via @ambertape).++The transport CPU indicator reads 5–10 % during playback; the OS monitor (`top`, GNOME System+Monitor) shows the Nota process at 35–45 %. In two other DAWs the internal meter roughly matched+the system monitor. The issue already identifies the cause (the meter shows `Engine.CpuLoad`,+the audio-callback DSP load) and suggests labelling the meter honestly and also showing the+process CPU as a recent-window average. The fact that Nota's process CPU is high in absolute+terms is tracked separately in #55 and is **out of scope** here.++Additional requirement from the maintainer: the fix must behave correctly on **macOS, Linux and+Windows**.++## Symptom++The only CPU readout in the app is labelled plainly "CPU N%" but measures audio-thread render+time ÷ block duration. It excludes the UI thread, Avalonia rendering, timers, plugin editors and+everything else in the process, so it is several times lower than any OS monitor. Expected: the+meter says what it measures, and the process-wide CPU is visible in the app in a form that can be+compared against the platform's own monitor.++## Reproduction++1. Open a project with several tracks/devices and press Play.+2. Read the transport meter ("CPU N%", right of the time signature).+3. Compare with the OS monitor for the Nota process: `top`/`htop`/GNOME System Monitor (Linux),+ Activity Monitor (macOS), Task Manager → Details (Windows).+4. Observed: meter ≈ 5–10 %, OS ≈ 35–45 % (Linux report). Not yet measured on macOS / Windows —+ the gap is expected there too, since the cause is platform-independent.++## Suspected Code Paths++- `src/native/nota.engine/src/Engine_Render.cpp:327-345` — `Engine::render` times `processBlock`+ with `steady_clock` and stores `elapsed / (numFrames / sr)`, smoothed 0.9/0.1, into `cpuLoad_`.+ This is a correct **DSP load** (render is single-threaded on the device callback), not process CPU.+- `src/native/nota.engine/src/nota_engine_core.cpp:107` → `NativeMethods.CpuLoad` →+ `NotaEngine.CpuLoad` (`src/managed/Nota.Infrastructure/Interop/NotaEngine.cs:248`) — plumbing.+- `src/managed/Nota.App/MainWindow.axaml:359-367` — the meter (`CpuMeter`/`CpuFill`/`CpuText`),+ no tooltip, comment says "live DSP load" but the label says "CPU".+- `src/managed/Nota.App/MainWindow.axaml.cs:298-301` — updates the meter on every+ `PlayheadUpdated` tick from `Engine.CpuLoad`; text `"CPU " + N + "%"`.+- `src/managed/Nota.Mcp/Tools/SettingsTools.cs:23-36` — `get_cpu_load` computes `ProcessCpu` as+ `TotalProcessorTime / (now − StartTime)`: a **lifetime average**, which barely moves after a few+ minutes and is useless as a live readout. Also allocates a `Process` per call.+- `src/managed/Nota.App/PreferencesWindow.cs:362-400` — Preferences → Audio "CPU check" also+ measures DSP load only (caption already says "audio-thread load", so it is honest).+- Device-card meta lines also print `CPU x %` from the global DSP load:+ `SamplerInstrumentCard.cs:562-563`, `RhythmInstrumentCard.cs:696`, `MosaicInstrumentCard.cs:1261`,+ `PendulumInstrumentCard.cs:174` — same mislabelling (and it is the whole engine's load, not the+ device's).++## Root Cause Hypothesis++Confidence: **high**. The DSP-load number itself is computed correctly; the defect is+presentation. The UI calls it "CPU" with no qualifier, and the process-wide figure the user is+comparing against is never shown live — the only implementation (MCP) averages since process+start. Note that the two numbers are different in kind: DSP load is "% of the real-time budget+used by the audio callback" (what predicts dropouts), process CPU is "% of CPU time used by all+threads" (what the OS shows). Neither can replace the other.++## Proposed Remediation++**Preferred**:++1. **Shared sampler for process CPU** — add a small, UI-agnostic `ProcessCpuSampler` (e.g. in+ `Nota.Infrastructure`, behind an interface in `Nota.Application` so MCP and App share it).+ It keeps one cached `Process` (`Process.GetCurrentProcess()` once), and on `Sample()` calls+ `Refresh()`, reads `TotalProcessorTime` and a `Stopwatch` timestamp, and returns+ `Δcpu / Δwall` over the window since the previous sample (EMA or a ~2–3 s window). Sample at+ ~1 Hz from a dedicated `DispatcherTimer`, **not** from the 30–60 Hz `PlayheadUpdated` tick+ (`Refresh()` + `/proc/self/stat` parse / `proc_pidinfo` / `GetProcessTimes` per frame is+ wasteful and makes the number jittery). Wrap in try/catch → `null` = "unavailable" rather+ than 0.+ `Process.TotalProcessorTime` is backed by `GetProcessTimes` (Windows), `/proc/self/stat`+ (Linux) and `proc_pidinfo`/`task_info` (macOS), so one managed code path covers all three; no+ new native ABI and no new dependency.++2. **Cross-platform normalization (the key decision)** — OS monitors disagree on scale:+ - Linux `top`/`htop`, GNOME System Monitor (default, "Irix mode"), macOS Activity Monitor and+ `top`: **% of one core** (can exceed 100 %).+ - Windows Task Manager / Resource Monitor: **% of the whole machine** (÷ logical CPUs, ≤ 100 %).+ Preferred: report raw core-% internally and **display in the platform's native convention**+ (`OperatingSystem.IsWindows()` → divide by `Environment.ProcessorCount`), so the number lines up+ with the monitor the user actually opens, and say which in the tooltip ("…of one core" /+ "…of all CPUs"). `Environment.ProcessorCount` honours affinity and cgroup limits on Linux,+ which is also what `top` effectively counts against.++3. **Name the meter for what it is** — transport: change the label to `DSP N%` (or keep the+ compact readout but rename) and add a tooltip that shows both figures, e.g.+ "Audio (DSP) load: 8 % of the buffer time — what causes dropouts · Nota process: 41 % of one+ core (UI, plugins, audio)". The bar colour keeps tracking DSP load (that is what drives+ dropouts). Rename the device-card meta `CPU x %` to `DSP x %`. Optionally add a "Process CPU"+ line to the Preferences → Audio "CPU check" result (average/peak over the same 5 s).++4. **MCP** — make `get_cpu_load` use the same sampler (recent window, not lifetime), and say in the+ description which normalization `ProcessCpu` uses (recommend: always % of one core in MCP, a+ stable machine-facing contract; add `LogicalCpus` so the client can rescale). Keep field names+ for compatibility.++**Alternatives**:+- *Always show % of the whole machine on every OS* — one consistent number, but on Linux/macOS it+ will be 8–16× lower than `top`/Activity Monitor and the issue will be re-reported.+- *Native implementation in the engine (C ABI `nota_engine_process_cpu`)* using+ `getrusage`/`GetProcessTimes` — no benefit over `Process.TotalProcessorTime`, adds ABI surface+ and three platform branches in C++. Not recommended.+- *Only relabel, no process figure* — cheapest, satisfies "says clearly what it measures", but+ leaves users without the number they compare against.++**Files likely to change**:+- `src/managed/Nota.Application/…` — `IProcessCpuSampler` (or similar) interface+- `src/managed/Nota.Infrastructure/…/ProcessCpuSampler.cs` — new+- `src/managed/Nota.App/MainWindow.axaml`, `MainWindow.axaml.cs` — label, tooltip, 1 Hz timer+- `src/managed/Nota.App/PreferencesWindow.cs` — optional process figure in "CPU check"+- `src/managed/Nota.App/DeviceCards/Instruments/{Sampler,Rhythm,Mosaic,Pendulum}InstrumentCard.cs` — `CPU` → `DSP`+- `src/managed/Nota.Mcp/Tools/SettingsTools.cs` — use the sampler, document units+- `CHANGELOG.md` [Unreleased] Fixed; docs (`nota-docs` transport/Preferences pages, EN + RU) via+ the `nota-docs` skill; `FEATURES.md` if the readout counts as a capability++**Tests to add or update**:+- Unit/smoke check for the sampler: busy-spin one thread for ~1 s between two samples → reading+ ≈ 100 % of one core (tolerance ±25 %); idle → near 0; never negative/NaN; first sample (no+ previous point) returns null/0 rather than a lifetime average. Run in `tests/Nota.SmokeTest`+ so it executes on all three CI platforms.+- Normalization test: core-% → display-% conversion for Windows vs. others (pure function, OS+ passed in, so it is testable on any host).+- Manual verification on each OS: play a project, compare tooltip process figure with+ `top`/GNOME System Monitor, Activity Monitor and Task Manager → Details; expect agreement within+ a few percent of the monitor's own convention.++## Risks & Considerations++- **macOS / Apple Silicon accuracy**: older .NET versions reported `TotalProcessorTime` on arm64+ macOS in Mach absolute-time ticks instead of ns (values off by ~41×). Believed fixed in current+ .NET, but this must be verified on an M-series Mac with .NET 10 against Activity Monitor before+ shipping; if wrong, convert via `mach_timebase_info` or fall back to `getrusage(RUSAGE_SELF)`.+- **Windows**: `Process.Refresh()`/`TotalProcessorTime` is cheap via `GetProcessTimes`, but+ `Process.StartTime`-style calls can be slow/throw for other processes; we only touch our own, so+ fine. Task Manager's "CPU" column on Windows 11 may use "CPU utility" (frequency-scaled) rather+ than "CPU time" — expect small differences; note in docs rather than chase.+- **Linux sandboxed builds (Flatpak/AppImage)**: `/proc/self/stat` is always available to the+ process itself; `ProcessorCount` reflects cgroup quotas — the readout is consistent with what the+ sandbox grants.+- **Child processes** (`nota-scanworker` plugin scanner) are not included in our process time —+ correct, OS monitors list them separately too.+- **Thread-safety / RT rules**: the sampler runs on the UI thread; nothing touches the audio thread.+ No allocations per tick if the `Process` instance is cached.+- **MCP contract**: changing `ProcessCpu` from lifetime to recent-window changes the value's+ meaning; keep the name, update the description, consider adding a `WindowSeconds` field.+- **Expectation management**: after the fix, users will see a large process figure (35–45 %) — the+ real cost is addressed by #55; the tooltip should not imply the high number is a problem with+ audio safety (DSP load is the dropout predictor).++## Open Questions++- [NEEDS CLARIFICATION: Should the compact transport readout show DSP load (dropout predictor,+ current behaviour) or process CPU (comparable to OS monitor)? Assessment assumes DSP stays in+ the bar, renamed "DSP", with process CPU in the tooltip.]+- [NEEDS CLARIFICATION: Platform-native normalization (Windows ÷ cores, macOS/Linux per-core) vs.+ one convention everywhere? Assessment recommends platform-native.]+- [NEEDS CLARIFICATION: Nota version for the report — not stated; does not change the analysis.]diff --git a/.specify/bugs/cpu-meter-dsp-only/fix.md b/.specify/bugs/cpu-meter-dsp-only/fix.mdnew file mode 100644index 00000000..9d0d32d9--- /dev/null+++ b/.specify/bugs/cpu-meter-dsp-only/fix.md@@ -0,0 +1,110 @@+# Bug Fix: CPU meter shows DSP load only, far below the OS process figure++- **Slug**: cpu-meter-dsp-only+- **Fixed**: 2026-10-15+- **Assessment**: ./assessment.md+- **Status**: applied++## Summary++The transport meter is now labelled **DSP** (the bar still tracks DSP load). Its tooltip adds+the whole process's CPU over a recent window. Windows shows it as a percent of all CPUs, like+Task Manager; macOS and Linux show it as a percent of one core, like Activity Monitor,+`top` and GNOME System Monitor. The transport and MCP `get_cpu_load` share one sampler,+so MCP no longer reports a lifetime average.++Maintainer decisions applied (2026-10-15): platform-native normalization; the bar stays DSP.++## Changes++| File | Change | Notes |+|------|--------|-------|+| `src/managed/Nota.Application/Ports/IProcessCpu.cs` | added | `IProcessCpu` port (`CorePercent()`, `LogicalCpus`) + `ProcessCpuScale` (platform display scale, unit text) |+| `src/managed/Nota.Infrastructure/Logging/ProcessCpuSampler.cs` | added | Δ`Environment.CpuUsage.TotalTime` ÷ Δwall, 0.5 s step, 2 s time-based EMA; injectable clocks; null on failure |+| `src/managed/Nota.App/App.axaml.cs` | modified | registers `IProcessCpu` singleton |+| `src/managed/Nota.App/MainWindow.axaml` | modified | `CPU 0%` → `DSP 0%`; transparent background so the tooltip hit-tests the whole meter |+| `src/managed/Nota.App/MainWindow.axaml.cs` | modified | label `DSP N%`; `SetUpCpuTip` builds the two-line tooltip, refreshed from the transport tick at ≤ 1 Hz |+| `src/managed/Nota.App/DeviceCards/Instruments/{Sampler,Rhythm,Mosaic,Pendulum}InstrumentCard.cs` | modified | meta line `CPU x %` → `DSP x %` (these show the global engine load) |+| `src/managed/Nota.Mcp/Tools/SettingsTools.cs` | modified | `get_cpu_load` uses the shared sampler: `ProcessCpu` = recent window, % of one core on every OS, `double?` (null while measuring), new `LogicalCpus` |+| `src/managed/Nota.App/Mcp/McpAppServices.cs` | modified | shares `IProcessCpu` with the MCP container |+| `tests/Nota.SmokeTest/ProcessCpuTests.cs` | added test | 12 checks, see below |+| `tests/Nota.SmokeTest/Program.cs` | modified | runs `ProcessCpuTests` in the full run and alone via `--cpu` |+| `CHANGELOG.md` | modified | [Unreleased] → Fixed entry |++## Diff Highlights++```csharp+// ProcessCpuSampler.CorePercent()+double instant = Math.Max(0, (cpu - _lastCpu).TotalSeconds) / dWall.TotalSeconds * 100.0;+double alpha = 1.0 - Math.Exp(-dWall.TotalSeconds / Smoothing.TotalSeconds);+_value = _value is { } prev ? prev + (instant - prev) * alpha : instant;++// ProcessCpuScale+public static bool WholeMachine => OperatingSystem.IsWindows();+public static double ToDisplay(double corePercent, int logicalCpus, bool wholeMachine) =>+ wholeMachine ? corePercent / Math.Max(1, logicalCpus) : corePercent;+```++Tooltip text (macOS, as captured):++```+DSP load: 3 % of the audio buffer time — dropouts start near 100 %+Nota process CPU: 32 % of one core (audio, interface, plugins)+```++## Tests Added or Updated++`tests/Nota.SmokeTest/ProcessCpuTests.cs` (`-- process cpu --`, `--cpu`):+- Injected clocks: null before the first window; 0.5 s CPU / 1 s wall = 50 %; reads within the step+ return the cached value; a jump to 200 % is smoothed; after 18 s idle the reading is near 0+ (recent window, not a lifetime average); a backwards counter never reads negative; a throwing OS+ reading gives null and no exception.+- Scale: Windows 400 % on 8 CPUs → 50 %; macOS/Linux 400 % → 400 %; zero CPU count is guarded;+ `WholeMachine` is true only on Windows.+- Real clocks: one thread busy for 1.5 s reads 60 %…(100 × CPUs + 50) % of one core. This runs on+ every CI platform and would catch wrong units from the OS counter.++## Local Verification++- `dotnet run --project tests/Nota.SmokeTest -- --cpu` → CPU PASSED (12/12; busy loop 105.8 % on macOS arm64).+- `scripts/build.sh` (twice, the second after the tooltip refactor) → exit 0, SMOKE TEST PASSED, 3414 checks;+ busy loop 114–115 % of one core in the full run.+- Headless harness `/tmp/cpumeterharness` (real MainWindow + VM ticks driven by reflection, 12 s):+ label `DSP 3%`, the tooltip refreshed 11× in 12 s (about 1 Hz), and the tooltip figure was 32 % vs. 31 % from an independent+ `Process.TotalProcessorTime` measurement over the last 3 s. The transport capture shows "DSP 3%" in+ the same slot with no layout shift.+- **Not verified**: Linux and Windows runs (only macOS arm64 here), and a tooltip render (popups do not+ render headless; the text was read from `ToolTip.GetTip`).++## Deviations from Assessment++- **API**: `Environment.CpuUsage` (.NET 9+) replaces `Process.TotalProcessorTime`. On Windows it+ calls `GetProcessTimes`, on Linux and macOS `getrusage(RUSAGE_SELF)`. It avoids the per-read+ `Process` allocation and the Apple Silicon Mach-tick units risk the assessment flagged. The real-clock+ test pins the units on each platform.+- **Refresh source**: the assessment proposed a dedicated 1 Hz `DispatcherTimer`. The tooltip now+ refreshes from the existing transport tick (`PlayheadUpdated`), throttled to 1 Hz with a+ `Stopwatch`. This is one fewer timer, and it means the tooltip is refreshed exactly when the meter is.+ The harness showed the separate timer never firing headless, which hid the refresh path from testing.+- **MCP `ProcessCpu`** became `double?` (null while the first window is measuring) and gained+ `LogicalCpus`. The field names are kept.+- **Optional items not done**: no process figure was added to Preferences → Audio "CPU check". Its caption+ already says "audio-thread load".++## Merge with #66 (Less CPU while idle)++On top of #66 the meter keeps #66's redraw-only-on-change (`pct != cpuShown`), with the+label changed to DSP. The tooltip is re-set only when its text changes, and it is skipped+with the rest of the tick while the window is minimized. After the merge: `scripts/build.sh` →+SMOKE TEST PASSED (3420 checks). The harness shows the tooltip at 22 % vs. an independent 20 %.++## Follow-ups++- Run `scripts/build-linux.sh` / Windows sibling (or CI) so the real-clock test runs on Linux x86_64+ and Windows. Manually compare the tooltip with GNOME System Monitor / Task Manager → Details.+- 18 effect/instrument cards (Consort, Pentad, Compressor, Reverb, …) still say `CPU x %` for their+ **own** per-device audio-thread share. That figure is honest, but the same kind of number is+ now called "DSP" on the transport. Decide on one term across cards.+- Docs: transport/meter description in `nota-docs` (EN + RU) via the `nota-docs` skill, and the MCP+ tool reference if it lists `get_cpu_load` fields.+- Actual process CPU cost is tracked in #55.diff --git a/.specify/bugs/cpu-meter-dsp-only/test.md b/.specify/bugs/cpu-meter-dsp-only/test.mdnew file mode 100644index 00000000..1defad08--- /dev/null+++ b/.specify/bugs/cpu-meter-dsp-only/test.md@@ -0,0 +1,69 @@+# Bug Verification: CPU meter shows DSP load only, far below the OS process figure++- **Slug**: cpu-meter-dsp-only+- **Tested**: 2026-10-15+- **Assessment**: ./assessment.md+- **Fix**: ./fix.md+- **Result**: partial++## Summary++On macOS arm64 the fix holds. The meter now reads "DSP", and the tooltip and MCP report the+process CPU. Those figures agree with an independent measurement and roughly with `top`. Before+the fix, the only figure was the 3–4 % DSP load labelled "CPU". The full smoke suite passes. The+result is **partial** because the bug was reported on Linux and nothing was run on Linux or Windows.+The tooltip popup itself was also not seen rendered: its text was read programmatically.++## Checks Performed++| Check | Command / Action | Result | Notes |+|-------|------------------|--------|-------|+| New tests | `dotnet run --project tests/Nota.SmokeTest -- --cpu` | pass | 12/12, CPU PASSED; busy loop 106.7 % of one core (macOS Arm64, 14 CPUs) |+| Reproduction (post-fix), app UI | headless harness `/tmp/cpumeterharness`: real `MainWindow`, VM `OnTick` driven for 12 s | pass | label `DSP 4%`; tooltip refreshed 13× in 12 s; tooltip process CPU 32 % vs. independent `Process.TotalProcessorTime` over the last 3 s: 32 % |+| Reproduction (post-fix), vs. OS monitor | same harness runs `top -l 2 -s 2 -pid <self>` while ticking | pass (approx.) | `top` 25.9 %, sampler 33 %. The windows differ (top: 2 s sample; sampler: 2 s EMA that also covers the moment before top's window). Same order of magnitude, unlike the 4 % DSP figure |+| MCP path | harness calls `SettingsTools.GetCpuLoad()` with the shared sampler | pass | `DspLoad=0.035 ProcessCpu=32.4 LogicalCpus=14`: a recent window, not a lifetime average |+| Transport layout | harness capture of the full window | pass | "DSP 3%" in the same slot, no shift |+| Regression suite | `scripts/build.sh` (native + managed build + full smoke test) | pass | exit 0, SMOKE TEST PASSED, 3414 checks. Last run at 17:05 on the final fix code; no fix file changed since |+| Linux x86_64 (reporter's platform) | — | not-run | no Linux host in this session |+| Windows (whole-machine scale) | — | not-run | no Windows host; the scale is covered only by the pure-function test |+| Tooltip visual | — | not-run | popups don't render headless; text read via `ToolTip.GetTip` |++## Output Excerpts++```+-- process cpu --+ [PASS] a one-core busy loop reads about 100 % of one core on macOS Arm64 (got 106,7 %, 14 CPUs)+CPU PASSED+```++```+independent, last 3 s: 32 % of one core+label: DSP 4%+tip: DSP load: 4 % of the audio buffer time — dropouts start near 100 %+ Nota process CPU: 32 % of one core (audio, interface, plugins)+mcp get_cpu_load: DspLoad=0.035 ProcessCpu=32.4 LogicalCpus=14+top (2nd sample): 66785 25.9+```++```+SMOKE TEST PASSED+==> Done.+```++## Residual Risks++- **Linux**: the reporter's platform. `Environment.CpuUsage` reads `getrusage` there, the same call as on+ macOS, so the risk is low, but this is unverified. The real-clock test will run on the Linux CI job.+- **Windows**: the percent-of-all-CPUs scale and `GetProcessTimes` are unverified on a real host.+ Compare with Task Manager → Details. Note that Windows 11 Task Manager may show "CPU utility",+ which is frequency-scaled, so small differences are expected.+- **Headless timing**: harness ticks are driven manually; the real app's tick cadence is not exercised here.+- **Unrelated working-tree changes**: `src/managed/Nota.Remote/wwwroot/index.html` and its hashed+ `assets/*` were rebuilt at 17:10, after the last build. This was not done by this fix, most likely+ by the docs screenshot harness. Review or revert them before committing so they don't ride along.++## Recommendation++Merge after review. Close #54 once the Linux CI run is green (the real-clock test passes there).+Ideally also do a quick manual comparison with GNOME System Monitor and with Task Manager →+Details on Windows. On macOS the fix is verified end-to-end.diff --git a/CHANGELOG.md b/CHANGELOG.mdindex ed53ac02..481b0558 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -82,6 +82,12 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.chain.### Fixed+- **The transport meter says what it measures:** it read "CPU" but showed only the audio+ engine's load, so it sat far below the system monitor. It is now labelled **DSP** — the+ share of each audio buffer the engine needs, which is what causes dropouts — and its+ tooltip adds the CPU used by the whole Nota process over the last few seconds, in the+ same scale as your system monitor (Windows: of all CPUs; macOS and Linux: of one core).+ Instrument cards that showed the engine load now say DSP too.- **Less CPU while idle:** Nota no longer redraws its meters, playhead and CPU read-out~30 times a second when nothing on them has changed. It skips them entirely while thewindow is minimized, and on Linux the plug-in message pump slows down when no plug-indiff --git a/src/managed/Nota.App/App.axaml.cs b/src/managed/Nota.App/App.axaml.csindex 27e241cd..444b2655 100644--- a/src/managed/Nota.App/App.axaml.cs+++ b/src/managed/Nota.App/App.axaml.cs@@ -58,6 +58,7 @@ public partial class App : Avalonia.Applicationservices.AddSingleton<GamepadService>();services.AddSingleton<IGamepadService>(sp => sp.GetRequiredService<GamepadService>());services.AddSingleton<IAudioExporter, AudioExporter>();+ services.AddSingleton<IProcessCpu, ProcessCpuSampler>();// UI-thread timer factory lives in the App layer (over DispatcherTimer).services.AddSingleton<IPeriodicTimerFactory, AvaloniaPeriodicTimerFactory>();services.AddSingleton<RecoveryService>();diff --git a/src/managed/Nota.App/DeviceCards/Instruments/MosaicInstrumentCard.cs b/src/managed/Nota.App/DeviceCards/Instruments/MosaicInstrumentCard.csindex d8da4840..95e787b6 100644--- a/src/managed/Nota.App/DeviceCards/Instruments/MosaicInstrumentCard.cs+++ b/src/managed/Nota.App/DeviceCards/Instruments/MosaicInstrumentCard.cs@@ -1258,7 +1258,7 @@ internal sealed class MosaicInstrumentCard : IInstrumentCardsamSnap.Note = snap.Note; samSnap.CutoffHz = snap.CutoffHz; samSnap.PlayPos = snap.Pos;map.SetSounding(snap.Zones, snap.Keys);if (tab == 1) wave.SetPlayhead(snap.Live && snap.Zone == ui.Zone ? snap.Pos : -1);- meta.Text = $"{Rate()} · {snap.Voices}/{Poly()} voices · CPU {NotaNum.Unit(engine.CpuLoad * 100, "0.0", "%")}";+ meta.Text = $"{Rate()} · {snap.Voices}/{Poly()} voices · DSP {NotaNum.Unit(engine.CpuLoad * 100, "0.0", "%")}";bool ld = Loading(), miss = AllMissing();if (ld != lastLoading || miss != lastMissing){diff --git a/src/managed/Nota.App/DeviceCards/Instruments/PendulumInstrumentCard.cs b/src/managed/Nota.App/DeviceCards/Instruments/PendulumInstrumentCard.csindex 5a54f2d2..865be8e4 100644--- a/src/managed/Nota.App/DeviceCards/Instruments/PendulumInstrumentCard.cs+++ b/src/managed/Nota.App/DeviceCards/Instruments/PendulumInstrumentCard.cs@@ -171,7 +171,7 @@ internal sealed class PendulumInstrumentCard : IInstrumentCardint voices = snap.Live ? snap.Voices : Math.Max(0, engine.InstrumentVoiceCount(track));lastNote.Text = $"last note {PendulumModel.NoteName(snap.LastPitch)} · {voices} {(voices == 1 ? "voice" : "voices")}";double sr = engine.SampleRate > 0 ? engine.SampleRate : 48000;- meta.Text = $"{voices}/{PendulumModel.Voices} voices · {NotaNum.Unit(sr / 1000, "0.#", "kHz")} · {NotaNum.Bpm(engine.Bpm)} BPM · CPU {NotaNum.Unit(engine.CpuLoad * 100, "0.0", "%")}";+ meta.Text = $"{voices}/{PendulumModel.Voices} voices · {NotaNum.Unit(sr / 1000, "0.#", "kHz")} · {NotaNum.Bpm(engine.Bpm)} BPM · DSP {NotaNum.Unit(engine.CpuLoad * 100, "0.0", "%")}";status.Text = Summary();}diff --git a/src/managed/Nota.App/DeviceCards/Instruments/RhythmInstrumentCard.cs b/src/managed/Nota.App/DeviceCards/Instruments/RhythmInstrumentCard.csindex 047575b2..04fdfc10 100644--- a/src/managed/Nota.App/DeviceCards/Instruments/RhythmInstrumentCard.cs+++ b/src/managed/Nota.App/DeviceCards/Instruments/RhythmInstrumentCard.cs@@ -693,7 +693,7 @@ internal sealed class RhythmInstrumentCard : IInstrumentCard}int voices = Math.Max(0, engine.InstrumentVoiceCount(track));double sr = engine.SampleRate > 0 ? engine.SampleRate : 48000;- meta.Text = $"{voices}/{RM.Voices} voices · {NotaNum.Unit(sr / 1000, "0.#", "kHz")} · {NotaNum.Bpm(engine.Bpm)} BPM · CPU {NotaNum.Unit(engine.CpuLoad * 100, "0.0", "%")}";+ meta.Text = $"{voices}/{RM.Voices} voices · {NotaNum.Unit(sr / 1000, "0.#", "kHz")} · {NotaNum.Bpm(engine.Bpm)} BPM · DSP {NotaNum.Unit(engine.CpuLoad * 100, "0.0", "%")}";}// ---- assembly --------------------------------------------------------------------------diff --git a/src/managed/Nota.App/DeviceCards/Instruments/SamplerInstrumentCard.cs b/src/managed/Nota.App/DeviceCards/Instruments/SamplerInstrumentCard.csindex 42c3f8d8..cae25b57 100644--- a/src/managed/Nota.App/DeviceCards/Instruments/SamplerInstrumentCard.cs+++ b/src/managed/Nota.App/DeviceCards/Instruments/SamplerInstrumentCard.cs@@ -559,8 +559,8 @@ internal sealed class SamplerInstrumentCard : IInstrumentCardint voices = snap.Live ? snap.Voices : 0;double esr = engine.SampleRate > 0 ? engine.SampleRate : 48000;meta.Text = hasSample- ? $"{NotaNum.Unit(esr / 1000, "0.#", "kHz")} · {NotaNum.Unit(durSec, "0.00", "s")} sample · {voices}/{SamplerModel.Voices} voices · CPU {NotaNum.Unit(engine.CpuLoad * 100, "0.0", "%")}"- : $"{NotaNum.Unit(esr / 1000, "0.#", "kHz")} · CPU {NotaNum.Unit(engine.CpuLoad * 100, "0.0", "%")}";+ ? $"{NotaNum.Unit(esr / 1000, "0.#", "kHz")} · {NotaNum.Unit(durSec, "0.00", "s")} sample · {voices}/{SamplerModel.Voices} voices · DSP {NotaNum.Unit(engine.CpuLoad * 100, "0.0", "%")}"+ : $"{NotaNum.Unit(esr / 1000, "0.#", "kHz")} · DSP {NotaNum.Unit(engine.CpuLoad * 100, "0.0", "%")}";Refresh();}registerTick(Live);diff --git a/src/managed/Nota.App/MainWindow.axaml b/src/managed/Nota.App/MainWindow.axamlindex 33c8f860..d43f0c0d 100644--- a/src/managed/Nota.App/MainWindow.axaml+++ b/src/managed/Nota.App/MainWindow.axaml@@ -356,14 +356,14 @@<Border x:Name="CpuSep" Grid.Column="7" Width="1" Height="18" Margin="10,0"Background="{DynamicResource Brush.Rule}"/>- <!-- CPU: live DSP load -->- <StackPanel x:Name="CpuMeter" Grid.Column="8" Spacing="3" VerticalAlignment="Center">+ <!-- DSP load (audio-callback time ÷ buffer); the tooltip adds process CPU (MainWindow.SetUpCpuTip) -->+ <StackPanel x:Name="CpuMeter" Grid.Column="8" Spacing="3" VerticalAlignment="Center" Background="Transparent"><Border Width="52" Height="4" Background="{DynamicResource Brush.BgSunken}"CornerRadius="{StaticResource Radius.Clip}" ClipToBounds="True"><Border x:Name="CpuFill" Width="0" HorizontalAlignment="Left" CornerRadius="{StaticResource Radius.Clip}"Background="{DynamicResource Brush.Success}"/></Border>- <TextBlock x:Name="CpuText" Classes="Mono CellLabel" Text="CPU 0%" FontWeight="Normal"/>+ <TextBlock x:Name="CpuText" Classes="Mono CellLabel" Text="DSP 0%" FontWeight="Normal"/></StackPanel><!-- Master: fader over its meter, with the gain in dB -->diff --git a/src/managed/Nota.App/MainWindow.axaml.cs b/src/managed/Nota.App/MainWindow.axaml.csindex 0c2f95ed..0d1fd6bd 100644--- a/src/managed/Nota.App/MainWindow.axaml.cs+++ b/src/managed/Nota.App/MainWindow.axaml.cs@@ -307,8 +307,9 @@ public partial class MainWindow : WindowcpuShown = pct;CpuFill.Width = pct * 0.52;CpuFill.Background = pct > 90 ? cpuRed : pct > 70 ? cpuAmber : cpuGreen;- CpuText.Text = "CPU " + pct + "%";+ CpuText.Text = "DSP " + pct + "%";}+ _cpuTipTick?.Invoke();SyncMidiDot();};// Recording tick fires ~60 Hz: refresh clip data + lane drawing only, WITHOUT@@ -459,6 +460,7 @@ public partial class MainWindow : WindowReleaseTextFocusOnOutsidePress(this);Closed += (_, _) => vm.Dispose();+ SetUpCpuTip(vm.Engine);// MCP server: MCP tool edits redraw the arrangement + device panel; start the server if// enabled in Preferences (loopback only). Runs off the settings toggle thereafter.@@ -640,6 +642,34 @@ public partial class MainWindow : Windowf.ShowAt(MetronomeBtn);}+ // The transport meter shows DSP load (what predicts dropouts); its tooltip adds the whole+ // process's CPU in the platform monitor's own scale (issue #54). Refreshed from the+ // transport tick, at most once a second.+ private Action? _cpuTipTick;++ private void SetUpCpuTip(IAudioEngine engine)+ {+ var cpu = App.Services.GetRequiredService<IProcessCpu>();+ bool wholeMachine = ProcessCpuScale.WholeMachine;+ var clock = System.Diagnostics.Stopwatch.StartNew();+ var next = TimeSpan.Zero;+ string? shown = null;+ _cpuTipTick = () =>+ {+ if (clock.Elapsed < next) return;+ next = clock.Elapsed + TimeSpan.FromSeconds(1);+ double dsp = Math.Clamp(engine.CpuLoad, 0, 1) * 100;+ string proc = cpu.CorePercent() is { } core+ ? NotaNum.Unit(ProcessCpuScale.ToDisplay(core, cpu.LogicalCpus, wholeMachine), "0", "%")+ + " " + ProcessCpuScale.Unit(wholeMachine)+ : "measuring…";+ string tip = $"DSP load: {NotaNum.Unit(dsp, "0", "%")} of the audio buffer time — dropouts start near 100\u2009%\n"+ + $"Nota process CPU: {proc} (audio, interface, plugins)";+ if (tip != shown) ToolTip.SetTip(CpuMeter, shown = tip); // re-set only when it changed (#66)+ };+ _cpuTipTick();+ }+private readonly TapTempo _tap = new();private readonly System.Diagnostics.Stopwatch _tapClock = System.Diagnostics.Stopwatch.StartNew();private DispatcherTimer? _tapIdle;diff --git a/src/managed/Nota.App/Mcp/McpAppServices.cs b/src/managed/Nota.App/Mcp/McpAppServices.csindex 4f1dcf01..10be940a 100644--- a/src/managed/Nota.App/Mcp/McpAppServices.cs+++ b/src/managed/Nota.App/Mcp/McpAppServices.cs@@ -91,7 +91,8 @@ public sealed class McpService(IPluginCatalog pluginCatalog, IFactoryPresets factoryPresets, IPresetStore presetStore, IPresetLibrary presetLibrary,IAudioExporter exporter, IMidiDeviceService midiDevices, MidiLearnService midiLearn, IDrumKits drumKits,ProjectVersionsBridge projectVersions, IProjectHistory projectHistory, IModelStore models, IClipAi clipAi,- ISampleIndex sampleIndex, Nota.Presentation.TransportViewModel transport, IMosaicPacks mosaicPacks)+ ISampleIndex sampleIndex, Nota.Presentation.TransportViewModel transport, IMosaicPacks mosaicPacks,+ IProcessCpu processCpu){private readonly NotaMcpServer _server = new();@@ -116,6 +117,7 @@ public sealed class McpService(s.AddSingleton(clipAi);s.AddSingleton(sampleIndex);s.AddSingleton(mosaicPacks);+ s.AddSingleton(processCpu);s.AddSingleton<IProjectKeyAccess>(new ProjectKeyAccess(transport));}diff --git a/src/managed/Nota.Application/Ports/IProcessCpu.cs b/src/managed/Nota.Application/Ports/IProcessCpu.csnew file mode 100644index 00000000..ca5281fc--- /dev/null+++ b/src/managed/Nota.Application/Ports/IProcessCpu.cs@@ -0,0 +1,34 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.++namespace Nota.Application;++/// <summary>CPU used by the whole Nota process (all threads: audio, UI, rendering, plugins) over+/// a recent window — what the OS system monitor shows, as opposed to the engine's DSP load+/// (audio-callback time ÷ buffer length). Implemented in Infrastructure; read on the UI thread.</summary>+public interface IProcessCpu+{+ /// <summary>Recent process CPU in percent of ONE core (can exceed 100 on multi-core machines),+ /// smoothed over a few seconds. Null until the first window has elapsed, or if the OS+ /// reading is unavailable. Cheap: calls closer together than the sampling step return the+ /// cached value, so several readers (transport, MCP) can share one instance.</summary>+ double? CorePercent();++ /// <summary>Logical CPUs available to the process (honours affinity / cgroup limits).</summary>+ int LogicalCpus { get; }+}++/// <summary>Converts a per-core CPU figure into the scale the platform's own monitor uses, so+/// Nota's readout lines up with it: Windows Task Manager shows percent of the whole machine;+/// macOS Activity Monitor, <c>top</c>/<c>htop</c> and GNOME System Monitor show percent of one core.</summary>+public static class ProcessCpuScale+{+ /// <summary>True where the platform monitor shows percent of all CPUs (Windows).</summary>+ public static bool WholeMachine => OperatingSystem.IsWindows();++ public static double ToDisplay(double corePercent, int logicalCpus, bool wholeMachine) =>+ wholeMachine ? corePercent / Math.Max(1, logicalCpus) : corePercent;++ /// <summary>What a displayed figure is a percentage of, for tooltips.</summary>+ public static string Unit(bool wholeMachine) => wholeMachine ? "of all CPUs" : "of one core";+}diff --git a/src/managed/Nota.Infrastructure/Logging/ProcessCpuSampler.cs b/src/managed/Nota.Infrastructure/Logging/ProcessCpuSampler.csnew file mode 100644index 00000000..5a0c0e2a--- /dev/null+++ b/src/managed/Nota.Infrastructure/Logging/ProcessCpuSampler.cs@@ -0,0 +1,65 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Process CPU over a recent window (issue #54). Uses Environment.CpuUsage: GetProcessTimes on+// Windows, getrusage(RUSAGE_SELF) on Linux and macOS — no Process object, no allocation per+// read, and correct units on Apple Silicon. The figure is Δ(process CPU time) ÷ Δ(wall time),+// i.e. percent of one core, smoothed with a time-based moving average.++using System.Diagnostics;+using Nota.Application;++namespace Nota.Infrastructure;++public sealed class ProcessCpuSampler : IProcessCpu+{+ /// <summary>Reads closer together than this return the cached value.</summary>+ public static readonly TimeSpan Step = TimeSpan.FromMilliseconds(500);+ /// <summary>Smoothing time constant: the readout settles over a few seconds, like a monitor.</summary>+ public static readonly TimeSpan Smoothing = TimeSpan.FromSeconds(2);++ private readonly Func<TimeSpan> _cpuTime;+ private readonly Func<TimeSpan> _wallTime;+ private TimeSpan _lastCpu, _lastWall;+ private double? _value;+ private bool _failed;++ public ProcessCpuSampler() : this(() => Environment.CpuUsage.TotalTime, StopwatchClock()) { }++ /// <summary>Clocks injected for tests: process CPU time and a monotonic wall clock.</summary>+ public ProcessCpuSampler(Func<TimeSpan> cpuTime, Func<TimeSpan> wallTime)+ {+ _cpuTime = cpuTime;+ _wallTime = wallTime;+ try { _lastCpu = _cpuTime(); }+ catch { _failed = true; }+ _lastWall = _wallTime();+ }++ public int LogicalCpus => Environment.ProcessorCount;++ public double? CorePercent()+ {+ if (_failed) return null;+ var wall = _wallTime();+ var dWall = wall - _lastWall;+ if (dWall < Step) return _value;+ TimeSpan cpu;+ try { cpu = _cpuTime(); }+ catch { _failed = true; return _value = null; }++ // CPU time never runs backwards; clamp in case an OS counter hiccups.+ double instant = Math.Max(0, (cpu - _lastCpu).TotalSeconds) / dWall.TotalSeconds * 100.0;+ double alpha = 1.0 - Math.Exp(-dWall.TotalSeconds / Smoothing.TotalSeconds);+ _value = _value is { } prev ? prev + (instant - prev) * alpha : instant;+ _lastCpu = cpu;+ _lastWall = wall;+ return _value;+ }++ private static Func<TimeSpan> StopwatchClock()+ {+ var sw = Stopwatch.StartNew();+ return () => sw.Elapsed;+ }+}diff --git a/src/managed/Nota.Mcp/Tools/SettingsTools.cs b/src/managed/Nota.Mcp/Tools/SettingsTools.csindex b73b6135..b66e2664 100644--- a/src/managed/Nota.Mcp/Tools/SettingsTools.cs+++ b/src/managed/Nota.Mcp/Tools/SettingsTools.cs@@ -11,29 +11,21 @@ using Nota.Application;namespace Nota.Mcp.Tools;[McpServerToolType]-public sealed class SettingsTools(IAudioEngine engine, IEngineDispatch dispatch, IArrangementRefresh refresh)+public sealed class SettingsTools(IAudioEngine engine, IEngineDispatch dispatch, IArrangementRefresh refresh,+ IProcessCpu? processCpu = null): EngineTools(engine, dispatch, refresh){public sealed record EngineInfo(double SampleRate, int Xruns, int SceneCount);- public sealed record CpuLoadInfo(float DspLoad, double ProcessCpu);+ public sealed record CpuLoadInfo(float DspLoad, double? ProcessCpu, int LogicalCpus);[McpServerTool(Name = "get_engine_info"), Description("Read engine status: sample rate, audio dropout (xrun) count, session scene count.")]public Task<EngineInfo> GetEngineInfo() => Read(() => new EngineInfo(E.SampleRate, E.XrunCount, E.SceneCount));- [McpServerTool(Name = "get_cpu_load"), Description("Read CPU load: DSP load (0..1, engine-side audio thread) and this process's total CPU usage (percent, from the OS).")]- public Task<CpuLoadInfo> GetCpuLoad() => Read(() =>- {- float dsp = Math.Clamp(E.CpuLoad, 0f, 1f);- double proc = 0;- try- {- using var p = System.Diagnostics.Process.GetCurrentProcess();- p.Refresh();- proc = p.TotalProcessorTime.TotalSeconds / (DateTime.UtcNow - p.StartTime.ToUniversalTime()).TotalSeconds * 100.0;- }- catch { }- return new CpuLoadInfo(dsp, proc);- });+ [McpServerTool(Name = "get_cpu_load"), Description("Read CPU load. DspLoad: audio-callback time / buffer length (0..1; dropouts near 1). " ++ "ProcessCpu: the whole Nota process's CPU over the last few seconds, in percent of ONE core on every OS " ++ "(can exceed 100; divide by LogicalCpus for percent of the whole machine, as Windows Task Manager shows); null while still measuring.")]+ public Task<CpuLoadInfo> GetCpuLoad() => Read(() => new CpuLoadInfo(+ Math.Clamp(E.CpuLoad, 0f, 1f), processCpu?.CorePercent(), processCpu?.LogicalCpus ?? Environment.ProcessorCount));[McpServerTool(Name = "preview_file"), Description("Audition an audio file (WAV/FLAC/MP3) through the master, without adding it to the project.")]public Task PreviewFile(string path) => Mutate(() => E.PreviewFile(path));diff --git a/tests/Nota.SmokeTest/ProcessCpuTests.cs b/tests/Nota.SmokeTest/ProcessCpuTests.csnew file mode 100644index 00000000..0eb2331e--- /dev/null+++ b/tests/Nota.SmokeTest/ProcessCpuTests.cs@@ -0,0 +1,74 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.+//+// Process CPU readout (.specify/bugs/cpu-meter-dsp-only, issue #54): the sampler reports a+// recent window, not a lifetime average; it never goes negative or throws; the display scale+// follows the platform monitor (Windows: of all CPUs, macOS/Linux: of one core); and a real+// one-core busy loop reads about 100 % of one core on whichever OS the smoke test runs on.+// Also runnable alone: `dotnet run --project tests/Nota.SmokeTest -- --cpu`.++using System.Diagnostics;+using Nota.Application;+using Nota.Infrastructure;++namespace Nota.SmokeTest;++internal static class ProcessCpuTests+{+ public static IEnumerable<(bool Ok, string Label)> Run()+ {+ // --- deterministic: injected clocks ---+ var cpu = TimeSpan.Zero; var wall = TimeSpan.Zero;+ var s = new ProcessCpuSampler(() => cpu, () => wall);+ wall = TimeSpan.FromMilliseconds(200);+ yield return (s.CorePercent() is null, "no reading before the first window has elapsed");++ cpu = TimeSpan.FromSeconds(0.5); wall = TimeSpan.FromSeconds(1);+ double? first = s.CorePercent();+ yield return (first is { } f && Math.Abs(f - 50) < 1e-9, $"0.5 s CPU over 1 s wall reads 50 % of one core (got {first})");++ cpu = TimeSpan.FromSeconds(0.9); wall = TimeSpan.FromSeconds(1.2);+ yield return (s.CorePercent() == first, "reads closer than the step return the cached value");++ // 2 s of CPU over the next 1 s (two busy cores): the readout moves toward 200 but is smoothed.+ cpu = TimeSpan.FromSeconds(2.5); wall = TimeSpan.FromSeconds(2);+ double? second = s.CorePercent();+ yield return (second is > 50 and < 200, $"a jump to 200 % is smoothed, not instant (got {second})");++ // Recent window, not lifetime: after a long idle stretch the reading falls toward 0.+ for (int i = 3; i <= 20; i++) { wall = TimeSpan.FromSeconds(i); s.CorePercent(); }+ double? idle = s.CorePercent();+ yield return (idle is < 1, $"after 18 s idle the reading is near 0, not a lifetime average (got {idle})");++ // An OS counter that steps backwards clamps to 0 instead of going negative.+ cpu = TimeSpan.FromSeconds(1); wall = TimeSpan.FromSeconds(21);+ double? back = s.CorePercent();+ yield return (back is >= 0, $"a backwards CPU counter never reads negative (got {back})");++ // An unavailable OS reading yields null, never an exception.+ var broken = new ProcessCpuSampler(() => throw new PlatformNotSupportedException(), () => wall);+ wall += TimeSpan.FromSeconds(1);+ yield return (broken.CorePercent() is null, "an unavailable OS reading gives null, no exception");++ // --- display scale ---+ yield return (ProcessCpuScale.ToDisplay(400, 8, wholeMachine: true) == 50, "Windows scale: 400 % of one core on 8 CPUs shows 50 %");+ yield return (ProcessCpuScale.ToDisplay(400, 8, wholeMachine: false) == 400, "macOS/Linux scale: 400 % of one core shows 400 %");+ yield return (ProcessCpuScale.ToDisplay(80, 0, wholeMachine: true) == 80, "a zero CPU count can't divide by zero");+ yield return (ProcessCpuScale.WholeMachine == OperatingSystem.IsWindows(), "whole-machine scale only on Windows");++ // --- real clocks: one thread busy for ~1.5 s ≈ 100 % of one core on this OS ---+ // Catches wrong units from the OS counter (e.g. Mach ticks on Apple Silicon would read+ // tens of times too high or low). Loose bounds: runtime threads (GC, JIT) add a little.+ var real = new ProcessCpuSampler();+ var sw = Stopwatch.StartNew();+ double spin = 0;+ while (sw.Elapsed < TimeSpan.FromSeconds(1.5)) spin += Math.Sqrt(spin + 1);+ double? busy = real.CorePercent();+ double ceiling = 100.0 * Environment.ProcessorCount + 50;+ yield return (busy is >= 60 && busy <= ceiling && spin > 0,+ $"a one-core busy loop reads about 100 % of one core on {RuntimeInformationOs()} (got {busy:0.0} %, {Environment.ProcessorCount} CPUs)");+ }++ private static string RuntimeInformationOs() =>+ $"{System.Runtime.InteropServices.RuntimeInformation.OSDescription.Split(' ')[0]} {System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture}";+}diff --git a/tests/Nota.SmokeTest/Program.cs b/tests/Nota.SmokeTest/Program.csindex db2e1fac..8672d29b 100644--- a/tests/Nota.SmokeTest/Program.cs+++ b/tests/Nota.SmokeTest/Program.cs@@ -229,6 +229,14 @@ if (args.Length >= 1 && args[0] == "--bundle")return failures == 0 ? 0 : 1;}+// Process CPU readout alone: `--cpu`. Also part of the full run.+if (args.Length >= 1 && args[0] == "--cpu")+{+ Console.WriteLine("-- process cpu --");+ foreach (var (ok, label) in ProcessCpuTests.Run()) Check(ok, label);+ Console.WriteLine(failures == 0 ? "CPU PASSED" : $"CPU FAILED ({failures})");+ return failures == 0 ? 0 : 1;+}// Tap tempo alone: `--tap`. Also part of the full run.if (args.Length >= 1 && args[0] == "--tap"){@@ -14625,6 +14633,9 @@ foreach (var (ok, label) in MosaicTests.Run()) Check(ok, label);Console.WriteLine("-- tap tempo --");foreach (var (ok, label) in TapTempoTests.Run()) Check(ok, label);+Console.WriteLine("-- process cpu --");+foreach (var (ok, label) in ProcessCpuTests.Run()) Check(ok, label);+Console.WriteLine("-- snap grid --");foreach (var (ok, label) in SnapGridTests.Run()) Check(ok, label);