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/plugin inactive buses (#31)
Egor Khindikaynen9bed4013a7d0
diff --git a/.specify/bugs/engine-start-prepare-race/assessment.md b/.specify/bugs/engine-start-prepare-race/assessment.mdnew file mode 100644index 00000000..81157134--- /dev/null+++ b/.specify/bugs/engine-start-prepare-race/assessment.md@@ -0,0 +1,104 @@+# Bug Assessment: Engine::start() re-prepares live nodes while the audio thread renders++- **Slug**: engine-start-prepare-race+- **Created**: 2026-10-14+- **Source**: pasted text (found while assessing `.specify/bugs/plugin-inactive-bus-crash`)+- **Verdict**: valid+- **Severity**: high++## Report (summarized)++`Engine::start()` calls `backend_->start(render)` first and only then+`propagateSampleRate()`. That re-prepares every live node, including hosted plugins+(`PluginInstrument/PluginEffect::prepare()` → `prepareToPlay`, `storage_.setSize`,+`spare_.assign`) on the calling thread, while the audio thread may already be inside+`processBlock` on the same objects. Triggers: after export (`AudioExporter.cs` `Restore`+→ `engine.Start()`), after freeze/bounce (`TrackFreezer.cs` `Restore` → `engine.Start()`),+and Preferences → Audio → Apply (`Engine::applyAudioConfig` → `stop()` + `start()`).+It does not explain the Vienna Synchron crash (a plain insert does not call `start()`),+but produces the same class of audio-thread access violation.++## Symptom++Restarting the backend with a non-empty project (export, freeze, audio-settings Apply)+lets the device callback render the graph while the control thread re-prepares the same+nodes. Expected: nodes are prepared before the first device callback touches them.+Observed (possible): access violation / heap corruption inside a plugin's `process()`+or in `storage_` (JUCE `AudioBuffer` reallocated under the reader), or glitches from+built-in DSP whose buffers are resized mid-block.++## Reproduction++1. Open a project with a hosted VST3/AU instrument or effect on a track.+2. Export (or freeze a track, or press Apply in Preferences → Audio).+3. On completion the engine calls `start()`; the backend callback begins immediately,+ racing `propagateSampleRate()`.++Timing-dependent — the window is the first few device callbacks after start.+[NEEDS CLARIFICATION: no observed crash report attributed to this path yet.]++## Suspected Code Paths++- `src/native/nota.engine/src/Engine.cpp:54` `Engine::start()` — starts the backend before+ `propagateSampleRate` / `reconfigureAllWarpStreams` / `recomputePdc`.+- `src/native/nota.engine/src/Engine.cpp:80` `Engine::propagateSampleRate()` — calls+ `setSampleRate` on every live instrument/device/MIDI effect (shared with the live graph).+- `src/native/nota.engine/pluginhost/PluginHost.cpp:769-773, 820-824` — `prepareToPlay`,+ `storage_.setSize`, `spare_.assign` (reallocations the audio thread reads).+- `src/native/nota.engine/src/Engine_Render.cpp:327` `Engine::render()` — the device+ callback; has no gate.+- `src/native/nota.engine/src/Engine_Render.cpp:347` `Engine::renderOffline()` — also+ calls `propagateSampleRate` + `processBlock` on the calling thread; safe only if the+ backend is stopped (callers do stop it today, nothing enforces it).+- `src/native/nota.engine/src/Engine.cpp:134` `Engine::applyAudioConfig()` — stop + start.++## Root Cause Hypothesis++Ordering bug: the render callback is installed and the device started before nodes are+re-prepared at the negotiated rate, and the device rate is only known after the backend+opens, so the prepare cannot simply move before `backend_->start()`. Nothing tells the+audio thread to stay out of the graph during that window. Confidence: high (direct+reading of the code).++## Proposed Remediation++**Preferred**: add `std::atomic<bool> renderSuspended_` to `Engine`. In `start()`, store+`true` before `backend_->start(...)`; `Engine::render()` checks it with an acquire load+and, while set, writes silence (`numFrames * 2` zeros) and returns without touching the+graph. After `propagateSampleRate`, `reconfigureAllWarpStreams` and `recomputePdc`+finish, clear it with a release store (also clear it on the failure path). No locks or+allocation on the audio thread. Remaining exposure: a callback that loaded `false`+before the store — impossible here because the flag is set before the backend starts.++Guard `renderOffline()`: if `backend_->isRunning()`, zero the output and return without+preparing or rendering, so an offline render can never race the device thread.++**Alternatives**:+- Open the device without starting it, prepare, then start — needs a backend API change+ in CoreAudio/miniaudio backends; larger.+- A spin/mutex handshake in render — rejected (no locks on the audio thread).++**Files likely to change**:+- `src/native/nota.engine/src/Engine.h`+- `src/native/nota.engine/src/Engine.cpp`+- `src/native/nota.engine/src/Engine_Render.cpp`+- `CHANGELOG.md`++**Tests to add or update**:+- The smoke test runs without an audio device, so the live race cannot be exercised in+ CI. `scripts/build.sh` must stay green (offline render path unchanged when the backend+ is stopped).++## Risks & Considerations++- A few device callbacks of silence right after start — inaudible (transport is stopped+ after export/freeze/Apply).+- Commands queued while suspended stay in the queue and are drained on the next real+ block — no loss.+- `renderOffline` guard changes behaviour for a caller that renders offline with the+ device live: it now gets silence instead of a racy render. No current caller does+ this (exporter and freezer stop first; smoke tests never start the backend).++## Open Questions++- None blocking.diff --git a/.specify/bugs/engine-start-prepare-race/fix.md b/.specify/bugs/engine-start-prepare-race/fix.mdnew file mode 100644index 00000000..d3d3a010--- /dev/null+++ b/.specify/bugs/engine-start-prepare-race/fix.md@@ -0,0 +1,52 @@+# Bug Fix: Engine::start() re-prepares live nodes while the audio thread renders++- **Slug**: engine-start-prepare-race+- **Fixed**: 2026-10-14+- **Assessment**: ./assessment.md+- **Status**: applied++## Summary++`Engine::start()` now suspends rendering before the backend starts and resumes it only after+every node is re-prepared at the device rate; `renderOffline()` refuses to run while the+backend is live. No locks or allocation on the audio thread.++## Changes++| File | Change | Notes |+|------|--------|-------|+| `src/native/nota.engine/src/Engine.h` | modified | `std::atomic<bool> renderSuspended_` |+| `src/native/nota.engine/src/Engine.cpp` | modified | `start()`: release-store `true` before `backend_->start()`, `false` after `propagateSampleRate` / `reconfigureAllWarpStreams` / `recomputePdc` (also on the failure path) |+| `src/native/nota.engine/src/Engine_Render.cpp` | modified | `render()`: acquire load; while suspended, zero `numFrames * 2` and return. `renderOffline()`: if `isRunning()`, zero the output and return |+| `CHANGELOG.md` | modified | `[Unreleased]` → Fixed entry |++## Diff Highlights++```cpp+renderSuspended_.store(true, std::memory_order_release);+const bool ok = backend_->start(...);+if (ok) { /* propagateSampleRate, reconfigureAllWarpStreams, recomputePdc */ }+renderSuspended_.store(false, std::memory_order_release);+if (ok) openMidiInput();+```++`openMidiInput()` moved after the clear (it doesn't touch the graph; order otherwise unchanged).++## Tests Added or Updated++None. The smoke test runs without an audio device, so the live race can't be driven in CI.+The offline path is unchanged when the backend is stopped, which the whole suite covers.++## Local Verification++- `scripts/build.sh` (macOS) → exit 0, `SMOKE TEST PASSED`.+- Not exercised on a live device or on Windows.++## Deviations from Assessment++None.++## Follow-ups++- Manual check on Windows with a hosted plug-in: export, freeze, and Preferences → Audio →+ Apply, each with the project playing a plug-in, then confirm audio resumes.diff --git a/.specify/bugs/plugin-inactive-bus-crash/assessment.md b/.specify/bugs/plugin-inactive-bus-crash/assessment.mdnew file mode 100644index 00000000..0a4ddff4--- /dev/null+++ b/.specify/bugs/plugin-inactive-bus-crash/assessment.md@@ -0,0 +1,144 @@+# Bug Assessment: Windows 0.52.1 — adding Vienna Synchron Pianos (VST3) crashes Nota on the first audio block++- **Slug**: plugin-inactive-bus-crash+- **Created**: 2026-10-14 (updated the same day after the reporter's answers)+- **Source**: pasted text (Visual Studio exception + call stack, no symbols) + reporter's follow-up+- **Verdict**: likely valid, needs reproduction+- **Severity**: high++## Report (verbatim or summarized)++> Вызвано исключение по адресу 0x00007FFC13B1E6B0 (vcruntime140.dll) в Nota.App.exe: 0xC0000005: нарушение прав+> доступа при записи по адресу 0x0000000000000020.++```+vcruntime140.dll!00007ffc13b1e6b0()+Vienna Synchron Pianos.dll!000000004309de6e()+Vienna Synchron Pianos.dll!000000004309cad4()+Vienna Synchron Pianos.dll!0000000042cb7695()+nota_engine.dll!00007ffb8a0080cb() … 12 nota_engine frames, no symbols …+nota_engine.dll!00007ffb89f83d5a()+kernel32.dll!00007ffc2a0a7374() (BaseThreadInitThunk)+ntdll.dll!00007ffc2bdbcc91() (RtlUserThreadStart)+```++Follow-up from the reporter: **version 0.52.1**; the crash happens when they **just add the plugin to a track**.++The thread was created inside `nota_engine.dll`. On Windows that's the miniaudio WASAPI thread+(`MiniaudioBackend.cpp`); the warp-build worker (`Engine_Tracks.cpp:438`) never touches plugins. So it goes+audio callback → `Engine::render` → graph → `PluginInstrument::render` → JUCE VST3 `processBlock` → the plugin's+`process()`, which `memcpy`/`memset`s through a null-based pointer.++The vcruntime fault address and "write 0x20" are byte-identical to the second exception in+`.specify/bugs/plugin-add-crash-windows` (DecentSampler, 0.51.2). It's the same machine and the same fault, and it+survived that bug's fix (`06057f8`, in 0.52.1).++## Symptom++On Windows, Nota 0.52.1 crashes with an access violation as soon as Vienna Synchron Pianos (VST3) is added to a+track. The plugin gets its first `process()` call and writes through a null pointer. Expected: the plugin loads+and plays.++## Reproduction++1. Windows x64, Nota 0.52.1.+2. Install Vienna Synchron Pianos (VST3) and scan plug-ins.+3. Add it to a track (new instrument track or replace the instrument).+4. Crash on the first audio block.++[NEEDS CLARIFICATION: Synchron Pianos version / which piano; does it crash with the transport stopped too, without+playing a note?]++## Suspected Code Paths++- `src/native/nota.engine/vendor/JUCE/modules/juce_audio_processors_headless/format_types/juce_VST3Common.h:1057-1065`+ `HostBufferMapper::associateBufferTo` — for an **inactive** bus JUCE sets `numChannels = N`, every channel+ pointer = `nullptr`, `silenceFlags = all`. Our `pluginChannelPtrs()` headroom (0.52.1) doesn't help here: JUCE+ never asks our buffer for those channels.+- `src/native/nota.engine/pluginhost/PluginHost.cpp:766` `PluginInstrument::prepare()` —+ `setPlayConfigDetails(0, 2, …)` + `prepareToPlay`. It never activates the plugin's non-main buses, so a+ multi-output instrument runs with its aux output buses inactive and receives null channel pointers for them in+ every `process()` call. Same for `PluginEffect::prepare` (`PluginHost.cpp:~815`).+- `src/native/nota.engine/pluginhost/PluginHost.cpp:948` `instantiate()` — JUCE creates the VST3 with the+ plugin's default bus activation (`kDefaultActive`), so the aux outputs start inactive.+- `src/native/nota.engine/src/Engine.h:1520` `kMaxBlock = 16384` — every plugin is prepared with+ `maxSamplesPerBlock = 16384`. That's legal but unusual (DAWs typically pass ≤ 4096–8192). A plugin that sizes an+ internal pool from it and fails or caps the allocation could write through a null buffer. A secondary suspect.+- Ruled out for this report: the bus-widening null pointer (fixed in 0.52.1); the `Engine::start()` re-prepare race+ (see below; adding a plugin doesn't call `start()`). The plugin host code is essentially unchanged since+ 0.50.1, and JUCE is unchanged.++## Root Cause Hypothesis++**Medium confidence.** Vienna's Synchron player is a multi-output instrument: its VST3 exposes extra stereo+output buses (mic positions / output routing) that aren't active by default. Nota never activates them, and JUCE+passes `nullptr` channel pointers for inactive buses with `silenceFlags` set. Many plugins check the flags or the+pointers (Reaktor 6: 1 active + 7 inactive stereo outs, works). Synchron Pianos apparently writes or clears every+output bus unconditionally, so its first `process()` call does a CRT `memset`/`memcpy` into a null channel and+faults. On MSVC's vectorized `memset`, the first faulting store can land at dst+0x20; an 8-sample offset into the+channel is also consistent with 0x20. It's deterministic on the first block, which matches "crashes as soon as+I add it".++Most real hosts (Cubase, Reaper, Live) give inactive buses valid scratch buffers, which is why the plugin gets+away with it elsewhere. That's the gap to close.++Unconfirmed: that Synchron Pianos actually exposes inactive aux buses. That has to be checked, either by logging+the bus layout at insert or by loading it in JUCE's AudioPluginHost.++### Also found (separate latent bug, not this crash)++`Engine::start()` (`src/Engine.cpp:54-66`) starts the audio callback *before* `propagateSampleRate()` re-prepares+every live plugin (`prepareToPlay` + `storage_.setSize`) from the UI thread. After export+(`AudioExporter.cs:343`), freeze/bounce (`TrackFreezer.cs:129`) or Preferences → Audio Apply, the audio thread can+be in `processBlock` while the plugin is being deactivated, reconfigured and reactivated. That's a real race with+the same crash signature, but it doesn't trigger on a plain insert. Track it separately.++## Proposed Remediation++**Preferred**: never let a hosted plugin run with null bus buffers. In `PluginInstrument::prepare()` and+`PluginEffect::prepare()`, call `plugin_->enableAllBuses()` before `prepareToPlay`. Replace+`setPlayConfigDetails(0, 2, …)` with `setRateAndBufferSizeDetails(sr, maxBlock_)`; forcing 0-in/2-out is what+fights the plugin's layout. `storage_` is already sized from the totals, and `render()` still mixes only channels+0/1, so the aux outputs render and are discarded. That's the same thing other hosts do with outputs nobody+routed. If the plugin rejects a bus (`enableAllBuses` → `setBusesLayout` fails), fall back to the current layout.++Ship it with a one-time diagnostic: log each bus (`name`, channels, active) on insert, behind the existing stderr+logging. That makes the next report self-explanatory.++**Alternatives**:+- Patch JUCE's `associateBufferTo` to point inactive-bus channels at a host scratch buffer instead of `nullptr`.+ It keeps aux buses inactive (no extra CPU) and protects every plugin, but it's a vendor patch: check the+ dependency policy in `CONTRIBUTING.md`, and every JUCE bump would have to carry it.+- Lower `kMaxBlock` handed to plugins (e.g. 4096) and split larger offline chunks. Do this if the bus log shows+ only main buses (the secondary suspect).+- Out-of-process plugin hosting: the long-term answer to any plugin crash.++**Files likely to change**:+- `src/native/nota.engine/pluginhost/PluginHost.cpp` (`PluginInstrument::prepare`, `PluginEffect::prepare`, bus log)+- `CHANGELOG.md` (`[Unreleased]` → Fixed)++**Tests to add or update**:+- Local (macOS): Reaktor 6 VST3, a multi-out instrument with inactive aux buses by default. After the fix its+ layout reports all buses active, it renders 200 blocks, and the main stereo output is unchanged.+- Smoke test: if a hosted test plugin is available, assert after insert that no bus is inactive+ (`getBusCount`/`getBus(i)->isEnabled()`).+- Windows retest by the reporter with Synchron Pianos on a build with the fix and the bus log.++## Risks & Considerations++- Enabling all buses costs CPU for multi-out plugins (they render outputs that are then discarded). Acceptable;+ a later "multi-out routing" feature would make them useful.+- Effects with a sidechain input bus would get it activated. `PluginEffect` already handles sidechain channel+ offsets (`scChanOffset_`), so check that enabling it doesn't conflict when no sidechain is routed (the input+ must be silent).+- Saved project state: bus activation isn't part of the plugin's state chunk in JUCE VST3 hosting, so it doesn't+ affect projects.+- If the bus log shows Synchron Pianos has only a main bus, this hypothesis is wrong. Fall back to the `kMaxBlock`+ suspect and ask for a full dump.++## Open Questions++- [NEEDS CLARIFICATION: Synchron Pianos version; does it crash with the transport stopped and no note played?]+- [NEEDS CLARIFICATION: does the same project/track work in another host (Reaper/Cubase) on that machine?]+- [NEEDS CLARIFICATION: a full dump (`procdump -e -ma Nota.App.exe`) would name the 12 `nota_engine` frames with a+ local RelWithDebInfo build.]diff --git a/.specify/bugs/plugin-inactive-bus-crash/fix.md b/.specify/bugs/plugin-inactive-bus-crash/fix.mdnew file mode 100644index 00000000..544e9e3e--- /dev/null+++ b/.specify/bugs/plugin-inactive-bus-crash/fix.md@@ -0,0 +1,79 @@+# Bug Fix: multi-output plugins crash on their first block (inactive buses get null channels)++- **Slug**: plugin-inactive-bus-crash+- **Fixed**: 2026-10-14+- **Assessment**: ./assessment.md+- **Status**: applied++## Summary++Hosted plugins now run with every bus active. Before, `prepare()` called JUCE's `setPlayConfigDetails`, which+**explicitly disables all non-main buses** (`juce_AudioProcessor.cpp:367`, `disableNonMainBuses()`), and JUCE+passes inactive VST3 buses to `process()` with `nullptr` channel pointers. A multi-output instrument that writes to+every output bus anyway (Vienna Synchron Pianos, Windows, 0.52.1) faults on the first block. Nota still mixes only+the main stereo pair; aux outputs are rendered and discarded.++## Changes++| File | Change | Notes |+|------|--------|-------|+| `src/native/nota.engine/pluginhost/PluginHost.cpp` | modified | new `enableEveryBus()` + `logBuses()`; `PluginInstrument::prepare` and `PluginEffect::setSampleRate` set the main bus(es) to stereo, enable every bus, then `setRateAndBufferSizeDetails` (no more `setPlayConfigDetails`); `stereoIn_`/`stereoOut_` from the main bus's real channel count |+| `CHANGELOG.md` | modified | `[Unreleased]` → Fixed entry |++## Diff Highlights++```cpp+void enableEveryBus(juce::AudioPluginInstance& p) {+ if (p.enableAllBuses()) return;+ for (const bool isInput : { true, false }) // all-or-nothing failed: take what it accepts+ for (int i = 1; i < p.getBusCount(isInput); ++i)+ if (auto* bus = p.getBus(isInput, i); bus != nullptr && !bus->isEnabled()) bus->enable(true);+}++// PluginInstrument::prepare+if (plugin_->getBusCount(false) > 0) plugin_->setChannelLayoutOfBus(false, 0, juce::AudioChannelSet::stereo());+enableEveryBus(*plugin_);+logBuses(*plugin_);+plugin_->setRateAndBufferSizeDetails(sr, maxBlock_);+plugin_->prepareToPlay(sr, maxBlock_);+```++With aux buses active, channel 1 of the process buffer belongs to the *next* bus when a plugin's main bus is mono+(previously all other buses were off, so it was just a cleared channel). So the right channel is now picked from+the main bus's own channel count: the instrument and effect output fall back to L, and a mono effect input drops+R into the scratch channel instead of feeding the next bus.++`NOTA_DEBUG_PLUGIN_BUSES=1` prints each bus (name, channels, enabled) on prepare. Ask the Windows reporter for+this output if the crash persists.++## Tests Added or Updated++None in the repo: the smoke test has no hosted multi-output plugin. Verified with real plugins below.++## Local Verification++- `scripts/build.sh` → native + managed build OK, **SMOKE TEST PASSED**.+- `/tmp/widenharness/run2.py` (Python ctypes over `libnota_engine.dylib`, `NOTA_DATA_DIR` isolated), **Reaktor 6+ VST3** instrument with `NOTA_DEBUG_PLUGIN_BUSES=1`: input bus 0 and all **8 stereo output buses enabled=1**+ (before: only out 0 active, 7 inactive with null pointers). Bus state also survives the second prepare from+ `propagateSampleRate`. 200 × 512-frame blocks rendered, exit 0 (peak 0.0, since no ensemble is loaded).+- `/tmp/widenharness/fx.py`: built-in instrument track + VST3 effect, 100 blocks, peak L/R:+ no effect 0.054/0.054 · Solid Bus Comp 0.071/0.071 (sidechain bus in 1 enabled) · Replika 0.074/0.076 ·+ BYOD 0.054/0.054 · Supercharger 0.050/0.050 (sidechain bus enabled). Stereo is intact through every effect,+ exit 0.+- Not done: Windows, Vienna Synchron Pianos (not available here), and the GUI app.++## Deviations from Assessment++- The mono-main handling (`stereoIn_`/`stereoOut_`) wasn't in the assessment. It's needed because enabling aux+ buses changes what channel 1 of the process buffer is.+- The assessment's `kMaxBlock = 16384` secondary suspect is left as is, pending the bus log from the reporter.++## Follow-ups++- Windows retest with Synchron Pianos on a build with this fix (`/speckit-bug-test`). If it still crashes, get+ `NOTA_DEBUG_PLUGIN_BUSES=1` output and a dump.+- Multi-out drum/sampler plugins that route parts to aux outputs *when those are active* now play those parts+ into discarded outputs. Most default to the main out. A later multi-out routing feature (or summing aux into+ main as an option) would cover them.+- A hosted test plugin with an aux output bus in the smoke test would pin this down in CI.diff --git a/CHANGELOG.md b/CHANGELOG.mdindex be6fdb6c..3d8cedb9 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -22,6 +22,8 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.## [Unreleased]+## [0.53.1] — 2026-10-15+### Added- **Note length and velocity from the keyboard:** in the piano roll, **⇧← / ⇧→** shortenor lengthen every selected note by one grid step (starts stay put), and **⌥↑ / ⌥↓**@@ -60,6 +62,13 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.paste jumped to the playback cursor while the song played.### Fixed+- **Multi-output plug-ins no longer crash Nota when added:** Nota switched off a plug-in's+ extra outputs, and some instruments (Vienna Synchron Pianos on Windows) still wrote to them+ and crashed on the first block. Every output is now on; Nota plays the main stereo pair.+- **No crash when audio restarts with plug-ins loaded:** after an export, a track freeze or+ Apply in Preferences → Audio, Nota could play a few blocks while it was still getting the+ project's plug-ins and devices ready for the audio device, which could crash inside a+ plug-in. Audio now stays silent until everything is ready.- **Return tracks can be deleted in the arrangement:** the Return row's context menu hasDelete track, and Delete / Backspace removes a selected Return, in one undo step. TheReturns that stay keep sounding, and every track's sends stay on the same Returns.diff --git a/FEATURES.md b/FEATURES.mdindex befabd18..4f9460da 100644--- a/FEATURES.md+++ b/FEATURES.md@@ -2,7 +2,7 @@# Nota — full feature listA consolidated list of what Nota (a cross-platform DAW) can do, as of version-**0.52.1** (plus changes in development on `main`). This document describes what is+**0.53.1** (plus changes in development on `main`). This document describes what isimplemented in the code, not what is planned. Sources: `CHANGELOG.md`, `README.md`,`ARCHITECTURE.md`.diff --git a/VERSION b/VERSIONindex d06c2d46..09b1cdc0 100644--- a/VERSION+++ b/VERSION@@ -1 +1 @@-0.52.1\ No newline at end of file+0.53.1\ No newline at end of filediff --git a/release-notes/0.53.1.en.md b/release-notes/0.53.1.en.mdnew file mode 100644index 00000000..fdae566a--- /dev/null+++ b/release-notes/0.53.1.en.md@@ -0,0 +1,22 @@+<!-- SPDX-License-Identifier: AGPL-3.0-only -->+Nota 0.53 is about the mix: a Stereo Map that shows where every sound sits, panning that keeps stereo tracks whole, and undo for every fader and pan move. The piano roll gets faster note editing, and plug-ins are more reliable on every system.++**1. Stereo Map**+The Mixer has a second view: switch to **Stereo Map** in its title bar. Every track, return and the master is a dot at its pan and volume, with a cloud around it showing where the sound really is, how wide and how loud: a mono sound is a narrow cloud on its dot, a wide pad spreads across the map. The master's phase correlation is shown too. Drag a dot to set pan and volume at once, double-click to centre it, ⌥ double-click for 0 dB, hover for the numbers, click to select the track.++**2. Panning that keeps stereo whole**+Panning a stereo track or return now moves its whole image instead of dropping one channel: at full left, both channels play from the left speaker. Mono material and centred tracks sound exactly as before. New projects use the new **Stereo** pan law. Existing projects keep **Balance** and sound the same; the Mixer marks them **Older project**, and the **PAN LAW** switch in its footer changes the law at any time, even during playback, without a click. Group strips stay on Balance (marked **BAL**), so grouping doesn't change levels.++**3. Undo for volume and pan**+Fader, pan and master volume moves can now be undone and redone with **⌘Z / ⌘⇧Z**, wherever you made them: the Mixer, track headers, the Return and Master rows, the Session mixer, the transport's **MST**, Nota Remote, a MIDI controller or the AI assistant. One move is one step in the same history as every other edit.++**4. Faster note editing in the piano roll**+**⇧← / ⇧→** shorten or lengthen the selected notes by one grid step, **⌥↑ / ⌥↓** change their velocity by 10 (**⌥⇧↑ / ⌥⇧↓** by 1). A note moved, stretched, drawn or pasted onto a note of the same pitch now replaces it instead of stacking on top: the note underneath is cut or removed when you let the selection go, and until then the part that will go is drawn faint.++**Also**+• **⌘V** in the piano roll always pastes right on top of the copied notes, selected, even during playback; move the copy off with the arrows or the mouse+• Return tracks can be deleted in the arrangement, from the context menu or with Delete / Backspace; other tracks' sends stay on the right returns+• Multi-output instruments (Vienna Synchron Pianos on Windows and others) no longer crash Nota when added+• No more crash inside plug-ins after an export, a track freeze or applying audio settings+• Plug-ins work on Linux: VST3 plug-ins play sound again, and their windows draw and close properly+• Projects are now saved in format v21, which earlier Nota versions can't opendiff --git a/release-notes/0.53.1.ru.md b/release-notes/0.53.1.ru.mdnew file mode 100644index 00000000..74f989d5--- /dev/null+++ b/release-notes/0.53.1.ru.md@@ -0,0 +1,22 @@+<!-- SPDX-License-Identifier: AGPL-3.0-only -->+Nota 0.53 — про сведение: стереокарта показывает, где звучит каждая дорожка, панорама больше не теряет стерео, а любое движение фейдера и панорамы можно отменить. В пиано-ролле ноты правятся быстрее, а плагины стали надёжнее на всех системах.++**1. Стереокарта**+У микшера появился второй вид — **Stereo Map**, переключается в заголовке окна. Каждая дорожка, возврат и мастер — точка по панораме и громкости, а облако вокруг неё показывает, где звук на самом деле, насколько он широкий и громкий: моно — узкое облачко на точке, широкий пэд растекается по всей карте. Видна и фазовая корреляция мастера. Тяните точку — меняются панорама и громкость сразу; двойной щелчок ставит в центр, ⌥ + двойной щелчок — 0 дБ; наведите курсор, чтобы увидеть цифры, щёлкните, чтобы выбрать дорожку.++**2. Панорама, которая сохраняет стерео**+Стереодорожка или возврат при панорамировании теперь сдвигают всю картину целиком, а не глушат один канал: в крайнем левом положении оба канала звучат из левой колонки. Моно и дорожки по центру звучат как раньше. Новые проекты используют закон панорамы **Stereo**. Старые проекты остаются на **Balance** и звучат так же; микшер помечает их **Older project**, а переключатель **PAN LAW** внизу микшера меняет закон в любой момент, даже во время игры и без щелчка. Группы остаются на Balance (метка **BAL**), чтобы группировка не меняла уровни.++**3. Отмена для громкости и панорамы**+Движения фейдеров, панорамы и громкости мастера теперь отменяются и повторяются через **⌘Z / ⌘⇧Z** — где бы вы их ни сделали: в микшере, заголовках дорожек, строках Return и Master, микшере Session, на **MST** в транспорте, в Nota Remote, с MIDI-контроллера или через AI-ассистента. Одно движение — один шаг в общей истории правок.++**4. Быстрая правка нот в пиано-ролле**+**⇧← / ⇧→** укорачивают или удлиняют выделенные ноты на шаг сетки, **⌥↑ / ⌥↓** меняют велосити на 10 (**⌥⇧↑ / ⌥⇧↓** — на 1). Нота, которую сдвинули, растянули, нарисовали или вставили поверх ноты той же высоты, теперь заменяет её, а не ложится сверху: нижняя нота обрезается или удаляется, когда вы снимаете выделение, а до тех пор уходящая часть показана бледной.++**Ещё**+• **⌘V** в пиано-ролле всегда вставляет ноты прямо поверх скопированных, выделенными, даже во время игры — дальше сдвигайте копию стрелками или мышью+• Возвраты можно удалять в аранжировке — из контекстного меню или клавишей Delete / Backspace; посылы остальных дорожек остаются на своих возвратах+• Многовыходные инструменты (Vienna Synchron Pianos на Windows и другие) больше не роняют Nota при добавлении+• Больше нет падений внутри плагинов после экспорта, заморозки дорожки или применения настроек звука+• Плагины работают на Linux: VST3 снова звучат, а их окна рисуют интерфейс и нормально закрываются+• Проекты теперь сохраняются в формате v21 — более ранние версии Nota их не откроютdiff --git a/src/native/nota.engine/VERSION b/src/native/nota.engine/VERSIONindex 83145459..bd03320d 100644--- a/src/native/nota.engine/VERSION+++ b/src/native/nota.engine/VERSION@@ -1 +1 @@-0.31.1\ No newline at end of file+0.32.1\ No newline at end of filediff --git a/src/native/nota.engine/pluginhost/PluginHost.cpp b/src/native/nota.engine/pluginhost/PluginHost.cppindex 7b614dc3..0b84f33c 100644--- a/src/native/nota.engine/pluginhost/PluginHost.cpp+++ b/src/native/nota.engine/pluginhost/PluginHost.cpp@@ -410,6 +410,33 @@ int pluginChannelPtrs(const juce::AudioProcessor& p, juce::AudioBuffer<float>& sreturn want;}+// Turn on every bus the plugin has, keeping the main buses as the caller set them. JUCE hands+// an inactive VST3 bus to process() with null channel pointers (HostBufferMapper), and some+// multi-output instruments (Vienna Synchron Pianos) write to every output bus regardless —+// a null write on the first block. Active buses get real channels in the process buffer;+// Nota mixes only the main stereo pair and discards the rest, like a host with unrouted+// outputs. Never use setPlayConfigDetails after this: it disables non-main buses again.+// Message thread, before prepareToPlay.+void enableEveryBus(juce::AudioPluginInstance& p) {+ if (p.enableAllBuses()) return;+ for (const bool isInput : { true, false }) // all-or-nothing failed: take what it accepts+ for (int i = 1; i < p.getBusCount(isInput); ++i)+ if (auto* bus = p.getBus(isInput, i); bus != nullptr && !bus->isEnabled()) bus->enable(true);+}++// Bus layout on stderr when NOTA_DEBUG_PLUGIN_BUSES is set — the first thing to ask for+// when a hosted plugin crashes in process().+void logBuses(const juce::AudioPluginInstance& p) {+ static const bool dbg = std::getenv("NOTA_DEBUG_PLUGIN_BUSES") != nullptr;+ if (!dbg) return;+ for (const bool isInput : { true, false })+ for (int i = 0; i < p.getBusCount(isInput); ++i)+ if (auto* bus = p.getBus(isInput, i))+ std::fprintf(stderr, "[nota buses] %s %s %d '%s' chans=%d enabled=%d\n",+ p.getName().toRawUTF8(), isInput ? "in" : "out", i, bus->getName().toRawUTF8(),+ bus->getLastEnabledLayout().size(), (int)bus->isEnabled());+}+// Message-thread producer -> audio-thread consumer. The editor window's computer// keyboard pushes note events here; the plugin adapter drains them in its audio// callback (keeps the plugin's own MidiBuffer audio-thread-only — no data race).@@ -699,14 +726,13 @@ public:for (GuiNote g; guiNotes_.pop(g); )pending_.addEvent(g.on ? juce::MidiMessage::noteOn(1, g.pitch, g.velocity): juce::MidiMessage::noteOff(1, g.pitch), 0);- const int nc = juce::jmin(storage_.getNumChannels(), kMaxChans);storage_.clear();float* ptrs[kMaxChans];juce::AudioBuffer<float> block(ptrs, pluginChannelPtrs(*plugin_, storage_, spare_.data(), frames, ptrs), frames);plugin_->processBlock(block, pending_);pending_.clear();const float* l = block.getReadPointer(0);- const float* r = nc > 1 ? block.getReadPointer(1) : l;+ const float* r = stereoOut_ ? block.getReadPointer(1) : l; // channel 1 of a mono main is another busfor (int i = 0; i < frames; ++i) { out[i * 2] += l[i]; out[i * 2 + 1] += r[i]; }}@@ -765,11 +791,16 @@ private:void audioProcessorChanged(juce::AudioProcessor*, const juce::AudioProcessorListener::ChangeDetails&) override {}void prepare(double sr) {- plugin_->setPlayConfigDetails(0, 2, sr, maxBlock_);+ // Stereo main output (instruments get no input of their own), then every other bus on.+ if (plugin_->getBusCount(false) > 0) plugin_->setChannelLayoutOfBus(false, 0, juce::AudioChannelSet::stereo());+ enableEveryBus(*plugin_);+ logBuses(*plugin_);+ plugin_->setRateAndBufferSizeDetails(sr, maxBlock_);plugin_->prepareToPlay(sr, maxBlock_);plugin_->setPlayHead(&playHead_); // DAW transport sync// In and out share the buffer, so it spans the wider side.storage_.setSize(juce::jmax(2, plugin_->getTotalNumInputChannels(), plugin_->getTotalNumOutputChannels()), maxBlock_);+ stereoOut_ = plugin_->getBusCount(false) > 0 && plugin_->getChannelCountOfBus(false, 0) > 1;spare_.assign((size_t)maxBlock_, 0.0f);}@@ -779,6 +810,7 @@ private:std::vector<float> spare_; // the channels past storage_ (see pluginChannelPtrs)juce::MidiBuffer pending_;int maxBlock_;+ bool stereoOut_ = true; // main output bus has a channel 1 (see prepare)std::string name_; // cached plugin name for displayName()std::atomic<int32_t> lastTouched_{-1}; // "Learn" (M9-B3)std::atomic<int32_t> gestureBegin_{-1}, gestureEnd_{-1}; // write gestures (M9-C)@@ -815,12 +847,19 @@ public:if (plugin_->setBusesLayout(layout)) hasSidechain_ = true;}}- if (!hasSidechain_)- plugin_->setPlayConfigDetails(2, 2, sr, maxBlock_);+ if (!hasSidechain_) { // stereo main I/O+ if (plugin_->getBusCount(true) > 0) plugin_->setChannelLayoutOfBus(true, 0, juce::AudioChannelSet::stereo());+ if (plugin_->getBusCount(false) > 0) plugin_->setChannelLayoutOfBus(false, 0, juce::AudioChannelSet::stereo());+ }+ enableEveryBus(*plugin_); // an unused sidechain input is fed silence (storage_ cleared)+ logBuses(*plugin_);+ plugin_->setRateAndBufferSizeDetails(sr, maxBlock_);plugin_->prepareToPlay(sr, maxBlock_);const int chans = juce::jmax(2, juce::jmax(plugin_->getTotalNumInputChannels(),plugin_->getTotalNumOutputChannels()));storage_.setSize(chans, maxBlock_);+ stereoIn_ = plugin_->getBusCount(true) > 0 && plugin_->getChannelCountOfBus(true, 0) > 1;+ stereoOut_ = plugin_->getBusCount(false) > 0 && plugin_->getChannelCountOfBus(false, 0) > 1;spare_.assign((size_t)maxBlock_, 0.0f);if (hasSidechain_ && plugin_->getBus(true, 1) != nullptr) {scChanOffset_ = plugin_->getChannelIndexInProcessBlockBuffer(true, 1, 0);@@ -836,7 +875,7 @@ public:const int nc = juce::jmin(storage_.getNumChannels(), kMaxChans);storage_.clear();float* l = storage_.getWritePointer(0);- float* r = nc > 1 ? storage_.getWritePointer(1) : l;+ float* r = stereoIn_ ? storage_.getWritePointer(1) : spare_.data(); // mono main: drop R, don't feed the next busfor (int i = 0; i < frames; ++i) { l[i] = buf[i * 2]; r[i] = buf[i * 2 + 1]; }// Feed the sidechain input bus (Phase C) if the engine handed us a source@@ -860,7 +899,7 @@ public:plugin_->processBlock(block, empty_);const float* ol = block.getReadPointer(0);- const float* orr = nc > 1 ? block.getReadPointer(1) : ol;+ const float* orr = stereoOut_ ? block.getReadPointer(1) : ol;const float mix = sidechainMix(); // dry/wet of the plugin (Phase D)for (int i = 0; i < frames; ++i) {const float dl = buf[i * 2], dr = buf[i * 2 + 1];@@ -942,6 +981,7 @@ private:std::vector<float> spare_; // the channels past storage_ (see pluginChannelPtrs)juce::MidiBuffer empty_;int maxBlock_ = 0;+ bool stereoIn_ = true, stereoOut_ = true; // main buses have a channel 1 (see setSampleRate)EditorHost editor_; // declared last: destroyed before plugin_};diff --git a/src/native/nota.engine/src/Engine.cpp b/src/native/nota.engine/src/Engine.cppindex 50fdddb8..68e0aad3 100644--- a/src/native/nota.engine/src/Engine.cpp+++ b/src/native/nota.engine/src/Engine.cpp@@ -60,14 +60,19 @@ bool Engine::start() {bc.bufferFrames = config_.bufferFrames;bc.wasapiExclusive = config_.wasapiExclusive;backend_->setXrunCallback([this] { notifyXrun(); }); // device dropouts (M7-8)+ // The device rate is only known once the backend is open, so the nodes are re-prepared+ // after it starts. Until then the callback must stay out of the graph: prepare()+ // reallocates buffers (and hosted plugins run prepareToPlay) the audio thread would read.+ renderSuspended_.store(true, std::memory_order_release);const bool ok = backend_->start([this](float* out, int32_t n) { render(out, n); }, bc);if (ok) {transport_.setSampleRate(backend_->sampleRate());propagateSampleRate(backend_->sampleRate()); // re-prepare every node (incl. master + racks) at the new ratereconfigureAllWarpStreams(); // warp transpose + window sizes depend on the device SRrecomputePdc(); // latencies are known once plugins are prepared- openMidiInput();}+ renderSuspended_.store(false, std::memory_order_release);+ if (ok) openMidiInput();return ok;}diff --git a/src/native/nota.engine/src/Engine.h b/src/native/nota.engine/src/Engine.hindex 99bfea11..4f46eee8 100644--- a/src/native/nota.engine/src/Engine.h+++ b/src/native/nota.engine/src/Engine.h@@ -1320,6 +1320,9 @@ private:std::atomic<bool> recording_{false};std::atomic<int32_t> xruns_{0}; // device dropouts since launch (M7-8)std::atomic<float> cpuLoad_{0.0f}; // smoothed RT DSP load 0..1 (Phase 11)+ // Set by start() before the device opens, cleared (release) once every node is re-prepared+ // at the negotiated rate: while set, render() outputs silence and never touches the graph.+ std::atomic<bool> renderSuspended_{false};std::atomic<double> launchQuant_{4.0}; // Session launch quantize, beats (M5-2)// Arrangement playback active (M5): true after main Play / arrangement record; false in a// session-only jam. Read on the audio thread to gate arrangement clip content per track.diff --git a/src/native/nota.engine/src/Engine_Render.cpp b/src/native/nota.engine/src/Engine_Render.cppindex 20863a0f..fed9ae02 100644--- a/src/native/nota.engine/src/Engine_Render.cpp+++ b/src/native/nota.engine/src/Engine_Render.cpp@@ -325,6 +325,11 @@ void Engine::attachRecordedExpr(Note& n, int32_t pitch, double startBeat) {// --- audio thread ----------------------------------------------------------void Engine::render(float* out, int32_t numFrames) {+ // start() is still re-preparing the nodes on the control thread: output silence.+ if (renderSuspended_.load(std::memory_order_acquire)) {+ std::fill(out, out + static_cast<size_t>(numFrames) * 2, 0.0f);+ return;+ }ScopedNoDenormals noDenormals;const auto t0 = std::chrono::steady_clock::now();processBlock(out, numFrames);@@ -345,6 +350,12 @@ void Engine::renderOffline(float* out, int32_t frames, double sampleRate) {}void Engine::renderOffline(float* out, int32_t frames) {+ // Offline rendering re-prepares and processes the graph on the calling thread — with the+ // device live that would race the audio thread. Callers stop the backend first; enforce it.+ if (isRunning()) {+ std::fill(out, out + static_cast<size_t>(frames) * 2, 0.0f);+ return;+ }stopPreview(); // audition must never bleed into a bounce (M7-4a)if (transport_.sampleRate() <= 0) transport_.setSampleRate(44100.0);const double sr = transport_.sampleRate();