From e8144f662f0d89850423c63f82bf3937a4fabaeb Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:51:45 +0700 Subject: [PATCH 01/12] P0 GUI: tailored recessed mono meter and compact threshold-colored master LCD --- AR-MIX-Live-FX-Host-Standalone-v0.3.html | 875 +++++++++++++++++++++++ web/app.js | 25 +- web/styles-src/42-mixer-premium.css | 42 ++ web/styles.css | 42 ++ 4 files changed, 975 insertions(+), 9 deletions(-) diff --git a/AR-MIX-Live-FX-Host-Standalone-v0.3.html b/AR-MIX-Live-FX-Host-Standalone-v0.3.html index 5e817d8d8..3360a36a3 100644 --- a/AR-MIX-Live-FX-Host-Standalone-v0.3.html +++ b/AR-MIX-Live-FX-Host-Standalone-v0.3.html @@ -1296,6 +1296,48 @@ #app #scenesList .scene-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0} #app #scenesList .scene-delete{flex:0 0 20px;height:18px;padding:0;border:1px solid #53646d;border-radius:2px;background:#26343c;color:#d0dbdf;font-size:14px;line-height:14px} #app #scenesList .scene-delete:hover{background:#40515a} + +/* The mono meter has ONE LED slot, stereo/master TWO. Keep 7px fixed LEDs. */ +#app #mixer .fader-zone .vu-bank.is-mono{ + flex-basis:35px;width:35px;min-width:35px;max-width:35px; +} +#app #mixer .fader-zone .vu-bank.is-mono .vu-bars{ + flex-basis:14px;width:14px;min-width:14px;max-width:14px; +} +/* Same machined recessed folds as fader; no external rectangular stroke. */ +#app #mixer .fader-zone .vu-bank .vu-bars{ + position:relative;isolation:isolate;border:0;border-radius:5px;background:#24343c; + box-shadow:inset 0 4px 4px -3px #070e13,inset 0 -4px 4px -3px #070e13, + inset 4px 0 5px -4px #081116,inset -4px 0 5px -4px #081116; +} +#app #mixer .fader-zone .vu-bank .meter-unit .meter{ + border:0;border-radius:2px;background:#080f14; + box-shadow:inset 0 1px 2px #0009,inset 1px 0 2px #000c,inset -1px 0 2px #000b; +} +#app #mixer .fader-zone .vu-bank .meter-unit .meter::after{ + inset:0;background:linear-gradient(180deg,#d3eced10,transparent 35%); +} +/* LUFS / dBTP: exactly two lines in a black glass LCD. No blur/compositor. */ +#app #masterLeft .master-controls-zone .master-analysis{ + box-sizing:border-box;height:38px;min-height:38px;flex:0 0 38px; + display:flex;flex-direction:column;justify-content:center;gap:1px; + margin:0;padding:3px 6px;border:0;border-radius:4px; + background:linear-gradient(180deg,#0d1c1c,#030a0b 35%,#071313); + box-shadow:inset 0 3px 4px -2px #000,inset 2px 0 3px -2px #000, + inset -2px 0 3px -2px #000,inset 0 -1px 0 #40625c77; +} +#app #masterLeft .master-controls-zone .master-analysis .master-info-row{ + display:flex;align-items:center;justify-content:space-between; + flex:0 0 14px;height:14px;min-height:14px;margin:0; + color:#70c2a1;font:600 9px/14px Consolas,monospace; +} +#app #masterLeft .master-controls-zone .master-analysis .master-info-row strong{ + color:#58f3a0;font:700 12px/14px Consolas,monospace; + min-width:0;text-align:right;text-shadow:none; +} +#app #masterLeft .master-controls-zone .master-analysis .master-info-row strong.over-limit{ + color:#ff555f;text-shadow:none; +}
@@ -2151,6 +2193,839 @@ let lastPersist=0;setInterval(()=>{if(Date.now()-lastPersist<2000)return;lastPersist=Date.now();persistSession()},5000); try{userSnapshots=JSON.parse(localStorage.getItem('armix-v03-snapshots')||'{}');savedChains=JSON.parse(localStorage.getItem('armix-v03-chains')||'{}');for(const k of Object.keys(userSnapshots))if(!scenes.includes(k))scenes.push(k)}catch{userSnapshots={};savedChains={}} +createSide();renderMixer();renderMaster();try{let last=JSON.parse(localStorage.getItem('armix-v03-current'));if(!last)last=JSON.parse(localStorage.getItem('arMixStudioUI')); if(last&&last.channels?.length>=channels.length){last.channels.slice(0,channels.length).forEach((s,i)=>{if(typeof s.name==='string'&&s.name.trim())channels[i].name=s.name.trim().slice(0,26); + if(channelIcons.includes(s.icon))channels[i].icon=s.icon; + if(channelPalette.includes(s.color))channels[i].color=s.color; + for(const k of ['fader','pan','trim','mute','solo','hpf'])if(s[k]!==undefined)channels[i][k]=s[k];if(Array.isArray(s.inserts))channels[i].inserts=s.inserts.filter(x=>typeof x==='string').slice(0,8)});sceneIdx=last.sceneIdx??0;masterGain=last.masterGain??-.1;masterPan=Number.isFinite(last.masterPan)?clamp(last.masterPan,-100,100):0;masterMute=!!last.masterMute;masterMono=!!last.masterMono; + send('masterMono',masterMono,-1); + if(Array.isArray(last.masterInserts))masterInserts=last.masterInserts.filter(x=>typeof x==='string').slice(0,6); + if(last.masterBypassed&&typeof last.masterBypassed==='object')masterBypassed={...last.masterBypassed}; + if(last.bypassed&&typeof last.bypassed==='object')bypassed={...last.bypassed}; + if(last.fxParams&&typeof last.fxParams==='object')fxParams=structuredClone(last.fxParams); + renderMixer();renderMaster();flash('Previous UI session restored')}}catch{} +// Stop all simulated animation work while the tab is hidden, and restart on +// foregrounding. One owner per timer / RAF; never double-schedule on restore. +document.addEventListener('visibilitychange',()=>{ + if(document.hidden){ + if(meterTimer){clearTimeout(meterTimer);meterTimer=0} + if(meterRAF){cancelAnimationFrame(meterRAF);meterRAF=0} + }else if(!meterTimer&&!meterRAF)scheduleDemoMeter(); +}); +scheduleDemoMeter(); +'use strict'; +// AR MIX Studio UI-only demonstration. No audio is mixed or routed here. +const colors=['#1699cd','#b92e41','#cf6b1e','#b28c27','#34a544','#168762','#0e95c9','#066fa9','#7140b5','#b52893','#c32974','#586889']; +const raw=[ + ['Lead Vocal','♩',['Gate','EQ','Compressor','Reverb'],-.6,0], + ['Mic 2','♩',['EQ','Compressor','De-Esser'],-4.7,-15], + ['Music L','♫',['EQ','Compressor'],-10.3,0], + ['Music R','♫',['EQ','Compressor'],-6.1,0], + ['Guest Mic','♩',['Gate','EQ','Compressor'],-8.8,10], + ['Stream PC','▥',['EQ','Limiter'],-12.4,0], + ['Backing','♫',['EQ','Reverb'],-3.6,-25], + ['Guitar','♬',['EQ','Compressor','Delay'],-7.9,30], + ['Keyboard','▥',['EQ','Reverb'],-14.2,0], + ['FX Return','◎',['Reverb'],-5.1,0] +]; +const channels=raw.map((a,i)=>({id:i+1,name:a[0],icon:a[1],color:colors[i],inserts:[...a[2]],fader:a[3],pan:a[4],trim:0,mute:false,solo:false,pre:false,hpf:i%4!==0,stereo:i>=6})); +let currentChannel=0, masterSelected=false, view='MIX', sceneIdx=0, timer=0; +const scenes=['Vocal Live','Karaoke Warm','Clean Voice','Studio Session']; +const $=id=>document.getElementById(id); +const clamp=(v,min,max)=>Math.max(min,Math.min(max,v)); +const levelToTop=db=>+(clamp((10-db)/70,0,1)*100).toFixed(3); +const fmt=db=>db===-Infinity?'−∞':`${db>0?'+':''}${db.toFixed(1)} dB`; +// UI side throttling is distinct from the native realtime control plane. +const pendingUiParams=new Map();let uiFlushScheduled=false; +const peakHold=Object.create(null),clipLatch=Object.create(null); +function resetClip(key){ + clipLatch[key]=false;delete peakHold[key]; + document.querySelector(`[data-clip="${key}"]`)?.classList.remove('latched'); + const entry=meterNodes.get(key);if(entry?.peak){entry.peak.style.bottom='0%';entry.peakValue=-1} +} +function syncClipLeds(){document.querySelectorAll('[data-clip]').forEach(e=>e.classList.toggle('latched',!!clipLatch[e.dataset.clip]))} +// Cache per-meter nodes across preview frames, rebuilding on mixer re-render. +// Styling a full-height bar with a compositor transform avoids 14 cyclic height +// reflows per meter tick. No native meter or DSP data path is affected. +const meterNodes=new Map(); +// Shared preview/native painter: preserve fixed colors; light only whole 7px LEDs. +const LED_PITCH_PX=7,ledMeterCache=new WeakMap(); +// Opt-in performance A/B: reproduce pre-P1 raw-level DOM writes, with the +// exact same meter visuals. Production only writes CSS on visible LED changes. +const meterRawStyleWrites=new URLSearchParams(location.search).get('mixperf')==='meter-raw'; +function setLedMeterLevel(el,rawLevel){ + if(!el)return; + const level=clamp(Number(rawLevel)||0,0,100); + let state=ledMeterCache.get(el); + if(!state){state={height:el.getBoundingClientRect().height,level:-1,lit:-1};ledMeterCache.set(el,state)} + const levelChanged=state.level!==level; + state.level=level; // Full precision remains cached for ResizeObserver / telemetry. + const lit=level>=100?state.height:Math.floor((level*state.height/100+1e-7)/LED_PITCH_PX)*LED_PITCH_PX; + if(state.lit!==lit){ + state.lit=lit; + // --led-lit drives the clip; --level remains the compatible fallback, + // updated only when the visible whole-row LED state actually changes. + el.style.setProperty('--level',level+'%'); + el.style.setProperty('--led-lit',lit+'px'); + }else if(meterRawStyleWrites&&levelChanged){ + // Diagnostics only: old unconditional raw-level style invalidation. + el.style.setProperty('--level',level+'%'); + } +} +window.__arMixSetLedMeterLevel=setLedMeterLevel; + +// Native-only visual interpolation. JUCE sends true peak samples at 12 Hz; +// never change that realtime/data cadence to control animation smoothness. +// Exactly ONE pending timer + ONE rAF serve every live meter (not one per bar). +const NATIVE_METER_FRAME_MS=34; // ceiling 29.4 scheduled paint frames/s +const NATIVE_METER_ATTACK_SECONDS=.018; // immediate-looking, but visually bounded +const NATIVE_METER_RELEASE_SECONDS=.165; // fast initial fall, gentle exponential landing +const nativeMeterStates=new Map(); +const nativeMeterDirect=new URLSearchParams(location.search).get('metermotion')==='direct'; +const nativeMeterMotionStats={frames:0,scheduled:0,targets:0,meterPaintCalls:0,frameBudgetMs:NATIVE_METER_FRAME_MS,active:0}; +let nativeMeterTimer=0,nativeMeterRAF=0,nativeMeterLastTime=0; +function nativeMeterStep(level,target,dt){ + // One-pole envelope in DISPLAY space only: never modify audio/true peak. + // On a sudden level drop, travel is initially fast because the gap is large; + // speed decays continuously as the visible bar approaches the measured target. + // Time-correct across 30fps jitter; no easing animation, overshoot or bounce. + const span=Math.max(0,Math.min(.065,Number(dt)||0)); + if(!span||level===target)return level; + const tau=target>level?NATIVE_METER_ATTACK_SECONDS:NATIVE_METER_RELEASE_SECONDS; + const next=target+(level-target)*Math.exp(-span/tau); + // Sub-LED residual cannot be seen: stop scheduling without tail jitter. + return Math.abs(next-target)<.3?target:next; +} +function scheduleNativeMeterFrame(){ + if(nativeMeterTimer||nativeMeterRAF||document.hidden)return; + nativeMeterMotionStats.scheduled++; + nativeMeterTimer=setTimeout(()=>{ + nativeMeterTimer=0; + if(!document.hidden)nativeMeterRAF=requestAnimationFrame(animateNativeMeters); + },NATIVE_METER_FRAME_MS); +} +function animateNativeMeters(now){ + nativeMeterRAF=0; + if(document.hidden){nativeMeterLastTime=0;return;} + const dt=nativeMeterLastTime?Math.min(.065,Math.max(0,(now-nativeMeterLastTime)/1000)):NATIVE_METER_FRAME_MS/1000; + nativeMeterLastTime=now; + nativeMeterMotionStats.frames++; + let active=0; + for(const [el,s] of nativeMeterStates){ + if(!el.isConnected){nativeMeterStates.delete(el);continue;} + s.level=nativeMeterStep(s.level,s.target,dt); + setLedMeterLevel(el,s.level); + nativeMeterMotionStats.meterPaintCalls++; + if(Math.abs(s.level-s.target)>.3)active++; + } + nativeMeterMotionStats.active=active; + if(active)scheduleNativeMeterFrame(); + else nativeMeterLastTime=0; +} +function setNativeMeterTarget(el,rawValue){ + if(!el)return; + const target=clamp(Number(rawValue)||0,0,100); + let s=nativeMeterStates.get(el); + if(!s){ + // Mixer DOM may be rebuilt after a preset/FX edit: prune detached nodes + // without polling or leaking strong references to old LED bars. + if(nativeMeterStates.size>4) + for(const [old] of nativeMeterStates)if(!old.isConnected)nativeMeterStates.delete(old); + s={level:0,target:0};nativeMeterStates.set(el,s); + setLedMeterLevel(el,0); + } + s.target=target; + nativeMeterMotionStats.targets++; + if(nativeMeterDirect||document.hidden|| + (typeof matchMedia==='function'&&matchMedia('(prefers-reduced-motion: reduce)').matches)){ + s.level=target;setLedMeterLevel(el,target); + return; + } + if(Math.abs(s.level-target)>.3)scheduleNativeMeterFrame(); +} +window.__arMixSetNativeMeterTarget=setNativeMeterTarget; +window.__arMixMeterMotionStats=nativeMeterMotionStats; +document.addEventListener('visibilitychange',()=>{ + if(!document.hidden)return; + if(nativeMeterTimer){clearTimeout(nativeMeterTimer);nativeMeterTimer=0;} + if(nativeMeterRAF){cancelAnimationFrame(nativeMeterRAF);nativeMeterRAF=0;} + nativeMeterLastTime=0; + for(const [el,s] of nativeMeterStates){ + if(!el.isConnected){nativeMeterStates.delete(el);continue;} + s.level=s.target;setLedMeterLevel(el,s.level); + } + nativeMeterMotionStats.active=0; +}); + +// Observe only the stable mixer root, never disposable strips; no hot-path reflow. +if(typeof ResizeObserver==='function'){ + const ledResizeObserver=new ResizeObserver(()=>{ + document.querySelectorAll('#mixer [data-meter]').forEach(el=>{ + const state=ledMeterCache.get(el);if(!state)return; + const height=el.getBoundingClientRect().height; + if(height===state.height)return; + state.height=height;state.lit=-1;setLedMeterLevel(el,state.level); + }); + }); + const mixerRoot=document.getElementById('mixer'); + if(mixerRoot)ledResizeObserver.observe(mixerRoot); +} +function meterNode(key){ + const cached=meterNodes.get(key); + if(cached?.fill.isConnected)return cached; + const fill=document.querySelector(`[data-meter="${key}"]`); + if(!fill)return null; + const slot=fill.closest('.meter'); + const entry={fill,peak:slot?.querySelector('.meter-peak'), + clip:slot?.querySelector('.clip-led'),level:-1,peakValue:-1}; + // DOM replacement must not erase a held peak or a latched CLIP lamp. + const held=peakHold[key]; + if(held&&entry.peak){ + entry.peakValue=Math.round(held.value*10); + entry.peak.style.bottom=(entry.peakValue/10)+'%'; + } + if(clipLatch[key])entry.clip?.classList.add('latched'); + meterNodes.set(key,entry); + return entry; +} +function updateMeterVisual(key,level,now){ + const meter=meterNode(key);if(!meter)return; + const value=clamp(level,0,99); + const levelStep=Math.round(value*10); + if(meter.level!==levelStep){ + meter.level=levelStep; + setLedMeterLevel(meter.fill,levelStep/10); + } + const previous=peakHold[key]; + if(!previous||value>=previous.value||now>=previous.until){ + peakHold[key]={value,until:now+1600}; + const step=Math.round(value*10); + if(meter.peak&&meter.peakValue!==step){ + meter.peakValue=step; + meter.peak.style.bottom=(step/10)+'%'; + } + } + if(value>=97&&!clipLatch[key]){ + clipLatch[key]=true; + meter.clip?.classList.add('latched'); + } +} + +function flushUiParams(){uiFlushScheduled=false;const bridge=window.__JUCE__?.backend;if(bridge?.emitEvent)for(const event of pendingUiParams.values())bridge.emitEvent('arMixParameter',event);pendingUiParams.clear()} +function send(param,value,ch=currentChannel){ + const event={channel:ch+1,parameter:param,value}; + // P1I: native routing token rejects UI gestures from stale device graphs. + const liveToken=window.__armixRouteToken; + if(ch>=0&&ch<10&&liveToken?.epoch>0&&liveToken?.revision>0){ + event.routeEpoch=liveToken.epoch;event.routeRevision=liveToken.revision; + } + if(['faderDb','pan','trimDb','phonesDb','masterGain'].includes(param)){ + pendingUiParams.set(`${ch}:${param}`,event); + if(!uiFlushScheduled){uiFlushScheduled=true;requestAnimationFrame(flushUiParams)} + }else{flushUiParams();const bridge=window.__JUCE__?.backend;if(bridge?.emitEvent)bridge.emitEvent('arMixParameter',event)} +} +function flash(message){const x=$('toast');x.textContent=message;x.classList.add('show');clearTimeout(timer);timer=setTimeout(()=>x.classList.remove('show'),1500)} +function createSide(){ + const labels=channels.map(c=>c.name); + $('channelList').innerHTML=labels.map((label,i)=>`
${i+1}${safeText(label)}
`).join(''); + $('groupsList').innerHTML=['Drums','Band','Vocals','FX','All Music','All Vocals'].map((x,i)=>`
${i+1}${x}
`).join(''); + $('scenesList').innerHTML=scenes.map((x,i)=>`
${safeText(x)}${userSnapshots[x]?``:''}
`).join(''); + $('currentScene').innerHTML=`Snapshot: ${scenes[sceneIdx]}▾`; +} +function knobMarkup(param,ch,value,label,small=false){let angle=(param==='pan'?value/100*130:value/24*130);return ``} +function panText(v){return v===0?'C':(v<0?'L':'R')+' '+Math.abs(v)} +function panMarkup(ch,i){return `
`} + +const channelIcons=['♩','♫','♬','🎙','🎸','🎹','🥁','🎧','▥','◉','◎','⊞']; +const channelPalette=['#1699cd','#b92e41','#cf6b1e','#b28c27','#34a544','#168762','#0e95c9','#066fa9','#7140b5','#b52893','#c32974','#586889']; +let editingChannel=-1,editingColor='',editingIcon=''; +// Position the lightweight popover at the strip name the user actually clicked. +// Clamp the panel to the visible viewport without breaking its anchor/arrow. +function positionChannelIdentity(){ + const modal=$('channelIdentity');if(editingChannel<0||!modal||modal.classList.contains('hidden'))return; + const anchor=document.querySelector('[data-editstrip="'+editingChannel+'"]'); + const panel=modal.querySelector('.identity-panel');if(!anchor||!panel)return; + const target=anchor.getBoundingClientRect(),pop=panel.getBoundingClientRect(); + const left=clamp(target.left+target.width/2-pop.width/2,10,Math.max(10,innerWidth-pop.width-10)); + const top=Math.max(10,target.top-pop.height-12); + panel.style.left=left+'px';panel.style.top=top+'px'; + panel.style.setProperty('--identity-pointer-x',clamp(target.left+target.width/2-left,18,pop.width-18)+'px'); +} +function openChannelIdentity(index){ + if(!Number.isInteger(index)||index<0||index>=channels.length)return; + editingChannel=index;editingColor=channels[index].color||colors[index];editingIcon=channels[index].icon; + const modal=$('channelIdentity');if(!modal)return; + $('identityIndex').textContent=String(index+1).padStart(2,'0'); + $('identityName').value=channels[index].name; + $('identityIcons').innerHTML=channelIcons.map(icon=>``).join(''); + $('identityColors').innerHTML=channelPalette.map(color=>``).join(''); + modal.classList.remove('hidden'); + document.querySelectorAll('.strip.identity-editing').forEach(el=>el.classList.remove('identity-editing')); + document.querySelector('[data-strip="'+index+'"]')?.classList.add('identity-editing'); + positionChannelIdentity(); + $('identityName').focus();$('identityName').select(); +} +function closeChannelIdentity(){ + editingChannel=-1;$('channelIdentity')?.classList.add('hidden'); + document.querySelectorAll('.strip.identity-editing').forEach(el=>el.classList.remove('identity-editing')); +} +function commitChannelIdentity(){ + if(editingChannel<0)return;const index=editingChannel; + const name=$('identityName').value.trim().replace(/\s+/g,' ').slice(0,26); + if(!name){flash('Enter a channel name');$('identityName').focus();return} + channels[index].name=name;channels[index].icon=channelIcons.includes(editingIcon)?editingIcon:'♩'; + channels[index].color=channelPalette.includes(editingColor)?editingColor:colors[index]; + closeChannelIdentity();currentChannel=index;renderMixer(); + if(view==='FX RACK')renderRackWorkspace(); + persistSession();flash('Channel identity updated'); +} +window.addEventListener('resize',positionChannelIdentity); +$('mixer').addEventListener('scroll',positionChannelIdentity,{passive:true}); +function makeStrip(ch,i){let inserts=ch.inserts.slice(0,6);while(inserts.length<6) inserts.push('');return `
+
${i+1}
${inserts.map((n,j)=>`
${n?``:''}
`).join('')}
+
TRIM
dB
${fmt(ch.trim)}
${knobMarkup('trim',i,ch.trim,'Trim')}
${panMarkup(ch,i)}
${panText(ch.pan)}
+
+
${fmt(ch.fader)}
${ch.stereo?meterUnit(String(i)+'L','L')+meterUnit(String(i)+'R','R'):meterUnit(String(i),'')}
${meterScaleMarkup()}
${faderScaleMarkup()}
+
${safeText(ch.name)}${safeText(ch.icon)}
+ `} +function renderMixer(){ + const x=$('mixer'),scroll=x.scrollLeft; + x.innerHTML=channels.map(makeStrip).join('')+'
'; + renderMaster();x.scrollLeft=scroll;createSide(); +} +let masterGain=-.1,masterPan=0,masterMute=false,masterMono=false,phones=-12,masterInserts=['Studio EQ','Brickwall Limiter'],masterBypassed={},pendingMasterSlot=null; +function masterFxRows(){ + const slots=masterInserts.slice(0,6);while(slots.length<6)slots.push(''); + return slots.map((name,i)=>`
+ + ${name?``:''}
`).join(''); +} +// Independent physically calibrated rulers, not seven flex-spaced labels. +// Fader endpoints are the center stripe of the 36x77px PNG, y=38. +const FADER_DB_TICKS=[10,5,0,-5,-10,-15,-20,-25,-30,-35,-40,-45,-50,-55,-60]; +const METER_DBFS_TICKS=[0,-6,-12,-18,-24,-36,-48,-60]; +const FADER_MAJOR_DB=new Set([10,0,-10,-20,-30,-40,-50,-60]); +const faderScaleMarkup=()=>`
${FADER_DB_TICKS.map(db=>`
${FADER_MAJOR_DB.has(db)?`${db>0?'+'+db:db}`:''}
`).join('')}
`; +const meterScaleMarkup=()=>`
${METER_DBFS_TICKS.map(db=>`
${db}
`).join('')}
`; +// Native peak telemetry is mapped from -60..0 dBFS to 0..100% in web/bridge.js. +const meterPercentToDbfs=p=>clamp(p,0,100)*.6-60; +function meterUnit(key,label){return `
`} +function renderMaster(){ + const host=$('masterLeft');if(!host)return; + host.innerHTML=`
MASTER
+
${masterFxRows()}
+
+
+
LUFS—
+
dBTP—
+
+
+
+
+
${panText(masterPan)}
+
+
+
STEREO MAIN L / R
+
+
+ + +
+
${fmt(masterGain)}
+
+
+
${meterUnit('masterL','L')}${meterUnit('masterR','R')}
+ ${meterScaleMarkup()} +
+
+
+
+ ${faderScaleMarkup()} +
+
MASTER
`; + syncClipLeds(); +} +function setMasterMono(value,emit=true){ + masterMono=!!value; + const button=$('masterMode');if(button){ + button.textContent=masterMono?'MONO':'STEREO'; + button.classList.toggle('is-mono',masterMono); + button.classList.toggle('is-stereo',!masterMono); + button.setAttribute('aria-pressed',String(masterMono)); + button.setAttribute('aria-label','Master output mode: '+(masterMono?'Mono':'Stereo')); + } + if(emit){send('masterMono',masterMono,-1);persistSession()} +} +function setView(next){ + if(next!=='MIX'&&next!=='FX RACK'&&next!=='SIGNAL FLOW')return; + view=next; + document.querySelectorAll('[data-view]').forEach(btn=>btn.classList.toggle('selected',btn.dataset.view===next)); + $('mixer').classList.toggle('hidden',next!=='MIX'); + $('rackWorkspace').classList.toggle('hidden',!['FX RACK','SIGNAL FLOW'].includes(next)); + if(next==='FX RACK')renderRackWorkspace(); + if(next==='SIGNAL FLOW')renderSignalFlow(); +} +function updateFader(idx,value){if(idx==='master'){masterGain=clamp(value,-60,10);const host=document.querySelector('[data-fader="master"]');host.querySelector('.cap').style.setProperty('--pos',levelToTop(masterGain)+'%');host.setAttribute('aria-valuenow',masterGain.toFixed(1));$('masterLeft').querySelectorAll('.master-db').forEach(e=>e.textContent=fmt(masterGain));send('masterGain',masterGain,-1);return}const ch=channels[+idx];ch.fader=clamp(value,-60,10);const el=document.querySelector(`[data-fader="${idx}"]`);if(el){el.querySelector('.cap').style.setProperty('--pos',levelToTop(ch.fader)+'%');el.setAttribute('aria-valuenow',ch.fader.toFixed(1));document.querySelector(`[data-read="${idx}"]`).textContent=fmt(ch.fader)}send('faderDb',ch.fader,+idx)} +function updatePan(idx,value,pointer=false){ + const master=idx==='master'; + const actual=master?masterPan:channels[idx].pan; + // A tactile 10% center detent, with 3% release hysteresis during a drag. + const oldCenter=actual===0; + const threshold=pointer?(oldCenter?13:10):0; + const next=Math.round(clamp(pointer&&Math.abs(value)<=threshold?0:value,-100,100)); + if(master)masterPan=next;else channels[idx].pan=next; + const c={pan:next}; + const el=document.querySelector(`[data-pan="${idx}"]`); + if(el){el.classList.toggle('is-centered',c.pan===0);el.style.setProperty('--pan-frac',(c.pan+100)/200);el.style.setProperty('--pan-left',Math.min(.5,(c.pan+100)/200));el.style.setProperty('--pan-span',Math.abs(c.pan)/200);el.setAttribute('aria-valuenow',String(c.pan));el.setAttribute('aria-valuetext',panText(c.pan))} + const display=document.querySelector(`[data-pan-read="${idx}"]`); + if(display)display.textContent=panText(c.pan); + send(master?'masterPan':'pan',c.pan,master?-1:idx); +} +function updateKnob(el,value){let idx=+el.dataset.ch,param=el.dataset.knob; + if(param==='phones'){phones=clamp(value,-60,10);el.style.setProperty('--angle',phones/24*130+'deg');const rd=document.querySelector('[data-phones-read]');if(rd)rd.textContent=fmt(phones);send('phonesDb',phones,-1);return} + const c=channels[idx];if(param==='pan'){updatePan(idx,value)}else{c.trim=+clamp(value,-24,24).toFixed(1);el.style.setProperty('--angle',c.trim/24*130+'deg');document.querySelector(`[data-trim-read="${idx}"]`).textContent=fmt(c.trim);send('trimDb',c.trim,idx)}} +function focusChannel(i){ + if(i<0||i>=channels.length||(i===currentChannel&&!masterSelected))return; + masterSelected=false;currentChannel=i; + document.querySelectorAll('.strip').forEach(strip=>strip.classList.toggle('selected',strip.dataset.strip!==undefined&&+strip.dataset.strip===i)); + document.querySelectorAll('#channelList [data-choose]').forEach(row=>row.classList.toggle('selected',+row.dataset.choose===i)); +} +function focusMaster(){ + if(masterSelected)return; + masterSelected=true; + document.querySelectorAll('.strip').forEach(strip=>strip.classList.toggle('selected',strip.id==='masterLeft')); + document.querySelectorAll('#channelList [data-choose]').forEach(row=>row.classList.remove('selected')); +} +function chooseChannel(i){if(i<0||i>=channels.length){flash('Additional bank channels are not populated in this UI study');return}currentChannel=i;renderMixer();if(view==='FX RACK')renderRackWorkspace()} +function toggleState(i,key){channels[i][key]=!channels[i][key];const btn=document.querySelector(`[data-${key}="${i}"]`);if(btn){btn.classList.toggle('active',channels[i][key]);btn.setAttribute('aria-pressed',String(channels[i][key]))}send(key,channels[i][key],i)} +document.addEventListener('click',e=>{const b=e.target.closest('button,[data-choose],[data-scene],[data-group]'); + const icon=e.target.closest('[data-icon-choice]'),color=e.target.closest('[data-color-choice]'); + if(icon){editingIcon=icon.dataset.iconChoice;document.querySelectorAll('[data-icon-choice]').forEach(n=>{n.classList.toggle('selected',n===icon);n.setAttribute('aria-pressed',String(n===icon))});return} + if(color){editingColor=color.dataset.colorChoice;document.querySelectorAll('[data-color-choice]').forEach(n=>{n.classList.toggle('selected',n===color);n.setAttribute('aria-pressed',String(n===color))});return} + if(!b){const strip=e.target.closest('[data-strip]');if(strip&&view==='MIX')focusChannel(+strip.dataset.strip);else if(e.target.closest('#masterLeft')&&view==='MIX')focusMaster();return;} + const originStrip=b.closest('[data-strip]'); + if(originStrip&&view==='MIX')focusChannel(+originStrip.dataset.strip);else if(b.closest('#masterLeft')&&view==='MIX')focusMaster(); + if(b.dataset.view){setView(b.dataset.view);return} + if(b.dataset.nativeAction==='audioSetup'){flash('Audio Setup is available in the Windows desktop app');return} + if(b.dataset.pluginManager!==undefined){flash('Plugin Manager is available in the Windows desktop app');return} + if(b.dataset.mySounds!==undefined){flash('Native VST3 presets are available in the Windows desktop app');return} + if(b.dataset.choose!==undefined){chooseChannel(+b.dataset.choose);return} + if(b.dataset.mute!==undefined){toggleState(+b.dataset.mute,'mute');return}if(b.dataset.solo!==undefined){toggleState(+b.dataset.solo,'solo');return} + if(b.dataset.pre!==undefined){let i=+b.dataset.pre;channels[i].pre=!channels[i].pre;b.classList.toggle('active');send('phase',channels[i].pre,i);return} + if(b.dataset.hpf!==undefined){let i=+b.dataset.hpf;channels[i].hpf=!channels[i].hpf;b.classList.toggle('active');send('hpf',channels[i].hpf,i);return} + if(b.dataset.masterInsert!==undefined){pendingMasterSlot=+b.dataset.masterInsert;openPluginBrowser(currentChannel,true);return} + if(b.dataset.masterPower!==undefined){const slot=+b.dataset.masterPower;masterBypassed[slot]=!masterBypassed[slot];renderMaster();persistSession();send('masterFxBypass',{slot,bypass:masterBypassed[slot]},-1);return} + if(b.dataset.clip!==undefined){resetClip(b.dataset.clip);return} + if(b.dataset.fxpower!==undefined){const [i,j]=b.dataset.fxpower.split(':').map(Number);setFxBypass(i,j,!bypassed[fxKey(i,j)]);return} + if(b.dataset.insert){let [i,j]=b.dataset.insert.split(':').map(Number);currentChannel=i;pendingSlot=j;openPluginBrowser(i);return} + if(b.dataset.deleteScene!==undefined){deleteMixerSnapshot(b.dataset.deleteScene);return} + if(b.dataset.scene!==undefined){loadSnapshotByIndex(+b.dataset.scene);return} + if(b.dataset.preset){applyQuickPreset(b.dataset.preset);return} + if(b.dataset.addplugin!==undefined){pendingSlot=channels[currentChannel].inserts.length;openPluginBrowser(currentChannel);return} + if(b.dataset.chainmove){movePlugin(+b.dataset.index,+b.dataset.chainmove);return} + if(b.dataset.chainremove!==undefined){removePlugin(+b.dataset.chainremove);return} + if(b.dataset.chainbypass!==undefined){toggleBypass(+b.dataset.chainbypass);return} + if(b.dataset.chainedit!==undefined){pluginEditorIndex=+b.dataset.chainedit;renderRackWorkspace();return} + if(b.dataset.chanselect!==undefined){chooseChannel(+b.dataset.chanselect);renderRackWorkspace();return} + if(b.dataset.pluginname){insertPlugin(b.dataset.pluginname);return} + if(b.dataset.category){activeCategory=b.dataset.category;renderPluginBrowser();return} + if(b.dataset.group!==undefined){flash('Group selection — interface placeholder');return} + if(b.dataset.side){document.querySelectorAll('[data-side]').forEach(x=>x.classList.toggle('selected',x===b));if(b.dataset.side==='fx')setView('FX RACK');else setView('MIX');return} + switch(b.id){case'identityCancel':closeChannelIdentity();break;case'identitySave':commitChannelIdentity();break;case'masterMute':masterMute=!masterMute;b.textContent='MUTE';b.classList.toggle('active',masterMute);b.setAttribute('aria-pressed',String(masterMute));send('masterMute',masterMute,-1);break;case'masterMode':setMasterMono(!masterMono);break;case'addScene':saveMixerSnapshot();break;case'saveFxPreset':saveFxChainPreset();break;case'menuScene':exportSession();break;case'closeBrowser':closePluginBrowser();break;case'closeFxInspector':pluginEditorIndex=null;renderRackWorkspace();break;case'chooseFxFile':importSession();break;case'flowRoutingButton':case'flowRoutingButtonSecondary':if(typeof window.__arMixOpenRoutingLab==="function")window.__arMixOpenRoutingLab();else flash("Routing editor is available in the native desktop app");break;case'arSignalOpen':if(!window.__JUCE__?.backend?.emitEvent)flash('Signal Check is available in the Windows desktop app');break;default:if(b.id)flash('UI study: '+b.textContent.trim().slice(0,28));} +}); +// Deliberate double-click to edit a strip. Single-click only changes selection. +document.addEventListener('dblclick',e=>{const el=e.target.closest('[data-editstrip]');if(!el)return; + const i=Number(el.dataset.editstrip);if(!Number.isInteger(i)||i<0||i>=channels.length)return; + e.preventDefault();e.stopPropagation();openChannelIdentity(i); +},true); +document.addEventListener('dblclick',e=>{const pan=e.target.closest('[data-pan]');if(pan){e.preventDefault();e.stopPropagation();updatePan(pan.dataset.pan==='master'?'master':+pan.dataset.pan,0)}},true); +// DAW-like insert move in standalone preview: ghost and insertion line during +// pointer travel; one final chain transaction at drop. Native host owns its +// own verified DSP reorder and this preview path never sends native edits. +let fxGesture=null,fxSuppressClick=false; +function clearFxGesture(){ + const d=fxGesture;if(!d)return; + d.marker?.classList.remove('fx-drop-before','fx-drop-after'); + d.source?.classList.remove('fx-drag-source');d.ghost?.remove(); + document.removeEventListener('pointermove',moveFxGesture); + fxGesture=null; +} +document.addEventListener('pointerdown',e=>{ + if(window.__JUCE__?.backend?.emitEvent||e.button!==0||fxGesture)return; + const button=e.target.closest('#mixer .rack .insert:not(.empty)'); + if(!button)return; + const strip=button.closest('[data-strip]'),rack=button.closest('.rack'); + if(!strip||!rack)return; + const channel=Number(strip.dataset.strip),from=Number(button.dataset.insert?.split(':')[1]); + const count=normalChain(channels[channel]).length; + if(!Number.isInteger(from)||from>=count||count<2)return; + const slots=[...rack.querySelectorAll('.insert-slot')]; + fxGesture={pointerId:e.pointerId,source:button.closest('.insert-slot'),channel,from,count, + startX:e.clientX,startY:e.clientY,x:e.clientX,y:e.clientY, + bounds:slots.map(slot=>({slot,rect:slot.getBoundingClientRect()})), + insertion:from,active:false,ghost:null,marker:null}; + document.addEventListener('pointermove',moveFxGesture,{passive:false}); +},true); +const moveFxGesture=e=>{ + const d=fxGesture;if(!d||e.pointerId!==d.pointerId)return; + d.x=e.clientX;d.y=e.clientY; + if(!d.active){ + if(Math.hypot(d.x-d.startX,d.y-d.startY)<7)return; + d.active=true;d.source.classList.add('fx-drag-source'); + d.ghost=document.createElement('div');d.ghost.className='fx-drag-ghost'; + d.ghost.textContent=d.source.querySelector('.insert-name')?.textContent||'FX'; + document.body.appendChild(d.ghost); + } + e.preventDefault(); + d.ghost.style.transform='translate3d('+(d.x+12)+'px,'+(d.y+10)+'px,0)'; + d.marker?.classList.remove('fx-drop-before','fx-drop-after');d.marker=null; + const bounds=d.bounds; + const inside=bounds.length&&d.x>=bounds[0].rect.left-15&&d.x<=bounds[0].rect.right+15 + &&d.y>=bounds[0].rect.top-8&&d.y<=bounds[bounds.length-1].rect.bottom+8; + if(!inside){d.insertion=-1;return} + let insertion=d.count; + for(let i=0;i{ + const d=fxGesture;if(!d||e.pointerId!==d.pointerId)return; + const active=d.active,from=d.from,at=d.insertion,ch=d.channel; + clearFxGesture(); + if(active){fxSuppressClick=true;setTimeout(()=>fxSuppressClick=false,0); + if(at>=0)movePluginTo(ch,from,Math.max(0,Math.min(d.count-1,at>from?at-1:at)));} +},true); +document.addEventListener('pointercancel',e=>{ + if(fxGesture?.pointerId===e.pointerId)clearFxGesture(); +},true); +document.addEventListener('keydown',e=>{ + if(e.key==='Escape'&&fxGesture){clearFxGesture();fxSuppressClick=true;setTimeout(()=>fxSuppressClick=false,0);} +},true); +document.addEventListener('click',e=>{ + if(fxSuppressClick&&!window.__JUCE__?.backend?.emitEvent){fxSuppressClick=false;e.preventDefault();e.stopImmediatePropagation()} +},true); + +// Double-click a fader for 0 dB unity gain, without changing workspace. +document.addEventListener('dblclick',e=>{const f=e.target.closest('[data-fader]');if(!f)return;e.preventDefault();e.stopPropagation();updateFader(f.dataset.fader,0)},true); +// Idle pointer movement has no handler. Acquire geometry only once per drag +// rather than forcing a layout read on every input event. +let drag=null; +function moveDraggedControl(e){ + const d=drag; + if(!d||d.pointerId!==e.pointerId)return; + if(d.type==='fader'){ + updateFader(d.index,d.startDb+(d.startY-e.clientY)*70/d.distance); + }else if(d.type==='pan'){ + updatePan(d.index,d.fromThumb?d.startPan+(e.clientX-d.startX)*200/d.travel: + ((e.clientX-d.left-9)/d.travel)*200-100,true); + }else if(d.type==='knob'){ + updateKnob(d.el,d.original+(d.initial-e.clientY)*.35); + } +} +document.addEventListener('pointerdown',e=>{ + if(drag)return; + const f=e.target.closest('[data-fader]'),p=e.target.closest('[data-pan]'),k=e.target.closest('[data-knob]'); + if(!f&&!p&&!k)return; + const el=f||p||k,strip=e.target.closest('[data-strip]'); + if(strip&&view==='MIX')focusChannel(+strip.dataset.strip); + else if(e.target.closest('#masterLeft')&&view==='MIX')focusMaster(); + if(f){ + const idx=f.dataset.fader,r=f.getBoundingClientRect(); + drag={type:'fader',el:f,pointerId:e.pointerId,index:idx, + startY:e.clientY,distance:Math.max(24,r.height-77), + startDb:idx==='master'?masterGain:channels[+idx].fader}; + // Relative drag: clicking track never teleports the fader. + }else if(p){ + const index=p.dataset.pan==='master'?'master':+p.dataset.pan, + fromThumb=!!e.target.closest('.pan-thumb'),r=p.getBoundingClientRect(), + travel=Math.max(1,r.width-18); + drag={type:'pan',el:p,pointerId:e.pointerId,index,fromThumb, + startX:e.clientX,startPan:index==='master'?masterPan:channels[index].pan, + travel,left:r.left}; + if(!fromThumb)updatePan(index,((e.clientX-r.left-9)/travel)*200-100,true); + }else{ + drag={type:'knob',el:k,pointerId:e.pointerId,initial:e.clientY, + original:k.dataset.knob==='phones'?phones:channels[+k.dataset.ch][k.dataset.knob]}; + } + if(drag.type==='fader'||drag.type==='pan')el.classList.add('is-dragging'); + document.addEventListener('pointermove',moveDraggedControl,{passive:true}); + if(el.setPointerCapture)el.setPointerCapture(e.pointerId); + e.preventDefault(); +}); +for(const type of ['pointerup','pointercancel'])document.addEventListener(type,e=>{ + if(!drag||e.pointerId!==drag.pointerId)return; + document.removeEventListener('pointermove',moveDraggedControl); + drag.el.classList.remove('is-dragging'); + drag=null; + flushUiParams(); +}); +document.addEventListener('wheel',e=>{const pan=e.target.closest('[data-pan]');if(pan){e.preventDefault();const idx=pan.dataset.pan==='master'?'master':+pan.dataset.pan;updatePan(idx,(idx==='master'?masterPan:channels[idx].pan)-Math.sign(e.deltaY)*2);return} + const k=e.target.closest('[data-knob]');if(!k)return;e.preventDefault();const p=k.dataset.knob,i=+k.dataset.ch,v=p==='phones'?phones:channels[i][p];updateKnob(k,v-Math.sign(e.deltaY)*.5)},{passive:false}); +document.addEventListener('keydown',e=>{const pan=e.target.closest('[data-pan]');if(pan){const k=e.key,idx=pan.dataset.pan==='master'?'master':+pan.dataset.pan; + if(!['ArrowLeft','ArrowRight','PageUp','PageDown','Home','End'].includes(k))return; + e.preventDefault();const value=idx==='master'?masterPan:channels[idx].pan,step=e.shiftKey?10:1; + updatePan(idx,k==='Home'?0:k==='End'?100:k==='PageUp'?value+10:k==='PageDown'?value-10:value+(k==='ArrowRight'?step:-step));return} + const f=e.target.closest('[data-fader]');if(!f)return; + const steps={ArrowUp:.5,ArrowDown:-.5,PageUp:5,PageDown:-5}; + if(!(e.key in steps)&&e.key!=='Home'&&e.key!=='End')return; + e.preventDefault();const idx=f.dataset.fader,db=idx==='master'?masterGain:channels[+idx].fader; + updateFader(idx,e.key==='Home'?-60:e.key==='End'?10:db+steps[e.key]); +}); +document.addEventListener('keydown',e=>{if(e.ctrlKey&&e.key.toLowerCase()==='s'){e.preventDefault();if(persistSession())flash('UI state saved locally');else flash('Browser storage unavailable')}}); +// Issue #56: no pointer profiler/event listener runs in normal preview or native. +const mixperfParam=new URLSearchParams(location.search).get('mixperf'); +const mixperfModes=['optimized','baseline','hover-off','meters-off','layers-off','all-off','meter-raw']; +const mixperfMode=mixperfModes.includes(mixperfParam)?mixperfParam:'optimized'; +document.documentElement.dataset.mixperf=mixperfMode; +if(mixperfParam&&mixperfModes.includes(mixperfParam)){ + window.__arMixPerfProbe={mode:mixperfMode,run(durationMs=10000){ + const ms=Math.max(1000,Math.min(20000,Number(durationMs)||10000)); + const buckets={mixer:[],outside:[]},moves={mixer:0,outside:0}; + let area='',pointerAt=-Infinity,lastFrame=0,frameId=0,observer=null,longTasks=0,longTaskMs=0; + // Long Task entries are browser-dependent. Unavailable must never read as zero. + let longTaskAvailable=false; + function pointer(e){area=e.target.closest?.('#mixer')?'mixer':'outside';pointerAt=performance.now();moves[area]++} + function visibility(){lastFrame=0;pointerAt=-Infinity} + function frame(t){ + if(lastFrame&&!document.hidden&&t-pointerAt<350&&t-lastFrame>0)buckets[area].push(t-lastFrame); + lastFrame=t;frameId=requestAnimationFrame(frame); + } + function stats(a){const s=a.slice().sort((x,y)=>x-y),n=s.length; + const over33=s.filter(x=>x>33.3).length,over50=s.filter(x=>x>50).length; + return {samples:n,medianMs:n?+s[Math.floor((n-1)*.5)].toFixed(2):null, + p95Ms:n?+s[Math.ceil(n*.95)-1].toFixed(2):null, + p99Ms:n?+s[Math.ceil(n*.99)-1].toFixed(2):null,maxMs:n?+s[n-1].toFixed(2):null, + over33Ms:over33,over50Ms:over50,over33Pct:n?+(over33*100/n).toFixed(2):null}; + } + document.addEventListener('pointermove',pointer,{passive:true}); + document.addEventListener('visibilitychange',visibility); + if(typeof PerformanceObserver==='function' && + PerformanceObserver.supportedEntryTypes?.includes('longtask'))try{ + observer=new PerformanceObserver(l=>{ + for(const e of l.getEntries()){longTasks++;longTaskMs+=e.duration} + });observer.observe({entryTypes:['longtask']});longTaskAvailable=true; + }catch{observer?.disconnect();observer=null} + frameId=requestAnimationFrame(frame); + return new Promise(done=>setTimeout(()=>{ + cancelAnimationFrame(frameId);document.removeEventListener('pointermove',pointer); + document.removeEventListener('visibilitychange',visibility);observer?.disconnect(); + done({mode:mixperfMode,durationMs:ms,environment:{userAgent:navigator.userAgent,dpr:devicePixelRatio, + width:innerWidth,height:innerHeight,iframe:top!==self},mixer:stats(buckets.mixer), + outside:stats(buckets.outside),pointerMoves:moves,longTaskAvailable, + longTasks:longTaskAvailable?longTasks:null, + longTaskMs:longTaskAvailable?+longTaskMs.toFixed(1):null, + note:'rAF proxy, not measured GPU paint/input latency; unsupported longtask is null'}); + },ms)); + }}; +} +// Browser-only meter scheduler: do not enqueue a 60/120/144Hz rAF just to +// reject 3/4 of its callbacks. Timer wakes shortly before the next visual tick; +// a single rAF aligns the paint with the browser. Native JUCE owns live metering. +const browserMeterStats={ticks:0,skipped:0,slowWakeups:0,intervalMs:40}; +let meterTimer=0,meterRAF=0,meterExpected=0,meterLate=0,meterHealthy=0; +function scheduleDemoMeter(){ + if(window.__JUCE__?.backend?.emitEvent||document.hidden|| + mixperfMode==='meters-off'||mixperfMode==='all-off')return; + const interval=browserMeterStats.intervalMs; + meterExpected=performance.now()+interval; + meterTimer=setTimeout(()=>{ + meterTimer=0; + const late=Math.max(0,performance.now()-meterExpected); + if(late>25){ + browserMeterStats.slowWakeups++; + meterLate++;meterHealthy=0; + if(meterLate>=3){browserMeterStats.intervalMs=60;meterLate=0} + }else{ + meterHealthy++;meterLate=0; + if(meterHealthy>=30){browserMeterStats.intervalMs=40;meterHealthy=0} + } + if(document.hidden){browserMeterStats.skipped++;return} + meterRAF=requestAnimationFrame(t=>{meterRAF=0;meters(t)}); + },interval); +} +function meters(t){ + // JUCE desktop reads actual audio meters; browser demo only animates a preview. + if(window.__JUCE__?.backend?.emitEvent||document.hidden|| + mixperfMode==='meters-off'||mixperfMode==='all-off')return; + browserMeterStats.ticks++; + scheduleDemoMeter(); + channels.forEach((ch,i)=>{const wave=(Math.sin(t*.0022+i*1.92)+Math.sin(t*.0043+i*.6))*.5; + const v=clamp(45+wave*24+ch.fader*.48,4,98); + if(ch.stereo){ // Browser-only preview: independent L/R motion; no invented native telemetry. + const delta=Math.sin(t*.0027+i*1.3)*7; + updateMeterVisual(String(i)+'L',ch.mute?2:clamp(v+delta,2,98),t); + updateMeterVisual(String(i)+'R',ch.mute?2:clamp(v-delta*.7+Math.sin(t*.004+i)*3,2,98),t); + }else updateMeterVisual(String(i),ch.mute?2:v,t)}); + const base=clamp(67+Math.sin(t*.002)*15,8,95); + const l=clamp(base+Math.sin(t*.003)*6,3,99),r=clamp(base-5+Math.sin(t*.003+1)*7,3,99); + updateMeterVisual('masterL',masterMute?2:l,t);updateMeterVisual('masterR',masterMute?2:r,t); + // UI preview only. No native BS.1770 or oversampled true peak is calculated. + updateMasterAnalysisPreview(-31+(l+r)/11,-18+Math.max(l,r)/7); +} +// Threshold color policy for browser-only preview, no additional timer. +function updateMasterAnalysisPreview(lufs,dbtp){ + for(const [id,value,limit] of [['masterLufs',lufs,-12],['masterDbtp',dbtp,-1]]){ + const el=$(id);if(!el)continue; + const valid=Number.isFinite(value),next=valid?value.toFixed(1):'—'; + if(el.textContent!==next)el.textContent=next; + el.classList.toggle('over-limit',valid&&value>limit); + el.setAttribute('aria-label',valid?('Simulated '+id+' '+next):(id+' unavailable')); + } +} +// v0.3: demo-only FX catalog. Items represent mock plugins, not installed VST3 binaries. +const pluginCatalog=[ + {name:'Studio EQ',type:'EQ',badge:'EQ',hint:'Four-band tonal shaping'}, + {name:'Dynamic EQ',type:'EQ',badge:'D',hint:'Adaptive tonal control'}, + {name:'Vocal Compressor',type:'Dynamics',badge:'C',hint:'Smooth vocal dynamics'}, + {name:'Noise Gate',type:'Dynamics',badge:'G',hint:'Reduce background noise'}, + {name:'De-Esser',type:'Dynamics',badge:'S',hint:'Sibilance control'}, + {name:'Brickwall Limiter',type:'Dynamics',badge:'L',hint:'Prevent excessive peaks'}, + {name:'Studio Reverb',type:'Space',badge:'R',hint:'Natural vocal ambience'}, + {name:'Tempo Delay',type:'Space',badge:'D',hint:'Synced echo'}, + {name:'Stereo Chorus',type:'Creative',badge:'CH',hint:'Gentle stereo width'}, + {name:'Saturator',type:'Creative',badge:'SAT',hint:'Analog-style harmonic color'} +]; +let pendingSlot=-1, activeCategory='All', userSnapshots={},savedChains={},bypassed={},fxParams={},pluginEditorIndex=null; +const initialFactoryChannels=channels.map(c=>({...c,inserts:[...c.inserts]})); +const safeText=s=>String(s).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); +function normalChain(ch){return ch.inserts.filter(Boolean)} +function fxKey(ch,slot){return `${ch}:${slot}`} +function getFxParams(ch,slot){const k=fxKey(ch,slot);return fxParams[k]??(fxParams[k]={mix:60,amount:45,output:0})} +function moveFxMeta(ch,from,to){const a=fxKey(ch,from),b=fxKey(ch,to),tmp=fxParams[a];fxParams[a]=fxParams[b];fxParams[b]=tmp;const bo=bypassed[a];bypassed[a]=bypassed[b];bypassed[b]=bo} +function shiftFxMetaRight(ch,at,len){for(let i=len;i>at;i--){fxParams[fxKey(ch,i)]=fxParams[fxKey(ch,i-1)];bypassed[fxKey(ch,i)]=bypassed[fxKey(ch,i-1)]}delete fxParams[fxKey(ch,at)];delete bypassed[fxKey(ch,at)]} +function shiftFxMetaLeft(ch,at,len){for(let i=at;i``).join('')} +function renderRackWorkspace(){let c=channels[currentChannel];let chain=normalChain(c);$('rackWorkspace').innerHTML=`
YOUR SOUND · CORE WORKFLOW

FX Rack — ${safeText(c.name)}

Build your signature vocal sound. Add, reorder, bypass, and store your VST chain.

● AUDIO INPUT · ${safeText(c.name)}
↓
${chain.map((name,i)=>`
${String(i+1).padStart(2,'0')}${safeText(name)}${safeText(pluginCatalog.find(p=>p.name===name)?.hint||'VST3 plugin · mock chain state')}
↓
`).join('')}
↓
◎ OUTPUT · MASTER / STREAM
${pluginEditorIndex!==null&&pluginEditorIndex

Ready-to-use Sound

Start with a preset, then personalize your FX chain. No complex routing required.

${['Clean Vocal','Warm Karaoke','Live Broadcast'].map(s=>``).join('')}

Make it sound better

Recommended signal path:

Noise Gate → EQ → Compressor → De-Esser → Reverb

Demo status

Plugin names and bypass buttons currently change visual state only. Installed VST3 scanning and DSP are scheduled for the native engine phase.

`}`} +function pluginInspector(ch,slot){const name=normalChain(channels[ch])[slot],v=getFxParams(ch,slot);return `
FX EDITOR · DEMO PARAMETERS

${safeText(name)}

These generic controls demonstrate the editing and preset workflow. The real VST3 editor will replace them when connected.

`} +function renderSignalFlow(){ + if(window.__JUCE__?.backend?.emitEvent){ + $('rackWorkspace').innerHTML=`
ARSONMIX · NATIVE ROUTING

Signal Flow — 10 Native Channels

Physical inputs → native VST3 → PRE/POST sends → BUS returns → MASTER. All routing changes use the same live engine and hardware epoch.

01 · DEVICEVerified ASIO/WASAPIActual enabled port mask
➜
02 · CHANNELS10 Native StripsIndependent VST3 + live controls
➜
03 · BUSPRE/POST SendsCycle-validated internal returns
➜
04 · MASTERHardware L / RDirect authorized endpoint
Routing edits still require OUTPUT MUTE. Unchanged VST3 instances now retain state and tails when a route is re-applied. CUE/AUX hardware output patching and plugin latency compensation remain future gates.
`; + return; + } + $('rackWorkspace').innerHTML=`
NO TECHNICAL PATCHBAY REQUIRED

Signal Flow — See where your voice goes

A beginner-first view of the real-time audio path. Select your audio device in Setup.

01 · INPUTMicrophoneAudio Interface
ASIO or WASAPI
➜
02 · FX CHAINVST3 PluginsEQ · Dynamics
Reverb · Delay
➜
03 · MIXERMix & MonitorFader · Pan
Master · Meters
➜
04 · OUTPUTSpeakers / StreamAudio Device
Streaming bridge later
⚠ In this trial the audio flow is a visual concept; no microphone is captured and no audio is sent to a livestream.
`} +function openPluginBrowser(idx,isMaster=false){if(!isMaster){currentChannel=idx;pendingMasterSlot=null}activeCategory='All';$('pluginModal').classList.remove('hidden');$('pluginTarget').textContent=isMaster?'Adding to MASTER bus · demo FX catalog':'Adding to '+channels[idx].name+' · virtual effects catalog';$('pluginSearch').value='';renderPluginBrowser();$('pluginSearch').focus()} +function closePluginBrowser(){$('pluginModal').classList.add('hidden')} +function renderPluginBrowser(){document.querySelectorAll('[data-category]').forEach(b=>b.classList.toggle('active',b.dataset.category===activeCategory));const q=$('pluginSearch').value.trim().toLowerCase();let pool=pluginCatalog.filter(p=>(activeCategory==='All'||p.type===activeCategory)&&`${p.name} ${p.type} ${p.hint}`.toLowerCase().includes(q));$('pluginResults').innerHTML=pool.map(p=>``).join('')||'

No matching demo effects.

'} +function insertPlugin(name){ + if(pendingMasterSlot!==null){ + const slot=pendingMasterSlot; + if(slot>=6)return; + masterInserts[slot]=name;delete masterBypassed[slot];pendingMasterSlot=null; + closePluginBrowser();renderMaster();persistSession(); + send('masterChainChanged',{chain:[...masterInserts]},-1); + flash('Master FX updated (GUI preview)');return; + } + const c=channels[currentChannel];const chain=normalChain(c);if(chain.length>=8){flash('Maximum 8 FX slots in this UI trial');return}const index=clamp(pendingSlot,0,chain.length);shiftFxMetaRight(currentChannel,index,chain.length);chain.splice(index,0,name);pluginEditorIndex=index;setChain(c,chain);closePluginBrowser();flash(name+' added to preview chain');send('chainChanged',{chain},currentChannel)} +function movePluginTo(channel,from,to){ + const c=channels[channel],chain=normalChain(c); + if(from<0||to<0||from>=chain.length||to>=chain.length||from===to)return false; + const [fx]=chain.splice(from,1);chain.splice(to,0,fx); + // Preserve each insert's bypass and editor settings, rather than swapping labels. + for(let i=from;i!==to;i+=to>from?1:-1)moveFxMeta(channel,i,i+(to>from?1:-1)); + if(channel===currentChannel)pluginEditorIndex=to; + setChain(c,chain);persistSession(); + send('chainChanged',{chain},channel);return true; +} +function movePlugin(idx,dir){movePluginTo(currentChannel,idx,idx+dir)} +function removePlugin(idx){const c=channels[currentChannel],ch=normalChain(c);shiftFxMetaLeft(currentChannel,idx,ch.length);ch.splice(idx,1);pluginEditorIndex=null;setChain(c,ch);send('chainChanged',{chain:ch},currentChannel)} +function setFxBypass(ch,slot,disabled){ + const chain=normalChain(channels[ch]); + if(!chain[slot])return; + const k=fxKey(ch,slot); + bypassed[k]=!!disabled; + const power=document.querySelector(`[data-fxpower="${k}"]`); + const cell=power?.closest('.insert-slot'); + if(cell)cell.classList.toggle('is-bypassed',disabled); + if(power){ + power.classList.toggle('is-bypassed',disabled); + power.setAttribute('aria-pressed',String(!disabled)); + power.setAttribute('aria-label',(disabled?'Enable ':'Bypass ')+chain[slot]); + power.title=(disabled?'Enable ':'Bypass ')+chain[slot]; + } + if(ch===currentChannel){ + const rackButton=document.querySelector(`[data-chainbypass="${slot}"]`); + if(rackButton){ + rackButton.classList.toggle('power-on',!disabled); + rackButton.classList.toggle('is-bypassed',disabled); + rackButton.setAttribute('aria-pressed',String(!disabled)); + rackButton.setAttribute('aria-label',(disabled?'Enable ':'Bypass ')+chain[slot]); + rackButton.title=(disabled?'Enable ':'Bypass ')+chain[slot]; + rackButton.closest('.chain-node')?.classList.toggle('dimmed',disabled); + } + } + send('chainBypass',{slot,bypass:!!disabled},ch); + persistSession(); +} +function toggleBypass(idx){setFxBypass(currentChannel,idx,!bypassed[fxKey(currentChannel,idx)])} +const quickPresets={'Clean Vocal':['Noise Gate','Studio EQ','Vocal Compressor'],'Warm Karaoke':['Noise Gate','Studio EQ','Vocal Compressor','Studio Reverb'],'Live Broadcast':['Noise Gate','Dynamic EQ','De-Esser','Brickwall Limiter']}; +function applyQuickPreset(name){const c=channels[currentChannel];for(let i=0;i<8;i++){delete fxParams[fxKey(currentChannel,i)];delete bypassed[fxKey(currentChannel,i)]}pluginEditorIndex=null;setChain(c,quickPresets[name]||[]);document.querySelectorAll('[data-preset]').forEach(b=>b.classList.toggle('active',b.dataset.preset===name));flash('FX chain preset selected: '+name+' (UI only)');send('chainChanged',{chain:normalChain(c)},currentChannel)} +function durableSession(){return {schemaVersion:1,version:'0.3-ui',channels:channels.map(c=>({id:c.id,name:c.name,icon:c.icon,color:c.color,inserts:[...c.inserts],fader:c.fader,pan:c.pan,trim:c.trim,mute:c.mute,solo:c.solo,hpf:c.hpf,stereo:c.stereo})),masterGain,masterPan,masterMute,masterMono,masterInserts:[...masterInserts],masterBypassed:{...masterBypassed},sceneIdx,selected:currentChannel,fxParams:structuredClone(fxParams),bypassed:{...bypassed}};} +function persistSession(){try{localStorage.setItem('armix-v03-current',JSON.stringify(durableSession()));localStorage.setItem('armix-v03-snapshots',JSON.stringify(userSnapshots));localStorage.setItem('armix-v03-chains',JSON.stringify(savedChains));return true}catch{return false}} +function saveFxChainPreset(){const name=prompt('Name this FX chain preset:','My Vocal Chain');if(!name)return;const key=name.trim().slice(0,60);if(!key)return;savedChains[key]={schemaVersion:1,inserts:[...normalChain(channels[currentChannel])],states:normalChain(channels[currentChannel]).map((_,i)=>({...getFxParams(currentChannel,i),bypass:!!bypassed[fxKey(currentChannel,i)]}))};persistSession();flash('FX chain preset saved: '+key)} +function recallFxChain(){const keys=Object.keys(savedChains);if(!keys.length){flash('No saved FX chains yet');return}const key=prompt('Enter FX chain preset name:\n'+keys.join('\n'),keys[0]);if(!key||!savedChains[key])return;setChain(channels[currentChannel],savedChains[key].inserts);savedChains[key].states?.forEach((v,i)=>{fxParams[fxKey(currentChannel,i)]={mix:v.mix,amount:v.amount,output:v.output};bypassed[fxKey(currentChannel,i)]=!!v.bypass});pluginEditorIndex=null;renderRackWorkspace();flash('FX chain recalled: '+key)} +function saveMixerSnapshot(){ + const name=prompt('Save mixer snapshot — name:',scenes[sceneIdx]||'My Live Sound'); + if(name===null)return; + const key=name.trim().replace(/\\s+/g,' ').slice(0,60); + if(!key){flash('Enter a snapshot name');return} + if(Object.prototype.hasOwnProperty.call(userSnapshots,key)&&!confirm('Replace existing snapshot "'+key+'"?'))return; + const session=durableSession(); + const previous=userSnapshots[key]; + userSnapshots[key]={...session,savedAt:new Date().toISOString()}; + if(!scenes.includes(key))scenes.push(key); + sceneIdx=scenes.indexOf(key); + if(!persistSession()){ + if(previous===undefined)delete userSnapshots[key];else userSnapshots[key]=previous; + flash('Snapshot NOT saved: storage unavailable');return; + } + createSide();flash('Mixer snapshot saved: '+key+' (local UI state)'); +} +function deleteMixerSnapshot(name){ + if(!Object.prototype.hasOwnProperty.call(userSnapshots,name))return; + if(!confirm('Delete saved snapshot "'+name+'"?'))return; + const previous=userSnapshots[name];delete userSnapshots[name]; + if(!persistSession()){userSnapshots[name]=previous;flash('Delete failed: storage unavailable');return} + const index=scenes.indexOf(name);if(index>=4)scenes.splice(index,1); + sceneIdx=Math.min(sceneIdx,scenes.length-1);createSide();flash('Snapshot deleted: '+name); +} +function applySession(session){if(!session||session.schemaVersion!==1||!Array.isArray(session.channels)||session.channels.length=6; // Fixed 1–6 mono, 7–10 stereo across legacy snapshot migrations. + if(typeof src.name==='string'&&src.name.trim())c.name=src.name.trim().slice(0,26); + if(channelIcons.includes(src.icon))c.icon=src.icon; + if(channelPalette.includes(src.color))c.color=src.color; + for(const k of ['fader','pan','trim'])if(Number.isFinite(src[k]))c[k]=src[k];for(const k of ['mute','solo','hpf'])if(typeof src[k]==='boolean')c[k]=src[k];if(Array.isArray(src.inserts))c.inserts=src.inserts.filter(x=>typeof x==='string').slice(0,8)}masterGain=Number.isFinite(session.masterGain)?session.masterGain:-.1;masterPan=Number.isFinite(session.masterPan)?clamp(session.masterPan,-100,100):0;masterMute=!!session.masterMute;masterMono=!!session.masterMono; + send('masterMono',masterMono,-1); + if(Array.isArray(session.masterInserts))masterInserts=session.masterInserts.filter(x=>typeof x==='string').slice(0,6); + masterBypassed=(session.masterBypassed&&typeof session.masterBypassed==='object')?{...session.masterBypassed}:{}; + fxParams=(session.fxParams&&typeof session.fxParams==='object')?structuredClone(session.fxParams):{};bypassed=(session.bypassed&&typeof session.bypassed==='object')?{...session.bypassed}:{};pluginEditorIndex=null;renderMixer();renderMaster();if(view==='FX RACK')renderRackWorkspace()} +function loadSnapshotByIndex(i){if(!Number.isInteger(i)||i<0||i>=scenes.length)return;sceneIdx=i;const name=scenes[sceneIdx]; + if(userSnapshots[name])applySession(userSnapshots[name]); + else if(sceneIdx<4){const state=durableSession();state.channels=initialFactoryChannels.map(c=>({...c,inserts:[...c.inserts]}));state.masterGain=-.1; + const voicePresets=[quickPresets['Clean Vocal'],quickPresets['Warm Karaoke'],quickPresets['Live Broadcast'],quickPresets['Clean Vocal']];state.channels[0].inserts=[...voicePresets[sceneIdx]];applySession(state);flash('Factory snapshot recalled: '+name+' (UI only)')} + createSide();persistSession()} +function exportSession(){const data=JSON.stringify({...durableSession(),savedChains,userSnapshots},null,2);const blob=new Blob([data],{type:'application/json'}),url=URL.createObjectURL(blob),a=document.createElement('a');a.href=url;a.download='ar-mix-live-session.json';a.click();setTimeout(()=>URL.revokeObjectURL(url),1200);flash('Session JSON exported')} +function importSession(){const f=document.createElement('input');f.type='file';f.accept='application/json,.json';f.onchange=async()=>{const file=f.files?.[0];if(!file)return;if(file.size>2_000_000){flash('Session too large');return}try{const obj=JSON.parse(await file.text());applySession(obj);persistSession();flash('Session loaded')}catch{flash('Invalid JSON session')}};f.click()} +// Single optimized console layout. The unused PRO/EASY switch is retired. +$('app').classList.add('easy'); +$('pluginSearch').addEventListener('input',renderPluginBrowser); +document.addEventListener('input',e=>{const el=e.target;if(!el.dataset.fxparam)return;const slot=+el.dataset.slot,key=el.dataset.fxparam;if(!['mix','amount','output'].includes(key))return;const v=getFxParams(currentChannel,slot);v[key]=+el.value;const out=el.closest('label')?.querySelector('output');if(out)out.textContent=key==='output'?`${v[key]>0?'+':''}${v[key]} dB`:`${v[key]}%`;send('fxDemoParam',{slot,key,value:v[key]},currentChannel)}); +$('pluginModal').addEventListener('click',e=>{if(e.target===$('pluginModal'))closePluginBrowser()}); +$('channelIdentity').addEventListener('click',e=>{if(e.target===$('channelIdentity'))closeChannelIdentity()}); +$('identityName').addEventListener('keydown',e=>{if(e.key==='Enter'){e.preventDefault();commitChannelIdentity()}}); +document.addEventListener('keydown',e=>{if(e.key==='Escape'){closePluginBrowser();closeChannelIdentity()}if((e.key==='Enter'||e.key===' ')&&e.target.matches('[data-editstrip]')){e.preventDefault();openChannelIdentity(+e.target.dataset.editstrip)}}); +document.addEventListener('change',e=>{if(e.target.id==='rackChannel'){currentChannel=+e.target.value;renderRackWorkspace();renderMixer()}}); +document.addEventListener('click',e=>{const id=e.target.closest('button')?.id;if(id==='saveFxFromRack')saveFxChainPreset();else if(id==='recallFxPreset')recallFxChain();else if(id==='openSetupFromFlow')$('audioSetupBtn')?.click();else if(id==='flowFxButton')setView('FX RACK');else if(id==='backMixer')setView('MIX')}); +let lastPersist=0;setInterval(()=>{if(Date.now()-lastPersist<2000)return;lastPersist=Date.now();persistSession()},5000); +try{userSnapshots=JSON.parse(localStorage.getItem('armix-v03-snapshots')||'{}');savedChains=JSON.parse(localStorage.getItem('armix-v03-chains')||'{}');for(const k of Object.keys(userSnapshots))if(!scenes.includes(k))scenes.push(k)}catch{userSnapshots={};savedChains={}} + createSide();renderMixer();renderMaster();try{let last=JSON.parse(localStorage.getItem('armix-v03-current'));if(!last)last=JSON.parse(localStorage.getItem('arMixStudioUI')); if(last&&last.channels?.length>=channels.length){last.channels.slice(0,channels.length).forEach((s,i)=>{if(typeof s.name==='string'&&s.name.trim())channels[i].name=s.name.trim().slice(0,26); if(channelIcons.includes(s.icon))channels[i].icon=s.icon; if(channelPalette.includes(s.color))channels[i].color=s.color; diff --git a/web/app.js b/web/app.js index 834deeb6e..714869dd7 100644 --- a/web/app.js +++ b/web/app.js @@ -270,7 +270,7 @@ function makeStrip(ch,i){let inserts=ch.inserts.slice(0,6);while(inserts.length<
${i+1}
${inserts.map((n,j)=>`
${n?``:''}
`).join('')}
TRIM
dB
${fmt(ch.trim)}
${knobMarkup('trim',i,ch.trim,'Trim')}
${panMarkup(ch,i)}
${panText(ch.pan)}
-
${fmt(ch.fader)}
${ch.stereo?meterUnit(String(i)+'L','L')+meterUnit(String(i)+'R','R'):meterUnit(String(i),'')}
${meterScaleMarkup()}
${faderScaleMarkup()}
+
${fmt(ch.fader)}
${ch.stereo?meterUnit(String(i)+'L','L')+meterUnit(String(i)+'R','R'):meterUnit(String(i),'')}
${meterScaleMarkup()}
${faderScaleMarkup()}
${safeText(ch.name)}${safeText(ch.icon)}
`} function renderMixer(){ @@ -300,10 +300,9 @@ function renderMaster(){ host.innerHTML=`
MASTER
${masterFxRows()}
-
-
STREAM LEVELS SIM
-
LUFS-I--
-
dBTP--
+
+
LUFS—
+
dBTP—
limit); + el.setAttribute('aria-label',valid?('Simulated '+id+' '+next):(id+' unavailable')); + } } // v0.3: demo-only FX catalog. Items represent mock plugins, not installed VST3 binaries. const pluginCatalog=[ diff --git a/web/styles-src/42-mixer-premium.css b/web/styles-src/42-mixer-premium.css index 0d9a4a511..0c1835996 100644 --- a/web/styles-src/42-mixer-premium.css +++ b/web/styles-src/42-mixer-premium.css @@ -320,3 +320,45 @@ html:not([data-mixperf="baseline"]):not([data-mixperf="layers-off"]):not([data-m #app #scenesList .scene-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0} #app #scenesList .scene-delete{flex:0 0 20px;height:18px;padding:0;border:1px solid #53646d;border-radius:2px;background:#26343c;color:#d0dbdf;font-size:14px;line-height:14px} #app #scenesList .scene-delete:hover{background:#40515a} + +/* The mono meter has ONE LED slot, stereo/master TWO. Keep 7px fixed LEDs. */ +#app #mixer .fader-zone .vu-bank.is-mono{ + flex-basis:35px;width:35px;min-width:35px;max-width:35px; +} +#app #mixer .fader-zone .vu-bank.is-mono .vu-bars{ + flex-basis:14px;width:14px;min-width:14px;max-width:14px; +} +/* Same machined recessed folds as fader; no external rectangular stroke. */ +#app #mixer .fader-zone .vu-bank .vu-bars{ + position:relative;isolation:isolate;border:0;border-radius:5px;background:#24343c; + box-shadow:inset 0 4px 4px -3px #070e13,inset 0 -4px 4px -3px #070e13, + inset 4px 0 5px -4px #081116,inset -4px 0 5px -4px #081116; +} +#app #mixer .fader-zone .vu-bank .meter-unit .meter{ + border:0;border-radius:2px;background:#080f14; + box-shadow:inset 0 1px 2px #0009,inset 1px 0 2px #000c,inset -1px 0 2px #000b; +} +#app #mixer .fader-zone .vu-bank .meter-unit .meter::after{ + inset:0;background:linear-gradient(180deg,#d3eced10,transparent 35%); +} +/* LUFS / dBTP: exactly two lines in a black glass LCD. No blur/compositor. */ +#app #masterLeft .master-controls-zone .master-analysis{ + box-sizing:border-box;height:38px;min-height:38px;flex:0 0 38px; + display:flex;flex-direction:column;justify-content:center;gap:1px; + margin:0;padding:3px 6px;border:0;border-radius:4px; + background:linear-gradient(180deg,#0d1c1c,#030a0b 35%,#071313); + box-shadow:inset 0 3px 4px -2px #000,inset 2px 0 3px -2px #000, + inset -2px 0 3px -2px #000,inset 0 -1px 0 #40625c77; +} +#app #masterLeft .master-controls-zone .master-analysis .master-info-row{ + display:flex;align-items:center;justify-content:space-between; + flex:0 0 14px;height:14px;min-height:14px;margin:0; + color:#70c2a1;font:600 9px/14px Consolas,monospace; +} +#app #masterLeft .master-controls-zone .master-analysis .master-info-row strong{ + color:#58f3a0;font:700 12px/14px Consolas,monospace; + min-width:0;text-align:right;text-shadow:none; +} +#app #masterLeft .master-controls-zone .master-analysis .master-info-row strong.over-limit{ + color:#ff555f;text-shadow:none; +} diff --git a/web/styles.css b/web/styles.css index f175347e2..88ea54f2a 100644 --- a/web/styles.css +++ b/web/styles.css @@ -1295,3 +1295,45 @@ html:not([data-mixperf="baseline"]):not([data-mixperf="layers-off"]):not([data-m #app #scenesList .scene-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0} #app #scenesList .scene-delete{flex:0 0 20px;height:18px;padding:0;border:1px solid #53646d;border-radius:2px;background:#26343c;color:#d0dbdf;font-size:14px;line-height:14px} #app #scenesList .scene-delete:hover{background:#40515a} + +/* The mono meter has ONE LED slot, stereo/master TWO. Keep 7px fixed LEDs. */ +#app #mixer .fader-zone .vu-bank.is-mono{ + flex-basis:35px;width:35px;min-width:35px;max-width:35px; +} +#app #mixer .fader-zone .vu-bank.is-mono .vu-bars{ + flex-basis:14px;width:14px;min-width:14px;max-width:14px; +} +/* Same machined recessed folds as fader; no external rectangular stroke. */ +#app #mixer .fader-zone .vu-bank .vu-bars{ + position:relative;isolation:isolate;border:0;border-radius:5px;background:#24343c; + box-shadow:inset 0 4px 4px -3px #070e13,inset 0 -4px 4px -3px #070e13, + inset 4px 0 5px -4px #081116,inset -4px 0 5px -4px #081116; +} +#app #mixer .fader-zone .vu-bank .meter-unit .meter{ + border:0;border-radius:2px;background:#080f14; + box-shadow:inset 0 1px 2px #0009,inset 1px 0 2px #000c,inset -1px 0 2px #000b; +} +#app #mixer .fader-zone .vu-bank .meter-unit .meter::after{ + inset:0;background:linear-gradient(180deg,#d3eced10,transparent 35%); +} +/* LUFS / dBTP: exactly two lines in a black glass LCD. No blur/compositor. */ +#app #masterLeft .master-controls-zone .master-analysis{ + box-sizing:border-box;height:38px;min-height:38px;flex:0 0 38px; + display:flex;flex-direction:column;justify-content:center;gap:1px; + margin:0;padding:3px 6px;border:0;border-radius:4px; + background:linear-gradient(180deg,#0d1c1c,#030a0b 35%,#071313); + box-shadow:inset 0 3px 4px -2px #000,inset 2px 0 3px -2px #000, + inset -2px 0 3px -2px #000,inset 0 -1px 0 #40625c77; +} +#app #masterLeft .master-controls-zone .master-analysis .master-info-row{ + display:flex;align-items:center;justify-content:space-between; + flex:0 0 14px;height:14px;min-height:14px;margin:0; + color:#70c2a1;font:600 9px/14px Consolas,monospace; +} +#app #masterLeft .master-controls-zone .master-analysis .master-info-row strong{ + color:#58f3a0;font:700 12px/14px Consolas,monospace; + min-width:0;text-align:right;text-shadow:none; +} +#app #masterLeft .master-controls-zone .master-analysis .master-info-row strong.over-limit{ + color:#ff555f;text-shadow:none; +} From a9942512c69aac8d6d9eff31937eef4c65916fb3 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:53:01 +0700 Subject: [PATCH 02/12] P0: WebView-ready-first startup avoids synchronous device-blocked blank window --- src/Main.cpp | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/Main.cpp b/src/Main.cpp index 7174f6f59..9893e9864 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -159,7 +159,11 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr presets_ (settingsDirectory().getChildFile ("presets"), settingsDirectory()), browser_ (webViewOptions() .withNativeIntegrationEnabled() - .withEventListener ("arMixGuiReady", [this] (juce::var) { browser_.loaded = true; }) + .withEventListener ("arMixGuiReady", [this] (juce::var) + { + browser_.loaded = true; + guiReadyTick_ = juce::Time::getMillisecondCounter(); + }) .withEventListener ("arMixParameter", [this] (juce::var args) { onParameter (args); }) .withEventListener ("arMixAction", [this] (juce::var args) { onAction (args); }) .withResourceProvider (assetFor)) @@ -173,13 +177,13 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr centreWithSize (1650, 930); setVisible (true); - auto saved = juce::XmlDocument::parse (machineSettingsDirectory().getChildFile ("audio-devices.xml")); - startupError_ = engine_.start (saved.get()); - engine_.devices().addChangeListener (this); - diagnostics_.record ("STARTUP", startupError_.isEmpty() ? "Audio device initialized" : startupError_); + // Begin WebView navigation BEFORE any synchronous JUCE driver setup. + // Device startup on cold PCs otherwise blocks the very first GUI. webViewStartupTick_ = juce::Time::getMillisecondCounter(); browser_.goToURL (juce::WebBrowserComponent::getResourceProviderRoot()); startTimerHz (12); + // The existing 12Hz message-thread tick starts the audio engine after + // an authenticated GUI handshake and initial compositor paint. // Defer initial scan until explicitly requested in Plugin Manager. // Startup must not spend seconds enumerating third-party VST3 modules. } @@ -215,6 +219,8 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr bool initialStateSent_ = false; bool webViewStartupNoticeSent_ = false; juce::uint32 webViewStartupTick_ = 0; + juce::uint32 guiReadyTick_ = 0; + bool audioEngineStarted_ = false; bool setupLaunching_ = false; unsigned int timerTicks_ = 0; bool deviceSettingsDirty_ = false; @@ -1436,6 +1442,21 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr " Check the WebView2 Runtime and browser-cache folder permissions."); return; } + // First visible GUI frame must precede device discovery. Reuse the + // existing timer; never add a worker or poll the audio callback. + if (!audioEngineStarted_) + { + if (!browser_.loaded || + juce::Time::getMillisecondCounter() - guiReadyTick_ < 150u) + return; + audioEngineStarted_ = true; + auto saved = juce::XmlDocument::parse ( + machineSettingsDirectory().getChildFile ("audio-devices.xml")); + startupError_ = engine_.start (saved.get()); + engine_.devices().addChangeListener (this); + diagnostics_.record ("STARTUP", + startupError_.isEmpty() ? "Audio device initialized" : startupError_); + } // ONE actionable notice per unexpected DIRECT reroute. The audio // callback has already zero-filled output atomically; status, log and // WebView notifications belong only on this JUCE control timer. From 625a965c44cbbea1198d440522de4bb8324254aa Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:53:42 +0700 Subject: [PATCH 03/12] test: mono/stereo recessed meter geometry, LCD thresholds and GUI-first native startup --- tests/ui_smoke.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/ui_smoke.py b/tests/ui_smoke.py index 454d19266..53faf6a75 100644 --- a/tests/ui_smoke.py +++ b/tests/ui_smoke.py @@ -18,6 +18,44 @@ def shared_shadow_shape(shadow): assert await page.locator(".strip").count()==11 assert await page.locator("#channelList [data-choose]").count()==10 assert await page.locator("[data-strip=\"10\"], [data-strip=\"11\"]").count()==0 + + # P0 visual fix: mono gets ONE recessed LED slot, stereo gets TWO. + # Existing 7px segment rendering and physical meter semantics are untouched. + lcd=await page.evaluate("""()=>{ + const mono=document.querySelector('#mixer .strip:not(.master-strip) .vu-bank.is-mono'); + const stereo=document.querySelector('#mixer .strip:not(.master-strip) .vu-bank.is-stereo'); + const master=document.querySelector('#masterLeft .vu-bank'); + const bars=e=>e.querySelector('.vu-bars'); + const style=e=>getComputedStyle(e); + const read=document.querySelector('#masterLeft .master-analysis'); + const labels=[...read.querySelectorAll('.master-info-row span')].map(x=>x.textContent); + updateMasterAnalysisPreview(-11.5,-.5); + const hot=[document.querySelector('#masterLufs').classList.contains('over-limit'), + document.querySelector('#masterDbtp').classList.contains('over-limit')]; + updateMasterAnalysisPreview(-12,-1); + const edge=[document.querySelector('#masterLufs').classList.contains('over-limit'), + document.querySelector('#masterDbtp').classList.contains('over-limit')]; + return {monoBars:bars(mono).getBoundingClientRect().width, + stereoBars:bars(stereo).getBoundingClientRect().width, + monoBank:mono.getBoundingClientRect().width, + stereoBank:stereo.getBoundingClientRect().width, + masterBars:bars(master).getBoundingClientRect().width, + physicalMono:mono.querySelectorAll('.meter').length, + physicalStereo:stereo.querySelectorAll('.meter').length, + innerShadow:style(bars(mono)).boxShadow, + border:style(bars(mono)).borderTopWidth, + lcdBackground:style(read).backgroundImage, lcdBorder:style(read).borderTopWidth, + labels,kicker:!!read.querySelector('.master-info-kicker'), + hot,edge}; + }""") + assert lcd['monoBars']==14 and lcd['stereoBars']==30 and lcd['masterBars']==30,lcd + assert lcd['monoBank']==35 and lcd['stereoBank']==51,lcd + assert lcd['physicalMono']==1 and lcd['physicalStereo']==2,lcd + assert 'inset' in lcd['innerShadow'] and lcd['border']=='0px',lcd + assert lcd['labels']==['LUFS','dBTP'] and not lcd['kicker'],lcd + assert lcd['hot']==[True,True] and lcd['edge']==[False,False],lcd + assert 'gradient' in lcd['lcdBackground'] and lcd['lcdBorder']=='0px',lcd + # Issue #56: defaults preserve geometry; mode CSS isolates hover/layers. assert await page.evaluate("""()=>document.documentElement.dataset.mixperf==='optimized' && !window.__arMixPerfProbe""") From 4df685caf8a0bb7ca0daf11e1ce5ed9edd555378 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:53:45 +0700 Subject: [PATCH 04/12] test: mono/stereo recessed meter geometry, LCD thresholds and GUI-first native startup --- tests/main_v08_native_integration_test.mjs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/main_v08_native_integration_test.mjs b/tests/main_v08_native_integration_test.mjs index 87485d986..526ad6ef4 100644 --- a/tests/main_v08_native_integration_test.mjs +++ b/tests/main_v08_native_integration_test.mjs @@ -9,7 +9,7 @@ test('GUI v0.8 remains the canonical host, not an older v0.5 reset',()=>{ assert.match(app,/function openChannelIdentity\(/); assert.match(app,/function masterFxRows\(/); assert.match(app,/class="master-analysis"/); - assert.match(app,/LUFS-I/); + assert.match(app,/span>LUFS<\\/span>/); assert.match(app,/dBTP/); assert.match(html,/id="channelIdentity"/); assert.match(css,/rail-input-footer/); @@ -68,3 +68,23 @@ test('native plugin state and graph preserved',()=>{ assert.match(bridge,/Master PAN DSP not yet implemented/); assert.match(bridge,/data-fxpower/); }); + +test('startup never opens an audio device before the WebView2 GUI handshake',()=>{ + const constructor=main.slice(main.indexOf('ConsoleWindow()'),main.indexOf('~ConsoleWindow()')); + const ready=constructor.indexOf('browser_.goToURL'); + assert.ok(ready>=0,'GUI navigation must be started from constructor'); + assert.ok(!constructor.includes('engine_.start ('),'synchronous audio startup must not block the first WebView frame'); + const timer=main.slice(main.indexOf('void timerCallback() override')); + const readyGate=timer.indexOf('if (!audioEngineStarted_)'); + const startup=timer.indexOf('engine_.start (saved.get())'); + assert.ok(readyGate>=0&&startup>readyGate); + assert.ok(timer.includes('browser_.loaded')&&timer.includes('guiReadyTick_ < 150u')); +}); +test('master readout remains native-unavailable until measured BS.1770/true peak exists',()=>{ + assert.match(app,/updateMasterAnalysisPreview\(-31\+/); + assert.match(app,/\['masterLufs',lufs,-12\]/); + assert.match(app,/\['masterDbtp',dbtp,-1\]/); + assert.match(bridge,/lufs\.textContent="—"/); + assert.match(bridge,/tp\.textContent="—"/); + assert.doesNotMatch(app, /STREAM LEVELS SIM<\/span>/); +}); From 3d1f554a2a61e9ef8b55af2fe9d7074ed6f9b244 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:54:33 +0700 Subject: [PATCH 05/12] test: use exact LUFS label check without fragile regexp escaping --- tests/main_v08_native_integration_test.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/main_v08_native_integration_test.mjs b/tests/main_v08_native_integration_test.mjs index 526ad6ef4..051d4673c 100644 --- a/tests/main_v08_native_integration_test.mjs +++ b/tests/main_v08_native_integration_test.mjs @@ -9,7 +9,7 @@ test('GUI v0.8 remains the canonical host, not an older v0.5 reset',()=>{ assert.match(app,/function openChannelIdentity\(/); assert.match(app,/function masterFxRows\(/); assert.match(app,/class="master-analysis"/); - assert.match(app,/span>LUFS<\\/span>/); + assert.ok(app.includes('LUFS')); assert.match(app,/dBTP/); assert.match(html,/id="channelIdentity"/); assert.match(css,/rail-input-footer/); From 7b2897cef7995c9ac7cffc83710386d942c510aa Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:55:05 +0700 Subject: [PATCH 06/12] fix: exact standalone script parity (remove duplicated JS after GUI update) --- AR-MIX-Live-FX-Host-Standalone-v0.3.html | 826 ----------------------- 1 file changed, 826 deletions(-) diff --git a/AR-MIX-Live-FX-Host-Standalone-v0.3.html b/AR-MIX-Live-FX-Host-Standalone-v0.3.html index 3360a36a3..5664391c4 100644 --- a/AR-MIX-Live-FX-Host-Standalone-v0.3.html +++ b/AR-MIX-Live-FX-Host-Standalone-v0.3.html @@ -1609,832 +1609,6 @@ function panText(v){return v===0?'C':(v<0?'L':'R')+' '+Math.abs(v)} function panMarkup(ch,i){return `
`} -const channelIcons=['♩','♫','♬','🎙','🎸','🎹','🥁','🎧','▥','◉','◎','⊞']; -const channelPalette=['#1699cd','#b92e41','#cf6b1e','#b28c27','#34a544','#168762','#0e95c9','#066fa9','#7140b5','#b52893','#c32974','#586889']; -let editingChannel=-1,editingColor='',editingIcon=''; -// Position the lightweight popover at the strip name the user actually clicked. -// Clamp the panel to the visible viewport without breaking its anchor/arrow. -function positionChannelIdentity(){ - const modal=$('channelIdentity');if(editingChannel<0||!modal||modal.classList.contains('hidden'))return; - const anchor=document.querySelector('[data-editstrip="'+editingChannel+'"]'); - const panel=modal.querySelector('.identity-panel');if(!anchor||!panel)return; - const target=anchor.getBoundingClientRect(),pop=panel.getBoundingClientRect(); - const left=clamp(target.left+target.width/2-pop.width/2,10,Math.max(10,innerWidth-pop.width-10)); - const top=Math.max(10,target.top-pop.height-12); - panel.style.left=left+'px';panel.style.top=top+'px'; - panel.style.setProperty('--identity-pointer-x',clamp(target.left+target.width/2-left,18,pop.width-18)+'px'); -} -function openChannelIdentity(index){ - if(!Number.isInteger(index)||index<0||index>=channels.length)return; - editingChannel=index;editingColor=channels[index].color||colors[index];editingIcon=channels[index].icon; - const modal=$('channelIdentity');if(!modal)return; - $('identityIndex').textContent=String(index+1).padStart(2,'0'); - $('identityName').value=channels[index].name; - $('identityIcons').innerHTML=channelIcons.map(icon=>``).join(''); - $('identityColors').innerHTML=channelPalette.map(color=>``).join(''); - modal.classList.remove('hidden'); - document.querySelectorAll('.strip.identity-editing').forEach(el=>el.classList.remove('identity-editing')); - document.querySelector('[data-strip="'+index+'"]')?.classList.add('identity-editing'); - positionChannelIdentity(); - $('identityName').focus();$('identityName').select(); -} -function closeChannelIdentity(){ - editingChannel=-1;$('channelIdentity')?.classList.add('hidden'); - document.querySelectorAll('.strip.identity-editing').forEach(el=>el.classList.remove('identity-editing')); -} -function commitChannelIdentity(){ - if(editingChannel<0)return;const index=editingChannel; - const name=$('identityName').value.trim().replace(/\s+/g,' ').slice(0,26); - if(!name){flash('Enter a channel name');$('identityName').focus();return} - channels[index].name=name;channels[index].icon=channelIcons.includes(editingIcon)?editingIcon:'♩'; - channels[index].color=channelPalette.includes(editingColor)?editingColor:colors[index]; - closeChannelIdentity();currentChannel=index;renderMixer(); - if(view==='FX RACK')renderRackWorkspace(); - persistSession();flash('Channel identity updated'); -} -window.addEventListener('resize',positionChannelIdentity); -$('mixer').addEventListener('scroll',positionChannelIdentity,{passive:true}); -function makeStrip(ch,i){let inserts=ch.inserts.slice(0,6);while(inserts.length<6) inserts.push('');return `
-
${i+1}
${inserts.map((n,j)=>`
${n?``:''}
`).join('')}
-
TRIM
dB
${fmt(ch.trim)}
${knobMarkup('trim',i,ch.trim,'Trim')}
${panMarkup(ch,i)}
${panText(ch.pan)}
-
-
${fmt(ch.fader)}
${ch.stereo?meterUnit(String(i)+'L','L')+meterUnit(String(i)+'R','R'):meterUnit(String(i),'')}
${meterScaleMarkup()}
${faderScaleMarkup()}
-
${safeText(ch.name)}${safeText(ch.icon)}
- `} -function renderMixer(){ - const x=$('mixer'),scroll=x.scrollLeft; - x.innerHTML=channels.map(makeStrip).join('')+'
'; - renderMaster();x.scrollLeft=scroll;createSide(); -} -let masterGain=-.1,masterPan=0,masterMute=false,masterMono=false,phones=-12,masterInserts=['Studio EQ','Brickwall Limiter'],masterBypassed={},pendingMasterSlot=null; -function masterFxRows(){ - const slots=masterInserts.slice(0,6);while(slots.length<6)slots.push(''); - return slots.map((name,i)=>`
- - ${name?``:''}
`).join(''); -} -// Independent physically calibrated rulers, not seven flex-spaced labels. -// Fader endpoints are the center stripe of the 36x77px PNG, y=38. -const FADER_DB_TICKS=[10,5,0,-5,-10,-15,-20,-25,-30,-35,-40,-45,-50,-55,-60]; -const METER_DBFS_TICKS=[0,-6,-12,-18,-24,-36,-48,-60]; -const FADER_MAJOR_DB=new Set([10,0,-10,-20,-30,-40,-50,-60]); -const faderScaleMarkup=()=>`
${FADER_DB_TICKS.map(db=>`
${FADER_MAJOR_DB.has(db)?`${db>0?'+'+db:db}`:''}
`).join('')}
`; -const meterScaleMarkup=()=>`
${METER_DBFS_TICKS.map(db=>`
${db}
`).join('')}
`; -// Native peak telemetry is mapped from -60..0 dBFS to 0..100% in web/bridge.js. -const meterPercentToDbfs=p=>clamp(p,0,100)*.6-60; -function meterUnit(key,label){return `
`} -function renderMaster(){ - const host=$('masterLeft');if(!host)return; - host.innerHTML=`
MASTER
-
${masterFxRows()}
-
-
-
STREAM LEVELS SIM
-
LUFS-I--
-
dBTP--
-
-
-
-
-
${panText(masterPan)}
-
-
-
STEREO MAIN L / R
-
-
- - -
-
${fmt(masterGain)}
-
-
-
${meterUnit('masterL','L')}${meterUnit('masterR','R')}
- ${meterScaleMarkup()} -
-
-
-
- ${faderScaleMarkup()} -
-
MASTER
`; - syncClipLeds(); -} -function setMasterMono(value,emit=true){ - masterMono=!!value; - const button=$('masterMode');if(button){ - button.textContent=masterMono?'MONO':'STEREO'; - button.classList.toggle('is-mono',masterMono); - button.classList.toggle('is-stereo',!masterMono); - button.setAttribute('aria-pressed',String(masterMono)); - button.setAttribute('aria-label','Master output mode: '+(masterMono?'Mono':'Stereo')); - } - if(emit){send('masterMono',masterMono,-1);persistSession()} -} -function setView(next){ - if(next!=='MIX'&&next!=='FX RACK'&&next!=='SIGNAL FLOW')return; - view=next; - document.querySelectorAll('[data-view]').forEach(btn=>btn.classList.toggle('selected',btn.dataset.view===next)); - $('mixer').classList.toggle('hidden',next!=='MIX'); - $('rackWorkspace').classList.toggle('hidden',!['FX RACK','SIGNAL FLOW'].includes(next)); - if(next==='FX RACK')renderRackWorkspace(); - if(next==='SIGNAL FLOW')renderSignalFlow(); -} -function updateFader(idx,value){if(idx==='master'){masterGain=clamp(value,-60,10);const host=document.querySelector('[data-fader="master"]');host.querySelector('.cap').style.setProperty('--pos',levelToTop(masterGain)+'%');host.setAttribute('aria-valuenow',masterGain.toFixed(1));$('masterLeft').querySelectorAll('.master-db').forEach(e=>e.textContent=fmt(masterGain));send('masterGain',masterGain,-1);return}const ch=channels[+idx];ch.fader=clamp(value,-60,10);const el=document.querySelector(`[data-fader="${idx}"]`);if(el){el.querySelector('.cap').style.setProperty('--pos',levelToTop(ch.fader)+'%');el.setAttribute('aria-valuenow',ch.fader.toFixed(1));document.querySelector(`[data-read="${idx}"]`).textContent=fmt(ch.fader)}send('faderDb',ch.fader,+idx)} -function updatePan(idx,value,pointer=false){ - const master=idx==='master'; - const actual=master?masterPan:channels[idx].pan; - // A tactile 10% center detent, with 3% release hysteresis during a drag. - const oldCenter=actual===0; - const threshold=pointer?(oldCenter?13:10):0; - const next=Math.round(clamp(pointer&&Math.abs(value)<=threshold?0:value,-100,100)); - if(master)masterPan=next;else channels[idx].pan=next; - const c={pan:next}; - const el=document.querySelector(`[data-pan="${idx}"]`); - if(el){el.classList.toggle('is-centered',c.pan===0);el.style.setProperty('--pan-frac',(c.pan+100)/200);el.style.setProperty('--pan-left',Math.min(.5,(c.pan+100)/200));el.style.setProperty('--pan-span',Math.abs(c.pan)/200);el.setAttribute('aria-valuenow',String(c.pan));el.setAttribute('aria-valuetext',panText(c.pan))} - const display=document.querySelector(`[data-pan-read="${idx}"]`); - if(display)display.textContent=panText(c.pan); - send(master?'masterPan':'pan',c.pan,master?-1:idx); -} -function updateKnob(el,value){let idx=+el.dataset.ch,param=el.dataset.knob; - if(param==='phones'){phones=clamp(value,-60,10);el.style.setProperty('--angle',phones/24*130+'deg');const rd=document.querySelector('[data-phones-read]');if(rd)rd.textContent=fmt(phones);send('phonesDb',phones,-1);return} - const c=channels[idx];if(param==='pan'){updatePan(idx,value)}else{c.trim=+clamp(value,-24,24).toFixed(1);el.style.setProperty('--angle',c.trim/24*130+'deg');document.querySelector(`[data-trim-read="${idx}"]`).textContent=fmt(c.trim);send('trimDb',c.trim,idx)}} -function focusChannel(i){ - if(i<0||i>=channels.length||(i===currentChannel&&!masterSelected))return; - masterSelected=false;currentChannel=i; - document.querySelectorAll('.strip').forEach(strip=>strip.classList.toggle('selected',strip.dataset.strip!==undefined&&+strip.dataset.strip===i)); - document.querySelectorAll('#channelList [data-choose]').forEach(row=>row.classList.toggle('selected',+row.dataset.choose===i)); -} -function focusMaster(){ - if(masterSelected)return; - masterSelected=true; - document.querySelectorAll('.strip').forEach(strip=>strip.classList.toggle('selected',strip.id==='masterLeft')); - document.querySelectorAll('#channelList [data-choose]').forEach(row=>row.classList.remove('selected')); -} -function chooseChannel(i){if(i<0||i>=channels.length){flash('Additional bank channels are not populated in this UI study');return}currentChannel=i;renderMixer();if(view==='FX RACK')renderRackWorkspace()} -function toggleState(i,key){channels[i][key]=!channels[i][key];const btn=document.querySelector(`[data-${key}="${i}"]`);if(btn){btn.classList.toggle('active',channels[i][key]);btn.setAttribute('aria-pressed',String(channels[i][key]))}send(key,channels[i][key],i)} -document.addEventListener('click',e=>{const b=e.target.closest('button,[data-choose],[data-scene],[data-group]'); - const icon=e.target.closest('[data-icon-choice]'),color=e.target.closest('[data-color-choice]'); - if(icon){editingIcon=icon.dataset.iconChoice;document.querySelectorAll('[data-icon-choice]').forEach(n=>{n.classList.toggle('selected',n===icon);n.setAttribute('aria-pressed',String(n===icon))});return} - if(color){editingColor=color.dataset.colorChoice;document.querySelectorAll('[data-color-choice]').forEach(n=>{n.classList.toggle('selected',n===color);n.setAttribute('aria-pressed',String(n===color))});return} - if(!b){const strip=e.target.closest('[data-strip]');if(strip&&view==='MIX')focusChannel(+strip.dataset.strip);else if(e.target.closest('#masterLeft')&&view==='MIX')focusMaster();return;} - const originStrip=b.closest('[data-strip]'); - if(originStrip&&view==='MIX')focusChannel(+originStrip.dataset.strip);else if(b.closest('#masterLeft')&&view==='MIX')focusMaster(); - if(b.dataset.view){setView(b.dataset.view);return} - if(b.dataset.nativeAction==='audioSetup'){flash('Audio Setup is available in the Windows desktop app');return} - if(b.dataset.pluginManager!==undefined){flash('Plugin Manager is available in the Windows desktop app');return} - if(b.dataset.mySounds!==undefined){flash('Native VST3 presets are available in the Windows desktop app');return} - if(b.dataset.choose!==undefined){chooseChannel(+b.dataset.choose);return} - if(b.dataset.mute!==undefined){toggleState(+b.dataset.mute,'mute');return}if(b.dataset.solo!==undefined){toggleState(+b.dataset.solo,'solo');return} - if(b.dataset.pre!==undefined){let i=+b.dataset.pre;channels[i].pre=!channels[i].pre;b.classList.toggle('active');send('phase',channels[i].pre,i);return} - if(b.dataset.hpf!==undefined){let i=+b.dataset.hpf;channels[i].hpf=!channels[i].hpf;b.classList.toggle('active');send('hpf',channels[i].hpf,i);return} - if(b.dataset.masterInsert!==undefined){pendingMasterSlot=+b.dataset.masterInsert;openPluginBrowser(currentChannel,true);return} - if(b.dataset.masterPower!==undefined){const slot=+b.dataset.masterPower;masterBypassed[slot]=!masterBypassed[slot];renderMaster();persistSession();send('masterFxBypass',{slot,bypass:masterBypassed[slot]},-1);return} - if(b.dataset.clip!==undefined){resetClip(b.dataset.clip);return} - if(b.dataset.fxpower!==undefined){const [i,j]=b.dataset.fxpower.split(':').map(Number);setFxBypass(i,j,!bypassed[fxKey(i,j)]);return} - if(b.dataset.insert){let [i,j]=b.dataset.insert.split(':').map(Number);currentChannel=i;pendingSlot=j;openPluginBrowser(i);return} - if(b.dataset.deleteScene!==undefined){deleteMixerSnapshot(b.dataset.deleteScene);return} - if(b.dataset.scene!==undefined){loadSnapshotByIndex(+b.dataset.scene);return} - if(b.dataset.preset){applyQuickPreset(b.dataset.preset);return} - if(b.dataset.addplugin!==undefined){pendingSlot=channels[currentChannel].inserts.length;openPluginBrowser(currentChannel);return} - if(b.dataset.chainmove){movePlugin(+b.dataset.index,+b.dataset.chainmove);return} - if(b.dataset.chainremove!==undefined){removePlugin(+b.dataset.chainremove);return} - if(b.dataset.chainbypass!==undefined){toggleBypass(+b.dataset.chainbypass);return} - if(b.dataset.chainedit!==undefined){pluginEditorIndex=+b.dataset.chainedit;renderRackWorkspace();return} - if(b.dataset.chanselect!==undefined){chooseChannel(+b.dataset.chanselect);renderRackWorkspace();return} - if(b.dataset.pluginname){insertPlugin(b.dataset.pluginname);return} - if(b.dataset.category){activeCategory=b.dataset.category;renderPluginBrowser();return} - if(b.dataset.group!==undefined){flash('Group selection — interface placeholder');return} - if(b.dataset.side){document.querySelectorAll('[data-side]').forEach(x=>x.classList.toggle('selected',x===b));if(b.dataset.side==='fx')setView('FX RACK');else setView('MIX');return} - switch(b.id){case'identityCancel':closeChannelIdentity();break;case'identitySave':commitChannelIdentity();break;case'masterMute':masterMute=!masterMute;b.textContent='MUTE';b.classList.toggle('active',masterMute);b.setAttribute('aria-pressed',String(masterMute));send('masterMute',masterMute,-1);break;case'masterMode':setMasterMono(!masterMono);break;case'addScene':saveMixerSnapshot();break;case'saveFxPreset':saveFxChainPreset();break;case'menuScene':exportSession();break;case'closeBrowser':closePluginBrowser();break;case'closeFxInspector':pluginEditorIndex=null;renderRackWorkspace();break;case'chooseFxFile':importSession();break;case'flowRoutingButton':case'flowRoutingButtonSecondary':if(typeof window.__arMixOpenRoutingLab==="function")window.__arMixOpenRoutingLab();else flash("Routing editor is available in the native desktop app");break;case'arSignalOpen':if(!window.__JUCE__?.backend?.emitEvent)flash('Signal Check is available in the Windows desktop app');break;default:if(b.id)flash('UI study: '+b.textContent.trim().slice(0,28));} -}); -// Deliberate double-click to edit a strip. Single-click only changes selection. -document.addEventListener('dblclick',e=>{const el=e.target.closest('[data-editstrip]');if(!el)return; - const i=Number(el.dataset.editstrip);if(!Number.isInteger(i)||i<0||i>=channels.length)return; - e.preventDefault();e.stopPropagation();openChannelIdentity(i); -},true); -document.addEventListener('dblclick',e=>{const pan=e.target.closest('[data-pan]');if(pan){e.preventDefault();e.stopPropagation();updatePan(pan.dataset.pan==='master'?'master':+pan.dataset.pan,0)}},true); -// DAW-like insert move in standalone preview: ghost and insertion line during -// pointer travel; one final chain transaction at drop. Native host owns its -// own verified DSP reorder and this preview path never sends native edits. -let fxGesture=null,fxSuppressClick=false; -function clearFxGesture(){ - const d=fxGesture;if(!d)return; - d.marker?.classList.remove('fx-drop-before','fx-drop-after'); - d.source?.classList.remove('fx-drag-source');d.ghost?.remove(); - document.removeEventListener('pointermove',moveFxGesture); - fxGesture=null; -} -document.addEventListener('pointerdown',e=>{ - if(window.__JUCE__?.backend?.emitEvent||e.button!==0||fxGesture)return; - const button=e.target.closest('#mixer .rack .insert:not(.empty)'); - if(!button)return; - const strip=button.closest('[data-strip]'),rack=button.closest('.rack'); - if(!strip||!rack)return; - const channel=Number(strip.dataset.strip),from=Number(button.dataset.insert?.split(':')[1]); - const count=normalChain(channels[channel]).length; - if(!Number.isInteger(from)||from>=count||count<2)return; - const slots=[...rack.querySelectorAll('.insert-slot')]; - fxGesture={pointerId:e.pointerId,source:button.closest('.insert-slot'),channel,from,count, - startX:e.clientX,startY:e.clientY,x:e.clientX,y:e.clientY, - bounds:slots.map(slot=>({slot,rect:slot.getBoundingClientRect()})), - insertion:from,active:false,ghost:null,marker:null}; - document.addEventListener('pointermove',moveFxGesture,{passive:false}); -},true); -const moveFxGesture=e=>{ - const d=fxGesture;if(!d||e.pointerId!==d.pointerId)return; - d.x=e.clientX;d.y=e.clientY; - if(!d.active){ - if(Math.hypot(d.x-d.startX,d.y-d.startY)<7)return; - d.active=true;d.source.classList.add('fx-drag-source'); - d.ghost=document.createElement('div');d.ghost.className='fx-drag-ghost'; - d.ghost.textContent=d.source.querySelector('.insert-name')?.textContent||'FX'; - document.body.appendChild(d.ghost); - } - e.preventDefault(); - d.ghost.style.transform='translate3d('+(d.x+12)+'px,'+(d.y+10)+'px,0)'; - d.marker?.classList.remove('fx-drop-before','fx-drop-after');d.marker=null; - const bounds=d.bounds; - const inside=bounds.length&&d.x>=bounds[0].rect.left-15&&d.x<=bounds[0].rect.right+15 - &&d.y>=bounds[0].rect.top-8&&d.y<=bounds[bounds.length-1].rect.bottom+8; - if(!inside){d.insertion=-1;return} - let insertion=d.count; - for(let i=0;i{ - const d=fxGesture;if(!d||e.pointerId!==d.pointerId)return; - const active=d.active,from=d.from,at=d.insertion,ch=d.channel; - clearFxGesture(); - if(active){fxSuppressClick=true;setTimeout(()=>fxSuppressClick=false,0); - if(at>=0)movePluginTo(ch,from,Math.max(0,Math.min(d.count-1,at>from?at-1:at)));} -},true); -document.addEventListener('pointercancel',e=>{ - if(fxGesture?.pointerId===e.pointerId)clearFxGesture(); -},true); -document.addEventListener('keydown',e=>{ - if(e.key==='Escape'&&fxGesture){clearFxGesture();fxSuppressClick=true;setTimeout(()=>fxSuppressClick=false,0);} -},true); -document.addEventListener('click',e=>{ - if(fxSuppressClick&&!window.__JUCE__?.backend?.emitEvent){fxSuppressClick=false;e.preventDefault();e.stopImmediatePropagation()} -},true); - -// Double-click a fader for 0 dB unity gain, without changing workspace. -document.addEventListener('dblclick',e=>{const f=e.target.closest('[data-fader]');if(!f)return;e.preventDefault();e.stopPropagation();updateFader(f.dataset.fader,0)},true); -// Idle pointer movement has no handler. Acquire geometry only once per drag -// rather than forcing a layout read on every input event. -let drag=null; -function moveDraggedControl(e){ - const d=drag; - if(!d||d.pointerId!==e.pointerId)return; - if(d.type==='fader'){ - updateFader(d.index,d.startDb+(d.startY-e.clientY)*70/d.distance); - }else if(d.type==='pan'){ - updatePan(d.index,d.fromThumb?d.startPan+(e.clientX-d.startX)*200/d.travel: - ((e.clientX-d.left-9)/d.travel)*200-100,true); - }else if(d.type==='knob'){ - updateKnob(d.el,d.original+(d.initial-e.clientY)*.35); - } -} -document.addEventListener('pointerdown',e=>{ - if(drag)return; - const f=e.target.closest('[data-fader]'),p=e.target.closest('[data-pan]'),k=e.target.closest('[data-knob]'); - if(!f&&!p&&!k)return; - const el=f||p||k,strip=e.target.closest('[data-strip]'); - if(strip&&view==='MIX')focusChannel(+strip.dataset.strip); - else if(e.target.closest('#masterLeft')&&view==='MIX')focusMaster(); - if(f){ - const idx=f.dataset.fader,r=f.getBoundingClientRect(); - drag={type:'fader',el:f,pointerId:e.pointerId,index:idx, - startY:e.clientY,distance:Math.max(24,r.height-77), - startDb:idx==='master'?masterGain:channels[+idx].fader}; - // Relative drag: clicking track never teleports the fader. - }else if(p){ - const index=p.dataset.pan==='master'?'master':+p.dataset.pan, - fromThumb=!!e.target.closest('.pan-thumb'),r=p.getBoundingClientRect(), - travel=Math.max(1,r.width-18); - drag={type:'pan',el:p,pointerId:e.pointerId,index,fromThumb, - startX:e.clientX,startPan:index==='master'?masterPan:channels[index].pan, - travel,left:r.left}; - if(!fromThumb)updatePan(index,((e.clientX-r.left-9)/travel)*200-100,true); - }else{ - drag={type:'knob',el:k,pointerId:e.pointerId,initial:e.clientY, - original:k.dataset.knob==='phones'?phones:channels[+k.dataset.ch][k.dataset.knob]}; - } - if(drag.type==='fader'||drag.type==='pan')el.classList.add('is-dragging'); - document.addEventListener('pointermove',moveDraggedControl,{passive:true}); - if(el.setPointerCapture)el.setPointerCapture(e.pointerId); - e.preventDefault(); -}); -for(const type of ['pointerup','pointercancel'])document.addEventListener(type,e=>{ - if(!drag||e.pointerId!==drag.pointerId)return; - document.removeEventListener('pointermove',moveDraggedControl); - drag.el.classList.remove('is-dragging'); - drag=null; - flushUiParams(); -}); -document.addEventListener('wheel',e=>{const pan=e.target.closest('[data-pan]');if(pan){e.preventDefault();const idx=pan.dataset.pan==='master'?'master':+pan.dataset.pan;updatePan(idx,(idx==='master'?masterPan:channels[idx].pan)-Math.sign(e.deltaY)*2);return} - const k=e.target.closest('[data-knob]');if(!k)return;e.preventDefault();const p=k.dataset.knob,i=+k.dataset.ch,v=p==='phones'?phones:channels[i][p];updateKnob(k,v-Math.sign(e.deltaY)*.5)},{passive:false}); -document.addEventListener('keydown',e=>{const pan=e.target.closest('[data-pan]');if(pan){const k=e.key,idx=pan.dataset.pan==='master'?'master':+pan.dataset.pan; - if(!['ArrowLeft','ArrowRight','PageUp','PageDown','Home','End'].includes(k))return; - e.preventDefault();const value=idx==='master'?masterPan:channels[idx].pan,step=e.shiftKey?10:1; - updatePan(idx,k==='Home'?0:k==='End'?100:k==='PageUp'?value+10:k==='PageDown'?value-10:value+(k==='ArrowRight'?step:-step));return} - const f=e.target.closest('[data-fader]');if(!f)return; - const steps={ArrowUp:.5,ArrowDown:-.5,PageUp:5,PageDown:-5}; - if(!(e.key in steps)&&e.key!=='Home'&&e.key!=='End')return; - e.preventDefault();const idx=f.dataset.fader,db=idx==='master'?masterGain:channels[+idx].fader; - updateFader(idx,e.key==='Home'?-60:e.key==='End'?10:db+steps[e.key]); -}); -document.addEventListener('keydown',e=>{if(e.ctrlKey&&e.key.toLowerCase()==='s'){e.preventDefault();if(persistSession())flash('UI state saved locally');else flash('Browser storage unavailable')}}); -// Issue #56: no pointer profiler/event listener runs in normal preview or native. -const mixperfParam=new URLSearchParams(location.search).get('mixperf'); -const mixperfModes=['optimized','baseline','hover-off','meters-off','layers-off','all-off','meter-raw']; -const mixperfMode=mixperfModes.includes(mixperfParam)?mixperfParam:'optimized'; -document.documentElement.dataset.mixperf=mixperfMode; -if(mixperfParam&&mixperfModes.includes(mixperfParam)){ - window.__arMixPerfProbe={mode:mixperfMode,run(durationMs=10000){ - const ms=Math.max(1000,Math.min(20000,Number(durationMs)||10000)); - const buckets={mixer:[],outside:[]},moves={mixer:0,outside:0}; - let area='',pointerAt=-Infinity,lastFrame=0,frameId=0,observer=null,longTasks=0,longTaskMs=0; - // Long Task entries are browser-dependent. Unavailable must never read as zero. - let longTaskAvailable=false; - function pointer(e){area=e.target.closest?.('#mixer')?'mixer':'outside';pointerAt=performance.now();moves[area]++} - function visibility(){lastFrame=0;pointerAt=-Infinity} - function frame(t){ - if(lastFrame&&!document.hidden&&t-pointerAt<350&&t-lastFrame>0)buckets[area].push(t-lastFrame); - lastFrame=t;frameId=requestAnimationFrame(frame); - } - function stats(a){const s=a.slice().sort((x,y)=>x-y),n=s.length; - const over33=s.filter(x=>x>33.3).length,over50=s.filter(x=>x>50).length; - return {samples:n,medianMs:n?+s[Math.floor((n-1)*.5)].toFixed(2):null, - p95Ms:n?+s[Math.ceil(n*.95)-1].toFixed(2):null, - p99Ms:n?+s[Math.ceil(n*.99)-1].toFixed(2):null,maxMs:n?+s[n-1].toFixed(2):null, - over33Ms:over33,over50Ms:over50,over33Pct:n?+(over33*100/n).toFixed(2):null}; - } - document.addEventListener('pointermove',pointer,{passive:true}); - document.addEventListener('visibilitychange',visibility); - if(typeof PerformanceObserver==='function' && - PerformanceObserver.supportedEntryTypes?.includes('longtask'))try{ - observer=new PerformanceObserver(l=>{ - for(const e of l.getEntries()){longTasks++;longTaskMs+=e.duration} - });observer.observe({entryTypes:['longtask']});longTaskAvailable=true; - }catch{observer?.disconnect();observer=null} - frameId=requestAnimationFrame(frame); - return new Promise(done=>setTimeout(()=>{ - cancelAnimationFrame(frameId);document.removeEventListener('pointermove',pointer); - document.removeEventListener('visibilitychange',visibility);observer?.disconnect(); - done({mode:mixperfMode,durationMs:ms,environment:{userAgent:navigator.userAgent,dpr:devicePixelRatio, - width:innerWidth,height:innerHeight,iframe:top!==self},mixer:stats(buckets.mixer), - outside:stats(buckets.outside),pointerMoves:moves,longTaskAvailable, - longTasks:longTaskAvailable?longTasks:null, - longTaskMs:longTaskAvailable?+longTaskMs.toFixed(1):null, - note:'rAF proxy, not measured GPU paint/input latency; unsupported longtask is null'}); - },ms)); - }}; -} -// Browser-only meter scheduler: do not enqueue a 60/120/144Hz rAF just to -// reject 3/4 of its callbacks. Timer wakes shortly before the next visual tick; -// a single rAF aligns the paint with the browser. Native JUCE owns live metering. -const browserMeterStats={ticks:0,skipped:0,slowWakeups:0,intervalMs:40}; -let meterTimer=0,meterRAF=0,meterExpected=0,meterLate=0,meterHealthy=0; -function scheduleDemoMeter(){ - if(window.__JUCE__?.backend?.emitEvent||document.hidden|| - mixperfMode==='meters-off'||mixperfMode==='all-off')return; - const interval=browserMeterStats.intervalMs; - meterExpected=performance.now()+interval; - meterTimer=setTimeout(()=>{ - meterTimer=0; - const late=Math.max(0,performance.now()-meterExpected); - if(late>25){ - browserMeterStats.slowWakeups++; - meterLate++;meterHealthy=0; - if(meterLate>=3){browserMeterStats.intervalMs=60;meterLate=0} - }else{ - meterHealthy++;meterLate=0; - if(meterHealthy>=30){browserMeterStats.intervalMs=40;meterHealthy=0} - } - if(document.hidden){browserMeterStats.skipped++;return} - meterRAF=requestAnimationFrame(t=>{meterRAF=0;meters(t)}); - },interval); -} -function meters(t){ - // JUCE desktop reads actual audio meters; browser demo only animates a preview. - if(window.__JUCE__?.backend?.emitEvent||document.hidden|| - mixperfMode==='meters-off'||mixperfMode==='all-off')return; - browserMeterStats.ticks++; - scheduleDemoMeter(); - channels.forEach((ch,i)=>{const wave=(Math.sin(t*.0022+i*1.92)+Math.sin(t*.0043+i*.6))*.5; - const v=clamp(45+wave*24+ch.fader*.48,4,98); - if(ch.stereo){ // Browser-only preview: independent L/R motion; no invented native telemetry. - const delta=Math.sin(t*.0027+i*1.3)*7; - updateMeterVisual(String(i)+'L',ch.mute?2:clamp(v+delta,2,98),t); - updateMeterVisual(String(i)+'R',ch.mute?2:clamp(v-delta*.7+Math.sin(t*.004+i)*3,2,98),t); - }else updateMeterVisual(String(i),ch.mute?2:v,t)}); - const base=clamp(67+Math.sin(t*.002)*15,8,95); - const l=clamp(base+Math.sin(t*.003)*6,3,99),r=clamp(base-5+Math.sin(t*.003+1)*7,3,99); - updateMeterVisual('masterL',masterMute?2:l,t);updateMeterVisual('masterR',masterMute?2:r,t); - // UI demonstration only. These values are never from a true-peak or loudness meter. - const lufs=$('masterLufs'),tp=$('masterDbtp'); - if(lufs)lufs.textContent=(-31+(l+r)/11).toFixed(1); - if(tp)tp.textContent=(-18+Math.max(l,r)/7).toFixed(1); -} -// v0.3: demo-only FX catalog. Items represent mock plugins, not installed VST3 binaries. -const pluginCatalog=[ - {name:'Studio EQ',type:'EQ',badge:'EQ',hint:'Four-band tonal shaping'}, - {name:'Dynamic EQ',type:'EQ',badge:'D',hint:'Adaptive tonal control'}, - {name:'Vocal Compressor',type:'Dynamics',badge:'C',hint:'Smooth vocal dynamics'}, - {name:'Noise Gate',type:'Dynamics',badge:'G',hint:'Reduce background noise'}, - {name:'De-Esser',type:'Dynamics',badge:'S',hint:'Sibilance control'}, - {name:'Brickwall Limiter',type:'Dynamics',badge:'L',hint:'Prevent excessive peaks'}, - {name:'Studio Reverb',type:'Space',badge:'R',hint:'Natural vocal ambience'}, - {name:'Tempo Delay',type:'Space',badge:'D',hint:'Synced echo'}, - {name:'Stereo Chorus',type:'Creative',badge:'CH',hint:'Gentle stereo width'}, - {name:'Saturator',type:'Creative',badge:'SAT',hint:'Analog-style harmonic color'} -]; -let pendingSlot=-1, activeCategory='All', userSnapshots={},savedChains={},bypassed={},fxParams={},pluginEditorIndex=null; -const initialFactoryChannels=channels.map(c=>({...c,inserts:[...c.inserts]})); -const safeText=s=>String(s).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c])); -function normalChain(ch){return ch.inserts.filter(Boolean)} -function fxKey(ch,slot){return `${ch}:${slot}`} -function getFxParams(ch,slot){const k=fxKey(ch,slot);return fxParams[k]??(fxParams[k]={mix:60,amount:45,output:0})} -function moveFxMeta(ch,from,to){const a=fxKey(ch,from),b=fxKey(ch,to),tmp=fxParams[a];fxParams[a]=fxParams[b];fxParams[b]=tmp;const bo=bypassed[a];bypassed[a]=bypassed[b];bypassed[b]=bo} -function shiftFxMetaRight(ch,at,len){for(let i=len;i>at;i--){fxParams[fxKey(ch,i)]=fxParams[fxKey(ch,i-1)];bypassed[fxKey(ch,i)]=bypassed[fxKey(ch,i-1)]}delete fxParams[fxKey(ch,at)];delete bypassed[fxKey(ch,at)]} -function shiftFxMetaLeft(ch,at,len){for(let i=at;i``).join('')} -function renderRackWorkspace(){let c=channels[currentChannel];let chain=normalChain(c);$('rackWorkspace').innerHTML=`
YOUR SOUND · CORE WORKFLOW

FX Rack — ${safeText(c.name)}

Build your signature vocal sound. Add, reorder, bypass, and store your VST chain.

● AUDIO INPUT · ${safeText(c.name)}
↓
${chain.map((name,i)=>`
${String(i+1).padStart(2,'0')}${safeText(name)}${safeText(pluginCatalog.find(p=>p.name===name)?.hint||'VST3 plugin · mock chain state')}
↓
`).join('')}
↓
◎ OUTPUT · MASTER / STREAM
${pluginEditorIndex!==null&&pluginEditorIndex

Ready-to-use Sound

Start with a preset, then personalize your FX chain. No complex routing required.

${['Clean Vocal','Warm Karaoke','Live Broadcast'].map(s=>``).join('')}

Make it sound better

Recommended signal path:

Noise Gate → EQ → Compressor → De-Esser → Reverb

Demo status

Plugin names and bypass buttons currently change visual state only. Installed VST3 scanning and DSP are scheduled for the native engine phase.

`}
`} -function pluginInspector(ch,slot){const name=normalChain(channels[ch])[slot],v=getFxParams(ch,slot);return `
FX EDITOR · DEMO PARAMETERS

${safeText(name)}

These generic controls demonstrate the editing and preset workflow. The real VST3 editor will replace them when connected.

`} -function renderSignalFlow(){ - if(window.__JUCE__?.backend?.emitEvent){ - $('rackWorkspace').innerHTML=`
ARSONMIX · NATIVE ROUTING

Signal Flow — 10 Native Channels

Physical inputs → native VST3 → PRE/POST sends → BUS returns → MASTER. All routing changes use the same live engine and hardware epoch.

01 · DEVICEVerified ASIO/WASAPIActual enabled port mask
➜
02 · CHANNELS10 Native StripsIndependent VST3 + live controls
➜
03 · BUSPRE/POST SendsCycle-validated internal returns
➜
04 · MASTERHardware L / RDirect authorized endpoint
Routing edits still require OUTPUT MUTE. Unchanged VST3 instances now retain state and tails when a route is re-applied. CUE/AUX hardware output patching and plugin latency compensation remain future gates.
`; - return; - } - $('rackWorkspace').innerHTML=`
NO TECHNICAL PATCHBAY REQUIRED

Signal Flow — See where your voice goes

A beginner-first view of the real-time audio path. Select your audio device in Setup.

01 · INPUTMicrophoneAudio Interface
ASIO or WASAPI
➜
02 · FX CHAINVST3 PluginsEQ · Dynamics
Reverb · Delay
➜
03 · MIXERMix & MonitorFader · Pan
Master · Meters
➜
04 · OUTPUTSpeakers / StreamAudio Device
Streaming bridge later
⚠ In this trial the audio flow is a visual concept; no microphone is captured and no audio is sent to a livestream.
`} -function openPluginBrowser(idx,isMaster=false){if(!isMaster){currentChannel=idx;pendingMasterSlot=null}activeCategory='All';$('pluginModal').classList.remove('hidden');$('pluginTarget').textContent=isMaster?'Adding to MASTER bus · demo FX catalog':'Adding to '+channels[idx].name+' · virtual effects catalog';$('pluginSearch').value='';renderPluginBrowser();$('pluginSearch').focus()} -function closePluginBrowser(){$('pluginModal').classList.add('hidden')} -function renderPluginBrowser(){document.querySelectorAll('[data-category]').forEach(b=>b.classList.toggle('active',b.dataset.category===activeCategory));const q=$('pluginSearch').value.trim().toLowerCase();let pool=pluginCatalog.filter(p=>(activeCategory==='All'||p.type===activeCategory)&&`${p.name} ${p.type} ${p.hint}`.toLowerCase().includes(q));$('pluginResults').innerHTML=pool.map(p=>``).join('')||'

No matching demo effects.

'} -function insertPlugin(name){ - if(pendingMasterSlot!==null){ - const slot=pendingMasterSlot; - if(slot>=6)return; - masterInserts[slot]=name;delete masterBypassed[slot];pendingMasterSlot=null; - closePluginBrowser();renderMaster();persistSession(); - send('masterChainChanged',{chain:[...masterInserts]},-1); - flash('Master FX updated (GUI preview)');return; - } - const c=channels[currentChannel];const chain=normalChain(c);if(chain.length>=8){flash('Maximum 8 FX slots in this UI trial');return}const index=clamp(pendingSlot,0,chain.length);shiftFxMetaRight(currentChannel,index,chain.length);chain.splice(index,0,name);pluginEditorIndex=index;setChain(c,chain);closePluginBrowser();flash(name+' added to preview chain');send('chainChanged',{chain},currentChannel)} -function movePluginTo(channel,from,to){ - const c=channels[channel],chain=normalChain(c); - if(from<0||to<0||from>=chain.length||to>=chain.length||from===to)return false; - const [fx]=chain.splice(from,1);chain.splice(to,0,fx); - // Preserve each insert's bypass and editor settings, rather than swapping labels. - for(let i=from;i!==to;i+=to>from?1:-1)moveFxMeta(channel,i,i+(to>from?1:-1)); - if(channel===currentChannel)pluginEditorIndex=to; - setChain(c,chain);persistSession(); - send('chainChanged',{chain},channel);return true; -} -function movePlugin(idx,dir){movePluginTo(currentChannel,idx,idx+dir)} -function removePlugin(idx){const c=channels[currentChannel],ch=normalChain(c);shiftFxMetaLeft(currentChannel,idx,ch.length);ch.splice(idx,1);pluginEditorIndex=null;setChain(c,ch);send('chainChanged',{chain:ch},currentChannel)} -function setFxBypass(ch,slot,disabled){ - const chain=normalChain(channels[ch]); - if(!chain[slot])return; - const k=fxKey(ch,slot); - bypassed[k]=!!disabled; - const power=document.querySelector(`[data-fxpower="${k}"]`); - const cell=power?.closest('.insert-slot'); - if(cell)cell.classList.toggle('is-bypassed',disabled); - if(power){ - power.classList.toggle('is-bypassed',disabled); - power.setAttribute('aria-pressed',String(!disabled)); - power.setAttribute('aria-label',(disabled?'Enable ':'Bypass ')+chain[slot]); - power.title=(disabled?'Enable ':'Bypass ')+chain[slot]; - } - if(ch===currentChannel){ - const rackButton=document.querySelector(`[data-chainbypass="${slot}"]`); - if(rackButton){ - rackButton.classList.toggle('power-on',!disabled); - rackButton.classList.toggle('is-bypassed',disabled); - rackButton.setAttribute('aria-pressed',String(!disabled)); - rackButton.setAttribute('aria-label',(disabled?'Enable ':'Bypass ')+chain[slot]); - rackButton.title=(disabled?'Enable ':'Bypass ')+chain[slot]; - rackButton.closest('.chain-node')?.classList.toggle('dimmed',disabled); - } - } - send('chainBypass',{slot,bypass:!!disabled},ch); - persistSession(); -} -function toggleBypass(idx){setFxBypass(currentChannel,idx,!bypassed[fxKey(currentChannel,idx)])} -const quickPresets={'Clean Vocal':['Noise Gate','Studio EQ','Vocal Compressor'],'Warm Karaoke':['Noise Gate','Studio EQ','Vocal Compressor','Studio Reverb'],'Live Broadcast':['Noise Gate','Dynamic EQ','De-Esser','Brickwall Limiter']}; -function applyQuickPreset(name){const c=channels[currentChannel];for(let i=0;i<8;i++){delete fxParams[fxKey(currentChannel,i)];delete bypassed[fxKey(currentChannel,i)]}pluginEditorIndex=null;setChain(c,quickPresets[name]||[]);document.querySelectorAll('[data-preset]').forEach(b=>b.classList.toggle('active',b.dataset.preset===name));flash('FX chain preset selected: '+name+' (UI only)');send('chainChanged',{chain:normalChain(c)},currentChannel)} -function durableSession(){return {schemaVersion:1,version:'0.3-ui',channels:channels.map(c=>({id:c.id,name:c.name,icon:c.icon,color:c.color,inserts:[...c.inserts],fader:c.fader,pan:c.pan,trim:c.trim,mute:c.mute,solo:c.solo,hpf:c.hpf,stereo:c.stereo})),masterGain,masterPan,masterMute,masterMono,masterInserts:[...masterInserts],masterBypassed:{...masterBypassed},sceneIdx,selected:currentChannel,fxParams:structuredClone(fxParams),bypassed:{...bypassed}};} -function persistSession(){try{localStorage.setItem('armix-v03-current',JSON.stringify(durableSession()));localStorage.setItem('armix-v03-snapshots',JSON.stringify(userSnapshots));localStorage.setItem('armix-v03-chains',JSON.stringify(savedChains));return true}catch{return false}} -function saveFxChainPreset(){const name=prompt('Name this FX chain preset:','My Vocal Chain');if(!name)return;const key=name.trim().slice(0,60);if(!key)return;savedChains[key]={schemaVersion:1,inserts:[...normalChain(channels[currentChannel])],states:normalChain(channels[currentChannel]).map((_,i)=>({...getFxParams(currentChannel,i),bypass:!!bypassed[fxKey(currentChannel,i)]}))};persistSession();flash('FX chain preset saved: '+key)} -function recallFxChain(){const keys=Object.keys(savedChains);if(!keys.length){flash('No saved FX chains yet');return}const key=prompt('Enter FX chain preset name:\n'+keys.join('\n'),keys[0]);if(!key||!savedChains[key])return;setChain(channels[currentChannel],savedChains[key].inserts);savedChains[key].states?.forEach((v,i)=>{fxParams[fxKey(currentChannel,i)]={mix:v.mix,amount:v.amount,output:v.output};bypassed[fxKey(currentChannel,i)]=!!v.bypass});pluginEditorIndex=null;renderRackWorkspace();flash('FX chain recalled: '+key)} -function saveMixerSnapshot(){ - const name=prompt('Save mixer snapshot — name:',scenes[sceneIdx]||'My Live Sound'); - if(name===null)return; - const key=name.trim().replace(/\\s+/g,' ').slice(0,60); - if(!key){flash('Enter a snapshot name');return} - if(Object.prototype.hasOwnProperty.call(userSnapshots,key)&&!confirm('Replace existing snapshot "'+key+'"?'))return; - const session=durableSession(); - const previous=userSnapshots[key]; - userSnapshots[key]={...session,savedAt:new Date().toISOString()}; - if(!scenes.includes(key))scenes.push(key); - sceneIdx=scenes.indexOf(key); - if(!persistSession()){ - if(previous===undefined)delete userSnapshots[key];else userSnapshots[key]=previous; - flash('Snapshot NOT saved: storage unavailable');return; - } - createSide();flash('Mixer snapshot saved: '+key+' (local UI state)'); -} -function deleteMixerSnapshot(name){ - if(!Object.prototype.hasOwnProperty.call(userSnapshots,name))return; - if(!confirm('Delete saved snapshot "'+name+'"?'))return; - const previous=userSnapshots[name];delete userSnapshots[name]; - if(!persistSession()){userSnapshots[name]=previous;flash('Delete failed: storage unavailable');return} - const index=scenes.indexOf(name);if(index>=4)scenes.splice(index,1); - sceneIdx=Math.min(sceneIdx,scenes.length-1);createSide();flash('Snapshot deleted: '+name); -} -function applySession(session){if(!session||session.schemaVersion!==1||!Array.isArray(session.channels)||session.channels.length=6; // Fixed 1–6 mono, 7–10 stereo across legacy snapshot migrations. - if(typeof src.name==='string'&&src.name.trim())c.name=src.name.trim().slice(0,26); - if(channelIcons.includes(src.icon))c.icon=src.icon; - if(channelPalette.includes(src.color))c.color=src.color; - for(const k of ['fader','pan','trim'])if(Number.isFinite(src[k]))c[k]=src[k];for(const k of ['mute','solo','hpf'])if(typeof src[k]==='boolean')c[k]=src[k];if(Array.isArray(src.inserts))c.inserts=src.inserts.filter(x=>typeof x==='string').slice(0,8)}masterGain=Number.isFinite(session.masterGain)?session.masterGain:-.1;masterPan=Number.isFinite(session.masterPan)?clamp(session.masterPan,-100,100):0;masterMute=!!session.masterMute;masterMono=!!session.masterMono; - send('masterMono',masterMono,-1); - if(Array.isArray(session.masterInserts))masterInserts=session.masterInserts.filter(x=>typeof x==='string').slice(0,6); - masterBypassed=(session.masterBypassed&&typeof session.masterBypassed==='object')?{...session.masterBypassed}:{}; - fxParams=(session.fxParams&&typeof session.fxParams==='object')?structuredClone(session.fxParams):{};bypassed=(session.bypassed&&typeof session.bypassed==='object')?{...session.bypassed}:{};pluginEditorIndex=null;renderMixer();renderMaster();if(view==='FX RACK')renderRackWorkspace()} -function loadSnapshotByIndex(i){if(!Number.isInteger(i)||i<0||i>=scenes.length)return;sceneIdx=i;const name=scenes[sceneIdx]; - if(userSnapshots[name])applySession(userSnapshots[name]); - else if(sceneIdx<4){const state=durableSession();state.channels=initialFactoryChannels.map(c=>({...c,inserts:[...c.inserts]}));state.masterGain=-.1; - const voicePresets=[quickPresets['Clean Vocal'],quickPresets['Warm Karaoke'],quickPresets['Live Broadcast'],quickPresets['Clean Vocal']];state.channels[0].inserts=[...voicePresets[sceneIdx]];applySession(state);flash('Factory snapshot recalled: '+name+' (UI only)')} - createSide();persistSession()} -function exportSession(){const data=JSON.stringify({...durableSession(),savedChains,userSnapshots},null,2);const blob=new Blob([data],{type:'application/json'}),url=URL.createObjectURL(blob),a=document.createElement('a');a.href=url;a.download='ar-mix-live-session.json';a.click();setTimeout(()=>URL.revokeObjectURL(url),1200);flash('Session JSON exported')} -function importSession(){const f=document.createElement('input');f.type='file';f.accept='application/json,.json';f.onchange=async()=>{const file=f.files?.[0];if(!file)return;if(file.size>2_000_000){flash('Session too large');return}try{const obj=JSON.parse(await file.text());applySession(obj);persistSession();flash('Session loaded')}catch{flash('Invalid JSON session')}};f.click()} -// Single optimized console layout. The unused PRO/EASY switch is retired. -$('app').classList.add('easy'); -$('pluginSearch').addEventListener('input',renderPluginBrowser); -document.addEventListener('input',e=>{const el=e.target;if(!el.dataset.fxparam)return;const slot=+el.dataset.slot,key=el.dataset.fxparam;if(!['mix','amount','output'].includes(key))return;const v=getFxParams(currentChannel,slot);v[key]=+el.value;const out=el.closest('label')?.querySelector('output');if(out)out.textContent=key==='output'?`${v[key]>0?'+':''}${v[key]} dB`:`${v[key]}%`;send('fxDemoParam',{slot,key,value:v[key]},currentChannel)}); -$('pluginModal').addEventListener('click',e=>{if(e.target===$('pluginModal'))closePluginBrowser()}); -$('channelIdentity').addEventListener('click',e=>{if(e.target===$('channelIdentity'))closeChannelIdentity()}); -$('identityName').addEventListener('keydown',e=>{if(e.key==='Enter'){e.preventDefault();commitChannelIdentity()}}); -document.addEventListener('keydown',e=>{if(e.key==='Escape'){closePluginBrowser();closeChannelIdentity()}if((e.key==='Enter'||e.key===' ')&&e.target.matches('[data-editstrip]')){e.preventDefault();openChannelIdentity(+e.target.dataset.editstrip)}}); -document.addEventListener('change',e=>{if(e.target.id==='rackChannel'){currentChannel=+e.target.value;renderRackWorkspace();renderMixer()}}); -document.addEventListener('click',e=>{const id=e.target.closest('button')?.id;if(id==='saveFxFromRack')saveFxChainPreset();else if(id==='recallFxPreset')recallFxChain();else if(id==='openSetupFromFlow')$('audioSetupBtn')?.click();else if(id==='flowFxButton')setView('FX RACK');else if(id==='backMixer')setView('MIX')}); -let lastPersist=0;setInterval(()=>{if(Date.now()-lastPersist<2000)return;lastPersist=Date.now();persistSession()},5000); -try{userSnapshots=JSON.parse(localStorage.getItem('armix-v03-snapshots')||'{}');savedChains=JSON.parse(localStorage.getItem('armix-v03-chains')||'{}');for(const k of Object.keys(userSnapshots))if(!scenes.includes(k))scenes.push(k)}catch{userSnapshots={};savedChains={}} - -createSide();renderMixer();renderMaster();try{let last=JSON.parse(localStorage.getItem('armix-v03-current'));if(!last)last=JSON.parse(localStorage.getItem('arMixStudioUI')); if(last&&last.channels?.length>=channels.length){last.channels.slice(0,channels.length).forEach((s,i)=>{if(typeof s.name==='string'&&s.name.trim())channels[i].name=s.name.trim().slice(0,26); - if(channelIcons.includes(s.icon))channels[i].icon=s.icon; - if(channelPalette.includes(s.color))channels[i].color=s.color; - for(const k of ['fader','pan','trim','mute','solo','hpf'])if(s[k]!==undefined)channels[i][k]=s[k];if(Array.isArray(s.inserts))channels[i].inserts=s.inserts.filter(x=>typeof x==='string').slice(0,8)});sceneIdx=last.sceneIdx??0;masterGain=last.masterGain??-.1;masterPan=Number.isFinite(last.masterPan)?clamp(last.masterPan,-100,100):0;masterMute=!!last.masterMute;masterMono=!!last.masterMono; - send('masterMono',masterMono,-1); - if(Array.isArray(last.masterInserts))masterInserts=last.masterInserts.filter(x=>typeof x==='string').slice(0,6); - if(last.masterBypassed&&typeof last.masterBypassed==='object')masterBypassed={...last.masterBypassed}; - if(last.bypassed&&typeof last.bypassed==='object')bypassed={...last.bypassed}; - if(last.fxParams&&typeof last.fxParams==='object')fxParams=structuredClone(last.fxParams); - renderMixer();renderMaster();flash('Previous UI session restored')}}catch{} -// Stop all simulated animation work while the tab is hidden, and restart on -// foregrounding. One owner per timer / RAF; never double-schedule on restore. -document.addEventListener('visibilitychange',()=>{ - if(document.hidden){ - if(meterTimer){clearTimeout(meterTimer);meterTimer=0} - if(meterRAF){cancelAnimationFrame(meterRAF);meterRAF=0} - }else if(!meterTimer&&!meterRAF)scheduleDemoMeter(); -}); -scheduleDemoMeter(); -'use strict'; -// AR MIX Studio UI-only demonstration. No audio is mixed or routed here. -const colors=['#1699cd','#b92e41','#cf6b1e','#b28c27','#34a544','#168762','#0e95c9','#066fa9','#7140b5','#b52893','#c32974','#586889']; -const raw=[ - ['Lead Vocal','♩',['Gate','EQ','Compressor','Reverb'],-.6,0], - ['Mic 2','♩',['EQ','Compressor','De-Esser'],-4.7,-15], - ['Music L','♫',['EQ','Compressor'],-10.3,0], - ['Music R','♫',['EQ','Compressor'],-6.1,0], - ['Guest Mic','♩',['Gate','EQ','Compressor'],-8.8,10], - ['Stream PC','▥',['EQ','Limiter'],-12.4,0], - ['Backing','♫',['EQ','Reverb'],-3.6,-25], - ['Guitar','♬',['EQ','Compressor','Delay'],-7.9,30], - ['Keyboard','▥',['EQ','Reverb'],-14.2,0], - ['FX Return','◎',['Reverb'],-5.1,0] -]; -const channels=raw.map((a,i)=>({id:i+1,name:a[0],icon:a[1],color:colors[i],inserts:[...a[2]],fader:a[3],pan:a[4],trim:0,mute:false,solo:false,pre:false,hpf:i%4!==0,stereo:i>=6})); -let currentChannel=0, masterSelected=false, view='MIX', sceneIdx=0, timer=0; -const scenes=['Vocal Live','Karaoke Warm','Clean Voice','Studio Session']; -const $=id=>document.getElementById(id); -const clamp=(v,min,max)=>Math.max(min,Math.min(max,v)); -const levelToTop=db=>+(clamp((10-db)/70,0,1)*100).toFixed(3); -const fmt=db=>db===-Infinity?'−∞':`${db>0?'+':''}${db.toFixed(1)} dB`; -// UI side throttling is distinct from the native realtime control plane. -const pendingUiParams=new Map();let uiFlushScheduled=false; -const peakHold=Object.create(null),clipLatch=Object.create(null); -function resetClip(key){ - clipLatch[key]=false;delete peakHold[key]; - document.querySelector(`[data-clip="${key}"]`)?.classList.remove('latched'); - const entry=meterNodes.get(key);if(entry?.peak){entry.peak.style.bottom='0%';entry.peakValue=-1} -} -function syncClipLeds(){document.querySelectorAll('[data-clip]').forEach(e=>e.classList.toggle('latched',!!clipLatch[e.dataset.clip]))} -// Cache per-meter nodes across preview frames, rebuilding on mixer re-render. -// Styling a full-height bar with a compositor transform avoids 14 cyclic height -// reflows per meter tick. No native meter or DSP data path is affected. -const meterNodes=new Map(); -// Shared preview/native painter: preserve fixed colors; light only whole 7px LEDs. -const LED_PITCH_PX=7,ledMeterCache=new WeakMap(); -// Opt-in performance A/B: reproduce pre-P1 raw-level DOM writes, with the -// exact same meter visuals. Production only writes CSS on visible LED changes. -const meterRawStyleWrites=new URLSearchParams(location.search).get('mixperf')==='meter-raw'; -function setLedMeterLevel(el,rawLevel){ - if(!el)return; - const level=clamp(Number(rawLevel)||0,0,100); - let state=ledMeterCache.get(el); - if(!state){state={height:el.getBoundingClientRect().height,level:-1,lit:-1};ledMeterCache.set(el,state)} - const levelChanged=state.level!==level; - state.level=level; // Full precision remains cached for ResizeObserver / telemetry. - const lit=level>=100?state.height:Math.floor((level*state.height/100+1e-7)/LED_PITCH_PX)*LED_PITCH_PX; - if(state.lit!==lit){ - state.lit=lit; - // --led-lit drives the clip; --level remains the compatible fallback, - // updated only when the visible whole-row LED state actually changes. - el.style.setProperty('--level',level+'%'); - el.style.setProperty('--led-lit',lit+'px'); - }else if(meterRawStyleWrites&&levelChanged){ - // Diagnostics only: old unconditional raw-level style invalidation. - el.style.setProperty('--level',level+'%'); - } -} -window.__arMixSetLedMeterLevel=setLedMeterLevel; - -// Native-only visual interpolation. JUCE sends true peak samples at 12 Hz; -// never change that realtime/data cadence to control animation smoothness. -// Exactly ONE pending timer + ONE rAF serve every live meter (not one per bar). -const NATIVE_METER_FRAME_MS=34; // ceiling 29.4 scheduled paint frames/s -const NATIVE_METER_ATTACK_SECONDS=.018; // immediate-looking, but visually bounded -const NATIVE_METER_RELEASE_SECONDS=.165; // fast initial fall, gentle exponential landing -const nativeMeterStates=new Map(); -const nativeMeterDirect=new URLSearchParams(location.search).get('metermotion')==='direct'; -const nativeMeterMotionStats={frames:0,scheduled:0,targets:0,meterPaintCalls:0,frameBudgetMs:NATIVE_METER_FRAME_MS,active:0}; -let nativeMeterTimer=0,nativeMeterRAF=0,nativeMeterLastTime=0; -function nativeMeterStep(level,target,dt){ - // One-pole envelope in DISPLAY space only: never modify audio/true peak. - // On a sudden level drop, travel is initially fast because the gap is large; - // speed decays continuously as the visible bar approaches the measured target. - // Time-correct across 30fps jitter; no easing animation, overshoot or bounce. - const span=Math.max(0,Math.min(.065,Number(dt)||0)); - if(!span||level===target)return level; - const tau=target>level?NATIVE_METER_ATTACK_SECONDS:NATIVE_METER_RELEASE_SECONDS; - const next=target+(level-target)*Math.exp(-span/tau); - // Sub-LED residual cannot be seen: stop scheduling without tail jitter. - return Math.abs(next-target)<.3?target:next; -} -function scheduleNativeMeterFrame(){ - if(nativeMeterTimer||nativeMeterRAF||document.hidden)return; - nativeMeterMotionStats.scheduled++; - nativeMeterTimer=setTimeout(()=>{ - nativeMeterTimer=0; - if(!document.hidden)nativeMeterRAF=requestAnimationFrame(animateNativeMeters); - },NATIVE_METER_FRAME_MS); -} -function animateNativeMeters(now){ - nativeMeterRAF=0; - if(document.hidden){nativeMeterLastTime=0;return;} - const dt=nativeMeterLastTime?Math.min(.065,Math.max(0,(now-nativeMeterLastTime)/1000)):NATIVE_METER_FRAME_MS/1000; - nativeMeterLastTime=now; - nativeMeterMotionStats.frames++; - let active=0; - for(const [el,s] of nativeMeterStates){ - if(!el.isConnected){nativeMeterStates.delete(el);continue;} - s.level=nativeMeterStep(s.level,s.target,dt); - setLedMeterLevel(el,s.level); - nativeMeterMotionStats.meterPaintCalls++; - if(Math.abs(s.level-s.target)>.3)active++; - } - nativeMeterMotionStats.active=active; - if(active)scheduleNativeMeterFrame(); - else nativeMeterLastTime=0; -} -function setNativeMeterTarget(el,rawValue){ - if(!el)return; - const target=clamp(Number(rawValue)||0,0,100); - let s=nativeMeterStates.get(el); - if(!s){ - // Mixer DOM may be rebuilt after a preset/FX edit: prune detached nodes - // without polling or leaking strong references to old LED bars. - if(nativeMeterStates.size>4) - for(const [old] of nativeMeterStates)if(!old.isConnected)nativeMeterStates.delete(old); - s={level:0,target:0};nativeMeterStates.set(el,s); - setLedMeterLevel(el,0); - } - s.target=target; - nativeMeterMotionStats.targets++; - if(nativeMeterDirect||document.hidden|| - (typeof matchMedia==='function'&&matchMedia('(prefers-reduced-motion: reduce)').matches)){ - s.level=target;setLedMeterLevel(el,target); - return; - } - if(Math.abs(s.level-target)>.3)scheduleNativeMeterFrame(); -} -window.__arMixSetNativeMeterTarget=setNativeMeterTarget; -window.__arMixMeterMotionStats=nativeMeterMotionStats; -document.addEventListener('visibilitychange',()=>{ - if(!document.hidden)return; - if(nativeMeterTimer){clearTimeout(nativeMeterTimer);nativeMeterTimer=0;} - if(nativeMeterRAF){cancelAnimationFrame(nativeMeterRAF);nativeMeterRAF=0;} - nativeMeterLastTime=0; - for(const [el,s] of nativeMeterStates){ - if(!el.isConnected){nativeMeterStates.delete(el);continue;} - s.level=s.target;setLedMeterLevel(el,s.level); - } - nativeMeterMotionStats.active=0; -}); - -// Observe only the stable mixer root, never disposable strips; no hot-path reflow. -if(typeof ResizeObserver==='function'){ - const ledResizeObserver=new ResizeObserver(()=>{ - document.querySelectorAll('#mixer [data-meter]').forEach(el=>{ - const state=ledMeterCache.get(el);if(!state)return; - const height=el.getBoundingClientRect().height; - if(height===state.height)return; - state.height=height;state.lit=-1;setLedMeterLevel(el,state.level); - }); - }); - const mixerRoot=document.getElementById('mixer'); - if(mixerRoot)ledResizeObserver.observe(mixerRoot); -} -function meterNode(key){ - const cached=meterNodes.get(key); - if(cached?.fill.isConnected)return cached; - const fill=document.querySelector(`[data-meter="${key}"]`); - if(!fill)return null; - const slot=fill.closest('.meter'); - const entry={fill,peak:slot?.querySelector('.meter-peak'), - clip:slot?.querySelector('.clip-led'),level:-1,peakValue:-1}; - // DOM replacement must not erase a held peak or a latched CLIP lamp. - const held=peakHold[key]; - if(held&&entry.peak){ - entry.peakValue=Math.round(held.value*10); - entry.peak.style.bottom=(entry.peakValue/10)+'%'; - } - if(clipLatch[key])entry.clip?.classList.add('latched'); - meterNodes.set(key,entry); - return entry; -} -function updateMeterVisual(key,level,now){ - const meter=meterNode(key);if(!meter)return; - const value=clamp(level,0,99); - const levelStep=Math.round(value*10); - if(meter.level!==levelStep){ - meter.level=levelStep; - setLedMeterLevel(meter.fill,levelStep/10); - } - const previous=peakHold[key]; - if(!previous||value>=previous.value||now>=previous.until){ - peakHold[key]={value,until:now+1600}; - const step=Math.round(value*10); - if(meter.peak&&meter.peakValue!==step){ - meter.peakValue=step; - meter.peak.style.bottom=(step/10)+'%'; - } - } - if(value>=97&&!clipLatch[key]){ - clipLatch[key]=true; - meter.clip?.classList.add('latched'); - } -} - -function flushUiParams(){uiFlushScheduled=false;const bridge=window.__JUCE__?.backend;if(bridge?.emitEvent)for(const event of pendingUiParams.values())bridge.emitEvent('arMixParameter',event);pendingUiParams.clear()} -function send(param,value,ch=currentChannel){ - const event={channel:ch+1,parameter:param,value}; - // P1I: native routing token rejects UI gestures from stale device graphs. - const liveToken=window.__armixRouteToken; - if(ch>=0&&ch<10&&liveToken?.epoch>0&&liveToken?.revision>0){ - event.routeEpoch=liveToken.epoch;event.routeRevision=liveToken.revision; - } - if(['faderDb','pan','trimDb','phonesDb','masterGain'].includes(param)){ - pendingUiParams.set(`${ch}:${param}`,event); - if(!uiFlushScheduled){uiFlushScheduled=true;requestAnimationFrame(flushUiParams)} - }else{flushUiParams();const bridge=window.__JUCE__?.backend;if(bridge?.emitEvent)bridge.emitEvent('arMixParameter',event)} -} -function flash(message){const x=$('toast');x.textContent=message;x.classList.add('show');clearTimeout(timer);timer=setTimeout(()=>x.classList.remove('show'),1500)} -function createSide(){ - const labels=channels.map(c=>c.name); - $('channelList').innerHTML=labels.map((label,i)=>`
${i+1}${safeText(label)}
`).join(''); - $('groupsList').innerHTML=['Drums','Band','Vocals','FX','All Music','All Vocals'].map((x,i)=>`
${i+1}${x}
`).join(''); - $('scenesList').innerHTML=scenes.map((x,i)=>`
${safeText(x)}${userSnapshots[x]?``:''}
`).join(''); - $('currentScene').innerHTML=`Snapshot: ${scenes[sceneIdx]}▾`; -} -function knobMarkup(param,ch,value,label,small=false){let angle=(param==='pan'?value/100*130:value/24*130);return ``} -function panText(v){return v===0?'C':(v<0?'L':'R')+' '+Math.abs(v)} -function panMarkup(ch,i){return `
`} - const channelIcons=['♩','♫','♬','🎙','🎸','🎹','🥁','🎧','▥','◉','◎','⊞']; const channelPalette=['#1699cd','#b92e41','#cf6b1e','#b28c27','#34a544','#168762','#0e95c9','#066fa9','#7140b5','#b52893','#c32974','#586889']; let editingChannel=-1,editingColor='',editingIcon=''; From 92b055cf8b1afe9b961589b0d05e12e69c06cc6e Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:56:14 +0700 Subject: [PATCH 07/12] test: replace superseded SIM/LUFS-I caption assertions with minimal LCD and honest preview provenance --- tests/ui_smoke.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/ui_smoke.py b/tests/ui_smoke.py index 53faf6a75..40df08a9c 100644 --- a/tests/ui_smoke.py +++ b/tests/ui_smoke.py @@ -330,8 +330,9 @@ def shared_shadow_shape(shadow): assert await page.locator('#masterPeakDb').count()==0 assert await page.locator('#masterLufs').count()==1 assert await page.locator('#masterDbtp').count()==1 - assert 'SIM' in await page.locator('#masterLeft .master-analysis').inner_text() - assert 'LUFS-I' in await page.locator('#masterLeft .master-analysis').inner_text() + assert 'SIM' not in await page.locator('#masterLeft .master-analysis').inner_text() + assert 'LUFS' in await page.locator('#masterLeft .master-analysis').inner_text() + assert 'simulated' in (await page.locator('#masterLeft .master-analysis').get_attribute('title')).lower() # Buttons must describe and perform actual distinct actions: no "..." blank cap. assert await page.locator('.left-rail #addScene').inner_text()=='+ SAVE SNAPSHOT' assert await page.locator('.left-rail #saveFxPreset').inner_text()=='SAVE FX' From 5249f3d17b700d4ebde1f5fcdd2f24b52177a3b5 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:57:23 +0700 Subject: [PATCH 08/12] test: updated mono/stereo bank widths and rail offsets to match requested compact meter geometry --- tests/ui_smoke.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/ui_smoke.py b/tests/ui_smoke.py index 40df08a9c..66fc615bd 100644 --- a/tests/ui_smoke.py +++ b/tests/ui_smoke.py @@ -917,14 +917,17 @@ def same_rect(a,b): assert [s['count'] for s in module_layout]==[1]*6+[2]*5,module_layout for s in module_layout: assert s['dom']==['VU','FADER','SCALE'],s - assert abs(s['bank']['w']-51)<.3 and abs(s['ruler']['w']-26)<.3,s + assert abs(s['bank']['w']-(35 if s['count']==1 else 51))<.3 and abs(s['ruler']['w']-26)<.3,s assert s['bank']['r']+2=s['zone']['l']-1 and s['ruler']['r']<=s['zone']['r']+1,s assert all(abs(m['w']-14)<.3 for m in s['meters']),s assert s['rail']['w']>=36 and s['rail']['h']>150,s - # Mono and stereo strips share an identically located central rail. - rail_x=[s['rail']['l']-s['zone']['l'] for s in module_layout[:10]] - assert max(rail_x)-min(rail_x)<1,rail_x + # Mono's narrower well intentionally releases 16px to its fader. + # Same-format strips retain precisely aligned central rail offsets. + mono_x=[s['rail']['l']-s['zone']['l'] for s in module_layout[:10] if s['count']==1] + stereo_x=[s['rail']['l']-s['zone']['l'] for s in module_layout[:10] if s['count']==2] + assert max(mono_x)-min(mono_x)<1 and max(stereo_x)-min(stereo_x)<1,(mono_x,stereo_x) + assert abs((stereo_x[0]-mono_x[0])-16)<1,(mono_x,stereo_x) assert all(abs(v['unit']-14)<.3 and abs(v['meter']-14)<.3 and abs(v['fill']-10)<.6 and v['clip'] for v in vu_geometry),vu_geometry assert len(set(v['gradient'] for v in vu_geometry))==1, 'VU palette must match across all L/R/mono bars' From 1e7d53ea7a896e8a1c2f5a78a656a89950985bf3 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:57:40 +0700 Subject: [PATCH 09/12] P0: keep fixed 10px LED cells inside borderless recessed meter well --- web/styles-src/42-mixer-premium.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/styles-src/42-mixer-premium.css b/web/styles-src/42-mixer-premium.css index 0c1835996..fc3650a47 100644 --- a/web/styles-src/42-mixer-premium.css +++ b/web/styles-src/42-mixer-premium.css @@ -362,3 +362,9 @@ html:not([data-mixperf="baseline"]):not([data-mixperf="layers-off"]):not([data-m #app #masterLeft .master-controls-zone .master-analysis .master-info-row strong.over-limit{ color:#ff555f;text-shadow:none; } + +/* Borderless deep LED slit keeps the approved 10px illuminated cell width. */ +#app #mixer .fader-zone .meter-signal-area .meter-fill, +#app #mixer .fader-zone .meter-signal-area .meter-peak{ + left:2px;right:2px; +} From 0a6d26131f665114bc99b8df6376a9b0eaacf681 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:57:44 +0700 Subject: [PATCH 10/12] P0: keep fixed 10px LED cells inside borderless recessed meter well --- web/styles.css | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/web/styles.css b/web/styles.css index 88ea54f2a..f969bac31 100644 --- a/web/styles.css +++ b/web/styles.css @@ -1337,3 +1337,9 @@ html:not([data-mixperf="baseline"]):not([data-mixperf="layers-off"]):not([data-m #app #masterLeft .master-controls-zone .master-analysis .master-info-row strong.over-limit{ color:#ff555f;text-shadow:none; } + +/* Borderless deep LED slit keeps the approved 10px illuminated cell width. */ +#app #mixer .fader-zone .meter-signal-area .meter-fill, +#app #mixer .fader-zone .meter-signal-area .meter-peak{ + left:2px;right:2px; +} From 2f5fa49b7101c3d94fdf2c6ae0dd23ddcbe49045 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 04:57:49 +0700 Subject: [PATCH 11/12] P0: keep fixed 10px LED cells inside borderless recessed meter well --- AR-MIX-Live-FX-Host-Standalone-v0.3.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AR-MIX-Live-FX-Host-Standalone-v0.3.html b/AR-MIX-Live-FX-Host-Standalone-v0.3.html index 5664391c4..5804c79ca 100644 --- a/AR-MIX-Live-FX-Host-Standalone-v0.3.html +++ b/AR-MIX-Live-FX-Host-Standalone-v0.3.html @@ -1338,6 +1338,12 @@ #app #masterLeft .master-controls-zone .master-analysis .master-info-row strong.over-limit{ color:#ff555f;text-shadow:none; } + +/* Borderless deep LED slit keeps the approved 10px illuminated cell width. */ +#app #mixer .fader-zone .meter-signal-area .meter-fill, +#app #mixer .fader-zone .meter-signal-area .meter-peak{ + left:2px;right:2px; +}
From db5a2685e30abb6dc01c744b58f61051ec33e048 Mon Sep 17 00:00:00 2001 From: Ari Sulistiono Date: Thu, 29 Oct 2026 05:06:00 +0700 Subject: [PATCH 12/12] P0: lightweight native first-frame text during WebView2 cold boot, no blank window or compositor timer --- src/Main.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Main.cpp b/src/Main.cpp index 9893e9864..67733814e 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -92,6 +92,24 @@ class Browser final : public juce::WebBrowserComponent public: explicit Browser (Options options) : WebBrowserComponent (std::move (options)) {} bool loaded = false; + // Paint a lightweight native first-frame while WebView2 spins up. This is + // entirely static JUCE graphics, not an overlay CSS compositor or timer. + // The embedded browser owns the content as soon as its authenticated + // arMixGuiReady event arrives. + void paint (juce::Graphics& g) override + { + if (loaded) return; + g.fillAll (juce::Colour (0xff111b23)); + g.setColour (juce::Colour (0xff58cdeb)); + g.setFont (juce::FontOptions (22.0f, juce::Font::plain)); + g.drawText ("ArSonMix", getLocalBounds().withTrimmedTop (getHeight() / 2 - 36) + .removeFromTop (30), juce::Justification::centred); + g.setColour (juce::Colour (0xff94adbb)); + g.setFont (juce::FontOptions (12.0f)); + g.drawText ("Loading mixer interface", getLocalBounds().withTrimmedTop ( + getHeight() / 2 + 4).removeFromTop (24), + juce::Justification::centred); + } // An Internet Explorer error page can trigger this callback too. // Only arMixGuiReady from our final JS script authenticates readiness. void pageFinishedLoading (const juce::String&) override {} @@ -163,6 +181,7 @@ class ConsoleWindow final : public juce::DocumentWindow, private juce::Timer, pr { browser_.loaded = true; guiReadyTick_ = juce::Time::getMillisecondCounter(); + browser_.repaint(); }) .withEventListener ("arMixParameter", [this] (juce::var args) { onParameter (args); }) .withEventListener ("arMixAction", [this] (juce::var args) { onAction (args); })