diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml index 458be169b..77249dfff 100644 --- a/.github/workflows/p1-windows.yml +++ b/.github/workflows/p1-windows.yml @@ -1,7 +1,7 @@ name: Windows Native VST3 Host on: push: - branches: [ main, feature/p1-first-sound-windows, feature/p2-native-vst-catalog-fx-rack, feature/p2-daw-workflow-progress, fix/p2-native-output-monitor-diagnostics, fix/p2-realtime-glitch-telemetry-latest-gui, fix/p2-truthful-meter-pan-fx-toggle, feature/p2-native-state-presets ] + branches: [ main, feature/p1-first-sound-windows, feature/p2-native-vst-catalog-fx-rack, feature/p2-daw-workflow-progress, fix/p2-native-output-monitor-diagnostics, fix/p2-realtime-glitch-telemetry-latest-gui, fix/p2-truthful-meter-pan-fx-toggle, feature/p2-native-state-presets, fix/p2-fabfilter-add-workflow ] pull_request: workflow_dispatch: @@ -35,6 +35,7 @@ jobs: node --check web/app.js node --test tests/native_ui_contract_test.mjs node --test tests/native_preset_contract_test.mjs + node --test tests/fx_add_contract_test.mjs - name: Configure Windows x64 shell: pwsh run: > @@ -54,13 +55,13 @@ jobs: Where-Object { $_.Name -like "*AR*Mix*" -and $_.FullName -match 'Release' } | Select-Object -First 1 if (-not $exe) { throw "ARMixConsole EXE not found" } - Copy-Item $exe.FullName "dist/ArSonMix-P2-Native-Presets.exe" + Copy-Item $exe.FullName "dist/ArSonMix-P2-FX-Compatibility.exe" Copy-Item README.md "dist/README.md" "P2 experimental: audio routes automatically; use headphones at low level. Only Channel 1 is native. Other strips are inactive previews." | Out-File -FilePath dist/FIRST_SOUND_README.txt -Encoding utf8 - uses: actions/upload-artifact@v4 with: - name: ArSonMix-P2-Native-Presets-Windows-x64 + name: ArSonMix-P2-FX-Compatibility-Windows-x64 path: dist/ if-no-files-found: error retention-days: 14 diff --git a/CMakeLists.txt b/CMakeLists.txt index b5ffe4664..c0d35805a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ juce_add_gui_app(ARMixConsole juce_add_binary_data(ARMixAssets SOURCES web/index.html web/styles.css web/app.js web/bridge.js web/monitor.js) -target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h src/PluginCatalog.h src/DiagnosticsRecorder.h src/StereoPan.h src/NativePresetArchive.h) +target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h src/PluginCatalog.h src/DiagnosticsRecorder.h src/StereoPan.h src/NativePresetArchive.h src/VstBusLayout.h) target_compile_definitions(ARMixConsole PRIVATE JUCE_WEB_BROWSER=1 JUCE_USE_WIN_WEBVIEW2=1 diff --git a/docs/P2_FABFILTER_FX_COMPATIBILITY.md b/docs/P2_FABFILTER_FX_COMPATIBILITY.md new file mode 100644 index 000000000..97336438d --- /dev/null +++ b/docs/P2_FABFILTER_FX_COMPATIBILITY.md @@ -0,0 +1,23 @@ +# P2.4.1 — VST3 Add FX compatibility and failure diagnostics + +Hardware report: FabFilter plugins appear in installed VST3 catalog, but pressing ADD has no visible effect. + +## Source audit and fixes +- Confirmed UX defect: Native engine previously emits loading errors as a toast obscured by the Add VST3 modal; a failed insert looks like no response. +- Confirmed compatibility restriction: the host always called `setBusesLayout` with exactly one stereo input and one stereo output, potentially rejecting VST3s with an auxiliary sidechain bus or already valid default layout. Now it preserves the plugin's existing compatible main stereo bus layout, or negotiates stereo main with optional auxiliary buses disabled. +- Plugin creation still runs synchronously in the UI message thread; an indeterminate "Loading…" indicator is painted before calling JUCE, but long/blocked third-party VST creation remains possible. +- New native result event `arMixAddResult` sends result/error, elapsed time, request ID and chain size. Failures stay visible **inside** the Add FX dialog, with a diagnostic log event `FX_LOAD_FAIL`. +- Both adding a plugin and restoring a native preset apply the same bus negotiation. + +## Trial +1. Use the new Windows artifact in PR; open **MIX → ADD FX**, search FAB. +2. Choose FabFilter Pro-C 2, Pro-Q or Pro-DS. Observe Loading… status, then insert success or visible exact error. +3. On success, the plugin appears in Channel 1 live rack; click its name to open native UI; toggle power to bypass. Test with headphones at low volume. +4. On failure, copy the full text of the red FX NOT LOADED message and open **SIGNAL CHECK → OPEN DIAGNOSTIC LOG**. Attach log for class/bus/plugin-specific diagnosis. +5. Test at least one previously working ArSonKuPik and native preset Save/Recall to prevent regression. + +## Remaining risks +- No real FabFilter VST3 binary and license is available to CI. Windows build GREEN does **not** prove vendor-specific runtime compatibility. +- Creating VSTs remains synchronous on the host message thread, so slow initialization may stall even with a Loading state. True off-thread staging plus graph swap is subsequent ARD work. +- Scanner is a worker thread, not a separate crash-isolated process. +- Host processes exactly one native stereo Channel 1 path; other mixer strips remain previews. diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index fdf5d4ad6..4fc5812f7 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -4,6 +4,7 @@ #include #include "StereoPan.h" #include "NativePresetArchive.h" +#include "VstBusLayout.h" #include #include #include @@ -142,11 +143,9 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback if (! instance) return "Failed to instantiate VST3: " + error; - juce::AudioProcessor::BusesLayout layout; - layout.inputBuses.add (juce::AudioChannelSet::stereo()); - layout.outputBuses.add (juce::AudioChannelSet::stereo()); - if (! instance->setBusesLayout (layout)) - return "P2 accepts stereo-in/stereo-out effects; plugin bus layout is incompatible"; + const auto busError = armix::vst::prepareStereoEffectLayout (*instance); + if (busError.isNotEmpty()) + return chosen->name + ": " + busError; detach(); Slot node; @@ -242,11 +241,9 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback juce::String error; auto processor = formats_.createPluginInstance (*match, rate, buffer, error); if (!processor) return "Cannot open preset plugin " + fx.name + ": " + error; - juce::AudioProcessor::BusesLayout layout; - layout.inputBuses.add (juce::AudioChannelSet::stereo()); - layout.outputBuses.add (juce::AudioChannelSet::stereo()); - if (!processor->setBusesLayout (layout)) - return "Unsupported VST3 stereo bus: " + fx.name; + const auto busError = armix::vst::prepareStereoEffectLayout (*processor); + if (busError.isNotEmpty()) + return "Unsupported VST3 bus layout for " + fx.name + ": " + busError; try { // State is restored before insertion; live audio still uses the diff --git a/src/Main.cpp b/src/Main.cpp index 8ae996541..ded74c734 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -168,6 +168,22 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr browser_.emitEventIfBrowserIsVisible ("arMixCatalog", catalog_.snapshot()); } + // Every plugin insert request gets a structured result. A toast behind + // a modal is not an actionable failure report for live performers. + void emitFxAddResult (int requestId, const juce::String& name, + const juce::String& error, unsigned int elapsedMs) + { + auto response = std::make_unique(); + response->setProperty ("requestId", requestId); + response->setProperty ("name", name); + response->setProperty ("ok", error.isEmpty()); + response->setProperty ("error", error); + response->setProperty ("elapsedMs", static_cast (elapsedMs)); + response->setProperty ("chainSize", engine_.chainSize()); + if (browser_.loaded) + browser_.emitEventIfBrowserIsVisible ("arMixAddResult", juce::var (response.release())); + } + void emitPresets() { if (browser_.loaded) @@ -369,13 +385,46 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr } else if (action == "addCatalog") { - const auto* plugin = catalog_.find (args.getProperty ("id", {}).toString()); - if (!plugin) - return emitNotice ("Plugin not found in catalog. Rescan your VST3 folders.", true); - editorWindow_.reset(); - const auto error = engine_.addVst3 (plugin->path, plugin->uid, plugin->key()); - if (error.isNotEmpty()) { diagnostics_.record ("FX_LOAD_FAIL", plugin->name + ": " + error); emitNotice (error, true); } - else { diagnostics_.record ("FX_LOAD", plugin->name + " (callback reattached)"); emitChain(); emitNotice (plugin->name + " inserted. Live chain changes may briefly interrupt audio."); } + const auto requestId = static_cast (args.getProperty ("requestId", 0)); + const auto requestedId = args.getProperty ("id", {}).toString(); + const auto* plugin = catalog_.find (requestedId); + const auto name = plugin != nullptr ? plugin->name : juce::String ("Unknown VST3"); + const auto started = juce::Time::getMillisecondCounter(); + juce::String error; + + if (plugin == nullptr) + error = "Plugin is no longer in the catalog. Rescan in PLUGINS and try again."; + else + { + diagnostics_.record ("FX_ADD_REQUEST", name + " | " + plugin->path); + editorWindow_.reset(); + try + { + error = engine_.addVst3 (plugin->path, plugin->uid, plugin->key()); + } + catch (const std::exception& ex) + { + error = "VST3 instantiation threw an exception: " + juce::String (ex.what()); + } + catch (...) + { + error = "VST3 instantiation failed with an unknown exception"; + } + } + const auto elapsed = juce::Time::getMillisecondCounter() - started; + emitFxAddResult (requestId, name, error, elapsed); + if (error.isNotEmpty()) + { + diagnostics_.record ("FX_LOAD_FAIL", name + " | " + error + + " | elapsedMs=" + juce::String (elapsed)); + emitNotice (name + ": " + error, true); + } + else + { + diagnostics_.record ("FX_LOAD", name + " | elapsedMs=" + juce::String (elapsed)); + emitChain(); + emitNotice (name + " inserted into Channel 1 FX Rack."); + } } else if (action == "fxRemove") { diff --git a/src/VstBusLayout.h b/src/VstBusLayout.h new file mode 100644 index 000000000..07b7cb55e --- /dev/null +++ b/src/VstBusLayout.h @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include + +// Non-RT only. The host processes a 2-channel scratch block. Keep the +// plugin's already-compatible main stereo buses unchanged, rather than +// unconditionally forcing a new layout (which can fail for VST3s with +// optional sidechain/auxiliary buses). +namespace armix::vst +{ +inline juce::String describeBuses (const juce::AudioProcessor::BusesLayout& layout) +{ + juce::String text; + const auto describe = [] (const juce::Array& buses) + { + juce::StringArray names; + for (const auto& bus : buses) + names.add (juce::String (bus.size()) + "ch"); + return names.joinIntoString (","); + }; + return "inputs [" + describe (layout.inputBuses) + "], outputs [" + + describe (layout.outputBuses) + "]"; +} + +inline juce::String prepareStereoEffectLayout (juce::AudioProcessor& processor) +{ + if (processor.getBusCount (true) < 1 || processor.getBusCount (false) < 1) + return "VST3 has no main input or output bus"; + + auto original = processor.getBusesLayout(); + if (original.inputBuses.isEmpty() || original.outputBuses.isEmpty()) + return "VST3 reports missing main bus layout"; + const auto stereo = juce::AudioChannelSet::stereo(); + const auto disabled = juce::AudioChannelSet::disabled(); + const auto compatible = [&stereo, &disabled] (const juce::AudioProcessor::BusesLayout& l) + { + if (l.inputBuses.isEmpty() || l.outputBuses.isEmpty() || + l.inputBuses[0] != stereo || l.outputBuses[0] != stereo) return false; + for (int i = 1; i < l.inputBuses.size(); ++i) + if (l.inputBuses[i] != disabled) return false; + for (int i = 1; i < l.outputBuses.size(); ++i) + if (l.outputBuses[i] != disabled) return false; + return true; + }; + + // Working defaults (common in FabFilter and other commercial VST3s) + // must not be reset just because the host wants stereo. + if (compatible (original)) return {}; + + auto requested = original; + requested.inputBuses.set (0, stereo); + requested.outputBuses.set (0, stereo); + for (int i = 1; i < requested.inputBuses.size(); ++i) + requested.inputBuses.set (i, disabled); + for (int i = 1; i < requested.outputBuses.size(); ++i) + requested.outputBuses.set (i, disabled); + + if (processor.setBusesLayout (requested) && + compatible (processor.getBusesLayout())) return {}; + + return "Stereo main bus could not be negotiated (existing " + + describeBuses (original) + "). This host requires stereo in/out with optional sidechains disabled."; +} +} // namespace armix::vst diff --git a/tests/fx_add_contract_test.mjs b/tests/fx_add_contract_test.mjs new file mode 100644 index 000000000..0e640a20c --- /dev/null +++ b/tests/fx_add_contract_test.mjs @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// Regression guard for nonresponsive ADD FX clicks and VST3 stereo/sidechain. +import test from 'node:test'; +import assert from 'node:assert/strict'; +import {readFileSync} from 'node:fs'; +const js=readFileSync('web/bridge.js','utf8'); +const host=readFileSync('src/Main.cpp','utf8'); +const dsp=readFileSync('src/LiveAudioEngine.h','utf8'); +const layout=readFileSync('src/VstBusLayout.h','utf8'); + +test('every ADD click identifies request and reports result inside the open selector',()=>{ + assert.match(js,/send\("addCatalog",\{id,requestId\}\)/); + assert.match(js,/backend\.addEventListener\("arMixAddResult"/); + assert.match(js,/nativeAddFeedback/); + assert.match(js,/FX NOT LOADED:/); + assert.match(js,/if\(result\.ok\)hideDialog\("nativeFxSelector"\)/); + assert.match(host,/emitFxAddResult \(requestId, name, error, elapsed\)/); + assert.match(host,/FX_LOAD_FAIL/); +}); +test('plugin load and preset restore both negotiate existing VST3 bus layouts',()=>{ + assert.equal((dsp.match(/prepareStereoEffectLayout/g)||[]).length,2); + assert.match(layout,/if \(compatible \(original\)\) return \{\};/); + assert.match(layout,/requested\.inputBuses\.set \(i, disabled\)/); + assert.match(layout,/processor\.setBusesLayout \(requested\)/); +}); +test('GUI paints actual indeterminate feedback before synchronous plugin instantiate',()=>{ + assert.match(js,/requestAnimationFrame\(\(\)=>requestAnimationFrame\(\(\)=>send\("addCatalog"/); + assert.match(js,/aria-live="polite"/); + assert.match(js,/state\.adding=true/); +}); diff --git a/web/bridge.js b/web/bridge.js index ce7c52e09..363a586ca 100644 --- a/web/bridge.js +++ b/web/bridge.js @@ -11,7 +11,7 @@ const send = (action, more = {}) => backend.emitEvent("arMixAction", {action, ...more}); const state = {catalog: [], chain: [], scanning: false, message: "Connecting to native host...", - device: {}, presets: [], filter: "", selectedCategory: "All", monitor: false, error: "", progress: {active:false,phase:"done",done:0,total:0,found:0,current:""}, adding:false}; + device: {}, presets: [], addRequestId:0, addError:"", pendingPlugin:"", filter: "", selectedCategory: "All", monitor: false, error: "", progress: {active:false,phase:"done",done:0,total:0,found:0,current:""}, adding:false}; const escapeHtml = text => String(text ?? "").replace(/[&<>"']/g, c => ( {"&":"&","<":"<",">":">",'"':""","'":"'"}[c])); @@ -32,6 +32,15 @@ background:linear-gradient(180deg,#405c70 0%,#243846 47%,#0d1e29 100%);cursor:pointer; box-shadow:inset 0 1px 1px #93badc70,0 2px 3px #0008} .native-btn:hover{border-color:#62b8dc} + .native-add-feedback{margin:9px 0 11px;padding:10px 12px;border-radius:5px;font-size:12px; + line-height:1.55;border:1px solid #4e7789;background:#153545;color:#b9eaff} + .native-add-feedback.error{background:#39252a;border-color:#b76b68;color:#ffe0d4} + .native-add-feedback.waiting{background:#203849;border-color:#669abc;color:#c4ecff} + .native-add-feedback strong{font-weight:600} + .native-add-feedback .native-busy{display:inline-block;width:10px;height:10px; + margin-right:7px;border:2px solid #477a97;border-top-color:#80eaff; + border-radius:100%;animation:nativeBusySpin 1s linear infinite} + @keyframes nativeBusySpin{to{transform:rotate(360deg)}} .native-btn.primary{border-color:#2dbee9;background:linear-gradient(180deg,#4cddff 0%,#0f9fd1 42%,#08688c 100%);color:#042231} .native-btn.warn{color:#ffd0c9;border-color:#915552} .native-btn.on{border-color:#4ae3fd;color:#9ceaff;background:linear-gradient(#165b79,#123142)} @@ -147,7 +156,7 @@ ${escapeHtml(p.vendor||"Unknown vendor")} · ${escapeHtml(p.category||"Audio effect")} VST3 `).join("") + ${state.chain.length>=8||state.adding?"disabled":""}>+ ADD`).join("") :'
No matching installed VST3 effects. Open Plugin Manager to scan your folders.
'; } function filterPlugins(){ @@ -162,6 +171,14 @@
${fxCategories.map(c=>``).join("")}
+
+ ${state.adding?`Loading ${escapeHtml(state.pendingPlugin)}… + Initializing VST3; this may take a moment.`: + state.addError?`FX NOT LOADED: ${escapeHtml(state.addError)} +
Open PLUGINS to rescan or SIGNAL CHECK for diagnostic logs.
`:""} +
${pluginRows(filterPlugins())}
`; dlg.querySelector(".native-dialog-footer").innerHTML=`${state.catalog.length} available plugins · OPEN PLUGIN MANAGER for scanning and import`; } @@ -405,8 +422,25 @@ send(action);return; } if(el.dataset.nativeAdd){ + if(state.adding)return; + const id=el.dataset.nativeAdd; + const chosen=state.catalog.find(p=>p.id===id); state.adding=true; - send("addCatalog",{id:el.dataset.nativeAdd});return; + state.addError=""; + state.pendingPlugin=chosen?.name||"selected effect"; + const requestId=++state.addRequestId; + const progress=document.getElementById("nativeAddFeedback"); + if(progress){ + progress.style.display=""; + progress.className="native-add-feedback waiting"; + progress.textContent="Loading "+state.pendingPlugin+"… Initializing VST3."; + progress.setAttribute("aria-busy","true"); + } + document.querySelectorAll("#nativeFxSelector [data-native-add]") + .forEach(b=>b.disabled=true); + // Let the WebView paint before the synchronous plugin factory call. + requestAnimationFrame(()=>requestAnimationFrame(()=>send("addCatalog",{id,requestId}))); + return; } if(el.dataset.nativeCategory){ state.selectedCategory=el.dataset.nativeCategory; @@ -465,13 +499,23 @@ updateProgress(); }); backend.addEventListener("arMixChain",nodes=>{ - const before=state.chain.length; state.chain=Array.isArray(nodes)?nodes:[]; - if(state.adding && state.chain.length>before){hideDialog("nativeFxSelector");state.adding=false;} repaint(); const picker=document.getElementById("nativeFxSelector"); if(picker&&!picker.hidden)renderPicker(); }); + backend.addEventListener("arMixAddResult",result=>{ + if(Number(result.requestId)!==state.addRequestId)return; + state.adding=false; + state.pendingPlugin=""; + state.addError=result.ok?"":String(result.error||"Unknown VST3 loading failure"); + if(result.ok)hideDialog("nativeFxSelector"); + else{ + // Keep error in the open modal; toast behind backdrop is insufficient. + renderPicker(); + document.getElementById("nativeAddFeedback")?.setAttribute("aria-busy","false"); + } + }); backend.addEventListener("arMixNotice",data=>{ const text=data.text||""; const toast=document.querySelector("#toast"); @@ -480,7 +524,7 @@ toast.classList.add("show"); setTimeout(()=>toast.classList.remove("show"),3500); } - if(data.error){state.adding=false;console.warn("AR MIX native:",text);} + if(data.error)console.warn("AR MIX native:",text); }); let liveInputLevel=0, liveOutputLevel=0, liveOutputLeft=0, liveOutputRight=0; let lastSetupSignature="";