From 27ed2034ab166ec9c41eda5ec72b6f3ca0c44328 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:12:20 +0700 Subject: [PATCH 01/28] fix(workflow): bind approved strip identity to native channels and drive visible IN selectors from physical ports --- web/mixer-io.js | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/web/mixer-io.js b/web/mixer-io.js index bf34032b4..8bfd6ae29 100644 --- a/web/mixer-io.js +++ b/web/mixer-io.js @@ -775,7 +775,25 @@ toolbar.querySelectorAll('[data-mix-mode]').forEach(b=>{const selected=b.dataset.mixMode===mode;b.classList.toggle('active',selected);b.setAttribute('aria-pressed',String(selected));}); refresh(); } + // Approved /preview/ renders data-id (stable UI track identity), while + // the native routing controller uses zero-based channel ordinals. + // Previously all .strip[data-strip] queries matched ZERO strips, silently + // disabling every existing native per-channel source selector. + // Translate identity on each render; never assume DOM order after drag. + function bindNativeChannelStrips(){ + if(!isNative())return; + const view=window.__ARMIX_NATIVE_SCOPE__; + const inputs=Array.isArray(view?.tracks)? + view.tracks.filter(track=>track?.kind==='audio').slice(0,10):[]; + const ordinal=new Map(inputs.map((track,i)=>[String(track.id),i])); + for(const strip of mixer.querySelectorAll('.strip[data-id]')){ + const index=ordinal.get(String(strip.dataset.id)); + if(index===undefined)strip.removeAttribute('data-strip'); + else strip.dataset.strip=String(index); + } + } function decorate(){ + bindNativeChannelStrips(); for(const strip of mixer.querySelectorAll('.strip[data-strip]')){ // Every physical channel gets its own source selector. The native // routing controller is unchanged and owns every hardware APPLY. @@ -808,6 +826,16 @@ const source=strip.querySelector('.arBankSource'),output=strip.querySelector('.arBankOutput'); if(!source||!output)return; const current=valueFor(r),choices=portsFor(s,r); + // The approved DAW-like IN dropdown is the canonical operator control. + // Replace its PREVIEW options only inside JUCE with verified physical + // port names. Every track can bind ANY input, including shared sources. + const visible=strip.querySelector('.route-select[data-field="input"]'); + if(visible && isNative()){ + populate(visible,choices,current); + visible.dataset.channel=String(i); + visible.disabled=!s.ready||!!s.pending||!!quickSourcePending; + visible.title='CH '+(i+1)+' · Select physical input · native ACK'; + } const inline=strip.querySelector('.arChannelQuickInput'); if(inline){ populate(inline,choices,current); @@ -1628,7 +1656,7 @@ const channel=Number(select.dataset.channel); 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.matches('.arBankSource,.arChannelQuickInput'); + const direct=select.matches('.arBankSource,.arChannelQuickInput,.route-select[data-field="input"]'); const response=direct?commitSourceInOneGesture(channel,mode,left,right): window.__arMixStageChannelInput?.(channel,mode,left,right); if(response?.pending)quickSourcePending={channel,epoch:response.epoch, @@ -1670,6 +1698,12 @@ else el('arIOFeedback').textContent=result.message; lastSignature='';refresh();return; } + if(e.target.matches('.route-select[data-field="input"]')&&isNative()){ + // Capture before the Pages demo handleField reducer and before any + // later native adapter handler. Never write demo t.input/PCM. + e.preventDefault();e.stopImmediatePropagation(); + changeSource(e.target);return; + } if(e.target.matches('.arChannelQuickInput,.arBankSource,.arIOSource'))changeSource(e.target); if(e.target.matches('.arBankChannelFormat')){ const response=window.__arMixStageChannelFormat?.( From 5ae93ed3bb5308f4dca8328652eb7073a79db2f8 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:12:59 +0700 Subject: [PATCH 02/28] fix(workflow): remove competing CH1 Patch/Arm wizard, reuse unified Audio I/O and ten-track IN controls --- web/approved-native-bridge.js | 138 +++++++++------------------------- 1 file changed, 35 insertions(+), 103 deletions(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 7e548a6e3..9471bb75b 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -145,67 +145,38 @@ } } - // 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; - }; + // Existing approved /preview/ mixer owns input-selection presentation. + // web/mixer-io.js owns ten physical channel selectors and the SINGLE + // custom WebView2 Audio I/O dialog. Do not add a competing CH1 wizard or + // invoke the generic JUCE selector for routine live performance. + let hardware=null,hardwareNote=null,muteBtn=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); 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){ + const nextText=!deviceOpen?"Device not ready": + d.outputArmed?"Output enabled":"Output muted"; + if(label.textContent!==nextText)label.textContent=nextText; + } const warning=document.querySelector?.(".status-bar .warning"); - if(warning)warning.textContent=!deviceOpen?"NO VERIFIED AUDIO DEVICE": - 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; + if(warning){ + const nextText=!deviceOpen?"NO VERIFIED AUDIO DEVICE": + d.outputArmed?(next.admitted?"NATIVE PCM · HARDWARE FAT PENDING": + "OUTPUT ENABLED · VERIFY AUDIO"): + legacy()?.routeAccepted?"INPUT ROUTED · OUTPUT MUTED": + "SELECT HARDWARE INPUT ON ANY CHANNEL"; + if(warning.textContent!==nextText)warning.textContent=nextText; } - 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."; + if(muteBtn)muteBtn.disabled=!deviceOpen||!d.outputArmed; + if(hardwareNote){ + const evidence=protocol.diagnoseFirstSound?.(next); + const text=evidence?evidence.readout+" · "+ + evidence.nextAction:"Awaiting verified hardware readback"; + if(hardwareNote.textContent!==text)hardwareNote.textContent=text; } } function installFirstSoundMenu() { @@ -217,53 +188,23 @@ 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=item("span","more-tools-caption","HARDWARE AUDIO · ADVANCED"); + const setup=item("button","tool","Audio I/O settings"); + // Same custom device dialog as the toolbar's Audio Setup button. + // No additional native AudioDeviceSelectorComponent window. 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."); + if(typeof window.__arMixOpenAudioIO==="function") + window.__arMixOpenAudioIO("device"); + else status("AUDIO I/O panel unavailable; hardware unchanged"); }); muteBtn=item("button","tool","Mute output"); muteBtn.addEventListener("click",()=>{ backend.emitEvent("arMixAction",{action:"monitor",value:false}); - status("NATIVE: output MUTE requested; awaiting JUCE ACK."); + status("Native output MUTE requested; awaiting engine ACK"); }); - hardwareNote=item("span","more-tools-caption","Device not initialized"); + hardwareNote=item("span","more-tools-caption","Select IN on any channel strip"); hardwareNote.style.whiteSpace="normal"; - menu.append(caption,setup,inputSelect,routeBtn,armBtn,muteBtn,hardwareNote); + menu.append(caption,setup,muteBtn,hardwareNote); updateHardwarePanel(hardware); } @@ -275,7 +216,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 G0 · pilih hardware IN langsung pada CH1–CH10; fader/WIRE ChannelId tetap menunggu accepted PCM."); return; } // Control readback may change at the SAME structural graph revision. @@ -319,15 +260,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.": From 0372c1b16095c22a8477eed795236c4cca2998cf Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:14:03 +0700 Subject: [PATCH 03/28] revert(nonruntime): avoid modifying legacy mixer-io not bundled in approved native WebView --- web/mixer-io.js | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/web/mixer-io.js b/web/mixer-io.js index 8bfd6ae29..bf34032b4 100644 --- a/web/mixer-io.js +++ b/web/mixer-io.js @@ -775,25 +775,7 @@ toolbar.querySelectorAll('[data-mix-mode]').forEach(b=>{const selected=b.dataset.mixMode===mode;b.classList.toggle('active',selected);b.setAttribute('aria-pressed',String(selected));}); refresh(); } - // Approved /preview/ renders data-id (stable UI track identity), while - // the native routing controller uses zero-based channel ordinals. - // Previously all .strip[data-strip] queries matched ZERO strips, silently - // disabling every existing native per-channel source selector. - // Translate identity on each render; never assume DOM order after drag. - function bindNativeChannelStrips(){ - if(!isNative())return; - const view=window.__ARMIX_NATIVE_SCOPE__; - const inputs=Array.isArray(view?.tracks)? - view.tracks.filter(track=>track?.kind==='audio').slice(0,10):[]; - const ordinal=new Map(inputs.map((track,i)=>[String(track.id),i])); - for(const strip of mixer.querySelectorAll('.strip[data-id]')){ - const index=ordinal.get(String(strip.dataset.id)); - if(index===undefined)strip.removeAttribute('data-strip'); - else strip.dataset.strip=String(index); - } - } function decorate(){ - bindNativeChannelStrips(); for(const strip of mixer.querySelectorAll('.strip[data-strip]')){ // Every physical channel gets its own source selector. The native // routing controller is unchanged and owns every hardware APPLY. @@ -826,16 +808,6 @@ const source=strip.querySelector('.arBankSource'),output=strip.querySelector('.arBankOutput'); if(!source||!output)return; const current=valueFor(r),choices=portsFor(s,r); - // The approved DAW-like IN dropdown is the canonical operator control. - // Replace its PREVIEW options only inside JUCE with verified physical - // port names. Every track can bind ANY input, including shared sources. - const visible=strip.querySelector('.route-select[data-field="input"]'); - if(visible && isNative()){ - populate(visible,choices,current); - visible.dataset.channel=String(i); - visible.disabled=!s.ready||!!s.pending||!!quickSourcePending; - visible.title='CH '+(i+1)+' · Select physical input · native ACK'; - } const inline=strip.querySelector('.arChannelQuickInput'); if(inline){ populate(inline,choices,current); @@ -1656,7 +1628,7 @@ const channel=Number(select.dataset.channel); 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.matches('.arBankSource,.arChannelQuickInput,.route-select[data-field="input"]'); + const direct=select.matches('.arBankSource,.arChannelQuickInput'); const response=direct?commitSourceInOneGesture(channel,mode,left,right): window.__arMixStageChannelInput?.(channel,mode,left,right); if(response?.pending)quickSourcePending={channel,epoch:response.epoch, @@ -1698,12 +1670,6 @@ else el('arIOFeedback').textContent=result.message; lastSignature='';refresh();return; } - if(e.target.matches('.route-select[data-field="input"]')&&isNative()){ - // Capture before the Pages demo handleField reducer and before any - // later native adapter handler. Never write demo t.input/PCM. - e.preventDefault();e.stopImmediatePropagation(); - changeSource(e.target);return; - } if(e.target.matches('.arChannelQuickInput,.arBankSource,.arIOSource'))changeSource(e.target); if(e.target.matches('.arBankChannelFormat')){ const response=window.__arMixStageChannelFormat?.( From 312039b81fa888291d16603845c33337b260e47e Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:16:19 +0700 Subject: [PATCH 04/28] feat(native): publish ten verified M4 physical input assignments for DAW-style per-track selectors --- integration/ApprovedNativeRuntimeSnapshot.h | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/integration/ApprovedNativeRuntimeSnapshot.h b/integration/ApprovedNativeRuntimeSnapshot.h index eaafd93b0..4e07c8b41 100644 --- a/integration/ApprovedNativeRuntimeSnapshot.h +++ b/integration/ApprovedNativeRuntimeSnapshot.h @@ -82,6 +82,36 @@ inline bool publishVerifiedFirstSoundState(juce::var& snapshot, boolIs(route,"hasAcceptedRoute",true)); firstSound->setProperty("routingRevision",physicalReady ?juce::String(static_cast(revision)):juce::String("0")); + // Direct physical-source readback for EVERY existing 10-channel M4 strip. + // Never infer source routes from demo UI, or mark stale controls accepted. + juce::Array sources; + if(physicalReady) { + const bool patched=boolIs(route,"hasAcceptedRoute",true); + const auto accepted=route.getProperty( + patched?"acceptedRoute":"preparedM4Route",{}); + const auto rows=accepted.getProperty("channels",{}); + const auto* list=rows.getArray(); + if(list && list->size()==10) { + for(const auto& row:*list) { + const auto mode=row.getProperty("mode",{}).toString(); + const auto left=row.getProperty("left",{}); + const auto right=row.getProperty("right",{}); + const bool mono=mode=="MONO", stereo=mode=="STEREO"; + const bool valid=mode=="NONE" || + ((mono||stereo) && (left.isInt()||left.isInt64()) && + (right.isInt()||right.isInt64()) && + inputs.getArray()->contains(left) && + (!stereo || (inputs.getArray()->contains(right) && left!=right))); + if(!valid) {sources.clear();break;} + auto src=std::make_unique(); + src->setProperty("mode",mode); + src->setProperty("left",mono||stereo?left:juce::var(-1)); + src->setProperty("right",stereo?right:juce::var(-1)); + sources.add(juce::var(src.release())); + } + } + } + firstSound->setProperty("channelSources",juce::var(sources)); // Do not write the route to the graph or change native capability flags. snapshot.getDynamicObject()->setProperty("legacyM4",juce::var(firstSound.release())); return physicalReady; From 2d92cc494b1f22cf2b172611d39a3e5e93a792ab Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:18:07 +0700 Subject: [PATCH 05/28] feat(workflow): direct ten-channel hardware IN selection, single native Audio I/O dialog and MAIN input monitor toggle --- web/approved-native-bridge.js | 300 +++++++++++++++++++++++++++++++++- 1 file changed, 297 insertions(+), 3 deletions(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 9471bb75b..9c5cf171d 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -151,8 +151,264 @@ // invoke the generic JUCE selector for routine live performance. let hardware=null,hardwareNote=null,muteBtn=null; const legacy=()=>hardware?.raw?.legacyM4; + + // Adobe Audition / FL Studio operator pattern: + // one hardware setup, physical IN selector on EACH channel, master monitor. + // G0 is still the real existing ten-channel M4 source kernel, not fake + // ChannelId admission. Physical route mutation always needs JUCE ACK. + const physicalUiIds=(scope?.tracks||[]).filter(t=>t.kind==="audio") + .slice(0,10).map(t=>String(t.id)); + let sourceRequest=10000, sourcePending=null, deviceInventory=null; + let deviceDialog=null, deviceDraft=null, devicePending=null, deviceMutePending=false; + const actualPorts=()=>Array.isArray(hardware?.device?.inputEndpoints)? + hardware.device.inputEndpoints.filter(p=>p?.active===true && + hardware.device.enabledInputs.includes(p.port)):[]; + const routeValue=r=>r?.mode==="MONO"?"MONO:"+r.left: + r?.mode==="STEREO"?"STEREO:"+r.left+":"+r.right:"NONE"; + const firstSoundReady=()=>hardware?.raw?.legacyM4?.active===true; + function portOptions(){ + const ports=actualPorts(),opts=[["NONE","None"]]; + const pins=new Set(ports.map(p=>p.port)); + for(const p of ports)opts.push(["MONO:"+p.port,"Mono · "+p.label]); + for(const p of ports)if(pins.has(p.port+1)) + opts.push(["STEREO:"+p.port+":"+(p.port+1), + "Stereo · IN "+(p.port+1)+"/"+(p.port+2)]); + return opts; + } + function syncDawNativeInputs(){ + const options=portOptions(); + const sources=hardware?.raw?.legacyM4?.channelSources; + const signature=JSON.stringify(options); + for(let i=0;i{ + const o=document.createElement("option");o.value=value;o.textContent=label;return o; + }); + select.replaceChildren(...nodes); + select.dataset.nativePins=signature; + } + const accepted=Array.isArray(sources)&&sources.length===10? + routeValue(sources[i]):"NONE"; + const pending=sourcePending?.channel===i; + if(!pending && select.value!==accepted)select.value=accepted; + select.disabled=!firstSoundReady()||!!sourcePending||!Array.isArray(sources)|| + sources.length!==10; + select.title="CH "+(i+1)+" · verified physical input · native ACK"; + } + const master=document.querySelector(".strip.master .route-top"); + if(master){ + let monitor=master.querySelector("[data-native-monitor]"); + if(!monitor){ + monitor=document.createElement("button"); + monitor.type="button";monitor.className="mx-util-key"; + monitor.dataset.nativeMonitor="1"; + monitor.setAttribute("aria-label","Enable or mute MAIN output monitoring"); + monitor.addEventListener("click",event=>{ + event.preventDefault();event.stopPropagation(); + const armed=hardware?.device?.outputArmed===true; + if(!armed && (!firstSoundReady()|| + hardware?.raw?.legacyM4?.routeAccepted!==true)){ + status("Select a physical input on a channel before monitoring MAIN"); + return; + } + const epoch=Number(hardware?.device?.epoch); + const rev=Number(hardware?.raw?.legacyM4?.routingRevision); + if(!armed && (!Number.isSafeInteger(epoch)||!Number.isSafeInteger(rev)|| + epoch<=0||rev<=0))return; + backend.emitEvent("arMixAction",{action:"monitor",value:!armed, + ...(!armed?{expectedEpoch:epoch,expectedRevision:rev}:{})}); + status(!armed?"MAIN monitor requested · awaiting hardware ACK": + "MAIN mute requested"); + }); + master.appendChild(monitor); + } + const armed=hardware?.device?.outputArmed===true; + monitor.textContent=armed?"I ON":"I OFF"; + monitor.title=armed?"MAIN output monitoring ON · click to MUTE": + "MAIN input monitoring OFF · click to listen"; + monitor.setAttribute("aria-pressed",String(armed)); + monitor.disabled=!armed && (!firstSoundReady()|| + hardware?.raw?.legacyM4?.routeAccepted!==true); + } + } + function changeNativeInput(event){ + const select=event.target?.closest?.('.route-select[data-field="input"]'); + if(!select || !connected)return; + event.preventDefault();event.stopImmediatePropagation(); + const index=Number(select.dataset.nativeChannel); + const parts=String(select.value).split(":"); + const mode=parts[0],left=mode==="NONE"?-1:Number(parts[1]); + const right=mode==="STEREO"?Number(parts[2]):-1; + const allowed=portOptions().some(pair=>pair[0]===select.value); + const epoch=Number(hardware?.device?.epoch); + const revision=Number(hardware?.raw?.legacyM4?.routingRevision); + if(!firstSoundReady()||!!sourcePending||!allowed|| + !Number.isInteger(index)||index<0||index>=10|| + !Number.isSafeInteger(epoch)||epoch<=0|| + !Number.isSafeInteger(revision)||revision<=0){ + status("INPUT REJECTED · verify hardware, native graph and actual ports"); + syncDawNativeInputs();return; + } + sourcePending={id:++sourceRequest,channel:index,mode,left,right, + epoch,revision}; + backend.emitEvent("arMixAction",{action:"routingSourceSwitch", + requestId:sourcePending.id,channel:index,mode,left,right, + deviceEpoch:epoch,revision}); + status("CH "+(index+1)+" INPUT · applying hardware source · native ACK pending"); + syncDawNativeInputs(); + } + function createAudioDeviceDialog(){ + if(deviceDialog)return deviceDialog; + const style=document.createElement("style"); + style.id="armix-native-device-style"; + style.textContent=` + #armixNativeDevice{width:min(560px,94vw);max-height:85vh;overflow:auto; + background:#13232d;color:#d9e7ee;border:1px solid #476373; + border-radius:9px;box-shadow:0 18px 65px #0009;padding:17px 19px; + font:12px Inter,Segoe UI,sans-serif} + #armixNativeDevice::backdrop{background:#0009} + #armixNativeDevice .io-top{display:flex;justify-content:space-between; + align-items:center;gap:12px;margin-bottom:15px} + #armixNativeDevice h3{font-size:15px;font-weight:550;margin:0} + #armixNativeDevice .io-fields{display:grid;grid-template-columns:124px 1fr; + align-items:center;gap:11px} + #armixNativeDevice label{color:#abbdc8} + #armixNativeDevice select{width:100%;min-width:0;padding:7px;background:#1d3441; + color:#e9f3fa;border:1px solid #536f7b;border-radius:5px;font:inherit} + #armixNativeDevice button{background:#284454;color:#f0f7fa; + border:1px solid #607b89;border-radius:5px;padding:7px 13px; + font:inherit;cursor:pointer} + #armixNativeDevice button:disabled{opacity:.44;cursor:default} + #armixNativeDevice .io-actions{display:flex;justify-content:flex-end;gap:8px; + margin-top:16px} + #armixNativeDevice [data-io-status]{display:block;margin-top:14px;min-height:2em; + color:#bcd3df;line-height:1.5} + #armixNativeDevice .io-advanced{margin-top:14px} + #armixNativeDevice .io-advanced summary{cursor:pointer;color:#b3c8d3} + `; + document.head.appendChild(style); + deviceDialog=document.createElement("dialog");deviceDialog.id="armixNativeDevice"; + deviceDialog.innerHTML=` +

Audio I/O · Hardware

+
+
+ + + +
+
Advanced · Sample rate / Buffer +
+ + + +
+
+ Reading actual JUCE devices… +
+
`; + document.body.appendChild(deviceDialog); + const get=id=>deviceDialog.querySelector("#"+id); + deviceDialog.querySelector("[data-io-close]").addEventListener("click", + ()=>deviceDialog.close()); + deviceDialog.querySelector("[data-io-refresh]").addEventListener("click", + ()=>backend.emitEvent("arMixAction",{action:"audioDeviceInventory"})); + get("armixDriver").addEventListener("change",()=>{ + const type=deviceInventory?.types?.find(x=>x.name===get("armixDriver").value); + deviceDraft={backend:type?.name||"",captureDevice:type?.inputs?.[0]||"", + playbackDevice:type?.outputs?.[0]||"",sampleRate:0,bufferSize:0}; + refreshAudioDeviceDialog(); + }); + get("armixCapture").addEventListener("change",()=>{ + if(deviceDraft)deviceDraft.captureDevice=get("armixCapture").value; + }); + get("armixPlayback").addEventListener("change",()=>{ + if(deviceDraft)deviceDraft.playbackDevice=get("armixPlayback").value; + refreshAudioDeviceHint(); + }); + deviceDialog.querySelector("[data-io-apply]").addEventListener("click",()=>{ + if(!deviceInventory?.active||!deviceDraft||devicePending)return; + deviceDraft.sampleRate=Number(get("armixRate").value); + deviceDraft.bufferSize=Number(get("armixBuffer").value); + const type=deviceInventory.types.find(x=>x.name===deviceDraft.backend); + if(!type?.inputs?.includes(deviceDraft.captureDevice)|| + !type?.outputs?.includes(deviceDraft.playbackDevice)|| + (!type.separate&&deviceDraft.captureDevice!==deviceDraft.playbackDevice)){ + getStatus("Invalid driver/input/output selection");return; + } + devicePending={requestId:"io-"+(++sourceRequest), + generation:Number(deviceInventory.active.deviceGeneration)}; + if(hardware?.device?.outputArmed===true){ + deviceMutePending=true; + backend.emitEvent("arMixAction",{action:"monitor",value:false}); + getStatus("Muting MAIN safely before switching device…"); + }else sendDeviceApply(); + }); + return deviceDialog; + } + function getStatus(message){ + const el=deviceDialog?.querySelector("[data-io-status]"); + if(el)el.textContent=message; + } + function fillSelect(el,items,current){ + el.replaceChildren(...items.map(([v,label])=>{ + const o=document.createElement("option");o.value=String(v);o.textContent=label; + return o; + })); + if(items.some(x=>String(x[0])===String(current)))el.value=String(current); + } + function refreshAudioDeviceHint(){ + const output=String(deviceDraft?.playbackDevice||""); + const virtual=/virtual|cable input|vb-audio|voicemeeter/i.test(output); + getStatus(virtual?"Virtual playback output · NOT automatically audible on headphones": + "Selected playback: "+(output||"none")+" · output stays muted during setup"); + } + function refreshAudioDeviceDialog(){ + if(!deviceDialog?.open||!deviceInventory)return; + const d=deviceDialog,types=Array.isArray(deviceInventory.types)? + deviceInventory.types:[]; + const active=deviceInventory.active||{}; + if(!deviceDraft){ + deviceDraft={backend:active.backend||types[0]?.name||"", + captureDevice:active.captureDevice||"",playbackDevice:active.playbackDevice||"", + sampleRate:0,bufferSize:0}; + } + const type=types.find(x=>x.name===deviceDraft.backend); + fillSelect(d.querySelector("#armixDriver"),types.map(t=>[t.name,t.name]),deviceDraft.backend); + fillSelect(d.querySelector("#armixCapture"), + (type?.inputs||[]).map(x=>[x,x]),deviceDraft.captureDevice); + fillSelect(d.querySelector("#armixPlayback"), + (type?.outputs||[]).map(x=>[x,x]),deviceDraft.playbackDevice); + const apply=d.querySelector("[data-io-apply]"); + apply.disabled=!!devicePending||!type||!type.inputs?.includes(deviceDraft.captureDevice)|| + !type.outputs?.includes(deviceDraft.playbackDevice); + refreshAudioDeviceHint(); + } + function openNativeAudioSetup(){ + const dialog=createAudioDeviceDialog(); + if(!dialog.open)dialog.showModal(); + backend.emitEvent("arMixAction",{action:"audioDeviceInventory"}); + } + function sendDeviceApply(){ + if(!devicePending||!deviceInventory?.active)return; + backend.emitEvent("arMixAction",{ + action:"audioDeviceApply", + requestId:devicePending.requestId, + expectedDeviceGeneration:devicePending.generation, + config:{...deviceDraft,enabledInputs:[],enabledOutputs:[]} + }); + getStatus("Opening selected hardware · verifying actual driver readback…"); + } function updateHardwarePanel(next) { hardware=next||null; + syncDawNativeInputs(); const d=next?.device; const deviceOpen=Boolean(d?.backend && d.sampleRate>0 && d.enabledOutputs.length>=2); @@ -193,9 +449,7 @@ // Same custom device dialog as the toolbar's Audio Setup button. // No additional native AudioDeviceSelectorComponent window. setup.addEventListener("click",()=>{ - if(typeof window.__arMixOpenAudioIO==="function") - window.__arMixOpenAudioIO("device"); - else status("AUDIO I/O panel unavailable; hardware unchanged"); + openNativeAudioSetup(); }); muteBtn=item("button","tool","Mute output"); muteBtn.addEventListener("click",()=>{ @@ -260,7 +514,44 @@ }); backend.addEventListener("arMixConsoleSnapshot", snapshot=>controller.onSnapshot(snapshot)); backend.addEventListener("arMixConsoleAck", ack=>controller.onAck(ack)); + // Accepted native M4 source-switch ACK, verified against actual route + // readback; neither UI option nor ACK alone invents PCM or monitoring. + backend.addEventListener("arMixSourceSwitchAck",ack=>{ + const p=sourcePending; + if(!p||ack?.requestId!==p.id||ack?.channel!==p.channel)return; + sourcePending=null; + const route=ack?.state?.acceptedRoute?.channels?.[p.channel]; + const valid=ack.ok===true&&Number(ack?.state?.epoch)===p.epoch&& + route?.mode===p.mode&& + (p.mode==="NONE" || (route?.left===p.left&&route?.right===p.right)); + status(valid?"CH "+(p.channel+1)+" input connected · monitor on MAIN to listen": + "CH "+(p.channel+1)+" input rejected · "+String(ack?.error||"readback mismatch")); + controller?.subscribe(); + syncDawNativeInputs(); + }); + backend.addEventListener("arMixAudioDeviceInventory",list=>{ + if(!list || !Array.isArray(list.types))return; + deviceInventory=list; + refreshAudioDeviceDialog(); + }); + backend.addEventListener("arMixAudioDeviceApplyAck",ack=>{ + if(!devicePending||ack?.requestId!==devicePending.requestId)return; + devicePending=null; + deviceDraft=null; + getStatus(ack.ok===true? + "Device accepted · "+ack.active?.backend+" · "+ack.active?.rate+ + " Hz · "+ack.active?.playbackDevice+" · select IN on channel": + "Device rejected · "+String(ack.error||ack.state||"unavailable")); + backend.emitEvent("arMixAction",{action:"audioDeviceInventory"}); + controller?.subscribe(); + }); + backend.addEventListener("arMixAudioArmAck", ack=>{ + if(deviceMutePending){ + deviceMutePending=false; + if(ack?.ok===true&&ack.armed===false)sendDeviceApply(); + else {devicePending=null;getStatus("Cannot safely mute output; device unchanged");} + } if(ack?.ok===true){ status(ack.armed?"NATIVE: user ARM accepted; checking real PCM.": "NATIVE: output muted."); @@ -413,6 +704,9 @@ // window.pointerup listener would run after that handler clears the gesture. const ready=()=>{ installFirstSoundMenu(); + // Capture source selection BEFORE the public Pages demo reducer. It + // remains the same visible IN dropdown, never a separate floating patch. + document.addEventListener("change",changeNativeInput,true); updateHardwarePanel(null); stopDemo(); status("NATIVE: subscribed · waiting for true device and accepted ChannelId graph"); From 81a61b4a8224f40ddee5f8f8194f8f84703ac7cf Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:18:45 +0700 Subject: [PATCH 06/28] fix(setup): preserve live verified pin masks and defer unknown-device masks to native JUCE --- web/approved-native-bridge.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 9c5cf171d..4954602ab 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -398,11 +398,22 @@ } function sendDeviceApply(){ if(!devicePending||!deviceInventory?.active)return; + const active=deviceInventory.active; + const same=active.backend===deviceDraft.backend && + active.captureDevice===deviceDraft.captureDevice && + active.playbackDevice===deviceDraft.playbackDevice; + const config={...deviceDraft}; + if(same && Array.isArray(active.enabledInputs) && + Array.isArray(active.enabledOutputs)){ + config.enabledInputs=active.enabledInputs.slice(); + config.enabledOutputs=active.enabledOutputs.slice(); + } + // For NEW devices, physical pin names are not yet verified; native JUCE + // opens safe defaults before the next authoritative inventory. backend.emitEvent("arMixAction",{ action:"audioDeviceApply", requestId:devicePending.requestId, - expectedDeviceGeneration:devicePending.generation, - config:{...deviceDraft,enabledInputs:[],enabledOutputs:[]} + expectedDeviceGeneration:devicePending.generation,config }); getStatus("Opening selected hardware · verifying actual driver readback…"); } From 0e6c0be5dab1fac99b4f17d9e2aa08c8ce7bbb56 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:19:40 +0700 Subject: [PATCH 07/28] test(workflow): require actual bundled ten-channel IN routing, native ACK, one setup and monitor --- tests/approved_native_m2_contract.test.cjs | 54 +++++++++++++--------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 2b584dd09..1950873ae 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -428,29 +428,41 @@ test("M3 Windows bundle owns pointerup fader gesture and fences native FX keyboa assert.ok(!bridge.includes('window.addEventListener("pointerup"')); }); -test("native Windows operator can explicitly patch first physical input, arm and mute",()=>{ +test("approved native runtime routes ANY of ten visible DAW channel IN selectors",()=>{ const js=read("web/approved-native-bridge.js"); - const main=read("src/Main.cpp"); - const engine=read("src/LiveAudioEngine.h"); - assert.match(js,/REAL AUDIO · FIRST SOUND/); - assert.match(js,/action:"audioSetup"/); - assert.match(js,/d\.inputEndpoints\.filter\(p=>/); - assert.match(js,/d\.enabledInputs\.includes\(p\.port\)/); - assert.match(js,/action:"routingSourceSwitch",requestId:pendingSourceId/); - assert.match(js,/channel:0,mode:"MONO",left:pin,right:-1/); - assert.match(js,/action:"monitor",value:true/); - assert.match(js,/action:"monitor",value:false/); - assert.match(js,/expectedEpoch:epoch,expectedRevision:revision/); + const cpp=read("src/Main.cpp"); + const native=read("integration/ApprovedNativeRuntimeSnapshot.h"); + const bundle=read("scripts/build_approved_native_gui.py"); + assert.match(js,/physicalUiIds=\(scope\?\.tracks\|\|\[\]\)/); + assert.match(js,/\.route-select\[data-field="input"\]/); + assert.match(js,/for\(let i=0;isize\(\)==10/); + assert.match(native,/inputs\.getArray\(\)->contains\(left\)/); + assert.match(js,/event\.stopImmediatePropagation\(\)/); + assert.match(js,/document\.addEventListener\("change",changeNativeInput,true\)/); + assert.doesNotMatch(js,/Physical input for CH1|Patch CH1|pendingSourceId/); + assert.match(js,/openNativeAudioSetup\(\)/); + assert.match(js,/action:"audioDeviceInventory"/); + assert.match(js,/action:"audioDeviceApply"/); + assert.match(js,/arMixAudioDeviceApplyAck/); + assert.match(js,/data-native-monitor/); + assert.match(js,/action:"monitor",value:!armed/); + assert.match(js,/action:"monitor",value:false/); + assert.match(js,/expectedEpoch:epoch,expectedRevision:rev/); assert.match(js,/NO VERIFIED AUDIO DEVICE/); assert.match(js,/NATIVE PCM · HARDWARE FAT PENDING/); - assert.match(js,/MAIN ARMED · PCM NOT YET ADMITTED/); - assert.match(main,/action=="routingSourceSwitch"/); - assert.match(main,/engine_\.liveOutputArmFault\(\)/); - assert.match(main,/safe->emitApprovedNativeSnapshot\(\)/); - assert.match(engine,/juce::String switchDryRoutingLabSource\(/); - assert.match(engine,/setOutputMuted\(true\)/); + assert.match(js,/Virtual playback output/); + assert.match(cpp,/action=="routingSourceSwitch"/); + assert.match(cpp,/engine_\.liveOutputArmFault\(\)/); + assert.match(cpp,/applyCustomAudioDevice\(args\)/); + assert.match(bundle,/approved-native-bridge\.js/); + assert.doesNotMatch(bundle,/NATIVE_ADAPTER = ROOT \/ "web" \/ "mixer-io\.js"/); + assert.doesNotMatch(js,/AudioContext|AudioWorklet|processBlock/); }); From fd24cfcfaa75be5005c023b56bf4ea275769f3cf Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:22:04 +0700 Subject: [PATCH 08/28] fix(workflow): require post-ACK native snapshot before presenting accepted hardware source --- web/approved-native-bridge.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 4954602ab..4a4889387 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -178,6 +178,18 @@ function syncDawNativeInputs(){ const options=portOptions(); const sources=hardware?.raw?.legacyM4?.channelSources; + // ACK is not final presentation authority. Keep the source disabled + // until the following CURRENT-EPOCH snapshot proves the accepted route. + if(sourcePending?.acked && Array.isArray(sources) && + sources.length===10 && + String(hardware?.device?.epoch)===String(sourcePending.epoch) && + routeValue(sources[sourcePending.channel])=== + routeValue(sourcePending)){ + sourcePending=null; + } + if(sourcePending && + String(hardware?.device?.epoch)!==String(sourcePending.epoch)) + sourcePending=null; // hotplug/driver change cancels stale source UI const signature=JSON.stringify(options); for(let i=0;i{ const p=sourcePending; if(!p||ack?.requestId!==p.id||ack?.channel!==p.channel)return; - sourcePending=null; const route=ack?.state?.acceptedRoute?.channels?.[p.channel]; const valid=ack.ok===true&&Number(ack?.state?.epoch)===p.epoch&& route?.mode===p.mode&& (p.mode==="NONE" || (route?.left===p.left&&route?.right===p.right)); - status(valid?"CH "+(p.channel+1)+" input connected · monitor on MAIN to listen": + if(valid)sourcePending.acked=true; + else sourcePending=null; + status(valid?"CH "+(p.channel+1)+" source ACK accepted · verifying next readback": "CH "+(p.channel+1)+" input rejected · "+String(ack?.error||"readback mismatch")); controller?.subscribe(); syncDawNativeInputs(); From f440d67c83e959caa2d48423a2d902d5a1252426 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:22:41 +0700 Subject: [PATCH 09/28] test(runtime): exercise real bundled ten-channel IN controls, sparse ports, stale epoch and post-ACK readback --- tests/approved_native_m2_contract.test.cjs | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 1950873ae..54c06698f 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -296,6 +296,86 @@ test("STALE/REJECTED/timeout leave accepted GUI untouched and request fresh nati deviceEpoch:s.device.epoch,graphRevision:"6",rosterRevision:"7",errorCode:"NONE"}),false); assert.ok(sent.filter(x=>x.name==="arMixConsoleSubscribe").length>=2); }); +test("ten on-strip hardware selectors dispatch exact native channel, await ACK then readback",()=>{ + const vm=require("node:vm"); + const sent=[],listeners=new Map(),handlers=new Map(); + const selects=new Map(); + const tracks=Array.from({length:10},(_,i)=>({kind:"audio",id:i+1,name:"CH"+(i+1)})); + const scope={tracks,master:{id:11,kind:"master"},stopDemo(){}}; + for(const tr of tracks){ + const sel={dataset:{},value:"None",disabled:false,options:[], + replaceChildren(...opts){this.options=opts;this.value=opts[0]?.value??"";}, + closest(){return this;}}; + selects.set(String(tr.id),sel); + } + const info={textContent:""},preview={disabled:false,title:""}; + const doc={readyState:"complete",documentElement:{dataset:{}}, + getElementById:id=>id==="info"?info:id==="preview"?preview:null, + querySelector:selector=>{ + const id=/^\\.strip\\[data-id="(\\d+)"\\]$/.exec(selector)?.[1]; + return id?{querySelector:()=>selects.get(id)}:null; + }, + createElement:tag=>({value:"",textContent:"",dataset:{},tag}), + addEventListener:(type,listener)=>handlers.set(type,listener) + }; + const backend={emitEvent:(name,payload)=>sent.push({name,payload}), + addEventListener:(name,fn)=>listeners.set(name,fn)}; + const window={__JUCE__:{backend},ArSonApprovedNativeContract:protocol, + __ARMIX_NATIVE_SCOPE__:scope,setTimeout(){},addEventListener(){}}; + vm.runInNewContext(read("web/approved-native-bridge.js"), + {window,document:doc,performance:{now:()=>0}},{timeout:3000}); + const snap=clone(fixtures.g0); + snap.device.epoch="7"; + snap.device.enabledInputs=[0,2]; + snap.device.inputEndpoints=[ + {id:"in:0",port:0,callback:0,label:"Mic 1",active:true}, + {id:"in:2",port:2,callback:1,label:"Mic 3",active:true} + ]; + snap.legacyM4={active:true,routeAccepted:false,routingRevision:"8", + channelSources:tracks.map(()=>({mode:"NONE",left:-1,right:-1}))}; + listeners.get("arMixConsoleSnapshot")(snap); + const selected=selects.get("8"); + assert.equal(selected.dataset.nativeChannel,"7"); + assert.equal(selected.disabled,false); + assert.deepEqual(selected.options.map(o=>o.value),["NONE","MONO:0","MONO:2"]); + selected.value="MONO:2"; + let prevented=false,stopped=false; + handlers.get("change")({target:selected,preventDefault(){prevented=true;}, + stopImmediatePropagation(){stopped=true;}}); + assert.equal(prevented,true);assert.equal(stopped,true); + const source=sent.findLast(x=>x.name==="arMixAction"); + assert.equal(source.payload.action,"routingSourceSwitch"); + assert.equal(source.payload.channel,7); + assert.equal(source.payload.mode,"MONO"); + assert.equal(source.payload.left,2); + assert.equal(source.payload.right,-1); + assert.equal(source.payload.deviceEpoch,7); + assert.equal(source.payload.revision,8); + assert.equal(selected.disabled,true,"another channel edit cannot overtake ACK"); + const stale=clone(snap); + stale.device.epoch="9"; + listeners.get("arMixConsoleSnapshot")(stale); + assert.equal(selected.disabled,false,"device epoch change releases stale UI transaction"); + listeners.get("arMixConsoleSnapshot")(snap); + selected.value="MONO:2"; + handlers.get("change")({target:selected,preventDefault(){},stopImmediatePropagation(){}}); + const pending=sent.findLast(x=>x.name==="arMixAction").payload; + const rows=tracks.map(()=>({mode:"NONE",left:-1,right:-1})); + rows[7]={mode:"MONO",left:2,right:-1}; + listeners.get("arMixSourceSwitchAck")({ + requestId:pending.requestId,channel:7,ok:true,error:"", + state:{epoch:7,acceptedRoute:{channels:rows}} + }); + assert.equal(selected.disabled,true,"ACK alone must not project native source"); + const readback=clone(snap); + readback.legacyM4.routeAccepted=true; + readback.legacyM4.channelSources=rows; + listeners.get("arMixConsoleSnapshot")(readback); + assert.equal(selected.value,"MONO:2"); + assert.equal(selected.disabled,false); + assert.equal(selects.get("1").value,"NONE", + "unselected channel must not inherit another channel's patch"); +}); test("M2 code edits approved Pages *events* only, not a second native GUI/audio engine",()=>{ const page=read("site/preview-v2/index.html"); const native=read("src/Main.cpp"); From 49b3b6640c7b9a30b3ebae666613463bff75c0e6 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:23:47 +0700 Subject: [PATCH 10/28] feat(readback): expose per-channel native MAIN routing rather than approved Pages demo output --- integration/ApprovedNativeRuntimeSnapshot.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integration/ApprovedNativeRuntimeSnapshot.h b/integration/ApprovedNativeRuntimeSnapshot.h index 4e07c8b41..758dd92c4 100644 --- a/integration/ApprovedNativeRuntimeSnapshot.h +++ b/integration/ApprovedNativeRuntimeSnapshot.h @@ -107,6 +107,8 @@ inline bool publishVerifiedFirstSoundState(juce::var& snapshot, src->setProperty("mode",mode); src->setProperty("left",mono||stereo?left:juce::var(-1)); src->setProperty("right",stereo?right:juce::var(-1)); + const auto main=row.getProperty("main",{}); + src->setProperty("main",main.isBool()&&static_cast(main)); sources.add(juce::var(src.release())); } } From 3d8d2365dcd3a7f564d2fa034932ce31b04cdc57 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:24:11 +0700 Subject: [PATCH 11/28] feat(workflow): expose real MAIN output device, suppress demo OUT controls, bound input transaction timeout --- web/approved-native-bridge.js | 52 ++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 4a4889387..22c391860 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -210,9 +210,41 @@ select.disabled=!firstSoundReady()||!!sourcePending||!Array.isArray(sources)|| sources.length!==10; select.title="CH "+(i+1)+" · verified physical input · native ACK"; + const out=strip.querySelector('.route-select[data-field="output"]'); + if(out){ + const src=Array.isArray(sources)&&sources.length===10?sources[i]:null; + const label=src?.main===true?"MAIN":"SOURCE ONLY"; + if(out.dataset.nativeOutput!==label){ + out.replaceChildren(Object.assign(document.createElement("option"),{ + value:label,textContent:label + })); + out.dataset.nativeOutput=label; + } + out.value=label; + // Per-channel OUT patching requires its own accepted MAIN/AUX + // transaction; never expose synthetic demo hardware destinations. + out.disabled=true; + out.title="Accepted native routing · advanced OUTPUT matrix required to change"; + } } const master=document.querySelector(".strip.master .route-top"); if(master){ + const output=master.closest(".strip")?.querySelector( + '.route-select[data-field="output"]'); + if(output){ + const device=hardware?.device?.playbackDevice||"No output"; + if(output.dataset.nativeDevice!==device){ + const selected=document.createElement("option"); + selected.value=device;selected.textContent=device; + const settings=document.createElement("option"); + settings.value="__SETUP__";settings.textContent="Change output…"; + output.replaceChildren(selected,settings); + output.dataset.nativeDevice=device; + } + if(output.value!==device)output.value=device; + output.disabled=false; + output.title="Current JUCE playback device · change in Audio I/O"; + } let monitor=master.querySelector("[data-native-monitor]"); if(!monitor){ monitor=document.createElement("button"); @@ -248,8 +280,18 @@ } } function changeNativeInput(event){ + if(!connected)return; + const output=event.target?.closest?.('.route-select[data-field="output"]'); + if(output){ + // The actual driver/playback destination is selected in ONE Audio I/O + // dialog. Never write the Pages demonstration output to the real graph. + event.preventDefault();event.stopImmediatePropagation(); + if(output.closest(".strip.master"))openNativeAudioSetup(); + syncDawNativeInputs(); + return; + } const select=event.target?.closest?.('.route-select[data-field="input"]'); - if(!select || !connected)return; + if(!select)return; event.preventDefault();event.stopImmediatePropagation(); const index=Number(select.dataset.nativeChannel); const parts=String(select.value).split(":"); @@ -267,6 +309,14 @@ } sourcePending={id:++sourceRequest,channel:index,mode,left,right, epoch,revision}; + const requestId=sourcePending.id; + window.setTimeout(()=>{ + if(sourcePending?.id!==requestId)return; + sourcePending=null; + status("INPUT timeout · native ACK/readback missing; refresh actual hardware"); + controller?.subscribe(); + syncDawNativeInputs(); + },8000); backend.emitEvent("arMixAction",{action:"routingSourceSwitch", requestId:sourcePending.id,channel:index,mode,left,right, deviceEpoch:epoch,revision}); From 1df5047b28aaf573b8486db0c26d55b854c39dd0 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:24:28 +0700 Subject: [PATCH 12/28] test(runtime): mock real DOM selector semantics for native IN versus OUT controls --- tests/approved_native_m2_contract.test.cjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 54c06698f..1d7592ddb 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -305,7 +305,7 @@ test("ten on-strip hardware selectors dispatch exact native channel, await ACK t for(const tr of tracks){ const sel={dataset:{},value:"None",disabled:false,options:[], replaceChildren(...opts){this.options=opts;this.value=opts[0]?.value??"";}, - closest(){return this;}}; + closest(selector){return selector.includes('field="input"')?this:null;}}; selects.set(String(tr.id),sel); } const info={textContent:""},preview={disabled:false,title:""}; @@ -313,7 +313,7 @@ test("ten on-strip hardware selectors dispatch exact native channel, await ACK t getElementById:id=>id==="info"?info:id==="preview"?preview:null, querySelector:selector=>{ const id=/^\\.strip\\[data-id="(\\d+)"\\]$/.exec(selector)?.[1]; - return id?{querySelector:()=>selects.get(id)}:null; + return id?{querySelector:q=>q.includes('field="input"')?selects.get(id):null}:null; }, createElement:tag=>({value:"",textContent:"",dataset:{},tag}), addEventListener:(type,listener)=>handlers.set(type,listener) From b885bb7ca9acb9f206d23e37f52260019e057ece Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:27:00 +0700 Subject: [PATCH 13/28] test(runtime): correct test-only DOM query regex for actual approved strip data-id --- tests/approved_native_m2_contract.test.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 1d7592ddb..9525bf28b 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -312,7 +312,7 @@ test("ten on-strip hardware selectors dispatch exact native channel, await ACK t const doc={readyState:"complete",documentElement:{dataset:{}}, getElementById:id=>id==="info"?info:id==="preview"?preview:null, querySelector:selector=>{ - const id=/^\\.strip\\[data-id="(\\d+)"\\]$/.exec(selector)?.[1]; + const id=/^\.strip\[data-id="(\d+)"\]$/.exec(selector)?.[1]; return id?{querySelector:q=>q.includes('field="input"')?selects.get(id):null}:null; }, createElement:tag=>({value:"",textContent:"",dataset:{},tag}), From 964c822c66f318ba23081d498df95756ac2dd22a Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:27:29 +0700 Subject: [PATCH 14/28] feat(native): expose verified ten-channel M4 fader/pan/mute/solo readback and callback PCM meters --- integration/ApprovedNativeRuntimeSnapshot.h | 48 +++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/integration/ApprovedNativeRuntimeSnapshot.h b/integration/ApprovedNativeRuntimeSnapshot.h index 758dd92c4..3ae3da4a9 100644 --- a/integration/ApprovedNativeRuntimeSnapshot.h +++ b/integration/ApprovedNativeRuntimeSnapshot.h @@ -114,6 +114,54 @@ inline bool publishVerifiedFirstSoundState(juce::var& snapshot, } } firstSound->setProperty("channelSources",juce::var(sources)); + // Native ten-strip faders/pan/mute/solo already drive the SINGLE M4 + // callback through LiveDryRoutingLab::setChannelParameter(). Expose the + // actual acknowledged CONTROL-thread state, never public Pages defaults. + juce::var verifiedControls(juce::Array{}); + if(physicalReady) { + const auto controls=route.getProperty("channelControls",{}); + const auto* list=controls.getArray(); + if(list && list->size()==10) { + bool valid=true; + for(const auto& entry:*list) { + double db=0.,pan=0.; + if(!entry.isObject() || + !nativeV8Number(entry.getProperty("db",{}),db) || + !nativeV8Number(entry.getProperty("pan",{}),pan) || + !std::isfinite(db) || db< -60.01 || db>10.01 || + !std::isfinite(pan) || pan< -100.01 || pan>100.01 || + !entry.getProperty("mute",{}).isBool() || + !entry.getProperty("solo",{}).isBool()) { + valid=false;break; + } + } + if(valid)verifiedControls=controls; + } + } + firstSound->setProperty("channelControls",verifiedControls); + // These peaks are REAL atomics from the installed M4 render callback, + // not UI-generated meters. Zero is silence, not proof of loudspeakers. + juce::Array peakL,peakR; + const auto telemetry=snapshot.getProperty("telemetry",{}); + if(physicalReady && boolIs(route,"hasAcceptedRoute",true) && + boolIs(telemetry,"captureObserved",true)) { + const auto left=route.getProperty("channelPeaksL",{}), + right=route.getProperty("channelPeaksR",{}); + const auto* l=left.getArray();const auto* r=right.getArray(); + if(l&&r&&l->size()==10&&r->size()==10) { + bool valid=true; + for(int i=0;i<10;++i) { + double p=0.,q=0.; + if(!nativeV8Number(l->getReference(i),p) || + !nativeV8Number(r->getReference(i),q) || + !std::isfinite(p)||!std::isfinite(q)|| + p<0.||q<0.||p>16.||q>16.) {valid=false;break;} + } + if(valid) {peakL=*l;peakR=*r;} + } + } + firstSound->setProperty("channelPeaksL",juce::var(peakL)); + firstSound->setProperty("channelPeaksR",juce::var(peakR)); // Do not write the route to the graph or change native capability flags. snapshot.getDynamicObject()->setProperty("legacyM4",juce::var(firstSound.release())); return physicalReady; From 16400dcae5177c8ed8b81034c99f6aecbcc3bd06 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:28:08 +0700 Subject: [PATCH 15/28] feat(audio): ACK existing atomic M4 per-channel fader, pan, mute and solo controls --- src/Main.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/Main.cpp b/src/Main.cpp index f410bce6b..02a6e275f 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1402,6 +1402,46 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr // 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. + // DAW-like strip fader/pan/mute/solo: existing atomic M4 PCM owner. + // This is an explicit message-thread control ACK, not an alternative + // VST/audio callback, G0 ChannelId admission, or optimistic JS state. + if(action=="routingM4ChannelControl"){ + const int requestId=static_cast(args.getProperty("requestId",0)); + const int channel=static_cast(args.getProperty("channel",-1)); + const auto name=args.getProperty("parameter",{}).toString(); + const auto ep=args.getProperty("deviceEpoch",{}); + const auto rv=args.getProperty("revision",{}); + const auto value=args.getProperty("value",{}); + const bool flag=name=="mute"||name=="solo"; + const bool numeric=name=="faderDb"||name=="pan"; + const bool kind=flag||numeric; + const double amount=static_cast(value); + const bool valid=requestId>0&&channel>=0&&channel=-60.&&amount<=10.): + (amount>=-100.&&amount<=100.))); + const auto epoch=valid?static_cast( + static_cast(ep)):0; + const auto revision=valid?static_cast( + static_cast(rv)):0; + const bool accepted=valid&&engine_.setDryRoutingLabParameter( + channel,epoch,revision,name, + flag?(static_cast(value)?1.f:0.f):static_cast(amount)); + auto ack=std::make_unique(); + ack->setProperty("requestId",requestId); + ack->setProperty("channel",channel); + ack->setProperty("parameter",name); + ack->setProperty("ok",accepted); + ack->setProperty("error",accepted?juce::String(): + juce::String("STALE_ROUTE_OR_INVALID_CONTROL")); + ack->setProperty("state",engine_.status().getProperty("dryRoutingLab",{})); + if(browser_.loaded)browser_.emitEventIfBrowserIsVisible( + "arMixM4ControlAck",juce::var(ack.release())); + return; + } if(action=="routingSourceSwitch"){ const int requestId=static_cast(args.getProperty("requestId",0)); const int channel=static_cast(args.getProperty("channel",-1)); From 077dbd9d26d4abebcc3262ac81f0dfa85b63a2b4 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:29:34 +0700 Subject: [PATCH 16/28] feat(workflow): connect G0 ten-channel fader, pan, mute, solo and measured PCM meters to native ACK/readback --- web/approved-native-bridge.js | 171 +++++++++++++++++++++++++++++++++- 1 file changed, 169 insertions(+), 2 deletions(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 22c391860..fcf7daba9 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -479,9 +479,131 @@ }); getStatus("Opening selected hardware · verifying actual driver readback…"); } + + // Real ten-strip M4 fader/solo/mute control path. The installed native DSP + // already applies these atomically. Request-id ACK + later current-epoch + // snapshot is the only presentation commit, never a Pages demo mutation. + const m4Pending=new Map(); + let m4Request=30000; + const m4Key=(ch,name)=>ch+":"+name; + const m4Index=t=>physicalUiIds.indexOf(String(t?.id)); + const m4Controls=()=>hardware?.raw?.legacyM4?.channelControls; + const m4Expected=(actual,p)=>{ + if(!actual)return false; + const value=p.value; + if(p.parameter==="faderDb")return Number.isFinite(actual.db)&& + Math.abs(actual.db-value)<0.12; + if(p.parameter==="pan")return Number.isFinite(actual.pan)&& + Math.abs(actual.pan-value)<0.12; + if(p.parameter==="mute"||p.parameter==="solo") + return actual[p.parameter]===value; + return false; + }; + function submitM4Control(t,parameter,value){ + const channel=m4Index(t); + const controls=m4Controls(); + const key=m4Key(channel,parameter); + const epoch=Number(hardware?.device?.epoch); + const revision=Number(hardware?.raw?.legacyM4?.routingRevision); + if(channel<0 || channel>=10 || !firstSoundReady() || + !Array.isArray(controls)||controls.length!==10 || + m4Pending.has(key)||!Number.isSafeInteger(epoch)||epoch<=0|| + !Number.isSafeInteger(revision)||revision<=0) { + status("CONTROL unavailable · verify native strip readback"); + return false; + } + const flag=parameter==="mute"||parameter==="solo"; + if(flag?typeof value!=="boolean": + !Number.isFinite(value)|| + (parameter==="faderDb"&&(value< -60||value>10))|| + (parameter==="pan"&&(value< -100||value>100)))return false; + const pending={id:++m4Request,channel,parameter,value,epoch,revision, + acked:false}; + m4Pending.set(key,pending); + backend.emitEvent("arMixAction",{action:"routingM4ChannelControl", + requestId:pending.id,channel,parameter,value, + deviceEpoch:epoch,revision}); + window.setTimeout(()=>{ + if(m4Pending.get(key)?.id!==pending.id)return; + m4Pending.delete(key); + controller?.subscribe(); + syncDawM4Controls(); + status("CH "+(channel+1)+" "+parameter+" timed out · native state restored"); + },8000); + return true; + } + function syncDawM4Controls(){ + if(hardware?.admitted===true)return; + const controls=m4Controls(),ready=firstSoundReady() && + Array.isArray(controls)&&controls.length===10; + for(let i=0;i{ + const fill=strip.querySelector(".meter-fill."+side); + if(!fill||!scope?.displayMeterDbfs)return; + const peak=Number(value); + const db=actual&&Number.isFinite(peak)&&peak>0? + 20*Math.log10(peak):-90; + scope.displayMeterDbfs(fill,Math.max(-90,Math.min(6,db)), + performance.now(),physicalUiIds[i]+":"+side); + }; + paint("left",peaks?.channelPeaksL?.[i]); + paint("right",peaks?.channelPeaksR?.[i]); + if(!c)continue; + const t=(scope?.tracks||[]).find(item=>String(item.id)===physicalUiIds[i]); + if(!t)continue; + for(const name of ["faderDb","pan","mute","solo"]){ + const key=m4Key(i,name),pending=m4Pending.get(key); + if(pending && String(hardware?.device?.epoch)!==String(pending.epoch)) + m4Pending.delete(key); + else if(pending?.acked && m4Expected(c,pending)) + m4Pending.delete(key); + } + const level=Number(c.db),pan=Number(c.pan); + if(Number.isFinite(level)&&!m4Pending.has(m4Key(i,"faderDb"))){ + t.level=level; + const slider=strip.querySelector('.fader[data-field="level"]'); + if(slider && Number(slider.value)!==level){ + slider.value=String(level); + const min=Number(slider.min),max=Number(slider.max); + const p=(level-min)/(max-min); + const box=strip.querySelector(".fader-box"); + if(box&&Number.isFinite(p)&&max>min){ + const frac=Math.max(0,Math.min(1,p)); + box.style.setProperty("--fader-fill",(frac*100)+"%"); + box.style.setProperty("--fader-lit",String(frac)); + box.style.setProperty("--fader-y",((1-frac)*100)+"%"); + box.style.setProperty("--fader-frac",String(frac)); + } + } + const display=strip.querySelector(".db-value"); + const label=level.toFixed(1)+" dB"; + if(display&&display.textContent!==label)display.textContent=label; + } + if(Number.isFinite(pan)&&!m4Pending.has(m4Key(i,"pan"))){ + t.pan=pan; + const slider=strip.querySelector('.center-pan[data-field="pan"]'); + if(slider&&Number(slider.value)!==pan)slider.value=String(pan); + } + for(const name of ["mute","solo"]){ + if(typeof c[name]!=="boolean"||m4Pending.has(m4Key(i,name)))continue; + t[name]=c[name]; + const button=strip.querySelector('[data-action="'+name+'"]'); + if(button)button.setAttribute("aria-pressed",String(c[name])); + } + } + } function updateHardwarePanel(next) { hardware=next||null; syncDawNativeInputs(); + syncDawM4Controls(); const d=next?.device; const deviceOpen=Boolean(d?.backend && d.sampleRate>0 && d.enabledOutputs.length>=2); @@ -543,7 +665,7 @@ flags.productionCallbackLive=false;flags.acceptedGraphConnected=false; lastPaintedSignature=""; stopDemo(); - status("NATIVE G0 · pilih hardware IN langsung pada CH1–CH10; fader/WIRE ChannelId tetap menunggu accepted PCM."); + status("NATIVE M4 · hardware IN, fader, pan, mute, solo tersedia pada CH1–CH10; ChannelId WIRE menunggu admission."); return; } // Control readback may change at the SAME structural graph revision. @@ -620,6 +742,26 @@ controller?.subscribe(); }); + backend.addEventListener("arMixM4ControlAck",ack=>{ + if(!Number.isInteger(ack?.channel))return; + const key=m4Key(ack.channel,ack.parameter); + const pending=m4Pending.get(key); + if(!pending||pending.id!==ack.requestId)return; + const controls=ack?.state?.channelControls; + const verified=ack.ok===true && + Number(ack?.state?.epoch)===pending.epoch && + Number(ack?.state?.revision)===pending.revision && + Array.isArray(controls)&&controls.length===10 && + m4Expected(controls[pending.channel],pending); + if(verified)pending.acked=true; + else { + m4Pending.delete(key); + status("CH "+(pending.channel+1)+" "+pending.parameter+ + " rejected · "+String(ack.error||"native readback mismatch")); + } + controller?.subscribe(); + syncDawM4Controls(); + }); backend.addEventListener("arMixAudioArmAck", ack=>{ if(deviceMutePending){ deviceMutePending=false; @@ -642,9 +784,29 @@ const t=scope?.findTrack?.(el) || null; if (!t)return true; if (!flags.acceptedGraphConnected) { + if((field==="level"||field==="pan")&& + event.type==="change"&&firstSoundReady()){ + const value=Number(el.value); + const name=field==="level"?"faderDb":"pan"; + if(!submitM4Control(t,name,value))el.value= + String(field==="level"?t.level:t.pan); + return true; + } + if(event.type!=="change"&&field==="level"&&firstSoundReady()){ + const n=Number(el.value),min=Number(el.min),max=Number(el.max); + if([n,min,max].every(Number.isFinite)&&max>min){ + const frac=Math.max(0,Math.min(1,(n-min)/(max-min))); + const box=el.closest?.(".fader-box"); + box?.style?.setProperty("--fader-fill",(100*frac)+"%"); + box?.style?.setProperty("--fader-lit",String(frac)); + box?.style?.setProperty("--fader-y",(100*(1-frac))+"%"); + box?.style?.setProperty("--fader-frac",String(frac)); + } + return true; + } 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"); + status("NATIVE: control unavailable until verified DSP readback"); return true; } // During a native pointer drag move the approved fader *cap* only. @@ -684,6 +846,11 @@ if (["wireExpand","wireSource","wireRoute","editIdentity","rename"].includes(action)) return !["wireExpand","wireSource","wireRoute"].includes(action); if (action==="mute"||action==="solo") { + if(!flags.acceptedGraphConnected){ + if(firstSoundReady())submitM4Control(t,action,!Boolean(t[action])); + else status("NATIVE: device not ready for "+action); + return true; + } const key=action==="mute"?"SET_MUTE":"SET_SOLO"; intent(key,t,{value:!t[action],enabled:!t[action]});return true; } From 6fc5309f908473833f6154e9a99194c6744bab82 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:30:56 +0700 Subject: [PATCH 17/28] test(runtime): use monotonically increasing native epoch after simulated hotplug --- tests/approved_native_m2_contract.test.cjs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 9525bf28b..1a610aeee 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -356,7 +356,10 @@ test("ten on-strip hardware selectors dispatch exact native channel, await ACK t stale.device.epoch="9"; listeners.get("arMixConsoleSnapshot")(stale); assert.equal(selected.disabled,false,"device epoch change releases stale UI transaction"); - listeners.get("arMixConsoleSnapshot")(snap); + // The controller correctly rejects a regressive device epoch. Resume + // on a NEWER native hardware generation, never replay the old epoch 7. + const resumed=clone(snap);resumed.device.epoch="10"; + listeners.get("arMixConsoleSnapshot")(resumed); selected.value="MONO:2"; handlers.get("change")({target:selected,preventDefault(){},stopImmediatePropagation(){}}); const pending=sent.findLast(x=>x.name==="arMixAction").payload; @@ -364,10 +367,10 @@ test("ten on-strip hardware selectors dispatch exact native channel, await ACK t rows[7]={mode:"MONO",left:2,right:-1}; listeners.get("arMixSourceSwitchAck")({ requestId:pending.requestId,channel:7,ok:true,error:"", - state:{epoch:7,acceptedRoute:{channels:rows}} + state:{epoch:10,acceptedRoute:{channels:rows}} }); assert.equal(selected.disabled,true,"ACK alone must not project native source"); - const readback=clone(snap); + const readback=clone(resumed); readback.legacyM4.routeAccepted=true; readback.legacyM4.channelSources=rows; listeners.get("arMixConsoleSnapshot")(readback); From 7ad86dedca8ea1872fe5ffd6332496fff342f5e8 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:31:39 +0700 Subject: [PATCH 18/28] test(native): verify ten physical source/mix readback and real callback meters, reject invalid pins --- tests/approved_native_v8_projection_test.cpp | 54 ++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tests/approved_native_v8_projection_test.cpp b/tests/approved_native_v8_projection_test.cpp index 335593c5a..b9e11ec79 100644 --- a/tests/approved_native_v8_projection_test.cpp +++ b/tests/approved_native_v8_projection_test.cpp @@ -368,6 +368,60 @@ static void firstSoundRouteAdmissionRegression() { assert(publishVerifiedFirstSoundState(snapshot,live)); m4=snapshot.getProperty("legacyM4",{}); assert(static_cast(m4.getProperty("routeAccepted",false))); + // Ten independent physical inputs, including non-contiguous verified + // input pins, are authoritative JUCE readback (not Pages mock labels). + juce::Array physicalPins; + physicalPins.add(0);physicalPins.add(2); + snapshot.getProperty("device",{}).getDynamicObject() + ->setProperty("enabledInputs",juce::var(physicalPins)); + juce::Array rows,controls,peaksL,peaksR; + for(int i=0;i<10;++i) { + auto row=std::make_unique(); + row->setProperty("mode",i==7?"MONO":"NONE"); + row->setProperty("left",i==7?2:-1); + row->setProperty("right",-1); + row->setProperty("main",true); + rows.add(juce::var(row.release())); + auto control=std::make_unique(); + control->setProperty("db",-12.0); + control->setProperty("pan",0.0); + control->setProperty("mute",false); + control->setProperty("solo",false); + controls.add(juce::var(control.release())); + peaksL.add(i==7?0.3:0.); + peaksR.add(i==7?0.2:0.); + } + auto routeData=live.getProperty("dryRoutingLab",{}).getDynamicObject(); + auto accepted=std::make_unique(); + accepted->setProperty("channels",juce::var(rows)); + routeData->setProperty("acceptedRoute",juce::var(accepted.release())); + routeData->setProperty("channelControls",juce::var(controls)); + routeData->setProperty("channelPeaksL",juce::var(peaksL)); + routeData->setProperty("channelPeaksR",juce::var(peaksR)); + snapshot.getProperty("telemetry",{}).getDynamicObject() + ->setProperty("captureObserved",true); + assert(publishVerifiedFirstSoundState(snapshot,live)); + m4=snapshot.getProperty("legacyM4",{}); + const auto nativeInputs=m4.getProperty("channelSources",{}); + const auto nativeControls=m4.getProperty("channelControls",{}); + assert(nativeInputs.isArray() && nativeInputs.getArray()->size()==10); + assert(nativeControls.isArray() && nativeControls.getArray()->size()==10); + assert(nativeInputs[7].getProperty("mode","").toString()=="MONO"); + assert(static_cast(nativeInputs[7].getProperty("left",-1))==2); + assert(static_cast(nativeInputs[7].getProperty("main",false))); + assert(static_cast(nativeControls[7].getProperty("db",0.))==-12.); + assert(m4.getProperty("channelPeaksL",{}).getArray()->size()==10); + // Reject forged physical pins instead of silently assigning other + // channels or painting imaginary source/meter data. + rows.getReference(7).getDynamicObject()->setProperty("left",42); + routeData->getProperty("acceptedRoute",{}).getDynamicObject() + ->setProperty("channels",juce::var(rows)); + assert(publishVerifiedFirstSoundState(snapshot,live)); + m4=snapshot.getProperty("legacyM4",{}); + assert(m4.getProperty("channelSources",{}).getArray()->isEmpty()); + rows.getReference(7).getDynamicObject()->setProperty("left",2); + routeData->getProperty("acceptedRoute",{}).getDynamicObject() + ->setProperty("channels",juce::var(rows)); auto reject=[&](const juce::var& degraded) { auto fresh=juce::JSON::parse(juce::JSON::toString(snapshot,false)); assert(!publishVerifiedFirstSoundState(fresh,degraded)); From 59c9b43033c6630b323722aa1fb7ef6844193c46 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:31:56 +0700 Subject: [PATCH 19/28] test(native): use DynamicObject one-argument getProperty overload --- tests/approved_native_v8_projection_test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/approved_native_v8_projection_test.cpp b/tests/approved_native_v8_projection_test.cpp index b9e11ec79..c354519b0 100644 --- a/tests/approved_native_v8_projection_test.cpp +++ b/tests/approved_native_v8_projection_test.cpp @@ -414,13 +414,13 @@ static void firstSoundRouteAdmissionRegression() { // Reject forged physical pins instead of silently assigning other // channels or painting imaginary source/meter data. rows.getReference(7).getDynamicObject()->setProperty("left",42); - routeData->getProperty("acceptedRoute",{}).getDynamicObject() + routeData->getProperty("acceptedRoute").getDynamicObject() ->setProperty("channels",juce::var(rows)); assert(publishVerifiedFirstSoundState(snapshot,live)); m4=snapshot.getProperty("legacyM4",{}); assert(m4.getProperty("channelSources",{}).getArray()->isEmpty()); rows.getReference(7).getDynamicObject()->setProperty("left",2); - routeData->getProperty("acceptedRoute",{}).getDynamicObject() + routeData->getProperty("acceptedRoute").getDynamicObject() ->setProperty("channels",juce::var(rows)); auto reject=[&](const juce::var& degraded) { auto fresh=juce::JSON::parse(juce::JSON::toString(snapshot,false)); From 1bec845db1f78a0edf7c268010c5d25c1a3c2906 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:32:33 +0700 Subject: [PATCH 20/28] test(runtime): verify direct CH8 M4 fader and mute ACK then current-epoch PCM readback --- tests/approved_native_m2_contract.test.cjs | 43 +++++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 1a610aeee..fb16f2ef8 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -301,7 +301,8 @@ test("ten on-strip hardware selectors dispatch exact native channel, await ACK t const sent=[],listeners=new Map(),handlers=new Map(); const selects=new Map(); const tracks=Array.from({length:10},(_,i)=>({kind:"audio",id:i+1,name:"CH"+(i+1)})); - const scope={tracks,master:{id:11,kind:"master"},stopDemo(){}}; + const scope={tracks,master:{id:11,kind:"master"},stopDemo(){}, + findTrack(){return tracks[7];}}; for(const tr of tracks){ const sel={dataset:{},value:"None",disabled:false,options:[], replaceChildren(...opts){this.options=opts;this.value=opts[0]?.value??"";}, @@ -332,7 +333,8 @@ test("ten on-strip hardware selectors dispatch exact native channel, await ACK t {id:"in:2",port:2,callback:1,label:"Mic 3",active:true} ]; snap.legacyM4={active:true,routeAccepted:false,routingRevision:"8", - channelSources:tracks.map(()=>({mode:"NONE",left:-1,right:-1}))}; + channelSources:tracks.map(()=>({mode:"NONE",left:-1,right:-1})), + channelControls:tracks.map(()=>({db:-12,pan:0,mute:false,solo:false}))}; listeners.get("arMixConsoleSnapshot")(snap); const selected=selects.get("8"); assert.equal(selected.dataset.nativeChannel,"7"); @@ -378,6 +380,43 @@ test("ten on-strip hardware selectors dispatch exact native channel, await ACK t assert.equal(selected.disabled,false); assert.equal(selects.get("1").value,"NONE", "unselected channel must not inherit another channel's patch"); + // M4 G0 callback controls must be REAL, even before universal ChannelId + // operations are admitted. One gesture changes only CH08 on native engine. + const slider={dataset:{field:"level"},value:"-3"}; + assert.equal(window.__ARMIX_NATIVE_M2__.consumeField({ + target:slider,type:"change" + }),true); + const control=sent.findLast(x=>x.name==="arMixAction").payload; + assert.equal(control.action,"routingM4ChannelControl"); + assert.equal(control.channel,7); + assert.equal(control.parameter,"faderDb"); + assert.equal(control.value,-3); + assert.equal(control.deviceEpoch,10); + assert.equal(control.revision,8); + assert.equal(tracks[7].level,-12,"unverified fader request is not accepted GUI"); + const changed=clone(readback); + changed.legacyM4.channelControls[7].db=-3; + listeners.get("arMixM4ControlAck")({ + requestId:control.requestId,channel:7,parameter:"faderDb",ok:true, + state:{epoch:10,revision:8,channelControls:changed.legacyM4.channelControls} + }); + assert.equal(tracks[7].level,-12,"ACK alone is not current PCM readback"); + listeners.get("arMixConsoleSnapshot")(changed); + assert.equal(tracks[7].level,-3,"only verified native fader state is projected"); + assert.equal(tracks[0].level,-12,"other channels not mutated"); + assert.equal(window.__ARMIX_NATIVE_M2__.consumeAction(tracks[7],"mute",{}),true); + const mute=sent.findLast(x=>x.name==="arMixAction").payload; + assert.equal(mute.action,"routingM4ChannelControl"); + assert.equal(mute.parameter,"mute"); + assert.equal(mute.value,true); + const muted=clone(changed); + muted.legacyM4.channelControls[7].mute=true; + listeners.get("arMixM4ControlAck")({ + requestId:mute.requestId,channel:7,parameter:"mute",ok:true, + state:{epoch:10,revision:8,channelControls:muted.legacyM4.channelControls} + }); + listeners.get("arMixConsoleSnapshot")(muted); + assert.equal(tracks[7].mute,true); }); test("M2 code edits approved Pages *events* only, not a second native GUI/audio engine",()=>{ const page=read("site/preview-v2/index.html"); From 4ba0ba5ae890cc4a7e69936b4637a9d8c03dccd2 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:33:57 +0700 Subject: [PATCH 21/28] perf(gui): prevent 12Hz static status DOM churn and preserve native control ACK feedback --- web/approved-native-bridge.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index fcf7daba9..9b2aa14c3 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -21,7 +21,7 @@ const status = message => { lastNativeError = message; const info = document.getElementById("info"); - if (info) info.textContent = message; + if (info && info.textContent !== message) info.textContent = message; }; const stopDemo = () => { // The public Pages demo remains unchanged. In native, DEMO meters and @@ -663,9 +663,13 @@ const nativeAdmitted=next.admitted && caps?.callbackOwnsChannelIds===true; if (!nativeAdmitted) { flags.productionCallbackLive=false;flags.acceptedGraphConnected=false; - lastPaintedSignature=""; + // Repeated 12Hz snapshots must never repaint a fixed status label or + // erase the operator's pending input/fader ACK feedback on each tick. + if(lastPaintedSignature!=="G0"){ + lastPaintedSignature="G0"; + status("NATIVE M4 · IN/fader/pan/mute/solo available on all ten strips; WIRE pending."); + } stopDemo(); - status("NATIVE M4 · hardware IN, fader, pan, mute, solo tersedia pada CH1–CH10; ChannelId WIRE menunggu admission."); return; } // Control readback may change at the SAME structural graph revision. From 04606f02fc1e3b64d4b104bcdff4704df68de913 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:37:14 +0700 Subject: [PATCH 22/28] feat(native): expose actual MAIN gain and mute in verified M4 readback --- integration/ApprovedNativeRuntimeSnapshot.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/integration/ApprovedNativeRuntimeSnapshot.h b/integration/ApprovedNativeRuntimeSnapshot.h index 3ae3da4a9..b63343d9b 100644 --- a/integration/ApprovedNativeRuntimeSnapshot.h +++ b/integration/ApprovedNativeRuntimeSnapshot.h @@ -139,6 +139,20 @@ inline bool publishVerifiedFirstSoundState(juce::var& snapshot, } } firstSound->setProperty("channelControls",verifiedControls); + // MAIN gain and panic MUTE are JUCE atomics on the SAME callback. + juce::var master; + if(physicalReady) { + double db=0.; + const auto muted=live.getProperty("masterMute",{}); + if(nativeV8Number(live.getProperty("masterDb",{}),db) && + std::isfinite(db)&&db>=-60.01&&db<=10.01&&muted.isBool()) { + auto verified=std::make_unique(); + verified->setProperty("db",db); + verified->setProperty("mute",muted); + master=juce::var(verified.release()); + } + } + firstSound->setProperty("masterControls",master); // These peaks are REAL atomics from the installed M4 render callback, // not UI-generated meters. Zero is silence, not proof of loudspeakers. juce::Array peakL,peakR; From c07743d2276231523c9181b682cd8664e3be34a9 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:37:58 +0700 Subject: [PATCH 23/28] feat(audio): ack native MAIN fader and mute with device/route safety checks --- src/Main.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/Main.cpp b/src/Main.cpp index 02a6e275f..4c332a669 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -1405,6 +1405,52 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr // DAW-like strip fader/pan/mute/solo: existing atomic M4 PCM owner. // This is an explicit message-thread control ACK, not an alternative // VST/audio callback, G0 ChannelId admission, or optimistic JS state. + // Master fader / MUTE are existing no-heap atomic controls on the + // SAME 10-channel callback, with verified device epoch and route. + if(action=="routingM4MasterControl"){ + const int requestId=static_cast(args.getProperty("requestId",0)); + const auto name=args.getProperty("parameter",{}).toString(); + const auto ep=args.getProperty("deviceEpoch",{}); + const auto rv=args.getProperty("revision",{}); + const auto value=args.getProperty("value",{}); + const auto live=engine_.status(); + const auto routing=live.getProperty("dryRoutingLab",{}); + const auto routeEpoch=routing.getProperty("epoch",{}); + const auto routeRevision=routing.getProperty("revision",{}); + const bool tokenValid=(ep.isInt()||ep.isInt64()||ep.isDouble())&& + (rv.isInt()||rv.isInt64()||rv.isDouble())&& + (routeEpoch.isInt()||routeEpoch.isInt64())&& + (routeRevision.isInt()||routeRevision.isInt64())&& + static_cast(ep)==static_cast(routeEpoch)&& + static_cast(rv)==static_cast(routeRevision); + const bool validated=requestId>0&&tokenValid&& + static_cast(routing.getProperty("ready",false))&& + static_cast(routing.getProperty("hasAcceptedRoute",false))&& + engine_.directRouteAuthorized()&&!engine_.independentClockActive()&& + (name=="mute"?value.isBool(): + name=="faderDb"&&(value.isDouble()||value.isInt()||value.isInt64())&& + std::isfinite(static_cast(value))&& + static_cast(value)>=-60.&& + static_cast(value)<=10.); + if(validated) { + if(name=="mute")engine_.setMasterMuted(static_cast(value)); + else engine_.setMasterGainDb(static_cast(static_cast(value))); + } + const auto now=engine_.status(); + auto ack=std::make_unique(); + ack->setProperty("requestId",requestId); + ack->setProperty("parameter",name); + ack->setProperty("ok",validated); + ack->setProperty("error",validated?juce::String(): + juce::String("STALE_OR_UNVERIFIED_MASTER_CONTROL")); + ack->setProperty("deviceEpoch",routeEpoch); + ack->setProperty("revision",routeRevision); + ack->setProperty("value",name=="mute"? + now.getProperty("masterMute",{}):now.getProperty("masterDb",{})); + if(browser_.loaded)browser_.emitEventIfBrowserIsVisible( + "arMixM4MasterAck",juce::var(ack.release())); + return; + } if(action=="routingM4ChannelControl"){ const int requestId=static_cast(args.getProperty("requestId",0)); const int channel=static_cast(args.getProperty("channel",-1)); From 63416fcadbfcacdeaf8e71f8e06193203d6d2915 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:38:31 +0700 Subject: [PATCH 24/28] feat(gui): connect MAIN fader/mute to native M4 ACK and verified readback --- web/approved-native-bridge.js | 88 +++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 9b2aa14c3..af3407000 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -532,6 +532,32 @@ },8000); return true; } + let masterPending=null,masterSequence=40000; + function submitNativeMaster(parameter,value){ + const epoch=Number(hardware?.device?.epoch); + const revision=Number(hardware?.raw?.legacyM4?.routingRevision); + const controls=hardware?.raw?.legacyM4?.masterControls; + if(!firstSoundReady()||!controls||masterPending|| + !Number.isSafeInteger(epoch)||epoch<=0|| + !Number.isSafeInteger(revision)||revision<=0 || + (parameter==="mute"?typeof value!=="boolean": + parameter!=="faderDb"||!Number.isFinite(value)|| + value< -60||value>10)){ + status("MAIN control requires verified active routing"); + return false; + } + const pending={id:++masterSequence,parameter,value,epoch,revision,acked:false}; + masterPending=pending; + backend.emitEvent("arMixAction",{action:"routingM4MasterControl", + requestId:pending.id,parameter,value,deviceEpoch:epoch,revision}); + window.setTimeout(()=>{ + if(masterPending?.id!==pending.id)return; + masterPending=null; + controller?.subscribe();syncDawM4Controls(); + status("MAIN control timed out · restored last native readback"); + },8000); + return true; + } function syncDawM4Controls(){ if(hardware?.admitted===true)return; const controls=m4Controls(),ready=firstSoundReady() && @@ -599,6 +625,43 @@ if(button)button.setAttribute("aria-pressed",String(c[name])); } } + const master=hardware?.raw?.legacyM4?.masterControls; + const masterTrack=scope?.master; + if(master&&masterTrack){ + if(masterPending?.acked && String(hardware?.device?.epoch)=== + String(masterPending.epoch) && + (masterPending.parameter==="mute"? + master.mute===masterPending.value: + Math.abs(Number(master.db)-masterPending.value)<0.12)) + masterPending=null; + else if(masterPending && String(hardware?.device?.epoch)!== + String(masterPending.epoch))masterPending=null; + if(!masterPending){ + const strip=document.querySelector(".strip.master"); + if(Number.isFinite(Number(master.db))){ + masterTrack.level=Number(master.db); + const slider=strip?.querySelector('.fader[data-field="level"]'); + if(slider&&Number(slider.value)!==Number(master.db)){ + slider.value=String(master.db); + const min=Number(slider.min),max=Number(slider.max); + const frac=max>min?Math.max(0,Math.min(1,(Number(master.db)-min)/(max-min))):0; + const box=strip.querySelector(".fader-box"); + box?.style?.setProperty("--fader-fill",(100*frac)+"%"); + box?.style?.setProperty("--fader-lit",String(frac)); + box?.style?.setProperty("--fader-y",(100*(1-frac))+"%"); + box?.style?.setProperty("--fader-frac",String(frac)); + } + const db=strip?.querySelector(".db-value"); + const label=Number(master.db).toFixed(1)+" dB"; + if(db&&db.textContent!==label)db.textContent=label; + } + if(typeof master.mute==="boolean"){ + masterTrack.mute=master.mute; + strip?.querySelector('[data-action="mute"]')?.setAttribute( + "aria-pressed",String(master.mute)); + } + } + } } function updateHardwarePanel(next) { hardware=next||null; @@ -746,6 +809,21 @@ controller?.subscribe(); }); + backend.addEventListener("arMixM4MasterAck",ack=>{ + const pending=masterPending; + if(!pending||pending.id!==ack?.requestId)return; + const verified=ack.ok===true&&ack.parameter===pending.parameter && + Number(ack.deviceEpoch)===pending.epoch && + Number(ack.revision)===pending.revision && + (pending.parameter==="mute"?ack.value===pending.value: + Math.abs(Number(ack.value)-pending.value)<0.12); + if(verified)pending.acked=true; + else{ + masterPending=null; + status("MAIN "+pending.parameter+" rejected · native state unchanged"); + } + controller?.subscribe();syncDawM4Controls(); + }); backend.addEventListener("arMixM4ControlAck",ack=>{ if(!Number.isInteger(ack?.channel))return; const key=m4Key(ack.channel,ack.parameter); @@ -788,6 +866,12 @@ const t=scope?.findTrack?.(el) || null; if (!t)return true; if (!flags.acceptedGraphConnected) { + if(field==="level" && t===scope?.master && firstSoundReady() && + event.type==="change"){ + if(!submitNativeMaster("faderDb",Number(el.value))) + el.value=String(t.level); + return true; + } if((field==="level"||field==="pan")&& event.type==="change"&&firstSoundReady()){ const value=Number(el.value); @@ -851,6 +935,10 @@ return !["wireExpand","wireSource","wireRoute"].includes(action); if (action==="mute"||action==="solo") { if(!flags.acceptedGraphConnected){ + if(t===scope?.master && action==="mute" && firstSoundReady()){ + submitNativeMaster("mute",!Boolean(t.mute)); + return true; + } if(firstSoundReady())submitM4Control(t,action,!Boolean(t[action])); else status("NATIVE: device not ready for "+action); return true; From 192ef62a1dc561116a3ebf8efced6dc5d9874ec2 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:39:03 +0700 Subject: [PATCH 25/28] test(runtime): verify MAIN gain and mute require exact native ACK plus later snapshot --- tests/approved_native_m2_contract.test.cjs | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index fb16f2ef8..a09a612f7 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -417,6 +417,43 @@ test("ten on-strip hardware selectors dispatch exact native channel, await ACK t }); listeners.get("arMixConsoleSnapshot")(muted); assert.equal(tracks[7].mute,true); + // MAIN uses the same user gesture but its own verified master gain/mute + // JUCE atomics, not a fabricated channel 11 M4 routing control. + const nativeMaster={id:11,kind:"master",level:0,mute:false}; + scope.master=nativeMaster; + const masterSource=clone(muted); + masterSource.legacyM4.masterControls={db:0,mute:false}; + listeners.get("arMixConsoleSnapshot")(masterSource); + scope.findTrack=()=>nativeMaster; + assert.equal(window.__ARMIX_NATIVE_M2__.consumeField({ + target:{dataset:{field:"level"},value:"-9"},type:"change" + }),true); + const mainRequest=sent.findLast(x=>x.name==="arMixAction").payload; + assert.equal(mainRequest.action,"routingM4MasterControl"); + assert.equal(mainRequest.parameter,"faderDb"); + assert.equal(mainRequest.value,-9); + assert.equal(nativeMaster.level,0); + listeners.get("arMixM4MasterAck")({ + requestId:mainRequest.requestId,parameter:"faderDb",ok:true, + deviceEpoch:10,revision:8,value:-9 + }); + assert.equal(nativeMaster.level,0,"master ACK alone is not GUI acceptance"); + const mainUpdated=clone(masterSource); + mainUpdated.legacyM4.masterControls.db=-9; + listeners.get("arMixConsoleSnapshot")(mainUpdated); + assert.equal(nativeMaster.level,-9); + assert.equal(window.__ARMIX_NATIVE_M2__.consumeAction(nativeMaster,"mute",{}),true); + const mainMute=sent.findLast(x=>x.name==="arMixAction").payload; + assert.equal(mainMute.parameter,"mute"); + assert.equal(mainMute.value,true); + listeners.get("arMixM4MasterAck")({ + requestId:mainMute.requestId,parameter:"mute",ok:true, + deviceEpoch:10,revision:8,value:true + }); + const mainMuted=clone(mainUpdated); + mainMuted.legacyM4.masterControls.mute=true; + listeners.get("arMixConsoleSnapshot")(mainMuted); + assert.equal(nativeMaster.mute,true); }); test("M2 code edits approved Pages *events* only, not a second native GUI/audio engine",()=>{ const page=read("site/preview-v2/index.html"); From 0dae6f059977a4912a9e2fa41fed092220a126d3 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:41:28 +0700 Subject: [PATCH 26/28] perf(gui): stop redundant 12Hz root authority attribute writes --- web/approved-native-bridge.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index af3407000..4dcffd251 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -29,9 +29,10 @@ const demo = document.getElementById("preview"); if (demo) {demo.disabled = true;demo.title = "Demo meters disabled in native Windows application";} scope?.stopDemo?.(); - document.documentElement.dataset.armixNativeAuthority = - flags.productionCallbackLive ? "product-live" : - flags.acceptedGraphConnected ? "pcm-accepted" : "not-admitted"; + const authority=flags.productionCallbackLive?"product-live": + flags.acceptedGraphConnected?"pcm-accepted":"not-admitted"; + if(document.documentElement.dataset.armixNativeAuthority!==authority) + document.documentElement.dataset.armixNativeAuthority=authority; }; const nativeIdFor = t => nativeByUiId.get(t?.id) || null; const intent = (operation,t,payload) => { From c1d7d0099856830c628e7407eedc6a04b056b2f3 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:44:14 +0700 Subject: [PATCH 27/28] fix(meter): report measured MAIN stereo PCM peaks only when armed and observed --- integration/ApprovedNativeRuntimeSnapshot.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/integration/ApprovedNativeRuntimeSnapshot.h b/integration/ApprovedNativeRuntimeSnapshot.h index b63343d9b..bd7992d7a 100644 --- a/integration/ApprovedNativeRuntimeSnapshot.h +++ b/integration/ApprovedNativeRuntimeSnapshot.h @@ -176,6 +176,21 @@ inline bool publishVerifiedFirstSoundState(juce::var& snapshot, } firstSound->setProperty("channelPeaksL",juce::var(peakL)); firstSound->setProperty("channelPeaksR",juce::var(peakR)); + // MAIN L/R callback peaks must remain dark until the monitor/output gate + // reports measured native PCM. Never paint the Pages demo oscillator. + juce::var mainL,mainR; + if(physicalReady && boolIs(route,"hasAcceptedRoute",true) && + boolIs(telemetry,"mainPcmObserved",true)) { + double l=0.,r=0.; + if(nativeV8Number(route.getProperty("peakL",{}),l) && + nativeV8Number(route.getProperty("peakR",{}),r) && + std::isfinite(l)&&std::isfinite(r)&&l>=0.&&r>=0.&& + l<=16.&&r<=16.) { + mainL=l;mainR=r; + } + } + firstSound->setProperty("mainPeakL",mainL); + firstSound->setProperty("mainPeakR",mainR); // Do not write the route to the graph or change native capability flags. snapshot.getDynamicObject()->setProperty("legacyM4",juce::var(firstSound.release())); return physicalReady; From f91ac75f3caa1e4df5ba695c8cd1b653cc99e56e Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 5 Nov 2026 12:44:34 +0700 Subject: [PATCH 28/28] fix(gui): paint genuine MAIN L/R callback peaks and silence unavailable G0 meters --- web/approved-native-bridge.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 4dcffd251..d3ff7bb51 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -627,6 +627,18 @@ } } const master=hardware?.raw?.legacyM4?.masterControls; + // Paint actual MAIN L/R independently, not duplicated browser demo + // motion, and force silence when native output telemetry is unavailable. + const mainStrip=document.querySelector(".strip.master"); + const m4=hardware?.raw?.legacyM4; + for(const [side,peak] of [["left",m4?.mainPeakL],["right",m4?.mainPeakR]]){ + const fill=mainStrip?.querySelector(".meter-fill."+side); + if(!fill||!scope?.displayMeterDbfs)continue; + const measured=typeof peak==="number"&&Number.isFinite(peak)&&peak>=0; + const db=measured&&peak>0?20*Math.log10(peak):-90; + scope.displayMeterDbfs(fill,Math.max(-90,Math.min(6,db)), + performance.now(),"MAIN:"+side); + } const masterTrack=scope?.master; if(master&&masterTrack){ if(masterPending?.acked && String(hardware?.device?.epoch)===