From 653cff81071732d051777c7f454488c17eb5fc51 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 25 Oct 2026 06:59:29 +0700 Subject: [PATCH 1/2] feat(ux): DAW-style FX picker, plugin manager and truthful progress UX for ASIO/VST3 --- .github/workflows/p1-windows.yml | 9 +- README.md | 4 + docs/P2_DAW_WORKFLOW.md | 34 +++ src/Main.cpp | 83 ++++++-- src/PluginCatalog.h | 55 ++++- web/bridge.js | 346 ++++++++++++++++++++++--------- 6 files changed, 417 insertions(+), 114 deletions(-) create mode 100644 docs/P2_DAW_WORKFLOW.md diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml index 58df495cd..7986a7b82 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 ] + branches: [ main, feature/p1-first-sound-windows, feature/p2-native-vst-catalog-fx-rack, feature/p2-daw-workflow-progress ] pull_request: workflow_dispatch: @@ -27,6 +27,9 @@ jobs: - name: Install WebView2 SDK for JUCE shell: pwsh run: nuget install Microsoft.Web.WebView2 -Version 1.0.3485.44 -OutputDirectory .deps -NonInteractive + - name: Validate native UI JavaScript + shell: pwsh + run: node --check web/bridge.js - name: Configure Windows x64 shell: pwsh run: > @@ -46,13 +49,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/AR-MIX-Studio-P2.exe" + Copy-Item $exe.FullName "dist/AR-MIX-Studio-P2-DAW.exe" Copy-Item README.md "dist/README.md" "P2 experimental: output muted until MONITOR ON; do not use during a public livestream without hardware tests." | Out-File -FilePath dist/FIRST_SOUND_README.txt -Encoding utf8 - uses: actions/upload-artifact@v4 with: - name: AR-MIX-Studio-P2-Windows-x64 + name: AR-MIX-Studio-P2-DAW-Workflow-Windows-x64 path: dist/ if-no-files-found: error retention-days: 14 diff --git a/README.md b/README.md index 8f9ed3ffc..6e73913da 100644 --- a/README.md +++ b/README.md @@ -58,3 +58,7 @@ GitHub Actions: [Windows First Sound builds](https://github.com/masarray/arsonmi The native Windows host supports **Scan VST3**, **Add Plugin Folder**, **Import VST3** and a persistent plugin catalog in user app-data. The FX Rack inside WebView2 now controls the **one native stereo audio path** with up to 8 real VST3 effects: add, bypass, reorder, remove and open plugin UI. The Windows audio setup dialog is also native, with saved device configuration. All remaining UI preview channels and factory vocal presets are still visual; do not infer that they are running live audio. Legacy VST2 `.dll` is **not** supported or automatically treated as VST3. Plugin scanning uses a worker, but not yet a crash-isolated subprocess; avoid unknown plugins during a livestream. Read [P2 Hardware Trial](docs/P2_NATIVE_FX_RACK.md). + +## P2 DAW UX improvement + +Use MIX → Channel 1 ADD FX to select a real indexed VST3; PLUGINS opens Plugin Manager for scan/import only. Audio Setup now reports loading status and reuses the native selector window. Scan uses real candidate counters and indeterminate discovery stage. See [P2 DAW workflow guide](docs/P2_DAW_WORKFLOW.md). diff --git a/docs/P2_DAW_WORKFLOW.md b/docs/P2_DAW_WORKFLOW.md new file mode 100644 index 000000000..19bcd142e --- /dev/null +++ b/docs/P2_DAW_WORKFLOW.md @@ -0,0 +1,34 @@ +# P2 DAW Workflow & Progress UX — Windows Trial + +## What changed + +- **Mixer-first add:** click **ADD FX** directly on channel 1. The FX selector opens an indexed VST3 catalog with search and categories. Click **+ ADD** to insert into the real native chain; existing mixer insert buttons open plugin editors. Do not confuse the other 11 visual channel strips with native I/O. +- **Plugin Manager:** **PLUGINS** in the toolbar opens plugin administration. System scan, custom folder scan and individual `.vst3` import exist exclusively here, not inside the effects picker. +- **Real scanning progress:** while finding `.vst3` candidates the total is unknown (animated indeterminate bar). Once the scanner has enumerated candidate modules, the bar becomes determinate using **processed candidate count / total candidates**. It shows current module and effects found; no invented percentages. +- **Audio Setup progress:** opening from toolbar or SETUP immediately shows a busy dialog while JUCE initializes the selector. First-open ASIO driver enumeration may still take time. The app reports actual setup construction time in milliseconds; the native audio setup window is reused for later opens. +- **Background:** VST3 scan runs on a dedicated worker. Metadata discovery can still run untrusted third-party plugin code; there is no crash isolation in this version. +- **Monitor safety:** scanning and chain structural changes require MONITOR OFF. Live bypass uses atomic flags in the native engine. + +## Quick trial + +1. Download and unzip **AR-MIX-Studio-P2-DAW-Workflow-Windows-x64** from a successful GitHub Actions run. +2. Launch the EXE and click **AUDIO SETUP**. Observe a graphical progress indicator; configure your ASIO or WASAPI input/output. Close settings, then reopen to verify faster cached window reuse. +3. Click **PLUGINS** and **SCAN STANDARD FOLDERS**. Watch the scan change from discovery (indeterminate) to candidate inspection (% with real totals). Import a single .vst3 with **IMPORT INDIVIDUAL .VST3** or add a folder if needed. +4. Return to **MIX**, click **ADD FX** on Channel 1, search the catalog, and choose **+ ADD**. The effect should appear in the real channel rack. Click the inserted plugin to open its native editor. +5. With monitoring off, build your chain. Enable monitoring only after you have wired headphones at low volume and have a stable driver setup. + +## Known limits + +- First ASIO driver enumeration may still be slow or blocked by an external driver. Reporting an indeterminate busy state is honest; claiming a fake numeric percentage is not. Timing data supports the next performance audit. +- Scanner currently loads third-party plugin metadata in the application process. Crashes/hangs remain possible. +- The catalog indexes VST3 only. VST2 *.dll loading is unsupported. +- P2 is one native Channel 1 input path with up to eight serial stereo VST3 effects, not a complete 12-channel live mixer. +- GUI and scanner features compile in Windows CI but hardware scan/audio/editor behavior must be validated on a physical Windows PC. + +## Acceptance + +- Windows CI GREEN including `node --check web/bridge.js`, C++ Release build and RT tests. +- Opening Audio Setup displays busy feedback immediately; subsequent opens use the cached native window. +- Plugin Manager displays real progress with total after discovery. +- ADD FX on mixer opens selector without navigation to manager. +- No fake scan percentages, no plugin scan operations accidentally triggered from FX selection. diff --git a/src/Main.cpp b/src/Main.cpp index 7057f9ce5..da3f35dd7 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -63,6 +63,24 @@ class PluginEditorWindow final : public juce::DocumentWindow void closeButtonPressed() override { setVisible (false); } }; +class AudioSetupWindow final : public juce::DocumentWindow +{ +public: + explicit AudioSetupWindow (juce::AudioDeviceManager& manager) + : juce::DocumentWindow ("AR MIX — ASIO / WASAPI Setup", + juce::Colour (0xff14212a), allButtons) + { + setUsingNativeTitleBar (true); + setResizable (true, true); + setResizeLimits (580, 430, 1300, 1000); + auto* selector = new juce::AudioDeviceSelectorComponent ( + manager, 1, 2, 1, 2, false, false, false, false); + setContentOwned (selector, true); + centreWithSize (740, 590); + } + void closeButtonPressed() override { setVisible (false); } +}; + class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer { public: @@ -84,7 +102,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer .withResourceProvider (assetFor)) { settingsDirectory().createDirectory(); - catalog_.onChanged = [this] { emitCatalog(); }; + catalog_.onChanged = [this] { emitCatalog(); emitScanProgress(); }; setUsingNativeTitleBar (true); setResizable (true, true); setResizeLimits (1100, 650, 3840, 2160); @@ -96,8 +114,8 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer startupError_ = engine_.start (saved.get()); browser_.goToURL (juce::WebBrowserComponent::getResourceProviderRoot()); startTimerHz (12); - if (catalog_.entries().empty()) - catalog_.scanDefaults(); + // Defer initial scan until explicitly requested in Plugin Manager. + // Startup must not spend seconds enumerating third-party VST3 modules. } ~ConsoleWindow() override @@ -105,6 +123,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer stopTimer(); catalog_.onChanged = nullptr; editorWindow_.reset(); + audioSetupWindow_.reset(); engine_.stop(); browser_.setVisible (false); } @@ -117,8 +136,10 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer Browser browser_; std::unique_ptr chooser_; std::unique_ptr editorWindow_; + std::unique_ptr audioSetupWindow_; juce::String startupError_, lastAudioXml_; bool initialStateSent_ = false; + bool setupLaunching_ = false; unsigned int timerTicks_ = 0; void emitNotice (const juce::String& message, bool error = false) @@ -158,18 +179,51 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer engine_.setMasterMuted (bool (value)); } + void emitSetupPhase (const juce::String& phase, int elapsedMs = 0) + { + auto o = std::make_unique(); + o->setProperty ("phase", phase); + o->setProperty ("elapsedMs", elapsedMs); + if (browser_.loaded) + browser_.emitEventIfBrowserIsVisible ("arMixSetupProgress", juce::var (o.release())); + } + + void emitScanProgress() + { + if (browser_.loaded) + browser_.emitEventIfBrowserIsVisible ("arMixScanProgress", catalog_.progress()); + } + void showDeviceSetup() { - juce::DialogWindow::LaunchOptions opts; - opts.dialogTitle = "AR MIX — ASIO / WASAPI Audio Setup"; - opts.dialogBackgroundColour = juce::Colour (0xff14212a); - auto* selector = new juce::AudioDeviceSelectorComponent ( - engine_.devices(), 1, 2, 1, 2, false, false, false, false); - selector->setSize (720, 560); - opts.content.setOwned (selector); - opts.useNativeTitleBar = true; - opts.resizable = true; - opts.launchAsync(); + if (setupLaunching_) return; + + // The native JUCE device list is cached after first construction: + // reopening the settings window avoids repeating full widget setup. + if (audioSetupWindow_ != nullptr) + { + audioSetupWindow_->setVisible (true); + audioSetupWindow_->toFront (true); + emitSetupPhase ("opened", 0); + return; + } + + setupLaunching_ = true; + emitSetupPhase ("preparing"); + const auto begin = juce::Time::getMillisecondCounter(); + juce::Timer::callAfterDelay (150, + [safe = juce::Component::SafePointer (this), begin] + { + if (safe == nullptr) return; + safe->emitSetupPhase ("enumerating"); + safe->audioSetupWindow_ = + std::make_unique (safe->engine_.devices()); + safe->audioSetupWindow_->setVisible (true); + safe->audioSetupWindow_->toFront (true); + safe->setupLaunching_ = false; + safe->emitSetupPhase ("opened", + static_cast (juce::Time::getMillisecondCounter() - begin)); + }); } void chooseImport() @@ -294,8 +348,11 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer { initialStateSent_ = true; emitCatalog(); + emitScanProgress(); emitChain(); } + if (catalog_.busy() && timerTicks_ % 3 == 0) + emitScanProgress(); // Persist configuration off the callback; cap XML serialization to ~3 s. if (++timerTicks_ % 36 == 0) { diff --git a/src/PluginCatalog.h b/src/PluginCatalog.h index b27c20c2d..d3be9b56c 100644 --- a/src/PluginCatalog.h +++ b/src/PluginCatalog.h @@ -70,6 +70,25 @@ class PluginCatalog final const std::vector& entries() const noexcept { return entries_; } bool busy() const noexcept { return scanning_.load(); } juce::String scanMessage() const { return scanMessage_; } + // Real scan counters. Enumeration has no known denominator; only report + // a percentage after candidate discovery has finished. + juce::var progress() const + { + auto result = std::make_unique(); + const auto phase = phase_.load (std::memory_order_acquire); + const auto total = total_.load (std::memory_order_relaxed); + result->setProperty ("active", busy()); + result->setProperty ("phase", phase == 1 ? "discovering" : + phase == 2 ? "inspecting" : "done"); + result->setProperty ("done", completed_.load (std::memory_order_relaxed)); + result->setProperty ("total", total); + result->setProperty ("found", found_.load (std::memory_order_relaxed)); + { + const juce::ScopedLock lock (progressLock_); + result->setProperty ("current", current_); + } + return juce::var (result.release()); + } Callback onChanged; void addDirectory (const juce::File& folder) @@ -146,6 +165,9 @@ class PluginCatalog final #endif std::vector found; juce::VST3PluginFormat format; + juce::StringArray allCandidates; + // 1. Enumerate candidates. Total cannot be estimated here. + owner_.phase_.store (1, std::memory_order_release); for (const auto& requested : requested_) { if (threadShouldExit()) break; @@ -159,11 +181,23 @@ class PluginCatalog final } else if (file.hasFileExtension (".vst3")) candidates.add (requested); - for (const auto& path : candidates) + allCandidates.addIfNotAlreadyThere (path); + } + + // 2. Inspect actual plugins; progress denominator is now real. + owner_.total_.store (allCandidates.size(), std::memory_order_relaxed); + owner_.phase_.store (2, std::memory_order_release); + for (int n = 0; n < allCandidates.size(); ++n) + { + if (threadShouldExit()) break; + const auto path = allCandidates[n]; + { + const juce::ScopedLock lock (owner_.progressLock_); + owner_.current_ = juce::File (path).getFileName(); + } + if (format.fileMightContainThisPluginType (path)) { - if (threadShouldExit()) break; - if (! format.fileMightContainThisPluginType (path)) continue; juce::OwnedArray descriptions; format.findAllTypesForFile (descriptions, path); for (int i = 0; i < descriptions.size(); ++i) @@ -175,6 +209,12 @@ class PluginCatalog final desc->uniqueId, i }); } } + owner_.found_.store (static_cast (found.size()), std::memory_order_relaxed); + owner_.completed_.store (n + 1, std::memory_order_release); + } + { + const juce::ScopedLock lock (owner_.progressLock_); + owner_.current_.clear(); } #if JUCE_WINDOWS if (SUCCEEDED (hr)) CoUninitialize(); @@ -198,6 +238,7 @@ class PluginCatalog final [] (const CatalogEntry& a, const CatalogEntry& b) { return a.name.compareIgnoreCase (b.name) < 0; }); owner.scanMessage_ = "Scan complete: " + juce::String (results.size()) + " plugin variants inspected"; + owner.phase_.store (0, std::memory_order_release); owner.scanning_.store (false); owner.save(); if (owner.onChanged) owner.onChanged(); @@ -208,6 +249,11 @@ class PluginCatalog final void scan (const juce::StringArray& paths) { if (busy()) return; + completed_.store (0); + total_.store (0); + found_.store (0); + phase_.store (1); + { const juce::ScopedLock lock (progressLock_); current_.clear(); } scanning_.store (true); scanMessage_ = "Scanning VST3 metadata (background)..."; if (onChanged) onChanged(); @@ -251,6 +297,9 @@ class PluginCatalog final juce::StringArray customFolders_; std::atomic alive_ { true }, scanning_ { false }; std::shared_ptr> lifetime_ = std::make_shared> (true); + mutable juce::CriticalSection progressLock_; + juce::String current_; + std::atomic phase_ { 0 }, total_ { 0 }, completed_ { 0 }, found_ { 0 }; juce::String scanMessage_ = "Ready"; Scanner worker_; }; diff --git a/web/bridge.js b/web/bridge.js index 2eaaefc20..518510d36 100644 --- a/web/bridge.js +++ b/web/bridge.js @@ -7,7 +7,7 @@ const send = (action, more = {}) => backend.emitEvent("arMixAction", {action, ...more}); const state = {catalog: [], chain: [], scanning: false, message: "Connecting to native host...", - device: {}, filter: "", selectedCategory: "All", monitor: false, error: ""}; + device: {}, 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])); @@ -64,6 +64,7 @@ .status-help{flex:1;min-width:0} @media(max-width:1150px){.native-grid{grid-template-columns:1fr}.native-hdr{flex-direction:column}} `; + css.textContent += "\n .native-modal{position:fixed;inset:0;z-index:700;display:flex;align-items:center;justify-content:center;\n background:rgba(3,11,18,.78);backdrop-filter:blur(5px);padding:22px;box-sizing:border-box}\n .native-modal[hidden]{display:none}\n .native-dialog{width:min(860px,96vw);max-height:min(840px,92vh);overflow:hidden;\n display:flex;flex-direction:column;background:linear-gradient(145deg,#243945 0%,#101e29 62%,#0c1821);\n border:1px solid #638293;border-radius:11px;box-shadow:0 18px 80px #000c,inset 0 1px #b2d9e449}\n .native-dialog-header{display:flex;align-items:center;justify-content:space-between;gap:15px;\n border-bottom:1px solid #3c5360;padding:14px 17px}\n .native-dialog-header h2{font-size:18px;font-weight:500;color:#e4f4f9;margin:4px 0}\n .native-dialog-body{padding:14px 17px;overflow:auto;min-height:60px}\n .native-dialog-footer{border-top:1px solid #334b58;padding:9px 17px;color:#91abb8;font-size:11px}\n .native-dialog.small{max-width:520px}\n .native-bar{height:12px;border:1px solid #527282;background:#0a1621;border-radius:7px;overflow:hidden;position:relative;\n box-shadow:inset 0 2px 5px #000c}\n .native-bar-fill{height:100%;width:0%;background:linear-gradient(180deg,#8ef6ff,#17a8da 43%,#08688e);\n box-shadow:0 0 8px #1ed5fcbb;border-right:1px solid #ddffff}\n .native-bar.unknown .native-bar-fill{width:34%;position:absolute;animation:native-indeterminate 1.65s ease-in-out infinite}\n @keyframes native-indeterminate{0%{left:-36%}50%{left:58%}100%{left:105%}}\n .native-progress-info{font:11px monospace;color:#a5d5e2;margin:8px 0;display:flex;justify-content:space-between;gap:9px}\n .native-progress-info strong{font-weight:500;color:#d8f9ff}\n #nativeScanHud{position:fixed;left:50%;transform:translateX(-50%);bottom:37px;z-index:550;\n background:#152c3b;border:1px solid #537588;border-radius:8px;box-shadow:0 6px 20px #000a;\n padding:9px 13px;width:min(470px,90vw)}\n #nativeScanHud[hidden]{display:none}\n .native-result{display:flex;align-items:center;gap:7px;background:#10222c;border:1px solid #314d5c;\n border-radius:6px;padding:9px 11px;margin:5px 0}\n .native-result span{flex:1;min-width:0}\n .native-result b{display:block;font-weight:500;color:#d6edf7;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n .native-result small{display:block;color:#88aaba;font-size:10px;margin-top:4px}\n .native-search{font-family:inherit!important}\n"; document.head.appendChild(css); const footer = document.querySelector(".status-help"); if(footer) footer.innerHTML = `
@@ -89,53 +90,141 @@ return `
AR MIX · NATIVE VST3 ENGINE

${escapeHtml(title)}

${escapeHtml(subtitle)}
`; } - function renderRack() { - if(!workspace || currentTab()!=="FX RACK") return; - const matches = state.catalog.filter(p => ( - (state.selectedCategory==="All"||classFor(p)===state.selectedCategory) && - ((p.name+" "+p.vendor+" "+p.category).toLowerCase().includes(state.filter.toLowerCase())) - )); - workspace.dataset.nativeRack="1"; - workspace.innerHTML = `
- ${cardHeader("Live VST3 FX Rack","Input 1 · live stereo chain · plugin order is the real processing order · 8 inserts maximum")} -
- - - - ${state.catalog.length} plugins · ${escapeHtml(state.message)} + function renderRack(){ + if(!workspace || currentTab()!=="FX RACK") return; + workspace.innerHTML=`
+ ${cardHeader("Live FX Chain · Vocal Input","Arrange your real VST3 effects here. Use + ADD FX to choose from your installed catalog.")} +
+ + + ${state.chain.length}/8 live effects · Real-time processor chain (Channel 1) +
+
+

MIC INPUT → PROCESSING → MAIN OUTPUT

+
+
INPUT 1 / MICROPHONE
+ ${state.chain.map((p,i)=>`
+ ${String(i+1).padStart(2,"0")} + ${escapeHtml(p.name)}${p.latency||0} samples processing latency + + + + + +
`).join("")} + ${state.chain.length===0?'
No FX loaded yet · Click + ADD FX to insert a real VST3.
':""} + +
MASTER OUTPUT / STREAM
-
-

ACTIVE PROCESSING CHAIN · ${state.chain.length}/8

-
-
MIC / AUDIO INPUT →
- ${state.chain.map((p,i)=>`
- ${String(i+1).padStart(2,"0")} - ${escapeHtml(p.name)}${p.latency||0} samples plugin latency - - - - - -
`).join("")} - ${state.chain.length===0?'
No real effects loaded. Choose a VST3 from the catalog to hear its processing.
':""} -
→ MASTER · ${escapeHtml(state.device.device||"Audio output")}
-
-
Live plugin changes briefly pause audio in this build. Avoid editing a chain during a livestream.
-
-
-

INSTALLED / IMPORTED PLUGIN CATALOG

- -
${fxCategories.map(c=>``).join("")}
-
${matches.length?matches.slice(0,200).map(p=>`
- VST3
${escapeHtml(p.name)} - ${escapeHtml(p.vendor||"Unknown developer")} · ${escapeHtml(p.category||"Effect")}
-
`).join("") - : '
No matching VST3. Click RESCAN VST3, ADD PLUGIN FOLDER, or IMPORT VST3 FILE.
'}
-
-
-

Only VST3 modules (.vst3) are supported. Legacy VST2 .dll is not a VST3 file. VST3 plugin editors open in separate native windows.

-
`; +
+

Bypass can change during monitoring. Stop monitoring before scanning, adding, removing or reordering effects.

+
`; +} + function createDialog(id,title,small=false){ + let overlay=document.getElementById(id); + if(overlay)return overlay; + overlay=document.createElement("div");overlay.id=id;overlay.className="native-modal";overlay.hidden=true; + overlay.innerHTML=``; + document.body.appendChild(overlay); + return overlay; +} + function showDialog(id){const d=document.getElementById(id);if(d){d.hidden=false;d.querySelector("input")?.focus()}} + function hideDialog(id){const d=document.getElementById(id);if(d)d.hidden=true} + function pluginRows(items,limit=180){ + return items.length?items.slice(0,limit).map(p=>`
+ ${escapeHtml(p.name)} + ${escapeHtml(p.vendor||"Unknown vendor")} · ${escapeHtml(p.category||"Audio effect")} + VST3 +
`).join("") + :'
No matching installed VST3 effects. Open Plugin Manager to scan your folders.
'; +} + function filterPlugins(){ + return state.catalog.filter(p=>state.selectedCategory==="All"||classFor(p)===state.selectedCategory) + .filter(p=>(p.name+" "+p.vendor+" "+p.category).toLowerCase().includes(state.filter.toLowerCase())); +} + function renderPicker(){ + const dlg=document.getElementById("nativeFxSelector"); + if(!dlg)return; + dlg.querySelector(".native-dialog-body").innerHTML=` +
SELECT EFFECT → INSERT INTO LIVE VOCAL FX RACK
+ +
${fxCategories.map(c=>``).join("")}
+
${pluginRows(filterPlugins())}
`; + dlg.querySelector(".native-dialog-footer").innerHTML=`${state.catalog.length} available plugins · OPEN PLUGIN MANAGER for scanning and import`; +} + function openPicker(){renderPicker();showDialog("nativeFxSelector")} + function scanProgressHtml(){ + const p=state.progress||{}; + const count=p.done||0,total=p.total||0,found=p.found||0; + const known=p.phase==="inspecting"&&total>0; + const percentage=known?Math.round(count/total*100):null; + return `
${p.phase==="discovering"?"Discovering plugin files": + p.phase==="inspecting"?"Inspecting VST3 metadata":"Scan completed"} + ${known?`${count} / ${total} · ${percentage}%`:"Working…"}
+
+
${escapeHtml(p.current||"")}${found} effects found
`; +} + function renderManager(){ + const dlg=document.getElementById("nativePluginManager"); + if(!dlg)return; + dlg.querySelector(".native-dialog-body").innerHTML=` +
MANAGE INSTALLED VST3 PLUGINS · SCANNING RUNS OFF THE AUDIO CALLBACK
+
+ + + +
+
+

${state.scanning?"SCANNING PLUGINS":"PLUGIN SCANNER"}

+
${state.scanning?scanProgressHtml(): + `
${escapeHtml(state.message)} · ${state.catalog.length} cached effects
`}
+
+
Plugin catalog (${state.catalog.length}) — stored between launches
+
${state.catalog.length? + state.catalog.slice(0,120).map(p=>`
${escapeHtml(p.name)} + ${escapeHtml(p.vendor||"Unknown")} · ${escapeHtml(p.path)}
`).join("") + :'
No plugins indexed yet. Scan your standard folders or import a .vst3 file.
'}
`; + dlg.querySelector(".native-dialog-footer").textContent= + "VST2 DLL is not VST3. Scanning third-party binaries is not yet crash-isolated."; +} + function updateProgress(){ + const p=state.progress||{}; + const hud=document.getElementById("nativeScanHud"); + hud.hidden=!p.active; + if(p.active)hud.innerHTML=`
VST3 SCANNING · ${state.catalog.length} cached effects
${scanProgressHtml()}`; + const mgr=document.getElementById("nativePluginManager"); + if(mgr&&!mgr.hidden){ + const host=mgr.querySelector("#nativeManagerProgress"); + if(host)host.innerHTML=p.active?scanProgressHtml():`
${escapeHtml(state.message)}
`; } +} + function addPluginManagerToolbar(){ + const nav=document.querySelector(".nav"); + if(nav&&!nav.querySelector("[data-plugin-manager]")){ + const b=document.createElement("button"); + b.dataset.pluginManager="1"; + b.textContent="PLUGINS"; + b.title="Plugin Manager · VST3 scan and catalog administration"; + nav.appendChild(b); + } + } + function initModals(){ + createDialog("nativeFxSelector","Add VST3 Effect"); + createDialog("nativePluginManager","Plugin Manager"); + createDialog("nativeAudioSetup","Opening Audio Setup",true); + const setup=document.getElementById("nativeAudioSetup"); + setup.querySelector(".native-dialog-body").innerHTML=`

Preparing ASIO/WASAPI driver configuration…

+
+

Third-party ASIO drivers may require additional enumeration time.

`; + setup.querySelector(".native-dialog-footer").textContent="Audio processing remains independent of this window."; + const hud=document.createElement("div");hud.id="nativeScanHud";hud.hidden=true;document.body.appendChild(hud); +} function renderSetup() { if(!workspace||currentTab()!=="SETUP") return; workspace.dataset.nativeSetup="1"; @@ -147,26 +236,33 @@

Driver: ${escapeHtml(d.driver||"Not connected")}
Device: ${escapeHtml(d.device||"Not selected")}
Sample rate: ${Number(d.rate||0).toLocaleString()} Hz · Buffer: ${d.buffer||0} samples

- +

For first test: wired headphones, 48 kHz and 128/256 samples. Start MONITOR OFF. ASIO and WASAPI are not interchangeable with virtual streaming outputs; loopback routing is a separate feature.

`; } - function patchMixer() { - if(!mixer) return; - const tracks=mixer.querySelectorAll(".strip"); - tracks.forEach((track,i)=>{ - if(i>0) {track.title="UI preview channel (audio not connected yet)";return;} - const rack=track.querySelector(".rack"); - if(!rack || rack.dataset.liveNative==="1") return; - rack.dataset.liveNative="1"; - rack.innerHTML = state.chain.slice(0,4).map(p=> - `` - ).join("")+``; - }); - } - + function patchMixer(){ + if(!mixer)return; + const tracks=mixer.querySelectorAll(".strip"); + tracks.forEach((track,i)=>{ + const rack=track.querySelector(".rack"); + if(!rack)return; + if(i!==0){ + rack.dataset.preview="1"; + track.title=`${track.querySelector(".channel-name")?.textContent||"Channel"} — visual preview only; native I/O not wired`; + return; + } + const signature=state.chain.map(p=>p.id+"|"+p.bypass).join(","); + if(rack.dataset.nativeSig===signature)return; + rack.dataset.nativeSig=signature; + rack.innerHTML=state.chain.slice(0,4).map((p,i)=> + ``).join("")+ + ``; + }); +} let renderPending = false; function syncView(){ if(renderPending) return; @@ -189,51 +285,93 @@ patchMixer(); }; - // Capture native commands before the legacy v0.3 demo handlers. - document.addEventListener("click",e=>{ - const target=e.target.closest("[data-native-action],[data-native-add],[data-native-fx],[data-native-category],[data-go-native-rack],[data-insert]"); - if(!target)return; - if(target.matches("[data-insert]") && currentTab()!=="MIX") return; - e.preventDefault();e.stopImmediatePropagation(); - if(target.hasAttribute("data-go-native-rack")||target.hasAttribute("data-insert")){ - document.querySelector('.nav button[data-view="FX RACK"]')?.click();return; + // Capture native controls before the legacy v0.3 demo handlers. + document.addEventListener("click", function(e){ + const el=e.target.closest("[data-native-action],[data-native-add],[data-native-fx],[data-native-category],[data-go-native-rack],[data-insert],[data-plugin-picker],[data-plugin-manager],[data-close-modal]"); + if(!el)return; + e.preventDefault();e.stopImmediatePropagation(); + + if(el.dataset.closeModal){hideDialog(el.dataset.closeModal);return;} + if(el.hasAttribute("data-plugin-manager")){ + renderManager();showDialog("nativePluginManager");return; + } + if(el.hasAttribute("data-plugin-picker")){ + openPicker();return; + } + if(el.hasAttribute("data-insert")){ + const article=el.closest(".strip"); + const idx=Number(article?.dataset.strip??0); + if(idx!==0){ + const toast=document.querySelector("#toast"); + if(toast){toast.textContent="Native VST3 is currently available on Channel 1 only.";toast.classList.add("show"); + setTimeout(()=>toast.classList.remove("show"),2200);} + return; } - const action=target.dataset.nativeAction; - if(action){ - if(action==="monitor")send("monitor",{value:!state.monitor}); - else send(action); + openPicker();return; + } + if(el.hasAttribute("data-go-native-rack")){ + document.querySelector('.nav button[data-view="FX RACK"]')?.click();return; + } + const action=el.dataset.nativeAction; + if(action){ + if(action==="monitor"){send("monitor",{value:!state.monitor});return;} + if(action==="audioSetup"){ + const overlay=document.getElementById("nativeAudioSetup"); + if(overlay){ + overlay.querySelector(".native-dialog-body").innerHTML= + `

Preparing ASIO/WASAPI device selection…

+
+

Loading device options. Third-party driver enumeration may be slow.

`; + showDialog("nativeAudioSetup"); + } + // Allow WebView to paint before synchronous JUCE/ASIO enumeration begins. + requestAnimationFrame(()=>requestAnimationFrame(()=>send("audioSetup"))); return; } - if(target.dataset.nativeAdd){send("addCatalog",{id:target.dataset.nativeAdd});return;} - if(target.dataset.nativeCategory){state.selectedCategory=target.dataset.nativeCategory;renderRack();return;} - const fx=target.dataset.nativeFx,slot=Number(target.dataset.slot); - if(fx==="editor")send("fxEditor",{slot}); - if(fx==="remove")send("fxRemove",{slot}); - if(fx==="bypass")send("fxBypass",{slot,value:!state.chain[slot]?.bypass}); - if(fx==="up"||fx==="down")send("fxMove",{slot,value:fx==="up"?-1:1}); - },true); - document.addEventListener("input",e=>{ - if(e.target.id!=="nativeVstSearch")return; - state.filter=e.target.value; - // Keep typing focus and selection while updating only catalog list on - // the next browser task. Full redraw of the search input would break UX. - const input=e.target; - const pos=input.selectionStart; - renderRack(); - const newInput=document.querySelector("#nativeVstSearch"); - newInput?.focus(); - newInput?.setSelectionRange(pos,pos); - },true); + send(action);return; + } + if(el.dataset.nativeAdd){ + state.adding=true; + send("addCatalog",{id:el.dataset.nativeAdd});return; + } + if(el.dataset.nativeCategory){ + state.selectedCategory=el.dataset.nativeCategory; + renderPicker();return; + } + const fx=el.dataset.nativeFx,slot=Number(el.dataset.slot); + if(fx==="editor")send("fxEditor",{slot}); + if(fx==="remove")send("fxRemove",{slot}); + if(fx==="bypass")send("fxBypass",{slot,value:!state.chain[slot]?.bypass}); + if(fx==="up"||fx==="down")send("fxMove",{slot,value:fx==="up"?-1:1}); +},true); + document.addEventListener("input", function(e){ + if(e.target.id!=="nativeVstSearch")return; + state.filter=e.target.value; + const pos=e.target.selectionStart; + renderPicker(); + const input=document.querySelector("#nativeVstSearch"); + input?.focus(); + input?.setSelectionRange(pos,pos); +},true); backend.addEventListener("arMixCatalog",data=>{ state.catalog=Array.isArray(data.items)?data.items:[]; state.scanning=!!data.scanning; state.message=data.message||"Ready"; repaint(); + const dialog=document.getElementById("nativePluginManager"); + if(dialog&&!dialog.hidden)renderManager(); + const picker=document.getElementById("nativeFxSelector"); + if(picker&&!picker.hidden)renderPicker(); + 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("arMixNotice",data=>{ const text=data.text||""; @@ -243,7 +381,7 @@ toast.classList.add("show"); setTimeout(()=>toast.classList.remove("show"),3500); } - if(data.error)console.warn("AR MIX native:",text); + if(data.error){state.adding=false;console.warn("AR MIX native:",text);} }); backend.addEventListener("arMixStatus",d=>{ state.device=d; @@ -267,7 +405,25 @@ const statusSetup=document.querySelector("[data-native-setup]"); if(statusSetup && !document.activeElement?.matches("input"))renderSetup(); }); - // JS bridge may initialise after the initial native push. Explicit sync. + backend.addEventListener("arMixScanProgress",p=>{ + state.progress=p; + updateProgress(); + }); + backend.addEventListener("arMixSetupProgress",p=>{ + const dlg=document.getElementById("nativeAudioSetup"); + if(!dlg)return; + if(p.phase==="opened"){ + const body=dlg.querySelector(".native-dialog-body"); + body.innerHTML=`

Audio Device Settings opened in a separate window.

Setup initialization: ${Number(p.elapsedMs)||0} ms.

`; + setTimeout(()=>hideDialog("nativeAudioSetup"),700); + }else{ + const info=dlg.querySelector(".native-dialog-body p"); + if(info) info.textContent=p.phase==="enumerating"?"Enumerating ASIO/WASAPI devices and drivers…":"Preparing audio device selector…"; + } + }); + // Create real dialogs and synchronize cached state after WebView startup. + initModals(); + addPluginManagerToolbar(); send("refreshState"); syncView(); })(); From 0eb0b1a24d55b5cbb09701b33af9051ce3f8443d Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 25 Oct 2026 07:05:31 +0700 Subject: [PATCH 2/2] perf(ui): update native Audio Setup only on device changes, not every meter tick --- web/bridge.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/bridge.js b/web/bridge.js index 518510d36..fbef564bd 100644 --- a/web/bridge.js +++ b/web/bridge.js @@ -383,6 +383,7 @@ } if(data.error){state.adding=false;console.warn("AR MIX native:",text);} }); + let lastSetupSignature=""; backend.addEventListener("arMixStatus",d=>{ state.device=d; state.monitor=!!d.monitor; @@ -403,7 +404,11 @@ const cpu=document.querySelector(".cpu strong"); if(cpu)cpu.textContent="NATIVE"; const statusSetup=document.querySelector("[data-native-setup]"); - if(statusSetup && !document.activeElement?.matches("input"))renderSetup(); + const setupSignature=[d.connected,d.driver,d.device,d.rate,d.buffer,d.error||""].join("|"); + if(statusSetup && setupSignature!==lastSetupSignature && !document.activeElement?.matches("input")){ + lastSetupSignature=setupSignature; + renderSetup(); + } }); backend.addEventListener("arMixScanProgress",p=>{ state.progress=p;