diff --git a/.github/workflows/p1-windows.yml b/.github/workflows/p1-windows.yml index e6fdfe871..0c52db822 100644 --- a/.github/workflows/p1-windows.yml +++ b/.github/workflows/p1-windows.yml @@ -42,6 +42,7 @@ jobs: 'tests/native_preset_contract_test.mjs' 'tests/fx_add_contract_test.mjs' 'tests/live_graph_contract_test.mjs' + 'tests/fx_drag_reorder_contract_test.mjs' 'tests/reconciled_gui_engine_contract_test.mjs' 'tests/main_v08_native_integration_test.mjs' 'tests/smart_audio_ard_contract_test.mjs' @@ -63,7 +64,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 ARMixWorkspaceTests ARMixVaultTests ARMixOrbitPhaseTests ARMixOrbitControlTests ARMixOrbitMotionTests ARMixOrbitDistanceTests 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 ARMixWorkspaceTests ARMixVaultTests ARMixOrbitPhaseTests ARMixOrbitControlTests ARMixOrbitMotionTests ARMixOrbitDistanceTests 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 018ea7780..3db0d4141 100644 --- a/.github/workflows/ui-smoke.yml +++ b/.github/workflows/ui-smoke.yml @@ -40,6 +40,7 @@ jobs: run: | node --check web/app.js node --test tests/gui_workflow_contract_test.mjs + node --test 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 0a7173964..63d5320a4 100644 --- a/AR-MIX-Live-FX-Host-Standalone-v0.3.html +++ b/AR-MIX-Live-FX-Host-Standalone-v0.3.html @@ -754,7 +754,7 @@ /* Scope-specific ON palette: only variables change; all keys share the same seven-layer pad and exact press recipe above. */ #app .toolbar-actions .nav button.btn-180.selected{ - --b180-color:#f0f1f3;--b180-border:#939ba5;--b180-ink:#222932; + --b180-color:#b9cf77;--b180-border:#778c45;--b180-ink:#253019; } #app .left-rail button.btn-180:is(.selected,.active){ --b180-color:var(--b180-on-magenta);--b180-border:#ad6d9f;--b180-ink:#32172f; @@ -1143,6 +1143,106 @@ } /* LED increments stay fixed and the meter keeps its native dBFS conversion. No hot-path DOM reads, filters, blur or per-frame scale animation. */ + +/* P0: one folded-sheet-metal trough across CH1–10 and MASTER. + Dark graphite flat interior, soft top/bottom rolled lips, zero bright + rectangular border. 46px bay independently centered in each fader rail. + Preserve existing cap PNG, gain travel, and mouse hit targets. */ +#app #mixer .fader-zone .fader{ + position:relative;isolation:isolate;min-width:36px; + background:transparent!important;border:0!important;box-shadow:none!important; +} +#app #mixer .fader-zone .fader::before{ + content:"";position:absolute;left:50%;top:0;bottom:0;width:46px; + transform:translateX(-50%);z-index:0;pointer-events:none; + box-sizing:border-box;border:0;border-radius:6px; + background:#24333b; + /* Smooth machine folds at all four edges, no light outer rectangle. */ + box-shadow: + inset 0 4px 4px -3px #070e13, + inset 0 -4px 4px -3px #070e13, + inset 4px 0 5px -4px #081116, + inset -4px 0 5px -4px #081116; +} +#app #mixer .fader-zone .fader::after{ + content:"";position:absolute;left:50%;top:38px;bottom:39px;width:5px; + transform:translateX(-50%);z-index:0;pointer-events:none; + background:#05090c;border:0; + 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;backdrop-filter:none!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}
@@ -1620,6 +1720,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 @@ -1819,7 +1988,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 0edf5b9e4..261925770 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,9 @@ target_link_libraries(ARMixConsole PRIVATE include(CTest) if(BUILD_TESTING) + add_executable(ARMixFxOrderTests tests/fx_order_atomic_test.cpp) + target_compile_features(ARMixFxOrderTests PRIVATE cxx_std_20) + add_test(NAME FxOrderAtomicBlockSnapshot COMMAND ARMixFxOrderTests) add_executable(ARMixOrbitPhaseTests tests/orbit_phase_test.cpp) target_compile_features(ARMixOrbitPhaseTests PRIVATE cxx_std_20) add_test(NAME VstAzimuthOrbitRamp COMMAND ARMixOrbitPhaseTests) 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 bead8706f..09b49710d 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -12,6 +12,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 @@ -26,7 +28,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: @@ -43,6 +45,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 {}; int count = 0; @@ -197,6 +212,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(); @@ -478,31 +495,63 @@ 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 (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"; @@ -534,6 +583,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback return chosen->name + ": " + busError; detach(); + materializeOrderOnStoppedCallback(); Slot node; node.name = chosen->name; node.catalogId = catalogId; @@ -553,7 +603,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback juce::String captureSnapshot (armix::storage::Snapshot& snapshot) { 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); @@ -568,14 +618,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) { @@ -598,7 +649,7 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback // or destroys a plugin. No manual output mute is required for recall. juce::String restoreSnapshot (const armix::storage::Snapshot& snapshot) { - if (handoff_.busy()) + if (handoff_.busy() || fxMovePhase_.load (std::memory_order_acquire) != 0) return "A live FX graph transition is already in progress"; if (snapshot.effects.size() > maxFx) return "Too many plugins in preset"; auto* device = deviceManager_.getCurrentAudioDevice(); @@ -694,16 +745,18 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback if (handoff_.busy()) 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 = graphOwned_->physicalAt (index); + graphOwned_->slots[physical].bypass = value; + graphOwned_->bypassFlags[physical].store (value, std::memory_order_release); return true; } bool removeAt (int index) { - 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) @@ -717,19 +770,25 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback bool moveSlot (int from, int to) { - 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 (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; } @@ -842,9 +901,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)); @@ -994,6 +1054,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_; armix::diagnostics::DiagnosticTone diagnosticTone_; @@ -1201,6 +1265,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) @@ -1238,16 +1307,19 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback juce::MidiBuffer midi; if (!dry) { + // One order snapshot: never observe half of a drag reorder. + 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]; - if (slot.processor && ! cycle.graph->bypassFlags[fx].load (std::memory_order_relaxed)) + const int physical = Graph::physicalAt (order, fx); + auto& slot = cycle.graph->slots[physical]; + if (slot.processor && ! cycle.graph->bypassFlags[physical].load (std::memory_order_relaxed)) { 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); @@ -1274,8 +1346,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; @@ -1292,6 +1367,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 c31c9935a..6ce442a73 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -6,9 +6,9 @@ #include #include "LiveAudioEngine.h" #include "VstOrbitController.h" -#include "../engine/core/OrbitDistanceMapping.h" #include "DiagnosticsRecorder.h" #include "../engine/device/DirectRestoreBackoff.h" +#include "../engine/core/OrbitDistanceMapping.h" #include "../engine/device/PeriodCapabilityEvidence.h" #include "../engine/diagnostics/CrackleEvidenceWindow.h" #if defined(_WIN32) @@ -831,7 +831,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr return emitNotice (error, true); } if (engine_.independentClockActive() && - (action == "fxRemove" || action == "fxMove" || + (action == "fxRemove" || action == "presetLoad" || action == "presetSave")) return emitNotice ("Return to DIRECT mode before editing VST3 graph (live-safe graph edits are a later gate).", true); @@ -1116,8 +1116,10 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr if (engine_.hasTemporaryDiagnosticDevice()) return emitNotice ("Return to NORMAL before rearranging VST3 effects.", true); const auto* orbitPlugin=orbit_.processor(); + // MOVE only publishes a lock-free order word at the next audio + // buffer boundary; the underlying VST3 processor/editor remains + // alive, so neither callback detach nor editor close is needed. orbit_.pauseForGraphEdit(); - editorWindow_.reset(); 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..28592294b --- /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:46px/); + assert.match(css,/background:#1b2a32/); + assert.match(css,/top:0;bottom:0;width:46px/); + 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: one folded-sheet-metal trough'),css.indexOf('/* DAW insertion markers')); + assert.match(trough,/background:#24333b/); + assert.match(trough,/width:46px/); + assert.match(trough,/border:0;border-radius:6px/); + assert.doesNotMatch(trough,/0 -1px 0 #364650/); + 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..eaa967370 --- /dev/null +++ b/tests/fx_order_atomic_test.cpp @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: AGPL-3.0-only +#include "../engine/core/FxOrderPlan.h" +#include "../engine/core/FxMoveRamp.h" +#include +#include +#include +#include +#include + +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}) + { + assert(Ramp::gain(1,0,frames)==1.f); + assert(Ramp::gain(1,frames-1,frames)==0.f); + assert(Ramp::gain(2,0,frames)==0.f); + assert(Ramp::gain(2,frames-1,frames)==1.f); + assert(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); + assert(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 86ce65738..eb6b6d7c2 100644 --- a/tests/live_graph_contract_test.mjs +++ b/tests/live_graph_contract_test.mjs @@ -28,7 +28,14 @@ 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',()=>{ +test('atomic MOVE keeps VST3 instances live while ADD/REMOVE remain guarded',()=>{ assert.match(e,/if \(handoff_\.busy\(\)\) return false/); - assert.match(e,/Legacy Add\/Remove\/Move still detach/); + assert.match(e,/Add\/Remove still use a bounded offline lifecycle/); + assert.match(e,/std::atomic orderPacked/); + const begin=e.indexOf('bool moveSlot (int from, int to)'); + const move=e.slice(begin,e.indexOf('juce::var status()',begin)); + assert.match(move,/FxOrderPlan::moved/); + assert.match(move,/orderPacked.store/); + assert.doesNotMatch(move,/detach\(|attach\(|releaseResources\(|prepareToPlay\(/); + assert.match(e,/cycle\.graph->orderPacked.load/); }); diff --git a/tests/native_ui_contract_test.mjs b/tests/native_ui_contract_test.mjs index c73a55dfb..13fb377f5 100644 --- a/tests/native_ui_contract_test.mjs +++ b/tests/native_ui_contract_test.mjs @@ -32,7 +32,7 @@ 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/); }); test('GUI pan event reaches actual callback pan matrix',()=>{ assert.match(app,/send\(master\?'masterPan':'pan',c\.pan,master\?-1:idx\)/); diff --git a/tests/ui_smoke.py b/tests/ui_smoke.py index b10e0273f..94ab6a1fc 100644 --- a/tests/ui_smoke.py +++ b/tests/ui_smoke.py @@ -309,7 +309,7 @@ def shared_shadow_shape(shadow): assert style[key]['image']=='none',(key,style) assert style[key]['shadow'].count('rgb')==7,(key,style) assert style[key]['radius']=='3px',(key,style) - assert style['selected']['face']=='rgb(240, 241, 243)',style + assert style['selected']['face']=='rgb(185, 207, 119)',style assert style['railOn']['face']=='rgb(227, 166, 216)',style # Audio Device shares the physical BTN-180 toolbar face and dark ink. # The OFF state is truthful in UI-only preview. Explicitly force ON @@ -367,7 +367,7 @@ def shared_shadow_shape(shadow): const on=document.querySelector('[data-view="FX RACK"]'); const off=document.querySelector('[data-view="MIX"]'); return on.classList.contains('selected') && !off.classList.contains('selected') - && getComputedStyle(on).backgroundColor==='rgb(240, 241, 243)' + && getComputedStyle(on).backgroundColor==='rgb(185, 207, 119)' && getComputedStyle(off).backgroundColor==='rgb(179, 179, 179)'; }""") nav=page.locator('[data-view="FX RACK"]') diff --git a/web/app.js b/web/app.js index 281fe2aa7..3eee1c461 100644 --- a/web/app.js +++ b/web/app.js @@ -427,6 +427,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 @@ -626,7 +695,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 c8661016f..92d26f883 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 ''; }; @@ -443,7 +494,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(){ @@ -454,7 +505,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("")}
@@ -469,7 +520,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; @@ -567,14 +653,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"); @@ -584,6 +673,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"); @@ -593,8 +689,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)=> + `
@@ -602,13 +698,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; @@ -647,7 +749,9 @@ fxContext.innerHTML=''+ ''+ ''+ - ''; + ''+ + ''+ + ''; 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'; @@ -681,6 +785,7 @@ if(action==="orbit")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"); @@ -709,10 +814,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-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-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; @@ -776,7 +887,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"); @@ -787,7 +900,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; @@ -800,6 +914,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; @@ -829,6 +947,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; @@ -895,7 +1083,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, @@ -918,8 +1112,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/20-button-180.css b/web/styles-src/20-button-180.css index fd8296344..e1d42e3f5 100644 --- a/web/styles-src/20-button-180.css +++ b/web/styles-src/20-button-180.css @@ -145,7 +145,7 @@ /* Scope-specific ON palette: only variables change; all keys share the same seven-layer pad and exact press recipe above. */ #app .toolbar-actions .nav button.btn-180.selected{ - --b180-color:#f0f1f3;--b180-border:#939ba5;--b180-ink:#222932; + --b180-color:#b9cf77;--b180-border:#778c45;--b180-ink:#253019; } #app .left-rail button.btn-180:is(.selected,.active){ --b180-color:var(--b180-on-magenta);--b180-border:#ad6d9f;--b180-ink:#32172f; diff --git a/web/styles-src/42-mixer-premium.css b/web/styles-src/42-mixer-premium.css index 9e4ed9ebe..63d73ce39 100644 --- a/web/styles-src/42-mixer-premium.css +++ b/web/styles-src/42-mixer-premium.css @@ -183,3 +183,103 @@ html:not([data-mixperf="baseline"]):not([data-mixperf="layers-off"]):not([data-m } /* LED increments stay fixed and the meter keeps its native dBFS conversion. No hot-path DOM reads, filters, blur or per-frame scale animation. */ + +/* P0: one folded-sheet-metal trough across CH1–10 and MASTER. + Dark graphite flat interior, soft top/bottom rolled lips, zero bright + rectangular border. 46px bay independently centered in each fader rail. + Preserve existing cap PNG, gain travel, and mouse hit targets. */ +#app #mixer .fader-zone .fader{ + position:relative;isolation:isolate;min-width:36px; + background:transparent!important;border:0!important;box-shadow:none!important; +} +#app #mixer .fader-zone .fader::before{ + content:"";position:absolute;left:50%;top:0;bottom:0;width:46px; + transform:translateX(-50%);z-index:0;pointer-events:none; + box-sizing:border-box;border:0;border-radius:6px; + background:#24333b; + /* Smooth machine folds at all four edges, no light outer rectangle. */ + box-shadow: + inset 0 4px 4px -3px #070e13, + inset 0 -4px 4px -3px #070e13, + inset 4px 0 5px -4px #081116, + inset -4px 0 5px -4px #081116; +} +#app #mixer .fader-zone .fader::after{ + content:"";position:absolute;left:50%;top:38px;bottom:39px;width:5px; + transform:translateX(-50%);z-index:0;pointer-events:none; + background:#05090c;border:0; + 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;backdrop-filter:none!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 c8a91e769..8e3869efd 100644 --- a/web/styles.css +++ b/web/styles.css @@ -753,7 +753,7 @@ html,body,body *:not(svg):not(path):not(circle):not(rect){ /* Scope-specific ON palette: only variables change; all keys share the same seven-layer pad and exact press recipe above. */ #app .toolbar-actions .nav button.btn-180.selected{ - --b180-color:#f0f1f3;--b180-border:#939ba5;--b180-ink:#222932; + --b180-color:#b9cf77;--b180-border:#778c45;--b180-ink:#253019; } #app .left-rail button.btn-180:is(.selected,.active){ --b180-color:var(--b180-on-magenta);--b180-border:#ad6d9f;--b180-ink:#32172f; @@ -1142,3 +1142,103 @@ html:not([data-mixperf="baseline"]):not([data-mixperf="layers-off"]):not([data-m } /* LED increments stay fixed and the meter keeps its native dBFS conversion. No hot-path DOM reads, filters, blur or per-frame scale animation. */ + +/* P0: one folded-sheet-metal trough across CH1–10 and MASTER. + Dark graphite flat interior, soft top/bottom rolled lips, zero bright + rectangular border. 46px bay independently centered in each fader rail. + Preserve existing cap PNG, gain travel, and mouse hit targets. */ +#app #mixer .fader-zone .fader{ + position:relative;isolation:isolate;min-width:36px; + background:transparent!important;border:0!important;box-shadow:none!important; +} +#app #mixer .fader-zone .fader::before{ + content:"";position:absolute;left:50%;top:0;bottom:0;width:46px; + transform:translateX(-50%);z-index:0;pointer-events:none; + box-sizing:border-box;border:0;border-radius:6px; + background:#24333b; + /* Smooth machine folds at all four edges, no light outer rectangle. */ + box-shadow: + inset 0 4px 4px -3px #070e13, + inset 0 -4px 4px -3px #070e13, + inset 4px 0 5px -4px #081116, + inset -4px 0 5px -4px #081116; +} +#app #mixer .fader-zone .fader::after{ + content:"";position:absolute;left:50%;top:38px;bottom:39px;width:5px; + transform:translateX(-50%);z-index:0;pointer-events:none; + background:#05090c;border:0; + 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;backdrop-filter:none!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}