diff --git a/AGENTS.md b/AGENTS.md index 39005f086..1517a53b6 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,3 +1,5 @@ +> **M2 UNIFIED FX CONSOLE / BUS WORKFLOW 2026-10-31 (BRANCH IN VALIDATION):** Read docs/M2_UNIFIED_CONSOLE_BUS_WORKFLOW_20261031.md before editing FX Rack/bus routing. Current branch unifies CH1–10 FX Rack UI using one presenter and offers real +BUS/+FX BUS using an otherwise unused native 10CH lane and existing muted native ACK. It intentionally does NOT remove CH1's legacy vendor VST3 lease, create dynamic CH11, implement native MASTER FX/PDC, or certify physical #15 FAT. Protect device + SOURCE PR #228/#231/#232/#233, Show/Orbit, one JUCE callback, epoch revision ACK, and AGENTS product truth. The next major engine milestone is real per-ChannelId FxRack/Show migration, not another cosmetic branch. + > **LATEST CROSS-THREAD STATUS (2026-10-31, main after #234):** Read [M1/M2 & release reconciliation](docs/RECONCILED_PROGRESS_M1_M2_20261031.md) FIRST. DEVICE2+SOURCE2 are merged together in #234 (`7db4ab70`); #232 closed superseded, never merge its old head. #235 M2 FX/BUS is OPEN with Chromium regressions and not production; #229/#225 FactoryFX overlap and need selective reconcile. The native Windows FAT ZIP from `main@a7fb6151` predates #234; use a newer successful main artifact when published. No MAONO/WASAPI hardware FAT or #15 zero-VST crackle clearance, and FactoryFX approved lock still empty. Older AGENTS milestones below are historical if they conflict. Preserve one JUCE device owner, one native graph/route authority, stable L2/RAIL3, and explicit native ACK / output safety. > **DEVICE1 CUSTOM DEVICE SETUP MERGED #228 (2026-10-31) — CI PASS, PHYSICAL FAT PENDING:** Read [PRD](docs/PRD_CUSTOM_AUDIO_DEVICE_SETUP_20261031.md), [ARD](docs/ARD_CUSTOM_AUDIO_DEVICE_SETUP_20261031.md) and [per-file handoff](docs/HANDOFF_CUSTOM_AUDIO_DEVICE_SETUP_20261031.md) before touching AUDIO DEVICE / DEVICE-DRIVER / ASIO / WASAPI. Existing WebView2 Audio I/O Matrix must become the SINGLE real device setup UI: backend, actual capture/playback endpoints, sample rate, buffer, enabled pins, APPLY with verified JUCE readback, fail-closed muted rollback. Keep ONE existing AudioDeviceManager, native routing epoch/ACK, MAIN/MONITOR/OUTPUT1/FX and #15 gate. Now DEVICE/DRIVER in the existing WebView2 matrix selects actual JUCE-reported ASIO/WASAPI/DirectSound backend, input/output endpoints, rate, buffer and verified pin masks; its native APPLY, muted rollback, readback and requestId ACK were merged in #228 at e0eaeafe88b9fdc997f3f6e7856331679db1ba7b. The old AudioDeviceSelectorComponent remains only a C++ engineering fallback and is NOT the normal UI. Physical MAONO/WASAPI FAT, vendor driver hangs and #15 0FX crackle remain UNQUALIFIED. Driver scans/opens may block vendor code: don't claim async bridge eliminates freeze; audit pinned JUCE thread affinity and instrument physical hangs. No second hardware setup UI, manager, audio graph or naive per-dropdown device restart. diff --git a/docs/M2_UNIFIED_CONSOLE_BUS_WORKFLOW_20261031.md b/docs/M2_UNIFIED_CONSOLE_BUS_WORKFLOW_20261031.md new file mode 100644 index 000000000..ca78416a3 --- /dev/null +++ b/docs/M2_UNIFIED_CONSOLE_BUS_WORKFLOW_20261031.md @@ -0,0 +1,39 @@ +# M2 — Studio-style console FX parity and native BUS staging +2026-10-31 | user-visible implementation on existing native 10-input/4-AUX graph. +Owner: #192 dynamic channels, #95 VST3/FX/PDC. No certified physical results claimed. + +## Reference behavior +Official Fender Studio Pro / Studio One console manual: +https://fenderstudiopromanual.fender.com/en/Content/Mixing_Topics/Effects_Signal_Routing.htm +https://fenderstudiopromanual.fender.com/en/Content/Mixing_Topics/The_Console.htm +Audio, Bus and FX strips use inserts/sends, subgroup output sums into bus, FX send can preserve dry direct-to-MAIN, nested buses require feedback prevention. Match the operation semantics and accessible actions rather than copying branding/code/assets. + +## What this branch actually implements +- One presentation pipeline in web/bridge.js: fxLaneSnapshot, fxSlotMarkup and renderRack generate exactly the same 8-row FX workspace and 6 compact strip slots for existing CH1–10. No second visual CH1 renderer. All displayed loaded/bypass states come from real JUCE CH1 chain or native routed VST3 ACK. Unpatched lanes are disabled and clearly marked, not fake active FX. +- CH1 existing VST3 lease, plugin state/Orbit, existing native bypass/move and Show remain unchanged. Other CHs keep their real routed VST3 controller. This only unifies the UI adapter and preserves audio identity until native instance-owner migration is safe. +- + BUS from selected connected CH stages an otherwise unused native CH as BUS receiver, source direct MAIN off, unity POST send to the BUS, BUS MAIN on. Avoid doubled dry signal. Operator must MUTE outputs, APPLY and wait for positive native routing ACK before it sounds. +- + FX BUS stages a separate BUS receiver with 0.25 linear POST send while source still feeds MAIN; the FX BUS inserts can then host real native VST3. No fake reverb added automatically. +- Real native channel-send DAG validation guards self-feedback, cycles, duplicates and resource limits. The wizard also rejects pending drafts, dirty graph, stale device epoch, output armed, no source and no spare native strip; rollback restores previous source main and exact spare channel state. +- No new callbacks, WebAudio DSP, allocations in processBlock, serial device changes or plugin lifecycle added. Existing 10-input/4-AUX DSP and ROUTING/MUTE/APPLY/ACK remain sole authority. + +## Status boundaries +- This is a meaningful console workflow and native routing feature, NOT yet full Studio One parity. +- LIVE channel add/remove and arbitrary named buses remain unimplemented. Current +BUS reuses one of the TEN available native strips and explicitly fails when full. User may use that strip for a Vocal/Drum/FX Bus but cannot create CH11 yet. +- CH1 native vendor FX and routed FX still have distinct lifecycle paths despite identical UI. MASTER insert FX, PDC and end-to-end zero latency are not implemented. ChannelId dynamic/Show migration remains the next big milestone: replace LegacyChannelOneLease and fixed 10CH path with one prepared graph + one FxRack keyed by ChannelId, preserving Orbit/vendor state and native ACK. +- No claim of complete Studio One visual copy, zero device roundtrip delay, hardware approval or solved #15 crackle. + +## Validation and physical FAT +1. Exact-head native Windows compile, CTest, packaging and Chromium smoke; targeted JS contracts enforce single view model and route wizard fail-closed behavior. +2. Under DIRECT ASIO/WASAPI with outputs MUTED: physical Mic CH1 -> BUS on unused CH10 -> MAIN. With output armed after accepted ACK, exactly one path should be audible. Independently physical Mic CH3 -> FX BUS on CH9, CH3 direct MAIN remains while CH9 processes real reverb VST3. +3. Channel 1, 3, 9 and 10 six FX rows identical in geometry and operator workflow. No ghost live inserts, source/output stays correct, no dropped plugin editor lease/Show state. Bus routing status must only become live after positive ACK. +4. Reject: output armed, source NONE, prior dirty draft, full 10 native channels, obsolete epoch, feedback cycles, VST add failure; preserve previous audible graph. +5. Hardware #15: 0FX baseline and real wired ASIO/WASAPI low buffer (32/64/128), 44.1/48/96k, 30-minute soak, silence/dropout/crackle and low-spec GUI. Only mark product FAT passed after measured evidence. + +## Follow-up architecture gate, no parallel DSP +Only one live native ChannelId-based graph, same native instance lease for CH1..N, FX bus, group and main, topology precompile control-thread, stable ID, full VST3 state, safe de-click handoff and PDC. Do not merge any old 10CH prototype branch into main to simulate dynamic add. Check current main and #232 device-owner PR before changes to JUCE audio graph. + +## M2B integrated milestone: Multi-source BUS and FX SEND routing +- A previously ACKed BUS can now accept multiple native CH inputs through the same FX Rack using SEND TO EXISTING BUS → OUTPUT → BUS or FX SEND → BUS. +- Exclusive group routing disables source direct MAIN, unity POST to BUS; parallel FX sends at linear .25 retain direct dry MAIN. Native DAG prevents feedback/self-loop and a duplicate edge. BUS-to-BUS nesting only when legal. +- Reuses existing audio graph, 10-CH capacity, same epoch/revision/MUTE/APPLY/ACK. Safe failure retains previously accepted route. A BUS is selectable only after native ACK, not a browser draft. +- No falsely claimed arbitrary new runtime channels/independent FX bus role, native master VST/PDC, physical latency or #15 FAT. diff --git a/tests/fx_drag_reorder_contract_test.mjs b/tests/fx_drag_reorder_contract_test.mjs index acd9d0561..4ee4f98f4 100644 --- a/tests/fx_drag_reorder_contract_test.mjs +++ b/tests/fx_drag_reorder_contract_test.mjs @@ -42,7 +42,7 @@ test('DAW reorder preserves real chain identity, metadata, and bypass',()=>{ }); 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,/Array\.from\(\{length:6\},\(_,slot\)=>fxSlotMarkup\(lane,slot,true\)\)/); assert.match(bridge,/fx-drag-ghost/); assert.match(bridge,/send\("fxMove",\{slot:from,value:to-from\}\)/); assert.doesNotMatch(bridge,/FX FULL/); diff --git a/tests/live_routing_ui_contract_test.mjs b/tests/live_routing_ui_contract_test.mjs index 21793bbf2..f3743d2fd 100644 --- a/tests/live_routing_ui_contract_test.mjs +++ b/tests/live_routing_ui_contract_test.mjs @@ -41,7 +41,7 @@ test("GUI exposes only truthful dry device routes and acknowledged commit",()=>{ assert.match(main,/arMixRoutingLabAck/); // Default 10 fake preview strips are intentionally not made into VST3 // controls by the dry hardware test. - assert.match(bridge,/if\(i!==0\)/); + assert.match(bridge,/const lane=fxLaneSnapshot\(i\)/); assert.match(bridge,/track\.dataset\.preview="1"/); }); diff --git a/tests/mixer_io_smoke.py b/tests/mixer_io_smoke.py index f3232d558..823a54475 100644 --- a/tests/mixer_io_smoke.py +++ b/tests/mixer_io_smoke.py @@ -77,6 +77,36 @@ async def main(): assert "LIVE" in await page.locator('[data-strip="0"] .arBankStage').inner_text() assert 'Microphone 1' in await page.locator('[data-focus-source]').inner_text() assert 'MAIN' in await page.locator('[data-focus-out]').inner_text() + # M2 Studio-style BUS: one existing empty native lane, no phantom + # CH11; group re-routes direct MAIN, parallel FX BUS preserves dry. + # Both remain DRAFT until the operator explicitly MUTES/APPLIES/ACKs. + group=await page.evaluate("""()=>({ + result:window.__arMixStageBusFromSelected({source:0,kind:'group'}), + view:window.__arMixRouteView() + })""") + assert group['result']['ok'],group + bus=group['result']['target'] + assert group['view']['draftRoutes'][bus]['mode']=='BUS',group + assert group['view']['draftRoutes'][bus]['gain']==1,group + assert group['view']['draftRoutes'][0]['main'] is False,group + assert any(x['from']==0 and x['to']==bus and x['gain']==1 + for x in group['view']['draftSends']),group + assert (await page.evaluate("""()=>window.__armixTestActions.filter( + x=>x.name==='arMixAction'&&x.data.action==='routingDryApply').length"""))==1 + assert (await page.evaluate("()=>window.__arMixRevertMixerDraft()"))['ok'] + await page.locator('#arRouteClose').click() + fxbus=await page.evaluate("""()=>({ + result:window.__arMixStageBusFromSelected({source:0,kind:'fx'}), + view:window.__arMixRouteView() + })""") + assert fxbus['result']['ok'] and fxbus['result']['target']==bus,fxbus + assert fxbus['view']['draftRoutes'][0]['main'] is True,fxbus + assert any(x['from']==0 and x['to']==bus and x['gain']==.25 + for x in fxbus['view']['draftSends']),fxbus + assert (await page.evaluate("()=>window.__arMixRevertMixerDraft()"))['ok'] + await page.locator('#arRouteClose').click() + assert (await page.evaluate("""()=>window.__armixTestActions.filter( + x=>x.name==='arMixAction'&&x.data.action==='routingDryApply').length"""))==1 await page.locator('[data-focus-step="fx"]').click() assert await page.locator('#mixer').get_attribute('data-io-mode')=='FX' await page.locator('[data-focus-step="source"]').click() @@ -745,6 +775,90 @@ async def main(): assert await page.locator('[data-source-alias-save]').is_disabled() await page.screenshot(path="mixer-patch1-maono-ch3-ch6-1366.png") assert not errors,errors + # M2B independent browser-native routing graph (same browser process): + # create group, ACK, route a second CH into that same existing BUS. + bp=await browser.new_page(viewport={"width":1366,"height":768}) + bus_errors=[] + bp.on("pageerror",lambda e:bus_errors.append(str(e))) + await bp.add_init_script("""(()=>{ + const listeners={};window.__armixTestActions=[]; + window.__JUCE__={backend:{ + addEventListener(name,fn){(listeners[name]??=[]).push(fn)}, + emitEvent(name,data){window.__armixTestActions.push({name,data})} + }}; + window.__armixTestEmit=(name,data)=>(listeners[name]||[]).forEach(fn=>fn(data)); + })();""") + await bp.goto((root/"web/index.html").as_uri()) + await bp.evaluate("""()=>{ + const channels=Array.from({length:10},(_,i)=>({ + mode:i<2?'MONO':'NONE',channelFormat:'MONO',left:i<2?i:-1, + right:-1,gain:.25,pan:0,main:true,mute:false,solo:false, + fxId:'',fxIds:[]})); + const auxes=Array.from({length:4},()=>({ + enabled:false,gain:1,main:true,mute:false,fxId:'',fxIds:[]})); + const d={active:true,ready:true,epoch:45,revision:3, + ports:[{port:0,label:'Mic 1'},{port:1,label:'Mic 2'}], + outputPorts:[0,1],channelControls:[], + acceptedRoute:{deviceEpoch:45,channels,auxes,sends:[]}}; + window.__busDevice={connected:true,driver:'ASIO', + monitor:false,chainCount:0,dryRoutingLab:d}; + window.__armixTestEmit('arMixStatus',window.__busDevice); + }""") + created=await bp.evaluate("""()=>({ + action:window.__arMixStageBusFromSelected({source:0,kind:'group'}), + draft:window.__arMixRouteView()})""") + assert created['action']['ok'],created + bus=created['action']['target'] + assert created['draft']['draftRoutes'][bus]['mode']=='BUS',created + assert created['draft']['draftRoutes'][bus]['gain']==1,created + assert created['draft']['draftRoutes'][0]['main'] is False,created + assert not await bp.evaluate("""()=>window.__armixTestActions.some( + x=>x.data?.action==='routingDryApply')""") + await bp.locator('#arRouteApply').click() + assert await bp.evaluate("""()=>window.__armixTestActions.some( + x=>x.data?.action==='routingDryApply')""") + await bp.evaluate("""()=>{ + const view=window.__arMixRouteView(); + const d=window.__busDevice.dryRoutingLab; + d.acceptedRoute={...d.acceptedRoute, + channels:view.draftRoutes,auxes:view.draftAux,sends:view.draftSends}; + d.revision=4; + window.__armixTestEmit('arMixRoutingLabAck',{ok:true,state:d}); + window.__armixTestEmit('arMixStatus',window.__busDevice); + }""") + await bp.locator('#arRouteClose').click() + await bp.locator('[data-view="FX RACK"]').click() + await bp.evaluate('()=>{currentChannel=1;renderRackWorkspace()}') + assert await bp.locator('#rackWorkspace [data-bus-target] option').count()==1 + assert await bp.locator('#rackWorkspace [data-bus-target]').input_value()==str(bus) + # Existing BUS accepts a second input; no new strip is allocated. + await bp.locator('#rackWorkspace [data-bus-assign="group"]').click() + send=await bp.evaluate('()=>window.__arMixRouteView()') + assert send['draftRoutes'][1]['main'] is False,send + assert send['draftRoutes'][bus]['mode']=='BUS',send + assert len(send['draftSends'])==2,send + assert any(e['from']==1 and e['to']==bus and e['gain']==1 + for e in send['draftSends']),send + assert len(await bp.evaluate("""()=>window.__armixTestActions.filter( + x=>x.data?.action==='routingDryApply')"""))==1 + assert (await bp.evaluate('()=>window.__arMixRevertMixerDraft()'))['ok'] + await bp.locator('#arRouteClose').click() + await bp.locator('[data-view="FX RACK"]').click() + await bp.evaluate('()=>{currentChannel=1;renderRackWorkspace()}') + await bp.locator('#rackWorkspace [data-bus-assign="fx"]').click() + fxsend=await bp.evaluate('()=>window.__arMixRouteView()') + assert fxsend['draftRoutes'][1]['main'] is True,fxsend + assert any(e['from']==1 and e['to']==bus and e['gain']==.25 + for e in fxsend['draftSends']),fxsend + assert (await bp.evaluate('()=>window.__arMixRevertMixerDraft()'))['ok'] + self_cycle=await bp.evaluate("""target=>window.__arMixStageSendToBus({ + source:target,target,kind:'fx'})""",bus) + assert not self_cycle['ok'] and 'Feedback' in self_cycle['error'] + duplicate=await bp.evaluate("""target=>window.__arMixStageSendToBus({ + source:0,target,kind:'fx'})""",bus) + assert not duplicate['ok'] and 'already' in duplicate['error'] + assert not bus_errors,bus_errors + await bp.close() await browser.close() print("PASS: G1/G2 + G3 real PRE/POST draft, AUX return, 0-gain bypass, native ACK/reject/revert, stable rack and 3 viewports") diff --git a/tests/mixer_shell_contract_test.mjs b/tests/mixer_shell_contract_test.mjs index 93425c5dc..131922b38 100644 --- a/tests/mixer_shell_contract_test.mjs +++ b/tests/mixer_shell_contract_test.mjs @@ -134,8 +134,8 @@ test('L2 route and VST inserts use one consistent six-row native rack with locke assert.match(src,/master-locked-six/); assert.match(src,/class="master-insert insert empty" disabled aria-disabled="true"/); assert.match(src,/slot===0\?"FX UNAVAILABLE":"ADD FX"/); - assert.match(src,/class="fx-power \$\{actual\.bypassed\?"is-bypassed":""\}"/); - assert.match(src,/loaded\?"":'{ - assert.match(bridge,/data-native-fx="bypass" data-slot="\$\{i\}"/); - assert.match(bridge,/aria-pressed="\$\{!p\.bypass\}"/); + assert.match(bridge,/data-native-fx="bypass" data-slot=/); + assert.match(bridge,/aria-pressed/); assert.match(bridge,/send\("fxBypass",\{slot,value:!state\.chain\[slot\]\?\.bypass\}\)/); assert.match(engine,/graphOwned_->bypassFlags\[physical\]\.store/); assert.match(engine,/bypassEnvelope\[physical\]/); diff --git a/tests/plugin_ui_contract_test.mjs b/tests/plugin_ui_contract_test.mjs index 58a4bcdb6..bd5391df3 100644 --- a/tests/plugin_ui_contract_test.mjs +++ b/tests/plugin_ui_contract_test.mjs @@ -136,7 +136,7 @@ test('favorites sort to top, remain searchable and serialize in the portable cat test('real routed FX rack remains separate from Routing and respects native apply/ACK',()=>{ const monitor=read('web/monitor.js'); const engine=read('src/LiveDryRoutingLab.h'); - assert.match(bridge,/CH1 without a routed VST3 continues into its existing 8-slot rack/); + assert.match(bridge,/M2 single console presenter/); assert.match(bridge,/native-rack-/); assert.match(bridge,/data-routed-fx=/); assert.match(bridge,/data-routed-apply="1"/); @@ -185,8 +185,8 @@ test('P2 user field regressions: fixed catalog header, uniform material and orig assert.match(generatedCss,/font-size:11px!important;min-width:0/); assert.ok(standalone.includes(''), 'canonical standalone CSS must track the shared BTN-180 text size'); - assert.match(bridge,/if\(lab\?\.active && \(i!==0 \|\| \(!!lab\.channelFxNames\?\.\[0\] && state\.chain\.length===0\)\)\)/); - assert.match(bridge,/if\(isMaster\|\|selected!==0\|\|\(fx&&state\.chain\.length===0\)\)/); + assert.match(bridge,/function fxLaneSnapshot\(channel,master=false\)/); + assert.match(bridge,/function fxSlotMarkup\(lane,slot,compact=false\)/); assert.match(bridge,/send\("addCatalog",\{id,requestId\}\)/); assert.match(bridge,/Audio device is unavailable\. Open SETUP/); assert.match(monitor,/document\.fonts\.ready\.then\(guiPaintReady,guiPaintReady\)/); @@ -208,9 +208,9 @@ test('G5 UI safety: compact Studio One-like browser and native insert truth',()= assert.match(bridge,/MASTER FX · UNAVAILABLE/); assert.doesNotMatch(bridge,/data-native-unrouted="-1"/); assert.match(bridge,/Array\.from\(\{length:8\}/); - assert.match(bridge,/data-routed-lane/); - assert.match(bridge,/ar-routed-loaded/); - assert.match(bridge,/state\.chain\.slice\(0,6\)/); + assert.match(bridge,/data-fx-lane/); + assert.match(bridge,/fxSlotMarkup\(lane,slot,true\)/); + assert.match(bridge,/Array\.from\(\{length:6\},\(_,slot\)=>fxSlotMarkup\(lane,slot,true\)\)/); assert.match(bridge,/data-routed-fx/); assert.match(bridge,/data-native-fx="editor"/); }); @@ -268,3 +268,21 @@ test('FXF1 manifest parser is fail-closed and factory entries do not persist in assert.match(native,/catalog_\.scanFactoryIfPresent\(\)/); assert.match(cmake,/FactoryFxVerifiedManifestAndNegativePathGate/); }); + +test('M2 one FX presenter and native BUS staging have shared safety gates',()=>{ + const monitor=read('web/monitor.js'); + for(const term of ['function fxLaneSnapshot','function fxSlotMarkup','data-bus-create','__arMixStageBusFromSelected'])assert.ok(bridge.includes(term)); + for(const term of ['row.mode="BUS"','kind==="group"','draftSends.push({from:source,to:target,tap:"POST"','const issue=patchPreflight()','Object.assign(row,previousRow)','openRoutingLab()','No unused native strip for BUS'])assert.ok(monitor.includes(term)); + assert.doesNotMatch(bridge,/if\(lab\?\.active && \(i!==0/); +}); + +test('M2B existing BUS supports group, parallel FX, rollback and feedback safety',()=>{ + const m=read('web/monitor.js'); + for(const part of ['SEND TO EXISTING BUS','data-bus-target','data-bus-assign="group"', + 'data-bus-assign="fx"','__arMixStageSendToBus']) + assert.ok(bridge.includes(part)||m.includes(part),part); + for(const part of ['source===target','d.acceptedRoute.channels[target]?.mode!=="BUS"', + 'draftRoutes[source].main=originalMain','const issue=patchPreflight()', + 'mixerDraftActive=true','Native 32-send budget reached']) + assert.ok(m.includes(part),part); +}); diff --git a/web/bridge.js b/web/bridge.js index 4eb3cfb71..25d3a0518 100644 --- a/web/bridge.js +++ b/web/bridge.js @@ -49,6 +49,7 @@ const css = document.createElement("style"); css.textContent = ` .native-toolbar{display:flex;flex-wrap:wrap;gap:7px;align-items:center} + .native-bus-target{font:11px inherit;background:#10242f;color:#d9eaf1;border:1px solid #507184;border-radius:4px;max-width:175px;min-height:29px;padding:4px 7px;outline-offset:2px} .native-btn{font:inherit;color:#d6e9ef;padding:8px 12px;border:1px solid #48677a;border-radius:6px; background:linear-gradient(180deg,#405c70 0%,#243846 47%,#0d1e29 100%);cursor:pointer; box-shadow:inset 0 1px 1px #93badc70,0 2px 3px #0008} @@ -199,111 +200,108 @@ return `
AR MIX · NATIVE VST3 ENGINE

${escapeHtml(title)}

${escapeHtml(subtitle)}
`; } - function renderRack(){ - if(!workspace || currentTab()!=="FX RACK") return; - const lab=state.device?.dryRoutingLab; - if(lab?.active) { + // M2 single console presenter. CH1 without a routed VST3 continues into its + // existing 8-slot rack until the original VST lease/Orbit migrates to the + // common prepared graph. No "native-rack-" duplicate visual renderer. + function fxLaneSnapshot(channel,master=false) { + const lab=state.device?.dryRoutingLab; + const legacy=!master&&channel===0&&(state.chain.length>0||!lab?.channelFxNames?.[0]); + const routed=!master&&!legacy&&!!lab?.active&&!!lab?.ready; + const view=routed?(window.__arMixFxLaneView?.(channel)||{}):{}; + const ids=Array.isArray(view.ids)?view.ids:[]; + const instances=Array.isArray(view.liveSlots)?view.liveSlots:[]; + const items=legacy?state.chain.map(p=>({ + name:p.name||"VST3",bypassed:!!p.bypass,live:true + })):routed?ids.map((id,i)=>({ + name:view.names?.[i]||"VST3",bypassed:!!instances[i]?.bypassed, + live:!view.pending&&instances[i]?.catalogId===id&&!!instances[i]?.instanceId + })):[]; + return {channel,mode:master?"master":legacy?"legacy":routed?"routed":"unpatched", + items,pending:!!view.pending}; + } + function fxSlotMarkup(lane,slot,compact=false) { + const p=lane.items[slot],filled=!!p; + const native=lane.mode==="legacy",routed=lane.mode==="routed"; + // All empty chrome rows are actionable; native insert goes to the next + // contiguous VST3 slot rather than silently creating a hole. + const canChoose=slot<8; + const routedSlot=filled?slot:lane.items.length; + const open=native?(filled?'data-native-fx="editor" data-slot="'+slot+'"': + canChoose?'data-plugin-picker="1"':'disabled'): + routed&&(filled||canChoose)?'data-routed-fx="'+lane.channel+'" data-routed-slot="'+routedSlot+'"':'disabled'; + const power=native?'data-native-fx="bypass" data-slot="'+slot+'"': + 'data-routed-bypass="'+lane.channel+'" data-routed-slot="'+slot+'"'; + const move=direction=>native?'data-native-fx="'+direction+'" data-slot="'+slot+'"': + 'data-routed-move="'+lane.channel+'" data-routed-slot="'+slot+'" data-routed-direction="'+direction+'"'; + const remove=native?'data-native-fx="remove" data-slot="'+slot+'"': + 'data-routed-clear="'+lane.channel+'" data-routed-slot="'+slot+'"'; + const label=filled?p.name:"ADD FX"; + const status=lane.pending?"DRAFT · NOT LIVE":filled?(p.live?"NATIVE VST3":"NOT ACKNOWLEDGED"): + lane.mode==="master"?"MASTER FX UNAVAILABLE":lane.mode==="unpatched"?"SOURCE NOT PATCHED":"EMPTY FX SLOT"; + const live=filled&&p.live&&!lane.pending; + const marker=native&&filled?' data-native-move="'+slot+'"':""; + const cl=(compact?"insert-slot"+(filled?" native-insert-row":""):"native-node")+ + (p?.bypassed?" is-bypassed":"")+ + (native&&state.orbitActiveSlot===slot?" has-orbit":""); + if(compact)return '
'+ + ''+ + (filled?'':"")+ + '
'; + return '
'+ + ''+String(slot+1).padStart(2,"0")+''+ + ''+escapeHtml(label)+''+status+''+ + ''+ + (routed&&filled?'':"")+ + (filled?''+ + ''+ + ''+ + '':"")+ + '
'; + } + function renderRack() { + if(!workspace||currentTab()!=="FX RACK")return; const selected=typeof currentChannel==="number"?currentChannel:0; const isMaster=typeof masterSelected!=="undefined"&&masterSelected; - const name=isMaster?"MASTER":(channels[selected]?.name||("CH "+(selected+1))); - const fx=isMaster?"":(lab.channelFxNames?.[selected]||""); - // Native route ACK is the only LIVE truth. G5B supports eight ordered - // inserts on CH2..10; CH1's existing vendor/Orbit chain stays untouched. - if(isMaster||selected!==0||(fx&&state.chain.length===0)){ - const view=window.__arMixFxLaneView?.(selected)||{}; - const ids=Array.isArray(view.ids)?view.ids:[]; - const liveIds=Array.isArray(view.live)?view.live:[]; - const liveSlots=Array.isArray(view.liveSlots)?view.liveSlots:[]; - const names=Array.isArray(view.names)?view.names:[]; - const pending=!!view.pending; - const nodes=Array.from({length:8},(_,slot)=>{ - const loaded=slot - ${String(slot+1).padStart(2,"0")} - ${escapeHtml(label)} - ${loaded?(pending?"DRAFT · not live":"Native VST3 insert"):"Empty FX slot"} - - - - - - `; - }).join(""); - workspace.innerHTML=`
- ${cardHeader("FX Rack · "+name,"Independent FX chain · one verified native graph")} -
- - - ${isMaster?"MASTER DSP unavailable":ids.length+"/8 ordered VST3 inserts"} -
-
-

${escapeHtml(name)} · FX CHAIN

-
${isMaster?'
MASTER FX not yet connected to native DSP.
':nodes}
- ${pending?'

FX DRAFT · not live until native ACK

':""} -
- - Changes require muted output, verified device epoch and positive ACK; old graph stays live on failure. -
-
-
`; - return; - } - // CH1 without a routed VST3 continues into its existing 8-slot rack. + const lane=fxLaneSnapshot(selected,isMaster); + const accepted=state.device?.dryRoutingLab?.acceptedRoute?.channels||[]; + const isBus=Array.isArray(accepted)&&accepted[selected]?.mode==="BUS"; + const name=isMaster?"MASTER":(isBus?"BUS · ":"")+ + (channels[selected]?.name||("CH "+(selected+1))); + const busTargets=Array.isArray(accepted)?accepted.flatMap((r,i)=> + r?.mode==="BUS"&&i!==selected?[i]:[]):[]; + const busAttach=busTargets.length?'
'+ + 'SEND TO EXISTING BUS'+ + ''+ + ''+ + '
':""; + const nodes=Array.from({length:8},(_,slot)=>fxSlotMarkup(lane,slot)).join(""); + const canBus=lane.mode==="legacy"||lane.mode==="routed"; + workspace.innerHTML='
'+ + cardHeader("FX Rack · "+name,"One native console layout · inserts and routing")+ + '
'+ + ''+ + ''+ + (canBus?''+ + '':"")+ + (lane.mode==="legacy"?'':"")+ + ''+(lane.mode==="master"?"MASTER FX · UNAVAILABLE": + lane.mode==="unpatched"?"PATCH INPUT TO ENABLE FX":lane.items.length+"/8 VST3 INSERTS")+'
'+ + (canBus?busAttach:"")+'

'+ + escapeHtml(name)+' · FX CHAIN

'+nodes+'
'+ + (lane.pending?'

FX DRAFT · waiting for native APPLY/ACK

':"")+ + (lane.mode==="routed"?'
'+ + 'Structural edits require muted outputs and accepted native ACK.
':"")+ + '
'; } - 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.")} -
- - - - ${state.chain.length}/8 live effects · Real-time processor chain (Channel 1) -
-
-

MIC INPUT → PROCESSING → MAIN OUTPUT

-
-
INPUT 1 / MICROPHONE
- ${state.chain.map((p,i)=>`
- ${String(i+1).padStart(2,"0")} - ${escapeHtml(p.name)}${p.latency||0} samples processing latency - - - - - -
`).join("")} - ${state.chain.length===0?'
No FX loaded yet · Click + ADD FX to insert a real VST3.
':""} - -
MASTER OUTPUT / STREAM
-
-
-

Bypass can change without stopping the audio callback. Live chain edits briefly restart processing; avoid editing FX while performing. Bypass is real-time safe.

-
`; -} function createDialog(id,title,small=false){ let overlay=document.getElementById(id); if(overlay)return overlay; @@ -721,71 +719,24 @@ } const rack=track.querySelector(".rack"); if(!rack)return; - const lab=state.device?.dryRoutingLab; - // CH1 keeps its real multi-insert rack after Audio Setup activates 10CH. - // Only use the one-slot routed presentation if CH1 has a routed FX and - // no legacy CH1 inserts. Catalog, graph and route status remain distinct. - if(lab?.active && (i!==0 || (!!lab.channelFxNames?.[0] && state.chain.length===0))){ - const view=window.__arMixFxLaneView?.(i)||{}; - const ids=view.ids||[],names=view.names||[],slots=view.liveSlots||[]; - const signature="native-rack-"+i+"-"+ids.join("|")+"-"+!!view.pending+ - "-"+slots.map(s=>s.instanceId+":"+!!s.bypassed).join("|"); - if(rack.dataset.nativeSig!==signature){ - rack.dataset.nativeSig=signature; - rack.innerHTML=Array.from({length:6},(_,slot)=>{ - const loaded=slotids.length; - const actual=!view.pending&&loaded&&slots[slot]?.catalogId===ids[slot] - ?slots[slot]:null; - return `
- - ${actual?``:""}
`; - }).join(""); - } - track.removeAttribute("data-preview");rack.removeAttribute("data-preview"); - track.title="LIVE CH "+(i+1)+" · "+ids.length+" native VST3 inserts"; - return; + const lane=fxLaneSnapshot(i); + // CH1 and all routed channels now share one physical FX strip widget. + // Only command mapping varies until CH1 vendor lease/Orbit migration. + const signature=lane.mode+"|"+lane.pending+"|"+lane.items.map((p,slot)=> + slot+":"+p.name+":"+p.bypassed+":"+p.live).join("|"); + if(rack.dataset.nativeSig!==signature){ + rack.dataset.nativeSig=signature; + rack.innerHTML=Array.from({length:6},(_,slot)=>fxSlotMarkup(lane,slot,true)).join(""); } - // Keep original CH1 multi-insert rows even when its native route is active. - 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"); - track.title=`${track.querySelector(".strip-name")?.textContent?.trim()||"Channel"} — visual preview only; native I/O not wired`; - return; + const unpatched=lane.mode==="unpatched"; + if(unpatched){ + rack.dataset.preview="1";track.dataset.preview="1"; + track.querySelectorAll(".meter-peak").forEach(el=>el.style.display="none"); + }else{ + rack.removeAttribute("data-preview");track.removeAttribute("data-preview"); } - 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,6).map((p,i)=> - `
- - -
`).join("")+ - Array.from({length:Math.max(0,6-Math.min(state.chain.length,6))},()=> - `
`).join(""); + track.title="CH "+(i+1)+" · "+lane.items.length+" VST3 inserts"+ + (unpatched?" · SOURCE UNPATCHED":""); }); } // Orbit lighting changes a class on existing rows. Never replace the row @@ -918,10 +869,24 @@ // Capture native controls before the legacy v0.3 demo handlers. document.addEventListener("click", function(e){ if(fxNativeBlockClick){fxNativeBlockClick=false;e.preventDefault();e.stopImmediatePropagation();return;} - const el=e.target.closest("[data-routed-fx],[data-routed-editor],[data-routed-bypass],[data-routed-clear],[data-routed-move],[data-routed-apply],[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]"); + const el=e.target.closest("[data-routed-fx],[data-routed-editor],[data-routed-bypass],[data-routed-clear],[data-routed-move],[data-routed-apply],[data-bus-create],[data-bus-assign],[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-bus-assign")){ + const source=typeof currentChannel==="number"?currentChannel:0; + const target=Number(document.querySelector("#rackWorkspace [data-bus-target]")?.value); + const result=window.__arMixStageSendToBus?.({source,target,kind:el.dataset.busAssign}); + toStatus(result?.message||result?.error||"Native BUS assignment unavailable"); + return; + } + if(el.hasAttribute("data-bus-create")){ + const selected=typeof currentChannel==="number"?currentChannel:0; + const result=window.__arMixStageBusFromSelected?.({ + source:selected,kind:el.dataset.busCreate}); + toStatus(result?.message||result?.error||"Native BUS controller unavailable"); + return; + } if(el.hasAttribute("data-routed-editor")){ const channel=Number(el.dataset.routedEditor),index=Number(el.dataset.routedSlot); const view=window.__arMixFxLaneView?.(channel)||{}; @@ -1042,7 +1007,7 @@ if(el.hasAttribute("data-plugin-picker")){ 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; + openPicker(el,0,state.chain.length);return; } if(el.hasAttribute("data-insert")){ const article=el.closest(".strip"); diff --git a/web/monitor.js b/web/monitor.js index a87f39449..4b85dbed5 100644 --- a/web/monitor.js +++ b/web/monitor.js @@ -279,6 +279,7 @@ const draftAux=Array.from({length:4},()=>({enabled:false,gain:1,main:true,mute:false,fxId:"",fxIds:[]})); const draftSends=[]; let mixerDraftActive=false; // Source edits from MIX/IO share this exact controller + let busDraftTarget=-1; // Protect newly created BUS unity fader from stale native readback let selectedAuxPair=null; // editor-only; not a second audio graph let draftEpoch=0; // identity of the hardware used to draw these selectors let draftMainOutputs=[]; // physical port IDs (2), never callback offsets @@ -294,6 +295,7 @@ for(const b of draftAux){b.enabled=false;b.gain=1;b.main=true;b.mute=false;b.fxId="";b.fxIds=[];} draftSends.length=0; mixerDraftActive=false; + busDraftTarget=-1; selectedAuxPair=null; draftMainOutputs=[]; draftMonitorOutputs=[]; @@ -433,6 +435,7 @@ // Changes performed on the main mixer must survive the next STRUCTURAL // APPLY; never roll back a musician's fader/PAN when editing a send. for(let i=0;i{ const d=state.dryRoutingLab||{}; rackFxDraft=null; + busDraftTarget=-1; if(!hydrateAcceptedRoute()){ invalidateDraftForNewDevice(0); invalidateDraftForNewDevice(Number(d.epoch)||0); @@ -1053,6 +1057,102 @@ document.getElementById("arRouteApply").click(); return {ok:true,message:"FX change submitted. Live only after native route ACK."}; }; + // Studio-style Bussing for CURRENT physical mixer capacity: an unused + // native CH can become a real stereo BUS receiver, not a ghost UI strip. + // True runtime ADD CHANNEL/ADD BUS requires ChannelId live graph cutover. + window.__arMixStageBusFromSelected=({source,kind}={})=>{ + const d=state.dryRoutingLab||{}; + if(!Number.isInteger(source)||source<0||source>=draftRoutes.length|| + !["group","fx"].includes(kind)) + return {ok:false,error:"Select a valid mixer channel and BUS type."}; + if(!d.active||!d.ready||!d.acceptedRoute||patchPending|| + mixerDraftActive||rackFxDraft||Number(d.epoch)!==draftEpoch) + return {ok:false,error:"Finish existing routing draft and verify the active device first."}; + if(state.monitor||state.secondaryOutputArmed) + return {ok:false,error:"MUTE/DISARM physical outputs before changing BUS topology."}; + if(draftRoutes[source].mode==="NONE") + return {ok:false,error:"Assign a real source or existing BUS to the selected channel first."}; + if(draftSends.length>=32) + return {ok:false,error:"Native send graph has reached its current 32-send budget."}; + const target=Array.from({length:draftRoutes.length},(_,i)=>draftRoutes.length-1-i) + .find(i=>i!==source&&draftRoutes[i].mode==="NONE"&& + !draftRoutes[i].fxId&&!(draftRoutes[i].fxIds||[]).length&& + !draftSends.some(edge=>edge.from===i||edge.to===i)); + if(target===undefined) + return {ok:false,error:"No unused native strip for BUS. Existing 10CH engine is full; dynamic ChannelId expansion is not yet LIVE."}; + // FX SEND preserves dry-to-MAIN; GROUP reroutes its direct output to + // prevent unintentional dry doubling (sends to other destinations remain). + const row=draftRoutes[target]; + const previousRow={...row,fxIds:row.fxIds?.slice()||[]}; + const sourceWasMain=draftRoutes[source].main; + row.mode="BUS";row.channelFormat="STEREO"; + row.left=-1;row.right=-1;row.gain=1;row.pan=0; + row.main=true;row.mute=false;row.solo=false;row.fxId="";row.fxIds=[]; + if(kind==="group")draftRoutes[source].main=false; + draftSends.push({from:source,to:target,tap:"POST", + gain:kind==="fx"?0.25:1,pan:0}); + const issue=patchPreflight(); + if(issue){ + draftSends.pop(); + if(kind==="group")draftRoutes[source].main=sourceWasMain; + Object.assign(row,previousRow); + return {ok:false,error:"BUS rejected by native route preflight: "+issue}; + } + mixerDraftActive=true; + busDraftTarget=target; + window.dispatchEvent(new Event("arMixRoutingDraftChanged")); + openRoutingLab(); // Exactly the existing route authority; NO live sound yet. + patchFeedback("BUS DRAFT · CH "+(source+1)+" → CH "+(target+1)+ + (kind==="fx"?" FX SEND":" SUBGROUP")+ + " · MUTE → APPLY → native ACK. Channel/Bus count remains 10."); + return {ok:true,target,kind, + message:"CH "+(target+1)+" staged as "+(kind==="fx"?"FX BUS":"GROUP BUS")+ + "; real audio ONLY after native APPLY and ACK."}; + }; + // Existing-BUS multi-source routing shares the SAME native DAG and ACK. + // No fake CH11, new AudioProcessorGraph or additional audio callback. + window.__arMixStageSendToBus=({source,target,kind}={})=>{ + const d=state.dryRoutingLab||{}; + if(!Number.isInteger(source)||source<0||source>=draftRoutes.length|| + !Number.isInteger(target)||target<0||target>=draftRoutes.length|| + !["group","fx"].includes(kind)) + return {ok:false,error:"Invalid channel, native BUS or route mode."}; + if(source===target)return {ok:false,error:"Feedback: BUS cannot send to itself."}; + if(!d.active||!d.ready||!d.acceptedRoute||patchPending|| + mixerDraftActive||rackFxDraft||Number(d.epoch)!==draftEpoch) + return {ok:false,error:"Finish existing draft and verify native device first."}; + if(state.monitor||state.secondaryOutputArmed) + return {ok:false,error:"MUTE/DISARM physical outputs before assigning a BUS."}; + if(draftRoutes[source].mode==="NONE"||draftRoutes[target].mode!=="BUS") + return {ok:false,error:"Source must be patched and destination an existing BUS."}; + if(!Array.isArray(d.acceptedRoute.channels)|| + d.acceptedRoute.channels[target]?.mode!=="BUS") + return {ok:false,error:"BUS is not accepted in the native graph."}; + if(draftSends.length>=32)return {ok:false,error:"Native 32-send budget reached."}; + if(draftSends.some(s=>s.from===source&&s.to===target)) + return {ok:false,error:"BUS already receives this channel; edit its SEND instead."}; + if(kind==="group"&&!draftRoutes[source].main&& + draftSends.some(s=>s.from===source&&s.to<10&&draftRoutes[s.to]?.mode==="BUS")) + return {ok:false,error:"Source already belongs to a subgroup; remove old route first."}; + const originalMain=draftRoutes[source].main; + if(kind==="group")draftRoutes[source].main=false; + draftSends.push({from:source,to:target,tap:"POST",gain:kind==="fx"?0.25:1,pan:0}); + const issue=patchPreflight(); + if(issue){ + draftSends.pop(); + draftRoutes[source].main=originalMain; + return {ok:false,error:"BUS send rejected: "+issue}; + } + mixerDraftActive=true; + window.dispatchEvent(new Event("arMixRoutingDraftChanged")); + openRoutingLab(); // Only DRAFT; native graph remains unchanged. + patchFeedback("SEND DRAFT · CH "+(source+1)+" → BUS CH "+(target+1)+ + " · "+(kind==="fx"?"PARALLEL FX":"SUBGROUP")+ + " · MUTE → APPLY → native ACK."); + return {ok:true,source,target,kind, + message:"CH "+(source+1)+" → BUS CH "+(target+1)+ + " staged; only LIVE after native route ACK."}; + }; window.__arMixOpenRoutingLab=openRoutingLab; document.getElementById("arPatchHardwareSetup")?.addEventListener("click",()=>{ window.__arMixOpenAudioIO?.("inputs"); @@ -1605,7 +1705,7 @@ rackFxDraft=null; // Native ACK became authoritative, not the browser draft. mixerDraftActive=false; sendResumeGain.clear(); - if(result.acceptedRoute)hydrateAcceptedRoute(); + if(result.acceptedRoute){busDraftTarget=-1;hydrateAcceptedRoute();} else { // CLEAR resets CH, FX, and the new R2 CH→AUX matrix draft together. invalidateDraftForNewDevice(0);