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) Plug-ins that change their inputs or outputs no longer crash Nota
Egor Khindikaynen06057f89f5c6
diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 4bd0a5d5..7e3c3b71 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -2,8 +2,9 @@ name: Release# Builds and publishes Nota for every x64 + arm64 target across macOS, Windows and# Linux. Runs ONLY on a semver release tag (vX.Y.Z), and only when that tag points at a-# commit contained in `main`. The GitHub release is created as a DRAFT with the matching-# CHANGELOG section as its body; you review the artifacts and publish manually.+# commit contained in `main`. The GitHub release is created as a DRAFT whose body is the+# curated release notes (release-notes/X.Y.Z.{en,ru}.md, rendered by+# scripts/release-notes.sh); you review the artifacts and publish manually.## Manual run (Actions -> Release -> Run workflow): builds the chosen platforms from# any branch, without a tag, and only uploads the build artifacts — no release is@@ -32,7 +33,8 @@ permissions:jobs:# --------------------------------------------------------------------------------# Gate: the tag must be on main, must match the VERSION file, and must have a- # CHANGELOG section. Every build job depends on this, so a bad tag never builds.+ # CHANGELOG section and curated release notes. Every build job depends on this, so a+ # bad tag never builds.# --------------------------------------------------------------------------------guard:name: ${{ github.event_name == 'push' && 'Validate release tag' || 'Read version' }}@@ -78,6 +80,14 @@ jobs:exit 1fi+ # 4) There must be curated release notes in both languages for the release body.+ for lang in en ru; do+ if [ ! -s "release-notes/${version}.${lang}.md" ]; then+ echo "::error::release-notes/${version}.${lang}.md is missing or empty."+ exit 1+ fi+ done+echo "version=$version" >> "$GITHUB_OUTPUT"# --------------------------------------------------------------------------------@@ -193,7 +203,7 @@ jobs:if-no-files-found: error# --------------------------------------------------------------------------------- # Draft release — collect every artifact and attach the CHANGELOG section as the body.+ # Draft release — collect every artifact and attach the curated release notes as the body.# --------------------------------------------------------------------------------release:name: Create draft release@@ -203,34 +213,10 @@ jobs:steps:- uses: actions/checkout@v5- - name: Extract CHANGELOG section for this version+ - name: Render release notes for this versionrun: |set -euo pipefail- version="${{ needs.guard.outputs.version }}"- # Print the body of the "## [<version>]" section, up to the next "## [" heading.- awk -v ver="$version" '- $0 ~ ("^## \\[" ver "\\]") { grab = 1; next }- grab && /^## \[/ { exit }- grab { print }- ' CHANGELOG.md | sed '/./,$!d' > RELEASE_NOTES.md- if [ ! -s RELEASE_NOTES.md ]; then- echo "See CHANGELOG.md for details." > RELEASE_NOTES.md- fi- cat >> RELEASE_NOTES.md <<'EOF'-- ----- ### Install-- | System | File |- |---|---|- | macOS, Apple Silicon | `Nota-*-arm64.dmg` |- | macOS, Intel | `Nota-*-x86_64.dmg` |- | Windows | `Nota-Setup-*-x64.exe` (`-arm64` for Windows on ARM) |- | Linux | `Nota-*-x86_64.AppImage` (`-aarch64` for ARM) |-- **First launch:** Nota isn't signed with a paid certificate yet. On **macOS**, if it says Apple could not verify Nota, open **System Settings → Privacy & Security** and click **Open Anyway** — [step-by-step guide](https://github.com/nota-daw/nota#opening-nota-on-macos). On **Windows**, click **More info → Run anyway** in SmartScreen.- EOF+ bash scripts/release-notes.sh "${{ needs.guard.outputs.version }}" github > RELEASE_NOTES.mdecho "----- release notes -----"; cat RELEASE_NOTES.md- name: Download all build artifactsdiff --git a/.specify/bugs/plugin-add-crash-windows/assessment.md b/.specify/bugs/plugin-add-crash-windows/assessment.mdindex 7d3f470f..d7d63add 100644--- a/.specify/bugs/plugin-add-crash-windows/assessment.md+++ b/.specify/bugs/plugin-add-crash-windows/assessment.md@@ -3,7 +3,7 @@- **Slug**: plugin-add-crash-windows- **Created**: 2026-10-13- **Source**: pasted text (user comment + screenshot of the Visual Studio JIT "Unhandled exception" dialog)-- **Verdict**: likely valid, needs reproduction+- **Verdict**: valid (macOS repro with Reaktor 6 VST3; Windows report consistent)- **Severity**: high## Report (verbatim or summarized)@@ -17,6 +17,14 @@Screenshot: VS JIT debugger dialog "Исключение не обработано", the `vcruntime140.dll` write AV at 0x20.+### Second report (maintainer, macOS, 0.51.2, 2026-10-13)++Reaktor 6 **VST3** (AU version is fine): drag onto the arrangement → open the plugin GUI → click any of the+Play / Patch / Build mode buttons → Nota crashes. Crash report: `EXC_BAD_ACCESS (SIGSEGV) KERN_INVALID_ADDRESS at+0x0`, **triggered by thread 20 `com.apple.audio.IOThread.client`** (the audio thread); the main thread is at the same+moment inside Reaktor `project::close` → `openProject` → `ReaktorGUI::restoreWindows` (the mode switch reloads Reaktor's+project, which makes it reconfigure its buses).+## SymptomOn Windows, adding a hosted plugin (DecentSampler.vst3 named; the reporter says "every time I add a plugin") crashes@@ -58,6 +66,29 @@ so the codecs are ruled out.## Root Cause Hypothesis+**Updated after the macOS repro — high confidence on the mechanism.**++`PluginInstrument` / `PluginEffect` hand the plugin a `juce::AudioBuffer` that *refers to* exactly `nc` channels of+`storage_` (`PluginHost.cpp:653-657`, `:805-807`). `storage_` is sized once in `prepare()` / `setSampleRate()`+(`PluginHost.cpp:723`: `max(2, totalOutputs)` — inputs are ignored for instruments; `:772` for effects). JUCE's VST3+wrapper maps each bus channel with `buffer.getWritePointer(ch)` (`juce_VST3Common.h:1059`); for `ch >= nc` a referring+`AudioBuffer` returns `channels[nc] == nullptr` (`juce_AudioSampleBuffer.h:1231`, the bounds check is a `jassert` only).+So whenever the plugin's current layout needs more channels than `storage_` holds, the plugin receives a null channel+pointer and writes through it.++A VST3 plugin can change its layout at any time: `IComponentHandler::restartComponent(kIoChanged)` → JUCE+`restartComponentOnMessageThread` → `releaseResources()` + `prepareToPlay()` with the plugin's new bus arrangement+(`juce_VST3PluginFormatImpl.h:3512-3530`). Nota is not told (our `audioProcessorChanged` is empty) and keeps the old+`storage_`. Reaktor's mode switch reloads its project and does exactly that → null write on the audio thread at 0x0+(macOS), and null + small offsets on Windows (`read 0x8` in the plugin, `write 0x20` in a CRT memcpy/memset) —+consistent with the DecentSampler report. An instrument whose *input* bus is wider than its output (ignored at `:723`)+can hit the same thing right at insert.++The original hypothesis below is kept for the record; the 0.50.1 → 0.51 "regression" is likely incidental (this code and+JUCE are unchanged between those tags).++Original hypothesis:+**Low confidence.** The faulting frames are inside DecentSampler and the CRT, so Nota is most likely driving the plugininto an invalid state rather than corrupting memory itself. The regression window (0.50.1 → 0.51.1) contains twoplugin-facing changes: (a) the rewritten insert flow in `DeviceInsertService` (undo grouping, placement/replace), and@@ -72,7 +103,14 @@ on the reporter's machine — it would appear without any PDBs. Still, the insta## Proposed Remediation-**Preferred**:+**Preferred (updated)**: never hand the plugin a buffer narrower than its layout. In `render()` / `process()`, build+the referring buffer with `kMaxChans` channel pointers: the first `nc` point into `storage_`, the rest at one+per-instance, preallocated scratch channel (`maxBlock_` floats, zeroed each block). Allocation-free, lock-free, and+immune to the race between reading the layout and JUCE re-preparing it on the message thread; extra channels are+silent in and discarded out. Also size `storage_` by `max(2, totalIn, totalOut)` for instruments. Test with Reaktor 6+VST3 locally (mode switch), plus a smoke-level guard if a test plugin with a variable layout is available.++**Original proposal (superseded)**:1. Reproduce on a Windows x64 box with DecentSampler 1.x: add it via browser drag, double-click, palette, and as areplace-in-place, on 0.50.1 and 0.51.2; capture a full dump (`procdump -e -ma Nota.App.exe` or WER LocalDumps) andopen it with JUCE + nota_engine symbols from a local RelWithDebInfo build to get the real stack.diff --git a/.specify/bugs/plugin-add-crash-windows/fix.md b/.specify/bugs/plugin-add-crash-windows/fix.mdnew file mode 100644index 00000000..9459415a--- /dev/null+++ b/.specify/bugs/plugin-add-crash-windows/fix.md@@ -0,0 +1,68 @@+# Bug Fix: hosted plugin crashes when its bus layout grows past Nota's process buffer++- **Slug**: plugin-add-crash-windows+- **Fixed**: 2026-10-13+- **Assessment**: ./assessment.md+- **Status**: applied++## Summary++`PluginInstrument::render` and `PluginEffect::process` now never hand a plugin a buffer narrower than its current+layout. Channels past `storage_` point at one zeroed per-instance scratch channel, so a VST3 plugin that widens its+buses via `restartComponent(kIoChanged)` (Reaktor's Play/Patch/Build switch) no longer gets null channel pointers on+the audio thread. Instrument `storage_` is also sized by the wider of inputs/outputs.++## Changes++| File | Change | Notes |+|------|--------|-------|+| `src/native/nota.engine/pluginhost/PluginHost.cpp` | modified | new `pluginChannelPtrs()` helper + `kNoAllocChans`; used by `PluginInstrument::render` and `PluginEffect::process`; `spare_` scratch channel (sized in `prepare()` / `setSampleRate()`); instrument `storage_` = `max(2, in, out)` |++## Diff Highlights++```cpp+int pluginChannelPtrs(const juce::AudioProcessor& p, juce::AudioBuffer<float>& storage,+ float* spare, int frames, float* (&ptrs)[kMaxChans]) {+ const int have = juce::jmin(storage.getNumChannels(), kMaxChans);+ const int want = juce::jmin(kMaxChans, juce::jmax(kNoAllocChans, have,+ p.getTotalNumInputChannels(), p.getTotalNumOutputChannels()));+ if (want > have) juce::FloatVectorOperations::clear(spare, frames);+ for (int c = 0; c < want; ++c) ptrs[c] = c < have ? storage.getWritePointer(c) : spare;+ return want;+}+```++The buffer always spans at least 31 channels — the most a referring `juce::AudioBuffer` holds without allocating —+which also covers a layout change that lands between reading the channel counts and JUCE taking its process lock.++## Tests Added or Updated++None in the repo: the smoke test has no hosted plugin that changes its layout at runtime (see Follow-ups).++## Local Verification++- Deterministic repro with the real Reaktor 6 VST3 (installed on this Mac), harness `/tmp/widenharness` (Python ctypes+ over `libnota_engine.dylib`, `NOTA_DATA_DIR` isolated, copy of the user's `plugins.xml`). A temporary, since removed+ `TEMP-VERIFY` hook enabled all of Reaktor's buses and re-prepared it like JUCE's `restartComponentOnMessageThread`+ does, leaving `storage_` as is: layout went `in=0 out=2` → `in=2 out=16` with `storage=2`.+ - old buffer width (toggle) → **SIGSEGV during render** (exit 139)+ - fixed → 200 × 512-frame blocks rendered, exit 0+ - fixed, no hook → 200 blocks rendered, exit 0+- `scripts/build.sh` → native + managed build OK, **SMOKE TEST PASSED**.+- Not done: clicking Reaktor's mode buttons in the GUI app (no WindowServer in the sandbox), and no Windows /+ DecentSampler run.++## Deviations from Assessment++- The assessment proposed passing `kMaxChans` (64) channels every block. That would make JUCE's referring+ `AudioBuffer` allocate on the audio thread (its inline space is 32 pointers), so the buffer instead spans+ `max(31, storage, plugin in, plugin out)`, capped at 64. A plugin with more than 31 channels still makes the+ `AudioBuffer` allocate, as it already did before the fix.++## Follow-ups++- Confirm by hand in the app: Reaktor 6 VST3 → open GUI → Play/Patch/Build (`/speckit-bug-test`).+- Ask the Windows reporter to retest with DecentSampler on the build with this fix.+- `audioProcessorChanged` could resize `storage_` when the layout grows, so the extra channels become audible rather+ than discarded. That needs a lock-free buffer swap; out of scope for the hotfix.+- CHANGELOG `[Unreleased]` → Fixed entry.diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2e7b5196..d997995c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -34,6 +34,11 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.track's instrument and switches the instrument if the preset is for a different one. Thisworks for factory presets, your own presets and sample-pack presets, and the track's effectsstay. A preset dropped on empty space still starts a new track.+- **Plug-ins that change their inputs or outputs no longer crash Nota:** some VST3+ plug-ins add audio inputs or outputs while they run — Reaktor 6 does when you switch+ between Play, Patch and Build. Nota used to crash the moment that happened. The plug-in+ now keeps playing; outputs Nota doesn't use are ignored. This is also the likely cause of+ crashes reported on Windows when adding a plug-in such as DecentSampler.## [0.51.2] — 2026-10-11diff --git a/scripts/release-bump.sh b/scripts/release-bump.shnew file mode 100755index 00000000..c2504bd8--- /dev/null+++ b/scripts/release-bump.sh@@ -0,0 +1,45 @@+#!/usr/bin/env bash+# SPDX-License-Identifier: AGPL-3.0-only+#+# Bumps the app (VERSION) and engine (src/native/nota.engine/VERSION) versions together,+# by the project's rule: a feature release bumps both minors, a fix release bumps both+# patches, and a component that resets starts at 1, never 0 (0.51.2 -> 0.52.1).+#+# Usage: scripts/release-bump.sh <minor|patch> [--dry-run]+# Prints "app OLD -> NEW" and "engine OLD -> NEW"; --dry-run writes nothing.++set -euo pipefail+cd "$(dirname "$0")/.."++kind="${1:?usage: $0 <minor|patch> [--dry-run]}"+dry="${2:-}"++bump() {+ local major minor patch+ IFS=. read -r major minor patch <<<"$1"+ case "$kind" in+ minor) echo "${major}.$((minor + 1)).1" ;;+ patch) echo "${major}.${minor}.$((patch + 1))" ;;+ *) echo "error: unknown bump '$kind' (minor | patch)" >&2; exit 1 ;;+ esac+}++app_file=VERSION+engine_file=src/native/nota.engine/VERSION+app_old="$(tr -d '[:space:]' <"$app_file")"+engine_old="$(tr -d '[:space:]' <"$engine_file")"+app_new="$(bump "$app_old")"+engine_new="$(bump "$engine_old")"++if git rev-parse -q --verify "refs/tags/v${app_new}" >/dev/null; then+ echo "error: tag v${app_new} already exists" >&2+ exit 1+fi++echo "app ${app_old} -> ${app_new}"+echo "engine ${engine_old} -> ${engine_new}"++if [ "$dry" != "--dry-run" ]; then+ printf '%s' "$app_new" >"$app_file"+ printf '%s' "$engine_new" >"$engine_file"+fidiff --git a/scripts/release-notes.sh b/scripts/release-notes.shnew file mode 100755index 00000000..9d06c98d--- /dev/null+++ b/scripts/release-notes.sh@@ -0,0 +1,65 @@+#!/usr/bin/env bash+# SPDX-License-Identifier: AGPL-3.0-only+#+# Renders a release's curated notes (release-notes/X.Y.Z.{en,ru}.md) for one place.+# The one source of the published release text: the release workflow builds the GitHub+# release body with it, and /release builds the news posts with it, then checks the+# published draft against it, so the text can't drift between the places.+#+# Usage: scripts/release-notes.sh <version> <github|post-en|post-ru>+# github GitHub release body: title + EN notes + install table+# post-en English news-channel post: title + EN notes + download link+# post-ru Russian news-channel post: title + RU notes + download link++set -euo pipefail+cd "$(dirname "$0")/.."++version="${1:?usage: $0 <version> <github|post-en|post-ru>}"+target="${2:?usage: $0 <version> <github|post-en|post-ru>}"+release_url="https://github.com/nota-daw/nota/releases/tag/v${version}"++# The note file's body: drop the SPDX comment line and leading/trailing blank lines.+body() {+ local file="release-notes/${version}.$1.md"+ if [ ! -s "$file" ]; then+ echo "error: $file is missing or empty" >&2+ exit 1+ fi+ grep -v '^<!-- SPDX-License-Identifier' "$file" | sed '/./,$!d' | sed -e :a -e '/^\n*$/{$d;N;ba' -e '}'+}++case "$target" in+ github)+ en="$(body en)"+ cat <<EOF+🎛 **Nota ${version} is out**++${en}++---++### Install++| System | File |+|---|---|+| macOS, Apple Silicon | \`Nota-*-arm64.dmg\` |+| macOS, Intel | \`Nota-*-x86_64.dmg\` |+| Windows | \`Nota-Setup-*-x64.exe\` (\`-arm64\` for Windows on ARM) |+| Linux | \`Nota-*-x86_64.AppImage\` (\`-aarch64\` for ARM) |++**First launch:** Nota isn't signed with a paid certificate yet. On **macOS**, if it says Apple could not verify Nota, open **System Settings → Privacy & Security** and click **Open Anyway** — [step-by-step guide](https://github.com/nota-daw/nota#opening-nota-on-macos). On **Windows**, click **More info → Run anyway** in SmartScreen.+EOF+ ;;+ post-en)+ en="$(body en)"+ printf '🎛 **Nota %s is out**\n\n%s\n\nDownload: %s\n' "$version" "$en" "$release_url"+ ;;+ post-ru)+ ru="$(body ru)"+ printf '🎛 **Вышла Nota %s**\n\n%s\n\nСкачать: %s\n' "$version" "$ru" "$release_url"+ ;;+ *)+ echo "error: unknown target '$target' (github | post-en | post-ru)" >&2+ exit 1+ ;;+esacdiff --git a/scripts/release-tag.sh b/scripts/release-tag.shnew file mode 100755index 00000000..55ba31e4--- /dev/null+++ b/scripts/release-tag.sh@@ -0,0 +1,34 @@+#!/usr/bin/env bash+# SPDX-License-Identifier: AGPL-3.0-only+#+# Creates the local vX.Y.Z release tag on main once the release PR (develop -> main) has+# merged. It runs the same checks as the release workflow's guard first, so a tag that+# CI would reject is never made. It does not push — pushing the tag starts the release+# build, and that stays a human step.+#+# Usage: scripts/release-tag.sh++set -euo pipefail+cd "$(dirname "$0")/.."++fail() { echo "error: $*" >&2; exit 1; }++[ "$(git rev-parse --abbrev-ref HEAD)" = "main" ] || fail "not on main — run: git switch main && git pull"+[ -z "$(git status --porcelain)" ] || fail "working tree is not clean"++git fetch --quiet origin main+[ "$(git rev-parse HEAD)" = "$(git rev-parse origin/main)" ] \+ || fail "local main differs from origin/main — run: git pull --ff-only"++version="$(tr -d '[:space:]' <VERSION)"+tag="v${version}"++git rev-parse -q --verify "refs/tags/${tag}" >/dev/null && fail "tag ${tag} already exists locally"+git ls-remote --exit-code --tags origin "refs/tags/${tag}" >/dev/null 2>&1 \+ && fail "tag ${tag} already exists on origin"+grep -qE "^## \[${version}\]" CHANGELOG.md || fail "CHANGELOG.md has no '## [${version}]' section"+scripts/release-notes.sh "$version" github >/dev/null # fails if either notes file is missing++git tag -a "$tag" -m "Nota ${tag}"+echo "Created ${tag} on $(git rev-parse --short HEAD). Push it to start the release build:"+echo " git push origin ${tag}"diff --git a/scripts/release-verify.sh b/scripts/release-verify.shnew file mode 100755index 00000000..bfb1a1fe--- /dev/null+++ b/scripts/release-verify.sh@@ -0,0 +1,47 @@+#!/usr/bin/env bash+# SPDX-License-Identifier: AGPL-3.0-only+#+# Checks the GitHub release the workflow drafted for vX.Y.Z: all six platform files are+# attached and the body matches, word for word, what scripts/release-notes.sh renders+# from release-notes/. Needs the gh CLI signed in to an account that can see drafts.+#+# Usage: scripts/release-verify.sh [version] (default: the version in VERSION)++set -euo pipefail+cd "$(dirname "$0")/.."++version="${1:-$(tr -d '[:space:]' <VERSION)}"+tag="v${version}"+repo="nota-daw/nota"++json="$(gh release view "$tag" --repo "$repo" --json isDraft,body,assets,url)" \+ || { echo "error: no GitHub release for ${tag} yet — is the workflow still running?" >&2; exit 1; }++# GitHub may store the body with CRLF and trim trailing space; compare normalised text.+normalise() { tr -d '\r' | sed -e 's/[[:space:]]*$//' | sed -e :a -e '/^\n*$/{$d;N;ba' -e '}'; }+expected="$(scripts/release-notes.sh "$version" github | normalise)"+actual="$(jq -r .body <<<"$json" | normalise)"++status=0+if [ "$expected" = "$actual" ]; then+ echo "ok body matches release-notes/${version}.{en,ru}.md"+else+ echo "FAIL body differs from release-notes/${version}.{en,ru}.md (- expected, + published):"+ diff <(printf '%s\n' "$expected") <(printf '%s\n' "$actual") | sed 's/^/ /' || true+ status=1+fi++assets="$(jq -r '.assets[].name' <<<"$json")"+for pattern in "-arm64.dmg" "-x86_64.dmg" "-x64.exe" "-arm64.exe" "-x86_64.AppImage" "-aarch64.AppImage"; do+ if grep -q -- "${version}${pattern}\$" <<<"$assets"; then+ echo "ok asset *${version}${pattern}"+ else+ echo "FAIL asset *${version}${pattern} is missing"+ status=1+ fi+done++if [ "$(jq -r .isDraft <<<"$json")" = "true" ]; then+ echo "note the release is still a draft: $(jq -r .url <<<"$json")"+fi+exit $statusdiff --git a/src/native/nota.engine/pluginhost/PluginHost.cpp b/src/native/nota.engine/pluginhost/PluginHost.cppindex 562c6a51..53764b3d 100644--- a/src/native/nota.engine/pluginhost/PluginHost.cpp+++ b/src/native/nota.engine/pluginhost/PluginHost.cpp@@ -32,6 +32,7 @@#include <functional>#include <memory>#include <string>+#include <vector>namespace {@@ -360,6 +361,26 @@ extern "C" NOTA_API const char* nota_pluginhost_scan_path(int32_t index) {namespace {constexpr int kMaxChans = 64;+// Channels a referring juce::AudioBuffer holds without allocating (its preallocated+// space is 32 pointers, one of them the null terminator).+constexpr int kNoAllocChans = 31;++// Channel pointers for one processBlock: `storage`'s channels, then every further channel+// the plugin may address pointing at `spare` (one zeroed, discarded channel). JUCE maps the+// plugin's buses with buffer.getWritePointer(ch), which is null past the buffer's width, and a+// VST3 plugin can widen its layout at any moment (restartComponent kIoChanged → JUCE+// re-prepares it on the message thread, e.g. Reaktor switching Play/Patch/Build) — so the+// buffer is never narrower than the plugin's current layout, with headroom for a change that+// lands between this read and processBlock. Returns the channel count. Audio thread.+int pluginChannelPtrs(const juce::AudioProcessor& p, juce::AudioBuffer<float>& storage,+ float* spare, int frames, float* (&ptrs)[kMaxChans]) {+ const int have = juce::jmin(storage.getNumChannels(), kMaxChans);+ const int want = juce::jmin(kMaxChans, juce::jmax(kNoAllocChans, have,+ p.getTotalNumInputChannels(), p.getTotalNumOutputChannels()));+ if (want > have) juce::FloatVectorOperations::clear(spare, frames);+ for (int c = 0; c < want; ++c) ptrs[c] = c < have ? storage.getWritePointer(c) : spare;+ return want;+}// Message-thread producer -> audio-thread consumer. The editor window's computer// keyboard pushes note events here; the plugin adapter drains them in its audio@@ -653,8 +674,7 @@ public:const int nc = juce::jmin(storage_.getNumChannels(), kMaxChans);storage_.clear();float* ptrs[kMaxChans];- for (int c = 0; c < nc; ++c) ptrs[c] = storage_.getWritePointer(c);- juce::AudioBuffer<float> block(ptrs, nc, frames);+ 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);@@ -720,12 +740,15 @@ private:plugin_->setPlayConfigDetails(0, 2, sr, maxBlock_);plugin_->prepareToPlay(sr, maxBlock_);plugin_->setPlayHead(&playHead_); // DAW transport sync- storage_.setSize(juce::jmax(2, plugin_->getTotalNumOutputChannels()), maxBlock_);+ // In and out share the buffer, so it spans the wider side.+ storage_.setSize(juce::jmax(2, plugin_->getTotalNumInputChannels(), plugin_->getTotalNumOutputChannels()), maxBlock_);+ spare_.assign((size_t)maxBlock_, 0.0f);}NotaPlayHead playHead_; // declared first: outlives plugin_ (which points at it)std::unique_ptr<juce::AudioPluginInstance> plugin_;juce::AudioBuffer<float> storage_;+ std::vector<float> spare_; // the channels past storage_ (see pluginChannelPtrs)juce::MidiBuffer pending_;int maxBlock_;std::string name_; // cached plugin name for displayName()@@ -770,6 +793,7 @@ public:const int chans = juce::jmax(2, juce::jmax(plugin_->getTotalNumInputChannels(),plugin_->getTotalNumOutputChannels()));storage_.setSize(chans, maxBlock_);+ spare_.assign((size_t)maxBlock_, 0.0f);if (hasSidechain_ && plugin_->getBus(true, 1) != nullptr) {scChanOffset_ = plugin_->getChannelIndexInProcessBlockBuffer(true, 1, 0);scNumChans_ = plugin_->getBus(true, 1)->getNumberOfChannels();@@ -803,8 +827,7 @@ public:scBuf_ = nullptr; // consume once; the engine re-hands it each block if a source is setfloat* ptrs[kMaxChans];- for (int c = 0; c < nc; ++c) ptrs[c] = storage_.getWritePointer(c);- juce::AudioBuffer<float> block(ptrs, nc, frames);+ juce::AudioBuffer<float> block(ptrs, pluginChannelPtrs(*plugin_, storage_, spare_.data(), frames, ptrs), frames);empty_.clear();plugin_->processBlock(block, empty_);@@ -888,6 +911,7 @@ private:bool hasSidechain_ = false; // plugin exposes a usable sidechain input busint scChanOffset_ = -1, scNumChans_ = 0; // where its channels sit in the process bufferjuce::AudioBuffer<float> storage_;+ std::vector<float> spare_; // the channels past storage_ (see pluginChannelPtrs)juce::MidiBuffer empty_;int maxBlock_ = 0;EditorHost editor_; // declared last: destroyed before plugin_