diff --git a/integration/ApprovedNativeRuntimeSnapshot.h b/integration/ApprovedNativeRuntimeSnapshot.h index eaafd93b0..b3f1c5081 100644 --- a/integration/ApprovedNativeRuntimeSnapshot.h +++ b/integration/ApprovedNativeRuntimeSnapshot.h @@ -82,7 +82,30 @@ inline bool publishVerifiedFirstSoundState(juce::var& snapshot, boolIs(route,"hasAcceptedRoute",true)); firstSound->setProperty("routingRevision",physicalReady ?juce::String(static_cast(revision)):juce::String("0")); - // Do not write the route to the graph or change native capability flags. + // Native Windows WebView2 needs accepted physical inputs for EACH source + // strip, not the Pages demo "IN None". These are message-thread copies of + // REAL M4 accepted readback, never invented ChannelIds, FX or PCM. + juce::Array channels; + const auto selection=route.getProperty( + boolIs(route,"hasAcceptedRoute",true)?"acceptedRoute":"preparedM4Route",{}); + const auto sourceRows=selection.getProperty("channels",{}); + if(physicalReady && sourceRows.isArray() && + sourceRows.getArray()->size()==10) { + for(const auto& source:*sourceRows.getArray()) { + if(!source.isObject()) { channels.clear(); break; } + const auto mode=source.getProperty("mode",{}).toString(); + if(mode!="NONE" && mode!="MONO" && mode!="STEREO" && + mode!="BUS") {channels.clear();break;} + auto item=std::make_unique(); + item->setProperty("mode",mode); + item->setProperty("left",source.getProperty("left",-1)); + item->setProperty("right",source.getProperty("right",-1)); + item->setProperty("main",source.getProperty("main",true)); + channels.add(juce::var(item.release())); + } + } + firstSound->setProperty("channels",juce::var(channels)); + // Do not write the route to the ChannelId graph or change capabilities. snapshot.getDynamicObject()->setProperty("legacyM4",juce::var(firstSound.release())); return physicalReady; } diff --git a/tests/approved_native_m2_contract.test.cjs b/tests/approved_native_m2_contract.test.cjs index 2b584dd09..bd8af380c 100644 --- a/tests/approved_native_m2_contract.test.cjs +++ b/tests/approved_native_m2_contract.test.cjs @@ -114,6 +114,25 @@ test("native signal evidence is produced from measured engine fields, never JS s assert.doesNotMatch(transport,/setProperty \("rawCapturePeak", 0\.0\)/); assert.match(bridge,/protocol\.diagnoseFirstSound/); }); +test("P0 DAW native output uses shipped ONE WebView2 source menu on every installed channel",()=>{ + const bridge=read("web/approved-native-bridge.js"); + const producer=read("integration/ApprovedNativeRuntimeSnapshot.h"); + assert.match(bridge,/scope\.tracks\.filter\(t=>t\.kind==="audio"\)\.slice\(0,10\)/); + assert.match(bridge,/select\.route-select\[data-field="input"\]/); + assert.match(bridge,/select\.dataset\.armixPhysicalInput=String\(channel\)/); + assert.match(bridge,/select\.replaceChildren/); + assert.match(bridge,/action:"routingSourceSwitch",requestId:p\.id,channel:p\.channel/); + assert.match(bridge,/backend\.addEventListener\("arMixSourceSwitchAck"/); + assert.match(bridge,/completeNativeSourceFromReadback\(next\)/); + assert.match(bridge,/action:"monitor",value:true/); + assert.match(bridge,/action:"audioDeviceInventory"/); + assert.match(bridge,/action:"audioDeviceApply"/); + assert.match(producer,/firstSound->setProperty\("channels",juce::var\(channels\)\)/); + assert.match(producer,/boolIs\(route,"hasAcceptedRoute",true\)\?"acceptedRoute":"preparedM4Route"/); + assert.doesNotMatch(bridge,/window\.__arMixOpenAudioIO/); + // No EXE startup dependency on a second non-bundled mixer renderer: + assert.match(read("scripts/build_approved_native_gui.py"),/NATIVE_ADAPTER = ROOT \/ "web" \/ "approved-native-bridge\.js"/); +}); test("strict producer rejects JS Number identities, invalid hardware pins and fake LIVE",()=>{ const cases=[ s=>{s.device.epoch=69;}, @@ -432,7 +451,12 @@ test("native Windows operator can explicitly patch first physical input, arm and 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,/ADVANCED · DRIVER \/ FIRST SOUND DIAGNOSTICS/); + assert.match(js,/setup\.addEventListener\("click",openNativeAudioSettings\)/); + assert.match(js,/function openNativeAudioSettings\(\)/); + assert.match(js,/id="arNativeAudioIO"|setupButton\.id="arNativeAudioIO"/); + assert.match(js,/renderVerifiedStripInputs\(next\)/); + assert.match(js,/advanced\.append\(caption,setup,driver,inputSelect,routeBtn,armBtn,muteBtn,hardwareNote\)/); assert.match(js,/action:"audioSetup"/); assert.match(js,/d\.inputEndpoints\.filter\(p=>/); assert.match(js,/d\.enabledInputs\.includes\(p\.port\)/); diff --git a/web/approved-native-bridge.js b/web/approved-native-bridge.js index 212cd2d9f..452521907 100644 --- a/web/approved-native-bridge.js +++ b/web/approved-native-bridge.js @@ -177,8 +177,190 @@ hardware.device.sampleRate>0 && hardware.device.enabledInputs.length>0 && hardware.device.enabledOutputs.length>=2 && legacy()?.active===true); + // Shipped DAW-style physical-source controls. These live in the ONE + // approved /preview/ WebView2, not web/mixer-io.js (not part of this EXE). + // The ORIGINAL visible strip IN row replaces demo input choices. Each of + // the ten installed M4 inputs has its own native routing command and ACK. + let selectedSourcePending=null, selectedSourceSerial=5000; + const availablePhysicalInputs=next=>{ + const d=next?.device; + if(!next?.raw?.legacyM4?.active || !Array.isArray(d?.inputEndpoints) || + !Array.isArray(d?.enabledInputs))return []; + return d.inputEndpoints.filter(p=> + p?.active===true && Number.isInteger(p.port) && + d.enabledInputs.includes(p.port)).sort((a,b)=>a.port-b.port); + }; + const routeValue=r=>r?.mode==="MONO"?"MONO:"+r.left: + r?.mode==="STEREO"?"STEREO:"+r.left+":"+r.right: + r?.mode==="NONE"?"NONE":"CUSTOM"; + const sourceChoices=pins=>{ + const items=[["NONE","None · silent"]]; + for(const p of pins) + items.push(["MONO:"+p.port,"Mono · "+String(p.label||"IN "+(p.port+1))]); + for(let i=0;i+10; + const tracks=scope.tracks.filter(t=>t.kind==="audio").slice(0,10); + for(let channel=0;channel{ + const option=document.createElement("option"); + option.value=value;option.textContent=label;return option; + })); + select.dataset.options=signature; + } + const live=rows[channel],value=routeValue(live); + if(value==="CUSTOM" && !Array.from(select.options).some(o=>o.value===value)){ + const extra=document.createElement("option"); + extra.value="CUSTOM";extra.textContent="Internal bus · advanced"; + select.appendChild(extra); + } + const selected=Array.from(select.options).some(o=>o.value===value)?value:"NONE"; + if(select.value!==selected)select.value=selected; + const disabled=!ready || !!selectedSourcePending; + if(select.disabled!==disabled)select.disabled=disabled; + select.title=ready?"CH "+(channel+1)+" · "+(select.selectedOptions[0]?.textContent||"Input")+ + " · accepted hardware route":"Choose real ASIO/WASAPI input/output in Audio Setup"; + } + // Don't display Pages-only SOURCE ONLY and phantom hardware outputs. + const demoOut=strip.querySelector('select.route-select[data-field="output"]'); + let actualOut=strip.querySelector('[data-armix-native-output]'); + if(demoOut){ + actualOut=document.createElement("span"); + actualOut.className="route-select"; + actualOut.dataset.armixNativeOutput=String(channel); + demoOut.replaceWith(actualOut); + } + if(actualOut){ + const accepted=legacyRoute?.routeAccepted===true && ready; + const text=!accepted?"MAIN · unverified": + rows[channel]?.main===false?"SEND ONLY": + rows[channel]?.mode==="NONE"?"MAIN · no input":"MAIN"; + if(actualOut.textContent!==text)actualOut.textContent=text; + actualOut.title="Native output "+String(d?.playbackDevice||"not set"); + } + } + } + function requestNativeSource() { + const p=selectedSourcePending; + if(!p)return; + p.phase="patch"; + backend.emitEvent("arMixAction",{ + action:"routingSourceSwitch",requestId:p.id,channel:p.channel, + mode:p.mode,left:p.left,right:p.right, + deviceEpoch:p.epoch,revision:p.revision + }); + status("CH "+(p.channel+1)+" · input routing requested"); + } + function completeNativeSourceFromReadback(next) { + const p=selectedSourcePending; + if(!p||p.phase!=="readback")return; + if(next?.device?.epoch!==String(p.epoch)){ + selectedSourcePending=null; + status("Device changed · select input again");return; + } + const l=next?.raw?.legacyM4,actual=l?.channels?.[p.channel]; + if(l?.routeAccepted!==true||routeValue(actual)!==p.value)return; + if(next.device.outputArmed){ + selectedSourcePending=null; + status("CH "+(p.channel+1)+" · hardware input LIVE");return; + } + // One operator input choice also requests monitoring after an actual + // native patch ACK. Native liveOutputArmFault remains final authority. + // Driver opens/hotplug NEVER initiate this independently. + const anyRouted=l.channels.some(r=>r.main!==false && + (r.mode==="MONO"||r.mode==="STEREO")); + if(!anyRouted){ + selectedSourcePending=null; + status("Inputs unpatched · output remains muted");return; + } + const revision=safeNativeCounter(l.routingRevision); + if(revision===null){selectedSourcePending=null;return;} + p.phase="arming"; + backend.emitEvent("arMixAction",{action:"monitor",value:true, + expectedEpoch:p.epoch,expectedRevision:revision}); + } + function installNativeStripInputEvents() { + const bank=document.getElementById("tracks"); + if(bank && typeof MutationObserver==="function"){ + const observer=new MutationObserver(()=>renderVerifiedStripInputs(hardware)); + // Only the bank's direct children change on re-render/bank switch. + // Updating