diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml index 7ec8dae79..11c5aeadb 100644 --- a/.github/workflows/p1-windows.yml +++ b/.github/workflows/p1-windows.yml @@ -67,6 +67,7 @@ jobs: 'tests/native_ui_contract_test.mjs' 'tests/native_preset_contract_test.mjs' 'tests/fx_add_contract_test.mjs' + 'tests/fx_drag_reorder_contract_test.mjs' 'tests/live_graph_contract_test.mjs' 'tests/reconciled_gui_engine_contract_test.mjs' 'tests/main_v08_native_integration_test.mjs' @@ -91,7 +92,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 ARMixMixerRoutingTests ARMixChannelRoutingContractTests ARMixChannelSendTests ARMixPreparedMixerBlockTests ARMixLiveRoutingEpochTests ARMixWorkspaceTests ARMixVaultTests ARMixBackupTests ARMixOrbitPhaseTests ARMixOrbitControlTests ARMixOrbitMotionTests ARMixOrbitDistanceTests ARMixFxBypassEnvelopeTests ARMixDearVrPolarPolicyTests ARMixRTTests ARMixPresetTests ARMixDiagnosticTests ARMixClockBridgeTests ARMixVirtualClockSoakTests ARMixCadenceTests ARMixCrackleWindowTests ARMixHealthTests ARMixPolicyTests ARMixPeriodEvidenceTests ARMixLifecycleTests ARMixWasapiProbeTests ARMixDualJuceTests ARMixClockSizingTests ARMixIndependentFormatTests ARMixRecoveryTests ARMixStreamWatchdogTests ARMixBridgeContinuityTests ARMixEndpointPolicyTests ARMixEndpointGuardTests ARMixAsioPolicyTests ARMixAsioBackendTests ARMixAsioRegistryIdentityTests ARMixDirectFenceTests --parallel 2 + run: cmake --build build --config Release --target ARMixConsole ARMixFxOrderTests ARMixMixerRoutingTests ARMixChannelRoutingContractTests ARMixChannelSendTests ARMixPreparedMixerBlockTests ARMixLiveRoutingEpochTests ARMixWorkspaceTests ARMixVaultTests ARMixBackupTests ARMixOrbitPhaseTests ARMixOrbitControlTests ARMixOrbitMotionTests ARMixOrbitDistanceTests ARMixFxBypassEnvelopeTests ARMixDearVrPolarPolicyTests ARMixRTTests ARMixPresetTests ARMixDiagnosticTests ARMixClockBridgeTests ARMixVirtualClockSoakTests ARMixCadenceTests ARMixCrackleWindowTests ARMixHealthTests ARMixPolicyTests ARMixPeriodEvidenceTests ARMixLifecycleTests ARMixWasapiProbeTests ARMixDualJuceTests ARMixClockSizingTests ARMixIndependentFormatTests ARMixRecoveryTests ARMixStreamWatchdogTests ARMixBridgeContinuityTests ARMixEndpointPolicyTests ARMixEndpointGuardTests ARMixAsioPolicyTests ARMixAsioBackendTests ARMixAsioRegistryIdentityTests ARMixDirectFenceTests --parallel 2 - name: Test realtime control primitives run: ctest --test-dir build -C Release --output-on-failure - name: Package verified JUCE GUI for hardware FAT diff --git a/.github/workflows/ui-smoke.yml b/.github/workflows/ui-smoke.yml index 7b988f0fb..3d4fff8e5 100644 --- a/.github/workflows/ui-smoke.yml +++ b/.github/workflows/ui-smoke.yml @@ -55,7 +55,7 @@ jobs: - name: Validate JavaScript syntax run: | node --check web/app.js - node --test tests/gui_workflow_contract_test.mjs tests/ci_workflow_efficiency_test.mjs + node --test tests/gui_workflow_contract_test.mjs tests/ci_workflow_efficiency_test.mjs tests/fx_drag_reorder_contract_test.mjs - name: Validate approved GUI checkpoint and single publisher run: python tests/gui_baseline_lock_test.py - name: Validate smart audio architecture handoff contract diff --git a/AR-MIX-Live-FX-Host-Standalone-v0.3.html b/AR-MIX-Live-FX-Host-Standalone-v0.3.html index 4bb963469..4a7a3dd4b 100644 --- a/AR-MIX-Live-FX-Host-Standalone-v0.3.html +++ b/AR-MIX-Live-FX-Host-Standalone-v0.3.html @@ -1172,6 +1172,78 @@ box-shadow:inset 1px 0 #34434b,inset -1px 0 #34434b; } #app #mixer .fader-zone .fader-travel{z-index:1} +/* DAW insertion markers are painted only while an FX drag is active. */ +#app #mixer .insert-slot.fx-drop-before::before, +#app #mixer .insert-slot.fx-drop-after::after{ + content:"";position:absolute;left:1px;right:1px;height:2px; + background:#9dd6d3;z-index:5;pointer-events:none; +} +#app #mixer .insert-slot{position:relative} +#app #mixer .insert-slot.fx-drop-before::before{top:-1px} +#app #mixer .insert-slot.fx-drop-after::after{bottom:-1px} +.fx-drag-ghost{ + position:fixed;z-index:5000;top:0;left:0;box-sizing:border-box; + min-width:84px;max-width:290px;padding:6px 9px;pointer-events:none; + color:#e7f8f8;background:#172a34;border:1px solid #81c5c8; + border-radius:3px;box-shadow:0 3px 8px #0008;font:11px/1.2 Arial,sans-serif; + white-space:nowrap;overflow:hidden;text-overflow:ellipsis;will-change:transform; +} +.fx-drag-source{opacity:.48} + +/* Native FX Rack uses the same lightweight insertion marker as mixer inserts. */ +.native-node[data-native-move]{position:relative} +.native-node.fx-drop-before::before,.native-node.fx-drop-after::after{ + content:"";position:absolute;left:1px;right:1px;height:2px; + background:#9dd6d3;z-index:5;pointer-events:none; +} +.native-node.fx-drop-before::before{top:-2px} +.native-node.fx-drop-after::after{bottom:-2px} + +/* FX slot selection is always clear without expensive hover blur/compositing. */ +#app #mixer .fx-picker-target{ + outline:1px solid #88cfc5;outline-offset:-1px; + background-color:#1b393e; +} +#app #mixer .native-insert-row.has-orbit .insert, +#app #mixer .native-insert-row.has-orbit .fx-power{ + background-color:#24454b!important;color:#b7eee1; +} +#app #mixer .native-insert-row.has-orbit .insert-name::after{ + content:" · ↻";color:#8dd9c4;font-size:10px; +} +#nativeFxSelector.native-modal{ + background:transparent!important; + pointer-events:none!important;display:block;padding:0; +} +#nativeFxSelector[hidden]{display:none!important} +#nativeFxSelector .native-dialog{ + position:fixed;pointer-events:auto;width:min(390px,calc(100vw - 16px)); + max-height:min(560px,calc(100vh - 16px)); + margin:0;padding:0;box-shadow:0 5px 19px #0008; + border:1px solid #547c85;border-radius:6px; + background:#172a34;overflow:visible; +} +#nativeFxSelector .native-dialog::before{ + content:"";position:absolute;top:-5px;left:var(--fx-arrow-x,22px); + width:8px;height:8px;background:#172a34; + border-left:1px solid #547c85;border-top:1px solid #547c85; + transform:rotate(45deg); +} +#nativeFxSelector .native-dialog.picker-above::before{ + top:auto;bottom:-5px;border:0;border-right:1px solid #547c85; + border-bottom:1px solid #547c85; +} +#nativeFxSelector .native-dialog-header{ + padding:8px 11px;border-bottom:1px solid #34515e; +} +#nativeFxSelector .native-dialog-header h2{font-size:13px;margin:2px 0;font-weight:500} +#nativeFxSelector .native-dialog-body{padding:9px 11px;min-height:0;overflow:auto} +#nativeFxSelector .native-dialog-footer{padding:6px 11px} +#nativeFxSelector .native-category{gap:3px} +#nativeFxSelector .native-category button{padding:4px 6px;font-size:10px} +#nativeFxSelector .native-search{padding:7px 9px;margin-bottom:5px} +#nativeFxContext .fx-context-delete{color:#efb2a8;display:flex;align-items:center;gap:7px} +#nativeFxContext .fx-context-delete svg{width:15px;height:15px;fill:currentColor}
@@ -1646,6 +1718,75 @@ e.preventDefault();e.stopPropagation();openChannelIdentity(i); },true); document.addEventListener('dblclick',e=>{const pan=e.target.closest('[data-pan]');if(pan){e.preventDefault();e.stopPropagation();updatePan(pan.dataset.pan==='master'?'master':+pan.dataset.pan,0)}},true); +// DAW-like insert move in standalone preview: ghost and insertion line during +// pointer travel; one final chain transaction at drop. Native host owns its +// own verified DSP reorder and this preview path never sends native edits. +let fxGesture=null,fxSuppressClick=false; +function clearFxGesture(){ + const d=fxGesture;if(!d)return; + d.marker?.classList.remove('fx-drop-before','fx-drop-after'); + d.source?.classList.remove('fx-drag-source');d.ghost?.remove(); + document.removeEventListener('pointermove',moveFxGesture); + fxGesture=null; +} +document.addEventListener('pointerdown',e=>{ + if(window.__JUCE__?.backend?.emitEvent||e.button!==0||fxGesture)return; + const button=e.target.closest('#mixer .rack .insert:not(.empty)'); + if(!button)return; + const strip=button.closest('[data-strip]'),rack=button.closest('.rack'); + if(!strip||!rack)return; + const channel=Number(strip.dataset.strip),from=Number(button.dataset.insert?.split(':')[1]); + const count=normalChain(channels[channel]).length; + if(!Number.isInteger(from)||from>=count||count<2)return; + const slots=[...rack.querySelectorAll('.insert-slot')]; + fxGesture={pointerId:e.pointerId,source:button.closest('.insert-slot'),channel,from,count, + startX:e.clientX,startY:e.clientY,x:e.clientX,y:e.clientY, + bounds:slots.map(slot=>({slot,rect:slot.getBoundingClientRect()})), + insertion:from,active:false,ghost:null,marker:null}; + document.addEventListener('pointermove',moveFxGesture,{passive:false}); +},true); +const moveFxGesture=e=>{ + const d=fxGesture;if(!d||e.pointerId!==d.pointerId)return; + d.x=e.clientX;d.y=e.clientY; + if(!d.active){ + if(Math.hypot(d.x-d.startX,d.y-d.startY)<7)return; + d.active=true;d.source.classList.add('fx-drag-source'); + d.ghost=document.createElement('div');d.ghost.className='fx-drag-ghost'; + d.ghost.textContent=d.source.querySelector('.insert-name')?.textContent||'FX'; + document.body.appendChild(d.ghost); + } + e.preventDefault(); + d.ghost.style.transform='translate3d('+(d.x+12)+'px,'+(d.y+10)+'px,0)'; + d.marker?.classList.remove('fx-drop-before','fx-drop-after');d.marker=null; + const bounds=d.bounds; + const inside=bounds.length&&d.x>=bounds[0].rect.left-15&&d.x<=bounds[0].rect.right+15 + &&d.y>=bounds[0].rect.top-8&&d.y<=bounds[bounds.length-1].rect.bottom+8; + if(!inside){d.insertion=-1;return} + let insertion=d.count; + for(let i=0;i{ + const d=fxGesture;if(!d||e.pointerId!==d.pointerId)return; + const active=d.active,from=d.from,at=d.insertion,ch=d.channel; + clearFxGesture(); + if(active){fxSuppressClick=true;setTimeout(()=>fxSuppressClick=false,0); + if(at>=0)movePluginTo(ch,from,Math.max(0,Math.min(d.count-1,at>from?at-1:at)));} +},true); +document.addEventListener('pointercancel',e=>{ + if(fxGesture?.pointerId===e.pointerId)clearFxGesture(); +},true); +document.addEventListener('keydown',e=>{ + if(e.key==='Escape'&&fxGesture){clearFxGesture();fxSuppressClick=true;setTimeout(()=>fxSuppressClick=false,0);} +},true); +document.addEventListener('click',e=>{ + if(fxSuppressClick&&!window.__JUCE__?.backend?.emitEvent){fxSuppressClick=false;e.preventDefault();e.stopImmediatePropagation()} +},true); + // Double-click a fader for 0 dB unity gain, without changing workspace. document.addEventListener('dblclick',e=>{const f=e.target.closest('[data-fader]');if(!f)return;e.preventDefault();e.stopPropagation();updateFader(f.dataset.fader,0)},true); // Idle pointer movement has no handler. Acquire geometry only once per drag @@ -1845,7 +1986,17 @@ flash('Master FX updated (GUI preview)');return; } const c=channels[currentChannel];const chain=normalChain(c);if(chain.length>=8){flash('Maximum 8 FX slots in this UI trial');return}const index=clamp(pendingSlot,0,chain.length);shiftFxMetaRight(currentChannel,index,chain.length);chain.splice(index,0,name);pluginEditorIndex=index;setChain(c,chain);closePluginBrowser();flash(name+' added to preview chain');send('chainChanged',{chain},currentChannel)} -function movePlugin(idx,dir){const c=channels[currentChannel],ch=normalChain(c),n=idx+dir;if(n<0||n>=ch.length)return;[ch[idx],ch[n]]=[ch[n],ch[idx]];moveFxMeta(currentChannel,idx,n);pluginEditorIndex=n;setChain(c,ch);send('chainChanged',{chain:ch},currentChannel)} +function movePluginTo(channel,from,to){ + const c=channels[channel],chain=normalChain(c); + if(from<0||to<0||from>=chain.length||to>=chain.length||from===to)return false; + const [fx]=chain.splice(from,1);chain.splice(to,0,fx); + // Preserve each insert's bypass and editor settings, rather than swapping labels. + for(let i=from;i!==to;i+=to>from?1:-1)moveFxMeta(channel,i,i+(to>from?1:-1)); + if(channel===currentChannel)pluginEditorIndex=to; + setChain(c,chain);persistSession(); + send('chainChanged',{chain},channel);return true; +} +function movePlugin(idx,dir){movePluginTo(currentChannel,idx,idx+dir)} function removePlugin(idx){const c=channels[currentChannel],ch=normalChain(c);shiftFxMetaLeft(currentChannel,idx,ch.length);ch.splice(idx,1);pluginEditorIndex=null;setChain(c,ch);send('chainChanged',{chain:ch},currentChannel)} function setFxBypass(ch,slot,disabled){ const chain=normalChain(channels[ch]); diff --git a/CMakeLists.txt b/CMakeLists.txt index d4a775b17..734e93ad7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,6 +146,10 @@ if(BUILD_TESTING) target_compile_features(ARMixVirtualClockSoakTests PRIVATE cxx_std_20) add_test(NAME IndependentClockASRCDriftJitterSoak COMMAND ARMixVirtualClockSoakTests) set_tests_properties(IndependentClockASRCDriftJitterSoak PROPERTIES TIMEOUT 30) + # Live-safe logical FX move: deterministic x64 atomic order + output de-click. + add_executable(ARMixFxOrderTests tests/fx_order_atomic_test.cpp) + target_compile_features(ARMixFxOrderTests PRIVATE cxx_std_20) + add_test(NAME FxAtomicOrderAndOutputRamp COMMAND ARMixFxOrderTests) add_executable(ARMixFxBypassEnvelopeTests tests/fx_bypass_envelope_test.cpp) target_compile_features(ARMixFxBypassEnvelopeTests PRIVATE cxx_std_20) add_test(NAME P0FXBypassSampleAccurateDeClick COMMAND ARMixFxBypassEnvelopeTests) diff --git a/engine/core/FxMoveRamp.h b/engine/core/FxMoveRamp.h new file mode 100644 index 000000000..38e6bfed9 --- /dev/null +++ b/engine/core/FxMoveRamp.h @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once + +namespace armix::dsp +{ +// Output-only de-click around a graph's single atomic order publication. +// 1 = fade old processing 1->0; 2 = fade new processing 0->1. +// A callback completes one stage, so channel outputs share exact envelope. +// Does not duplicate VST processing or allocate on the audio thread. +struct FxMoveRamp final +{ + static constexpr float gain (int stage, int sample, int frames) noexcept + { + if (stage != 1 && stage != 2) return 1.f; + if (frames <= 1) return stage == 1 ? 0.f : 1.f; + const float phase = static_cast(sample) / static_cast(frames-1); + return stage == 1 ? 1.f-phase : phase; + } +}; +} // namespace armix::dsp diff --git a/engine/core/FxOrderPlan.h b/engine/core/FxOrderPlan.h new file mode 100644 index 000000000..33e83da50 --- /dev/null +++ b/engine/core/FxOrderPlan.h @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#pragma once +#include +#include + +namespace armix::dsp +{ +// Logical insert order is encoded as eight 4-bit physical slot identities. +// Callback reads exactly one 64-bit snapshot at an audio block boundary. +// Reorder is control-thread-only; processor ownership is NOT changed. +struct FxOrderPlan final +{ + static constexpr int capacity = 8; + static constexpr std::uint64_t canonical = 0x76543210ULL; + static constexpr int physicalAt (std::uint64_t word, int logical) noexcept + { + return static_cast ((word >> (logical * 4)) & 0xfULL); + } + static constexpr std::uint64_t moved (std::uint64_t previous, + int count, int from, int to) noexcept + { + if (count < 1 || count > capacity || from < 0 || to < 0 + || from >= count || to >= count || from == to) + return previous; + std::array slots {}; + for (int i = 0; i < count; ++i) slots[i] = physicalAt (previous, i); + const auto chosen = slots[from]; + if (from < to) + for (int i = from; i < to; ++i) slots[i] = slots[i + 1]; + else + for (int i = from; i > to; --i) slots[i] = slots[i - 1]; + slots[to] = chosen; + auto next = canonical; + for (int i = 0; i < count; ++i) + { + const auto shift = static_cast (i * 4); + next = (next & ~(0xfULL << shift)) + | (static_cast (slots[i]) << shift); + } + return next; + } +}; +} // namespace armix::dsp diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index 808e06715..06417cba1 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -13,6 +13,8 @@ #include "../engine/device/AsioRegistryIdentityProbe.h" #include "../engine/device/DirectRouteFence.h" #include "../engine/device/WasapiEndpointIdentityGuard.h" +#include "../engine/core/FxOrderPlan.h" +#include "../engine/core/FxMoveRamp.h" #include "../engine/core/RealtimeHealthHistogram.h" #include "../engine/core/CallbackCadenceEvidence.h" #include "../engine/core/FxBypassEnvelope.h" @@ -28,7 +30,7 @@ // The audio callback never scans files, creates plugins, mutates the chain, // enters UI code, locks host mutexes, logs, or changes device settings. // P2.5 recall pre-stages a graph and transitions at callback boundaries. -// Legacy Add/Remove/Move still detach; seamless structural editing is deferred. +// Add/Remove still use a bounded offline lifecycle; MOVE is a lock-free order publication. class LiveAudioEngine final : private juce::AudioIODeviceCallback { public: @@ -45,6 +47,19 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback struct Graph { + // Eight 4-bit physical slot indices in one x64 lock-free word. + // Moving an insert publishes one complete order for the NEXT audio + // block; the processor objects and their binary states never move. + static constexpr std::uint64_t canonicalOrder = armix::dsp::FxOrderPlan::canonical; + std::atomic orderPacked {canonicalOrder}; + static int physicalAt (std::uint64_t order, int logical) noexcept + { + return armix::dsp::FxOrderPlan::physicalAt (order, logical); + } + int physicalAt (int logical) const noexcept + { + return physicalAt (orderPacked.load (std::memory_order_acquire), logical); + } std::array slots {}; std::array, maxFx> bypassFlags {}; // Owned and advanced exclusively by the realtime render callback. @@ -205,6 +220,8 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback detach(); handoff_.resetAfterStop (graphOwned_.get()); stagedOwner_.reset(); + fxMovePhase_.store (0, std::memory_order_release); + fxMovePendingOrder_.store (Graph::canonicalOrder, std::memory_order_relaxed); for (int i = 0; i < graphOwned_->count; ++i) { if (graphOwned_->slots[i].processor) graphOwned_->slots[i].processor->releaseResources(); @@ -489,32 +506,64 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback return true; } + // Non-RT UI readers show the requested order even during the two-buffer + // de-click handoff. DSP still uses the active order until fade-out reaches 0. + std::uint64_t visibleFxOrder() const noexcept + { + return fxMovePhase_.load (std::memory_order_acquire) != 0 + ? fxMovePendingOrder_.load (std::memory_order_acquire) + : graphOwned_->orderPacked.load (std::memory_order_acquire); + } + juce::AudioPluginInstance* pluginAt (int index) noexcept { - return index >= 0 && index < graphOwned_->count ? graphOwned_->slots[index].processor.get() : nullptr; + return index >= 0 && index < graphOwned_->count + ? graphOwned_->slots[Graph::physicalAt (visibleFxOrder(), index)].processor.get() : nullptr; } juce::var chainState() const { juce::Array nodes; + const auto logicalOrder = visibleFxOrder(); for (int i = 0; i < graphOwned_->count; ++i) { auto node = std::make_unique(); node->setProperty ("index", i); - node->setProperty ("name", graphOwned_->slots[i].name); - node->setProperty ("id", graphOwned_->slots[i].catalogId); - node->setProperty ("bypass", graphOwned_->slots[i].bypass); - node->setProperty ("latency", graphOwned_->slots[i].latency); + const auto& slot = graphOwned_->slots[Graph::physicalAt (logicalOrder, i)]; + node->setProperty ("name", slot.name); + node->setProperty ("id", slot.catalogId); + node->setProperty ("bypass", slot.bypass); + node->setProperty ("latency", slot.latency); nodes.add (juce::var (node.release())); } return juce::var (nodes); } + // Called only after the current audio callback has been detached for a + // structural ADD/REMOVE. Normalize physical storage before mutation. + void materializeOrderOnStoppedCallback() + { + auto& graph = *graphOwned_; + const auto order = fxMovePhase_.load (std::memory_order_acquire) != 0 + ? fxMovePendingOrder_.load (std::memory_order_acquire) + : graph.orderPacked.load (std::memory_order_acquire); + fxMovePhase_.store (0, std::memory_order_release); + if (order == Graph::canonicalOrder) { graph.orderPacked.store (order, std::memory_order_release); return; } + std::array rearranged {}; + for (int i = 0; i < graph.count; ++i) + rearranged[i] = std::move (graph.slots[Graph::physicalAt (order, i)]); + graph.slots = std::move (rearranged); + for (int i = 0; i < graph.count; ++i) + graph.bypassFlags[i].store (graph.slots[i].bypass, std::memory_order_relaxed); + graph.orderPacked.store (Graph::canonicalOrder, std::memory_order_release); + } + juce::String addVst3 (const juce::String& filename, int uid, const juce::String& catalogId) { if (dryRoutingLab_.active()) return "Stop DRY ROUTING LAB before editing VST3"; - if (handoff_.busy()) return "FX graph transition in progress; retry shortly"; + if (handoff_.busy() || fxMovePhase_.load (std::memory_order_acquire) != 0) + return "FX graph transition in progress; retry shortly"; if (graphOwned_->count >= maxFx) return "FX Rack is full (maximum 8 VST3 effects)"; auto* device = deviceManager_.getCurrentAudioDevice(); if (device == nullptr) return "Configure a working audio input/output device first"; @@ -546,6 +595,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback return chosen->name + ": " + busError; detach(); + materializeOrderOnStoppedCallback(); Slot node; node.name = chosen->name; node.catalogId = catalogId; @@ -566,7 +616,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback { if (dryRoutingLab_.active()) return "Stop DRY ROUTING LAB before saving native FX state"; if (!isOutputMuted()) return "Mute hardware output before saving a native preset"; - if (handoff_.busy()) return "Finish pending FX graph transition before saving"; + if (handoff_.busy() || fxMovePhase_.load (std::memory_order_acquire) != 0) return "Finish pending FX graph transition before saving"; snapshot.effects.clear(); snapshot.channelDb = juce::Decibels::gainToDecibels ( channelGain_.load (std::memory_order_relaxed), -60.f); @@ -581,14 +631,15 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback { for (int i = 0; i < graphOwned_->count; ++i) { - const auto& slot = graphOwned_->slots[i]; + const int physical = graphOwned_->physicalAt (i); + const auto& slot = graphOwned_->slots[physical]; 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 = graphOwned_->bypassFlags[i].load (std::memory_order_acquire); + state.bypass = graphOwned_->bypassFlags[physical].load (std::memory_order_acquire); slot.processor->getStateInformation (state.binary); if (state.binary.getSize() > armix::storage::NativePresetArchive::maxStateBytes) { @@ -691,9 +742,9 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback for (int i = 0; i < staged->count; ++i) { staged->bypassFlags[i].store (staged->slots[i].bypass, std::memory_order_relaxed); + staged->slots[i].latency = staged->slots[i].processor->getLatencySamples(); staged->bypassEnvelope[i].prepare (staged->slots[i].bypass, rate, staged->slots[i].latency); - staged->slots[i].latency = staged->slots[i].processor->getLatencySamples(); if (!staged->slots[i].bypass) staged->latency += staged->slots[i].latency; } stagedOwner_ = std::move (staged); @@ -707,11 +758,12 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback bool setBypass (int index, bool value) { - if (handoff_.busy()) return false; + if (handoff_.busy() || fxMovePhase_.load (std::memory_order_acquire) != 0) return false; if (index < 0 || index >= graphOwned_->count) return false; // Message-thread metadata and an atomic value consumed by the audio thread. - graphOwned_->slots[index].bypass = value; - graphOwned_->bypassFlags[index].store (value, std::memory_order_release); + const int physical = Graph::physicalAt (visibleFxOrder(), index); + graphOwned_->slots[physical].bypass = value; + graphOwned_->bypassFlags[physical].store (value, std::memory_order_release); // Recompute the advertised steady-state graph latency on the control // thread. The audible transition is managed sample-by-sample by RT. int activeLatency=0; @@ -725,9 +777,10 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback bool removeAt (int index) { if (dryRoutingLab_.active()) return false; - if (handoff_.busy()) return false; + if (handoff_.busy() || fxMovePhase_.load (std::memory_order_acquire) != 0) return false; if (index < 0 || index >= graphOwned_->count) return false; detach(); + materializeOrderOnStoppedCallback(); if (graphOwned_->slots[index].processor) graphOwned_->slots[index].processor->releaseResources(); for (int i = index; i + 1 < graphOwned_->count; ++i) @@ -741,20 +794,26 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback bool moveSlot (int from, int to) { - if (dryRoutingLab_.active()) return false; - if (handoff_.busy()) return false; - if (from < 0 || from >= graphOwned_->count || to < 0 || to >= graphOwned_->count || from == to) + // The processor instances remain at stable PHYSICAL addresses. + // A 64-bit release store publishes the complete logical order. + // The callback takes one acquire snapshot per audio buffer. + if (dryRoutingLab_.active() || independent_.active()) return false; + if (handoff_.busy() || fxMovePhase_.load (std::memory_order_acquire) != 0) return false; - detach(); - auto moved = std::move (graphOwned_->slots[from]); - if (from < to) - for (int i = from; i < to; ++i) graphOwned_->slots[i] = std::move (graphOwned_->slots[i + 1]); - else - for (int i = from; i > to; --i) graphOwned_->slots[i] = std::move (graphOwned_->slots[i - 1]); - graphOwned_->slots[to] = std::move (moved); - for (int i = 0; i < graphOwned_->count; ++i) - graphOwned_->bypassFlags[i].store (graphOwned_->slots[i].bypass, std::memory_order_release); - attach(); + const int count = graphOwned_->count; + if (from < 0 || to < 0 || from >= count || to >= count || from == to) + return false; + const auto previous = graphOwned_->orderPacked.load (std::memory_order_acquire); + const auto next = armix::dsp::FxOrderPlan::moved (previous, count, from, to); + // Plugin objects are not moved. Acknowledge UI intent immediately, + // then run output ramp 1->0, publish at 0, ramp 0->1 in callback. + if (!attached_ && !independent_.active()) + { + graphOwned_->orderPacked.store (next, std::memory_order_release); + return true; // no callback exists to acknowledge a fade + } + fxMovePendingOrder_.store (next, std::memory_order_relaxed); + fxMovePhase_.store (1, std::memory_order_release); return true; } @@ -890,9 +949,10 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback { auto item = std::make_unique(); item->setProperty ("slot", i + 1); - item->setProperty ("name", graphOwned_->slots[i].name); - item->setProperty ("lastUs", static_cast (lastPluginUsBySlot_[i].load())); - item->setProperty ("worstUs", static_cast (worstPluginUsBySlot_[i].load())); + const int physical = graphOwned_->physicalAt (i); + item->setProperty ("name", graphOwned_->slots[physical].name); + item->setProperty ("lastUs", static_cast (lastPluginUsBySlot_[physical].load())); + item->setProperty ("worstUs", static_cast (worstPluginUsBySlot_[physical].load())); pluginTimings.add (juce::var (item.release())); } o->setProperty ("pluginTimings", juce::var (pluginTimings)); @@ -1042,6 +1102,10 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback std::unique_ptr graphOwned_ {std::make_unique()}; std::unique_ptr stagedOwner_; armix::rt::LiveGraphHandoff handoff_; + // 0 idle, 1 fade-out, 2 fade-in. One controller producer, one RT reader. + // No allocation, plugin re-instantiation or extra processing pass. + std::atomic fxMovePhase_ {0}; + std::atomic fxMovePendingOrder_ {Graph::canonicalOrder}; bool attached_ = false; juce::AudioBuffer scratch_; juce::AudioBuffer dryScratch_; @@ -1297,6 +1361,11 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback const float monoL = 0.5f * (matrix.ll + matrix.rl); const float monoR = 0.5f * (matrix.lr + matrix.rr); const float rampStep = samples > 1 ? 1.f / static_cast (samples - 1) : 0.f; + const int fxMovePhase = fxMovePhase_.load (std::memory_order_acquire); + // The same envelope applies to every output channel and sample. + // Old graph reaches zero before the callback publishes new order. + const bool fxFadeOut = fxMovePhase == 1; + const bool fxFadeIn = fxMovePhase == 2; 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) @@ -1334,12 +1403,15 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback juce::MidiBuffer midi; if (!dry) { + // One atomic order snapshot per block: stable physical FX and bypass identity. + const auto order = cycle.graph->orderPacked.load (std::memory_order_acquire); for (int fx = 0; fx < cycle.graph->count; ++fx) { - auto& slot = cycle.graph->slots[fx]; + const int physical = Graph::physicalAt (order, fx); + auto& slot = cycle.graph->slots[physical]; if (!slot.processor) {midi.clear();continue;} - auto& bypass=cycle.graph->bypassEnvelope[fx]; - bypass.request(cycle.graph->bypassFlags[fx].load(std::memory_order_acquire)); + auto& bypass=cycle.graph->bypassEnvelope[physical]; + bypass.request(cycle.graph->bypassFlags[physical].load(std::memory_order_acquire)); // Steady wet/dry requires no copy or extra arithmetic. // A transition temporarily snapshots the exact input to // this insert; a second full FX graph is never created. @@ -1354,8 +1426,8 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback const auto pluginBeginUs = clockMicros(); slot.processor->processBlock (scratchView, midi); const auto pluginUs = clockMicros() - pluginBeginUs; - lastPluginUsBySlot_[fx].store (pluginUs, std::memory_order_relaxed); - publishMax (worstPluginUsBySlot_[fx], pluginUs); + lastPluginUsBySlot_[physical].store (pluginUs, std::memory_order_relaxed); + publishMax (worstPluginUsBySlot_[physical], pluginUs); publishMax (worstPluginUs_, pluginUs); if (static_cast (pluginUs) > periodUs * 0.75) slowPlugins_.fetch_add (1, std::memory_order_relaxed); @@ -1395,8 +1467,11 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback { const float mapped = toneTest ? left[i] : fromL * left[i] + fromR * right[i]; const auto phase = (offset + i) * rampStep; - const float ramp = cycle.fadeOut ? 1.f - phase - : cycle.fadeIn ? phase : 1.f; + const float graphRamp = cycle.fadeOut ? 1.f - phase + : cycle.fadeIn ? phase : 1.f; + const float fxRamp = armix::dsp::FxMoveRamp::gain ( + fxMovePhase, offset + i, samples); + const float ramp = graphRamp * fxRamp; const float value = captureTest ? 0.f : toneTest ? mapped * ramp : (enabled && !muted) ? mapped * gain * ramp : 0.f; @@ -1413,6 +1488,19 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback 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); + if (fxFadeOut) + { + // The last emitted sample of this block is exactly zero. + // Switch order only after all outputs were rendered. Next block + // starts at zero under the NEW order, so there is no step edge. + cycle.graph->orderPacked.store ( + fxMovePendingOrder_.load (std::memory_order_acquire), + std::memory_order_release); + fxMovePhase_.store (2, std::memory_order_release); + } + else if (fxFadeIn) + fxMovePhase_.store (0, std::memory_order_release); + if (cycle.fadeOut) { // Ownership remains with stagedOwner_ until message thread ack. diff --git a/src/Main.cpp b/src/Main.cpp index 091c249dc..1187f2ee7 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1220,7 +1220,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr return emitNotice ("Return to NORMAL before rearranging VST3 effects.", true); const auto* orbitPlugin=orbit_.processor(); orbit_.pauseForGraphEdit(); - editorWindow_.reset(); + // Logical FX reorder preserves the existing vendor editor and stable plugin identity. const bool changed=engine_.moveSlot(slot,slot+static_cast(value)); if(orbitPlugin && orbit_.active()){ for(int i=0;isetMinimised (false); + window_->toFront (true); + window_->grabKeyboardFocus(); + } + } void initialise (const juce::String&) override { const auto folder = armix::storage::PortableWorkspace::browserDataRoot(); diff --git a/tests/fx_drag_reorder_contract_test.mjs b/tests/fx_drag_reorder_contract_test.mjs new file mode 100644 index 000000000..63c6322e4 --- /dev/null +++ b/tests/fx_drag_reorder_contract_test.mjs @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: AGPL-3.0-only +import test from 'node:test'; +import assert from 'node:assert/strict'; +import {readFileSync} from 'node:fs'; +import vm from 'node:vm'; +const app=readFileSync('web/app.js','utf8'); +const bridge=readFileSync('web/bridge.js','utf8'); +const css=readFileSync('web/styles-src/42-mixer-premium.css','utf8'); +const native=readFileSync('src/Main.cpp','utf8'); +function extractFunction(name){ + const start=app.indexOf('function '+name+'('); + assert.ok(start>=0,'Missing '+name); + const begin=app.indexOf('{',start); + let depth=0; + for(let i=begin;i{ + const channels=[{inserts:['Gate','EQ','Reverb','Limiter']}]; + const meta={'0:0':{name:'gate'},'0:1':{name:'eq'},'0:2':{name:'reverb'},'0:3':{name:'limiter'}}; + const bypassed={'0:0':false,'0:1':true,'0:2':false,'0:3':true}; + let saved=0,sends=[]; + const state={channels,fxParams:meta,bypassed,currentChannel:0,pluginEditorIndex:0, + persistSession:()=>{saved++;},send:(...v)=>sends.push(v), + setChain:(ch,items)=>{ch.inserts=[...items];}, + }; + vm.createContext(state); + vm.runInContext('function fxKey(ch,slot){return ch+":"+slot;}\nfunction normalChain(ch){return ch.inserts.filter(Boolean);}\n'.replaceAll('\\n','\n')+ + extractFunction('moveFxMeta')+'\n'+extractFunction('movePluginTo'),state); + assert.equal(state.movePluginTo(0,0,3),true); + assert.deepEqual([...channels[0].inserts],['EQ','Reverb','Limiter','Gate']); + assert.deepEqual([...Array(4)].map((_,i)=>meta['0:'+i].name),['eq','reverb','limiter','gate']); + assert.deepEqual([...Array(4)].map((_,i)=>bypassed['0:'+i]),[true,false,true,false]); + assert.equal(saved,1);assert.equal(sends.length,1); + assert.equal(state.movePluginTo(0,3,0),true); + assert.deepEqual([...channels[0].inserts],['Gate','EQ','Reverb','Limiter']); + assert.equal(state.movePluginTo(0,0,0),false); + assert.equal(sends.length,2,'no redundant graph change when dropped in place'); +}); +test('native has six consistent empty inserts and one DSP reorder per drop',()=>{ + assert.match(bridge,/Array.from\(\{length:6\}/); + assert.match(bridge,/Math.max\(0,6-Math.min\(state.chain.length,6\)\)/); + assert.match(bridge,/fx-drag-ghost/); + assert.match(bridge,/send\("fxMove",\{slot:from,value:to-from\}\)/); + assert.doesNotMatch(bridge,/FX FULL/); + assert.match(css,/width:min\(46px,100%\)/); + assert.match(css,/background:#26343c/); + assert.match(css,/top:0;bottom:0;left:50%/); + assert.match(css,/#nativeFxSelector .native-dialog::before/); + assert.match(css,/#app #mixer .native-insert-row.has-orbit/); + assert.match(bridge,/fx-context-delete/); + assert.match(bridge,/pickerAnchor/); + assert.match(bridge,/data\.activeSlot/); + assert.match(bridge,/openPicker\(el,id,Math.max\(0,slot\)\)/); + assert.match(native,/moreThanOneInstanceAllowed\(\) override \{ return false; \}/); +}); + + +test('premium fold and per-slot popover avoid rectangle border and global backdrop',()=>{ + const b=readFileSync('web/bridge.js','utf8'); + const trough=css.slice(css.indexOf('/* P0 FADER BED RECOVERY'),css.indexOf('/* DAW insertion markers')); + assert.match(trough,/background:#26343c/); + assert.match(trough,/width:min\(46px,100%\)/); + assert.match(trough,/border:0;border-radius:6px/); + assert.doesNotMatch(trough,/filter:blur\(/); + assert.match(b,/#nativeFxSelector\{position:fixed;inset:0;display:block;padding:0/); + assert.match(b,/background:transparent!important;backdrop-filter:none!important/); + assert.match(b,/pickerAnchor\?\.classList\.add\("fx-picker-target"\)/); + assert.match(b,/state\.chain\.length>=8\|\|state\.adding\|\|pickerChannel!==0/); + assert.ok(b.includes('data-context-fx="delete"')); + assert.match(b,/native-node\.has-orbit/); +}); diff --git a/tests/fx_order_atomic_test.cpp b/tests/fx_order_atomic_test.cpp new file mode 100644 index 000000000..73a333bf9 --- /dev/null +++ b/tests/fx_order_atomic_test.cpp @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#include "../engine/core/FxOrderPlan.h" +#include "../engine/core/FxMoveRamp.h" +#include +#include +#include +#include +#include +#include + +// These checks must execute in MSVC Release builds with NDEBUG. +static void check(bool ok) { if (!ok) { std::fputs("FX_ORDER_ASSERT_FAIL\n",stderr); std::abort(); } } +int main() +{ + using Plan = armix::dsp::FxOrderPlan; + static_assert (Plan::canonical == 0x76543210ULL); + static_assert (std::atomic::is_always_lock_free, + "Realtime order publication requires lock-free x64 atomic."); + // Both halves meet at exact digital zero across the graph-order seam. + using Ramp = armix::dsp::FxMoveRamp; + for (int frames : {32, 64, 128, 480, 1024}) + { + check(Ramp::gain(1,0,frames)==1.f); + check(Ramp::gain(1,frames-1,frames)==0.f); + check(Ramp::gain(2,0,frames)==0.f); + check(Ramp::gain(2,frames-1,frames)==1.f); + check(Ramp::gain(0,17,frames)==1.f); + for(int i=1;i=Ramp::gain(2,i-1,frames)); + } + } + // Entire insert identities survive every arbitrary move. No duplicates. + for (int count=2; count<=8; ++count) + for (int from=0; from found {}; + for (int i=0; i=0 && physical order {Plan::canonical}; + std::atomic running {true}; + std::thread reader([&]{ + while (running.load(std::memory_order_acquire)) + { + const auto snapshot=order.load(std::memory_order_acquire); + std::array seen {}; + for(int i=0;i<8;++i) + { + const int p=Plan::physicalAt(snapshot,i); + check(p>=0 && p<8 && !seen[p]); + seen[p]=true; + } + } + }); + for(int i=0;i<20000;i++){ + const auto old=order.load(std::memory_order_acquire); + order.store(Plan::moved(old,8,i%8,(i*7+3)%8),std::memory_order_release); + } + running.store(false,std::memory_order_release); + reader.join(); +} diff --git a/tests/live_graph_contract_test.mjs b/tests/live_graph_contract_test.mjs index ddd6b3984..a01161ad2 100644 --- a/tests/live_graph_contract_test.mjs +++ b/tests/live_graph_contract_test.mjs @@ -28,9 +28,12 @@ test('preset UI reflects callback-acknowledged state not queued state',()=>{ assert.match(m,/arMixNativePresetLoaded/); assert.match(b,/RECALL LIVE/); }); -test('old structural operations remain guarded and declared as unfinished',()=>{ - assert.match(e,/if \(handoff_\.busy\(\)\) return false/); - assert.match(e,/Legacy Add\/Remove\/Move still detach/); +test('ADD/REMOVE remain guarded while MOVE publishes physical-slot order',()=>{ + assert.match(e,/fxMovePhase_\.load/); + assert.match(e,/FxOrderPlan::moved/); + assert.match(e,/Add\/Remove still use a bounded offline lifecycle/); + const move=e.slice(e.indexOf('bool moveSlot'),e.indexOf('juce::String applyDryRoutingLab')); + assert.doesNotMatch(move,/detach\(|attach\(/); }); test('bypass is sample-smoothed on audio callback without control-thread CPU work',()=>{ diff --git a/tests/native_ui_contract_test.mjs b/tests/native_ui_contract_test.mjs index c73a55dfb..edbd3d33f 100644 --- a/tests/native_ui_contract_test.mjs +++ b/tests/native_ui_contract_test.mjs @@ -32,7 +32,8 @@ 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,/graphOwned_->bypassFlags\[index\]\.store/); + assert.match(engine,/graphOwned_->bypassFlags\[physical\]\.store/); + assert.match(engine,/bypassEnvelope\[physical\]/); }); test('GUI pan event reaches actual callback pan matrix',()=>{ assert.match(app,/send\(master\?'masterPan':'pan',c\.pan,master\?-1:idx\)/); diff --git a/web/app.js b/web/app.js index 3bf59497d..3584f3ded 100644 --- a/web/app.js +++ b/web/app.js @@ -424,6 +424,75 @@ document.addEventListener('dblclick',e=>{const el=e.target.closest('[data-editst e.preventDefault();e.stopPropagation();openChannelIdentity(i); },true); document.addEventListener('dblclick',e=>{const pan=e.target.closest('[data-pan]');if(pan){e.preventDefault();e.stopPropagation();updatePan(pan.dataset.pan==='master'?'master':+pan.dataset.pan,0)}},true); +// DAW-like insert move in standalone preview: ghost and insertion line during +// pointer travel; one final chain transaction at drop. Native host owns its +// own verified DSP reorder and this preview path never sends native edits. +let fxGesture=null,fxSuppressClick=false; +function clearFxGesture(){ + const d=fxGesture;if(!d)return; + d.marker?.classList.remove('fx-drop-before','fx-drop-after'); + d.source?.classList.remove('fx-drag-source');d.ghost?.remove(); + document.removeEventListener('pointermove',moveFxGesture); + fxGesture=null; +} +document.addEventListener('pointerdown',e=>{ + if(window.__JUCE__?.backend?.emitEvent||e.button!==0||fxGesture)return; + const button=e.target.closest('#mixer .rack .insert:not(.empty)'); + if(!button)return; + const strip=button.closest('[data-strip]'),rack=button.closest('.rack'); + if(!strip||!rack)return; + const channel=Number(strip.dataset.strip),from=Number(button.dataset.insert?.split(':')[1]); + const count=normalChain(channels[channel]).length; + if(!Number.isInteger(from)||from>=count||count<2)return; + const slots=[...rack.querySelectorAll('.insert-slot')]; + fxGesture={pointerId:e.pointerId,source:button.closest('.insert-slot'),channel,from,count, + startX:e.clientX,startY:e.clientY,x:e.clientX,y:e.clientY, + bounds:slots.map(slot=>({slot,rect:slot.getBoundingClientRect()})), + insertion:from,active:false,ghost:null,marker:null}; + document.addEventListener('pointermove',moveFxGesture,{passive:false}); +},true); +const moveFxGesture=e=>{ + const d=fxGesture;if(!d||e.pointerId!==d.pointerId)return; + d.x=e.clientX;d.y=e.clientY; + if(!d.active){ + if(Math.hypot(d.x-d.startX,d.y-d.startY)<7)return; + d.active=true;d.source.classList.add('fx-drag-source'); + d.ghost=document.createElement('div');d.ghost.className='fx-drag-ghost'; + d.ghost.textContent=d.source.querySelector('.insert-name')?.textContent||'FX'; + document.body.appendChild(d.ghost); + } + e.preventDefault(); + d.ghost.style.transform='translate3d('+(d.x+12)+'px,'+(d.y+10)+'px,0)'; + d.marker?.classList.remove('fx-drop-before','fx-drop-after');d.marker=null; + const bounds=d.bounds; + const inside=bounds.length&&d.x>=bounds[0].rect.left-15&&d.x<=bounds[0].rect.right+15 + &&d.y>=bounds[0].rect.top-8&&d.y<=bounds[bounds.length-1].rect.bottom+8; + if(!inside){d.insertion=-1;return} + let insertion=d.count; + for(let i=0;i{ + const d=fxGesture;if(!d||e.pointerId!==d.pointerId)return; + const active=d.active,from=d.from,at=d.insertion,ch=d.channel; + clearFxGesture(); + if(active){fxSuppressClick=true;setTimeout(()=>fxSuppressClick=false,0); + if(at>=0)movePluginTo(ch,from,Math.max(0,Math.min(d.count-1,at>from?at-1:at)));} +},true); +document.addEventListener('pointercancel',e=>{ + if(fxGesture?.pointerId===e.pointerId)clearFxGesture(); +},true); +document.addEventListener('keydown',e=>{ + if(e.key==='Escape'&&fxGesture){clearFxGesture();fxSuppressClick=true;setTimeout(()=>fxSuppressClick=false,0);} +},true); +document.addEventListener('click',e=>{ + if(fxSuppressClick&&!window.__JUCE__?.backend?.emitEvent){fxSuppressClick=false;e.preventDefault();e.stopImmediatePropagation()} +},true); + // Double-click a fader for 0 dB unity gain, without changing workspace. document.addEventListener('dblclick',e=>{const f=e.target.closest('[data-fader]');if(!f)return;e.preventDefault();e.stopPropagation();updateFader(f.dataset.fader,0)},true); // Idle pointer movement has no handler. Acquire geometry only once per drag @@ -623,7 +692,17 @@ function insertPlugin(name){ flash('Master FX updated (GUI preview)');return; } const c=channels[currentChannel];const chain=normalChain(c);if(chain.length>=8){flash('Maximum 8 FX slots in this UI trial');return}const index=clamp(pendingSlot,0,chain.length);shiftFxMetaRight(currentChannel,index,chain.length);chain.splice(index,0,name);pluginEditorIndex=index;setChain(c,chain);closePluginBrowser();flash(name+' added to preview chain');send('chainChanged',{chain},currentChannel)} -function movePlugin(idx,dir){const c=channels[currentChannel],ch=normalChain(c),n=idx+dir;if(n<0||n>=ch.length)return;[ch[idx],ch[n]]=[ch[n],ch[idx]];moveFxMeta(currentChannel,idx,n);pluginEditorIndex=n;setChain(c,ch);send('chainChanged',{chain:ch},currentChannel)} +function movePluginTo(channel,from,to){ + const c=channels[channel],chain=normalChain(c); + if(from<0||to<0||from>=chain.length||to>=chain.length||from===to)return false; + const [fx]=chain.splice(from,1);chain.splice(to,0,fx); + // Preserve each insert's bypass and editor settings, rather than swapping labels. + for(let i=from;i!==to;i+=to>from?1:-1)moveFxMeta(channel,i,i+(to>from?1:-1)); + if(channel===currentChannel)pluginEditorIndex=to; + setChain(c,chain);persistSession(); + send('chainChanged',{chain},channel);return true; +} +function movePlugin(idx,dir){movePluginTo(currentChannel,idx,idx+dir)} function removePlugin(idx){const c=channels[currentChannel],ch=normalChain(c);shiftFxMetaLeft(currentChannel,idx,ch.length);ch.splice(idx,1);pluginEditorIndex=null;setChain(c,ch);send('chainChanged',{chain:ch},currentChannel)} function setFxBypass(ch,slot,disabled){ const chain=normalChain(channels[ch]); diff --git a/web/bridge.js b/web/bridge.js index bc5571176..b66f828aa 100644 --- a/web/bridge.js +++ b/web/bridge.js @@ -27,7 +27,9 @@ }); const send = (action, more = {}) => backend.emitEvent("arMixAction", {action, ...more}); - const state = {catalog: [], chain: [], scanning: false, message: "Connecting to native host...", + let fxNativeGesture=null,fxNativeBlockClick=false; + let pickerAnchor=null,pickerChannel=0,pickerSlot=0; + const state = {orbitActiveSlot:-1,catalog: [], chain: [], scanning: false, message: "Connecting to native host...", device: {}, presets: [], addRequestId:0, addError:"", pendingPlugin:"", filter: "", selectedCategory: "All", monitor: false, error: "", progress: {active:false,phase:"done",done:0,total:0,found:0,current:""}, adding:false}; const orbit = {slot:-1, plugin:"", parameters:[], active:false, activeSlot:-1, activeParameter:-1, periodSeconds:20, reverse:false, preferredParameter:-1, selection:-1, revision:null,nearSetpoint:20,farSetpoint:70,distanceUnit:"%",distanceMin:0,distanceMax:100,selectedShape:0,appliedPeriod:20,appliedReverse:false,initialized:false,shape:0,distanceSelection:-1,elevationSelection:-1,distanceIndex:-1,elevationIndex:-1,preferredDistance:-1,preferredElevation:-1,motionPath:[],visualPhase:0,visualTime:0}; @@ -74,6 +76,8 @@ .native-node .node-text{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px} .native-node .node-text small{display:block;color:#7196a8;font-size:10px;margin-top:3px} .native-node.is-bypassed{opacity:.55} + .native-node.has-orbit{background:#19343b;border-color:#44757b} + .native-node.has-orbit .node-text::after{content:" · ORBIT";color:#a1e7da;font-size:9px;letter-spacing:.05em} .native-node button{padding:5px 7px;font-size:10px;min-width:28px} .native-search{box-sizing:border-box;display:block;width:100%;font:12px inherit;outline:0;color:#dcecf2; border:1px solid #4b6b79;background:#0b1923;border-radius:5px;padding:10px;margin-bottom:9px} @@ -147,6 +151,33 @@ #nativeFxContext .native-context-divider{height:1px;background:#334a58;margin:3px 4px} `; css.textContent += "\n #nativeOrbit .native-dialog{width:374px;max-width:calc(100vw - 16px)}\n #nativeOrbit .orbit-motion-view{background:#0b1e2a;border:1px solid #2f5161;\n border-radius:6px;margin:0 0 10px;padding:7px;display:flex;align-items:center;gap:10px}\n #nativeOrbit .orbit-map{width:132px;height:132px;flex:none}\n #nativeOrbit .orbit-mode-help{font-size:11px;color:#9abfce;line-height:1.55}\n #nativeOrbit .orbit-mode-help strong{display:block;color:#d8f0f7;font-weight:500;margin-bottom:4px}\n #nativeOrbit .orbit-field-label{font-size:11px}\n #nativeOrbit .orbit-extra-row{display:grid;grid-template-columns:1fr 1fr;gap:8px}\n #nativeOrbit .orbit-help-note{font-size:10px;color:#87a8b9;line-height:1.4;margin:0 0 8px}\n #nativeOrbit .material-icon{width:18px;height:18px;fill:currentColor;vertical-align:middle;flex:none}\n #nativeOrbit .orbit-actions .native-btn{display:inline-flex;justify-content:center;align-items:center;gap:5px}\n #nativeOrbit .orbit-map path{vector-effect:non-scaling-stroke}\n"; + // Slot-attached FX catalogue — independent of large screen-dimming dialogs. + css.textContent += ` + #nativeFxSelector{position:fixed;inset:0;display:block;padding:0; + background:transparent!important;backdrop-filter:none!important; + pointer-events:none;z-index:970} + #nativeFxSelector[hidden]{display:none} + #nativeFxSelector .native-dialog{position:fixed;box-sizing:border-box; + width:min(386px,calc(100vw - 16px));max-height:min(530px,calc(100vh - 20px)); + pointer-events:auto;overflow:hidden;margin:0;border:1px solid #4b6b78; + background:#1b2c36;border-radius:7px; + box-shadow:0 7px 18px #0009,inset 0 1px #ffffff14} + #nativeFxSelector .native-dialog::before{content:"";position:absolute; + top:-5px;left:var(--fx-arrow-x,20px);width:8px;height:8px; + background:#1b2c36;transform:rotate(45deg); + border-top:1px solid #4b6b78;border-left:1px solid #4b6b78} + #nativeFxSelector .native-dialog.picker-above::before{ + top:auto;bottom:-5px;border:0;border-right:1px solid #4b6b78; + border-bottom:1px solid #4b6b78} + #nativeFxSelector .native-dialog-header{padding:8px 11px} + #nativeFxSelector .native-dialog-header h2{font-size:13px;font-weight:500;margin:1px 0} + #nativeFxSelector .native-dialog-body{min-height:0;padding:8px 11px} + #nativeFxSelector .native-dialog-footer{padding:6px 11px} + #nativeFxSelector .native-result{padding:5px 7px;margin:3px 0} + #nativeFxSelector .native-result button{padding:5px 7px} + #nativeFxSelector .native-category button{padding:4px 6px} + .native-engine .fx-picker-target{outline:1px solid #7ccac3;outline-offset:-1px} + `; document.head.appendChild(css); document.getElementById("engineBadge").textContent="NATIVE CH1 · ORBIT"; const workspace = document.querySelector("#rackWorkspace"); @@ -167,6 +198,22 @@ } function renderRack(){ if(!workspace || currentTab()!=="FX RACK") return; + const selected=typeof currentChannel==="number"?currentChannel:0; + const isMaster=typeof masterSelected!=="undefined"&&masterSelected; + if(isMaster||selected!==0){ + const label=isMaster?"MASTER":(typeof channels!=="undefined"&&channels[selected]?.name)||("Channel "+(selected+1)); + workspace.innerHTML=`
+ ${cardHeader("FX Rack · "+label,"Same DAW insert layout across all mixer channels")} +
+

${escapeHtml(label)} · FX CHAIN

+
This bus is not yet connected to independent native VST3 processing. Its inserts are unavailable for audio until channel routing is implemented.
+
+ ${Array.from({length:6},(_,i)=>``).join("")} +
+
+
`; + return; + } workspace.innerHTML=`
${cardHeader("Live FX Chain · Vocal Input","Arrange your real VST3 effects here. Use + ADD FX to choose from your installed catalog.")}
@@ -179,7 +226,7 @@

MIC INPUT → PROCESSING → MAIN OUTPUT

INPUT 1 / MICROPHONE
- ${state.chain.map((p,i)=>`
+ ${state.chain.map((p,i)=>`
${String(i+1).padStart(2,"0")} ${escapeHtml(p.name)}${p.latency||0} samples processing latency @@ -209,7 +256,10 @@ return overlay; } function showDialog(id){const d=document.getElementById(id);if(d){d.hidden=false;d.querySelector("input")?.focus()}} - function hideDialog(id){const d=document.getElementById(id);if(d)d.hidden=true} + function hideDialog(id){ + const d=document.getElementById(id);if(d)d.hidden=true; + if(id==="nativeFxSelector")clearPickerTarget(); + } let orbitAnchor=null; function hideOrbit(){ const d=document.getElementById("nativeOrbit"); @@ -249,7 +299,8 @@ const paths={ close:"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z", play:"M8 5v14l11-7z", - stop:"M6 6h12v12H6z" + stop:"M6 6h12v12H6z", + bin:"M6 7h12v2H6V7zm2 3h2v9H8v-9zm6 0h2v9h-2v-9zM9 4h6l1 2H8l1-2zm-2 6h10l-.7 11H7.7L7 10z" }; return ''; }; @@ -447,7 +498,7 @@ ${escapeHtml(p.vendor||"Unknown vendor")} · ${escapeHtml(p.category||"Audio effect")} VST3
`).join("") + ${state.chain.length>=8||state.adding||pickerChannel!==0?"disabled":""} title="${pickerChannel===0?"Insert native VST3":"Channel routing not yet connected"}">+ ADD
`).join("") :'
No matching installed VST3 effects. Open Plugin Manager to scan your folders.
'; } function filterPlugins(){ @@ -458,7 +509,7 @@ const dlg=document.getElementById("nativeFxSelector"); if(!dlg)return; dlg.querySelector(".native-dialog-body").innerHTML=` -
SELECT EFFECT → INSERT INTO LIVE VOCAL FX RACK
+
INSERT → ${pickerChannel===-1?"MASTER":"CH "+(pickerChannel+1)} · SLOT ${pickerSlot+1}${pickerChannel===0?" · LIVE VST3":" · ROUTING NOT CONNECTED"}
${fxCategories.map(c=>``).join("")}
@@ -473,7 +524,42 @@
${pluginRows(filterPlugins())}
`; dlg.querySelector(".native-dialog-footer").innerHTML=`${state.catalog.length} available plugins · OPEN PLUGIN MANAGER for scanning and import`; } - function openPicker(){renderPicker();showDialog("nativeFxSelector")} + function clearPickerTarget(){ + pickerAnchor?.classList.remove("fx-picker-target"); + pickerAnchor=null; + } + function positionPicker(){ + const overlay=document.getElementById("nativeFxSelector"),dlg=overlay?.querySelector(".native-dialog"); + if(!overlay||overlay.hidden||!dlg)return; + if(!pickerAnchor?.isConnected){hideDialog("nativeFxSelector");return;} + const rect=pickerAnchor.getBoundingClientRect(),w=dlg.offsetWidth,h=dlg.offsetHeight; + const left=Math.max(8,Math.min(window.innerWidth-w-8,rect.left+rect.width/2-34)); + const above=(window.innerHeight-rect.bottomwindow.innerHeight-rect.bottom); + const top=above?Math.max(8,rect.top-h-9):Math.max(8,Math.min(window.innerHeight-h-8,rect.bottom+9)); + dlg.style.left=left+"px";dlg.style.top=top+"px"; + dlg.style.setProperty("--fx-arrow-x",Math.max(12,Math.min(w-20,rect.left+rect.width/2-left))+"px"); + dlg.classList.toggle("picker-above",above); + } + function openPicker(anchor,channel=0,slot=state.chain.length){ + clearPickerTarget(); + const row=anchor?.closest(".insert-slot,.master-fx-slot,.native-node"); + pickerAnchor=(row||anchor)?.isConnected?(row||anchor):document.querySelector('.nav button[data-view="FX RACK"]'); + pickerChannel=Number(channel);pickerSlot=Math.max(0,Number(slot)||0); + pickerAnchor?.classList.add("fx-picker-target"); + renderPicker();showDialog("nativeFxSelector");positionPicker(); + } + window.addEventListener("resize",positionPicker); + document.addEventListener("pointerdown",e=>{ + const picker=document.getElementById("nativeFxSelector"); + if(picker&&!picker.hidden&&!e.target.closest("#nativeFxSelector .native-dialog") + &&!e.target.closest("[data-plugin-picker],[data-native-unrouted]"))hideDialog("nativeFxSelector"); + },true); + document.addEventListener("keydown",e=>{ + if(e.key==="Escape"){ + const picker=document.getElementById("nativeFxSelector"); + if(picker&&!picker.hidden){e.preventDefault();hideDialog("nativeFxSelector");} + } + },true); function scanProgressHtml(){ const p=state.progress||{}; const count=p.done||0,total=p.total||0,found=p.found||0; @@ -579,14 +665,17 @@ tracks.forEach((track,i)=>{ // The v0.8 Master uses .master-fx-rack, not .rack. Handle it first. if(track.classList.contains("master-strip")){ - // FX/PAN are previews, but MASTER L/R metering is REAL native output. - // Never tag this entire strip data-preview: that hides its live LEDs. track.removeAttribute("data-preview"); track.dataset.fxPreview="1"; track.title="Master FX and master PAN are visual previews; Master fader and meters are native"; - track.querySelectorAll("[data-master-insert],[data-master-power]").forEach(x=>{ - x.disabled=true;x.title="Preview only — Master FX DSP not yet implemented"; - }); + const masterRack=track.querySelector(".master-fx-rack"); + if(masterRack&&masterRack.dataset.nativeSig!=="empty-nonlive"){ + masterRack.dataset.nativeSig="empty-nonlive"; + masterRack.innerHTML=Array.from({length:6},()=>`
+
`).join(""); + } const pan=track.querySelector('[data-pan="master"]'); if(pan){pan.removeAttribute("tabindex");pan.style.pointerEvents="none";pan.title="Master PAN DSP not yet implemented";} const marker=track.querySelector(".master-info-kicker span"); @@ -596,6 +685,13 @@ const rack=track.querySelector(".rack"); if(!rack)return; if(i!==0){ + if(rack.dataset.nativeSig!=="empty-nonlive"){ + rack.dataset.nativeSig="empty-nonlive"; + rack.innerHTML=Array.from({length:6},()=>`
+
`).join(""); + } rack.dataset.preview="1"; track.dataset.preview="1"; track.querySelectorAll(".meter-peak").forEach(x=>x.style.display="none"); @@ -605,8 +701,8 @@ const signature=state.chain.map(p=>p.id+"|"+p.bypass).join(","); if(rack.dataset.nativeSig===signature)return; rack.dataset.nativeSig=signature; - rack.innerHTML=state.chain.slice(0,5).map((p,i)=> - `
+ rack.innerHTML=state.chain.slice(0,6).map((p,i)=> + `
@@ -614,13 +710,19 @@ data-native-fx="bypass" data-slot="${i}" aria-pressed="${!p.bypass}" title="${p.bypass?"Enable":"Bypass"} ${escapeHtml(p.name)}">⏻
`).join("")+ - `
`; + Array.from({length:Math.max(0,6-Math.min(state.chain.length,6))},()=> + `
`).join(""); }); } + // Orbit lighting changes a class on existing rows. Never replace the row + // holding the native popup's anchor, nor reset its animation. + function updateOrbitRackMarker(){ + document.querySelectorAll('.native-insert-row[data-native-move],.native-node[data-native-move]') + .forEach(row=>row.classList.toggle("has-orbit", + state.orbitActiveSlot>=0&&Number(row.dataset.nativeMove)===state.orbitActiveSlot)); + } let renderPending = false; function syncView(){ if(renderPending) return; @@ -660,7 +762,9 @@ fxContext.innerHTML=''+ (dearVrOrbitEligible(p.name)?'':'')+ ''+ - ''; + ''+ + ''+ + ''; fxContext.hidden=false; fxContext.style.left=Math.max(4,Math.min(x,window.innerWidth-fxContext.offsetWidth-4))+'px'; fxContext.style.top=Math.max(4,Math.min(y,window.innerHeight-fxContext.offsetHeight-4))+'px'; @@ -694,6 +798,7 @@ if(action==="orbit"&&dearVrOrbitEligible(state.chain[slot].name))openOrbit(slot,anchor); else if(action==="editor")send("fxEditor",{slot}); else if(action==="bypass")send("fxBypass",{slot,value:!state.chain[slot].bypass}); + else if(action==="delete")send("fxRemove",{slot}); },true); document.addEventListener("pointerdown",e=>{ const popup=document.getElementById("nativeOrbit"); @@ -722,10 +827,16 @@ },true); // Capture native controls before the legacy v0.3 demo handlers. document.addEventListener("click", function(e){ - const el=e.target.closest("[data-native-action],[data-native-add],[data-native-fx],[data-fxpower],[data-master-insert],[data-master-power],[data-native-category],[data-go-native-rack],[data-insert],[data-plugin-picker],[data-plugin-manager],[data-my-sounds],[data-backup-studio],[data-preset-mute],[data-preset-save],[data-preset-load],[data-close-modal],[data-orbit-start],[data-orbit-stop]"); + if(fxNativeBlockClick){fxNativeBlockClick=false;e.preventDefault();e.stopImmediatePropagation();return;} + const el=e.target.closest("[data-native-unrouted],[data-native-action],[data-native-add],[data-native-fx],[data-fxpower],[data-master-insert],[data-master-power],[data-native-category],[data-go-native-rack],[data-insert],[data-plugin-picker],[data-plugin-manager],[data-my-sounds],[data-backup-studio],[data-preset-mute],[data-preset-save],[data-preset-load],[data-close-modal],[data-orbit-start],[data-orbit-stop]"); if(!el)return; e.preventDefault();e.stopImmediatePropagation(); + if(el.hasAttribute("data-native-unrouted")){ + const id=Number(el.dataset.nativeUnrouted),rack=el.closest(".rack,.master-fx-rack"); + const slot=rack?[...rack.children].indexOf(el.closest(".insert-slot,.master-fx-slot")):0; + openPicker(el,id,Math.max(0,slot));return; + } if(el.dataset.closeModal){if(el.dataset.closeModal==="nativeOrbit")hideOrbit();else hideDialog(el.dataset.closeModal);return;} if(el.hasAttribute("data-orbit-start")){ const raw=document.getElementById("nativeOrbitParameter")?.value; @@ -790,7 +901,9 @@ renderManager();showDialog("nativePluginManager");return; } if(el.hasAttribute("data-plugin-picker")){ - openPicker();return; + const rack=el.closest(".rack"); + const slot=rack?[...rack.children].indexOf(el.closest(".insert-slot")):state.chain.length; + openPicker(el,0,slot<0?state.chain.length:slot);return; } if(el.hasAttribute("data-insert")){ const article=el.closest(".strip"); @@ -801,7 +914,8 @@ setTimeout(()=>toast.classList.remove("show"),2200);} return; } - openPicker();return; + const slot=Number(el.dataset.insert?.split(":")[1]||state.chain.length); + openPicker(el,idx,slot);return; } if(el.hasAttribute("data-go-native-rack")){ document.querySelector('.nav button[data-view="FX RACK"]')?.click();return; @@ -814,6 +928,10 @@ } if(el.dataset.nativeAdd){ if(state.adding)return; + if(pickerChannel!==0){ + toStatus("Native VST3 routing is not connected on "+(pickerChannel===-1?"MASTER":"CH "+(pickerChannel+1))+". No effect was loaded."); + return; + } const id=el.dataset.nativeAdd; const chosen=state.catalog.find(p=>p.id===id); state.adding=true; @@ -843,6 +961,76 @@ if(fx==="bypass")send("fxBypass",{slot,value:!state.chain[slot]?.bypass}); if(fx==="up"||fx==="down")send("fxMove",{slot,value:fx==="up"?-1:1}); },true); + // True DAW FX insert gesture. Geometries are captured ONCE at pointerdown; + // pointermove only moves a ghost and a 2px insertion marker. Exactly one + // native fxMove request is emitted at pointerup (never while dragging). + const removeNativeDrag=()=>{ + const d=fxNativeGesture;if(!d)return; + d.marker?.classList.remove("fx-drop-before","fx-drop-after"); + d.row?.classList.remove("fx-drag-source"); + d.ghost?.remove();fxNativeGesture=null; + document.removeEventListener("pointermove",moveNativeFxGesture); + }; + document.addEventListener("pointerdown",e=>{ + if(e.button!==0||fxNativeGesture||state.chain.length<2)return; + const row=e.target.closest(".native-insert-row[data-native-move],.native-node[data-native-move]"); + if(!row||!row.isConnected)return; + if(row.classList.contains("native-node")){ + if(!e.target.closest(".node-text,.node-index"))return; + }else if(!e.target.closest(".insert:not(.empty)"))return; + const from=Number(row.dataset.nativeMove),siblings=[...row.parentElement.children] + .filter(n=>n.hasAttribute("data-native-move")); + if(!Number.isInteger(from)||from<0||from>=state.chain.length||siblings.length<2)return; + fxNativeGesture={pointerId:e.pointerId,row,from,count:siblings.length, + startX:e.clientX,startY:e.clientY,x:e.clientX,y:e.clientY, + bounds:siblings.map(el=>({el,rect:el.getBoundingClientRect()})), + insertion:from,marker:null,ghost:null,active:false}; + document.addEventListener("pointermove",moveNativeFxGesture,{passive:false}); + },true); + const moveNativeFxGesture=e=>{ + const d=fxNativeGesture;if(!d||e.pointerId!==d.pointerId)return; + d.x=e.clientX;d.y=e.clientY; + if(!d.active){ + if(Math.hypot(d.x-d.startX,d.y-d.startY)<7)return; + d.active=true;d.row.classList.add("fx-drag-source"); + d.ghost=document.createElement("div");d.ghost.className="fx-drag-ghost"; + d.ghost.textContent=state.chain[d.from]?.name||"VST3"; + document.body.appendChild(d.ghost); + } + e.preventDefault(); + d.ghost.style.transform="translate3d("+(d.x+12)+"px,"+(d.y+10)+"px,0)"; + d.marker?.classList.remove("fx-drop-before","fx-drop-after");d.marker=null; + const bs=d.bounds,first=bs[0].rect,last=bs[bs.length-1].rect; + if(d.xfirst.right+20||d.ylast.bottom+12){ + d.insertion=-1;return; + } + let at=d.count; + for(let i=0;i{ + const d=fxNativeGesture;if(!d||d.pointerId!==e.pointerId)return; + const active=d.active,at=d.insertion,from=d.from,count=d.count; + removeNativeDrag(); + if(active){ + fxNativeBlockClick=true;setTimeout(()=>fxNativeBlockClick=false,0); + if(at>=0){ + const to=Math.max(0,Math.min(count-1,at>from?at-1:at)); + if(to!==from)send("fxMove",{slot:from,value:to-from}); + } + } + },true); + document.addEventListener("pointercancel",e=>{ + if(fxNativeGesture?.pointerId===e.pointerId)removeNativeDrag(); + },true); + document.addEventListener("keydown",e=>{ + if(e.key==="Escape"&&fxNativeGesture)removeNativeDrag(); + },true); document.addEventListener("input", function(e){ if(e.target.id!=="nativeVstSearch")return; state.filter=e.target.value; @@ -909,7 +1097,13 @@ renderOrbit(); },true); backend.addEventListener("arMixOrbitState",data=>{ - if(!data||Number(data.slot)!==orbit.slot)return; + if(!data)return; + const activeSlot=data.active&&Number.isInteger(Number(data.activeSlot))?Number(data.activeSlot):-1; + if(state.orbitActiveSlot!==activeSlot){ + state.orbitActiveSlot=activeSlot; + updateOrbitRackMarker(); + } + if(Number(data.slot)!==orbit.slot)return; const wasInitialized=orbit.initialized; const preview=data.previewShape!==-1; const draft={nearSetpoint:orbit.nearSetpoint,farSetpoint:orbit.farSetpoint, @@ -932,8 +1126,7 @@ orbit.visualTime=performance.now(); } renderOrbit(); - if(currentTab()==="FX RACK")renderRack(); - patchMixer(); + updateOrbitRackMarker(); }); backend.addEventListener("arMixPresets",items=>{ state.presets=Array.isArray(items)?items:[]; diff --git a/web/styles-src/42-mixer-premium.css b/web/styles-src/42-mixer-premium.css index cda857c5f..2ec71fb65 100644 --- a/web/styles-src/42-mixer-premium.css +++ b/web/styles-src/42-mixer-premium.css @@ -212,3 +212,75 @@ html:not([data-mixperf="baseline"]):not([data-mixperf="layers-off"]):not([data-m box-shadow:inset 1px 0 #34434b,inset -1px 0 #34434b; } #app #mixer .fader-zone .fader-travel{z-index:1} +/* DAW insertion markers are painted only while an FX drag is active. */ +#app #mixer .insert-slot.fx-drop-before::before, +#app #mixer .insert-slot.fx-drop-after::after{ + content:"";position:absolute;left:1px;right:1px;height:2px; + background:#9dd6d3;z-index:5;pointer-events:none; +} +#app #mixer .insert-slot{position:relative} +#app #mixer .insert-slot.fx-drop-before::before{top:-1px} +#app #mixer .insert-slot.fx-drop-after::after{bottom:-1px} +.fx-drag-ghost{ + position:fixed;z-index:5000;top:0;left:0;box-sizing:border-box; + min-width:84px;max-width:290px;padding:6px 9px;pointer-events:none; + color:#e7f8f8;background:#172a34;border:1px solid #81c5c8; + border-radius:3px;box-shadow:0 3px 8px #0008;font:11px/1.2 Arial,sans-serif; + white-space:nowrap;overflow:hidden;text-overflow:ellipsis;will-change:transform; +} +.fx-drag-source{opacity:.48} + +/* Native FX Rack uses the same lightweight insertion marker as mixer inserts. */ +.native-node[data-native-move]{position:relative} +.native-node.fx-drop-before::before,.native-node.fx-drop-after::after{ + content:"";position:absolute;left:1px;right:1px;height:2px; + background:#9dd6d3;z-index:5;pointer-events:none; +} +.native-node.fx-drop-before::before{top:-2px} +.native-node.fx-drop-after::after{bottom:-2px} + +/* FX slot selection is always clear without expensive hover blur/compositing. */ +#app #mixer .fx-picker-target{ + outline:1px solid #88cfc5;outline-offset:-1px; + background-color:#1b393e; +} +#app #mixer .native-insert-row.has-orbit .insert, +#app #mixer .native-insert-row.has-orbit .fx-power{ + background-color:#24454b!important;color:#b7eee1; +} +#app #mixer .native-insert-row.has-orbit .insert-name::after{ + content:" · ↻";color:#8dd9c4;font-size:10px; +} +#nativeFxSelector.native-modal{ + background:transparent!important; + pointer-events:none!important;display:block;padding:0; +} +#nativeFxSelector[hidden]{display:none!important} +#nativeFxSelector .native-dialog{ + position:fixed;pointer-events:auto;width:min(390px,calc(100vw - 16px)); + max-height:min(560px,calc(100vh - 16px)); + margin:0;padding:0;box-shadow:0 5px 19px #0008; + border:1px solid #547c85;border-radius:6px; + background:#172a34;overflow:visible; +} +#nativeFxSelector .native-dialog::before{ + content:"";position:absolute;top:-5px;left:var(--fx-arrow-x,22px); + width:8px;height:8px;background:#172a34; + border-left:1px solid #547c85;border-top:1px solid #547c85; + transform:rotate(45deg); +} +#nativeFxSelector .native-dialog.picker-above::before{ + top:auto;bottom:-5px;border:0;border-right:1px solid #547c85; + border-bottom:1px solid #547c85; +} +#nativeFxSelector .native-dialog-header{ + padding:8px 11px;border-bottom:1px solid #34515e; +} +#nativeFxSelector .native-dialog-header h2{font-size:13px;margin:2px 0;font-weight:500} +#nativeFxSelector .native-dialog-body{padding:9px 11px;min-height:0;overflow:auto} +#nativeFxSelector .native-dialog-footer{padding:6px 11px} +#nativeFxSelector .native-category{gap:3px} +#nativeFxSelector .native-category button{padding:4px 6px;font-size:10px} +#nativeFxSelector .native-search{padding:7px 9px;margin-bottom:5px} +#nativeFxContext .fx-context-delete{color:#efb2a8;display:flex;align-items:center;gap:7px} +#nativeFxContext .fx-context-delete svg{width:15px;height:15px;fill:currentColor} diff --git a/web/styles.css b/web/styles.css index 85f332a2e..f73a66685 100644 --- a/web/styles.css +++ b/web/styles.css @@ -1171,3 +1171,75 @@ html:not([data-mixperf="baseline"]):not([data-mixperf="layers-off"]):not([data-m box-shadow:inset 1px 0 #34434b,inset -1px 0 #34434b; } #app #mixer .fader-zone .fader-travel{z-index:1} +/* DAW insertion markers are painted only while an FX drag is active. */ +#app #mixer .insert-slot.fx-drop-before::before, +#app #mixer .insert-slot.fx-drop-after::after{ + content:"";position:absolute;left:1px;right:1px;height:2px; + background:#9dd6d3;z-index:5;pointer-events:none; +} +#app #mixer .insert-slot{position:relative} +#app #mixer .insert-slot.fx-drop-before::before{top:-1px} +#app #mixer .insert-slot.fx-drop-after::after{bottom:-1px} +.fx-drag-ghost{ + position:fixed;z-index:5000;top:0;left:0;box-sizing:border-box; + min-width:84px;max-width:290px;padding:6px 9px;pointer-events:none; + color:#e7f8f8;background:#172a34;border:1px solid #81c5c8; + border-radius:3px;box-shadow:0 3px 8px #0008;font:11px/1.2 Arial,sans-serif; + white-space:nowrap;overflow:hidden;text-overflow:ellipsis;will-change:transform; +} +.fx-drag-source{opacity:.48} + +/* Native FX Rack uses the same lightweight insertion marker as mixer inserts. */ +.native-node[data-native-move]{position:relative} +.native-node.fx-drop-before::before,.native-node.fx-drop-after::after{ + content:"";position:absolute;left:1px;right:1px;height:2px; + background:#9dd6d3;z-index:5;pointer-events:none; +} +.native-node.fx-drop-before::before{top:-2px} +.native-node.fx-drop-after::after{bottom:-2px} + +/* FX slot selection is always clear without expensive hover blur/compositing. */ +#app #mixer .fx-picker-target{ + outline:1px solid #88cfc5;outline-offset:-1px; + background-color:#1b393e; +} +#app #mixer .native-insert-row.has-orbit .insert, +#app #mixer .native-insert-row.has-orbit .fx-power{ + background-color:#24454b!important;color:#b7eee1; +} +#app #mixer .native-insert-row.has-orbit .insert-name::after{ + content:" · ↻";color:#8dd9c4;font-size:10px; +} +#nativeFxSelector.native-modal{ + background:transparent!important; + pointer-events:none!important;display:block;padding:0; +} +#nativeFxSelector[hidden]{display:none!important} +#nativeFxSelector .native-dialog{ + position:fixed;pointer-events:auto;width:min(390px,calc(100vw - 16px)); + max-height:min(560px,calc(100vh - 16px)); + margin:0;padding:0;box-shadow:0 5px 19px #0008; + border:1px solid #547c85;border-radius:6px; + background:#172a34;overflow:visible; +} +#nativeFxSelector .native-dialog::before{ + content:"";position:absolute;top:-5px;left:var(--fx-arrow-x,22px); + width:8px;height:8px;background:#172a34; + border-left:1px solid #547c85;border-top:1px solid #547c85; + transform:rotate(45deg); +} +#nativeFxSelector .native-dialog.picker-above::before{ + top:auto;bottom:-5px;border:0;border-right:1px solid #547c85; + border-bottom:1px solid #547c85; +} +#nativeFxSelector .native-dialog-header{ + padding:8px 11px;border-bottom:1px solid #34515e; +} +#nativeFxSelector .native-dialog-header h2{font-size:13px;margin:2px 0;font-weight:500} +#nativeFxSelector .native-dialog-body{padding:9px 11px;min-height:0;overflow:auto} +#nativeFxSelector .native-dialog-footer{padding:6px 11px} +#nativeFxSelector .native-category{gap:3px} +#nativeFxSelector .native-category button{padding:4px 6px;font-size:10px} +#nativeFxSelector .native-search{padding:7px 9px;margin-bottom:5px} +#nativeFxContext .fx-context-delete{color:#efb2a8;display:flex;align-items:center;gap:7px} +#nativeFxContext .fx-context-delete svg{width:15px;height:15px;fill:currentColor}