diff --git a/.github/workflows/ui-smoke.yml b/.github/workflows/ui-smoke.yml index 1d75b9a9b..74f4417a6 100644 --- a/.github/workflows/ui-smoke.yml +++ b/.github/workflows/ui-smoke.yml @@ -297,6 +297,8 @@ jobs: run: python tests/approved_native_harmony_smoke.py - name: Cold start first WIRE and original-channel VST3 picker editor run: python tests/approved_native_cold_start_smoke.py + - name: Native VST3 ParamID hotkey Browse, Last Touched and accepted identity + run: python tests/approved_native_fx_param_hotkey_smoke.py - name: Offline logical mixer native ACK/readback and SOURCE ONLY (Chromium) run: python tests/approved_native_offline_logical_smoke.py - name: Native desktop titlebar toolbar measured in Chromium at four viewport widths diff --git a/CMakeLists.txt b/CMakeLists.txt index a6440f98d..49c6132fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,7 @@ juce_add_binary_data(ARMixAssets SOURCES "${ARMIX_BRAND_DIR}/arsonmix-256.png") target_include_directories(ARMixConsole PRIVATE "${ARMIX_APPROVED_GUI_DIR}") -target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h engine/builtin_fx/HarmonyDsp.h engine/builtin_fx/HarmonyMusicKey.h engine/builtin_fx/ChannelHarmonyProcessor.h src/VstOrbitController.h engine/core/MixerRoutingPlan.h engine/core/ChannelRoutingContract.h engine/core/ChannelSendPlan.h engine/core/AuxBusPlan.h engine/core/PreparedMixerBlock.h engine/core/MasterOutputMonoPolicy.h engine/core/LiveChannelFxGraph.h engine/core/PreparedNativeMixerSession.h engine/core/NativeDryRouteCommand.h engine/core/RealtimeRoutePublisher.h engine/device/LiveInputPortRegistry.h src/LiveDryRoutingLab.h engine/core/OrbitPhase.h engine/core/OrbitControlPolicy.h engine/core/OrbitMotion.h engine/core/OrbitDistanceMapping.h engine/core/DearVrPolarPolicy.h src/PluginCatalog.h src/FactoryFxRegistry.h src/PluginVault.h src/PortableWorkspace.h src/StudioBackup.h src/DiagnosticsRecorder.h src/StereoPan.h src/NativePresetArchive.h src/NativeShowSchema.h src/NativeDryShowRecall.h src/VstBusLayout.h src/LiveGraphHandoff.h src/DiagnosticTone.h engine/core/RealtimeHealthHistogram.h engine/core/CallbackCadenceEvidence.h engine/diagnostics/CrackleEvidenceWindow.h engine/device/AdaptiveClockBridge.h engine/device/AudioProfilePolicy.h engine/device/PeriodCapabilityEvidence.h engine/device/SessionLifecycle.h engine/device/WasapiCapabilityProbe.h engine/device/JuceIndependentClockDevice.h engine/device/LiveSecondaryOutputDevice.h engine/core/LiveOutputRouteGate.h engine/device/ClockBridgeSizing.h engine/device/IndependentStreamFormatFence.h engine/device/DirectRestoreBackoff.h engine/device/IndependentStreamWatchdog.h engine/device/BridgeContinuityGate.h engine/device/EndpointIdentityPolicy.h engine/device/WasapiEndpointIdentityGuard.h engine/device/AsioStartupPolicy.h engine/device/AsioPriorityDeviceManager.h engine/device/JuceActivePortSnapshot.h engine/device/AsioRegistrationPolicy.h engine/device/AsioRegistryIdentityProbe.h engine/device/DirectRouteFence.h) +target_sources(ARMixConsole PRIVATE src/Main.cpp src/LiveAudioEngine.h engine/builtin_fx/HarmonyDsp.h engine/builtin_fx/HarmonyMusicKey.h engine/builtin_fx/ChannelHarmonyProcessor.h src/VstOrbitController.h engine/core/MixerRoutingPlan.h engine/core/ChannelRoutingContract.h engine/core/ChannelSendPlan.h engine/core/AuxBusPlan.h engine/core/PreparedMixerBlock.h engine/core/MasterOutputMonoPolicy.h engine/core/LiveChannelFxGraph.h engine/core/PreparedNativeMixerSession.h engine/core/NativeDryRouteCommand.h engine/core/RealtimeRoutePublisher.h engine/device/LiveInputPortRegistry.h src/LiveDryRoutingLab.h engine/core/OrbitPhase.h engine/core/OrbitControlPolicy.h engine/core/OrbitMotion.h engine/core/OrbitDistanceMapping.h engine/core/DearVrPolarPolicy.h src/PluginCatalog.h src/NativeFxParameterHotkey.h src/FactoryFxRegistry.h src/PluginVault.h src/PortableWorkspace.h src/StudioBackup.h src/DiagnosticsRecorder.h src/StereoPan.h src/NativePresetArchive.h src/NativeShowSchema.h src/NativeDryShowRecall.h src/VstBusLayout.h src/LiveGraphHandoff.h src/DiagnosticTone.h engine/core/RealtimeHealthHistogram.h engine/core/CallbackCadenceEvidence.h engine/diagnostics/CrackleEvidenceWindow.h engine/device/AdaptiveClockBridge.h engine/device/AudioProfilePolicy.h engine/device/PeriodCapabilityEvidence.h engine/device/SessionLifecycle.h engine/device/WasapiCapabilityProbe.h engine/device/JuceIndependentClockDevice.h engine/device/LiveSecondaryOutputDevice.h engine/core/LiveOutputRouteGate.h engine/device/ClockBridgeSizing.h engine/device/IndependentStreamFormatFence.h engine/device/DirectRestoreBackoff.h engine/device/IndependentStreamWatchdog.h engine/device/BridgeContinuityGate.h engine/device/EndpointIdentityPolicy.h engine/device/WasapiEndpointIdentityGuard.h engine/device/AsioStartupPolicy.h engine/device/AsioPriorityDeviceManager.h engine/device/JuceActivePortSnapshot.h engine/device/AsioRegistrationPolicy.h engine/device/AsioRegistryIdentityProbe.h engine/device/DirectRouteFence.h) # Explicit UTF-8 source decoding: native channel icons are Unicode, and # MSVC's machine-specific ANSI source charset corrupts emoji literals. # Limit the flag to C++ (not Windows .rc/resource compilation). @@ -473,6 +473,14 @@ if(BUILD_TESTING) target_compile_features(ARMixNativeHotkeyTests PRIVATE cxx_std_20) add_test(NAME H1NativeGlobalShortcutRegistrationConflictAndPersistence COMMAND ARMixNativeHotkeyTests) + # H2 hosted VST3 ParamID remapping / automation flags; no hardware needed. + juce_add_console_app(ARMixFxParamHotkeyTests PRODUCT_NAME "ArSonMix FX Parameter Hotkey Tests") + target_sources(ARMixFxParamHotkeyTests PRIVATE + tests/native_fx_parameter_hotkey_test.cpp src/NativeFxParameterHotkey.h) + target_link_libraries(ARMixFxParamHotkeyTests PRIVATE + juce::juce_audio_processors juce::juce_recommended_config_flags) + target_compile_features(ARMixFxParamHotkeyTests PRIVATE cxx_std_20) + add_test(NAME H2HostedParamIdStableAndAutomationSafe COMMAND ARMixFxParamHotkeyTests) # Presentation-only native identity; no audio-thread access. juce_add_console_app(ARMixChannelAppearanceTests PRODUCT_NAME "ArSonMix Channel Appearance Tests") diff --git a/engine/core/LiveChannelFxGraph.h b/engine/core/LiveChannelFxGraph.h index 0c32f3edb..1ca1d5c53 100644 --- a/engine/core/LiveChannelFxGraph.h +++ b/engine/core/LiveChannelFxGraph.h @@ -40,6 +40,10 @@ class LiveChannelFxGraph final { const juce::String instanceId; // stable through MOVE; never a slot index const int latencySamples; std::atomic latencyChanged{false}; + // Vendor editor beginChangeGesture -> atomic index; never allocate, + // call JS or touch the JUCE message loop from a parameter callback. + std::atomic lastTouchedParameter{-1}; + std::atomic hostHotkeyWrite{false}; armix::dsp::StereoLatencyDelay dryDelay; std::atomic bypassRequested{false}; armix::dsp::FxBypassEnvelope bypassFade; // RT exclusive state @@ -101,6 +105,11 @@ class LiveChannelFxGraph final { } } void audioProcessorParameterChanged(juce::AudioProcessor*,int,float) override {} + void audioProcessorParameterChangeGestureBegin( + juce::AudioProcessor*,int parameterIndex) override { + if(!hostHotkeyWrite.load(std::memory_order_acquire)) + lastTouchedParameter.store(parameterIndex,std::memory_order_release); + } void audioProcessorChanged(juce::AudioProcessor* p, const juce::AudioProcessorListener::ChangeDetails& details) override { if(details.latencyChanged && p && p->getLatencySamples()!=latencySamples) diff --git a/src/Main.cpp b/src/Main.cpp index cd336646a..974b487ac 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -40,6 +40,7 @@ #include "NativeMixerSessionSaveWorker.h" #include "NativeLogicalMixerControl.h" #include "NativeHotkeyRegistry.h" +#include "NativeFxParameterHotkey.h" #include "NativeDeviceApplyCoordinator.h" #include #include @@ -281,6 +282,9 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr .withEventListener ("arMixHotkeyCapture", [this] (juce::var args) { hotkeys_.setCaptureMode(args.getProperty("enabled",false)==juce::var(true)); }) + .withEventListener ("arMixFxParameterHotkeyInspect", [this] (juce::var args) { + inspectFxParameterHotkey(args); + }) .withEventListener ("arMixConsoleSubscribe", [this] (juce::var) { // G0 real-device native producer, NEVER a synthetic ChannelId callback. consoleSubscribed_ = true; @@ -1258,6 +1262,154 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr reply("Offline FX settings could not be saved"); } + // H2: verify real live VST3 lease and class identity. The positional slot + // is a GUI hint only; moves resolve by the exact FX instance token. + struct FxHotkeyLease final { + armix::mixer::LiveChannelFxGraph::InstanceLease owner; + juce::AudioPluginInstance* plugin=nullptr; + int slot=-1; + }; + FxHotkeyLease resolveFxHotkey(const juce::String& channelId, + const juce::String& insertId,const juce::String& catalogId) { + FxHotkeyLease target; + if(channelId.isEmpty()||insertId.isEmpty()||catalogId.isEmpty()|| + deviceApply_.busy()||nativeShowBusy_||studioBackupBusy_|| + engine_.independentClockActive()||engine_.isGraphSwitchPending()) + return target; + const auto snapshot=approvedNativeSnapshot(); + const auto graph=snapshot.getProperty("graph",{}); + if(!static_cast(graph.getProperty("capabilities",{}) + .getProperty("callbackOwnsChannelIds",false)))return target; + std::uint64_t id=0,epoch=0,revision=0; + if(!armix::console::approvedNativeId(juce::var(channelId),id)|| + !armix::console::approvedNativeId( + snapshot.getProperty("device",{}).getProperty("epoch",{}),epoch)|| + !armix::console::approvedNativeId( + graph.getProperty("revision",{}),revision))return target; + const auto rows=graph.getProperty("channels",{}); + if(!rows.isArray())return target; + for(const auto& row:*rows.getArray()) { + if(row.getProperty("id","").toString()!=channelId || + (row.getProperty("role","").toString()!="INPUT" && + row.getProperty("role","").toString()!="GROUP" && + row.getProperty("role","").toString()!="FX_RETURN"))continue; + const auto inserts=row.getProperty("inserts",{}); + if(!inserts.isArray())return target; + const auto* all=inserts.getArray(); + for(int slot=0;slotsize();++slot) { + const auto entry=all->getReference(slot); + if(entry.getProperty("id","").toString()!=insertId || + entry.getProperty("catalogId","").toString()!=catalogId) + continue; + auto owner=engine_.leaseNativeVst3Editor(epoch,revision, + armix::mixer::ChannelId{id},static_cast(slot),insertId); + if(!owner||owner->instanceId!=insertId|| + owner->catalogId!=catalogId||!owner->processor)return target; + auto* plugin=dynamic_cast(owner->processor.get()); + if(!plugin)return target; + juce::PluginDescription description; + plugin->fillInPluginDescription(description); + if(!description.pluginFormatName.equalsIgnoreCase("VST3"))return target; + target.owner=std::move(owner); + target.plugin=plugin; + target.slot=slot; + return target; + } + break; + } + return target; + } + bool fxParameterHotkeyAdmitted(const armix::hotkey::Mapping& mapping) { + auto target=resolveFxHotkey(mapping.channelId,mapping.insertId,mapping.catalogId); + if(!target.plugin)return false; + auto* parameter=armix::hotkey::FxParameterPolicy::find( + target.plugin->getParameters(),mapping.paramId); + return parameter&&armix::hotkey::FxParameterPolicy::operationAllowed( + *parameter,mapping.operation); + } + bool applyFxParameterHotkey(const armix::hotkey::Mapping& mapping) { + auto target=resolveFxHotkey(mapping.channelId,mapping.insertId,mapping.catalogId); + if(!target.plugin)return false; + auto* parameter=armix::hotkey::FxParameterPolicy::find( + target.plugin->getParameters(),mapping.paramId); + float next=0.f; + if(!parameter || + !armix::hotkey::FxParameterPolicy::desired(*parameter,mapping.operation,next)) + return false; + // Call JUCE's notifying setter only on CONTROL, never on PCM callback. + // Host-written beginChangeGesture is not mistaken for vendor Last Touched. + target.owner->hostHotkeyWrite.store(true,std::memory_order_release); + bool applied=false; + try { + parameter->beginChangeGesture(); + parameter->setValueNotifyingHost(next); + parameter->endChangeGesture(); + applied=true; + } catch(...) { + try {parameter->endChangeGesture();}catch(...){} + } + target.owner->hostHotkeyWrite.store(false,std::memory_order_release); + if(applied) + diagnostics_.record("NATIVE_FX_PARAM_HOTKEY", + mapping.channelId+" / "+mapping.insertId+" / "+mapping.paramId); + return applied; + } + void inspectFxParameterHotkey(const juce::var& request) { + const auto requestId=request.getProperty("requestId","").toString(); + const auto channelId=request.getProperty("channelId","").toString(); + const auto insertId=request.getProperty("insertId","").toString(); + const auto catalogId=request.getProperty("catalogId","").toString(); + const auto observed=approvedNativeSnapshot(); + const auto graph=observed.getProperty("graph",{}); + auto response=juce::var(new juce::DynamicObject()); + auto* result=response.getDynamicObject(); + result->setProperty("requestId",requestId); + result->setProperty("channelId",channelId); + result->setProperty("insertId",insertId); + result->setProperty("catalogId",catalogId); + result->setProperty("ok",false); + result->setProperty("error","HOTKEY_FX_STALE_OR_UNAVAILABLE"); + const bool current=requestId.isNotEmpty()&&requestId.length()<=96 && + request.getProperty("deviceEpoch","").toString()== + observed.getProperty("device",{}).getProperty("epoch","").toString() && + request.getProperty("revision","").toString()== + graph.getProperty("revision","").toString() && + request.getProperty("rosterRevision","").toString()== + graph.getProperty("rosterRevision","").toString(); + if(current) { + auto target=resolveFxHotkey(channelId,insertId,catalogId); + if(target.plugin) { + const auto info=armix::hotkey::FxParameterPolicy::browse( + target.plugin->getParameters()); + juce::Array listed; + const auto touched=target.owner->lastTouchedParameter.load( + std::memory_order_acquire); + juce::String lastTouchedId; + for(const auto& p:info) { + auto item=juce::var(new juce::DynamicObject()); + auto* o=item.getDynamicObject(); + o->setProperty("id",p.id); + o->setProperty("name",p.name); + o->setProperty("index",p.index); // UI hint, never saved + o->setProperty("toggle",p.toggle); + o->setProperty("steps",p.steps); + o->setProperty("value",p.normalized); + listed.add(item); + if(touched==p.index)lastTouchedId=p.id; + } + result->setProperty("parameters",juce::var(listed)); + result->setProperty("lastTouchedId",lastTouchedId); + result->setProperty("slot",target.slot); + result->setProperty("name",target.plugin->getName()); + result->setProperty("ok",!info.empty()); + result->setProperty("error",info.empty()? + "VST3_STABLE_PARAMETER_IDS_UNAVAILABLE":"NONE"); + } + } + if(browser_.loaded) + browser_.emitEventIfBrowserIsVisible("arMixFxParameterHotkeyState",response); + } + // Native hotkeys share the accepted ChannelId mixer control path. // WM_HOTKEY is delivered on the JUCE message thread even while the // WebView is minimized, and never synthesizes a browser mouse click. @@ -1295,7 +1447,14 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr } break; } - const bool fx=op=="SET_FX_RACK_BYPASS"||op=="SET_FX_SLOT_BYPASS"; + const bool fxParam=op.startsWith("SET_FX_PARAM_"); + if(fxParam) { + armix::hotkey::Mapping mapping; + if(armix::hotkey::Registry::decode(row,mapping)) + fxAvailable=fxParameterHotkeyAdmitted(mapping); + } + const bool fx=op=="SET_FX_RACK_BYPASS"|| + op=="SET_FX_SLOT_BYPASS"||fxParam; const juce::String status= !admitted?"WAITING_NATIVE_AUDIO": !found?"NEEDS_REMAP": @@ -1338,7 +1497,8 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr const auto scope=supplied.getProperty("scope","").toString(); auto cleaned=juce::var(new juce::DynamicObject()); for(const char* field:{"id","scope","sessionId","channelId", - "operation","vk","modifiers","slot","insertId"}) { + "operation","vk","modifiers","slot","insertId", + "catalogId","paramId","paramName"}) { const auto value=supplied.getProperty(field,{}); if(!value.isVoid())cleaned.getDynamicObject()->setProperty(field,value); } @@ -1351,6 +1511,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr const auto op=supplied.getProperty("operation","").toString(); const bool fxRack=op=="SET_FX_RACK_BYPASS"; const bool fxSlot=op=="SET_FX_SLOT_BYPASS"; + const bool fxParam=op.startsWith("SET_FX_PARAM_"); bool found=false,fxAvailable=false; if(static_cast(caps.getProperty("callbackOwnsChannelIds",false)) && channels.isArray())for(const auto& c:*channels.getArray()) { @@ -1378,10 +1539,10 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr error="HOTKEY_FX_INSTANCE_NOT_ADMITTED"; const auto ops=caps.getProperty("supportedOps",{}); const auto* allowed=ops.getArray(); - if(error.isEmpty() && !fxRack && !fxSlot && + if(error.isEmpty() && !fxRack && !fxSlot && !fxParam && op!="SET_MUTE" && op!="SET_SOLO") error="HOTKEY_ACTION_UNSUPPORTED"; - if(error.isEmpty() && !fxRack && !fxSlot && + if(error.isEmpty() && !fxRack && !fxSlot && !fxParam && (!allowed || !allowed->contains(juce::var(op)))) error="HOTKEY_ACTION_NOT_ADMITTED"; if(error.isEmpty()) { @@ -1395,6 +1556,9 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr armix::hotkey::Mapping mapping; if(error.isEmpty() && !armix::hotkey::Registry::decode(cleaned,mapping)) error="INVALID_HOTKEY_MAPPING"; + if(error.isEmpty()&&mapping.operation.startsWith("SET_FX_PARAM_")&& + !fxParameterHotkeyAdmitted(mapping)) + error="HOTKEY_PARAMETER_ID_OR_INSTANCE_UNAVAILABLE"; if(error.isEmpty())error=hotkeys_.upsert(std::move(mapping)); } else error="UNSUPPORTED_HOTKEY_OPERATION"; } @@ -1426,6 +1590,10 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr match=&ch;break; } if(!match)return; + if(mapping.operation.startsWith("SET_FX_PARAM_")) { + (void)applyFxParameterHotkey(mapping); + return; + } const bool fxRack=mapping.operation=="SET_FX_RACK_BYPASS"; const bool fxSlot=mapping.operation=="SET_FX_SLOT_BYPASS"; if(fxRack||fxSlot) { diff --git a/src/NativeFxParameterHotkey.h b/src/NativeFxParameterHotkey.h new file mode 100644 index 000000000..f6c8f9832 --- /dev/null +++ b/src/NativeFxParameterHotkey.h @@ -0,0 +1,97 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include +#include +#include +#include + +// H2 host-side parameter identity: never persist JUCE parameter array indexes. +// JUCE's HostedAudioProcessorParameter::getParameterID() is the VST3 host's +// stable vendor-facing parameter ID; plugins without this surface cannot be +// safely mapped, even if their GUI displays a recognizable knob. +namespace armix::hotkey { +struct FxParameterTarget final { + juce::String id,name; + int index=-1,steps=0; + bool toggle=false; + float normalized=0.f; +}; +class FxParameterPolicy final { +public: + static constexpr int maxParameters=512; + static constexpr int maxIdLength=96; + static bool validId(const juce::String& value) noexcept { + return value.isNotEmpty() && value.length()<=maxIdLength && + !value.containsAnyOf("\r\n\t"); + } + static juce::String hostedId(const juce::AudioProcessorParameter* parameter) { + if(!parameter||!parameter->isAutomatable()||parameter->isMetaParameter()) + return {}; + const auto* hosted=dynamic_cast(parameter); + if(!hosted)return {}; + const auto id=hosted->getParameterID(); + return validId(id)?id:juce::String{}; + } + static bool isToggle(const juce::AudioProcessorParameter& parameter) { + return parameter.isDiscrete()&¶meter.getNumSteps()==2; + } + static bool operationAllowed(const juce::AudioProcessorParameter& parameter, + const juce::String& operation) { + if(!parameter.isAutomatable()||parameter.isMetaParameter())return false; + if(operation=="SET_FX_PARAM_TOGGLE")return isToggle(parameter); + if(operation=="SET_FX_PARAM_UP"||operation=="SET_FX_PARAM_DOWN") + return !isToggle(parameter); + return false; + } + // The caller supplies a verified, leased live processor. Each candidate ID + // must be unique; duplicate / missing stable IDs are never matched by index. + static juce::AudioProcessorParameter* find( + const juce::Array& parameters, + const juce::String& id, int* position=nullptr) { + if(!validId(id)||parameters.size()>maxParameters)return nullptr; + juce::AudioProcessorParameter* found=nullptr; + int foundIndex=-1; + for(int i=0;i browse( + const juce::Array& parameters) { + std::vector result; + if(parameters.size()>maxParameters)return result; + result.reserve(static_cast(parameters.size())); + for(int i=0;igetValue(); + if(!std::isfinite(value)||value<0.f||value>1.f)continue; + result.push_back({id,p->getName(100),i,p->getNumSteps(), + isToggle(*p),value}); + } + return result; + } + // Continuous controls take 5% of the *normalized* vendor range per key + // press; discrete controls take one actual vendor step. No key held repeat. + static bool desired(const juce::AudioProcessorParameter& p, + const juce::String& operation,float& next) { + if(!operationAllowed(p,operation))return false; + const float before=p.getValue(); + if(!std::isfinite(before)||before<0.f||before>1.f)return false; + if(operation=="SET_FX_PARAM_TOGGLE") + next=before>=0.5f?0.f:1.f; + else { + const int n=p.getNumSteps(); + const float step=p.isDiscrete()&&n>2 && n<100000? + 1.f/static_cast(n-1):0.05f; + next=std::clamp(before+(operation=="SET_FX_PARAM_UP"?step:-step),0.f,1.f); + } + return std::isfinite(next); + } +}; +} // namespace armix::hotkey diff --git a/src/NativeHotkeyRegistry.h b/src/NativeHotkeyRegistry.h index 08df695cf..9f93de8a7 100644 --- a/src/NativeHotkeyRegistry.h +++ b/src/NativeHotkeyRegistry.h @@ -35,6 +35,8 @@ struct Mapping final { // Preserve the exact plugin instance, not merely the positional slot. int slot=-1; juce::String insertId; + // H2: real hosted VST3 identity. Index/slot are discovery hints only. + juce::String catalogId,paramId,paramName; }; class Registry final { public: @@ -52,13 +54,22 @@ class Registry final { const bool chord=(m.modifiers&~7)==0 && (m.modifiers&3)!=0; // global chords need Ctrl or Alt const bool fxSlot=m.operation=="SET_FX_SLOT_BYPASS"; + const bool fxParam=m.operation=="SET_FX_PARAM_TOGGLE"|| + m.operation=="SET_FX_PARAM_UP"|| + m.operation=="SET_FX_PARAM_DOWN"; const bool command=m.operation=="PANIC_MUTE" || m.operation=="SET_MUTE"||m.operation=="SET_SOLO"|| - m.operation=="SET_FX_RACK_BYPASS"||fxSlot; - const bool target=fxSlot? - m.slot>=0 && m.slot<8 && m.insertId.isNotEmpty() && - m.insertId.length()<=128: - m.slot==-1 && m.insertId.isEmpty(); + m.operation=="SET_FX_RACK_BYPASS"||fxSlot||fxParam; + const bool hasInsert=m.slot>=0 && m.slot<8 && m.insertId.isNotEmpty() && + m.insertId.length()<=128; + const bool paramTarget=fxParam && hasInsert && + m.catalogId.isNotEmpty() && m.catalogId.length()<=512 && + m.paramId.isNotEmpty() && m.paramId.length()<=96 && + m.paramName.length()<=100 && !m.paramId.containsAnyOf("\r\n\t"); + const bool target=fxParam?paramTarget: + fxSlot?(hasInsert&&m.catalogId.isEmpty()&&m.paramId.isEmpty()&&m.paramName.isEmpty()): + (m.slot==-1&&m.insertId.isEmpty()&& + m.catalogId.isEmpty()&&m.paramId.isEmpty()&&m.paramName.isEmpty()); const bool app=m.scope=="APP" && m.operation=="PANIC_MUTE" && m.channelId.isEmpty() && m.sessionId.isEmpty(); const bool session=m.scope=="SESSION" && m.operation!="PANIC_MUTE" && @@ -76,9 +87,15 @@ class Registry final { o->setProperty("channelId",m.channelId); o->setProperty("operation",m.operation); o->setProperty("vk",m.vk);o->setProperty("modifiers",m.modifiers); - if(m.operation=="SET_FX_SLOT_BYPASS") { + if(m.operation=="SET_FX_SLOT_BYPASS"|| + m.operation.startsWith("SET_FX_PARAM_")) { o->setProperty("slot",m.slot); o->setProperty("insertId",m.insertId); + if(m.operation.startsWith("SET_FX_PARAM_")) { + o->setProperty("catalogId",m.catalogId); + o->setProperty("paramId",m.paramId); + if(m.paramName.isNotEmpty())o->setProperty("paramName",m.paramName); + } } return out; } @@ -94,14 +111,34 @@ class Registry final { !field("sessionId",m.sessionId)||!field("channelId",m.channelId)|| !field("operation",m.operation)||!vk.isInt()||!mods.isInt())return false; m.vk=static_cast(vk);m.modifiers=static_cast(mods); - m.slot=-1;m.insertId.clear(); // old H1 documents remain readable - if(m.operation=="SET_FX_SLOT_BYPASS") { + m.slot=-1;m.insertId.clear();m.catalogId.clear(); + m.paramId.clear();m.paramName.clear(); + const bool fxParam=m.operation.startsWith("SET_FX_PARAM_"); + if(m.operation=="SET_FX_SLOT_BYPASS"||fxParam) { const auto slot=v.getProperty("slot",{}),token=v.getProperty("insertId",{}); if(!slot.isInt()||!token.isString()||token.toString().length()>128) return false; m.slot=static_cast(slot);m.insertId=token.toString(); + if(fxParam) { + const auto catalog=v.getProperty("catalogId",{}); + const auto parameter=v.getProperty("paramId",{}); + if(!catalog.isString()||!parameter.isString() || + catalog.toString().length()>512|| + parameter.toString().length()>96)return false; + m.catalogId=catalog.toString();m.paramId=parameter.toString(); + const auto label=v.getProperty("paramName",{}); + if(!label.isVoid()){ + if(!label.isString()||label.toString().length()>100)return false; + m.paramName=label.toString(); + } + }else if(!v.getProperty("catalogId",{}).isVoid() || + !v.getProperty("paramId",{}).isVoid()|| + !v.getProperty("paramName",{}).isVoid())return false; } else if(!v.getProperty("slot",{}).isVoid() || - !v.getProperty("insertId",{}).isVoid())return false; + !v.getProperty("insertId",{}).isVoid()|| + !v.getProperty("catalogId",{}).isVoid()|| + !v.getProperty("paramId",{}).isVoid()|| + !v.getProperty("paramName",{}).isVoid())return false; return valid(m); } void setHandler(std::function handler) { diff --git a/tests/approved_native_fx_param_hotkey_smoke.py b/tests/approved_native_fx_param_hotkey_smoke.py new file mode 100644 index 000000000..490dffdbb --- /dev/null +++ b/tests/approved_native_fx_param_hotkey_smoke.py @@ -0,0 +1,146 @@ +"""H2: actual assembled /preview/ native-only FX parameter-browser journey. + +The JUCE bridge is mocked only to verify GUI intent/ACK/readback and stale +identity. Real hosted VST3 parameter-ID access is validated by MSVC CTest. +No fake audio PCM or vendor UI interception is claimed. +""" +import copy +import importlib.util +from pathlib import Path +import tempfile +from playwright.sync_api import sync_playwright +from approved_native_wire_gain_smoke import snapshot, emit, SOURCE + +ROOT=Path(__file__).resolve().parents[1] + + +def main(): + spec=importlib.util.spec_from_file_location( + "native_bundle", ROOT/"scripts/build_approved_native_gui.py") + bundle=importlib.util.module_from_spec(spec) + spec.loader.exec_module(bundle) + with tempfile.TemporaryDirectory(prefix="armix-h2-ui-") as tmp, sync_playwright() as p: + out=Path(tmp) + bundle.stage(out) + browser=p.chromium.launch(headless=True) + page=browser.new_page(viewport={"width":1366,"height":768}) + errors=[] + page.on("pageerror",lambda e:errors.append(str(e))) + page.add_init_script("""window.__nativeListeners=new Map();window.__events=[]; + window.__JUCE__={backend:{ + emitEvent(name,payload){window.__events.push({name,payload});}, + addEventListener(name,handler){window.__nativeListeners.set(name,handler);} + }};""") + page.goto((out/"index.html").as_uri()) + page.wait_for_function("()=>window.__ARMIX_NATIVE_M2__?.enabled") + state=snapshot() + state["graph"]["channels"][0]["inserts"]=[{ + "id":"g5c-real-001","catalogId":"vendor-vst3|class-7", + "name":"Vendor VST3","bypassed":False,"latencySamples":0}] + state["graph"]["channels"][0]["fxRackBypassed"]=False + state["mixerSession"]["channels"]=copy.deepcopy(state["graph"]["channels"]) + emit(page,"arMixConsoleSnapshot",state) + page.wait_for_selector('#tracks .strip[data-id="1"] .fxslot-row:not(.is-empty)') + emit(page,"arMixHotkeyRegistry",{ + "schema":"arsonmix.hotkey-registry.v1", + "sessionId":"11111111-2222-4333-8444-555555555555", + "entries":[]}) + row=page.locator('#tracks .strip[data-id="1"] .fxslot-row:not(.is-empty)').first + + row.click(button="right") + menu=page.locator("#armixContext") + assert menu.is_visible() + assert menu.get_by_role("menuitem",name="Browse Parameters…").count()==1 + assert menu.get_by_role("menuitem",name="Last Touched Hotkey…").count()==1 + menu.get_by_role("menuitem",name="Browse Parameters…").click() + page.wait_for_function("""()=>window.__events.some(e=> + e.name==='arMixFxParameterHotkeyInspect')""") + request=page.evaluate("""()=>window.__events.filter(e=> + e.name==='arMixFxParameterHotkeyInspect').at(-1).payload""") + assert request["channelId"]==SOURCE + assert request["insertId"]=="g5c-real-001" + assert request["catalogId"]=="vendor-vst3|class-7" + assert request["deviceEpoch"]==state["device"]["epoch"] + assert request["revision"]==state["graph"]["revision"] + params=[ + {"id":"class:77","name":"Stereo Width","index":4, + "toggle":False,"steps":2147483647,"value":0.5}, + {"id":"class:8","name":"Stereo Mode","index":0, + "toggle":True,"steps":2,"value":0.0}] + emit(page,"arMixFxParameterHotkeyState",{ + **request,"ok":True,"error":"NONE","slot":0, + "parameters":params,"lastTouchedId":""}) + panel=page.locator("#armixFxParamBrowse") + assert panel.is_visible() + assert panel.locator(".armix-param-row").count()==2 + panel.get_by_role("button",name="Assign Toggle hotkey for Stereo Mode").click() + card=page.locator("#armixHotkeyCard") + assert card.is_visible() + assert "Stereo Mode" in card.locator("#armixHkTarget").inner_text() + page.keyboard.press("Control+Shift+F5") + card.locator("[data-hk-save]").click() + reg=page.evaluate("""()=>window.__events.filter(e=> + e.name==='arMixHotkeyIntent'&&e.payload.operation==='REGISTER') + .at(-1).payload""") + mapping=reg["mapping"] + assert mapping["channelId"]==SOURCE and mapping["slot"]==0 + assert mapping["insertId"]=="g5c-real-001" + assert mapping["catalogId"]=="vendor-vst3|class-7" + assert mapping["paramId"]=="class:8" and mapping["paramName"]=="Stereo Mode" + assert mapping["operation"]=="SET_FX_PARAM_TOGGLE" + assert mapping["vk"]==0x74 and mapping["modifiers"]==6 + # A native ACK alone is not accepted as persistent success. + assert card.is_visible() + registered={**mapping,"status":"REGISTERED"} + emit(page,"arMixHotkeyRegistry",{ + "schema":"arsonmix.hotkey-registry.v1", + "sessionId":mapping["sessionId"],"entries":[registered], + "requestId":reg["requestId"],"status":"ACCEPTED"}) + assert card.is_visible() + emit(page,"arMixHotkeyRegistry",{ + "schema":"arsonmix.hotkey-registry.v1", + "sessionId":mapping["sessionId"],"entries":[registered]}) + assert card.is_hidden() + + # Last Touched is NEVER fabricated: without a vendor gesture the + # browser offers a genuine parameter browse fallback. + row.click(button="right") + menu.get_by_role("menuitem",name="Last Touched Hotkey…").click() + request2=page.evaluate("""()=>window.__events.filter(e=> + e.name==='arMixFxParameterHotkeyInspect').at(-1).payload""") + emit(page,"arMixFxParameterHotkeyState",{ + **request2,"ok":True,"error":"NONE","slot":0, + "parameters":params,"lastTouchedId":""}) + assert "No vendor gesture yet" in panel.inner_text() + assert panel.locator(".armix-param-row").count()==2 + panel.locator("[data-fxparam-close]").click() + row.click(button="right") + menu.get_by_role("menuitem",name="Last Touched Hotkey…").click() + request3=page.evaluate("""()=>window.__events.filter(e=> + e.name==='arMixFxParameterHotkeyInspect').at(-1).payload""") + emit(page,"arMixFxParameterHotkeyState",{ + **request3,"ok":True,"error":"NONE","slot":0, + "parameters":params,"lastTouchedId":"class:77"}) + assert panel.locator(".armix-param-row").count()==1 + assert "Stereo Width" in panel.locator(".armix-param-row").inner_text() + # Native parameter-ID mismatches/replaced VST instances cannot + # rebind from the old row to a different plugin. + replaced=copy.deepcopy(state) + replaced["graph"]["revision"]="3" + replaced["graph"]["channels"][0]["inserts"][0]["id"]="g5c-replaced" + replaced["mixerSession"]["routeRevision"]="3" + replaced["mixerSession"]["channels"]=copy.deepcopy(replaced["graph"]["channels"]) + emit(page,"arMixConsoleSnapshot",replaced) + before=page.evaluate("""()=>window.__events.filter(e=> + e.name==='arMixHotkeyIntent'&&e.payload.operation==='REGISTER').length""") + panel.get_by_role("button",name="Assign + hotkey for Stereo Width").click() + assert panel.is_hidden() + assert page.evaluate("""()=>window.__events.filter(e=> + e.name==='arMixHotkeyIntent'&&e.payload.operation==='REGISTER').length""")==before + assert not errors,errors + browser.close() + print("H2 compiled native VST3 ParamID Browse/Last Touched/ACK identity: PASS") + + +if __name__=="__main__": + main() diff --git a/tests/approved_native_gui_bundle_test.py b/tests/approved_native_gui_bundle_test.py index d9eac7580..29013eaec 100644 --- a/tests/approved_native_gui_bundle_test.py +++ b/tests/approved_native_gui_bundle_test.py @@ -68,6 +68,19 @@ def test_native_is_exact_assembled_public_pages_plus_nonvisual_native_seam(self) self.assertIn('data-action="fxOn"', context_menu) native_host = (ROOT / "src/Main.cpp").read_text("utf-8") self.assertIn("HOTKEY_FX_INSTANCE_NOT_ADMITTED", native_host) + self.assertIn("Browse Parameters…", context_menu) + self.assertIn("Last Touched Hotkey…", context_menu) + self.assertIn("arMixFxParameterHotkeyInspect", context_menu) + self.assertIn("arMixFxParameterHotkeyState", context_menu) + self.assertIn("SET_FX_PARAM_TOGGLE", context_menu) + self.assertIn("SET_FX_PARAM_UP", context_menu) + self.assertIn("SET_FX_PARAM_DOWN", context_menu) + self.assertIn("resolveFxHotkey", native_host) + self.assertIn("FxParameterPolicy::find", native_host) + self.assertIn("lastTouchedParameter", native_host) + self.assertIn("HOTKEY_PARAMETER_ID_OR_INSTANCE_UNAVAILABLE", native_host) + self.assertIn("HostedAudioProcessorParameter", + (ROOT / "src/NativeFxParameterHotkey.h").read_text("utf-8")) self.assertIn('routingNativeFxInsertBypass', native_host) self.assertIn('routingNativeFxRackBypass', native_host) self.assertIn("hotkey-register", context_menu) diff --git a/tests/native_fx_parameter_hotkey_test.cpp b/tests/native_fx_parameter_hotkey_test.cpp new file mode 100644 index 000000000..313bcd0b4 --- /dev/null +++ b/tests/native_fx_parameter_hotkey_test.cpp @@ -0,0 +1,63 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#ifdef NDEBUG + #undef NDEBUG +#endif +#include +#include +#include "../src/NativeFxParameterHotkey.h" + +using armix::hotkey::FxParameterPolicy; + +int main() { + juce::AudioParameterBool bypass(juce::ParameterID{"vendor-bypass",1}, + "Vendor bypass",false); + juce::AudioParameterFloat amount(juce::ParameterID{"vendor-amount",1}, + "Amount",{0.f,1.f},0.50f); + juce::Array params; + params.add(&bypass); + params.add(&amount); + const auto listed=FxParameterPolicy::browse(params); + assert(listed.size()==2); + assert(listed[0].id=="vendor-bypass"&&listed[0].toggle); + assert(listed[1].id=="vendor-amount"&&!listed[1].toggle); + assert(FxParameterPolicy::find(params,"vendor-bypass")==&bypass); + assert(FxParameterPolicy::find(params,"vendor-amount")==&amount); + assert(FxParameterPolicy::find(params,"unknown")==nullptr); + assert(FxParameterPolicy::find(params,"vendor-amount\n")==nullptr); + assert(FxParameterPolicy::operationAllowed(bypass,"SET_FX_PARAM_TOGGLE")); + assert(!FxParameterPolicy::operationAllowed(amount,"SET_FX_PARAM_TOGGLE")); + assert(FxParameterPolicy::operationAllowed(amount,"SET_FX_PARAM_UP")); + assert(!FxParameterPolicy::operationAllowed(bypass,"SET_FX_PARAM_DOWN")); + float next=0.f; + assert(FxParameterPolicy::desired(bypass,"SET_FX_PARAM_TOGGLE",next)); + assert(next==1.f); + assert(FxParameterPolicy::desired(amount,"SET_FX_PARAM_UP",next)); + assert(std::abs(next-0.55f)<0.00001f); + assert(FxParameterPolicy::desired(amount,"SET_FX_PARAM_DOWN",next)); + assert(std::abs(next-0.45f)<0.00001f); + assert(!FxParameterPolicy::desired(amount,"DELETE_FX",next)); + + // A vendor changed its parameter order across versions: the same ID + // must still resolve the same parameter, not the old positional index. + params.clear();params.add(&amount);params.add(&bypass); + int position=-1; + assert(FxParameterPolicy::find(params,"vendor-bypass",&position)==&bypass); + assert(position==1); + assert(FxParameterPolicy::find(params,"vendor-amount",&position)==&amount); + assert(position==0); + + // Duplicate hosted ID is ambiguous: no binding or automatic fallback. + juce::AudioParameterFloat duplicate(juce::ParameterID{"vendor-amount",1}, + "Duplicated ID",{0.f,1.f},0.1f); + params.add(&duplicate); + assert(FxParameterPolicy::find(params,"vendor-amount")==nullptr); + assert(FxParameterPolicy::browse(params).size()==1); + + // Bound before touching any JUCE processor vendor callback. + juce::Array tooMany; + for(int i=0;iremoveProperty("paramId"); + assert(!Registry::decode(damagedParam,decodedParam)); + damagedParam=Registry::encode(param); + // A literal backslash+n is a valid string, NOT a newline. The old test + // accidentally passed "wrong\\nid" and asserted it was unsafe. + damagedParam.getDynamicObject()->setProperty("paramId","wrong\nid"); + assert(!Registry::decode(damagedParam,decodedParam)); + damagedParam=Registry::encode(param); + damagedParam.getDynamicObject()->setProperty("paramId","wrong\rid"); + assert(!Registry::decode(damagedParam,decodedParam)); + damagedParam=Registry::encode(param); + damagedParam.getDynamicObject()->setProperty("paramId","wrong\tid"); + assert(!Registry::decode(damagedParam,decodedParam)); + damagedParam=Registry::encode(param); + damagedParam.getDynamicObject()->setProperty("paramId",juce::String("wrong\\nid")); + assert(Registry::decode(damagedParam,decodedParam)); + Mapping restoredSlot; assert(Registry::decode(Registry::encode(slot),restoredSlot)); assert(restoredSlot.slot==2&&restoredSlot.insertId=="original-instance"); diff --git a/tests/native_mixer_session_store_test.cpp b/tests/native_mixer_session_store_test.cpp index 7ef540944..d791bed18 100644 --- a/tests/native_mixer_session_store_test.cpp +++ b/tests/native_mixer_session_store_test.cpp @@ -1138,6 +1138,28 @@ static void verifyHotkeyDocumentIdentityAndMigration() { hotkeys=damaged.getProperty("hotkeys",{}); hotkeys.getArray()->getReference(3).getDynamicObject()->setProperty("insertId",""); assert(!Codec::decode(juce::JSON::toString(damaged,false),decoded)); + + // H2 .smix preserves the exact vendor parameter ID and class identity, + // even if FX slot order changes. Missing host parameter -> inert mapping. + auto withParam=doc; + withParam.hotkeys.push_back({"p-vendor-1","SESSION",session,"5", + "SET_FX_PARAM_TOGGLE",0x73,6,1,"g5c-724", + "verified-vst3-class-id","vendor-param-203","Stereo Width"}); + const auto saved=Codec::encode(withParam); + assert(Codec::decode(saved,decoded)); + assert(decoded.hotkeys.size()==5); + assert(decoded.hotkeys.back().paramId=="vendor-param-203"); + assert(decoded.hotkeys.back().catalogId=="verified-vst3-class-id"); + assert(Codec::encode(decoded)==saved); + auto unsafe=juce::JSON::parse(saved); + auto entries=unsafe.getProperty("hotkeys",{}).getArray(); + assert(entries&&entries->size()==5); + entries->getReference(4).getDynamicObject()->setProperty("paramId",""); + assert(!Codec::decode(juce::JSON::toString(unsafe,false),decoded)); + unsafe=juce::JSON::parse(saved); + unsafe.getProperty("hotkeys",{}).getArray()->getReference(4) + .getDynamicObject()->setProperty("catalogId",""); + assert(!Codec::decode(juce::JSON::toString(unsafe,false),decoded)); } int main(){ diff --git a/web/approved-native-context-menu.js b/web/approved-native-context-menu.js index cf0ae12a9..1ac8181e4 100644 --- a/web/approved-native-context-menu.js +++ b/web/approved-native-context-menu.js @@ -18,7 +18,16 @@ "#armixOrbit .head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px;font-size:14px;font-weight:550;cursor:grab;touch-action:none}", "#armixOrbit .head:active{cursor:grabbing}", "#armixContext button:disabled{opacity:.35;cursor:default}", - "#armixHotkeyCard[hidden],#armixHotkeyRegister[hidden]{display:none!important}", + "#armixHotkeyCard[hidden],#armixHotkeyRegister[hidden],#armixFxParamBrowse[hidden]{display:none!important}", + "#armixFxParamBrowse{position:fixed;z-index:10026;width:355px;max-width:calc(100vw - 16px);max-height:76vh;box-sizing:border-box;display:flex;flex-direction:column;overflow:hidden;padding:11px;border:1px solid #507584;border-radius:7px;background:#142933;box-shadow:0 15px 35px #000b;color:#e0edf2;font:12px Inter,system-ui,sans-serif}", + "#armixFxParamBrowse input{width:100%;box-sizing:border-box;height:29px;padding:5px 8px;background:#0d202a;color:#e5f4f6;border:1px solid #426a7b;border-radius:4px}", + "#armixFxParamBrowse .armix-param-list{overflow-y:auto;min-height:64px;margin-top:8px}", + "#armixFxParamBrowse .armix-param-row{padding:8px 2px;border-bottom:1px solid #304c5b;display:flex;align-items:center;gap:5px;justify-content:space-between}", + "#armixFxParamBrowse .armix-param-name{min-width:0;flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}", + "#armixFxParamBrowse .armix-param-actions{display:flex;flex-shrink:0;gap:4px}", + "#armixFxParamBrowse button{cursor:pointer;border:1px solid #426c7d;border-radius:4px;background:#225061;color:#e4f5f7;padding:4px 7px;font:11px Inter,system-ui,sans-serif}", + "#armixFxParamBrowse .armix-param-row span small{display:block;color:#88aebc;font-size:10px}", + "#armixHotkeyCard,#armixHotkeyRegister{position:fixed;z-index:10028;box-sizing:border-box;max-width:calc(100vw - 16px);padding:12px;border:1px solid #4b7180;border-radius:7px;background:#132731;color:#dbeef4;box-shadow:0 14px 35px #000c;font:12px Inter,system-ui,sans-serif}", "#armixHotkeyCard{width:286px}#armixHotkeyRegister{width:580px;max-height:76vh;display:flex;flex-direction:column}", ".armix-hk-head{display:flex;justify-content:space-between;align-items:center;gap:10px;cursor:grab;touch-action:none;font-weight:550;font-size:12px;margin-bottom:10px}", @@ -84,6 +93,18 @@ '
'+ '
'; document.body.appendChild(hotkeyRegister); + const fxParamPanel=document.createElement("section"); + fxParamPanel.id="armixFxParamBrowse";fxParamPanel.hidden=true; + fxParamPanel.setAttribute("role","dialog"); + fxParamPanel.setAttribute("aria-label","Assign Parameter Hotkey"); + fxParamPanel.innerHTML= + '
VST3 PARAMETERS
'+ + '
'+ + ''+ + '
Reading VST3 parameters…
'+ + '
'; + document.body.appendChild(fxParamPanel); + let fxParamSelection=null,fxParamStatus=null,fxParamRequest=""; const moreTools=document.querySelector("#moreTools .more-tools-panel"); if(moreTools){ const openButton=document.createElement("button"); @@ -144,6 +165,13 @@ '':'')+ ''; } + }else if(kind==="fx"){ + menu.innerHTML= + ''+ + ''+ + (hooks.orbitTarget(menuTrack,menuSlot)? + '':'')+ + ''; }else if(kind==="hotkey"){ const existing=hotkeyEntries.find(m=>sameHotkeyTarget(m,menuTarget)); menu.innerHTML='