Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/p1-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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: 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
-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
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
27 changes: 14 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,41 +1,42 @@
cmake_minimum_required(VERSION 3.22)
project(ARMixConsole VERSION 0.3.0 LANGUAGES CXX)
project(ARMixConsole VERSION 0.4.0 LANGUAGES C 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"
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)
juce_add_binary_data(ARMixAssets SOURCES
web/index.html web/styles.css web/app.js web/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)
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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.
36 changes: 36 additions & 0 deletions docs/P1_FIRST_SOUND.md
Original file line number Diff line number Diff line change
@@ -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.
209 changes: 209 additions & 0 deletions src/LiveAudioEngine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
// SPDX-License-Identifier: AGPL-3.0-only
#pragma once
#include <juce_audio_devices/juce_audio_devices.h>
#include <juce_audio_processors/juce_audio_processors.h>
#include <atomic>
#include <cmath>
#include <memory>

// 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<juce::VST3PluginFormat>());
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<juce::PluginDescription> 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<juce::DynamicObject>();
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<juce::AudioPluginInstance> plugin_;
juce::AudioBuffer<float> scratch_;
juce::String pluginName_;
bool callbackAttached_ = false;
std::atomic<bool> monitorEnabled_ { false }, bypassed_ { false };
std::atomic<float> 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);
}
};
Loading
Loading