Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/build_approved_native_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ def accepted_pages_html() -> str:
"window.__ARMIX_NATIVE_SCOPE__=Object.freeze({\n"
" get tracks(){return tracks;},get master(){return master;},\n"
" get wireEdges(){return wireEdges;}, // native read-only UI edge identity\n"
" get sofEnabled(){return sofEnabled;},get sofTarget(){return sofTarget;},toggleSof,\n"
" get sofEnabled(){return sofEnabled;},get sofTarget(){return sofTarget;},\n"
" get sofTargetId(){return sofTargetId;},toggleSof,\n"
" get selectedWireEdgeId(){return selectedWireEdgeId;},\n"
" get wireGainDragging(){return !!sendKnobDrag;},paintWireKnob,\n"
" syncNativeWireGains(rows){\n"
Expand Down
119 changes: 83 additions & 36 deletions site/preview-v2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
}));}catch(error){/* Manager still works without browser storage. */}
}
const tracksEl=document.getElementById('tracks'),masterEl=document.getElementById('master'),info=document.getElementById('info');
let nextId=1,nextGroup=1,tracks=[],master,preview=false,meterFrame=0,lastTick=0,clipboard=null,scenes=[],stripView="fx",sofEnabled=false,sofTarget="Bus A",wireSourceId=1,wireEdges=[],nextWireId=1,selectedWireEdgeId=null,wireMode='send',wireAnchorId=null,wireHoverId=null,wireGesture=null,wireSuppressClick=false,pendingBusRoute=null,wireView='focus',wireSourcePinned=false,wireIntent=false;
let nextId=1,nextGroup=1,tracks=[],master,preview=false,meterFrame=0,lastTick=0,clipboard=null,scenes=[],stripView="fx",sofEnabled=false,sofTarget="Bus A",sofTargetId=null,wireSourceId=1,wireEdges=[],nextWireId=1,selectedWireEdgeId=null,wireMode='send',wireAnchorId=null,wireHoverId=null,wireGesture=null,wireSuppressClick=false,pendingBusRoute=null,wireView='focus',wireSourcePinned=false,wireIntent=false;
const clone=x=>JSON.parse(JSON.stringify(x));
const selection=()=>tracks.concat(master).filter(t=>t.selected);
const make=(name,kind,color)=>{
Expand Down Expand Up @@ -335,16 +335,15 @@
const nativeUnavailable=!!window.__JUCE__?.backend&&!t.nativeGainAvailable;
return '<div class="section fx-section is-gain-view"><div class="subhead">'+
'<span class="sym">G</span><span class="hint">INPUT GAIN</span></div>'+
'<div class="gain-view-body"><label class="gain-dial" style="--gain-rotation:'+(value*5.625).toFixed(2)+'deg" title="Digital input trim · reference UI only">'+
'<div class="gain-view-body"><label class="gain-dial" style="--gain-rotation:'+(value*5.625).toFixed(2)+'deg" title="Digital input gain before FX · native changes require acknowledged PCM">'+
'<span class="gain-dial-face" aria-hidden="true"></span>'+
'<input type="range" data-field="trim" min="-24" max="24" step="0.1" value="'+value+'" aria-label="'+escapeHtml(t.name)+' digital input gain"'+(nativeUnavailable?' disabled':'')+'></label>'+
'<output class="gain-readout" aria-label="Gain in decibels">'+(nativeUnavailable?'NATIVE PENDING':formatDb(value)+' dB')+'</output></div></div>';
}
/* SOF is a contextual UI view of an explicit existing EdgeId, not a new graph. */
function sectionSof(t){
// SOF is a view of ONE selected target WIRE, not a parallel audio graph.
const options=tracks.filter(x=>x.name===sofTarget&&(x.kind==='bus'||x.kind==='fx'));
const dest=options.length===1?options[0]:null;
const dest=selectedSofDestination();
const edge=dest?wireFor(t.id,dest.id):null;
const send=edge&&edge.kind==='send'?edge:null;
const native=!!window.__JUCE__?.backend;
Expand All @@ -354,11 +353,13 @@
const visual=!send?'idle':tap==='preFader'||tap==='preFx'?'pre':'post';
const badge=!edge?'NO SEND':edge.kind!=='send'?'PRIMARY OUT':
tap==='preFader'?'PRE-FADER':tap==='preFx'?'PRE-FX':'POST-FADER';
const status=!dest?'Select one unique BUS/FX':!edge?'Patch with WIRE':
!send?'Not an independent SEND':'LEVEL '+wireDbText(send.levelDb);
const status=!dest?'Select a BUS/FX':!edge?'Patch with WIRE':
!send?'PRIMARY ROUTE · no send level':
send.sendEnabled===false?'OFF · saved '+wireDbText(send.levelDb):
'LEVEL '+wireDbText(send.levelDb);
const editable=!!send&&(!native||t.nativeTapAvailable===true);
const onEditable=!!send&&(!native||t.nativeSendAvailable===true);
const enabled=send?.sendEnabled!==false;
const enabled=!!send&&send.sendEnabled!==false;
return '<div class="section fx-section is-sof-view" data-sof-target="'+(dest?.id||'')+'">'+
'<div class="subhead"><span class="sym">↗</span><span class="hint">SEND TO '+escapeHtml(sofTarget||'—')+'</span></div>'+
'<div class="sof-view-body"><div class="sof-info"><span class="sof-badge">'+badge+'</span>'+
Expand Down Expand Up @@ -756,25 +757,28 @@
const parallelSends=wireEdges.filter(e=>e.enabled&&e.sourceId===t.id&&e.kind==='send'&&e.destId!==master.id);
const allSendPost=parallelSends.length>0&&parallelSends.every(e=>e.mode==='send');
const allSendPre=parallelSends.length>0&&parallelSends.every(e=>e.mode==='split');
const tapMode=allSendPost?'send':allSendPre?'split':parallelSends.length?'mixed':t.wireTapMode==='split'?'split':'send';
const tapTarget=parallelSends.find(edge=>edge.id===selectedWireEdgeId)||
(parallelSends.length===1?parallelSends[0]:null);
const tapMode=tapTarget?tapTarget.mode:allSendPost?'send':allSendPre?'split':
parallelSends.length?'mixed':'idle';
const nativeTapUnavailable=!!window.__JUCE__?.backend&&!t.nativeTapAvailable;
// An unpatched channel has a future WIRE default, not an illuminated send.
// Four dedicated PNG frames avoid CSS-faked lighting: PRE, POST idle, POST
// routed, MIX (several outgoing SEND edges with different tap positions).
const tapVisual=nativeTapUnavailable?'idle':
parallelSends.length===0?(tapMode==='split'?'pre':'idle'):
parallelSends.length===0?'idle':
tapMode==='mixed'?'mixed':tapMode==='split'?'pre':'post';
const tapText=tapVisual==='mixed'?'MIX':tapVisual==='pre'?'PRE':'POST';
const tapEditable=!nativeTapUnavailable&&!!tapTarget;
const tapTitle=nativeTapUnavailable?'PRE/POST unavailable until native WIRE tap ACK; routing unchanged':
!parallelSends.length?'No parallel sends · '+(tapMode==='split'?'PRE':'POST')+
' is only the future WIRE default; primary MAIN unchanged':
tapMode==='mixed'?'Mixed PRE and POST parallel WIRE sends · click to set all POST':
!parallelSends.length?'NO SEND · connect and select an independent WIRE first':
tapMode==='mixed'?'Mixed PRE and POST parallel WIRE sends · select one WIRE before editing':
(tapMode==='send'?'POST follows channel fader':'PRE independent before FX')+
' · '+parallelSends.length+' outgoing parallel SEND(s), primary MAIN unchanged';
' · selected EdgeId '+(tapTarget?.id||'none')+' of '+parallelSends.length+' parallel SEND(s)';
code+='<div class="section switch-section mx-hw-row" role="group" data-tap-applicable="'+(t.kind!=='master'&&!sofEnabled)+'" aria-label="Channel Mute Solo'+(t.kind==='master'||sofEnabled?'':' and PRE/POST')+'">'
+'<button type="button" class="mx-hw-key" data-hw-kind="mute" data-action="mute" title="Mute channel" aria-label="Mute channel" aria-pressed="'+t.mute+'"><span class="mx-hw-fallback">MUTE</span></button>'
+'<button type="button" class="mx-hw-key" data-hw-kind="solo" data-action="solo" title="Solo channel" aria-label="Solo channel" aria-pressed="'+t.solo+'"><span class="mx-hw-fallback">SOLO</span></button>';
if(t.kind!=='master'&&!sofEnabled)code+='<button type="button" class="mx-hw-key" data-hw-kind="tap" data-action="tapMode" data-tap-visual="'+tapVisual+'" title="'+escapeHtml(tapTitle)+'" aria-label="'+escapeHtml(t.name+' '+tapTitle)+'" aria-pressed="'+(tapMode==='mixed'&&!nativeTapUnavailable?'mixed':Boolean(parallelSends.length&&tapMode==='send'&&!nativeTapUnavailable))+'" '+(nativeTapUnavailable?'disabled':'')+'><span class="mx-hw-fallback">'+tapText+'</span></button>';
if(t.kind!=='master'&&!sofEnabled)code+='<button type="button" class="mx-hw-key" data-hw-kind="tap" data-action="tapMode" data-tap-visual="'+tapVisual+'" title="'+escapeHtml(tapTitle)+'" aria-label="'+escapeHtml(t.name+' '+tapTitle)+'" aria-pressed="'+(tapMode==='mixed'&&!nativeTapUnavailable?'mixed':Boolean(parallelSends.length&&tapMode==='send'&&!nativeTapUnavailable))+'" '+(!tapEditable?'disabled':'')+'><span class="mx-hw-fallback">'+tapText+'</span></button>';
code+='</div>';
code+=sectionFader(t);
code+='<div class="bottom-section"><div class="db-value">'+(sofEnabled&&t.kind==='audio'?'S ': '')+formatDb(sofEnabled&&t.kind==='audio'?getSofLevel(t):t.level)+'</div><div class="footer-label '+(t.kind==='master'?'master-label':t.kind==='bus'?'bus-label':'')+'"><span class="name" data-action="rename" title="Double-click to edit name, icon and color · F2" tabindex="0" role="button">'+escapeHtml(t.name)+'</span><span class="footer-icon" aria-hidden="true">'+escapeHtml(iconFor(t))+'</span><div class="color-strip"></div></div></div></article>';
Expand Down Expand Up @@ -819,8 +823,8 @@
if(tracksEl.style?.setProperty)tracksEl.style.setProperty('--bank-columns',String(capacity));
// Release observers for detached bank DOM; never accumulate orphan lanes.
meterObserver?.disconnect();meterGeometry=new WeakMap();
updateSofTargets(); // Resolve selected EdgeId destination before painting strips.
tracksEl.innerHTML=bankTracks.map(strip).join('');
updateSofTargets();
const gainBtn=document.getElementById('gainView'),fxBtn=document.getElementById('fxView');
for(const [button,value] of [[gainBtn,'gain'],[fxBtn,'fx']]){
button.disabled=sofEnabled;
Expand Down Expand Up @@ -866,23 +870,33 @@
btn.classList.toggle('active',compact);btn.setAttribute('aria-pressed',String(compact));
return density;
}
function selectedSofDestination(){
// A stable local display ID, never an audio-graph identity or a bus name.
// Native ChannelId stays a precise decimal string in the bridge.
return tracks.find(t=>t.id===sofTargetId&&(t.kind==='bus'||t.kind==='fx'))||null;
}
function updateSofTargets(){
const el=document.getElementById('sofTarget'),choices=tracks.filter(t=>t.kind==='bus'||t.kind==='fx').map(t=>t.name);
const target=choices.includes(sofTarget)?sofTarget:choices[0]||'';
sofTarget=target;
const html=choices.map(name=>'<option value="'+escapeHtml(name)+'">'+escapeHtml(name)+'</option>').join('');
if(el.innerHTML!==html)el.innerHTML=html;el.value=sofTarget;
const el=document.getElementById('sofTarget');
const choices=tracks.filter(t=>t.kind==='bus'||t.kind==='fx');
let target=selectedSofDestination();
if(!target){
const named=choices.filter(t=>t.name===sofTarget);
target=named.length===1?named[0]:choices[0]||null;
}
sofTargetId=target?.id??null;sofTarget=target?.name||'';
const html=choices.map(t=>'<option value="'+t.id+'">'+escapeHtml(t.name)+'</option>').join('');
if(el.innerHTML!==html)el.innerHTML=html;
el.value=target?String(target.id):'';
}
function getSofIndex(t){return t.sendSlots.findIndex((slot,i)=>(i===t.activeSend?t.send:slot.send)===sofTarget);}
function getSofEdge(t){
const options=tracks.filter(x=>x.name===sofTarget&&(x.kind==='bus'||x.kind==='fx'));
const dest=options.length===1?options[0]:null;
const dest=selectedSofDestination();
const edge=dest&&wireFor(t.id,dest.id);
return edge&&edge.kind==='send'?edge:null;
}
function getSofLevel(t){const edge=getSofEdge(t);return edge?edge.levelDb:-60;}
function setSofLevel(t,newLevel){
const dest=tracks.find(x=>x.name===sofTarget&&x.id!==t.id);
const dest=selectedSofDestination();
if(!dest||t.kind==='master')return false;
const level=Math.round(Math.max(-60,Math.min(6,newLevel))*10)/10;
const edge=getSofEdge(t);
Expand All @@ -892,7 +906,8 @@
}
function toggleSof(force){
sofEnabled=typeof force==='boolean'?force:!sofEnabled;
if(sofEnabled&&!sofTarget){sofEnabled=false;say('Create a Bus or FX Return to use Sends on Faders');return;}
updateSofTargets();
if(sofEnabled&&!selectedSofDestination()){sofEnabled=false;say('Create a Bus or FX Return to use Sends on Faders');return;}
const btn=document.getElementById('sofToggle');btn.classList.toggle('active',sofEnabled);
btn.setAttribute('aria-pressed',String(sofEnabled));document.querySelector('.console-body').classList.toggle('sends-mode',sofEnabled);
render();say(sofEnabled?'SENDS ON FADERS: adjusting '+sofTarget+' send levels · main faders protected':'MAIN MIX: faders control primary channel level');
Expand Down Expand Up @@ -2137,14 +2152,13 @@
// MIX status is not permission to rewrite all parallel connections.
const selected=sends.find(edge=>edge.id===selectedWireEdgeId)||(sends.length===1?sends[0]:null);
if(sends.length>1&&!selected){say('Select a specific WIRE before changing its tap');return;}
const next=selected?(selected.mode==='send'?'split':'send'):(t.wireTapMode==='split'?'send':'split');
if(selected&&!wireGraphCommit([{type:'MODE',sourceId:t.id,edgeId:selected.id,mode:next}]))return;
t.wireTapMode=next;
if(wireSourceId===t.id){wireMode=next;document.getElementById('wireMode').value=next;}
if(!selected){say('NO SEND · patch and select one WIRE before changing its tap');return;}
const next=selected.mode==='send'?'split':'send';
if(!wireGraphCommit([{type:'MODE',sourceId:t.id,edgeId:selected.id,mode:next}]))return;
refreshStrip(t);selectTrack(t);
say(t.name+' '+(next==='split'?'PRE (independent pre-FX)':'POST (follow fader)')+
' · outgoing parallel WIRE sends '+(sends.length?'updated':'default selected')+
' · primary MAIN unchanged · GUI reference only');
say(t.name+' → '+(tracks.find(x=>x.id===selected.destId)?.name||'BUS')+
' '+(next==='split'?'PRE-FX':'POST-FADER')+
' · one EdgeId only · primary MAIN unchanged · GUI reference');
return;
}
if(a==='eq')t.eq=!t.eq;
Expand All @@ -2164,7 +2178,28 @@
if(e.target.closest?.('.wire-gain,.wire-pot')){
const el=e.target.closest('.wire-pot')?.querySelector('.wire-gain')||e.target.closest('.wire-gain');el.value='0';handleField({target:el,type:'change'});return;
}
if(e.target.classList.contains('fader')){t.level=0;refreshStrip(t);say(t.name+' fader reset to 0.0 dB');}
const dial=e.target.closest?.('.gain-dial');
if(dial){
const gain=dial.querySelector('[data-field="trim"]');
if(!gain||gain.disabled)return;
// Same field path as a knob gesture: native ACK, no UI-only gain mutation.
gain.value='0';gain.dispatchEvent(new Event('input',{bubbles:true}));
gain.dispatchEvent(new Event('change',{bubbles:true}));
if(!window.__JUCE__?.backend)say(t.name+' digital input gain → unity (0.0 dB)');
return;
}
if(e.target.classList.contains('fader')){
const send=sofEnabled&&t.kind==='audio';
if(send&&!getSofEdge(t)){say('NO SEND · patch one WIRE first');return;}
// Never mutate t.level directly: in SOF the physical fader belongs to
// the selected EdgeId, not MAIN. Native bridge owns the accepted write.
const fader=e.target;
if(fader.disabled)return;
fader.value='0';fader.dispatchEvent(new Event('input',{bubbles:true}));
fader.dispatchEvent(new Event('change',{bubbles:true}));
if(!window.__JUCE__?.backend)say(t.name+(send?' SEND':' MAIN')+' fader → 0.0 dB');
return;
}
if(e.target.classList.contains('center-pan')){t.pan=0;refreshStrip(t);say(t.name+' pan centered');}
if(e.target.closest('.footer-label,.strip-identity-top'))openChannelIdentity(t,e.target);
});
Expand Down Expand Up @@ -2645,13 +2680,25 @@
for(const [id,value] of [['gainView','gain'],['fxView','fx']]){
document.getElementById(id).addEventListener('click',()=>{
if(sofEnabled)return;
if(value==='gain'&&window.__JUCE__?.backend){say('Native input gain requires accepted DSP control');return;}
if(value==='gain'&&window.__JUCE__?.backend&&
!tracks.some(t=>t.kind==='audio'&&t.nativeGainAvailable===true)){
say('INPUT GAIN unavailable · no channel has an acknowledged native gain stage');
return;
}
// View selection is presentation-only; the DSP insert chain stays resident.
stripView=value;render();
say(value==='gain'?'Digital INPUT GAIN view · preview trim only':'FX RACK view · existing inserts preserved');
say(value==='gain'?'Digital INPUT GAIN · each knob follows accepted channel readback':
'FX RACK · existing inserts preserved');
});
}
document.getElementById('sofToggle').addEventListener('click',()=>toggleSof());
document.getElementById('sofTarget').addEventListener('change',()=>{sofTarget=document.getElementById('sofTarget').value;render();say('Sends target: '+sofTarget);});
document.getElementById('sofTarget').addEventListener('change',()=>{
const id=Number(document.getElementById('sofTarget').value);
const target=tracks.find(t=>t.id===id&&(t.kind==='bus'||t.kind==='fx'));
if(!target){updateSofTargets();say('Invalid SEND target · selection unchanged');return;}
sofTargetId=target.id;sofTarget=target.name;
render();say('SEND MIX → '+sofTarget+' · MAIN faders protected');
});
document.getElementById('addTrack').addEventListener('click',()=>{
const n=tracks.filter(t=>t.kind==='audio').length+1,t=make('Track '+n,'audio',COLORS[(n-1)%COLORS.length]);const firstBus=tracks.findIndex(x=>x.kind==='bus');tracks.splice(firstBus<0?tracks.length:firstBus,0,t);
if(!wireGraphCommit([{type:'CONNECT',sourceId:t.id,destId:master.id}],{record:false})){tracks=tracks.filter(x=>x.id!==t.id);return;}revealTrack(t);say('Added '+t.name+' → MAIN · reference only');
Expand Down Expand Up @@ -2713,7 +2760,7 @@
if(x.send===old)x.send=name;
x.sendSlots.forEach(slot=>{if(slot.send===old)slot.send=name;});
});
if(sofTarget===old)sofTarget=name;
if(sofTargetId===t.id)sofTarget=name;
closeChannelIdentity();render();say('Channel identity updated · '+name+' · routing references preserved');
}
document.getElementById('identityClose').addEventListener('click',closeChannelIdentity);
Expand Down
21 changes: 21 additions & 0 deletions tests/approved_native_m2_contract.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -1981,3 +1981,24 @@ test("O3 OUTPUTS stays in one existing Audio I/O with safe, read-only DOM",()=>{
assert.match(bridge,/owner\.textContent=patch\.role/);
assert.doesNotMatch(bridge,/owner\.innerHTML=patch/);
});

test("SOF double-click and target selection never commandeer MAIN fader",()=>{
const html=read("site/preview-v2/index.html");
const bridge=read("web/approved-native-bridge.js");
const bundle=read("scripts/build_approved_native_gui.py");
assert.match(html,/function selectedSofDestination\(\)/);
assert.match(html,/sofTargetId=target\?\.id\?\?null/);
assert.match(html,/const send=sofEnabled&&t\.kind==='audio'/);
assert.match(html,/fader\.dispatchEvent\(new Event\('change'/);
assert.match(bundle,/get sofTargetId\(\)\{return sofTargetId;\}/);
assert.match(bridge,/x\.id===scope\.sofTargetId/);
const start=bridge.indexOf("consumeDoubleClick(event,t)");
const end=bridge.indexOf("applyIdentity:",start);
assert.ok(start>0&&end>start,"native delegate must own double-click");
const handler=bridge.slice(start,end);
assert.ok(handler.indexOf("scope?.sofEnabled") <
handler.indexOf('sendM4Control'),
"SOF must intercept fader reset BEFORE M4/Main fader ownership");
assert.match(handler,/requestWireGain\(\{sourceId:t\.id,edgeId:id,levelDb:0\}\)/);
assert.match(handler,/intent\("SET_INPUT_GAIN",t,\{valueDb:0\}\)/);
});
Loading
Loading