From b4c80197c3d8174bb2b889761985ae530a3f72e1 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 11:24:56 +0700 Subject: [PATCH 01/26] feat(live): make any channel IN one native source+monitor transaction without hidden patch/start/arm wizard --- web/monitor.js | 154 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 132 insertions(+), 22 deletions(-) diff --git a/web/monitor.js b/web/monitor.js index 1831c53d7..52baaf892 100644 --- a/web/monitor.js +++ b/web/monitor.js @@ -1561,6 +1561,132 @@ error:ok?"":String(ack?.error||"Source changed or native ACK mismatch") }})); }); + // Audition/FL-style primary workflow: IN on ANY of the ten mixer strips + // is the operator's single deliberate audio-routing gesture. No draft + // wizard, guessed CH1/CH2 mapping, separate START or exposed ARM step. + // Internal mute/ACK/repatch/monitor transitions stay in the existing + // native controller; no second engine or device callback is created. + let auditionInputPending=null,auditionInputSerial=1000000; + const auditionResult=(ok,message,channel)=>{ + const detail={ok,error:ok?"":message,channel,message}; + window.dispatchEvent(new CustomEvent("arMixMixerSourceResult",{detail})); + fastAudioNotify(message); + }; + const auditionAbort=(reason)=>{ + const p=auditionInputPending;auditionInputPending=null; + if(p)auditionResult(false,reason,p.channel); + }; + const auditionSubmit=()=>{ + const p=auditionInputPending,d=state.dryRoutingLab||{}; + if(!p || (p.phase!=="mute"&&p.phase!=="source") || + !d.ready||!d.active||Number(d.epoch)!==p.epoch || + patchPending||nativeShowBusy) { + auditionAbort("INPUT NOT CHANGED · device or route changed; monitoring remains safe."); + return; + } + p.phase="source";p.revision=Number(d.revision); + api.emitEvent("arMixAction",{ + action:"routingSourceSwitch",requestId:p.id, + channel:p.channel,mode:p.mode,left:p.left,right:p.right, + deviceEpoch:p.epoch,revision:p.revision + }); + fastAudioNotify("CH "+(p.channel+1)+" · verifying selected hardware input"); + }; + const auditionMonitor=()=>{ + const p=auditionInputPending,d=state.dryRoutingLab||{}; + if(!p||Number(d.epoch)!==p.epoch||!d.ready|| + d.topologyFault||!d.hasAcceptedRoute) { + auditionAbort("INPUT ROUTED BUT MONITOR OFF · device changed; check Audio I/O."); + return; + } + p.phase="monitor";p.revision=Number(d.revision); + api.emitEvent("arMixAction",{action:"monitor",value:true, + expectedEpoch:p.epoch,expectedRevision:p.revision}); + fastAudioNotify("CH "+(p.channel+1)+" · enabling verified MAIN monitoring"); + }; + window.__arMixChooseChannelInput=(channel,mode,left,right)=>{ + const d=state.dryRoutingLab||{},epoch=Number(d.epoch); + const r=d.acceptedRoute?.channels?.[channel]; + if(!Number.isInteger(channel)||channel<0||channel>=10 || + !["NONE","MONO","STEREO"].includes(mode)) + return {ok:false,error:"Choose a valid mixer channel and hardware input."}; + if(!state.connected||!state.directRouteAuthorized||!d.ready||!d.active|| + !Number.isSafeInteger(epoch)||epoch<=0||d.topologyFault|| + draftEpoch!==epoch) + return {ok:false,error:"Select a verified audio device in Audio I/O first."}; + const active=new Set(patchPorts().map(p=>p.port)); + if(mode==="MONO"&&!active.has(left) || + mode==="STEREO"&&(!active.has(left)||!active.has(right)||left===right)) + return {ok:false,error:"This input is not among the enabled hardware ports."}; + if(auditionInputPending||fastAudioPending||liveSourcePending||patchPending|| + nativeShowBusy||mixerDraftActive||rackFxDraft||liveSendPending.size|| + state.secondaryOutputArmed) + return {ok:false,error:"A route, effect, Show or stream change is pending. Finish it first."}; + const targetRight=mode==="STEREO"?right:-1; + const same=!!r&&r.mode===mode&& + (mode==="NONE"||r.left===left&&r.right===targetRight); + if(same && (state.monitor||mode==="NONE")) + return {ok:true,unchanged:true,message:"Channel input already connected."}; + const id=++auditionInputSerial; + auditionInputPending={id,channel,mode,left:mode==="NONE"?-1:left, + right:targetRight,epoch,revision:Number(d.revision), + phase:"source",wasMonitoring:!!state.monitor}; + // A same-format physical pin move already has a 64-sample ramp in RT + // and must NEVER interrupt live monitoring or rebuild VST3 instances. + // A structural change while monitoring safely mutes first, then restores + // monitoring only after native patch ACK and current-epoch readback. + if(state.monitor&&!same&&(!r||r.mode!==mode)){ + auditionInputPending.phase="mute"; + api.emitEvent("arMixAction",{action:"monitor",value:false, + expectedEpoch:epoch,expectedRevision:Number(d.revision)}); + }else if(same)auditionMonitor(); + else auditionSubmit(); + return {ok:true,pending:true,live:!!state.monitor,epoch, + message:"CH "+(channel+1)+" input requested; native readback pending."}; + }; + api.addEventListener("arMixAudioArmAck",ack=>{ + const p=auditionInputPending; + if(!p||!(p.phase==="mute"||p.phase==="monitor"))return; + if(Number(ack?.deviceEpoch)!==p.epoch||ack?.ok!==true || + (p.phase==="mute"&&ack.armed!==false) || + (p.phase==="monitor"&&ack.armed!==true)){ + auditionAbort("MONITOR REJECTED · "+String(ack?.error||"Native output not ready")); + return; + } + state.monitor=!!ack.armed; + if(p.phase==="mute")auditionSubmit(); + else { + auditionInputPending=null; + auditionResult(true,"CH "+(p.channel+1)+" · audio routed to MAIN (physical listening unverified)",p.channel); + } + }); + api.addEventListener("arMixSourceSwitchAck",ack=>{ + const p=auditionInputPending; + if(!p||p.phase!=="source"||Number(ack?.requestId)!==p.id|| + Number(ack?.channel)!==p.channel)return; + const next=ack?.state||{},row=next.acceptedRoute?.channels?.[p.channel]; + const verified=ack.ok===true && Number(next.epoch)===p.epoch && + Number(state.dryRoutingLab?.epoch)===p.epoch && + next.ready===true && !next.topologyFault && + row?.mode===p.mode && (p.mode==="NONE"|| + row.left===p.left&&row.right===p.right); + if(!verified){ + auditionAbort("INPUT REJECTED · "+String(ack?.error||"Native route readback mismatch")); + return; + } + state.dryRoutingLab=next; + hydrateAcceptedRoute();renderPatchMatrix();updateRouteLabIdentity(); + window.dispatchEvent(new Event("arMixRoutingDraftChanged")); + const anyInput=(next.acceptedRoute?.channels||[]) + .some(x=>x.mode==="MONO"||x.mode==="STEREO"); + if(p.mode==="NONE"&&!anyInput){ + auditionInputPending=null; + auditionResult(true,"Last input disconnected · MAIN monitoring off",p.channel); + }else if(p.wasMonitoring && state.monitor){ + auditionInputPending=null; + auditionResult(true,"CH "+(p.channel+1)+" · native input switched live",p.channel); + }else auditionMonitor(); + }); window.__arMixOpenChannelPatch=(channel,tab="input")=>{ if(!Number.isInteger(channel)||channel<0||channel>=10)return; openRoutingLab(); @@ -1755,28 +1881,9 @@ fastAudioArm(d); return {ok:true,pending:true,phase:"arm"}; } - // First boot only. Leave existing custom sources and BUS routing alone. - if(!Array.isArray(draftRoutes)||draftRoutes.length<2 || - draftRoutes[0].mode!=="NONE"||draftRoutes[1].mode!=="NONE") - return {ok:false,error:"Custom input patch already exists. APPLY or REVERT it first."}; - const pins=ports.slice(0,2).map(p=>p.port); - for(let i=0;i1?"/CH02":"")+" → MAIN · WAITING FOR NATIVE PATCH ACK"); - return {ok:true,pending:true,phase:"patch"}; + // Never guess CH1/CH2 hardware sources. In an Audition-style mixer + // the operator chooses IN on the strip they actually intend to use. + return {ok:false,error:"Choose IN on any mixer channel first; no automatic CH1/CH2 patch."}; }; // One explicit APPLY owns patch ACK -> physical ARM, no second START. const submitFastCustomPatch=()=>{ @@ -2030,6 +2137,9 @@ api.addEventListener("arMixStatus",d=>{ if(fastAudioPending&&Number(d?.dryRoutingLab?.epoch)!==fastAudioPending.epoch) fastAudioAbort("START CANCELLED · audio device generation changed; output remains MUTED."); + if(auditionInputPending && + Number(d?.dryRoutingLab?.epoch)!==auditionInputPending.epoch) + auditionAbort("INPUT CANCELLED · audio interface changed; monitoring remains muted."); state=d; // Single controller owns epoch hydration even if the full PATCH workspace // is closed. The status projection used by MIX is deliberately read-only. From 8890a7f84832b7610d920750da6e67da81487178 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 11:25:29 +0700 Subject: [PATCH 02/26] feat(mixer): connect every visible channel IN to native per-strip source selection and remove implicit CH1/2 start --- web/mixer-io.js | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/web/mixer-io.js b/web/mixer-io.js index bf34032b4..e84b82ec8 100644 --- a/web/mixer-io.js +++ b/web/mixer-io.js @@ -386,9 +386,9 @@ 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?'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'; + sourceNote.textContent=!s.ready?'Choose a verified audio interface in Audio I/O': + 'Select an input for CH '+(sourceChooserChannel+1)+ + ' · native mixer handles safe changes and monitoring automatically'; }; const openSourceChooser=channel=>{ if(!Number.isInteger(channel)||channel<0||channel>=10)return; @@ -967,7 +967,7 @@ row.dataset.state==='live'?'LIVE · ACK':'UNPATCHED')); row.append(identity,mode,left,right,action);section.appendChild(row); } - section.appendChild(node('p','arIOQuickFooter','Select verified inputs, click USE INPUT. Native routing handles any required safe mute, ACK and re-arm automatically.')); + section.appendChild(node('p','arIOQuickFooter','Choose IN on any mixer strip. The native mixer connects that channel to MAIN after verified readback; no separate Patch or Start.')); return section; } function stageQuickInput(button){ @@ -1612,17 +1612,12 @@ s.ready?'E'+s.epoch+' · Native APPLY required for input edits':'CHOOSE A VERIFIED DIRECT DEVICE'; el('arIOFeedback').textContent=(ioTab==='device'?deviceNote:matrixMessage)||hint; } - // Operator makes one choice. Same-format moves use the native source ramp; - // structural moves use FAST3's safe MUTE -> graph ACK -> guarded ARM internally. + // One hardware-IN chooser for EVERY mixer strip, as in Audition/FL. + // Native routingSourceSwitch supports silent first boot and live per-strip + // updates. Do not stage a second draft graph or guess CH1/CH2 sources. function commitSourceInOneGesture(channel,mode,left,right){ - const s=route(),accepted=s.acceptedRoute?.channels?.[channel]; - if(accepted?.mode===mode&&['MONO','STEREO'].includes(mode)) - return window.__arMixCommitSelectedSource?.(channel,mode,left,right); - const staged=window.__arMixStageChannelInput?.(channel,mode,left,right); - if(!staged?.ok)return staged||{ok:false,error:'Native staging unavailable'}; - const committed=window.__arMixApplyAndActivate?.(); - return committed?.ok?{ok:true,pending:true,live:false,epoch:s.epoch}: - {ok:false,error:committed?.error||'Safe native APPLY rejected'}; + return window.__arMixChooseChannelInput?.(channel,mode,left,right)|| + {ok:false,error:'Verified native audio routing is not initialized'}; } function changeSource(select){ const channel=Number(select.dataset.channel); @@ -2005,14 +2000,17 @@ if(ack?.active?.open&&Number(ack.active.deviceGeneration)!==oldGeneration) deviceMatrixWaitEpoch=route().epoch; deviceDraft=makeDeviceDraft(); - if(ack?.ok&&ack?.active?.open)applyAfterDevice={generation:Number(ack.active.deviceGeneration),capture:ack.active.captureDevice,playback:ack.active.playbackDevice,driver:ack.active.backend}; + // After a device APPLY the operator chooses IN on the desired strip. + // Never silently map the first two capture pins or start output. deviceNote=ack?.ok?'DEVICE ACCEPTED · OUTPUT MUTED · '+devicePinNextStep(): (ack?.state||'REJECTED')+' · '+(ack?.error||'Check driver and retry'); // Same real routing controller sees the new device epoch via normal status. lastSignature='';if(!overlay.hidden)refreshIO(); }); backend?.addEventListener?.('arMixRoutingLabAck',ack=>{ - if(quickSourcePending){ + // Advanced matrix APPLY owns its own draft; the per-channel IN selector + // is committed by arMixMixerSourceResult, not by this structural ACK. + if(quickSourcePending?.structural){ const requested=quickSourcePending; quickSourcePending=null; if(ack?.ok!==true)window.__arMixRevertMixerDraft?.(); @@ -2031,6 +2029,18 @@ renderSourceChooser(); } }); + window.addEventListener('arMixMixerSourceResult',event=>{ + const detail=event.detail||{}; + if(quickSourcePending?.channel===detail.channel)quickSourcePending=null; + const message=detail.message|| + (detail.ok?'Verified hardware source connected':'Hardware source rejected'); + matrixMessage=message; + if(!sourceChooser.hidden){ + renderSourceChooser(); + sourceNote.textContent=message; + } + lastSignature='';refresh(); + }); window.addEventListener('arMixSourceSwitchResult',event=>{ const result=event.detail||{}; if(quickSourcePending?.live&&quickSourcePending.channel===result.channel) From 73bed26961f5111e7b4c39a18056b6802a54f6a6 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 11:26:15 +0700 Subject: [PATCH 03/26] fix(ux): remove duplicate CH1 patch/arm wizard; route native Audio Setup to existing custom I/O panel --- web/approved-native-bridge.js | 152 ++++++++-------------------------- 1 file changed, 35 insertions(+), 117 deletions(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 7e548a6e3..a3d066641 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -145,128 +145,62 @@ } } - // Native-only operator controls in the EXISTING approved More menu: - // user selects REAL JUCE active pin -> explicitly patches CH1 -> arms output. - // No auto-arm, demo PCM, guessed physical port or second GUI. - let hardware=null, inputSelect=null, routeBtn=null, armBtn=null, muteBtn=null; - let hardwareNote=null, pendingSourceId=0, sourceSerial=100; - const safeNativeCounter=x=>{ - if(typeof x!=="string" || !/^[1-9]\d*$/.test(x))return null; - const number=Number(x); - return Number.isSafeInteger(number)&&number>0?number:null; - }; + // Exactly one device configuration flow: reuse the existing custom + // Audio I/O panel, not a second large JUCE AudioDeviceSelectorComponent. + // It remains available as an Advanced driver-recovery tool in native host. + let hardware=null, hardwareNote=null, lastDryReadback=null; const legacy=()=>hardware?.raw?.legacyM4; const deviceReady=()=>!!(hardware?.device?.backend && hardware.device.sampleRate>0 && hardware.device.enabledInputs.length>0 && hardware.device.enabledOutputs.length>=2 && legacy()?.active===true); + const verifiedM4=()=>{ + const d=lastDryReadback; + return deviceReady() && legacy()?.routeAccepted===true && + d?.ready===true && d?.hasAcceptedRoute===true && !d?.topologyFault && + String(d.epoch)===hardware.device.epoch && + String(d.revision)===legacy().routingRevision; + }; function updateHardwarePanel(next) { - hardware=next || null; + hardware=next||null; const d=next?.device; const deviceOpen=Boolean(d?.backend && d.sampleRate>0 && d.enabledOutputs.length>=2); const label=document.getElementById("transport"); - if(label)label.textContent=!deviceOpen?"Device not ready": - d.outputArmed?"Output armed":"Output muted"; + if(label)label.textContent=!deviceOpen?"Choose audio device": + d.outputArmed?"MAIN monitoring on":"MAIN monitoring off"; const warning=document.querySelector?.(".status-bar .warning"); - if(warning)warning.textContent=!deviceOpen?"NO VERIFIED AUDIO DEVICE": + if(warning)warning.textContent=!deviceOpen?"CHOOSE AUDIO OUTPUT": d.outputArmed?(next.admitted?"NATIVE PCM · HARDWARE FAT PENDING": - "MAIN ARMED · PCM NOT YET ADMITTED"): - legacy()?.routeAccepted?"INPUT PATCHED · OUTPUT MUTED": - "NO AUDIBLE OUTPUT · PATCH INPUT + ARM"; - if(!inputSelect)return; - const pins=deviceOpen?d.inputEndpoints.filter(p=> - p.active===true && d.enabledInputs.includes(p.port)):[]; - const key=pins.map(p=>p.id+"|"+p.label).join(";"); - if(inputSelect.dataset.pins!==key) { - const before=inputSelect.value; - inputSelect.dataset.pins=key; - inputSelect.replaceChildren(); - const option=document.createElement("option"); - option.value="";option.textContent="Physical input for CH1"; - inputSelect.appendChild(option); - for(const pin of pins){ - const item=document.createElement("option"); - item.value=String(pin.port); - item.textContent=pin.label+" · IN "+(pin.port+1); - inputSelect.appendChild(item); - } - if(pins.some(p=>String(p.port)===before))inputSelect.value=before; - } - inputSelect.disabled=!deviceReady(); - if(routeBtn)routeBtn.disabled=!deviceReady() || - inputSelect.value==="" || pendingSourceId!==0; - if(armBtn)armBtn.disabled=!deviceReady() || - legacy()?.routeAccepted!==true || d.outputArmed; - if(muteBtn)muteBtn.disabled=!deviceOpen || !d.outputArmed; - if(hardwareNote) { - const evidence=protocol.diagnoseFirstSound?.(next,inputSelect.value); - // Human-readable PCM stages from the ORIGINAL native callback only. - // These values are NOT evidence that the DAC or speaker is audible. - hardwareNote.textContent=evidence? - evidence.readout+" · "+evidence.nextAction: - "No verified hardware PCM readback available."; - } + "MAIN MONITOR ON · VERIFY SOUND"): + "CHOOSE CHANNEL IN · THEN MONITOR"; + if(hardwareNote)hardwareNote.textContent=!deviceOpen? + "Audio I/O: choose the hardware input and actual listening/output device.": + "Choose IN on any mixer channel. Source and monitoring are committed by native readback."; } function installFirstSoundMenu() { const menu=document.querySelector?.("#moreTools .more-tools-panel"); if(!menu || typeof document.createElement!=="function")return; - const item=(tag,cls,label)=>{ - const el=document.createElement(tag); - el.className=cls;el.textContent=label; - if(tag==="button")el.type="button"; - return el; - }; - const caption=item("span","more-tools-caption","REAL AUDIO · FIRST SOUND"); - const setup=item("button","tool","Audio Setup"); + const caption=document.createElement("span"); + caption.className="more-tools-caption"; + caption.textContent="AUDIO · DEVICE SETTINGS"; + const setup=document.createElement("button"); + setup.className="tool";setup.type="button";setup.textContent="Audio I/O Settings"; + setup.dataset.nativeAction="audioSetup"; setup.addEventListener("click",()=>{ - backend.emitEvent("arMixAction",{action:"audioSetup"}); - status("NATIVE: select actual ASIO/WASAPI input + output in Audio Setup."); - }); - inputSelect=item("select","toolbar-select",""); - inputSelect.setAttribute("aria-label","JUCE physical input for CH1"); - inputSelect.addEventListener("change",()=>updateHardwarePanel(hardware)); - routeBtn=item("button","tool","Patch CH1"); - routeBtn.addEventListener("click",()=>{ - const d=hardware?.device,l=legacy(); - const epoch=safeNativeCounter(d?.epoch); - const revision=safeNativeCounter(l?.routingRevision); - const pin=Number(inputSelect?.value); - if(!deviceReady()||inputSelect.value==="" || - epoch===null||revision===null|| - !Number.isInteger(pin)||!d.enabledInputs.includes(pin)){ - status("NATIVE: invalid input pin, epoch or route revision.");return; - } - pendingSourceId=++sourceSerial; - routeBtn.disabled=true; - backend.emitEvent("arMixAction",{ - action:"routingSourceSwitch",requestId:pendingSourceId, - channel:0,mode:"MONO",left:pin,right:-1, - deviceEpoch:epoch,revision - }); - status("NATIVE: CH1 physical input patch pending real ACK."); - }); - armBtn=item("button","tool","Arm output"); - armBtn.addEventListener("click",()=>{ - if(!deviceReady()||legacy()?.routeAccepted!==true)return; - const epoch=safeNativeCounter(hardware.device.epoch); - const revision=safeNativeCounter(legacy().routingRevision); - if(epoch===null||revision===null)return; - backend.emitEvent("arMixAction",{action:"monitor",value:true, - expectedEpoch:epoch,expectedRevision:revision}); - status("NATIVE: output ARM requested; awaiting JUCE ACK."); - }); - muteBtn=item("button","tool","Mute output"); - muteBtn.addEventListener("click",()=>{ - backend.emitEvent("arMixAction",{action:"monitor",value:false}); - status("NATIVE: output MUTE requested; awaiting JUCE ACK."); + // Event may be intercepted by the existing mixer-io.js capture handler. + // When handled there, do not emit the old JUCE setup command. + if(window.__arMixOpenAudioIO){ + window.__arMixOpenAudioIO("device"); + status("Choose actual capture and playback devices in Audio I/O."); + }else status("Audio I/O panel unavailable; do not open a second setup wizard."); }); - hardwareNote=item("span","more-tools-caption","Device not initialized"); + hardwareNote=document.createElement("span"); + hardwareNote.className="more-tools-caption"; hardwareNote.style.whiteSpace="normal"; - menu.append(caption,setup,inputSelect,routeBtn,armBtn,muteBtn,hardwareNote); + menu.append(caption,setup,hardwareNote); updateHardwarePanel(hardware); } - function onNativeReadback(next) { updateHardwarePanel(next); const caps=next?.graph?.capabilities; @@ -319,22 +253,6 @@ }); backend.addEventListener("arMixConsoleSnapshot", snapshot=>controller.onSnapshot(snapshot)); backend.addEventListener("arMixConsoleAck", ack=>controller.onAck(ack)); - backend.addEventListener("arMixSourceSwitchAck", ack=>{ - if(!pendingSourceId||ack?.requestId!==pendingSourceId)return; - pendingSourceId=0; - if(ack.ok===true) { - status("NATIVE: CH1 PATCH accepted by JUCE; validating later readback."); - controller.subscribe(); - }else status("NATIVE PATCH REJECTED: "+(ack?.error||"stale physical route")); - updateHardwarePanel(hardware); - }); - backend.addEventListener("arMixAudioArmAck", ack=>{ - if(ack?.ok===true){ - status(ack.armed?"NATIVE: user ARM accepted; checking real PCM.": - "NATIVE: output muted."); - controller.subscribe(); - }else status("NATIVE ARM REJECTED: "+(ack?.error||"device not ready")); - }); } const nativeHooks=Object.freeze({ enabled:connected, From 20cd8102f507e83e92e61a2d36b5319b9bae402d Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 11:26:41 +0700 Subject: [PATCH 04/26] fix(engine): acknowledge real M4 per-channel fader pan mute solo with verified routing epoch --- src/Main.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Main.cpp b/src/Main.cpp index f410bce6b..6fde37f5f 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -783,17 +783,31 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr if(engine_.dryRoutingLabActive() && channel>=1 && channel<=LiveDryRoutingLab::count && (name=="faderDb"||name=="pan"||name=="mute"||name=="solo")) { + // Audition-style live mixer control: all ten strip faders/pans/ + // mute/solo target their REAL native PCM owner, never the Pages + // demo model or hardcoded legacy CH1. No UI-thread graph rebuild. const auto ep=args.getProperty("routeEpoch",juce::var()); const auto rev=args.getProperty("routeRevision",juce::var()); + bool accepted=false; if(!ep.isVoid()&&!rev.isVoid() && ((name=="mute"||name=="solo")?value.isBool(): (value.isDouble()||value.isInt()))) { const auto epoch=static_cast(static_cast(ep)); const auto revision=static_cast(static_cast(rev)); const float liveValue=value.isBool()?(bool(value)?1.f:0.f):valueNumber; - (void)engine_.setDryRoutingLabParameter(channel-1,epoch,revision, + accepted=engine_.setDryRoutingLabParameter(channel-1,epoch,revision, name,liveValue); } + auto ack=std::make_unique(); + ack->setProperty("channel",channel); + ack->setProperty("parameter",name); + ack->setProperty("ok",accepted); + ack->setProperty("routeEpoch", + static_cast(engine_.dryRoutingLabEpoch())); + ack->setProperty("routeRevision", + static_cast(engine_.dryRoutingLabRevision())); + if(browser_.loaded) + browser_.emitEventIfBrowserIsVisible("arMixM4ControlAck",juce::var(ack.release())); return; } if (name == "masterGain" && (value.isDouble() || value.isInt())) From bd5e663c4e312627424acc0868bf77533e3a819a Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 11:27:55 +0700 Subject: [PATCH 05/26] feat(audio-control): unlock approved 10CH faders pan mute solo and measured meters on actual M4 PCM --- web/approved-native-bridge.js | 117 ++++++++++++++++++++++++++++++---- 1 file changed, 106 insertions(+), 11 deletions(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index a3d066641..71c743c69 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -201,6 +201,69 @@ menu.append(caption,setup,hardwareNote); updateHardwarePanel(hardware); } + // M4 is already the TRUE ten-channel realtime PCM owner before the + // universal ChannelId ABI is fully admitted. Its proven native parameter + // setter must not be hidden behind an unrelated G0 ChannelId gate. + const m4Parameter=(track,parameter,value)=>{ + if(!verifiedM4()){ + status("Select IN on a verified channel before adjusting the live mix."); + return false; + } + const channel=scope?.tracks?.indexOf(track)??-1; + if(channel<0||channel>=10){ + status("No native ten-channel identity for this control."); + return false; + } + const epoch=Number(lastDryReadback.epoch),revision=Number(lastDryReadback.revision); + if(!Number.isSafeInteger(epoch)||epoch<=0|| + !Number.isSafeInteger(revision)||revision<=0)return false; + backend.emitEvent("arMixParameter",{ + parameter,channel:channel+1,value,routeEpoch:epoch,routeRevision:revision + }); + return true; // request sent; not ACK or altered GUI model + }; + const renderMeasuredM4=(live)=>{ + if(flags.acceptedGraphConnected||!scope?.tracks)return; + const d=live?.dryRoutingLab||{}; + lastDryReadback=d; + if(!verifiedM4())return; + const controls=d.channelControls,peaksL=d.channelPeaksL,peaksR=d.channelPeaksR; + if(!Array.isArray(controls)||controls.length!==10)return; + let changed=false; + for(let i=0;i<10;++i){ + const t=scope.tracks[i],c=controls[i]; + if(!t||!c)continue; + const f=Number(c.db),p=Number(c.pan); + if(Number.isFinite(f)&&Math.abs(t.level-f)>0.02){t.level=f;changed=true;} + if(Number.isFinite(p)&&Math.abs(t.pan-p)>0.02){t.pan=p;changed=true;} + if(typeof c.mute==="boolean"&&t.mute!==c.mute){t.mute=c.mute;changed=true;} + if(typeof c.solo==="boolean"&&t.solo!==c.solo){t.solo=c.solo;changed=true;} + } + const master=scope.master; + const masterDb=Number(live?.masterDb); + if(master&&Number.isFinite(masterDb)&&masterDb>=-90&&masterDb<=12&& + Math.abs(master.level-masterDb)>0.02){master.level=masterDb;changed=true;} + if(master&&typeof live?.masterMute==="boolean"&& + master.mute!==live.masterMute){master.mute=live.masterMute;changed=true;} + // Render only on ACCEPTED control state changes, never at 12Hz. The + // WebView compositor is not a part of the realtime audio callback. + if(changed)scope.render?.(); + const timestamp=performance.now(); + const paint=(track,left,right)=>{ + const root=document.querySelector('.strip[data-id="'+track?.id+'"]'); + if(!root)return; + for(const [side,peak] of [["left",left],["right",right]]){ + const fill=root.querySelector('.meter-fill.'+side); + if(!fill||!Number.isFinite(peak)||peak<0)continue; + const db=peak===0?-90:20*Math.log10(peak); + scope.displayMeterDbfs?.(fill,Math.max(-90,Math.min(6,db)),timestamp, + "m4:"+track.id+":"+side); + } + }; + if(Array.isArray(peaksL)&&Array.isArray(peaksR)&&peaksL.length===10&&peaksR.length===10) + for(let i=0;i<10;++i)paint(scope.tracks[i],Number(peaksL[i]),Number(peaksR[i])); + paint(master,Number(d.peakL),Number(d.peakR)); + }; function onNativeReadback(next) { updateHardwarePanel(next); const caps=next?.graph?.capabilities; @@ -209,7 +272,7 @@ flags.productionCallbackLive=false;flags.acceptedGraphConnected=false; lastPaintedSignature=""; stopDemo(); - status("NATIVE G0 · PATCH CH1/ARM tersedia pada device terverifikasi; kontrol ChannelId/WIRE menunggu PCM native."); + status("NATIVE MIXER · pilih IN pada channel mana saja; level/pan/mute/solo menggunakan engine audio."); return; } // Control readback may change at the SAME structural graph revision. @@ -253,6 +316,11 @@ }); backend.addEventListener("arMixConsoleSnapshot", snapshot=>controller.onSnapshot(snapshot)); backend.addEventListener("arMixConsoleAck", ack=>controller.onAck(ack)); + backend.addEventListener("arMixStatus",live=>renderMeasuredM4(live)); + backend.addEventListener("arMixM4ControlAck",ack=>{ + if(ack?.ok!==true) + status("Control rejected: hardware/route changed; original mix retained."); + }); } const nativeHooks=Object.freeze({ enabled:connected, @@ -263,9 +331,23 @@ const t=scope?.findTrack?.(el) || null; if (!t)return true; if (!flags.acceptedGraphConnected) { - if (field==="level")el.value=String(t.level); - else if (field==="pan")el.value=String(t.pan); - status("NATIVE: ChannelId PCM not admitted; control unchanged"); + // Drag may move only the physical fader thumb. On release, send one + // real native M4 parameter with exact epoch/revision; the next real + // engine readback owns the displayed value. + const numeric=Number(el.value); + const pan=el.dataset.panKeyboard==="true"||el.dataset.panAltPointer==="true"|| + Math.abs(numeric)>12?numeric:0; + if(event.type==="change"&&t===scope.master){ + if(field==="level"&&Number.isFinite(numeric)) + backend.emitEvent("arMixParameter",{parameter:"masterGain",value:numeric,channel:-1}); + }else if(event.type==="change"&&field==="level"&&Number.isFinite(numeric)) + m4Parameter(t,"faderDb",numeric); + else if(event.type==="change"&&field==="pan"&&Number.isFinite(pan)) + m4Parameter(t,"pan",pan); + if(!verifiedM4()&&t!==scope.master){ + if(field==="level")el.value=String(t.level); + else if(field==="pan")el.value=String(t.pan); + } return true; } // During a native pointer drag move the approved fader *cap* only. @@ -305,6 +387,12 @@ if (["wireExpand","wireSource","wireRoute","editIdentity","rename"].includes(action)) return !["wireExpand","wireSource","wireRoute"].includes(action); if (action==="mute"||action==="solo") { + if(!flags.acceptedGraphConnected) { + if(t===scope?.master&&action==="mute") + backend.emitEvent("arMixParameter",{parameter:"masterMute",value:!t.mute,channel:-1}); + else m4Parameter(t,action,!t[action]); + return true; + } const key=action==="mute"?"SET_MUTE":"SET_SOLO"; intent(key,t,{value:!t[action],enabled:!t[action]});return true; } @@ -357,8 +445,15 @@ consumeUndo() {if (!connected)return false;status("NATIVE: WIRE undo requires accepted native transaction");return true;}, consumeDoubleClick(event,t) { if (!connected)return false; - if (event.target.classList.contains("fader"))intent("SET_FADER",t,{valueDb:0}); - else if(event.target.classList.contains("center-pan"))intent("SET_PAN",t,{value:0}); + if (event.target.classList.contains("fader")) { + if(flags.acceptedGraphConnected)intent("SET_FADER",t,{valueDb:0}); + else if(t===scope?.master) + backend.emitEvent("arMixParameter",{parameter:"masterGain",value:0,channel:-1}); + else m4Parameter(t,"faderDb",0); + } else if(event.target.classList.contains("center-pan")) { + if(flags.acceptedGraphConnected)intent("SET_PAN",t,{value:0}); + else m4Parameter(t,"pan",0); + } else status("NATIVE: identity editor unavailable until native ACK contract"); return true; }, @@ -378,13 +473,13 @@ value:descriptor,configurable:false,writable:false }); if (!connected)return; - // Disable physical control gestures while G0 has no accepted ChannelId graph. - // Presentation-only bank/selection remains available. + // G0 with a VERIFIED M4 native route is a real mixer: never block its + // fader just because universal ChannelId migration is not yet admitted. document.addEventListener("pointerdown",event=>{ - if (flags.acceptedGraphConnected) return; - if (!event.target.closest?.(".fader-box,.center-pan")) return; + if(flags.acceptedGraphConnected||verifiedM4())return; + if(!event.target.closest?.(".fader-box,.center-pan"))return; event.preventDefault();event.stopImmediatePropagation(); - status("NATIVE G0: physical gain/pan unavailable until engine graph admission"); + status("Choose a verified hardware IN before adjusting the mixer."); },true); // Reference-only buttons outside strips must not mutate fake Show/FX state. document.addEventListener("click",event=>{ From addddce97b2cea44d387f01c58a7a87555302aa8 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 11:30:22 +0700 Subject: [PATCH 06/26] chore(integration): keep legacy standalone source unchanged; Windows native UI is approved preview bundle --- web/monitor.js | 154 +++++++------------------------------------------ 1 file changed, 22 insertions(+), 132 deletions(-) diff --git a/web/monitor.js b/web/monitor.js index 52baaf892..1831c53d7 100644 --- a/web/monitor.js +++ b/web/monitor.js @@ -1561,132 +1561,6 @@ error:ok?"":String(ack?.error||"Source changed or native ACK mismatch") }})); }); - // Audition/FL-style primary workflow: IN on ANY of the ten mixer strips - // is the operator's single deliberate audio-routing gesture. No draft - // wizard, guessed CH1/CH2 mapping, separate START or exposed ARM step. - // Internal mute/ACK/repatch/monitor transitions stay in the existing - // native controller; no second engine or device callback is created. - let auditionInputPending=null,auditionInputSerial=1000000; - const auditionResult=(ok,message,channel)=>{ - const detail={ok,error:ok?"":message,channel,message}; - window.dispatchEvent(new CustomEvent("arMixMixerSourceResult",{detail})); - fastAudioNotify(message); - }; - const auditionAbort=(reason)=>{ - const p=auditionInputPending;auditionInputPending=null; - if(p)auditionResult(false,reason,p.channel); - }; - const auditionSubmit=()=>{ - const p=auditionInputPending,d=state.dryRoutingLab||{}; - if(!p || (p.phase!=="mute"&&p.phase!=="source") || - !d.ready||!d.active||Number(d.epoch)!==p.epoch || - patchPending||nativeShowBusy) { - auditionAbort("INPUT NOT CHANGED · device or route changed; monitoring remains safe."); - return; - } - p.phase="source";p.revision=Number(d.revision); - api.emitEvent("arMixAction",{ - action:"routingSourceSwitch",requestId:p.id, - channel:p.channel,mode:p.mode,left:p.left,right:p.right, - deviceEpoch:p.epoch,revision:p.revision - }); - fastAudioNotify("CH "+(p.channel+1)+" · verifying selected hardware input"); - }; - const auditionMonitor=()=>{ - const p=auditionInputPending,d=state.dryRoutingLab||{}; - if(!p||Number(d.epoch)!==p.epoch||!d.ready|| - d.topologyFault||!d.hasAcceptedRoute) { - auditionAbort("INPUT ROUTED BUT MONITOR OFF · device changed; check Audio I/O."); - return; - } - p.phase="monitor";p.revision=Number(d.revision); - api.emitEvent("arMixAction",{action:"monitor",value:true, - expectedEpoch:p.epoch,expectedRevision:p.revision}); - fastAudioNotify("CH "+(p.channel+1)+" · enabling verified MAIN monitoring"); - }; - window.__arMixChooseChannelInput=(channel,mode,left,right)=>{ - const d=state.dryRoutingLab||{},epoch=Number(d.epoch); - const r=d.acceptedRoute?.channels?.[channel]; - if(!Number.isInteger(channel)||channel<0||channel>=10 || - !["NONE","MONO","STEREO"].includes(mode)) - return {ok:false,error:"Choose a valid mixer channel and hardware input."}; - if(!state.connected||!state.directRouteAuthorized||!d.ready||!d.active|| - !Number.isSafeInteger(epoch)||epoch<=0||d.topologyFault|| - draftEpoch!==epoch) - return {ok:false,error:"Select a verified audio device in Audio I/O first."}; - const active=new Set(patchPorts().map(p=>p.port)); - if(mode==="MONO"&&!active.has(left) || - mode==="STEREO"&&(!active.has(left)||!active.has(right)||left===right)) - return {ok:false,error:"This input is not among the enabled hardware ports."}; - if(auditionInputPending||fastAudioPending||liveSourcePending||patchPending|| - nativeShowBusy||mixerDraftActive||rackFxDraft||liveSendPending.size|| - state.secondaryOutputArmed) - return {ok:false,error:"A route, effect, Show or stream change is pending. Finish it first."}; - const targetRight=mode==="STEREO"?right:-1; - const same=!!r&&r.mode===mode&& - (mode==="NONE"||r.left===left&&r.right===targetRight); - if(same && (state.monitor||mode==="NONE")) - return {ok:true,unchanged:true,message:"Channel input already connected."}; - const id=++auditionInputSerial; - auditionInputPending={id,channel,mode,left:mode==="NONE"?-1:left, - right:targetRight,epoch,revision:Number(d.revision), - phase:"source",wasMonitoring:!!state.monitor}; - // A same-format physical pin move already has a 64-sample ramp in RT - // and must NEVER interrupt live monitoring or rebuild VST3 instances. - // A structural change while monitoring safely mutes first, then restores - // monitoring only after native patch ACK and current-epoch readback. - if(state.monitor&&!same&&(!r||r.mode!==mode)){ - auditionInputPending.phase="mute"; - api.emitEvent("arMixAction",{action:"monitor",value:false, - expectedEpoch:epoch,expectedRevision:Number(d.revision)}); - }else if(same)auditionMonitor(); - else auditionSubmit(); - return {ok:true,pending:true,live:!!state.monitor,epoch, - message:"CH "+(channel+1)+" input requested; native readback pending."}; - }; - api.addEventListener("arMixAudioArmAck",ack=>{ - const p=auditionInputPending; - if(!p||!(p.phase==="mute"||p.phase==="monitor"))return; - if(Number(ack?.deviceEpoch)!==p.epoch||ack?.ok!==true || - (p.phase==="mute"&&ack.armed!==false) || - (p.phase==="monitor"&&ack.armed!==true)){ - auditionAbort("MONITOR REJECTED · "+String(ack?.error||"Native output not ready")); - return; - } - state.monitor=!!ack.armed; - if(p.phase==="mute")auditionSubmit(); - else { - auditionInputPending=null; - auditionResult(true,"CH "+(p.channel+1)+" · audio routed to MAIN (physical listening unverified)",p.channel); - } - }); - api.addEventListener("arMixSourceSwitchAck",ack=>{ - const p=auditionInputPending; - if(!p||p.phase!=="source"||Number(ack?.requestId)!==p.id|| - Number(ack?.channel)!==p.channel)return; - const next=ack?.state||{},row=next.acceptedRoute?.channels?.[p.channel]; - const verified=ack.ok===true && Number(next.epoch)===p.epoch && - Number(state.dryRoutingLab?.epoch)===p.epoch && - next.ready===true && !next.topologyFault && - row?.mode===p.mode && (p.mode==="NONE"|| - row.left===p.left&&row.right===p.right); - if(!verified){ - auditionAbort("INPUT REJECTED · "+String(ack?.error||"Native route readback mismatch")); - return; - } - state.dryRoutingLab=next; - hydrateAcceptedRoute();renderPatchMatrix();updateRouteLabIdentity(); - window.dispatchEvent(new Event("arMixRoutingDraftChanged")); - const anyInput=(next.acceptedRoute?.channels||[]) - .some(x=>x.mode==="MONO"||x.mode==="STEREO"); - if(p.mode==="NONE"&&!anyInput){ - auditionInputPending=null; - auditionResult(true,"Last input disconnected · MAIN monitoring off",p.channel); - }else if(p.wasMonitoring && state.monitor){ - auditionInputPending=null; - auditionResult(true,"CH "+(p.channel+1)+" · native input switched live",p.channel); - }else auditionMonitor(); - }); window.__arMixOpenChannelPatch=(channel,tab="input")=>{ if(!Number.isInteger(channel)||channel<0||channel>=10)return; openRoutingLab(); @@ -1881,9 +1755,28 @@ fastAudioArm(d); return {ok:true,pending:true,phase:"arm"}; } - // Never guess CH1/CH2 hardware sources. In an Audition-style mixer - // the operator chooses IN on the strip they actually intend to use. - return {ok:false,error:"Choose IN on any mixer channel first; no automatic CH1/CH2 patch."}; + // First boot only. Leave existing custom sources and BUS routing alone. + if(!Array.isArray(draftRoutes)||draftRoutes.length<2 || + draftRoutes[0].mode!=="NONE"||draftRoutes[1].mode!=="NONE") + return {ok:false,error:"Custom input patch already exists. APPLY or REVERT it first."}; + const pins=ports.slice(0,2).map(p=>p.port); + for(let i=0;i1?"/CH02":"")+" → MAIN · WAITING FOR NATIVE PATCH ACK"); + return {ok:true,pending:true,phase:"patch"}; }; // One explicit APPLY owns patch ACK -> physical ARM, no second START. const submitFastCustomPatch=()=>{ @@ -2137,9 +2030,6 @@ api.addEventListener("arMixStatus",d=>{ if(fastAudioPending&&Number(d?.dryRoutingLab?.epoch)!==fastAudioPending.epoch) fastAudioAbort("START CANCELLED · audio device generation changed; output remains MUTED."); - if(auditionInputPending && - Number(d?.dryRoutingLab?.epoch)!==auditionInputPending.epoch) - auditionAbort("INPUT CANCELLED · audio interface changed; monitoring remains muted."); state=d; // Single controller owns epoch hydration even if the full PATCH workspace // is closed. The status projection used by MIX is deliberately read-only. From 5e87a93c49868c98de6a35564e4ba1c61f934ded Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 11:30:27 +0700 Subject: [PATCH 07/26] chore(integration): keep legacy standalone source unchanged; Windows native UI is approved preview bundle --- web/mixer-io.js | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/web/mixer-io.js b/web/mixer-io.js index e84b82ec8..bf34032b4 100644 --- a/web/mixer-io.js +++ b/web/mixer-io.js @@ -386,9 +386,9 @@ 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?'Choose a verified audio interface in Audio I/O': - 'Select an input for CH '+(sourceChooserChannel+1)+ - ' · native mixer handles safe changes and monitoring automatically'; + sourceNote.textContent=!s.ready?'No verified native driver input ports': + 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; @@ -967,7 +967,7 @@ row.dataset.state==='live'?'LIVE · ACK':'UNPATCHED')); row.append(identity,mode,left,right,action);section.appendChild(row); } - section.appendChild(node('p','arIOQuickFooter','Choose IN on any mixer strip. The native mixer connects that channel to MAIN after verified readback; no separate Patch or Start.')); + section.appendChild(node('p','arIOQuickFooter','Select verified inputs, click USE INPUT. Native routing handles any required safe mute, ACK and re-arm automatically.')); return section; } function stageQuickInput(button){ @@ -1612,12 +1612,17 @@ s.ready?'E'+s.epoch+' · Native APPLY required for input edits':'CHOOSE A VERIFIED DIRECT DEVICE'; el('arIOFeedback').textContent=(ioTab==='device'?deviceNote:matrixMessage)||hint; } - // One hardware-IN chooser for EVERY mixer strip, as in Audition/FL. - // Native routingSourceSwitch supports silent first boot and live per-strip - // updates. Do not stage a second draft graph or guess CH1/CH2 sources. + // Operator makes one choice. Same-format moves use the native source ramp; + // structural moves use FAST3's safe MUTE -> graph ACK -> guarded ARM internally. function commitSourceInOneGesture(channel,mode,left,right){ - return window.__arMixChooseChannelInput?.(channel,mode,left,right)|| - {ok:false,error:'Verified native audio routing is not initialized'}; + const s=route(),accepted=s.acceptedRoute?.channels?.[channel]; + if(accepted?.mode===mode&&['MONO','STEREO'].includes(mode)) + return window.__arMixCommitSelectedSource?.(channel,mode,left,right); + const staged=window.__arMixStageChannelInput?.(channel,mode,left,right); + if(!staged?.ok)return staged||{ok:false,error:'Native staging unavailable'}; + const committed=window.__arMixApplyAndActivate?.(); + return committed?.ok?{ok:true,pending:true,live:false,epoch:s.epoch}: + {ok:false,error:committed?.error||'Safe native APPLY rejected'}; } function changeSource(select){ const channel=Number(select.dataset.channel); @@ -2000,17 +2005,14 @@ if(ack?.active?.open&&Number(ack.active.deviceGeneration)!==oldGeneration) deviceMatrixWaitEpoch=route().epoch; deviceDraft=makeDeviceDraft(); - // After a device APPLY the operator chooses IN on the desired strip. - // Never silently map the first two capture pins or start output. + if(ack?.ok&&ack?.active?.open)applyAfterDevice={generation:Number(ack.active.deviceGeneration),capture:ack.active.captureDevice,playback:ack.active.playbackDevice,driver:ack.active.backend}; deviceNote=ack?.ok?'DEVICE ACCEPTED · OUTPUT MUTED · '+devicePinNextStep(): (ack?.state||'REJECTED')+' · '+(ack?.error||'Check driver and retry'); // Same real routing controller sees the new device epoch via normal status. lastSignature='';if(!overlay.hidden)refreshIO(); }); backend?.addEventListener?.('arMixRoutingLabAck',ack=>{ - // Advanced matrix APPLY owns its own draft; the per-channel IN selector - // is committed by arMixMixerSourceResult, not by this structural ACK. - if(quickSourcePending?.structural){ + if(quickSourcePending){ const requested=quickSourcePending; quickSourcePending=null; if(ack?.ok!==true)window.__arMixRevertMixerDraft?.(); @@ -2029,18 +2031,6 @@ renderSourceChooser(); } }); - window.addEventListener('arMixMixerSourceResult',event=>{ - const detail=event.detail||{}; - if(quickSourcePending?.channel===detail.channel)quickSourcePending=null; - const message=detail.message|| - (detail.ok?'Verified hardware source connected':'Hardware source rejected'); - matrixMessage=message; - if(!sourceChooser.hidden){ - renderSourceChooser(); - sourceNote.textContent=message; - } - lastSignature='';refresh(); - }); window.addEventListener('arMixSourceSwitchResult',event=>{ const result=event.detail||{}; if(quickSourcePending?.live&&quickSourcePending.channel===result.channel) From b4deb9bb65843191bef35253cff339f8c9188137 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 11:32:01 +0700 Subject: [PATCH 08/26] fix(approved-gui): present verified native device ports on every mixer IN without redesign --- site/preview-v2/index.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/site/preview-v2/index.html b/site/preview-v2/index.html index 7be436edb..4be5bc3ba 100644 --- a/site/preview-v2/index.html +++ b/site/preview-v2/index.html @@ -228,7 +228,7 @@ visibility:'M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zm0 12.5a5 5 0 1 1 0-10 5 5 0 0 1 0 10zm0-2a3 3 0 1 0 0-6 3 3 0 0 0 0 6z' }); const materialIcon=(name)=>''; -const option=(values,selected)=>values.map(x=>'').join(''); +const option=(values,selected)=>values.map(x=>{const value=Array.isArray(x)?x[0]:x,label=Array.isArray(x)?x[1]:x;return '';}).join(''); // DEMO mult is a source binding, not a Group sum or copied JS audio engine. // Production must supply stable native ChannelId/TapPoint admission + ACK. const splitSourceLabel=(id,tap)=>'CH'+String(id).padStart(2,'0')+' '+tap+'-FX SPLIT'; @@ -254,6 +254,14 @@ return tracks.filter(x=>x.id!==t.id&&parseSplitSource(x.input)?.sourceId===t.id).length; } const channelOptions=(t,type)=>{ + // JUCE native only: the hardware I/O list comes from the verified active + // driver. The public /preview/ remains an unchanged visual reference. + if(window.__JUCE__?.backend){ + const native=window.__ARMIX_NATIVE_M2__?.channelOptions?.(t,type); + if(native)return native; + return type==='input'?[['None','Choose audio device…']]: + type==='output'?[[t.output||'Master','MAIN']]:['None']; + } if(type==='input')return t.kind==='audio' ?['None','Input 1 (Mono)','Input 2 (Mono)','Input 1 + 2 (Stereo)','CABLE Output L','CABLE Output R','CABLE Output L/R (Stereo)', ...tracks.filter(x=>x.kind==='audio'&&x.id!==t.id).flatMap(x=> From b56caa5c5fab2c869032174d5f17eb46fa8b1f72 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 11:33:22 +0700 Subject: [PATCH 09/26] feat(native): any visible mixer IN selects real hardware source and self-manages native safe monitor transition --- web/approved-native-bridge.js | 175 ++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 71c743c69..643f6934b 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -201,6 +201,122 @@ menu.append(caption,setup,hardwareNote); updateHardwarePanel(hardware); } + // Same operator contract as Adobe/FL: every processing strip selects + // its own VERIFIED hardware input; output initially targets MAIN. No + // forced CH1, no draft graph, no separate Start or Arm button. + const inputAt=track=>{ + const index=scope?.tracks?.indexOf(track)??-1; + return index>=0&&index<10?index:-1; + }; + const routeRow=index=>(lastDryReadback?.acceptedRoute?.channels|| + lastDryReadback?.preparedM4Route?.channels||[])[index]; + const routeValue=r=>r?.mode==="MONO"?"MONO:"+r.left: + r?.mode==="STEREO"?"STEREO:"+r.left+":"+r.right:"None"; + const hardwareInputs=()=>{ + const d=hardware?.device; + if(!deviceReady()||!Array.isArray(d?.inputEndpoints))return []; + const enabled=new Set(d.enabledInputs); + return d.inputEndpoints.filter(p=>p?.active===true && + Number.isInteger(p.port)&&enabled.has(p.port) && p.port>=0&&p.port<64); + }; + let nativeSourcePending=null,nativeSourceSerial=1500000; + const signalSourceResult=message=>{status(message);}; + const stopSource=error=>{ + nativeSourcePending=null; + signalSourceResult("INPUT NOT CHANGED · "+error+ + ". Review hardware I/O; previous audio route preserved."); + }; + const submitSource=()=>{ + const p=nativeSourcePending,d=lastDryReadback||{}; + if(!p||!deviceReady()||!d.ready||d.topologyFault|| + String(d.epoch)!==String(p.epoch)||Number(d.revision)!==p.revision){ + stopSource("device or route became stale");return; + } + p.phase="source"; + backend.emitEvent("arMixAction",{ + action:"routingSourceSwitch",requestId:p.id,channel:p.channel, + mode:p.mode,left:p.left,right:p.right, + deviceEpoch:p.epoch,revision:p.revision + }); + signalSourceResult("CH "+(p.channel+1)+" · connecting verified hardware source…"); + }; + const monitorAfterSource=()=>{ + const p=nativeSourcePending,d=p?.accepted; + if(!p||!d?.ready||!d.hasAcceptedRoute||d.topologyFault|| + String(d.epoch)!==String(p.epoch)){ + stopSource("output cannot be monitored until route is verified");return; + } + p.phase="monitor";p.revision=Number(d.revision); + backend.emitEvent("arMixAction",{action:"monitor",value:true, + expectedEpoch:p.epoch,expectedRevision:p.revision}); + signalSourceResult("CH "+(p.channel+1)+" · enabling MAIN monitoring…"); + }; + const chooseNativePhysicalInput=(track,value)=>{ + const channel=inputAt(track),d=lastDryReadback||{}; + if(channel<0)return false; + if(value==="__IO__"){openNativeAudioIO();return true;} + if(nativeSourcePending) {signalSourceResult("Previous input is still being verified.");return true;} + if(!deviceReady()||!d.ready||d.topologyFault||!d.active|| + String(d.epoch)!==hardware.device.epoch){ + signalSourceResult("Choose Audio I/O and a valid input/output device first."); + return true; + } + const mode=value==="None"?"NONE":value.startsWith("MONO:")?"MONO": + value.startsWith("STEREO:")?"STEREO":"INVALID"; + if(mode==="INVALID"){signalSourceResult("Input unavailable on this hardware.");return true;} + const pins=hardwareInputs(),set=new Set(pins.map(p=>p.port)); + const parts=value.split(":"),left=mode==="NONE"?-1:Number(parts[1]), + right=mode==="STEREO"?Number(parts[2]):-1; + if(mode==="MONO"&&(!set.has(left)||parts.length!==2) || + mode==="STEREO"&&(!set.has(left)||!set.has(right)||left===right||parts.length!==3)){ + signalSourceResult("This input is not enabled by the selected audio driver.");return true; + } + const before=routeRow(channel); + const unchanged=routeValue(before)===value; + if(unchanged&&hardware.device.outputArmed || unchanged&&mode==="NONE") + return true; + const epoch=Number(d.epoch),revision=Number(d.revision); + if(!Number.isSafeInteger(epoch)||epoch<=0||!Number.isSafeInteger(revision)||revision<1){ + signalSourceResult("Native route revision is not ready.");return true; + } + nativeSourcePending={id:++nativeSourceSerial,channel,mode,left,right, + epoch,revision,phase:"source",wasMonitoring:hardware.device.outputArmed===true}; + // Native M4 applies SAME-FORMAT source changes in 64-sample crossfade. + // Structural changes while monitored mute on the existing control thread + // before preparing the immutable graph, then resume only after real ACK. + if(hardware.device.outputArmed && !unchanged&&before?.mode!==mode){ + nativeSourcePending.phase="mute"; + backend.emitEvent("arMixAction",{action:"monitor",value:false, + expectedEpoch:epoch,expectedRevision:revision}); + }else if(unchanged){ + nativeSourcePending.accepted=d; + monitorAfterSource(); + }else submitSource(); + return true; + }; + function nativeChannelOptions(track,type){ + if(type==="input"){ + if(inputAt(track)<0)return [["None","No input"]]; + const pins=hardwareInputs(),list=[["None","No input"]]; + for(const pin of pins) + list.push(["MONO:"+pin.port,"Mono · IN "+(pin.port+1)+" · "+(pin.label||"Input")]); + for(let i=0;i+1