From 046ff7bf61c376e8daf7b0dfc2d34836e7d39134 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 12:45:38 +0700 Subject: [PATCH 01/15] M1 live console: coalesced ACK-backed continuous AUX sends and bus master faders --- AR-MIX-Live-FX-Host-Standalone-v0.3.html | 40 ++++++++++++++++------- tests/mixer_io_operator_contract_test.mjs | 16 +++++++++ web/mixer-io.js | 40 ++++++++++++++++------- web/monitor.js | 38 ++++++++++++++++++--- 4 files changed, 106 insertions(+), 28 deletions(-) diff --git a/AR-MIX-Live-FX-Host-Standalone-v0.3.html b/AR-MIX-Live-FX-Host-Standalone-v0.3.html index afbc1c25b..4e9f7e1a5 100644 --- a/AR-MIX-Live-FX-Host-Standalone-v0.3.html +++ b/AR-MIX-Live-FX-Host-Standalone-v0.3.html @@ -3501,9 +3501,8 @@ refresh();drawSendEditor(); } - // MS5 Sends-on-Faders: no second audio model. One native POST send per channel - // is edited only on release/keyboard; drag movement paints CSS without - // rebuilding the mixer, invoking plugins, or dispatching audio parameters. + // M1: one native POST send, one in-flight ACK per edge, coalesced continuous + // drag input (not a per-pointer DOM rerender, FX action or structural APPLY). function leaveSof(){ if(sofDrag){document.removeEventListener('pointermove',sofMove); sofDrag.slider.classList.remove('is-dragging');sofDrag=null;} @@ -3621,7 +3620,9 @@ sofDrag=null; document.removeEventListener('pointermove',sofMove); d.slider.classList.remove('is-dragging'); - if(!cancel&&Math.abs(d.db-d.startDb)>0.005)sofStage(d.ch,'gain',+sofGain(d.db).toFixed(7)); + if(cancel&&d.sent)sofStage(d.ch,'gain',+sofGain(d.startDb).toFixed(7)); + else if(!cancel&&Math.abs(d.db-d.startDb)>0.005) + sofStage(d.ch,'gain',+sofGain(d.db).toFixed(7)); else refresh(); } function sofMove(event){ @@ -3629,6 +3630,15 @@ if(!d||d.pointerId!==event.pointerId)return; d.db=Math.max(-60,Math.min(0,d.startDb+(d.startY-event.clientY)*60/d.travel)); if(d.slider.isConnected)sofPaintLayer(d.slider.closest('.arSofLayer'),sofGain(d.db)); + // Native ACK backpressure keeps at most one pending IPC command. While + // dragging, only the latest target is retained; the audio DSP de-zippers. + const now=performance.now(); + if(Math.abs(d.db-d.lastSentDb)>=.25 && now-d.lastSentAt>=25){ + const response=window.__arMixSetLiveAuxSendGain?.({ + from:d.ch,bus:sofBus,gain:+sofGain(d.db).toFixed(7)}); + if(response?.ok){d.sent=true;d.lastSentDb=d.db;d.lastSentAt=now;} + else if(response?.error)sofStatus(response.error); + } } document.addEventListener('pointerdown',event=>{ const slider=event.target.closest?.('[data-sof-fader]'); @@ -3637,7 +3647,8 @@ if(!item||s.pending||s.epoch!==sofEpoch)return; const rect=slider.getBoundingClientRect(); sofDrag={ch,slider,pointerId:event.pointerId,startY:event.clientY, - travel:Math.max(24,rect.height-18),startDb:sofDb(item.gain),db:sofDb(item.gain)}; + travel:Math.max(24,rect.height-18),startDb:sofDb(item.gain),db:sofDb(item.gain), + lastSentDb:sofDb(item.gain),lastSentAt:0,sent:false}; slider.classList.add('is-dragging'); slider.setPointerCapture?.(event.pointerId); document.addEventListener('pointermove',sofMove,{passive:true}); @@ -4372,18 +4383,23 @@ lastSignature='';refresh(); } },true); - // AUX return fader updates only after release/keyboard change; native - // DSP ramps it inside one callback. Never touch the MAIN fader or rack. - sofControls.addEventListener('change',event=>{ - if(event.target.matches('[data-sof-bus]')){sofMessage='';refresh();return;} + // AUX MASTER is a real continuous parameter as well; input and release + // share the same bounded native ACK/coalescing controller. + const sendAuxMaster=event=>{ if(!event.target.matches('[data-aux-master]'))return; const bus=Number(sofControls.querySelector('[data-sof-bus]').value); const db=Number(event.target.value); const gain=db<=-60?0:Math.pow(10,db/20); const answer=window.__arMixSetLiveAuxMasterGain?.(bus,+gain.toFixed(7)); - sofMessage=answer?.ok?'AUX MASTER · WAIT NATIVE ACK': - answer?.error||'AUX master unavailable'; - refresh(); + if(!answer?.ok)sofMessage=answer?.error||'AUX master unavailable'; + const read=sofControls.querySelector('[data-aux-master-read]'); + if(read)read.textContent=db<=-60?'OFF':db.toFixed(1)+' dB'; + }; + sofControls.addEventListener('input',sendAuxMaster); + sofControls.addEventListener('change',event=>{ + if(event.target.matches('[data-sof-bus]')){sofMessage='';refresh();return;} + if(!event.target.matches('[data-aux-master]'))return; + sendAuxMaster(event); }); // Channel focus is intentionally lightweight: point into existing MIX // modes and native controller, never create a parallel mixer/FX model. diff --git a/tests/mixer_io_operator_contract_test.mjs b/tests/mixer_io_operator_contract_test.mjs index 9e5baeaf7..6a8b29f97 100644 --- a/tests/mixer_io_operator_contract_test.mjs +++ b/tests/mixer_io_operator_contract_test.mjs @@ -275,3 +275,19 @@ test('SOURCE2 selected-channel popover selects verified physical ports without a assert.match(js,/NONADJACENT L\/R/); assert.doesNotMatch(js,/new AudioContext\(/); }); + + +test('M1 faders send continuous coalesced ACK-backed params without structural APPLY',()=>{ + const gui=read('web/mixer-io.js'),monitor=read('web/monitor.js'),html=read('AR-MIX-Live-FX-Host-Standalone-v0.3.html'); + assert.match(gui,/sofControls\.addEventListener\('input',sendAuxMaster\)/); + assert.match(gui,/const now=performance\.now\(\)/); + assert.match(gui,/Math\.abs\(d\.db-d\.lastSentDb\)>=\.25/); + assert.match(gui,/window\.__arMixSetLiveAuxSendGain\?\.\(/); + assert.match(monitor,/const liveSendLatest=new Map\(\)/); + assert.match(monitor,/const auxMasterLatest=new Map\(\)/); + assert.match(monitor,/LIVE SEND COALESCED/); + assert.match(monitor,/AUX MASTER COALESCED/); + assert.match(monitor,/if\(matched&&latest!==undefined/); + assert.match(monitor,/if\(ok&&latest!==undefined/); + assert.match(html,/Math\.abs\(d\.db-d\.lastSentDb\)>=\.25/); +}); diff --git a/web/mixer-io.js b/web/mixer-io.js index bfe9c5914..f63098622 100644 --- a/web/mixer-io.js +++ b/web/mixer-io.js @@ -248,9 +248,8 @@ refresh();drawSendEditor(); } - // MS5 Sends-on-Faders: no second audio model. One native POST send per channel - // is edited only on release/keyboard; drag movement paints CSS without - // rebuilding the mixer, invoking plugins, or dispatching audio parameters. + // M1: one native POST send, one in-flight ACK per edge, coalesced continuous + // drag input (not a per-pointer DOM rerender, FX action or structural APPLY). function leaveSof(){ if(sofDrag){document.removeEventListener('pointermove',sofMove); sofDrag.slider.classList.remove('is-dragging');sofDrag=null;} @@ -368,7 +367,9 @@ sofDrag=null; document.removeEventListener('pointermove',sofMove); d.slider.classList.remove('is-dragging'); - if(!cancel&&Math.abs(d.db-d.startDb)>0.005)sofStage(d.ch,'gain',+sofGain(d.db).toFixed(7)); + if(cancel&&d.sent)sofStage(d.ch,'gain',+sofGain(d.startDb).toFixed(7)); + else if(!cancel&&Math.abs(d.db-d.startDb)>0.005) + sofStage(d.ch,'gain',+sofGain(d.db).toFixed(7)); else refresh(); } function sofMove(event){ @@ -376,6 +377,15 @@ if(!d||d.pointerId!==event.pointerId)return; d.db=Math.max(-60,Math.min(0,d.startDb+(d.startY-event.clientY)*60/d.travel)); if(d.slider.isConnected)sofPaintLayer(d.slider.closest('.arSofLayer'),sofGain(d.db)); + // Native ACK backpressure keeps at most one pending IPC command. While + // dragging, only the latest target is retained; the audio DSP de-zippers. + const now=performance.now(); + if(Math.abs(d.db-d.lastSentDb)>=.25 && now-d.lastSentAt>=25){ + const response=window.__arMixSetLiveAuxSendGain?.({ + from:d.ch,bus:sofBus,gain:+sofGain(d.db).toFixed(7)}); + if(response?.ok){d.sent=true;d.lastSentDb=d.db;d.lastSentAt=now;} + else if(response?.error)sofStatus(response.error); + } } document.addEventListener('pointerdown',event=>{ const slider=event.target.closest?.('[data-sof-fader]'); @@ -384,7 +394,8 @@ if(!item||s.pending||s.epoch!==sofEpoch)return; const rect=slider.getBoundingClientRect(); sofDrag={ch,slider,pointerId:event.pointerId,startY:event.clientY, - travel:Math.max(24,rect.height-18),startDb:sofDb(item.gain),db:sofDb(item.gain)}; + travel:Math.max(24,rect.height-18),startDb:sofDb(item.gain),db:sofDb(item.gain), + lastSentDb:sofDb(item.gain),lastSentAt:0,sent:false}; slider.classList.add('is-dragging'); slider.setPointerCapture?.(event.pointerId); document.addEventListener('pointermove',sofMove,{passive:true}); @@ -1119,18 +1130,23 @@ lastSignature='';refresh(); } },true); - // AUX return fader updates only after release/keyboard change; native - // DSP ramps it inside one callback. Never touch the MAIN fader or rack. - sofControls.addEventListener('change',event=>{ - if(event.target.matches('[data-sof-bus]')){sofMessage='';refresh();return;} + // AUX MASTER is a real continuous parameter as well; input and release + // share the same bounded native ACK/coalescing controller. + const sendAuxMaster=event=>{ if(!event.target.matches('[data-aux-master]'))return; const bus=Number(sofControls.querySelector('[data-sof-bus]').value); const db=Number(event.target.value); const gain=db<=-60?0:Math.pow(10,db/20); const answer=window.__arMixSetLiveAuxMasterGain?.(bus,+gain.toFixed(7)); - sofMessage=answer?.ok?'AUX MASTER · WAIT NATIVE ACK': - answer?.error||'AUX master unavailable'; - refresh(); + if(!answer?.ok)sofMessage=answer?.error||'AUX master unavailable'; + const read=sofControls.querySelector('[data-aux-master-read]'); + if(read)read.textContent=db<=-60?'OFF':db.toFixed(1)+' dB'; + }; + sofControls.addEventListener('input',sendAuxMaster); + sofControls.addEventListener('change',event=>{ + if(event.target.matches('[data-sof-bus]')){sofMessage='';refresh();return;} + if(!event.target.matches('[data-aux-master]'))return; + sendAuxMaster(event); }); // Channel focus is intentionally lightweight: point into existing MIX // modes and native controller, never create a parallel mixer/FX model. diff --git a/web/monitor.js b/web/monitor.js index 55a12b7ea..3b92a57a9 100644 --- a/web/monitor.js +++ b/web/monitor.js @@ -1181,6 +1181,10 @@ // Creating/removing sends, editing PRE/PAN or enabling AUX is STRUCTURAL. let liveSendRequestId=1; const liveSendPending=new Map(); + // Bounded last-write-wins coalescing: one native request in flight per edge. + // No route/GUI state is promoted until ACK; no unbounded pointer backlog. + const liveSendLatest=new Map(); + const liveSendInFlightGain=new Map(); window.__arMixSetLiveAuxSendGain=({from,bus,gain}={})=>{ const fault=sendEditGate(from,bus); if(fault)return {ok:false,error:fault}; @@ -1192,8 +1196,6 @@ if(!Array.isArray(d.acceptedRoute?.sends)) return {ok:false,error:"No acknowledged native AUX send graph."}; const key=sendKey(from,bus,"POST"); - if(liveSendPending.has(key)) - return {ok:false,error:"Wait for the previous native send ACK."}; const source=d.acceptedRoute.sends.find(s=>s.from===from&& s.to===10+bus&&s.tap==="POST"); if(!source) @@ -1201,7 +1203,16 @@ if(!draftAux[bus]?.enabled||!draftSends.some(s=>s.from===from&& s.to===10+bus&&s.tap==="POST")) return {ok:false,error:"AUX return or accepted POST send unavailable."}; + if(liveSendPending.has(key)){ + // Replace the target; only the latest gesture is useful to the engine. + if(Math.abs(n-liveSendInFlightGain.get(key))<1e-7)liveSendLatest.delete(key); + else liveSendLatest.set(key,n); + return {ok:true,pending:true,queued:true,message:"LIVE SEND COALESCED · WAIT ACK"}; + } + if(Math.abs(n-Number(source.gain))<1e-7) + return {ok:true,unchanged:true,message:"LIVE SEND ALREADY ACKNOWLEDGED"}; const requestId=liveSendRequestId++; + liveSendInFlightGain.set(key,n); liveSendPending.set(key,requestId); api.emitEvent("arMixAction",{action:"routingAuxSendGain", requestId,from,bus,deviceEpoch:Number(d.epoch),revision:Number(d.revision), @@ -1213,6 +1224,7 @@ const key=sendKey(from,bus,"POST"); if(liveSendPending.get(key)!==Number(ack?.requestId))return; liveSendPending.delete(key); + liveSendInFlightGain.delete(key); const next=ack?.state||{},current=state.dryRoutingLab||{}; const matched=ack?.ok===true && next.epoch===current.epoch && next.revision===current.revision&&next.acceptedRoute; @@ -1226,11 +1238,18 @@ detail:{ok:!!matched,from,bus,gain:Number(ack?.gain), error:matched?"":String(ack?.error||"Native route changed; gain NOT applied")} })); + const latest=liveSendLatest.get(key); + liveSendLatest.delete(key); + // The ACK has updated the one authoritative accepted route; no speculative LIVE. + if(matched&&latest!==undefined&&Math.abs(latest-Number(ack.gain))>=1e-7) + window.__arMixSetLiveAuxSendGain({from,bus,gain:latest}); }); // M1 AUX MASTER: one existing enabled FX-return fader, ACK and epoch bound. // Structural AUX enabling/mute/toMaster/FX replacement still uses APPLY. let auxMasterRequestId=1; const auxMasterPending=new Map(); + const auxMasterLatest=new Map(); + const auxMasterInFlightGain=new Map(); window.__arMixSetLiveAuxMasterGain=(bus,value)=>{ const d=state.dryRoutingLab||{},gain=Number(value); if(!Number.isInteger(bus)||bus<0||bus>=4||!Number.isFinite(gain)|| @@ -1240,9 +1259,15 @@ rackFxDraft||!Array.isArray(d.acceptedRoute.auxes)|| !d.acceptedRoute.auxes[bus]?.enabled) return {ok:false,error:"AUX master unavailable: finish DRAFT and APPLY the enabled bus first."}; - if(auxMasterPending.has(bus)) - return {ok:false,error:"Wait for previous AUX master native ACK."}; + if(auxMasterPending.has(bus)){ + if(Math.abs(gain-auxMasterInFlightGain.get(bus))<1e-7)auxMasterLatest.delete(bus); + else auxMasterLatest.set(bus,gain); + return {ok:true,pending:true,queued:true,message:"AUX MASTER COALESCED · WAIT ACK"}; + } + if(Math.abs(gain-Number(d.acceptedRoute.auxes[bus].gain))<1e-7) + return {ok:true,unchanged:true,message:"AUX MASTER ALREADY ACKNOWLEDGED"}; const requestId=auxMasterRequestId++; + auxMasterInFlightGain.set(bus,gain); auxMasterPending.set(bus,requestId); api.emitEvent("arMixAction",{action:"routingAuxBusGain", bus,requestId,deviceEpoch:Number(d.epoch),revision:Number(d.revision), @@ -1253,6 +1278,7 @@ const bus=Number(ack?.bus),id=Number(ack?.requestId); if(auxMasterPending.get(bus)!==id)return; auxMasterPending.delete(bus); + auxMasterInFlightGain.delete(bus); const next=ack?.state||{},now=state.dryRoutingLab||{}; const ok=ack?.ok===true&&next.epoch===now.epoch&& next.revision===now.revision&&next.acceptedRoute&&!patchPending&& @@ -1266,6 +1292,10 @@ window.dispatchEvent(new CustomEvent("arMixAuxMasterGainResult",{ detail:{ok:!!ok,bus,gain:Number(ack?.gain), error:ok?"":String(ack?.error||"AUX native ACK stale; refresh device")}})); + const latest=auxMasterLatest.get(bus); + auxMasterLatest.delete(bus); + if(ok&&latest!==undefined&&Math.abs(latest-Number(ack.gain))>=1e-7) + window.__arMixSetLiveAuxMasterGain(bus,latest); }); window.__arMixStageAuxReturnEdit=(bus,field,value)=>{ const fault=sendEditGate(0,bus); From b195d5f958da9d944e5cd7437049ebb20c0f70ea Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 12:46:51 +0700 Subject: [PATCH 02/15] M1 named input profiles: strict device pin identity, mono/stereo aliases and native source picker --- AR-MIX-Live-FX-Host-Standalone-v0.3.html | 131 +++++++++++++++++++++- tests/mixer_io_operator_contract_test.mjs | 16 +++ web/mixer-io.css | 13 +++ web/mixer-io.js | 118 ++++++++++++++++++- 4 files changed, 274 insertions(+), 4 deletions(-) diff --git a/AR-MIX-Live-FX-Host-Standalone-v0.3.html b/AR-MIX-Live-FX-Host-Standalone-v0.3.html index 4e9f7e1a5..c1d4da60f 100644 --- a/AR-MIX-Live-FX-Host-Standalone-v0.3.html +++ b/AR-MIX-Live-FX-Host-Standalone-v0.3.html @@ -2169,6 +2169,19 @@ .arSourceChoice:hover:not(:disabled),.arSourceAdvanced:hover{border-color:#8dbcc5} .arSourceChoice:disabled{opacity:.45;cursor:default} .arSourceChooserNote{font-size:10px;line-height:1.5;color:#bbcad1;margin-top:8px} + +/* M1 logical sources: small, scrollable, driver-verified naming controls. */ +.arSourceSearch{box-sizing:border-box;width:100%;background:#0e2630;color:#e1f0f3;border:1px solid #466877;border-radius:3px;padding:7px 8px;font:11px 'Segoe UI',Arial,sans-serif;margin-bottom:7px} +.arSourceAliasRow{display:flex;align-items:stretch;gap:4px} +.arSourceAliasRow .arSourceChoice{flex:1;min-width:0} +.arSourceAliasRemove{flex:0 0 25px;border:1px solid #476473;border-radius:3px;background:#21313b;color:#adc4cc;cursor:pointer} +.arSourceAliasManager{border-top:1px solid #385463;margin-top:7px;padding-top:6px;color:#bdcfd5;font-size:10px} +.arSourceAliasManager summary{cursor:pointer;font:600 10px 'Segoe UI',Arial,sans-serif;letter-spacing:.04em} +.arSourceAliasFields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:5px;margin:7px 0} +.arSourceAliasFields input,.arSourceAliasFields select{box-sizing:border-box;min-width:0;width:100%;background:#0f2631;color:#e2ebef;border:1px solid #496876;border-radius:3px;padding:6px 5px;font:10px 'Segoe UI',Arial,sans-serif} +.arSourceAliasFields [data-source-alias-name]{grid-column:span 2} +.arSourceAliasFields [data-source-alias-save]{grid-column:span 2} +.arSourceAliasFields small{font:10px 'Segoe UI',Arial,sans-serif}
@@ -3281,6 +3294,57 @@ if(current!=='NONE'&&!options.some(v=>v[0]===current))options.push([current,'CUSTOM L/R · PATCH']); return options; }; + + // M1 named logical inputs: PRESENTATION aliases for verified native hardware + // pins. Every choice still commits through the single native route authority. + // Profile is bound to backend + capture device + the entire active pin/name + // signature; never remap silently when the driver or enabled pins change. + const aliasStorePrefix='armix:named-source:v1:'; + let aliasCacheKey='',aliasCache=[]; + const sourceIdentity=s=>{ + const d=deviceInventory?.active,pins=portList(s),enabled=d?.enabledInputs; + if(!isNative()||!s.ready||!d?.open||!d.backend||!d.captureDevice|| + !Array.isArray(enabled)||!pins.length||pins.length!==enabled.length)return ''; + const p=pins.map(x=>x.port).sort((a,b)=>a-b); + const e=enabled.map(Number).sort((a,b)=>a-b); + if(!p.every((v,i)=>v===e[i]))return ''; + const names=Array.isArray(d.inputNames)?d.inputNames:[]; + if(!pins.every(x=>names[x.port]===x.label))return ''; + // Device names are NOT guaranteed stable operating-system IDs; on any + // changed label/pin list, the prior aliases are deliberately unavailable. + return aliasStorePrefix+encodeURIComponent(JSON.stringify([ + d.backend,d.captureDevice,pins.map(x=>[x.port,x.label]).sort((a,b)=>a[0]-b[0])])); + }; + const validAlias=(a,pins)=>{ + const used=new Set(pins.map(x=>x.port)); + return !!a&&typeof a.name==='string'&&a.name.length>0&&a.name.length<=32&& + (a.mode==='MONO'||a.mode==='STEREO')&& + Number.isInteger(a.left)&&used.has(a.left)&& + (a.mode==='MONO'?(a.right===-1): + Number.isInteger(a.right)&&a.left!==a.right&&used.has(a.right)); + }; + const sourceAliases=s=>{ + const key=sourceIdentity(s); + if(key!==aliasCacheKey){ + aliasCacheKey=key;aliasCache=[]; + if(key)try { + const value=JSON.parse(localStorage.getItem(key)||'[]'); + if(Array.isArray(value))aliasCache=value.slice(0,32).filter(x=>validAlias(x,portList(s))); + }catch{} // blocked storage does not interrupt native routing + } + return key?aliasCache:[]; + }; + const saveSourceAliases=(s,items)=>{ + const key=sourceIdentity(s); + if(!key)return false; + try { + localStorage.setItem(key,JSON.stringify(items)); + aliasCacheKey=key;aliasCache=items; + return true; + }catch{return false;} + }; + const aliasValue=a=>a.mode+':'+a.left+(a.mode==='STEREO'?':'+a.right:''); + const namedRoute=(s,r)=>sourceAliases(s).find(a=>aliasValue(a)===valueFor(r)); const outputLabel=s=>{ const out=s.mainOutputs?.length===2?s.mainOutputs:s.outputPorts||[]; return s.ready&&Number.isInteger(out[0])&&Number.isInteger(out[1])? @@ -3324,6 +3388,7 @@ source=(names(r.left)||'L'+(Number(r.left)+1))+' / '+ (names(r.right)||'R'+(Number(r.right)+1)); if(ack&&r.mode==='BUS')source='INTERNAL BUS'; + if(ack&&r.mode!=='NONE'&&r.mode!=='BUS')source=namedRoute(s,r)?.name||source; if(!ack)source='NO NATIVE ACK'; const routed=ack?lastStatus.dryRoutingLab?.fxInstances?.[i]:null; const inserts=Array.isArray(routed)?routed.length:0; @@ -3353,11 +3418,16 @@ sourceChooser.hidden=true; sourceChooser.setAttribute('role','dialog'); sourceChooser.setAttribute('aria-label','Choose verified channel input source'); - sourceChooser.innerHTML='
INPUT SOURCE
'; + sourceChooser.innerHTML='
INPUT SOURCE
MANAGE NAMED INPUTS
Requires a verified device inventory; routes still require native ACK.
'; host.insertBefore(sourceChooser,mixer); let sourceChooserChannel=-1; const sourceChoices=sourceChooser.querySelector('[data-source-choices]'); const sourceNote=sourceChooser.querySelector('[data-source-note]'); + const aliasNameInput=sourceChooser.querySelector('[data-source-alias-name]'); + const aliasLeft=sourceChooser.querySelector('[data-source-alias-left]'); + const aliasRight=sourceChooser.querySelector('[data-source-alias-right]'); + const aliasMode=sourceChooser.querySelector('[data-source-alias-mode]'); + const aliasSearch=sourceChooser.querySelector('[data-source-search]'); const closeSourceChooser=()=>{ sourceChooser.hidden=true;sourceChooserChannel=-1; }; @@ -3370,7 +3440,27 @@ const pins=portList(s); const values=portsFor(s,r||{mode:'NONE',left:-1,right:-1}); const current=valueFor(r); + const aliases=sourceAliases(s),search=aliasSearch.value.trim().toLowerCase(); + const matched=title=>!search||title.toLowerCase().includes(search); + if(aliases.length){ + for(let i=0;i[String(p.port),portName(p)]); + populate(aliasLeft,pinOptions,previousLeft||String(pins[0]?.port??'')); + populate(aliasRight,pinOptions,previousRight||String(pins[1]?.port??pins[0]?.port??'')); + aliasRight.disabled=aliasMode.value!=='STEREO'; + const identified=!!sourceIdentity(s); + sourceChooser.querySelector('[data-source-alias-save]').disabled=!identified; + sourceChooser.querySelector('[data-source-alias-help]').textContent=identified? + 'Saved for this verified device and enabled-pin layout · native ACK required': + 'Awaiting actual driver inventory; naming disabled until hardware is verified'; sourceNote.textContent=!s.ready?'No verified native driver input ports': s.monitor?'MUTE OUTPUT to safely change SOURCE · no automatic unmute': 'Selecting SOURCE commits via existing native routing; wait for ACK'; @@ -3390,9 +3490,35 @@ const openSourceChooser=channel=>{ if(!Number.isInteger(channel)||channel<0||channel>=10)return; sourceChooserChannel=channel;sourceChooser.hidden=false; + if(!sourceIdentity(route()))deviceRefresh(); // cached JUCE readback, not a vendor rescan renderSourceChooser(); }; + sourceChooser.addEventListener('input',event=>{ + if(event.target===aliasSearch)renderSourceChooser(); + }); + aliasMode.addEventListener('change',()=>{aliasRight.disabled=aliasMode.value!=='STEREO';}); sourceChooser.addEventListener('click',event=>{ + const remove=event.target.closest('[data-source-alias-remove]'); + if(remove){ + const s=route(),items=sourceAliases(s).slice(),index=Number(remove.dataset.sourceAliasRemove); + if(Number.isInteger(index)&&index>=0&&indexi!==index))){ + sourceNote.textContent='SOURCE NAME REMOVED · live hardware route unchanged'; + renderSourceChooser();refreshFocus(s); + }return; + } + if(event.target.closest('[data-source-alias-save]')){ + const s=route(),a={name:aliasNameInput.value.trim(),mode:aliasMode.value, + left:Number(aliasLeft.value),right:aliasMode.value==='MONO'?-1:Number(aliasRight.value)}; + if(!validAlias(a,portList(s))){sourceNote.textContent='INVALID NAME OR HARDWARE L/R PAIR';return;} + const items=sourceAliases(s).filter(x=>x.name.toLowerCase()!==a.name.toLowerCase()); + if(items.length>=32){sourceNote.textContent='32 NAMED SOURCES MAXIMUM';return;} + if(saveSourceAliases(s,[...items,a])){ + aliasNameInput.value='';aliasSearch.value='';renderSourceChooser();refreshFocus(s); + sourceNote.textContent='NAMED SOURCE SAVED · choose it to request native routing'; + }else sourceNote.textContent='DEVICE/LOCAL STORAGE UNAVAILABLE · not saved'; + return; + } if(event.target.closest('[data-source-close]')){closeSourceChooser();return;} if(event.target.closest('[data-source-advanced]')){ const ch=sourceChooserChannel;closeSourceChooser();openIO('inputs',ch);return; @@ -4590,6 +4716,7 @@ const hadDraft=deviceDirty(); deviceInventory=d; if(!hadDraft&&!deviceBusy)deviceDraft=makeDeviceDraft(); + if(!sourceChooser.hidden){renderSourceChooser();refreshFocus(route());} if(d?.scanState==='SCANNED') deviceNote='DEVICE LIST REFRESHED · '+Number(d.scanDurationMs||0).toFixed(0)+' ms · output remains MUTED'; else if(d?.scanState==='BLOCKED_ARMED') diff --git a/tests/mixer_io_operator_contract_test.mjs b/tests/mixer_io_operator_contract_test.mjs index 6a8b29f97..a20058015 100644 --- a/tests/mixer_io_operator_contract_test.mjs +++ b/tests/mixer_io_operator_contract_test.mjs @@ -291,3 +291,19 @@ test('M1 faders send continuous coalesced ACK-backed params without structural A assert.match(monitor,/if\(ok&&latest!==undefined/); assert.match(html,/Math\.abs\(d\.db-d\.lastSentDb\)>=\.25/); }); + + +test('M1 named input sources are persisted only for native device and enabled pin identity',()=>{ + const ui=read('web/mixer-io.js'); + const html=read('AR-MIX-Live-FX-Host-Standalone-v0.3.html'); + for(const src of [ui,html]){ + assert.match(src,/const sourceIdentity=s=>/); + assert.match(src,/d\.backend,d\.captureDevice,pins\.map/); + assert.match(src,/const validAlias=\(a,pins\)=>/); + assert.match(src,/localStorage\.setItem\(key,JSON\.stringify\(items\)\)/); + assert.match(src,/const aliasValue=a=>/); + assert.match(src,/window\.__arMixCommitMutedSource\?\.\(/); + assert.match(src,/data-source-alias-save/); + assert.match(src,/if\(!sourceIdentity\(route\(\)\)\)deviceRefresh\(\)/); + } +}); diff --git a/web/mixer-io.css b/web/mixer-io.css index 171a37819..661847f49 100644 --- a/web/mixer-io.css +++ b/web/mixer-io.css @@ -512,3 +512,16 @@ .arSourceChoice:hover:not(:disabled),.arSourceAdvanced:hover{border-color:#8dbcc5} .arSourceChoice:disabled{opacity:.45;cursor:default} .arSourceChooserNote{font-size:10px;line-height:1.5;color:#bbcad1;margin-top:8px} + +/* M1 logical sources: small, scrollable, driver-verified naming controls. */ +.arSourceSearch{box-sizing:border-box;width:100%;background:#0e2630;color:#e1f0f3;border:1px solid #466877;border-radius:3px;padding:7px 8px;font:11px 'Segoe UI',Arial,sans-serif;margin-bottom:7px} +.arSourceAliasRow{display:flex;align-items:stretch;gap:4px} +.arSourceAliasRow .arSourceChoice{flex:1;min-width:0} +.arSourceAliasRemove{flex:0 0 25px;border:1px solid #476473;border-radius:3px;background:#21313b;color:#adc4cc;cursor:pointer} +.arSourceAliasManager{border-top:1px solid #385463;margin-top:7px;padding-top:6px;color:#bdcfd5;font-size:10px} +.arSourceAliasManager summary{cursor:pointer;font:600 10px 'Segoe UI',Arial,sans-serif;letter-spacing:.04em} +.arSourceAliasFields{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:5px;margin:7px 0} +.arSourceAliasFields input,.arSourceAliasFields select{box-sizing:border-box;min-width:0;width:100%;background:#0f2631;color:#e2ebef;border:1px solid #496876;border-radius:3px;padding:6px 5px;font:10px 'Segoe UI',Arial,sans-serif} +.arSourceAliasFields [data-source-alias-name]{grid-column:span 2} +.arSourceAliasFields [data-source-alias-save]{grid-column:span 2} +.arSourceAliasFields small{font:10px 'Segoe UI',Arial,sans-serif} diff --git a/web/mixer-io.js b/web/mixer-io.js index f63098622..94ad8074b 100644 --- a/web/mixer-io.js +++ b/web/mixer-io.js @@ -28,6 +28,57 @@ if(current!=='NONE'&&!options.some(v=>v[0]===current))options.push([current,'CUSTOM L/R · PATCH']); return options; }; + + // M1 named logical inputs: PRESENTATION aliases for verified native hardware + // pins. Every choice still commits through the single native route authority. + // Profile is bound to backend + capture device + the entire active pin/name + // signature; never remap silently when the driver or enabled pins change. + const aliasStorePrefix='armix:named-source:v1:'; + let aliasCacheKey='',aliasCache=[]; + const sourceIdentity=s=>{ + const d=deviceInventory?.active,pins=portList(s),enabled=d?.enabledInputs; + if(!isNative()||!s.ready||!d?.open||!d.backend||!d.captureDevice|| + !Array.isArray(enabled)||!pins.length||pins.length!==enabled.length)return ''; + const p=pins.map(x=>x.port).sort((a,b)=>a-b); + const e=enabled.map(Number).sort((a,b)=>a-b); + if(!p.every((v,i)=>v===e[i]))return ''; + const names=Array.isArray(d.inputNames)?d.inputNames:[]; + if(!pins.every(x=>names[x.port]===x.label))return ''; + // Device names are NOT guaranteed stable operating-system IDs; on any + // changed label/pin list, the prior aliases are deliberately unavailable. + return aliasStorePrefix+encodeURIComponent(JSON.stringify([ + d.backend,d.captureDevice,pins.map(x=>[x.port,x.label]).sort((a,b)=>a[0]-b[0])])); + }; + const validAlias=(a,pins)=>{ + const used=new Set(pins.map(x=>x.port)); + return !!a&&typeof a.name==='string'&&a.name.length>0&&a.name.length<=32&& + (a.mode==='MONO'||a.mode==='STEREO')&& + Number.isInteger(a.left)&&used.has(a.left)&& + (a.mode==='MONO'?(a.right===-1): + Number.isInteger(a.right)&&a.left!==a.right&&used.has(a.right)); + }; + const sourceAliases=s=>{ + const key=sourceIdentity(s); + if(key!==aliasCacheKey){ + aliasCacheKey=key;aliasCache=[]; + if(key)try { + const value=JSON.parse(localStorage.getItem(key)||'[]'); + if(Array.isArray(value))aliasCache=value.slice(0,32).filter(x=>validAlias(x,portList(s))); + }catch{} // blocked storage does not interrupt native routing + } + return key?aliasCache:[]; + }; + const saveSourceAliases=(s,items)=>{ + const key=sourceIdentity(s); + if(!key)return false; + try { + localStorage.setItem(key,JSON.stringify(items)); + aliasCacheKey=key;aliasCache=items; + return true; + }catch{return false;} + }; + const aliasValue=a=>a.mode+':'+a.left+(a.mode==='STEREO'?':'+a.right:''); + const namedRoute=(s,r)=>sourceAliases(s).find(a=>aliasValue(a)===valueFor(r)); const outputLabel=s=>{ const out=s.mainOutputs?.length===2?s.mainOutputs:s.outputPorts||[]; return s.ready&&Number.isInteger(out[0])&&Number.isInteger(out[1])? @@ -71,6 +122,7 @@ source=(names(r.left)||'L'+(Number(r.left)+1))+' / '+ (names(r.right)||'R'+(Number(r.right)+1)); if(ack&&r.mode==='BUS')source='INTERNAL BUS'; + if(ack&&r.mode!=='NONE'&&r.mode!=='BUS')source=namedRoute(s,r)?.name||source; if(!ack)source='NO NATIVE ACK'; const routed=ack?lastStatus.dryRoutingLab?.fxInstances?.[i]:null; const inserts=Array.isArray(routed)?routed.length:0; @@ -100,11 +152,16 @@ sourceChooser.hidden=true; sourceChooser.setAttribute('role','dialog'); sourceChooser.setAttribute('aria-label','Choose verified channel input source'); - sourceChooser.innerHTML='
INPUT SOURCE
'; + sourceChooser.innerHTML='
INPUT SOURCE
MANAGE NAMED INPUTS
Requires a verified device inventory; routes still require native ACK.
'; host.insertBefore(sourceChooser,mixer); let sourceChooserChannel=-1; const sourceChoices=sourceChooser.querySelector('[data-source-choices]'); const sourceNote=sourceChooser.querySelector('[data-source-note]'); + const aliasNameInput=sourceChooser.querySelector('[data-source-alias-name]'); + const aliasLeft=sourceChooser.querySelector('[data-source-alias-left]'); + const aliasRight=sourceChooser.querySelector('[data-source-alias-right]'); + const aliasMode=sourceChooser.querySelector('[data-source-alias-mode]'); + const aliasSearch=sourceChooser.querySelector('[data-source-search]'); const closeSourceChooser=()=>{ sourceChooser.hidden=true;sourceChooserChannel=-1; }; @@ -117,7 +174,27 @@ const pins=portList(s); const values=portsFor(s,r||{mode:'NONE',left:-1,right:-1}); const current=valueFor(r); + const aliases=sourceAliases(s),search=aliasSearch.value.trim().toLowerCase(); + const matched=title=>!search||title.toLowerCase().includes(search); + if(aliases.length){ + for(let i=0;i[String(p.port),portName(p)]); + populate(aliasLeft,pinOptions,previousLeft||String(pins[0]?.port??'')); + populate(aliasRight,pinOptions,previousRight||String(pins[1]?.port??pins[0]?.port??'')); + aliasRight.disabled=aliasMode.value!=='STEREO'; + const identified=!!sourceIdentity(s); + sourceChooser.querySelector('[data-source-alias-save]').disabled=!identified; + sourceChooser.querySelector('[data-source-alias-help]').textContent=identified? + 'Saved for this verified device and enabled-pin layout · native ACK required': + 'Awaiting actual driver inventory; naming disabled until hardware is verified'; sourceNote.textContent=!s.ready?'No verified native driver input ports': s.monitor?'MUTE OUTPUT to safely change SOURCE · no automatic unmute': 'Selecting SOURCE commits via existing native routing; wait for ACK'; @@ -137,9 +224,35 @@ const openSourceChooser=channel=>{ if(!Number.isInteger(channel)||channel<0||channel>=10)return; sourceChooserChannel=channel;sourceChooser.hidden=false; + if(!sourceIdentity(route()))deviceRefresh(); // cached JUCE readback, not a vendor rescan renderSourceChooser(); }; + sourceChooser.addEventListener('input',event=>{ + if(event.target===aliasSearch)renderSourceChooser(); + }); + aliasMode.addEventListener('change',()=>{aliasRight.disabled=aliasMode.value!=='STEREO';}); sourceChooser.addEventListener('click',event=>{ + const remove=event.target.closest('[data-source-alias-remove]'); + if(remove){ + const s=route(),items=sourceAliases(s).slice(),index=Number(remove.dataset.sourceAliasRemove); + if(Number.isInteger(index)&&index>=0&&indexi!==index))){ + sourceNote.textContent='SOURCE NAME REMOVED · live hardware route unchanged'; + renderSourceChooser();refreshFocus(s); + }return; + } + if(event.target.closest('[data-source-alias-save]')){ + const s=route(),a={name:aliasNameInput.value.trim(),mode:aliasMode.value, + left:Number(aliasLeft.value),right:aliasMode.value==='MONO'?-1:Number(aliasRight.value)}; + if(!validAlias(a,portList(s))){sourceNote.textContent='INVALID NAME OR HARDWARE L/R PAIR';return;} + const items=sourceAliases(s).filter(x=>x.name.toLowerCase()!==a.name.toLowerCase()); + if(items.length>=32){sourceNote.textContent='32 NAMED SOURCES MAXIMUM';return;} + if(saveSourceAliases(s,[...items,a])){ + aliasNameInput.value='';aliasSearch.value='';renderSourceChooser();refreshFocus(s); + sourceNote.textContent='NAMED SOURCE SAVED · choose it to request native routing'; + }else sourceNote.textContent='DEVICE/LOCAL STORAGE UNAVAILABLE · not saved'; + return; + } if(event.target.closest('[data-source-close]')){closeSourceChooser();return;} if(event.target.closest('[data-source-advanced]')){ const ch=sourceChooserChannel;closeSourceChooser();openIO('inputs',ch);return; @@ -1337,6 +1450,7 @@ const hadDraft=deviceDirty(); deviceInventory=d; if(!hadDraft&&!deviceBusy)deviceDraft=makeDeviceDraft(); + if(!sourceChooser.hidden){renderSourceChooser();refreshFocus(route());} if(d?.scanState==='SCANNED') deviceNote='DEVICE LIST REFRESHED · '+Number(d.scanDurationMs||0).toFixed(0)+' ms · output remains MUTED'; else if(d?.scanState==='BLOCKED_ARMED') From 717d65fb0ed1e95886891b80a13db2d4e520f408 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 12:50:16 +0700 Subject: [PATCH 03/15] M1 GUI regression: device-verified named sparse stereo source and strict remap rejection --- tests/mixer_io_smoke.py | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/mixer_io_smoke.py b/tests/mixer_io_smoke.py index 1dcef4813..ef78339ed 100644 --- a/tests/mixer_io_smoke.py +++ b/tests/mixer_io_smoke.py @@ -642,6 +642,56 @@ async def main(): }""",status) assert 'LIVE' in await page.locator('[data-io-quick-row="2"] .arIOQuickState').inner_text() assert 'LIVE' in await page.locator('[data-io-quick-row="5"] .arIOQuickState').inner_text() + # M1: a user-defined sparse stereo pair is selectable in CHANNEL SOURCE + # only when the real device identity and *all* active pins match. + await page.evaluate("""()=>window.__armixTestEmit('arMixAudioDeviceInventory',{ + currentType:'ASIO', + active:{backend:'ASIO',captureDevice:'MAONO PS22',playbackDevice:'MAONO PS22', + open:true,deviceGeneration:51,enabledInputs:[0,1,4,7], + inputNames:['MAONO Mic In 1','MAONO Mic In 2','Unused 3','Unused 4', + 'MAONO VC In L','Unused 6','Unused 7','MAONO VC In R']}, + types:[{name:'ASIO',active:true,separate:false, + inputs:['MAONO PS22'],outputs:['MAONO PS22']}]})""") + await page.locator('#arIOOverlay [data-io-close]').click() + await page.locator('[data-focus-step="source"]').click() + await page.locator('.arSourceAliasManager summary').click() + await page.locator('[data-source-alias-name]').fill('MAONO Virtual Stereo') + await page.locator('[data-source-alias-mode]').select_option('STEREO') + await page.locator('[data-source-alias-left]').select_option('4') + await page.locator('[data-source-alias-right]').select_option('7') + assert await page.locator('[data-source-alias-save]').is_enabled() + await page.locator('[data-source-alias-save]').click() + named=page.locator('[data-source-choice="STEREO:4:7"]') + assert await named.count()==1 + assert 'MAONO Virtual Stereo' in await named.inner_text() + selected=await page.evaluate("""()=>Number( + document.querySelector('.strip[data-strip].selected')?.dataset.strip||0)""") + await named.click() + native=await page.evaluate("""()=>window.__armixTestActions.filter(x=> + x.name==='arMixAction'&&x.data.action==='routingDryApply')""") + assert len(native)==2,native + target=native[-1]['data']['value']['channels'][selected] + assert target['mode']=='STEREO' and target['left']==4 and target['right']==7,target + status=await page.evaluate("""({status,selected})=>{ + status.dryRoutingLab.revision=5; + status.dryRoutingLab.acceptedRoute.channels[selected]={ + ...status.dryRoutingLab.acceptedRoute.channels[selected], + mode:'STEREO',left:4,right:7}; + window.__armixTestEmit('arMixRoutingLabAck',{ok:true,state:status.dryRoutingLab}); + window.__armixTestEmit('arMixStatus',status); + return status; + }""",{"status":status,"selected":selected}) + assert 'MAONO Virtual Stereo' in await page.locator('[data-focus-source]').inner_text() + # An altered pin mask must NOT inherit the saved alias or silently remap. + await page.evaluate("""()=>window.__armixTestEmit('arMixAudioDeviceInventory',{ + currentType:'ASIO', + active:{backend:'ASIO',captureDevice:'MAONO PS22',playbackDevice:'MAONO PS22', + open:true,deviceGeneration:52,enabledInputs:[0,1,4], + inputNames:['MAONO Mic In 1','MAONO Mic In 2','Unused 3','Unused 4','MAONO VC In L']}, + types:[{name:'ASIO',active:true,separate:false, + inputs:['MAONO PS22'],outputs:['MAONO PS22']}]})""") + assert await page.locator('[data-source-choice="STEREO:4:7"]').count()==0 + 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 await browser.close() From cc685ca7c3ad60cc36a1a40343a7c4a81e2970be Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 12:52:16 +0700 Subject: [PATCH 04/15] Fix M1 alias remap assertion: distinguish named identity from raw CUSTOM route; cover queued send backpressure --- tests/mixer_io_smoke.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tests/mixer_io_smoke.py b/tests/mixer_io_smoke.py index ef78339ed..89ae68abd 100644 --- a/tests/mixer_io_smoke.py +++ b/tests/mixer_io_smoke.py @@ -303,6 +303,15 @@ async def main(): live_actions=await page.evaluate("""()=>window.__armixTestActions.filter( x=>x.name==='arMixAction'&&x.data.action==='routingAuxSendGain')""") assert len(live_actions)==1,live_actions + # During the first native ACK flight, newer moves must only replace + # one queued value. Returning to the in-flight target drops the queue. + queued=await page.evaluate("""()=>({ + first:window.__arMixSetLiveAuxSendGain({from:0,bus:0,gain:.3}), + second:window.__arMixSetLiveAuxSendGain({from:0,bus:0,gain:1}), + count:window.__armixTestActions.filter(x=> + x.name==='arMixAction'&&x.data.action==='routingAuxSendGain').length + })""") + assert queued['first']['queued'] and queued['second']['queued'] and queued['count']==1,queued gain_command=live_actions[-1]['data'] assert gain_command['from']==0 and gain_command['bus']==0 assert gain_command['deviceEpoch']==4 and gain_command['revision']==5 @@ -690,7 +699,9 @@ async def main(): inputNames:['MAONO Mic In 1','MAONO Mic In 2','Unused 3','Unused 4','MAONO VC In L']}, types:[{name:'ASIO',active:true,separate:false, inputs:['MAONO PS22'],outputs:['MAONO PS22']}]})""") - assert await page.locator('[data-source-choice="STEREO:4:7"]').count()==0 + # The old pin route may still appear as CUSTOM for inspection; the + # device-bound named alias itself MUST disappear on mask mismatch. + assert await page.locator('.arSourceAliasRow [data-source-choice="STEREO:4:7"]').count()==0 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 From 2027d5ddf48234b7a1400a746fec8acaf1b187f1 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 12:55:16 +0700 Subject: [PATCH 05/15] M1 RT input crossfade: same prepared graph, one packed atomic source pair, 64-sample ramp --- engine/core/LiveChannelFxGraph.h | 3 ++ engine/core/PreparedMixerBlock.h | 83 ++++++++++++++++++++++++++++---- 2 files changed, 76 insertions(+), 10 deletions(-) diff --git a/engine/core/LiveChannelFxGraph.h b/engine/core/LiveChannelFxGraph.h index 4083c7051..fff61df01 100644 --- a/engine/core/LiveChannelFxGraph.h +++ b/engine/core/LiveChannelFxGraph.h @@ -165,6 +165,9 @@ class LiveChannelFxGraph final { int monitorOutputLeft() const noexcept{return monitorLeft_;} int monitorOutputRight() const noexcept{return monitorRight_;} const std::array& monitorGains() const noexcept{return monitorGains_;} + bool switchPhysicalSource(int strip,SourceMode mode,int left,int right) noexcept { + return block_&&block_->setPhysicalSource(strip,mode,left,right); + } // M1: native realtime send fader on an EXISTING validated AUX POST edge. // Same prepared graph, no VST instance change or global mute. bool setAuxBusGain(int bus,float gain) noexcept { diff --git a/engine/core/PreparedMixerBlock.h b/engine/core/PreparedMixerBlock.h index 9f685b40d..d6e1e7692 100644 --- a/engine/core/PreparedMixerBlock.h +++ b/engine/core/PreparedMixerBlock.h @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -174,6 +175,13 @@ class PreparedMixerBlock final { : 0u, 0.f) { if (!validCapacity(maxFrames)) capacity_=0; + for(int i=0;i=stripCount||mode==SourceMode::disconnected|| + plan_.channels.base.strips[strip].mode!=mode)return false; + const int n=plan_.channels.inputPorts.enabledCount; + if(left<0||left>=n||right<0||right>=n|| + (mode==SourceMode::mono&&left!=right)|| + (mode==SourceMode::stereo&&left==right))return false; + physicalTarget_[strip].store(packSourcePair(left,right), + std::memory_order_release); + return true; + } + // Message-thread-only target update; immutable edge topology/pan/FX ownership. // Only an ALREADY EXISTING POST edge may be adjusted while output is live. // This index lookup is on CONTROL, never inside the audio callback. @@ -296,16 +319,45 @@ class PreparedMixerBlock final { const auto& source=graph.channels.base.strips[strip]; // Incoming sends are already in l/r. Add actual hardware only // when that port is valid; never overwrite internal bus returns. - if (source.mode!=SourceMode::disconnected && - physical && source.inputA>=0 && - source.inputA=0 && source.inputB(pair&0xffffu); + const int b=static_cast((pair>>16)&0xffffu); + return pair!=invalidSourcePair&&a(fade.target&0xffffu); + const int b=static_cast((fade.target>>16)&0xffffu); + if(fade.remaining==0){ + if(valid(fade.target))for(int f=0;f(fade.previous&0xffffu); + const int oldB=static_cast((fade.previous>>16)&0xffffu); + const bool oldGood=valid(fade.previous),newGood=valid(fade.target); + for(int f=0;f(--fade.remaining)/64.f; + if(oldGood){l[f]+=physical[oldA][f]*(1.f-t); + r[f]+=physical[oldB][f]*(1.f-t);} + if(newGood){l[f]+=physical[a][f]*t; + r[f]+=physical[b][f]*t;} + if(fade.remaining==0){ + if(newGood)for(int j=f+1;j(left)| + (static_cast(right)<<16); + } + struct PhysicalSourceFade final { + std::uint32_t previous=invalidSourcePair,target=invalidSourcePair; + int remaining=0; // callback-thread-only, never shared with GUI + }; // Audio-thread exclusive smoothing state plus atomically published gain // targets. No lock, heap, plugin recreation or per-block graph compile. // POST/PRE edge identity and normalized PAN are immutable per revision. @@ -487,6 +548,8 @@ class PreparedMixerBlock final { std::array right_{}; std::array auxLeft_{},auxRight_{}; std::array preGate_{},lastGainL_{},lastGainR_{}; + std::array,stripCount> physicalTarget_{}; + std::array physicalBlend_{}; std::array,maxAuxSends> auxTarget_{}; std::array auxApplied_{}; // callback thread exclusive std::array,auxBusCount> auxBusTarget_{}; From c7252d4178c2322a528adc897d8057b8632feaf6 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 12:56:10 +0700 Subject: [PATCH 06/15] M1 native source switch: verified sparse port binding, epoch fencing and same-graph PCM ramp ACK --- src/LiveAudioEngine.h | 11 +++++++++ src/LiveDryRoutingLab.h | 49 +++++++++++++++++++++++++++++++++++++++++ src/Main.cpp | 29 ++++++++++++++++++++++++ 3 files changed, 89 insertions(+) diff --git a/src/LiveAudioEngine.h b/src/LiveAudioEngine.h index b7d07a3c9..00332c672 100644 --- a/src/LiveAudioEngine.h +++ b/src/LiveAudioEngine.h @@ -1028,6 +1028,17 @@ class LiveAudioEngine final : private juce::AudioIODeviceCallback setOutputMuted(true); // never expose CH1 unexpectedly on STOP dryRoutingLab_.disable(); } + juce::String switchDryRoutingLabSource(int strip,std::uint64_t epoch, + std::uint64_t revision,const juce::String& mode, + int left,int right) noexcept { + if(independent_.active()||routeReconfiguring_.load(std::memory_order_acquire)|| + handoff_.busy()||!directFence_.permitted()|| + diagnosticRoute_.load(std::memory_order_acquire) + !=armix::diagnostics::Route::normal|| + savedDirectSetup_||savedLiveSetup_) + return "SOURCE SWITCH: live DIRECT device or graph unavailable"; + return dryRoutingLab_.switchPhysicalSource(strip,epoch,revision,mode,left,right); + } bool setDryRoutingLabParameter(int strip,std::uint64_t epoch, std::uint64_t revision,const juce::String& parameter, float value) noexcept { diff --git a/src/LiveDryRoutingLab.h b/src/LiveDryRoutingLab.h index fb0437c13..a363870cd 100644 --- a/src/LiveDryRoutingLab.h +++ b/src/LiveDryRoutingLab.h @@ -436,6 +436,55 @@ class LiveDryRoutingLab final { } } + // M1 direct-source parameter: only same-format physical→physical + // input on an ALREADY scheduled channel. Route DAG, VST3 lease, FX + // identity and hardware output ownership are immutable. Epoch/revision + // and actual enabled sparse port mask are checked on CONTROL thread. + juce::String switchPhysicalSource(int strip,std::uint64_t expectedEpoch, + std::uint64_t expectedRevision,const juce::String& mode, + int physicalLeft,int physicalRight) noexcept { + if(strip<0||strip>=count||!hasExplicitRoute()|| + expectedEpoch!=epoch()||expectedRevision!=revision()|| + topologyFault_.load(std::memory_order_acquire)) + return "SOURCE SWITCH: stale native device, graph or channel"; + if(mode!="MONO"&&mode!="STEREO") + return "SOURCE SWITCH: existing MONO/STEREO format required"; + auto channels=acceptedRoute_.getProperty("channels",juce::var()); + auto* rows=channels.getArray(); + if(!rows||rows->size()!=count) + return "SOURCE SWITCH: missing accepted input routing"; + auto& row=rows->getReference(strip); + if(row.getProperty("mode",{}).toString()!=mode) + return "SOURCE SWITCH: channel format/topology change requires MUTE + APPLY"; + const int n=portCount_.load(std::memory_order_acquire); + int callbackLeft=-1,callbackRight=-1; + for(int i=0;isetProperty("left",physicalLeft); + object->setProperty("right",mode=="STEREO"?physicalRight:-1); + } + return {}; + } + // Native live control path. Only the JUCE message thread writes. No // graph recompilation, VST3 instantiation or callback detach. // Browser carries the exact acknowledged route token to reject stale diff --git a/src/Main.cpp b/src/Main.cpp index 43c7cecf8..70d18be5f 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1324,6 +1324,35 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr // A user-controlled hardware dry routing FAT, not a change to the // existing 1-channel VST3 production chain. Explicit Apply/Stop. + // M1 RT source switch on an existing physical channel. Unlike + // structural routingDryApply, it does not unpatch outputs, rebuild + // VST3s, or restart the device; input PCM fades inside one graph. + if(action=="routingSourceSwitch"){ + const int requestId=static_cast(args.getProperty("requestId",0)); + const int channel=static_cast(args.getProperty("channel",-1)); + const auto mode=args.getProperty("mode",juce::var()).toString(); + const auto ep=args.getProperty("deviceEpoch",juce::var()); + const auto rv=args.getProperty("revision",juce::var()); + const int left=static_cast(args.getProperty("left",-1)); + const int right=static_cast(args.getProperty("right",-1)); + const juce::String error=requestId>0&&!ep.isVoid()&&!rv.isVoid()&& + !nativeShowBusy_&&!studioBackupBusy_? + engine_.switchDryRoutingLabSource(channel, + static_cast(static_cast(ep)), + static_cast(static_cast(rv)), + mode,left,right): + juce::String("SOURCE SWITCH: stale request or Show/backup busy"); + auto ack=std::make_unique(); + ack->setProperty("requestId",requestId); + ack->setProperty("channel",channel); + ack->setProperty("ok",error.isEmpty()); + ack->setProperty("error",error); + ack->setProperty("state",engine_.status().getProperty("dryRoutingLab",{})); + if(browser_.loaded)browser_.emitEventIfBrowserIsVisible( + "arMixSourceSwitchAck",juce::var(ack.release())); + if(error.isNotEmpty())emitNotice(error,true); + return; + } if (action == "routingDryApply") { LiveDryRoutingLab::FxSelections selected{}; From 57fa6e66abe0d49c89b7d3c5c7a0ed793908a967 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 12:57:03 +0700 Subject: [PATCH 07/15] M1 native-ACKed same-format SOURCE quick handoff in single monitor.js route authority --- web/monitor.js | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/web/monitor.js b/web/monitor.js index 3b92a57a9..45203b531 100644 --- a/web/monitor.js +++ b/web/monitor.js @@ -1393,6 +1393,55 @@ return {ok:true,pending:true,epoch:Number(d.epoch), message:"SOURCE PENDING · native ACK required; output remains MUTED."}; }; + + // M1 input-only same-format crossfade. This updates one atomic physical PCM + // source in the existing native graph, never changes FX/bus/output topology. + let liveSourceRequestId=1,liveSourcePending=null; + window.__arMixCommitSelectedSource=(channel,mode,left,right)=>{ + const d=state.dryRoutingLab||{},r=d.acceptedRoute?.channels?.[channel]; + if(!r||r.mode!==mode||!["MONO","STEREO"].includes(mode)) + return window.__arMixCommitMutedSource(channel,mode,left,right); + if(!d.ready||!d.active||draftEpoch!==Number(d.epoch)|| + patchPending||mixerDraftActive||rackFxDraft||nativeShowBusy|| + studioBackupBusy||liveSendPending.size) + return {ok:false,error:"Finish native APPLY, FX/SEND draft or Show before SOURCE switching."}; + if(liveSourcePending)return {ok:false,error:"Wait for previous SOURCE native ACK."}; + const active=new Set(patchPorts().map(p=>p.port)); + if(!active.has(left)||(mode==="STEREO"&&(!active.has(right)||left===right))) + return {ok:false,error:"SOURCE requires verified enabled driver pins."}; + const targetRight=mode==="STEREO"?right:-1; + if(r.left===left&&r.right===targetRight) + return {ok:true,unchanged:true,message:"SOURCE ALREADY ACKNOWLEDGED"}; + const id=liveSourceRequestId++; + liveSourcePending={id,channel,mode,left,right:targetRight, + epoch:Number(d.epoch),revision:Number(d.revision)}; + api.emitEvent("arMixAction",{action:"routingSourceSwitch", + requestId:id,channel,mode,left,right:targetRight, + deviceEpoch:Number(d.epoch),revision:Number(d.revision)}); + return {ok:true,pending:true,live:true,epoch:Number(d.epoch), + message:"LIVE INPUT CROSSFADE · WAIT NATIVE ACK"}; + }; + api.addEventListener("arMixSourceSwitchAck",ack=>{ + const p=liveSourcePending; + if(!p||Number(ack?.requestId)!==p.id||Number(ack?.channel)!==p.channel)return; + liveSourcePending=null; + const next=ack?.state||{},old=state.dryRoutingLab||{}; + const accepted=next.acceptedRoute?.channels?.[p.channel]; + const ok=ack?.ok===true&&Number(next.epoch)===p.epoch&& + Number(next.revision)===p.revision&&Number(old.epoch)===p.epoch&& + Number(old.revision)===p.revision&&accepted?.mode===p.mode&& + accepted.left===p.left&&accepted.right===p.right; + if(ok){ + state.dryRoutingLab=next; + hydrateAcceptedRoute(); + renderPatchMatrix();updateRouteLabIdentity(); + window.dispatchEvent(new Event("arMixRoutingDraftChanged")); + } + window.dispatchEvent(new CustomEvent("arMixSourceSwitchResult",{detail:{ + ok,channel:p.channel, + error:ok?"":String(ack?.error||"Source changed or native ACK mismatch") + }})); + }); window.__arMixOpenChannelPatch=(channel,tab="input")=>{ if(!Number.isInteger(channel)||channel<0||channel>=10)return; openRoutingLab(); From 95f1259f215a07d8d079e69b9753e2d86a99d71e Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 12:59:14 +0700 Subject: [PATCH 08/15] Wire M1 same-format native crossfade into selected SOURCE and strip input with ACK-safe UI --- AR-MIX-Live-FX-Host-Standalone-v0.3.html | 29 ++++++++++++++++------- tests/mixer_io_operator_contract_test.mjs | 22 +++++++++++++++-- web/mixer-io.js | 29 ++++++++++++++++------- 3 files changed, 62 insertions(+), 18 deletions(-) diff --git a/AR-MIX-Live-FX-Host-Standalone-v0.3.html b/AR-MIX-Live-FX-Host-Standalone-v0.3.html index c1d4da60f..a669b27cd 100644 --- a/AR-MIX-Live-FX-Host-Standalone-v0.3.html +++ b/AR-MIX-Live-FX-Host-Standalone-v0.3.html @@ -3451,7 +3451,7 @@ const button=node('button','arSourceChoice',label); button.type='button';button.dataset.sourceChoice=value; button.setAttribute('aria-pressed',String(value===current)); - button.disabled=!!s.pending||!s.ready; + button.disabled=!!s.pending||!!quickSourcePending||!s.ready; line.appendChild(button); const remove=node('button','arSourceAliasRemove','×'); remove.type='button';remove.dataset.sourceAliasRemove=String(i); @@ -3467,7 +3467,7 @@ const button=node('button','arSourceChoice',title); button.type='button';button.dataset.sourceChoice=value; button.setAttribute('aria-pressed',String(value===current)); - button.disabled=!!s.pending||!s.ready; + button.disabled=!!s.pending||!!quickSourcePending||!s.ready; sourceChoices.appendChild(button); } const advanced=node('button','arSourceAdvanced','ADVANCED PATCH · NONADJACENT L/R'); @@ -3484,8 +3484,8 @@ 'Saved for this verified device and enabled-pin layout · native ACK required': 'Awaiting actual driver inventory; naming disabled until hardware is verified'; sourceNote.textContent=!s.ready?'No verified native driver input ports': - s.monitor?'MUTE OUTPUT to safely change SOURCE · no automatic unmute': - 'Selecting SOURCE commits via existing native routing; wait for ACK'; + s.monitor?'Same-format physical input changes use native 64-sample crossfade · new patch or format requires MUTE': + 'Choose verified source; native ACK required before it is LIVE'; }; const openSourceChooser=channel=>{ if(!Number.isInteger(channel)||channel<0||channel>=10)return; @@ -3528,7 +3528,7 @@ const [mode,a,b]=button.dataset.sourceChoice.split(':'); if(!['NONE','MONO','STEREO'].includes(mode))return; const channel=sourceChooserChannel; - const outcome=window.__arMixCommitMutedSource?.( + const outcome=window.__arMixCommitSelectedSource?.( channel,mode,mode==='NONE'?-1:Number(a),mode==='STEREO'?Number(b):-1); sourceNote.textContent=outcome?.ok? outcome.pending?'SOURCE PENDING · WAIT NATIVE ACK': @@ -3536,7 +3536,7 @@ outcome?.error||'Native source route rejected'; if(!outcome?.ok)return; if(outcome.pending)quickSourcePending={ - channel,epoch:outcome.epoch,value:button.dataset.sourceChoice}; + channel,epoch:outcome.epoch,value:button.dataset.sourceChoice,live:!!outcome.live}; renderSourceChooser(); }); // MS5: explicit Sends-on-Faders control, scoped to a single real AUX return. @@ -4456,10 +4456,10 @@ const value=select.value,parts=value.split(':'); const mode=parts[0],left=mode==='NONE'?-1:Number(parts[1]),right=mode==='STEREO'?Number(parts[2]):-1; const direct=select.classList.contains('arBankSource'); - const response=direct?window.__arMixCommitMutedSource?.(channel,mode,left,right): + const response=direct?window.__arMixCommitSelectedSource?.(channel,mode,left,right): window.__arMixStageChannelInput?.(channel,mode,left,right); if(response?.pending)quickSourcePending={channel,epoch:response.epoch, - value:valueFor({mode,left,right})}; + value:valueFor({mode,left,right}),live:!!response.live}; if(!response?.ok){ const message=response?.error||'Native INPUT PATCH unavailable'; el('arIOFeedback').textContent=message; @@ -4756,6 +4756,19 @@ renderSourceChooser(); } }); + window.addEventListener('arMixSourceSwitchResult',event=>{ + const result=event.detail||{}; + if(quickSourcePending?.live&&quickSourcePending.channel===result.channel) + quickSourcePending=null; + const s=route(); + lastSignature='';refresh(); + if(!sourceChooser.hidden){ + renderSourceChooser(); + sourceNote.textContent=result.ok? + 'SOURCE ACK · 64-SAMPLE INPUT CROSSFADE · FX AND BUS UNCHANGED': + 'SOURCE REJECTED · '+(result.error||'Verified route unchanged'); + } + }); window.addEventListener('arMixRoutingDraftChanged',()=>{lastSignature='';refresh();}); window.addEventListener('arMixAuxMasterGainResult',event=>{ const ack=event.detail||{}; diff --git a/tests/mixer_io_operator_contract_test.mjs b/tests/mixer_io_operator_contract_test.mjs index a20058015..38f7f3621 100644 --- a/tests/mixer_io_operator_contract_test.mjs +++ b/tests/mixer_io_operator_contract_test.mjs @@ -268,7 +268,7 @@ test('SOURCE2 selected-channel popover selects verified physical ports without a const js=read('web/mixer-io.js'); assert.match(js,/function refreshFocus\(s\)/); assert.match(js,/const openSourceChooser=channel=>/); - assert.match(js,/window\.__arMixCommitMutedSource\?\.\(/); + assert.match(js,/window\.__arMixCommitSelectedSource\?\.\(/); assert.match(js,/sourceNote\.textContent/); assert.match(js,/sourceChooser\.addEventListener\('click'/); assert.match(js,/portsFor\(s,r\|\|/); @@ -302,8 +302,26 @@ test('M1 named input sources are persisted only for native device and enabled pi assert.match(src,/const validAlias=\(a,pins\)=>/); assert.match(src,/localStorage\.setItem\(key,JSON\.stringify\(items\)\)/); assert.match(src,/const aliasValue=a=>/); - assert.match(src,/window\.__arMixCommitMutedSource\?\.\(/); + assert.match(src,/window\.__arMixCommitSelectedSource\?\.\(/); assert.match(src,/data-source-alias-save/); assert.match(src,/if\(!sourceIdentity\(route\(\)\)\)deviceRefresh\(\)/); } }); + + +test('M1 SOURCE safe unmuted handoff uses native input crossfade with immutable FX graph',()=>{ + const ui=read('web/mixer-io.js'),monitor=read('web/monitor.js'); + const main=read('src/Main.cpp'),engine=read('src/LiveAudioEngine.h'); + const lab=read('src/LiveDryRoutingLab.h'),block=read('engine/core/PreparedMixerBlock.h'); + assert.match(ui,/window\.__arMixCommitSelectedSource\?\.\(/); + assert.match(ui,/arMixSourceSwitchResult/); + assert.match(monitor,/window\.__arMixCommitSelectedSource=/); + assert.match(monitor,/action:"routingSourceSwitch"/); + assert.match(monitor,/arMixSourceSwitchAck/); + assert.match(main,/action=="routingSourceSwitch"/); + assert.match(engine,/switchDryRoutingLabSource\(/); + assert.match(lab,/switchPhysicalSource\(/); + assert.match(block,/physicalTarget_\[strip\]\.store/); + assert.match(block,/fade\.remaining=64/); + assert.doesNotMatch(ui,/new AudioContext\(/); +}); diff --git a/web/mixer-io.js b/web/mixer-io.js index 94ad8074b..07cb98ad9 100644 --- a/web/mixer-io.js +++ b/web/mixer-io.js @@ -185,7 +185,7 @@ const button=node('button','arSourceChoice',label); button.type='button';button.dataset.sourceChoice=value; button.setAttribute('aria-pressed',String(value===current)); - button.disabled=!!s.pending||!s.ready; + button.disabled=!!s.pending||!!quickSourcePending||!s.ready; line.appendChild(button); const remove=node('button','arSourceAliasRemove','×'); remove.type='button';remove.dataset.sourceAliasRemove=String(i); @@ -201,7 +201,7 @@ const button=node('button','arSourceChoice',title); button.type='button';button.dataset.sourceChoice=value; button.setAttribute('aria-pressed',String(value===current)); - button.disabled=!!s.pending||!s.ready; + button.disabled=!!s.pending||!!quickSourcePending||!s.ready; sourceChoices.appendChild(button); } const advanced=node('button','arSourceAdvanced','ADVANCED PATCH · NONADJACENT L/R'); @@ -218,8 +218,8 @@ 'Saved for this verified device and enabled-pin layout · native ACK required': 'Awaiting actual driver inventory; naming disabled until hardware is verified'; sourceNote.textContent=!s.ready?'No verified native driver input ports': - s.monitor?'MUTE OUTPUT to safely change SOURCE · no automatic unmute': - 'Selecting SOURCE commits via existing native routing; wait for ACK'; + s.monitor?'Same-format physical input changes use native 64-sample crossfade · new patch or format requires MUTE': + 'Choose verified source; native ACK required before it is LIVE'; }; const openSourceChooser=channel=>{ if(!Number.isInteger(channel)||channel<0||channel>=10)return; @@ -262,7 +262,7 @@ const [mode,a,b]=button.dataset.sourceChoice.split(':'); if(!['NONE','MONO','STEREO'].includes(mode))return; const channel=sourceChooserChannel; - const outcome=window.__arMixCommitMutedSource?.( + const outcome=window.__arMixCommitSelectedSource?.( channel,mode,mode==='NONE'?-1:Number(a),mode==='STEREO'?Number(b):-1); sourceNote.textContent=outcome?.ok? outcome.pending?'SOURCE PENDING · WAIT NATIVE ACK': @@ -270,7 +270,7 @@ outcome?.error||'Native source route rejected'; if(!outcome?.ok)return; if(outcome.pending)quickSourcePending={ - channel,epoch:outcome.epoch,value:button.dataset.sourceChoice}; + channel,epoch:outcome.epoch,value:button.dataset.sourceChoice,live:!!outcome.live}; renderSourceChooser(); }); // MS5: explicit Sends-on-Faders control, scoped to a single real AUX return. @@ -1190,10 +1190,10 @@ const value=select.value,parts=value.split(':'); const mode=parts[0],left=mode==='NONE'?-1:Number(parts[1]),right=mode==='STEREO'?Number(parts[2]):-1; const direct=select.classList.contains('arBankSource'); - const response=direct?window.__arMixCommitMutedSource?.(channel,mode,left,right): + const response=direct?window.__arMixCommitSelectedSource?.(channel,mode,left,right): window.__arMixStageChannelInput?.(channel,mode,left,right); if(response?.pending)quickSourcePending={channel,epoch:response.epoch, - value:valueFor({mode,left,right})}; + value:valueFor({mode,left,right}),live:!!response.live}; if(!response?.ok){ const message=response?.error||'Native INPUT PATCH unavailable'; el('arIOFeedback').textContent=message; @@ -1490,6 +1490,19 @@ renderSourceChooser(); } }); + window.addEventListener('arMixSourceSwitchResult',event=>{ + const result=event.detail||{}; + if(quickSourcePending?.live&&quickSourcePending.channel===result.channel) + quickSourcePending=null; + const s=route(); + lastSignature='';refresh(); + if(!sourceChooser.hidden){ + renderSourceChooser(); + sourceNote.textContent=result.ok? + 'SOURCE ACK · 64-SAMPLE INPUT CROSSFADE · FX AND BUS UNCHANGED': + 'SOURCE REJECTED · '+(result.error||'Verified route unchanged'); + } + }); window.addEventListener('arMixRoutingDraftChanged',()=>{lastSignature='';refresh();}); window.addEventListener('arMixAuxMasterGainResult',event=>{ const ack=event.detail||{}; From aa7e428d5750aa49c4ec99681df3e64c3451870d Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 12:59:32 +0700 Subject: [PATCH 09/15] Verify M1 source PCM sample crossfade, strict format/pin rejection and zero RT allocations --- tests/prepared_mixer_block_test.cpp | 38 +++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/prepared_mixer_block_test.cpp b/tests/prepared_mixer_block_test.cpp index f0c77d55f..80a7a31b5 100644 --- a/tests/prepared_mixer_block_test.cpp +++ b/tests/prepared_mixer_block_test.cpp @@ -149,4 +149,42 @@ int main() { assert(allocations.load(std::memory_order_relaxed)==pre); assert(near(outputL[0],.4f*.70710678f)); } + // M1 physical source: real PCM tap changes without graph recompile, + // plugin recreation, output mute or any audio-thread allocation. + { + constexpr std::array hardware {0,1,2}; + ChannelRoutingConfig ch; + ch.stripsAndMaster.strips[0]={SourceMode::mono,0,-1,1.f,0.f,false,false}; + SendRequest direct; + direct.toMaster[0]=true; + PreparedRenderGraph compiled;RenderError reason; + assert(PreparedRenderGraph::compile(ch,hardware,direct,compiled,reason)); + PreparedMixerBlock live(compiled,128); + std::array microphone{},alternate{},silent{}; + microphone.fill(.2f);alternate.fill(.8f); + const float* inputs[]={microphone.data(),alternate.data(),silent.data()}; + std::array left{},right{}; + auto fx=[](int,float*,float*,int) noexcept {}; + assert(!live.setPhysicalSource(0,SourceMode::stereo,1,2)); + assert(!live.setPhysicalSource(0,SourceMode::mono,1,2)); + assert(!live.setPhysicalSource(0,SourceMode::mono,20,20)); + assert(!live.setPhysicalSource(3,SourceMode::mono,1,1)); + assert(live.process(inputs,3,left.data(),right.data(),128,fx)); + const float old=left[127],newValue=.8f*.70710678118f; + assert(near(old,.2f*.70710678118f)); + assert(live.setPhysicalSource(0,SourceMode::mono,1,1)); + const auto allocationsBefore=allocations.load(std::memory_order_relaxed); + assert(live.process(inputs,3,left.data(),right.data(),128,fx)); + assert(allocations.load(std::memory_order_relaxed)==allocationsBefore); + assert(left[0]>old&&left[0]old&&left[0] Date: Sat, 31 Oct 2026 12:59:56 +0700 Subject: [PATCH 10/15] M1 functional GUI: armed same-format SOURCE 64-sample switch ACK, stale rejection, rollback and no structural apply --- tests/mixer_io_smoke.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/mixer_io_smoke.py b/tests/mixer_io_smoke.py index 89ae68abd..719098a00 100644 --- a/tests/mixer_io_smoke.py +++ b/tests/mixer_io_smoke.py @@ -98,6 +98,43 @@ async def main(): assert await page.evaluate("""()=>window.__armixTestActions.filter( x=>x.name==='arMixAction'&&x.data.action==='routingDryApply').length""")==1 assert (await page.evaluate("()=>window.__arMixRouteView().draftRoutes[1].mode"))=='NONE' + # M1: an ALREADY PATCHED MONO channel may change physical input + # while output is ARMED: one native source PARAM/ACK and no APPLY. + await page.locator('[data-mix-mode="FX"]').click() + await page.locator('[data-focus-step="source"]').click() + assert await page.locator('.arSourceChooser').is_visible() + await page.locator('.arSourceChoice[data-source-choice="MONO:1"]').click() + switching=await page.evaluate("""()=>window.__armixTestActions.filter(x=> + x.name==='arMixAction'&&x.data.action==='routingSourceSwitch')""") + assert len(switching)==1,switching + assert switching[0]['data']['requestId']==1 and switching[0]['data']['channel']==0 + assert switching[0]['data']['left']==1 and switching[0]['data']['deviceEpoch']==4 + assert (await page.evaluate("""()=>window.__armixTestActions.filter(x=> + x.name==='arMixAction'&&x.data.action==='routingDryApply').length"""))==1 + assert 'Microphone 1' in await page.locator('[data-focus-source]').inner_text() + # Stale request cannot impersonate the first accepted switch. + await page.evaluate("""status=>window.__armixTestEmit('arMixSourceSwitchAck',{ + ok:true,requestId:321,channel:0,state:status.dryRoutingLab})""",status) + assert 'Microphone 1' in await page.locator('[data-focus-source]').inner_text() + status=await page.evaluate("""status=>{ + status.dryRoutingLab.acceptedRoute.channels[0].left=1; + window.__armixTestEmit('arMixSourceSwitchAck',{ + ok:true,requestId:1,channel:0,state:status.dryRoutingLab}); + window.__armixTestEmit('arMixStatus',status);return status; + }""",status) + assert 'Microphone 2' in await page.locator('[data-focus-source]').inner_text() + # Restore original source to keep other mixer regression fixtures stable. + await page.locator('.arSourceChoice[data-source-choice="MONO:0"]').click() + status=await page.evaluate("""status=>{ + status.dryRoutingLab.acceptedRoute.channels[0].left=0; + window.__armixTestEmit('arMixSourceSwitchAck',{ + ok:true,requestId:2,channel:0,state:status.dryRoutingLab}); + window.__armixTestEmit('arMixStatus',status);return status; + }""",status) + assert 'Microphone 1' in await page.locator('[data-focus-source]').inner_text() + assert (await page.evaluate("""()=>window.__armixTestActions.filter(x=> + x.name==='arMixAction'&&x.data.action==='routingDryApply').length"""))==1 + await page.locator('[data-source-close]').click() await page.evaluate("""status=>{ status.monitor=false; window.__armixTestEmit('arMixStatus',status); From 0f59244068ad4ba26f3d0f02c3b8f7b1f8088b3a Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 13:00:41 +0700 Subject: [PATCH 11/15] Reconcile SOURCE1 safety contract with M1 same-format live input switching and structural fallback --- tests/mixer_io_operator_contract_test.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/mixer_io_operator_contract_test.mjs b/tests/mixer_io_operator_contract_test.mjs index 38f7f3621..898b2dc15 100644 --- a/tests/mixer_io_operator_contract_test.mjs +++ b/tests/mixer_io_operator_contract_test.mjs @@ -228,9 +228,9 @@ test('SETUP1 honest bus patch has real AUX/MAIN/MONITOR navigation, no fake GROU }); -test('SOURCE1 mute-only instant SOURCE uses one native ACK; armed output is rejected',()=>{ +test('SOURCE quick switch is live only for verified same format; structural fallback remains muted',()=>{ const io=read('web/mixer-io.js'),monitor=read('web/monitor.js'); - assert.match(io,/__arMixCommitMutedSource\?\.\(channel,mode,left,right\)/); + assert.match(io,/__arMixCommitSelectedSource\?\.\(channel,mode,left,right\)/); assert.match(io,/quickSourcePending/); assert.match(io,/PENDING · NATIVE ACK/); assert.match(monitor,/window\.__arMixCommitMutedSource=/); From f38256b807893d6eaf842a036ee688d0b6e663d7 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 13:02:53 +0700 Subject: [PATCH 12/15] Pin the selected input channel in armed SOURCE crossfade UI test --- tests/mixer_io_smoke.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/mixer_io_smoke.py b/tests/mixer_io_smoke.py index 719098a00..0e26c49e2 100644 --- a/tests/mixer_io_smoke.py +++ b/tests/mixer_io_smoke.py @@ -101,6 +101,9 @@ async def main(): # M1: an ALREADY PATCHED MONO channel may change physical input # while output is ARMED: one native source PARAM/ACK and no APPLY. await page.locator('[data-mix-mode="FX"]').click() + # SOURCE follows the selected strip, not the previous editable row. + await page.evaluate("()=>chooseChannel(0)") + assert await page.locator('#mixer [data-strip="0"]').evaluate("(e)=>e.classList.contains('selected')") await page.locator('[data-focus-step="source"]').click() assert await page.locator('.arSourceChooser').is_visible() await page.locator('.arSourceChoice[data-source-choice="MONO:1"]').click() From eeccc5c00da6f67fbb8ba9fccad0937199c74b36 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 13:04:27 +0700 Subject: [PATCH 13/15] Diagnose M1 selected SOURCE live switch test rejection using native/UI state evidence --- tests/mixer_io_smoke.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/mixer_io_smoke.py b/tests/mixer_io_smoke.py index 0e26c49e2..13d9949b5 100644 --- a/tests/mixer_io_smoke.py +++ b/tests/mixer_io_smoke.py @@ -109,7 +109,16 @@ async def main(): await page.locator('.arSourceChoice[data-source-choice="MONO:1"]').click() switching=await page.evaluate("""()=>window.__armixTestActions.filter(x=> x.name==='arMixAction'&&x.data.action==='routingSourceSwitch')""") - assert len(switching)==1,switching + if len(switching)!=1: + diagnostic=await page.evaluate("""()=>({ + note:document.querySelector('[data-source-note]')?.textContent, + selected:document.querySelector('.strip[data-strip].selected')?.dataset.strip, + route:window.__arMixRouteView()?.acceptedRoute?.channels?.[0], + canSwitch:typeof window.__arMixCommitSelectedSource, + pending:window.__arMixRouteView()?.pending, + monitor:window.__arMixRouteView()?.monitor + })""") + assert len(switching)==1,(switching,diagnostic) assert switching[0]['data']['requestId']==1 and switching[0]['data']['channel']==0 assert switching[0]['data']['left']==1 and switching[0]['data']['deviceEpoch']==4 assert (await page.evaluate("""()=>window.__armixTestActions.filter(x=> From ca28eb08fdd3a2c9b8e2d1ab78c8756638d8f567 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 13:06:38 +0700 Subject: [PATCH 14/15] Isolate M1 SOURCE picker event vs native routing preflight rejection in Chromium failure evidence --- tests/mixer_io_smoke.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/mixer_io_smoke.py b/tests/mixer_io_smoke.py index 13d9949b5..fc94b666e 100644 --- a/tests/mixer_io_smoke.py +++ b/tests/mixer_io_smoke.py @@ -118,7 +118,13 @@ async def main(): pending:window.__arMixRouteView()?.pending, monitor:window.__arMixRouteView()?.monitor })""") - assert len(switching)==1,(switching,diagnostic) + probe=await page.evaluate("""()=>({ + result:window.__arMixCommitSelectedSource(0,'MONO',1,-1), + sent:window.__armixTestActions.filter(x=> + x.name==='arMixAction'&&x.data.action==='routingSourceSwitch'), + actions:window.__armixTestActions.filter(x=>x.name==='arMixAction').slice(-5) + })""") + assert len(switching)==1,(switching,diagnostic,probe) assert switching[0]['data']['requestId']==1 and switching[0]['data']['channel']==0 assert switching[0]['data']['left']==1 and switching[0]['data']['deviceEpoch']==4 assert (await page.evaluate("""()=>window.__armixTestActions.filter(x=> From 259331438d2dc0666c9449bb527602ae7e0cbfb8 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Sat, 31 Oct 2026 13:09:08 +0700 Subject: [PATCH 15/15] Fix M1 live SOURCE JS undefined backup gate and preserve pending ACK feedback; restore focused regression --- AR-MIX-Live-FX-Host-Standalone-v0.3.html | 4 ++++ tests/mixer_io_smoke.py | 17 +---------------- web/mixer-io.js | 4 ++++ web/monitor.js | 2 +- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/AR-MIX-Live-FX-Host-Standalone-v0.3.html b/AR-MIX-Live-FX-Host-Standalone-v0.3.html index a669b27cd..addead97d 100644 --- a/AR-MIX-Live-FX-Host-Standalone-v0.3.html +++ b/AR-MIX-Live-FX-Host-Standalone-v0.3.html @@ -3538,6 +3538,10 @@ if(outcome.pending)quickSourcePending={ channel,epoch:outcome.epoch,value:button.dataset.sourceChoice,live:!!outcome.live}; renderSourceChooser(); + sourceNote.textContent=outcome.pending? + outcome.live?'LIVE SOURCE PENDING · 64-SAMPLE RAMP · WAIT NATIVE ACK': + 'MUTED SOURCE APPLY PENDING · WAIT NATIVE ACK': + 'SOURCE ALREADY ACKNOWLEDGED'; }); // MS5: explicit Sends-on-Faders control, scoped to a single real AUX return. // MAIN fader DOM and all audio controls remain resident and unmodified. diff --git a/tests/mixer_io_smoke.py b/tests/mixer_io_smoke.py index fc94b666e..f3232d558 100644 --- a/tests/mixer_io_smoke.py +++ b/tests/mixer_io_smoke.py @@ -109,22 +109,7 @@ async def main(): await page.locator('.arSourceChoice[data-source-choice="MONO:1"]').click() switching=await page.evaluate("""()=>window.__armixTestActions.filter(x=> x.name==='arMixAction'&&x.data.action==='routingSourceSwitch')""") - if len(switching)!=1: - diagnostic=await page.evaluate("""()=>({ - note:document.querySelector('[data-source-note]')?.textContent, - selected:document.querySelector('.strip[data-strip].selected')?.dataset.strip, - route:window.__arMixRouteView()?.acceptedRoute?.channels?.[0], - canSwitch:typeof window.__arMixCommitSelectedSource, - pending:window.__arMixRouteView()?.pending, - monitor:window.__arMixRouteView()?.monitor - })""") - probe=await page.evaluate("""()=>({ - result:window.__arMixCommitSelectedSource(0,'MONO',1,-1), - sent:window.__armixTestActions.filter(x=> - x.name==='arMixAction'&&x.data.action==='routingSourceSwitch'), - actions:window.__armixTestActions.filter(x=>x.name==='arMixAction').slice(-5) - })""") - assert len(switching)==1,(switching,diagnostic,probe) + assert len(switching)==1,(switching,await page.locator('[data-source-note]').inner_text()) assert switching[0]['data']['requestId']==1 and switching[0]['data']['channel']==0 assert switching[0]['data']['left']==1 and switching[0]['data']['deviceEpoch']==4 assert (await page.evaluate("""()=>window.__armixTestActions.filter(x=> diff --git a/web/mixer-io.js b/web/mixer-io.js index 07cb98ad9..4d1ce2abe 100644 --- a/web/mixer-io.js +++ b/web/mixer-io.js @@ -272,6 +272,10 @@ if(outcome.pending)quickSourcePending={ channel,epoch:outcome.epoch,value:button.dataset.sourceChoice,live:!!outcome.live}; renderSourceChooser(); + sourceNote.textContent=outcome.pending? + outcome.live?'LIVE SOURCE PENDING · 64-SAMPLE RAMP · WAIT NATIVE ACK': + 'MUTED SOURCE APPLY PENDING · WAIT NATIVE ACK': + 'SOURCE ALREADY ACKNOWLEDGED'; }); // MS5: explicit Sends-on-Faders control, scoped to a single real AUX return. // MAIN fader DOM and all audio controls remain resident and unmodified. diff --git a/web/monitor.js b/web/monitor.js index 45203b531..a87f39449 100644 --- a/web/monitor.js +++ b/web/monitor.js @@ -1403,7 +1403,7 @@ return window.__arMixCommitMutedSource(channel,mode,left,right); if(!d.ready||!d.active||draftEpoch!==Number(d.epoch)|| patchPending||mixerDraftActive||rackFxDraft||nativeShowBusy|| - studioBackupBusy||liveSendPending.size) + liveSendPending.size) return {ok:false,error:"Finish native APPLY, FX/SEND draft or Show before SOURCE switching."}; if(liveSourcePending)return {ok:false,error:"Wait for previous SOURCE native ACK."}; const active=new Set(patchPorts().map(p=>p.port));