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
9 changes: 5 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, fix/p2-truthful-meter-pan-fx-toggle ]
branches: [ main, feature/p1-first-sound-windows, feature/p2-native-vst-catalog-fx-rack, feature/p2-daw-workflow-progress, fix/p2-native-output-monitor-diagnostics, fix/p2-realtime-glitch-telemetry-latest-gui, fix/p2-truthful-meter-pan-fx-toggle, feature/p2-native-state-presets ]
pull_request:
workflow_dispatch:

Expand Down Expand Up @@ -34,6 +34,7 @@ jobs:
node --check web/monitor.js
node --check web/app.js
node --test tests/native_ui_contract_test.mjs
node --test tests/native_preset_contract_test.mjs
- name: Configure Windows x64
shell: pwsh
run: >
Expand All @@ -42,7 +43,7 @@ jobs:
-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
run: cmake --build build --config Release --target ARMixConsole ARMixRTTests ARMixPresetTests --parallel 2
- name: Test realtime control primitives
run: ctest --test-dir build -C Release --output-on-failure
- name: Package native executable
Expand All @@ -53,13 +54,13 @@ jobs:
Where-Object { $_.Name -like "*AR*Mix*" -and $_.FullName -match 'Release' } |
Select-Object -First 1
if (-not $exe) { throw "ARMixConsole EXE not found" }
Copy-Item $exe.FullName "dist/ArSonMix-P2-LiveMeter-Pan-FXToggle.exe"
Copy-Item $exe.FullName "dist/ArSonMix-P2-Native-Presets.exe"
Copy-Item README.md "dist/README.md"
"P2 experimental: audio routes automatically; use headphones at low level. Only Channel 1 is native. Other strips are inactive previews." |
Out-File -FilePath dist/FIRST_SOUND_README.txt -Encoding utf8
- uses: actions/upload-artifact@v4
with:
name: ArSonMix-P2-LiveMeter-Pan-FXToggle-Windows-x64
name: ArSonMix-P2-Native-Presets-Windows-x64
path: dist/
if-no-files-found: error
retention-days: 14
9 changes: 8 additions & 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 src/StereoPan.h)
target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h src/PluginCatalog.h src/DiagnosticsRecorder.h src/StereoPan.h src/NativePresetArchive.h)
target_compile_definitions(ARMixConsole PRIVATE
JUCE_WEB_BROWSER=1
JUCE_USE_WIN_WEBVIEW2=1
Expand All @@ -33,6 +33,7 @@ target_link_libraries(ARMixConsole PRIVATE
juce::juce_gui_extra
juce::juce_audio_utils
juce::juce_audio_processors
juce::juce_cryptography
juce::juce_audio_devices
juce::juce_recommended_config_flags
juce::juce_recommended_warning_flags)
Expand All @@ -42,4 +43,10 @@ if(BUILD_TESTING)
add_executable(ARMixRTTests tests/realtime_control_test.cpp)
target_compile_features(ARMixRTTests PRIVATE cxx_std_20)
add_test(NAME RealtimeControlPrimitives COMMAND ARMixRTTests)
juce_add_console_app(ARMixPresetTests PRODUCT_NAME "ArSonMix Native Preset Tests")
target_sources(ARMixPresetTests PRIVATE tests/native_preset_roundtrip_test.cpp src/NativePresetArchive.h)
target_link_libraries(ARMixPresetTests PRIVATE juce::juce_core juce::juce_cryptography
juce::juce_recommended_config_flags)
target_compile_features(ARMixPresetTests PRIVATE cxx_std_20)
add_test(NAME NativePresetZipRoundTrip COMMAND ARMixPresetTests)
endif()
27 changes: 27 additions & 0 deletions docs/P2_NATIVE_PRESETS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# P2.4 — Native My Sounds · VST3 binary preset ZIP

**Source of requirements:** `docs/ARD_AR_MIX_LIVE_FX_HOST_v0.3.md`, sections 2, 7, 8, 8.1, 13. This phase closes the fundamental persistence gap. This is NOT yet complete session/snapshot support or live-safe hot-swap.

## Completed milestone
- A native `MY SOUNDS` button is available beside Live FX Rack and in the FX Rack toolbar.
- Save `*.armix` files to the native app-data `AR-MIX-Studio/presets/` directory.
- ZIP contains `manifest.json` and `state/00.bin` through `state/07.bin`, captured with JUCE `AudioPluginInstance::getStateInformation` and restored with `setStateInformation` (full vendor-controlled binary state, unlike browser dummy knobs).
- Manifest includes schema/version, Channel 1 input gain/PAN/mute, master gain/mute, ordered stable plugin file/UID/catalog identity, bypass and SHA-256 per plugin-state blob. Output device/driver routing is **not** stored or switched.
- Input validates 8-plugin maximum, 8 MiB per plugin state, ZIP file 72 MiB, 256 KiB manifest, fixed entry names/entry count, finite numeric settings, plugin identity and SHA-256. It never extracts archive entries to arbitrary filesystem paths.
- Recall stages a full new chain and restores each VST3 state before detaching the existing audio callback. If plugin validation/creation/state restoration fails, active chain is left intact. Old processors are retired on the message thread after callback is detached.
- Audio output **must be muted before save or recall** because vendor plugin binary state calls and current graph detach are not guaranteed glitch-free. Output remains muted after recall. The UI explains why instead of silently interrupting a live broadcast.

## Physical trial on Windows
1. Select input/output in AUDIO SETUP and add ArSonKuPik or another known working VST3. Make an audible adjustment inside the plugin editor.
2. Open SIGNAL CHECK and click MUTE OUTPUT. Open MY SOUNDS, enter `Vocal Test 1`, SAVE SOUND.
3. Edit the plugin parameters to something clearly different or remove the plugin while muted.
4. Open MY SOUNDS and RECALL the saved sound. Check plugin editor state, bypass and processing, fader/PAN/master settings, and insert order. Unmute output manually.
5. Close/restart the EXE and repeat recall. Native presets should persist. Confirm there is no unexpected audio-device switch.
6. Test corrupted archives and missing plugins. The current chain must be retained when validation fails.

## Deferred ARD work / phase gate
- Smooth live graph switching with a prepared immutable graph + epoch-ack and bounded crossfade, so snapshot changes can be auditioned without output mute.
- Full mixer snapshots including every native channel and sends, A/B preview, durable sessions and autosave journal.
- Dedicated storage worker and out-of-process plugin scanner. ZIP save/restore I/O and vendor plugin preparation currently run on the non-real-time message thread *while output is muted*.
- Multiple independent physical/virtual inputs and real routing/stream output, rather than demo strips.
- Plugin compatibility test matrix / actual Windows xrun & 60-minute soak gates.
133 changes: 132 additions & 1 deletion src/LiveAudioEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <juce_audio_devices/juce_audio_devices.h>
#include <juce_audio_processors/juce_audio_processors.h>
#include "StereoPan.h"
#include "NativePresetArchive.h"
#include <array>
#include <atomic>
#include <cmath>
Expand All @@ -22,7 +23,8 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
struct Slot
{
std::unique_ptr<juce::AudioPluginInstance> processor;
juce::String name, catalogId;
juce::String name, catalogId, path;
int uid = 0;
bool bypass = false;
int latency = 0;
};
Expand Down Expand Up @@ -150,6 +152,8 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
Slot node;
node.name = chosen->name;
node.catalogId = catalogId;
node.path = filename;
node.uid = uid;
node.processor = std::move (instance);
slots_[count_] = std::move (node);
bypassFlags_[count_].store (false, std::memory_order_release);
Expand All @@ -158,6 +162,133 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback
return {};
}

// Capture VST3 vendor binary state, not the legacy WebView2 mock settings.
// Must only run when output is muted (caller enforces): callback is detached
// exactly once, no plugin state methods ever execute on the audio thread.
juce::String captureSnapshot (armix::storage::Snapshot& snapshot)
{
if (!isOutputMuted()) return "Mute hardware output before saving a native preset";
snapshot.effects.clear();
snapshot.channelDb = juce::Decibels::gainToDecibels (
channelGain_.load (std::memory_order_relaxed), -60.f);
snapshot.masterDb = juce::Decibels::gainToDecibels (
masterGain_.load (std::memory_order_relaxed), -60.f);
snapshot.pan = channelPan_.load (std::memory_order_relaxed);
snapshot.channelMute = channelMute_.load (std::memory_order_relaxed);
snapshot.masterMute = masterMute_.load (std::memory_order_relaxed);
detach();
juce::String error;
try
{
for (int i = 0; i < count_; ++i)
{
const auto& slot = slots_[i];
if (!slot.processor) { error = "Invalid active FX slot"; break; }
armix::storage::FxState state;
state.path = slot.path;
state.name = slot.name;
state.catalogId = slot.catalogId;
state.uid = slot.uid;
state.bypass = bypassFlags_[i].load (std::memory_order_acquire);
slot.processor->getStateInformation (state.binary);
if (state.binary.getSize() > armix::storage::NativePresetArchive::maxStateBytes)
{
error = "Plugin state exceeds 8 MB: " + slot.name;
break;
}
snapshot.effects.push_back (std::move (state));
}
}
catch (...)
{
error = "Plugin threw while saving its state";
}
attach();
if (error.isNotEmpty()) snapshot.effects.clear();
return error;
}

// Stage every plugin/state BEFORE touching the currently operating plan.
// Caller must mute output; replacing the graph is non-RT, and no old
// processor is destroyed until the callback has been detached.
juce::String restoreSnapshot (const armix::storage::Snapshot& snapshot)
{
if (!isOutputMuted())
return "Mute hardware output before recalling a native preset";
if (snapshot.effects.size() > maxFx) return "Too many plugins in preset";
auto* device = deviceManager_.getCurrentAudioDevice();
if (!device) return "No active audio device";
auto* fmt = formats_.getFormat (0);
if (!fmt) return "No VST3 format available";
const auto rate = device->getCurrentSampleRate();
const auto buffer = juce::jmax (32, device->getCurrentBufferSizeSamples());

std::array<Slot, maxFx> staged;
for (int i = 0; i < static_cast<int> (snapshot.effects.size()); ++i)
{
const auto& fx = snapshot.effects[static_cast<size_t> (i)];
if (fx.binary.getSize() > armix::storage::NativePresetArchive::maxStateBytes ||
!juce::File (fx.path).exists() || !fx.path.endsWithIgnoreCase (".vst3"))
return "Plugin is missing or invalid: " + fx.name;
juce::OwnedArray<juce::PluginDescription> descriptions;
fmt->findAllTypesForFile (descriptions, fx.path);
juce::PluginDescription* match = nullptr;
for (auto* candidate : descriptions)
if (candidate != nullptr && candidate->uniqueId == fx.uid &&
!candidate->isInstrument)
{ match = candidate; break; }
if (!match) return "VST3 plugin identity missing: " + fx.name;

juce::String error;
auto processor = formats_.createPluginInstance (*match, rate, buffer, error);
if (!processor) return "Cannot open preset plugin " + fx.name + ": " + error;
juce::AudioProcessor::BusesLayout layout;
layout.inputBuses.add (juce::AudioChannelSet::stereo());
layout.outputBuses.add (juce::AudioChannelSet::stereo());
if (!processor->setBusesLayout (layout))
return "Unsupported VST3 stereo bus: " + fx.name;
try
{
// State is restored before insertion; live audio still uses the
// old plan until every new instance has finished construction.
processor->prepareToPlay (rate, buffer);
if (fx.binary.getSize() > 0)
processor->setStateInformation (
fx.binary.getData(), static_cast<int> (fx.binary.getSize()));
}
catch (...)
{
return "Plugin failed to restore its binary state: " + fx.name;
}
Slot slot;
slot.name = match->name;
slot.catalogId = fx.catalogId;
slot.path = fx.path;
slot.uid = fx.uid;
slot.bypass = fx.bypass;
slot.processor = std::move (processor);
staged[static_cast<size_t> (i)] = std::move (slot);
}

detach();
for (int i = 0; i < count_; ++i)
if (slots_[i].processor) slots_[i].processor->releaseResources();
auto retired = std::move (slots_);
slots_ = std::move (staged);
count_ = static_cast<int> (snapshot.effects.size());
for (int i = 0; i < maxFx; ++i)
bypassFlags_[i].store (i < count_ ? slots_[i].bypass : false,
std::memory_order_release);
setChannelGainDb (snapshot.channelDb);
setChannelPan (snapshot.pan);
setMasterGainDb (snapshot.masterDb);
setChannelMuted (snapshot.channelMute);
setMasterMuted (snapshot.masterMute);
attach();
// retired instances are destroyed on the message thread, never callback.
return {};
}

bool setBypass (int index, bool value)
{
if (index < 0 || index >= count_) return false;
Expand Down
66 changes: 66 additions & 0 deletions src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
juce::Colour (0xff101921), allButtons),
catalog_ (settingsDirectory()),
diagnostics_ (settingsDirectory().getChildFile ("diagnostics")),
presets_ (settingsDirectory().getChildFile ("presets")),
browser_ (juce::WebBrowserComponent::Options{}
.withBackend (juce::WebBrowserComponent::Options::Backend::webview2)
.withWinWebView2Options (
Expand Down Expand Up @@ -141,6 +142,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
LiveAudioEngine engine_;
PluginCatalog catalog_;
DiagnosticsRecorder diagnostics_;
armix::storage::NativePresetArchive presets_;
Browser browser_;
std::unique_ptr<juce::FileChooser> chooser_;
std::unique_ptr<PluginEditorWindow> editorWindow_;
Expand All @@ -166,6 +168,12 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
browser_.emitEventIfBrowserIsVisible ("arMixCatalog", catalog_.snapshot());
}

void emitPresets()
{
if (browser_.loaded)
browser_.emitEventIfBrowserIsVisible ("arMixPresets", presets_.list());
}

void emitChain()
{
if (browser_.loaded)
Expand Down Expand Up @@ -283,6 +291,63 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
const int slot = static_cast<int> (args.getProperty ("slot", -1));

if (action == "audioSetup") showDeviceSetup();
else if (action == "presetList")
emitPresets();
else if (action == "presetSave")
{
const auto name = armix::storage::NativePresetArchive::cleanName (
args.getProperty ("name", {}).toString());
if (name.isEmpty())
return emitNotice ("Choose a valid preset name", true);
if (!engine_.isOutputMuted())
return emitNotice ("Mute output in SIGNAL CHECK before saving a native sound preset. This avoids interrupting your live performance.", true);
editorWindow_.reset();
armix::storage::Snapshot snapshot;
snapshot.name = name;
auto error = engine_.captureSnapshot (snapshot);
if (error.isEmpty()) error = presets_.save (snapshot);
if (error.isNotEmpty())
{
diagnostics_.record ("PRESET_SAVE_FAIL", name + ": " + error);
emitNotice (error, true);
}
else
{
diagnostics_.record ("PRESET_SAVED", name + " (" + juce::String (snapshot.effects.size()) + " VST3)");
emitPresets();
emitNotice ("Native VST3 preset saved: " + name);
}
}
else if (action == "presetLoad")
{
const auto name = args.getProperty ("name", {}).toString();
if (!engine_.isOutputMuted())
return emitNotice ("Mute output in SIGNAL CHECK before recalling a native sound preset.", true);
editorWindow_.reset();
armix::storage::Snapshot snapshot;
auto error = presets_.load (name, snapshot);
if (error.isEmpty()) error = engine_.restoreSnapshot (snapshot);
if (error.isNotEmpty())
{
diagnostics_.record ("PRESET_LOAD_FAIL", name + ": " + error);
emitNotice ("Preset unchanged: " + error, true);
}
else
{
diagnostics_.record ("PRESET_LOADED", name + " (" + juce::String (snapshot.effects.size()) + " VST3)");
emitChain();
auto updated = std::make_unique<juce::DynamicObject>();
updated->setProperty ("name", name);
updated->setProperty ("channelDb", snapshot.channelDb);
updated->setProperty ("masterDb", snapshot.masterDb);
updated->setProperty ("pan", snapshot.pan * 100.f);
updated->setProperty ("channelMute", snapshot.channelMute);
updated->setProperty ("masterMute", snapshot.masterMute);
if (browser_.loaded)
browser_.emitEventIfBrowserIsVisible ("arMixNativePresetLoaded", juce::var (updated.release()));
emitNotice ("Native sound recalled: " + name + ". Output remains muted until you unmute it.");
}
}
else if (action == "openDiagnostics")
{
const auto file = diagnostics_.getLogFile();
Expand Down Expand Up @@ -389,6 +454,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr
emitCatalog();
emitScanProgress();
emitChain();
emitPresets();
}
if (catalog_.busy() && timerTicks_ % 3 == 0)
emitScanProgress();
Expand Down
Loading
Loading