From 403fa749f75923da877724314fe3c3818a24c0d0 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 25 Oct 2026 05:48:18 +0700 Subject: [PATCH 1/5] feat(p1): native WASAPI/ASIO first-sound VST3 host with safe monitor arm and Windows CI --- .github/workflows/p1-windows.yml | 50 ++++++++ CMakeLists.txt | 26 ++-- README.md | 6 + docs/P1_FIRST_SOUND.md | 36 ++++++ src/LiveAudioEngine.h | 209 +++++++++++++++++++++++++++++++ src/Main.cpp | 197 +++++++++++++++++++++-------- web/app.js | 2 +- web/index.html | 2 +- web/native-bridge.js | 74 +++++++++++ 9 files changed, 533 insertions(+), 69 deletions(-) create mode 100644 .github/workflows/p1-windows.yml create mode 100644 docs/P1_FIRST_SOUND.md create mode 100644 src/LiveAudioEngine.h create mode 100644 web/native-bridge.js diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml new file mode 100644 index 000000000..1db30fb2e --- /dev/null +++ b/.github/workflows/p1-windows.yml @@ -0,0 +1,50 @@ +name: P1 Windows First Sound +on: + push: + branches: [ main, feature/p1-first-sound-windows ] + pull_request: + workflow_dispatch: + +permissions: + contents: read + +jobs: + windows-build: + runs-on: windows-2022 + timeout-minutes: 50 + steps: + - uses: actions/checkout@v4 + - name: Checkout JUCE 8 pinned + uses: actions/checkout@v4 + with: + repository: juce-framework/JUCE + ref: 8.0.15 + path: third_party/JUCE + - name: Configure Windows x64 + shell: pwsh + run: > + cmake -S . -B build -G "Visual Studio 17 2022" -A x64 + -DJUCE_ROOT="${{ github.workspace }}/third_party/JUCE" + -DBUILD_TESTING=ON + - name: Build executable and native RT tests + run: cmake --build build --config Release --target ARMixConsole ARMixRTTests --parallel 2 + - name: Test realtime control primitives + run: ctest --test-dir build -C Release --output-on-failure + - name: Package native executable + shell: pwsh + run: | + New-Item -ItemType Directory -Force -Path dist | Out-Null + $exe = Get-ChildItem -Path build -Filter "*.exe" -Recurse | + 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-P1.exe" + Copy-Item README.md "dist/README.md" + "P1 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-P1-Windows-x64 + path: dist/ + if-no-files-found: error + retention-days: 14 diff --git a/CMakeLists.txt b/CMakeLists.txt index 66c128819..93fad1c68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,41 +1,41 @@ cmake_minimum_required(VERSION 3.22) -project(ARMixConsole VERSION 0.3.0 LANGUAGES CXX) +project(ARMixConsole VERSION 0.4.0 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) -# Set JUCE_ROOT to the path of a local JUCE checkout. No downloads occur at runtime. if (NOT DEFINED JUCE_ROOT) - message(FATAL_ERROR "Pass -DJUCE_ROOT=C:/path/to/JUCE (JUCE 8/9 checkout)") + message(FATAL_ERROR "Pass -DJUCE_ROOT=C:/path/to/JUCE (8.0.15+ required)") endif() add_subdirectory("${JUCE_ROOT}" "${CMAKE_BINARY_DIR}/juce") juce_add_gui_app(ARMixConsole - PRODUCT_NAME "AR MIX Console" + PRODUCT_NAME "AR MIX Studio" COMPANY_NAME "AR MIX Open Source" NEEDS_WEB_BROWSER TRUE NEEDS_WEBVIEW2 TRUE NEEDS_CURL FALSE) -juce_add_binary_data(ARMixAssets - SOURCES - web/index.html - web/styles.css - web/app.js) +juce_add_binary_data(ARMixAssets SOURCES + web/index.html web/styles.css web/app.js web/native-bridge.js) -target_sources(ARMixConsole PRIVATE src/Main.cpp) +target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h) target_compile_definitions(ARMixConsole PRIVATE JUCE_WEB_BROWSER=1 JUCE_USE_WIN_WEBVIEW2=1 JUCE_USE_CURL=0 - JUCE_APPLICATION_NAME_STRING="AR MIX Console" - JUCE_APPLICATION_VERSION_STRING="0.3.0") + JUCE_ASIO=1 + JUCE_PLUGINHOST_VST3=1 + JUCE_APPLICATION_NAME_STRING="AR MIX Studio" + JUCE_APPLICATION_VERSION_STRING="0.4.0-p1") target_link_libraries(ARMixConsole PRIVATE ARMixAssets juce::juce_gui_extra + juce::juce_audio_utils + juce::juce_audio_processors + juce::juce_audio_devices juce::juce_recommended_config_flags juce::juce_recommended_warning_flags) -# Independent of JUCE; tests lock-free event and coalesced scalar contracts. include(CTest) if(BUILD_TESTING) add_executable(ARMixRTTests tests/realtime_control_test.cpp) diff --git a/README.md b/README.md index c06611ad3..2b29ca8b1 100644 --- a/README.md +++ b/README.md @@ -46,3 +46,9 @@ g++ -std=c++20 -O2 -Wall -Wextra -pedantic -pthread tests/realtime_control_test. ## Licensing Code in this trial is authored for the project and provided under AGPL-3.0-only to align with JUCE open-source licensing. JUCE, ASIO SDK and VST3 SDK have their own notices and obligations; check exact version and dependency licensing before publishing binaries. No third-party VST binaries or proprietary mixer UI graphics are included. + +## P1 Windows native First Sound + +The new P1 native EXE provides actual microphone passthrough through one VST3 effect, ASIO/WASAPI device selector, bypass, monitor arm/mute, master gain and real callback meter. The old FX rack and channels 2–12 are **still UI previews** (do not confuse demo plugin inserts with native VST3). Output starts muted for hearing/feedback safety. See [P1 trial instructions](docs/P1_FIRST_SOUND.md). + +GitHub Actions: [Windows First Sound builds](https://github.com/masarray/arsonmix/actions/workflows/p1-windows.yml). Download the artifact only after the run is GREEN. JUCE 8.0.15 is pinned by CI and includes GPLv3 ASIO SDK sources; this repository uses AGPLv3. Plugin compatibility and low latency must still be verified with real hardware. diff --git a/docs/P1_FIRST_SOUND.md b/docs/P1_FIRST_SOUND.md new file mode 100644 index 000000000..071ed2ac7 --- /dev/null +++ b/docs/P1_FIRST_SOUND.md @@ -0,0 +1,36 @@ +# P1 FIRST SOUND — Windows VST3 host +**Status:** Experimental source implementation. Windows physical I/O and VST3 compatibility must be confirmed by CI and hardware testing. + +## Hardware trial +1. Download the build artifact **AR-MIX-Studio-P1-Windows-x64** from the P1 GitHub Actions run. +2. Extract the ZIP. Install the Microsoft WebView2 Runtime if not already present. +3. Connect an audio interface and use wired headphones; reduce headphone/output volume. +4. Launch the EXE. Output starts **MUTED** deliberately to prevent feedback. +5. Click **AUDIO SETUP** at the bottom status area. Select ASIO when supported, otherwise Windows Audio/WASAPI. Set microphone input, headphone output, 48 kHz, and begin at 128/256 frames. +6. Click **LOAD REAL VST3** and choose one compatible installed stereo `.vst3`. The visual FX rack is still a DEMO: only the actual path chosen in the native strip is loaded. +7. Click **MONITOR ON**. Speak into the microphone and check headphone audio; test bypass. Lower physical gain if clipping or feedback occurs. +8. Open the native audio setup to try 64 frames *after* confirming clean audio at 128/256. Log pops/dropouts and real device latency. + +## Scope +- Native JUCE AudioDeviceManager (ASIO and Windows Audio/WASAPI), live input->output, one effect VST3, device dialog, monitor arm/disarm, bypass, master gain, basic callback-driven meter. +- No per-channel DSP beyond the first live stereo path. Track 2–12 and mock FX rack still simulate UI data, visually dimmed native meter. +- No plugin editor, multichain, host automation, plugin sandbox, latency compensation, snapshot state restore, streaming loopback, or crash isolation yet. +- Plugin insert/removal momentarily detaches audio callbacks. This is safe for ownership but **not glitch-free**. Do not change plugin on air. +- JUCE WebView2 UI does not process real-time audio. The audio callback avoids host-side heap allocations, locks, logging, file I/O and WebView access. Third-party VST3 code may violate RT safety and cannot be trusted. +- Host buffer period in ms is **not** actual input-to-output round-trip latency. Measure hardware loopback separately. + +## Known P1 risks +- Third-party VST3 discovery/creation runs on the message thread and may block or crash with badly-behaved plugins. P2 must isolate scanning and implement verified safe graph transitions. +- The current stereo-only effect restriction intentionally rejects mono-to-stereo and instrument-only plugins. +- ASIO and WASAPI hardware availability varies. Select a single full-duplex interface whenever possible. +- Monitor through **headphones**, not speakers, to avoid acoustic feedback. +- Verify plugin licensing and JUCE/ASIO GPLv3/AGPLv3 obligations before distribution. + +## Acceptance test (not inferred from successful compilation) +- Windows CI green and packaged executable downloads. +- Native output stays silent before user enables monitoring. +- 48 kHz mic -> headphone dry passthrough works. +- Known stereo VST3 changes audible signal; bypass restores dry signal. +- Real device name/rate/buffer/plugin latency reported, meter responds only to real output. +- Startup/shutdown repeat 20x without crash, test 30 min voice monitoring. +- Test ASIO and WASAPI separately, log latency and glitches. This P1 implementation does **not** yet count x-runs. diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h new file mode 100644 index 000000000..7d826507b --- /dev/null +++ b/src/LiveAudioEngine.h @@ -0,0 +1,209 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include +#include +#include +#include +#include + +// P1: single stereo microphone -> one VST3 -> master output. +// Structural mutations happen on the message thread ONLY after detaching the +// audio callback. No plugin load/scan/IO/mutex/logging/heap allocation by host +// code inside audioDeviceIOCallbackWithContext. +class LiveAudioEngine final : private juce::AudioIODeviceCallback +{ +public: + LiveAudioEngine() + { + formatManager_.addFormat (std::make_unique()); + scratch_.setSize (2, maxFrames, false, true, false); + } + + ~LiveAudioEngine() override { stop(); } + + juce::AudioDeviceManager& devices() noexcept { return deviceManager_; } + + juce::String start() + { + // Disarmed on launch to prevent acoustic feedback with open microphones. + monitorEnabled_.store (false); + const auto error = deviceManager_.initialise (1, 2, nullptr, true); + if (error.isNotEmpty()) + return error; + deviceManager_.addAudioCallback (this); + callbackAttached_ = true; + return {}; + } + + void stop() + { + if (callbackAttached_) + { + deviceManager_.removeAudioCallback (this); + callbackAttached_ = false; + } + if (plugin_ != nullptr) + { + plugin_->releaseResources(); + plugin_.reset(); + } + deviceManager_.closeAudioDevice(); + } + + void setMonitorEnabled (bool enabled) noexcept { monitorEnabled_.store (enabled); } + bool isMonitorEnabled() const noexcept { return monitorEnabled_.load(); } + void setBypassed (bool bypassed) noexcept { bypassed_.store (bypassed); } + bool isBypassed() const noexcept { return bypassed_.load(); } + void setMasterGainDb (float db) noexcept + { + if (std::isfinite (db)) + linearGain_.store (std::pow (10.0f, juce::jlimit (-60.0f, 10.0f, db) / 20.0f)); + } + + // Message-thread operation. VST3 code is untrusted and may hang or crash; + // sandboxed scanning/hosting is deliberately a later milestone. + juce::String loadVst3 (const juce::File& path) + { + if (! path.exists() || ! path.hasFileExtension (".vst3")) + return "Choose an installed .vst3 module or bundle"; + + auto* format = formatManager_.getFormat (0); + if (format == nullptr || ! format->fileMightContainThisPluginType (path.getFullPathName())) + return "Not a recognised VST3 module"; + + juce::OwnedArray descriptions; + format->findAllTypesForFile (descriptions, path.getFullPathName()); + if (descriptions.isEmpty()) + return "No VST3 effect found in the selected module"; + + auto* device = deviceManager_.getCurrentAudioDevice(); + if (device == nullptr) + return "Configure a working audio device first"; + + juce::String error; + auto candidate = formatManager_.createPluginInstance ( + *descriptions[0], device->getCurrentSampleRate(), + juce::jmax (32, device->getCurrentBufferSizeSamples()), error); + if (candidate == nullptr) + return "VST3 load failed: " + error; + + juce::AudioProcessor::BusesLayout stereo; + stereo.inputBuses.add (juce::AudioChannelSet::stereo()); + stereo.outputBuses.add (juce::AudioChannelSet::stereo()); + if (! candidate->setBusesLayout (stereo)) + return "P1 accepts stereo input/stereo output effects only"; + + // Detach waits for in-flight callbacks, then reattach after publish. + // The temporary silence is explicit P1 behaviour, not seamless hot swap. + if (callbackAttached_) + deviceManager_.removeAudioCallback (this); + if (plugin_ != nullptr) + plugin_->releaseResources(); + plugin_ = std::move (candidate); + pluginName_ = descriptions[0]->name; + bypassed_.store (false); + if (callbackAttached_) + deviceManager_.addAudioCallback (this); + return {}; + } + + void unloadPlugin() + { + if (callbackAttached_) + deviceManager_.removeAudioCallback (this); + if (plugin_ != nullptr) + plugin_->releaseResources(); + plugin_.reset(); + pluginName_.clear(); + if (callbackAttached_) + deviceManager_.addAudioCallback (this); + } + + juce::var status() const + { + auto object = std::make_unique(); + const auto* d = deviceManager_.getCurrentAudioDevice(); + object->setProperty ("connected", d != nullptr); + object->setProperty ("driver", deviceManager_.getCurrentAudioDeviceType()); + object->setProperty ("device", d != nullptr ? d->getName() : "No audio device"); + object->setProperty ("rate", d != nullptr ? d->getCurrentSampleRate() : 0.0); + object->setProperty ("buffer", d != nullptr ? d->getCurrentBufferSizeSamples() : 0); + object->setProperty ("plugin", pluginName_); + object->setProperty ("pluginLatencySamples", plugin_ != nullptr ? plugin_->getLatencySamples() : 0); + object->setProperty ("monitor", monitorEnabled_.load()); + object->setProperty ("bypass", bypassed_.load()); + object->setProperty ("peak", peak_.load (std::memory_order_relaxed)); + object->setProperty ("note", "P1: input stereo -> optional VST3 -> output; CH1 + master only"); + return juce::var (object.release()); + } + +private: + static constexpr int maxFrames = 8192; + juce::AudioDeviceManager deviceManager_; + juce::AudioPluginFormatManager formatManager_; + std::unique_ptr plugin_; + juce::AudioBuffer scratch_; + juce::String pluginName_; + bool callbackAttached_ = false; + std::atomic monitorEnabled_ { false }, bypassed_ { false }; + std::atomic linearGain_ { 1.0f }, peak_ { 0.0f }; + + void audioDeviceAboutToStart (juce::AudioIODevice* device) override + { + if (plugin_ != nullptr) + { + plugin_->releaseResources(); + plugin_->prepareToPlay (device->getCurrentSampleRate(), + juce::jmax (32, device->getCurrentBufferSizeSamples())); + } + peak_.store (0.0f, std::memory_order_relaxed); + } + + void audioDeviceStopped() override { peak_.store (0.0f, std::memory_order_relaxed); } + + void audioDeviceIOCallbackWithContext ( + const float* const* inputs, int numInputs, float* const* outputs, + int numOutputs, int samples, + const juce::AudioIODeviceCallbackContext&) override + { + const bool enabled = monitorEnabled_.load (std::memory_order_relaxed); + const bool bypass = bypassed_.load (std::memory_order_relaxed); + const float gain = linearGain_.load (std::memory_order_relaxed); + float peak = 0.0f; + for (int offset = 0; offset < samples; offset += maxFrames) + { + const int frames = juce::jmin (maxFrames, samples - offset); + // Scratch memory was allocated at startup: avoidReallocating=true. + scratch_.setSize (2, frames, false, false, true); + for (int ch = 0; ch < 2; ++ch) + { + float* dst = scratch_.getWritePointer (ch); + const float* src = numInputs > ch ? inputs[ch] + : numInputs > 0 ? inputs[0] : nullptr; + if (src != nullptr) + juce::FloatVectorOperations::copy (dst, src + offset, frames); + else + juce::FloatVectorOperations::clear (dst, frames); + } + if (plugin_ != nullptr && ! bypass) + { + juce::MidiBuffer midi; + plugin_->processBlock (scratch_, midi); + } + for (int ch = 0; ch < numOutputs; ++ch) + { + if (outputs[ch] == nullptr) + continue; + float* out = outputs[ch] + offset; + const float* source = scratch_.getReadPointer (juce::jmin (ch, 1)); + for (int i = 0; i < frames; ++i) + { + const float x = enabled ? source[i] * gain : 0.0f; + out[i] = x; + peak = juce::jmax (peak, std::abs (x)); + } + } + } + peak_.store (juce::jmin (1.0f, peak), std::memory_order_relaxed); + } +}; diff --git a/src/Main.cpp b/src/Main.cpp index 22666e162..239254591 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1,85 +1,174 @@ // SPDX-License-Identifier: AGPL-3.0-only -// AR MIX Studio UI integration prototype. No sound processing is implemented. +// P1 native Windows first-sound host: mic -> one VST3 -> master output. +// The desktop HTML remains a presentation layer, never the audio callback. #include -#include +#include #include +#include "LiveAudioEngine.h" #include +#include -namespace +namespace { +std::optional assetFor (const juce::String& path) { -std::optional assetFor(const juce::String& path) -{ - int size = 0; const char* data = nullptr; + int size = 0; juce::String mime; if (path == "/" || path == "/index.html") - { - data = BinaryData::index_html; size = BinaryData::index_htmlSize; mime = "text/html"; - } + { data = BinaryData::index_html; size = BinaryData::index_htmlSize; mime = "text/html"; } else if (path == "/styles.css") - { - data = BinaryData::styles_css; size = BinaryData::styles_cssSize; mime = "text/css"; - } + { data = BinaryData::styles_css; size = BinaryData::styles_cssSize; mime = "text/css"; } else if (path == "/app.js") - { - data = BinaryData::app_js; size = BinaryData::app_jsSize; mime = "text/javascript"; - } - else return std::nullopt; + { data = BinaryData::app_js; size = BinaryData::app_jsSize; mime = "text/javascript"; } + else if (path == "/native-bridge.js") + { data = BinaryData::native_bridge_js; size = BinaryData::native_bridge_jsSize; mime = "text/javascript"; } + else + return std::nullopt; juce::WebBrowserComponent::Resource result; - result.data.resize(static_cast(size)); - std::memcpy(result.data.data(), data, static_cast(size)); + result.data.resize (static_cast (size)); + std::memcpy (result.data.data(), data, static_cast (size)); result.mimeType = mime; return result; } -class ConsoleWindow final : public juce::DocumentWindow +class Browser final : public juce::WebBrowserComponent +{ +public: + explicit Browser (Options opts) : juce::WebBrowserComponent (std::move (opts)) {} + bool ready = false; + void pageFinishedLoading (const juce::String&) override { ready = true; } +}; + +class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer { public: ConsoleWindow() - : juce::DocumentWindow("AR MIX Studio — FX Host UI prototype", - juce::Colour(0xff101921), - juce::DocumentWindow::allButtons), - browser(juce::WebBrowserComponent::Options{} - .withBackend(juce::WebBrowserComponent::Options::Backend::webview2) - .withWinWebView2Options( - juce::WebBrowserComponent::Options::WinWebView2{} - .withUserDataFolder(juce::File::getSpecialLocation( - juce::File::userApplicationDataDirectory) - .getChildFile("AR-MIX-Studio-WebView2"))) - .withNativeIntegrationEnabled() - .withEventListener("arMixParameter", [](juce::var args) - { - // This is the JUCE message thread, NOT the audio callback. - // Forward validated state changes through a lock-free queue - // when a real audio engine is added. - DBG("AR MIX UI event: " + juce::JSON::toString(args)); - }) - .withResourceProvider(assetFor)) + : juce::DocumentWindow ("AR MIX Studio — P1 FIRST SOUND", + juce::Colour (0xff101921), allButtons), + browser_ (juce::WebBrowserComponent::Options{} + .withBackend (juce::WebBrowserComponent::Options::Backend::webview2) + .withWinWebView2Options ( + juce::WebBrowserComponent::Options::WinWebView2{} + .withUserDataFolder ( + juce::File::getSpecialLocation ( + juce::File::userApplicationDataDirectory) + .getChildFile ("AR-MIX-Studio-WebView2"))) + .withNativeIntegrationEnabled() + .withEventListener ("arMixParameter", [this] (juce::var args) { onParameter (args); }) + .withEventListener ("arMixAction", [this] (juce::var args) { onAction (args); }) + .withResourceProvider (assetFor)) + { + setUsingNativeTitleBar (true); + setResizable (true, true); + setResizeLimits (1100, 650, 3840, 2160); + setContentNonOwned (&browser_, false); + centreWithSize (1650, 930); + setVisible (true); + startupError_ = engine_.start(); + browser_.goToURL (juce::WebBrowserComponent::getResourceProviderRoot()); + startTimerHz (15); + } + + ~ConsoleWindow() override + { + stopTimer(); + browser_.setVisible (false); + engine_.stop(); + } + + void closeButtonPressed() override { - setUsingNativeTitleBar(true); - setResizable(true, true); - setResizeLimits(1100, 650, 3840, 2160); - setContentNonOwned(&browser, false); - centreWithSize(1650, 930); - setVisible(true); - browser.goToURL(juce::WebBrowserComponent::getResourceProviderRoot()); + juce::JUCEApplication::getInstance()->systemRequestedQuit(); } - void closeButtonPressed() override { juce::JUCEApplication::getInstance()->systemRequestedQuit(); } + private: - juce::WebBrowserComponent browser; - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ConsoleWindow) + // Engine is constructed before and destroyed after Browser. + LiveAudioEngine engine_; + Browser browser_; + std::unique_ptr chooser_; + juce::String startupError_; + + void onParameter (const juce::var& args) + { + // Events from WebView2 arrive on the message thread, not RT. + const auto name = args.getProperty ("parameter", {}).toString(); + const auto channel = static_cast (args.getProperty ("channel", -2)); + const auto value = args.getProperty ("value", {}); + if (name == "masterGain" && value.isDouble()) + engine_.setMasterGainDb (static_cast (double (value))); + else if (name == "masterGain" && value.isInt()) + engine_.setMasterGainDb (static_cast (int (value))); + else if (name == "masterMute" && value.isBool() && bool (value)) + engine_.setMonitorEnabled (false); + // P1 explicitly ignores channels 2-12, demo FX chain, and generic FX + // parameters. Future typed graph routing will map their IDs. + juce::ignoreUnused (channel); + } + + void onAction (const juce::var& args) + { + const auto action = args.getProperty ("action", {}).toString(); + if (action == "audioSetup") + { + juce::DialogWindow::LaunchOptions opt; + opt.dialogTitle = "AR MIX — Windows Audio Device Setup"; + opt.dialogBackgroundColour = juce::Colour (0xff14212a); + auto* selector = new juce::AudioDeviceSelectorComponent ( + engine_.devices(), 1, 2, 1, 2, false, false, false, false); + selector->setSize (650, 520); + opt.content.setOwned (selector); + opt.useNativeTitleBar = true; + opt.resizable = true; + opt.launchAsync(); + } + else if (action == "chooseVst3") + { + chooser_ = std::make_unique ( + "Load VST3 effect", juce::File{}, "*.vst3", true); + chooser_->launchAsync ( + juce::FileBrowserComponent::openMode | + juce::FileBrowserComponent::canSelectFiles, + [this] (const juce::FileChooser& chooser) + { + const auto file = chooser.getResult(); + if (file == juce::File{}) + return; + const auto error = engine_.loadVst3 (file); + if (error.isNotEmpty()) + juce::AlertWindow::showMessageBoxAsync ( + juce::MessageBoxIconType::WarningIcon, "VST3 Load", error); + }); + } + else if (action == "unloadVst3") + engine_.unloadPlugin(); + else if (action == "monitor" && args.getProperty ("value", {}).isBool()) + engine_.setMonitorEnabled (bool (args.getProperty ("value", false))); + else if (action == "bypass" && args.getProperty ("value", {}).isBool()) + engine_.setBypassed (bool (args.getProperty ("value", false))); + } + + void timerCallback() override + { + if (! browser_.ready || ! browser_.isVisible()) + return; + auto state = engine_.status(); + if (startupError_.isNotEmpty()) + state.getDynamicObject()->setProperty ("error", startupError_); + browser_.emitEventIfBrowserIsVisible ("arMixStatus", state); + } }; class ConsoleApp final : public juce::JUCEApplication { public: - const juce::String getApplicationName() override { return "AR MIX Console"; } - const juce::String getApplicationVersion() override { return "0.3.0"; } - void initialise(const juce::String&) override { window = std::make_unique(); } - void shutdown() override { window.reset(); } + const juce::String getApplicationName() override { return "AR MIX Studio"; } + const juce::String getApplicationVersion() override { return "0.4.0-p1"; } + void initialise (const juce::String&) override { window_ = std::make_unique(); } + void shutdown() override { window_.reset(); } private: - std::unique_ptr window; + std::unique_ptr window_; }; } // namespace -START_JUCE_APPLICATION(ConsoleApp) + +START_JUCE_APPLICATION (ConsoleApp) diff --git a/web/app.js b/web/app.js index 96efb3eb6..e4045f80a 100644 --- a/web/app.js +++ b/web/app.js @@ -181,4 +181,4 @@ let lastPersist=0;setInterval(()=>{if(Date.now()-lastPersist<2000)return;lastPer try{userSnapshots=JSON.parse(localStorage.getItem('armix-v03-snapshots')||'{}');savedChains=JSON.parse(localStorage.getItem('armix-v03-chains')||'{}');for(const k of Object.keys(userSnapshots))if(!scenes.includes(k))scenes.push(k)}catch{userSnapshots={};savedChains={}} createSide();renderMixer();renderMaster();try{let last=JSON.parse(localStorage.getItem('armix-v03-current'));if(!last)last=JSON.parse(localStorage.getItem('arMixStudioUI')); if(last&&last.channels?.length===channels.length){last.channels.forEach((s,i)=>{for(const k of ['fader','pan','trim','mute','solo','hpf'])if(s[k]!==undefined)channels[i][k]=s[k];if(Array.isArray(s.inserts))channels[i].inserts=s.inserts.filter(x=>typeof x==='string').slice(0,8)});sceneIdx=last.sceneIdx??0;masterGain=last.masterGain??-.1;renderMixer();renderMaster();flash('Previous UI session restored')}}catch{} -requestAnimationFrame(meters); +if (!window.__JUCE__?.backend) requestAnimationFrame(meters); diff --git a/web/index.html b/web/index.html index c84739b61..9b9bbc5e6 100644 --- a/web/index.html +++ b/web/index.html @@ -35,5 +35,5 @@
UI STUDY · Audio engine disconnected · Simulated metersDrag faders & knobs • Click FX insert to open plugin browser • Ctrl+S saves sessionAR MIX v0.3 | FX HOST UI PROTOTYPE
- + diff --git a/web/native-bridge.js b/web/native-bridge.js new file mode 100644 index 000000000..c78ca3bad --- /dev/null +++ b/web/native-bridge.js @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// The standalone HTML still works as a demo. This runs only inside JUCE WebView2. +(() => { + const backend = window.__JUCE__?.backend; + if (!backend?.emitEvent || !backend?.addEventListener) return; + const send = (action, value) => backend.emitEvent("arMixAction", { action, value }); + const target = document.querySelector(".status-help"); + if (!target) return; + const strip = document.createElement("div"); + strip.id = "nativeP1"; + strip.innerHTML = 'Starting audio...'; + target.replaceChildren(strip); + const style = document.createElement("style"); + style.textContent = ` + #nativeP1{display:flex;align-items:center;gap:5px;white-space:nowrap;font-size:10px;max-width:100%;overflow:auto} + #nativeP1 button{font:inherit;color:#cde5ed;border:1px solid #426273;border-radius:4px;padding:4px 7px; + background:linear-gradient(175deg,#42596b 0%,#233745 42%,#101e29 100%);cursor:pointer} + #nativeP1 button[aria-pressed=true]{background:linear-gradient(#24aadd,#10617d 58%,#063247); + border-color:#71d8f2;color:#fff} + #nativeP1 [data-p1-status]{color:#95b9c6;min-width:110px;overflow:hidden;text-overflow:ellipsis} + .status-help{min-width:0;flex:1} + `; + document.head.appendChild(style); + let monitor = false, bypass = false, warned = false; + strip.addEventListener("click", (e) => { + const b = e.target.closest("button[data-p1]"); + if (!b) return; + if (b.dataset.p1 === "setup") send("audioSetup"); + if (b.dataset.p1 === "load") send("chooseVst3"); + if (b.dataset.p1 === "unload") send("unloadVst3"); + if (b.dataset.p1 === "monitor") send("monitor", !monitor); + if (b.dataset.p1 === "bypass") send("bypass", !bypass); + }); + + // Actual output level from the native callback. Remaining mock channels + // are forced dark to avoid implying the P1 host has 12 live audio inputs. + function level(peak) { + const db = 20 * Math.log10(Math.max(1e-6, Number(peak) || 0)); + return Math.max(1, Math.min(100, (db + 60) * 100 / 60)); + } + backend.addEventListener("arMixStatus", (s) => { + monitor = !!s.monitor; + bypass = !!s.bypass; + const mon = strip.querySelector('[data-p1="monitor"]'); + const by = strip.querySelector('[data-p1="bypass"]'); + mon.textContent = monitor ? "MONITOR ON" : "MONITOR OFF"; + mon.setAttribute("aria-pressed", String(monitor)); + by.textContent = bypass ? "BYPASS ON" : "BYPASS OFF"; + by.setAttribute("aria-pressed", String(bypass)); + strip.querySelector("[data-p1-status]").textContent = + s.error ? "ERROR: " + s.error : + (s.connected ? s.driver + " · " + Math.round(s.rate) + "Hz / " + s.buffer + " · " + + (s.plugin || "Dry mic") + " · +" + (s.pluginLatencySamples || 0) + " samples plugin latency" : + "NO AUDIO DEVICE"); + const status = document.getElementById("audioStatus"); + if (status) status.textContent = s.connected + ? "P1 NATIVE · " + (monitor ? "MONITOR ARMED" : "MONITOR MUTED (safe)") + + " · Live VST3: " + (s.plugin || "none") + : "P1 NATIVE · No audio device"; + const p = level(s.peak); + document.querySelectorAll("[data-meter]").forEach((meter) => + meter.style.setProperty("--level", meter.dataset.meter === "0" ? p + "%" : "1%")); + ["masterMeterL","masterMeterR","masterMeterAux"].forEach((id) => { + const el = document.getElementById(id); + if (el) el.style.setProperty("--level", p + "%"); + }); + const cpu = document.querySelector(".cpu strong"); + if (cpu) cpu.textContent = "P1 LIVE"; + if (!warned && s.error) { + warned = true; + console.warn("AR MIX native audio:", s.error); + } + }); +})(); From 0a0599b0d631d850b02423f473409cb43b845f9d Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 25 Oct 2026 05:49:55 +0700 Subject: [PATCH 2/5] fix(ci): enable C language required by JUCE 8 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93fad1c68..68daae723 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.22) -project(ARMixConsole VERSION 0.4.0 LANGUAGES CXX) +project(ARMixConsole VERSION 0.4.0 LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) From b819fb976caa5fcda47233980a05fce7a3ea7d43 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 25 Oct 2026 05:52:36 +0700 Subject: [PATCH 3/5] fix(ci): install pinned Microsoft WebView2 SDK before configuring JUCE --- .github/workflows/p1-windows.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml index 1db30fb2e..751093fae 100644 --- a/.github/workflows/p1-windows.yml +++ b/.github/workflows/p1-windows.yml @@ -20,12 +20,12 @@ jobs: repository: juce-framework/JUCE ref: 8.0.15 path: third_party/JUCE - - name: Configure Windows x64 + - name: Install WebView2 SDK for JUCE\n shell: pwsh\n run: nuget install Microsoft.Web.WebView2 -Version 1.0.3485.44 -OutputDirectory .deps -NonInteractive\n - name: Configure Windows x64 shell: pwsh run: > cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -DJUCE_ROOT="${{ github.workspace }}/third_party/JUCE" - -DBUILD_TESTING=ON + -DBUILD_TESTING=ON\n -DJUCE_WEBVIEW2_PACKAGE_LOCATION="${{ github.workspace }}/.deps" - name: Build executable and native RT tests run: cmake --build build --config Release --target ARMixConsole ARMixRTTests --parallel 2 - name: Test realtime control primitives From 15c32a45c06285579a362241d48c031a37ecb8cf Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 25 Oct 2026 05:53:36 +0700 Subject: [PATCH 4/5] fix(ci): use real YAML newlines in WebView2 dependency step --- .github/workflows/p1-windows.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml index 751093fae..57729036c 100644 --- a/.github/workflows/p1-windows.yml +++ b/.github/workflows/p1-windows.yml @@ -20,12 +20,16 @@ jobs: repository: juce-framework/JUCE ref: 8.0.15 path: third_party/JUCE - - name: Install WebView2 SDK for JUCE\n shell: pwsh\n run: nuget install Microsoft.Web.WebView2 -Version 1.0.3485.44 -OutputDirectory .deps -NonInteractive\n - name: Configure Windows x64 + - name: Install WebView2 SDK for JUCE + shell: pwsh + run: nuget install Microsoft.Web.WebView2 -Version 1.0.3485.44 -OutputDirectory .deps -NonInteractive + - name: Configure Windows x64 shell: pwsh run: > cmake -S . -B build -G "Visual Studio 17 2022" -A x64 -DJUCE_ROOT="${{ github.workspace }}/third_party/JUCE" - -DBUILD_TESTING=ON\n -DJUCE_WEBVIEW2_PACKAGE_LOCATION="${{ github.workspace }}/.deps" + -DBUILD_TESTING=ON + -DJUCE_WEBVIEW2_PACKAGE_LOCATION="${{ github.workspace }}/.deps" - name: Build executable and native RT tests run: cmake --build build --config Release --target ARMixConsole ARMixRTTests --parallel 2 - name: Test realtime control primitives From edadb67e7d0f7abd6021d8dcd5437f83351df2bd Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sun, 25 Oct 2026 05:59:05 +0700 Subject: [PATCH 5/5] fix(p1): JUCE AudioIODevice constness and generated WebView2 bridge resource name --- CMakeLists.txt | 3 +- README.md | 2 +- src/LiveAudioEngine.h | 2 +- src/Main.cpp | 4 +-- web/bridge.js | 74 +++++++++++++++++++++++++++++++++++++++++++ web/index.html | 2 +- 6 files changed, 81 insertions(+), 6 deletions(-) create mode 100644 web/bridge.js diff --git a/CMakeLists.txt b/CMakeLists.txt index 68daae723..2609019ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,12 +11,13 @@ add_subdirectory("${JUCE_ROOT}" "${CMAKE_BINARY_DIR}/juce") juce_add_gui_app(ARMixConsole PRODUCT_NAME "AR MIX Studio" COMPANY_NAME "AR MIX Open Source" + BUNDLE_ID "org.armix.studio" NEEDS_WEB_BROWSER TRUE NEEDS_WEBVIEW2 TRUE NEEDS_CURL FALSE) juce_add_binary_data(ARMixAssets SOURCES - web/index.html web/styles.css web/app.js web/native-bridge.js) + web/index.html web/styles.css web/app.js web/bridge.js) target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h) target_compile_definitions(ARMixConsole PRIVATE diff --git a/README.md b/README.md index 2b29ca8b1..648346ab7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # AR MIX Studio — Open-Source Live FX Host (v0.3 UI & Architecture) -**Status: interactive UI prototype + C++ real-time messaging primitives. No audio engine yet.** +**Status: P1 experimental native Windows first-sound implementation (pending CI/hardware verification) + v0.3 UI demo.** AR MIX Studio targets live vocal processing for karaoke performers and livestream creators. It is VST3-first: the principal activity is building a beautiful, low-friction FX chain with a digital-console look. The core engine is planned as C++20/JUCE with Windows ASIO/WASAPI; the frontend is a self-contained HTML/CSS/SVG UI embedded in JUCE WebView2. diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index 7d826507b..d340aaf50 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -122,7 +122,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback juce::var status() const { auto object = std::make_unique(); - const auto* d = deviceManager_.getCurrentAudioDevice(); + auto* d = deviceManager_.getCurrentAudioDevice(); object->setProperty ("connected", d != nullptr); object->setProperty ("driver", deviceManager_.getCurrentAudioDeviceType()); object->setProperty ("device", d != nullptr ? d->getName() : "No audio device"); diff --git a/src/Main.cpp b/src/Main.cpp index 239254591..1f4c3e51d 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -20,8 +20,8 @@ std::optional assetFor (const juce::String& { data = BinaryData::styles_css; size = BinaryData::styles_cssSize; mime = "text/css"; } else if (path == "/app.js") { data = BinaryData::app_js; size = BinaryData::app_jsSize; mime = "text/javascript"; } - else if (path == "/native-bridge.js") - { data = BinaryData::native_bridge_js; size = BinaryData::native_bridge_jsSize; mime = "text/javascript"; } + else if (path == "/bridge.js") + { data = BinaryData::bridge_js; size = BinaryData::bridge_jsSize; mime = "text/javascript"; } else return std::nullopt; diff --git a/web/bridge.js b/web/bridge.js new file mode 100644 index 000000000..c78ca3bad --- /dev/null +++ b/web/bridge.js @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: AGPL-3.0-only +// The standalone HTML still works as a demo. This runs only inside JUCE WebView2. +(() => { + const backend = window.__JUCE__?.backend; + if (!backend?.emitEvent || !backend?.addEventListener) return; + const send = (action, value) => backend.emitEvent("arMixAction", { action, value }); + const target = document.querySelector(".status-help"); + if (!target) return; + const strip = document.createElement("div"); + strip.id = "nativeP1"; + strip.innerHTML = 'Starting audio...'; + target.replaceChildren(strip); + const style = document.createElement("style"); + style.textContent = ` + #nativeP1{display:flex;align-items:center;gap:5px;white-space:nowrap;font-size:10px;max-width:100%;overflow:auto} + #nativeP1 button{font:inherit;color:#cde5ed;border:1px solid #426273;border-radius:4px;padding:4px 7px; + background:linear-gradient(175deg,#42596b 0%,#233745 42%,#101e29 100%);cursor:pointer} + #nativeP1 button[aria-pressed=true]{background:linear-gradient(#24aadd,#10617d 58%,#063247); + border-color:#71d8f2;color:#fff} + #nativeP1 [data-p1-status]{color:#95b9c6;min-width:110px;overflow:hidden;text-overflow:ellipsis} + .status-help{min-width:0;flex:1} + `; + document.head.appendChild(style); + let monitor = false, bypass = false, warned = false; + strip.addEventListener("click", (e) => { + const b = e.target.closest("button[data-p1]"); + if (!b) return; + if (b.dataset.p1 === "setup") send("audioSetup"); + if (b.dataset.p1 === "load") send("chooseVst3"); + if (b.dataset.p1 === "unload") send("unloadVst3"); + if (b.dataset.p1 === "monitor") send("monitor", !monitor); + if (b.dataset.p1 === "bypass") send("bypass", !bypass); + }); + + // Actual output level from the native callback. Remaining mock channels + // are forced dark to avoid implying the P1 host has 12 live audio inputs. + function level(peak) { + const db = 20 * Math.log10(Math.max(1e-6, Number(peak) || 0)); + return Math.max(1, Math.min(100, (db + 60) * 100 / 60)); + } + backend.addEventListener("arMixStatus", (s) => { + monitor = !!s.monitor; + bypass = !!s.bypass; + const mon = strip.querySelector('[data-p1="monitor"]'); + const by = strip.querySelector('[data-p1="bypass"]'); + mon.textContent = monitor ? "MONITOR ON" : "MONITOR OFF"; + mon.setAttribute("aria-pressed", String(monitor)); + by.textContent = bypass ? "BYPASS ON" : "BYPASS OFF"; + by.setAttribute("aria-pressed", String(bypass)); + strip.querySelector("[data-p1-status]").textContent = + s.error ? "ERROR: " + s.error : + (s.connected ? s.driver + " · " + Math.round(s.rate) + "Hz / " + s.buffer + " · " + + (s.plugin || "Dry mic") + " · +" + (s.pluginLatencySamples || 0) + " samples plugin latency" : + "NO AUDIO DEVICE"); + const status = document.getElementById("audioStatus"); + if (status) status.textContent = s.connected + ? "P1 NATIVE · " + (monitor ? "MONITOR ARMED" : "MONITOR MUTED (safe)") + + " · Live VST3: " + (s.plugin || "none") + : "P1 NATIVE · No audio device"; + const p = level(s.peak); + document.querySelectorAll("[data-meter]").forEach((meter) => + meter.style.setProperty("--level", meter.dataset.meter === "0" ? p + "%" : "1%")); + ["masterMeterL","masterMeterR","masterMeterAux"].forEach((id) => { + const el = document.getElementById(id); + if (el) el.style.setProperty("--level", p + "%"); + }); + const cpu = document.querySelector(".cpu strong"); + if (cpu) cpu.textContent = "P1 LIVE"; + if (!warned && s.error) { + warned = true; + console.warn("AR MIX native audio:", s.error); + } + }); +})(); diff --git a/web/index.html b/web/index.html index 9b9bbc5e6..007e3d220 100644 --- a/web/index.html +++ b/web/index.html @@ -35,5 +35,5 @@
UI STUDY · Audio engine disconnected · Simulated metersDrag faders & knobs • Click FX insert to open plugin browser • Ctrl+S saves sessionAR MIX v0.3 | FX HOST UI PROTOTYPE
- +