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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions AR-MIX-Live-FX-Host-Standalone-v0.3.html
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,93 @@
}
}
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 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,fallVelocity,dt){
const span=Math.max(0,Math.min(.065,Number(dt)||0));
if(target>level){
// About 85% of an upward step in 34ms; almost immediate at real speech peaks.
const v=level+(target-level)*(1-Math.exp(-span/.018));
return {level:target-v<.3?target:v,velocity:0};
}
if(target<level){
// Gravity-like release: gentle initial descent, time-based acceleration,
// capped terminal speed. Never overshoot, even with irregular UI callbacks.
const speed=Math.min(100,Math.max(14,fallVelocity)+230*span);
const next=Math.max(target,level-speed*span);
return {level:next-target<.3?target:next,velocity:next===target?0:speed};
}
return {level:target,velocity:0};
}
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;}
const next=nativeMeterStep(s.level,s.target,s.velocity,dt);
s.level=next.level;s.velocity=next.velocity;
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,velocity: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;s.velocity=0;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;s.velocity=0;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(()=>{
Expand Down
34 changes: 34 additions & 0 deletions docs/ARD_056_NATIVE_METER_BALLISTICS_VISUAL_AUDIT_2026-10-27.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ARD-056 P2 — Native meter ballistics and GUI visual audit (2026-10-27)

## Basis and boundaries

Screenshot: user Windows 11 Pro native EXE at 1594×928, Channel 1 LED lit, un-routed preview lanes dark, Auto Orbit visible. This screenshot cannot establish actual FPS, GPU utilization, or repaint duration. Base main de4dd81c; PR #97 is simultaneously modifying FX Rack/channel selection/GUI optics, so visual scope is carefully separated.

## Engineering audit

1. Native JUCE src/Main.cpp calls startTimerHz(12) and publishes arMixStatus at 12Hz. The native audio callback remains unchanged.
2. Old web/bridge.js did source release using Math.max(raw,old-5) for each 12Hz status. That makes a stepped release tied to telemetry count, not elapsed time.
3. web/app.js paints fixed-palette 7px quantised LED segments; PR #96 avoids dirty CSS writes. Do not revert that renderer or distort its stationary color bands.
4. Browser demo simulates separate 25Hz meter changes, not native sound; the new ballistics work only through the JUCE native bridge.

## Implemented scheduling and signal motion

- One shared native meter scheduler for live CH1 input and master L/R/aux, with 34ms timer then one requestAnimationFrame, at most ~29.4 scheduled paint frames/sec (actual observed FPS can be less). No per-strip loops or timers and no idle rAF after levels settle.
- Fast attack: exponential rise with 18ms time constant, never overshoots. Gravity release: begin with at least 14 percent-units/second, accelerate +230 percent-units/s² up to 100 percent-units/second terminal rate, never overshoots.
- Time delta bounded to 65ms; after hidden-tab transition cancel timer and RAF and synchronize to latest target; reduced-motion or ?metermotion=direct displays raw native levels without animation.
- DOM Map prunes stale disconnected LED elements when mixer re-renders. Observability: window.__arMixMeterMotionStats for developer diagnostics only, never advertised as GPU proof.
- No modification to JUCE telemetry/audio RT callback, FX Orbit, FX Rack, PAN, faders, LED colors, clip/peak hold, or shadow styles.

## Visual UX audit, screenshot-based

- Strengths: identifiable 10-channel colors and master, coherent dark console palette, metallic fader cap assets, segmented LED scale, clear Orbit trajectory.
- P0 addressed here: stiff stair-step native metering; improve motion perception while preserving stationary LED color bands and bounded updates.
- P1: repeated ADD FX in the un-routed lanes can visually imply live DSP; PR #97 currently owns channel-aware FX/Rack remediation, so do not duplicate or overwrite that concurrent work.
- P1: tiny LUFS/true peak label, channel names, and footer status need selective typography/contrast tests at 1366×768 and 125% DPI, rather than global font/strip resizing.
- P1: Orbit popup obscures several input strips; current anchored workflow is functional, but reconsider side docking or collision avoidance after PR #97 settles (no extra glow/backdrop blur).
- P1: very strong bevels in top toolbar and left-rail are visually heavier than mixer; coordinate with approved BTN-180 recipes and PR #97 before altering. Do not remove mandated seven rest/seven pressed shadows.
- Preserve honest native routing indication: live CH1 and master meter are not proof that the other nine channels or master FX have audio DSP.

## Verification gate

Run deterministic ballistics tests for rise/fall/acceleration/no-overshoot and single scheduler, CSS/standalone parity, Chromium + Firefox GUI test, and Windows native MSVC CTests/package. Reconcile latest main and review PR #97 before merge. Validate on affected standard Windows hardware with direct versus animated mode, input quiet/loud, Orbit open/closed, p95 and GPU profiler. No claim of real end-to-end FPS or audio FAT from CI.
13 changes: 13 additions & 0 deletions tests/gui_workflow_contract_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,16 @@ test('quantised LED meter avoids redundant raw CSS writes while preserving diagn
assert.ok(monitor.includes('const setTextIfChanged='));
assert.ok(bridge.includes('footer.textContent!==text'));
});

test('native 12Hz status uses one capped shared visual meter scheduler',()=>{
assert.ok(app.includes('const NATIVE_METER_FRAME_MS=34;'));
assert.ok(app.includes('const nativeMeterStates=new Map()'));
assert.ok(app.includes('function nativeMeterStep('));
assert.ok(app.includes('function scheduleNativeMeterFrame('));
assert.ok(app.includes('if(nativeMeterTimer||nativeMeterRAF||document.hidden)return;'));
assert.ok(app.includes("window.__arMixSetNativeMeterTarget=setNativeMeterTarget"));
assert.ok(bridge.includes('window.__arMixSetNativeMeterTarget(el,level)'));
assert.ok(!bridge.includes('liveInputLevel-5'), 'release must use elapsed time, not telemetry count');
assert.ok(!bridge.includes('liveOutputLeft-5'));
assert.ok(!app.includes('setInterval(animateNativeMeters'), 'no perpetual meter frame timer');
});
6 changes: 4 additions & 2 deletions tests/main_v08_native_integration_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ test('no fake oscillating VUs inside native JUCE',()=>{
const scheduled=app.indexOf('meterTimer=setTimeout(',scheduler);
assert.ok(a>scheduler && guard>a && guard<firstSynth);
assert.ok(schedulerGuard>scheduler && schedulerGuard<scheduled);
assert.match(bridge,/\["masterL",liveOutputLeft\]/);
assert.match(bridge,/\["masterR",liveOutputRight\]/);
assert.match(bridge,/paintMeter\(document\.querySelector\('\[data-meter="masterL"\]'\)/);
assert.match(bridge,/paintMeter\(document\.querySelector\('\[data-meter="masterR"\]'\)/);
assert.ok(bridge.includes('percent(d.peakLeft)') && bridge.includes('percent(d.peakRight)'));
assert.ok(!bridge.includes('liveOutputLeft-5'),'do not smooth on the 12Hz source callback');
});
test('native mixer always displays DSP gain, pan, and mute instead of stale demo session',()=>{
assert.match(src,/setProperty \("channelDb", juce::Decibels::gainToDecibels/);
Expand Down
9 changes: 5 additions & 4 deletions tests/native_ui_contract_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ test('native app never runs demo sine meters',()=>{
assert.ok(app.indexOf('meterRAF=requestAnimationFrame(t=>{meterRAF=0;meters(t)});',scheduler)>scheduler);
});
test('native meter reads DSP and hides all 11 visual-only channels',()=>{
assert.match(bridge,/inputLevel=percent\(d\.inputPeak\)/);
assert.match(bridge,/outputLevel=percent\(d\.peak\)/);
assert.ok(bridge.includes('["masterL",liveOutputLeft]'));
assert.ok(bridge.includes('["masterR",liveOutputRight]'));
assert.ok(bridge.includes('percent(d.inputPeak)'),'CH1 uses native audio input peak');
assert.ok(bridge.includes('percent(d.peakLeft)') && bridge.includes('percent(d.peakRight)'),'real output L/R peak inputs');
assert.ok(bridge.includes('percent(d.peak)'),'master aux uses native output peak');
assert.ok(bridge.includes('window.__arMixSetNativeMeterTarget(el,level)'),'native data is fed to bounded visual presenter');
assert.ok(!bridge.includes('liveInputLevel-5'),'remove callback-cadence smoothing');
assert.match(bridge,/track\.dataset\.preview="1"/);
assert.ok(bridge.includes("meter-fill{opacity:0!important}"));
});
Expand Down
7 changes: 4 additions & 3 deletions tests/reconciled_gui_engine_contract_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ test('native desktop does not run any visual-only sine meter loop',()=>{
const timer=app.indexOf('meterTimer=setTimeout(',scheduler);
assert.ok(scheduler>=0 && fn>scheduler && early>fn && early<synth);
assert.ok(scheduleGuard>scheduler && scheduleGuard<timer);
assert.match(bridge,/liveOutputLeft/);
assert.match(bridge,/\["masterL",liveOutputLeft\]/);
assert.match(bridge,/\["masterR",liveOutputRight\]/);
assert.ok(bridge.includes('percent(d.peakLeft)')&&bridge.includes('percent(d.peakRight)'));
assert.match(bridge,/paintMeter\(document\.querySelector\('\[data-meter="masterL"\]'\)/);
assert.match(bridge,/paintMeter\(document\.querySelector\('\[data-meter="masterR"\]'\)/);
assert.ok(!bridge.includes('liveOutputLeft-5'),'native output must be raw before time-based visual motion');
assert.match(bridge,/track\.dataset\.preview="1"/);
});
test('master non-native control surfaces explicitly excluded',()=>{
Expand Down
19 changes: 19 additions & 0 deletions tests/ui_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,25 @@ def shared_shadow_shape(shadow):
return {before,after:e.getAttribute('style'),lit,level:ledMeterCache.get(e).level};
}""")
assert dirty['before']==dirty['after'] and dirty['level']==1.1,dirty
# Deterministic native-style time-based ballistics: fast attack,
# gravity release, non-overshoot, single shared 30fps visual owner.
ballistic=await page.evaluate("""()=>{
const fast=nativeMeterStep(8,96,0,.034);
const down=nativeMeterStep(96,8,0,.034);
const further=nativeMeterStep(down.level,8,down.velocity,.034);
const zero=nativeMeterStep(8,8,14,.034);
const overshoot=nativeMeterStep(2,0,96,.065);
return {fast,down,further,zero,overshoot,cap:NATIVE_METER_FRAME_MS,
nativeTarget:typeof window.__arMixSetNativeMeterTarget,
stats:typeof window.__arMixMeterMotionStats};
}""")
assert ballistic['cap']>=34 and ballistic['nativeTarget']=='function',ballistic
assert ballistic['fast']['level']>80 and ballistic['fast']['level']<=96,ballistic
assert 94<ballistic['down']['level']<96,ballistic
assert ballistic['down']['velocity']<ballistic['further']['velocity'],ballistic
assert ballistic['further']['level']<ballistic['down']['level'],ballistic
assert ballistic['zero']=={'level':8,'velocity':0},ballistic
assert ballistic['overshoot']['level']==0,ballistic
# Full mixer rebuild must restore held peaks and clip state on fresh DOM nodes.
restored=await page.evaluate("""()=>{
clipLatch['0']=true;
Expand Down
87 changes: 87 additions & 0 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,93 @@ function setLedMeterLevel(el,rawLevel){
}
}
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 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,fallVelocity,dt){
const span=Math.max(0,Math.min(.065,Number(dt)||0));
if(target>level){
// About 85% of an upward step in 34ms; almost immediate at real speech peaks.
const v=level+(target-level)*(1-Math.exp(-span/.018));
return {level:target-v<.3?target:v,velocity:0};
}
if(target<level){
// Gravity-like release: gentle initial descent, time-based acceleration,
// capped terminal speed. Never overshoot, even with irregular UI callbacks.
const speed=Math.min(100,Math.max(14,fallVelocity)+230*span);
const next=Math.max(target,level-speed*span);
return {level:next-target<.3?target:next,velocity:next===target?0:speed};
}
return {level:target,velocity:0};
}
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;}
const next=nativeMeterStep(s.level,s.target,s.velocity,dt);
s.level=next.level;s.velocity=next.velocity;
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,velocity: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;s.velocity=0;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;s.velocity=0;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(()=>{
Expand Down
Loading
Loading