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
10 changes: 6 additions & 4 deletions .github/workflows/p1-windows.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Windows Native VST3 Host
on:
push:
branches: [ main, feature/p1-first-sound-windows, feature/p2-native-vst-catalog-fx-rack, feature/p2-daw-workflow-progress, fix/p2-native-output-monitor-diagnostics, fix/p2-realtime-glitch-telemetry-latest-gui ]
branches: [ main, feature/p1-first-sound-windows, feature/p2-native-vst-catalog-fx-rack, feature/p2-daw-workflow-progress, fix/p2-native-output-monitor-diagnostics, fix/p2-realtime-glitch-telemetry-latest-gui, fix/p2-truthful-meter-pan-fx-toggle ]
pull_request:
workflow_dispatch:

Expand Down Expand Up @@ -32,6 +32,8 @@ jobs:
run: |
node --check web/bridge.js
node --check web/monitor.js
node --check web/app.js
node --test tests/native_ui_contract_test.mjs
- name: Configure Windows x64
shell: pwsh
run: >
Expand All @@ -51,13 +53,13 @@ jobs:
Where-Object { $_.Name -like "*AR*Mix*" -and $_.FullName -match 'Release' } |
Select-Object -First 1
if (-not $exe) { throw "ARMixConsole EXE not found" }
Copy-Item $exe.FullName "dist/ArSonMix-Realtime-Diagnostics.exe"
Copy-Item $exe.FullName "dist/ArSonMix-P2-LiveMeter-Pan-FXToggle.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." |
"P2 experimental: audio routes automatically; use headphones at low level. Only Channel 1 is native. Other strips are inactive previews." |
Out-File -FilePath dist/FIRST_SOUND_README.txt -Encoding utf8
- uses: actions/upload-artifact@v4
with:
name: ArSonMix-RealTime-Diagnostics-Windows-x64
name: ArSonMix-P2-LiveMeter-Pan-FXToggle-Windows-x64
path: dist/
if-no-files-found: error
retention-days: 14
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ juce_add_gui_app(ARMixConsole
juce_add_binary_data(ARMixAssets SOURCES
web/index.html web/styles.css web/app.js web/bridge.js web/monitor.js)

target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h src/PluginCatalog.h src/DiagnosticsRecorder.h)
target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h src/PluginCatalog.h src/DiagnosticsRecorder.h src/StereoPan.h)
target_compile_definitions(ARMixConsole PRIVATE
JUCE_WEB_BROWSER=1
JUCE_USE_WIN_WEBVIEW2=1
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,11 @@ Use MIX → Channel 1 ADD FX to select a real indexed VST3; PLUGINS opens Plugin
- Uses current `fix/fader-thumb-symmetry-polish` GUI (ArSonMix, metal controls, horizontal PAN sliders). Audio host code stays isolated.
- Press SIGNAL CHECK → OPEN DIAGNOSTIC LOG to inspect or share diagnostic evidence after reproducing audio stutter.
- Read [P2.2 reliability guide](docs/P2_REALTIME_RELIABILITY.md).

## P2.3 — Real Live VU + PAN + Instant FX Bypass

- In the native JUCE host, v0.3 sine-wave demonstration meter generator is completely disabled. Only real Channel 1 input and real master output move; other preview channels have no fake audio activity.
- Channel 1 horizontal PAN is connected to the actual stereo output matrix after VST3, with a transparent centre and correlated-stereo-safe extremes.
- Each VST3 insert in the MIX view has a small ⏻ toggle with clear ON/OFF state. Bypass updates the atomic realtime control without rebuilding the plugin graph or leaving the MIX screen.
- Diagnostic health JSON no longer truncates every record at 511 characters; the bounded queue slot is now 4096 bytes, with a truncation counter.
- Windows CI validates the native UI contract and real DSP pan coefficient tests. Hardware verification remains necessary.
22 changes: 22 additions & 0 deletions docs/P2_LIVE_METER_PAN_FX_BYPASS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# P2.3 — True VU meters, real PAN and fast VST3 bypass

## Changes
- **Native VU meters**: removed the conflicting sine-wave demo meter requestAnimationFrame path in the native WebView. Only Channel 1 input and real master output are driven from JUCE status samples. Other 11 channels remain explicitly inactive visual previews, with meter lamps disabled.
- **Meter appearance**: UI-only peak attack with a small falling-ballistic smoothing on incoming native input and master peak readings (12 Hz status cadence). No fabricated noise or sine animation.
- **Native PAN**: Channel 1 pan slider -100..100 now controls an atomic normalized stereo pan matrix applied *after* actual VST3 processing, before master gain. At centre, stereo passes unchanged. At a hard side, both stereo channels fold into the target channel at 0.5 each; dual-mono does not double its amplitude. Stereo balance is not a full multichannel spatial panner.
- **Fast Studio One-style insert enable**: Every native FX insert on the MIX channel strip now includes a dedicated ON/OFF power toggle. Clicking the plugin body still opens the VST3 editor. Power updates the existing atomic bypass flag, without callback detachment or FX Rack navigation. The FX Rack includes the same on/off state.
- **Logger repaired**: Uploaded 08:48–08:54 diagnostic log contained 364 AUDIO_HEALTH lines with exactly 511 bytes of text each, so time counters and VST slot details were truncated. Queue slot increased from 512 to 4096 bytes and truncation counts are exposed for verification. This does *not* retroactively recover the missing metrics.
- **Latest GUI**: adopted the current style sheet from the metallic PAN/fader GUI branch. No redesign of accepted user artwork.

## Acceptance tests
1. Run the new native EXE and confirm only Channel 1 input and master output react to actual input. All other strip meters remain dormant, even after changing tabs and moving faders.
2. Move Channel 1 PAN to hard left, centre and hard right with stereo headphones. A dual-mono vocal should move to the chosen ear and return to both at centre.
3. Add ArSonKuPik to MIX Channel 1, click the small ⏻ button on its insert (not the editor name). Sound must alternate FX processed/bypassed without an audio device restart. Watch ON/OFF immediately reflect native chain state.
4. Click the plugin name to open the native VST3 editor.
5. Open SIGNAL CHECK and OPEN DIAGNOSTIC LOG, reproduce for 1–2 minutes, confirm AUDIO_HEALTH JSON records are no longer clipped at 511 characters and the callback/plugin timings can be parsed.
6. Verify monitoring still flows automatically and no sonic dropout is introduced.

## Boundaries
- Only Channel 1 is native. The other channels and their mock inserts are visual previews.
- A successful CI build does not prove audio quality or round-trip stability on specific Windows hardware.
- Real ASIO/WASAPI channel assignment for 12 native channels, presets and streaming output is still out of scope.
10 changes: 7 additions & 3 deletions src/DiagnosticsRecorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ class DiagnosticsRecorder final : private juce::Thread
details.replaceCharacters ("\r\n", " ");
const auto utf8 = message.toRawUTF8();
auto& slot = queue_[head];
const auto inputLength = std::strlen (utf8);
const auto count = juce::jmin (static_cast<size_t> (sizeof (slot.data) - 1),
std::strlen (utf8));
inputLength);
if (inputLength > count)
truncated_.fetch_add (1, std::memory_order_relaxed);
std::memcpy (slot.data, utf8, count);
slot.data[count] = 0;
producer_.store (next, std::memory_order_release);
Expand All @@ -53,13 +56,14 @@ class DiagnosticsRecorder final : private juce::Thread

juce::File getLogFile() const { return logfile_; }
std::uint64_t lostRecords() const noexcept { return lost_.load(); }
std::uint64_t truncatedRecords() const noexcept { return truncated_.load(); }

private:
static constexpr unsigned capacity = 128;
struct Record { char data[512] {}; };
struct Record { char data[4096] {}; };
std::array<Record,capacity> queue_ {};
std::atomic<unsigned> producer_ { 0 }, consumer_ { 0 };
std::atomic<std::uint64_t> lost_ { 0 };
std::atomic<std::uint64_t> lost_ { 0 }, truncated_ { 0 };
juce::File folder_, logfile_;

void run() override
Expand Down
35 changes: 31 additions & 4 deletions src/LiveAudioEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#pragma once
#include <juce_audio_devices/juce_audio_devices.h>
#include <juce_audio_processors/juce_audio_processors.h>
#include "StereoPan.h"
#include <array>
#include <atomic>
#include <cmath>
Expand Down Expand Up @@ -76,6 +77,14 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
{
if (std::isfinite (value)) channelGain_.store (juce::Decibels::decibelsToGain (juce::jlimit (-60.f, 10.f, value)));
}
// True stereo-to-stereo pan: centre preserves stereo; extremes fold
// both stereo input channels to the chosen side at unity for dual-mono.
// Parameter is normalized on the UI thread; callback only loads atomic.
void setChannelPan (float value) noexcept
{
if (std::isfinite (value))
channelPan_.store (juce::jlimit (-1.f, 1.f, value), std::memory_order_relaxed);
}
void setChannelMuted (bool value) noexcept { channelMute_.store (value); }
void setMasterMuted (bool value) noexcept { masterMute_.store (value); }

Expand Down Expand Up @@ -202,6 +211,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
o->setProperty ("monitor", monitor_.load());
o->setProperty ("masterMute", masterMute_.load());
o->setProperty ("channelMute", channelMute_.load());
o->setProperty ("channelPan", channelPan_.load());
o->setProperty ("dryTest", dryTest_.load());
juce::AudioDeviceManager::AudioDeviceSetup setup;
deviceManager_.getAudioDeviceSetup (setup);
Expand Down Expand Up @@ -239,6 +249,8 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
o->setProperty ("inputPeak", inputPeak_.load());
o->setProperty ("postFxPeak", postFxPeak_.load());
o->setProperty ("peak", outputPeak_.load());
o->setProperty ("peakLeft", outputPeakL_.load());
o->setProperty ("peakRight", outputPeakR_.load());
o->setProperty ("latencySamples", totalLatency_.load());
o->setProperty ("chainCount", count_);
return juce::var (o.release());
Expand All @@ -255,8 +267,9 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
// Indexed atomic bypass flags: instant RT-safe toggles, no graph detachment.
std::array<std::atomic<bool>, maxFx> bypassFlags_ {};
std::atomic<bool> monitor_ { false }, channelMute_ { false }, masterMute_ { false }, dryTest_ { false };
std::atomic<float> masterGain_ { 1.f }, channelGain_ { 1.f };
std::atomic<float> masterGain_ { 1.f }, channelGain_ { 1.f }, channelPan_ { 0.f };
std::atomic<float> inputPeak_ { 0.f }, postFxPeak_ { 0.f }, outputPeak_ { 0.f };
std::atomic<float> outputPeakL_ { 0.f }, outputPeakR_ { 0.f };
std::atomic<int> callbackInputs_ { 0 }, callbackOutputs_ { 0 };
std::atomic<unsigned long long> callbackCount_ { 0 };
// Audio-thread-only timestamp and cheap atomically published counters.
Expand Down Expand Up @@ -364,7 +377,12 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
|| masterMute_.load (std::memory_order_relaxed);
const float gain = masterGain_.load (std::memory_order_relaxed)
* channelGain_.load (std::memory_order_relaxed);
const float pan = channelPan_.load (std::memory_order_relaxed);
// Precomputed stereo pan matrix; no trigonometry, locks or allocations
// in the realtime sample loop. 0 = transparent identity matrix.
const auto matrix = armix::dsp::StereoPanMatrix::fromNormalized (pan);
float inPeak = 0.f, postFxPeak = 0.f, outPeak = 0.f;
float outPeakL = 0.f, outPeakR = 0.f;
for (int offset = 0; offset < samples; offset += maxFrames)
{
const int frames = juce::jmin (maxFrames, samples - offset);
Expand Down Expand Up @@ -411,19 +429,28 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
for (int c = 0; c < outputChannels; ++c)
{
if (!outputs[c]) continue;
const float* src = scratch_.getReadPointer (juce::jmin (c, 1));
const float* left = scratch_.getReadPointer (0);
const float* right = scratch_.getReadPointer (1);
float* dst = outputs[c] + offset;
float channelPeak = 0.f;
for (int i = 0; i < frames; ++i)
{
const float value = (enabled && !muted) ? src[i] * gain : 0.f;
const float mapped = c == 0 ? matrix.ll * left[i] + matrix.lr * right[i]
: matrix.rl * left[i] + matrix.rr * right[i];
const float value = (enabled && !muted) ? mapped * gain : 0.f;
dst[i] = value;
outPeak = juce::jmax (outPeak, std::abs (value));
channelPeak = juce::jmax (channelPeak, std::abs (value));
}
outPeak = juce::jmax (outPeak, channelPeak);
if (c == 0) outPeakL = juce::jmax (outPeakL, channelPeak);
if (c == 1) outPeakR = juce::jmax (outPeakR, channelPeak);
}
}
inputPeak_.store (juce::jmin (1.f, inPeak), std::memory_order_relaxed);
postFxPeak_.store (juce::jmin (1.f, postFxPeak), std::memory_order_relaxed);
outputPeak_.store (juce::jmin (1.f, outPeak), std::memory_order_relaxed);
outputPeakL_.store (juce::jmin (1.f, outPeakL), std::memory_order_relaxed);
outputPeakR_.store (juce::jmin (1.f, outPeakR), std::memory_order_relaxed);
const auto elapsedUs = clockMicros() - beginUs;
lastCallbackUs_.store (elapsedUs, std::memory_order_relaxed);
publishMax (worstCallbackUs_, elapsedUs);
Expand Down
4 changes: 4 additions & 0 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
// The app.js bridge converts strip index 0 to channel ID 1.
else if (name == "faderDb" && channel == 1 && (value.isDouble() || value.isInt()))
engine_.setChannelGainDb (valueNumber);
else if (name == "pan" && channel == 1 && (value.isDouble() || value.isInt()))
engine_.setChannelPan (valueNumber * 0.01f);
else if (name == "mute" && channel == 1 && value.isBool())
engine_.setChannelMuted (bool (value));
else if (name == "masterMute" && value.isBool())
Expand Down Expand Up @@ -393,6 +395,8 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
auto state = engine_.status();
state.getDynamicObject()->setProperty ("diagnosticsDropped",
static_cast<double> (diagnostics_.lostRecords()));
state.getDynamicObject()->setProperty ("diagnosticsTruncated",
static_cast<double> (diagnostics_.truncatedRecords()));
if (startupError_.isNotEmpty() && !bool (state.getProperty ("connected", false)))
state.getDynamicObject()->setProperty ("error", startupError_);
browser_.emitEventIfBrowserIsVisible ("arMixStatus", state);
Expand Down
28 changes: 28 additions & 0 deletions src/StereoPan.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: AGPL-3.0-only
#pragma once
#include <algorithm>
#include <cmath>

namespace armix::dsp
{
// Branch selection occurs once per buffer, not inside the sample loop.
// Center: transparent stereo identity.
// Extremes: both channels fold into the selected output with 0.5 weights,
// so dual-mono input stays at unity instead of gaining +6 dB.
struct StereoPanMatrix final
{
float ll = 1.f, lr = 0.f, rl = 0.f, rr = 1.f;

static StereoPanMatrix fromNormalized (float p) noexcept
{
if (!std::isfinite (p)) p = 0.f;
p = std::clamp (p, -1.f, 1.f);
return {
p > 0.f ? 1.f - p : 1.f + .5f * p,
p < 0.f ? -.5f * p : 0.f,
p > 0.f ? .5f * p : 0.f,
p < 0.f ? 1.f + p : 1.f - .5f * p
};
}
};
} // namespace armix::dsp
39 changes: 39 additions & 0 deletions tests/native_ui_contract_test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: AGPL-3.0-only
// No dependencies; catches regressions between the legacy v0.3 GUI and native host.
import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
const app=readFileSync('web/app.js','utf8');
const bridge=readFileSync('web/bridge.js','utf8');
const engine=readFileSync('src/LiveAudioEngine.h','utf8');
const main=readFileSync('src/Main.cpp','utf8');
const recorder=readFileSync('src/DiagnosticsRecorder.h','utf8');
test('native app never runs demo sine meters',()=>{
const fn=app.indexOf('function meters(t)');
const nativeExit=app.indexOf('if(window.__JUCE__?.backend?.emitEvent)return;',fn);
const demoLoop=app.indexOf('requestAnimationFrame(meters)',fn);
assert.ok(fn>=0 && nativeExit>fn && nativeExit<demoLoop);
});
test('native meter reads DSP and hides all 11 visual-only channels',()=>{
assert.match(bridge,/inputLevel=percent\(d\.inputPeak\)/);
assert.match(bridge,/outputLevel=percent\(d\.peak\)/);
assert.ok(bridge.includes("masterMeterL:liveOutputLeft"));
assert.ok(bridge.includes("masterMeterR:liveOutputRight"));
assert.match(bridge,/track\.dataset\.preview="1"/);
assert.ok(bridge.includes("meter-fill{opacity:0!important}"));
});
test('quick FX bypass is wired to native slot instead of demo mock',()=>{
assert.match(bridge,/data-native-fx="bypass" data-slot="\$\{i\}"/);
assert.match(bridge,/aria-pressed="\$\{!p\.bypass\}"/);
assert.match(bridge,/send\("fxBypass",\{slot,value:!state\.chain\[slot\]\?\.bypass\}\)/);
assert.match(engine,/bypassFlags_\[index\]\.store/);
});
test('GUI pan event reaches actual callback pan matrix',()=>{
assert.match(app,/send\('pan',c\.pan,idx\)/);
assert.match(main,/name == "pan" && channel == 1/);
assert.match(engine,/StereoPanMatrix::fromNormalized/);
});
test('health logger has room for complete JSON snapshots',()=>{
assert.match(recorder,/char data\[4096\]/);
assert.match(recorder,/truncatedRecords\(\)/);
});
21 changes: 21 additions & 0 deletions tests/realtime_control_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// SPDX-License-Identifier: AGPL-3.0-only
#include "../engine/core/RealtimeControl.h"
#include <atomic>
#ifdef NDEBUG
#undef NDEBUG
#endif
#include <cassert>
#include "../src/StereoPan.h"
#include <cmath>
#include <iostream>
#include <thread>
Expand Down Expand Up @@ -29,5 +33,22 @@ int main(){
std::thread producer([&]{for(std::uint32_t i=0;i<count;){if(concurrent.tryPush(i))++i;else std::this_thread::yield();}});
std::thread consumer([&]{for(std::uint32_t i=0;i<count;){std::uint32_t v=0;if(concurrent.tryPop(v)){if(v!=i)bad=true;++i;}else std::this_thread::yield();}});
producer.join();consumer.join();assert(!bad);
// Test the exact pan matrix used by the production audio callback.
auto checkPan=[](float p,float left,float right,float expectedL,float expectedR)
{
const auto m=armix::dsp::StereoPanMatrix::fromNormalized (p);
const float l=m.ll*left+m.lr*right, r=m.rl*left+m.rr*right;
assert(std::fabs(l-expectedL)<0.00001f);
assert(std::fabs(r-expectedR)<0.00001f);
};
checkPan(0.f,.8f,.25f,.8f,.25f); // transparent stereo centre
checkPan(-1.f,1.f,1.f,1.f,0.f); // dual mono at hard left = unity
checkPan(1.f,1.f,1.f,0.f,1.f); // dual mono at hard right = unity
checkPan(-1.f,.8f,.2f,.5f,0.f); // stereo fold
checkPan(1.f,.8f,.2f,0.f,.5f);
checkPan(.5f,.8f,.2f,.4f,.35f);
checkPan(0.f,0.f,1.f,0.f,1.f);
checkPan(0.f,1.f,0.f,1.f,0.f);
std::cout<<"PASS: native stereo pan centre, extremes, half-pan and unit-gain dual-mono\n";
std::cout<<"PASS: SPSC capacity, wrap, 250000 ordered interthread events, parameter coalescing\n";
}
Loading
Loading