diff --git a/AR-MIX-Live-FX-Host-Standalone-v0.3.html b/AR-MIX-Live-FX-Host-Standalone-v0.3.html index 0a7173964..300ad3dc3 100644 --- a/AR-MIX-Live-FX-Host-Standalone-v0.3.html +++ b/AR-MIX-Live-FX-Host-Standalone-v0.3.html @@ -1256,25 +1256,23 @@ // 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,fallVelocity,dt){ +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(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(targetlevel?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; @@ -1293,8 +1291,7 @@ 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; + s.level=nativeMeterStep(s.level,s.target,dt); setLedMeterLevel(el,s.level); nativeMeterMotionStats.meterPaintCalls++; if(Math.abs(s.level-s.target)>.3)active++; @@ -1312,14 +1309,14 @@ // 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); + 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;s.velocity=0;setLedMeterLevel(el,target); + s.level=target;setLedMeterLevel(el,target); return; } if(Math.abs(s.level-target)>.3)scheduleNativeMeterFrame(); @@ -1333,7 +1330,7 @@ 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); + s.level=s.target;setLedMeterLevel(el,s.level); } nativeMeterMotionStats.active=0; }); diff --git a/docs/ARD_056_NATIVE_METER_FAST_FALL_EASEOUT_2026-10-28.md b/docs/ARD_056_NATIVE_METER_FAST_FALL_EASEOUT_2026-10-28.md new file mode 100644 index 000000000..bc57ba4bd --- /dev/null +++ b/docs/ARD_056_NATIVE_METER_FAST_FALL_EASEOUT_2026-10-28.md @@ -0,0 +1,30 @@ +# ARD-056 P3 — Fast fall, smooth landing for real native peak LEDs +Base: main de683b001a5a1e5e050bc20ddb52d32b22fa58d1 (includes PR #104 real MASTER L/R visibility, PR #105 capture/dearVR fixes). Independent of open FX Reorder PR #102, GUI PR #97 and CI PR #101. Scope **only JavaScript native meter visual ballistics**. + +## Why the old motion felt wrong + +Old `nativeMeterStep(level,target,fallVelocity,dt)` started the downward velocity at 14 level-units/s, then **accelerated** at 230/s² until terminal 100/s. The first frames were almost static; speed grew *near the bottom*. Owner wants the opposite: immediate dramatic visual descent after a signal drops, with controlled slowing as LEDs approach the measured output. That is **ease-out**, colloquially 'reverse gravity', not true constant-gravity free fall. + +## Design choice + +One-pole exact exponential envelope in display level-percent space only: +`next = target + (display - target) * exp(-dt / tau)`. +Choose `tau=18ms` when audio target rises (attack); `tau=165ms` when target falls (release). Large initial display–target gaps produce the highest initial fall speed, and speed naturally decreases to zero. This preserves monotonic movement, never overshoots or bounces, and is nearly frame-rate invariant even on busy standard GPUs. Snap when the residual is less than 0.3 level units, below an LED cell. Clamp elapsed time to 65ms to prevent one big jump after scheduling stalls. + +At 34ms step for a 96→8% signal drop: `96 → 79.6 → 66.3 → 55.4 → 46.6 → 39.4 → 33.6`. Compare the old first step near 95.3%, after which it accelerates down. Transient attack from 8→96 reaches ~82.7% at the first 34ms step. These are pure envelope calculations, **not guaranteed observed GPU FPS or real peak measurement accuracy**. + +- Preserve existing 34ms shared timer + single rAF (~29.4 scheduled frames/s), no per-strip clocks. +- Scalar function returns a number instead of allocating `{level, velocity}` per meter per frame. Native states now store only `level,target`; no velocity integration or allocations. +- Keep `setLedMeterLevel()` discrete fixed 7px LED quantization and dirty-write suppression, stable green/amber/red palette, independent MASTER L/R, and actual native `peakLeft/peakRight` data; no fake animation source or generated sample. +- Preserve direct-mode `?metermotion=direct`, reduced-motion, tab hidden synchronization and detached DOM pruning. +- Do not touch JUCE C++ audio callback, 12Hz telemetry, Orbit, VST3 FX, master FX DSP truthfulness or BTN-180 skin. + +## Professional meter semantics and limits + +This is a **visual peak activity bar**, not a calibrated IEC Type I/II PPM, VU, LUFS/true peak meter or proof of inter-sample overs. A fast-decay decorative bar should not be used as a clip detector or numeric loudness measurement. Keep independent real peak/clip markers; future standalone instrument grade calibration can use a calibrated dB/s decay profile with selectable hold and true peak oversampling, driven by actual DSP measurements. No brightness/glow transitions or fake smooth continuous filled bar. + +## Deterministic acceptance + +Browser test covers attack/release ordering, rapid initial descent and monotonically shrinking fall steps, exact time-split equivalence (2×34ms vs 65+3ms), no overshoot, target equality, near-target snap, retarget on new transient, 65ms delta clamp, and shared 34ms scheduler contract. Node enforces numeric step owner/no velocity allocation. Standalone app.js embedded parity. Chromium+Firefox UI regression including native MASTER LED visibility; Windows MSVC CTest and package; postmerge CI exact main before artifact release. + +**Remaining physical gate:** Listen to actual routed audio and inspect CH1 vs MASTER L/R against true real signal on low-spec PC with FFT/audio loopback as available; compare `metermotion=direct` vs default for rendering feel and p95/p99 pointer frame intervals, note 12Hz telemetry itself can alias sub-83ms transients unless DSP holds peak per callback. This update does not promise validated metrology or real-world FPS. diff --git a/tests/gui_workflow_contract_test.mjs b/tests/gui_workflow_contract_test.mjs index 3728ccac6..61c668d19 100644 --- a/tests/gui_workflow_contract_test.mjs +++ b/tests/gui_workflow_contract_test.mjs @@ -69,6 +69,11 @@ 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('const NATIVE_METER_ATTACK_SECONDS=.018;')); + assert.ok(app.includes('const NATIVE_METER_RELEASE_SECONDS=.165;')); + assert.ok(app.includes('target+(level-target)*Math.exp(-span/tau)')); + assert.ok(!app.includes('fallVelocity') && !app.includes('s.velocity'), 'no frame-dependent acceleration state or per-meter velocity GC'); + assert.ok(app.includes('s.level=nativeMeterStep(s.level,s.target,dt)')); assert.ok(app.includes('function scheduleNativeMeterFrame(')); assert.ok(app.includes('if(nativeMeterTimer||nativeMeterRAF||document.hidden)return;')); assert.ok(app.includes("window.__arMixSetNativeMeterTarget=setNativeMeterTarget")); diff --git a/tests/ui_smoke.py b/tests/ui_smoke.py index b10e0273f..f81e576f4 100644 --- a/tests/ui_smoke.py +++ b/tests/ui_smoke.py @@ -130,25 +130,38 @@ 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. + # Fast rise + aggressive early fall + smooth exponential landing. + # Numerical envelope is frame-rate invariant, bounded and allocation-free. 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, + const fast=nativeMeterStep(8,96,.034); + const down=nativeMeterStep(96,8,.034); + const further=nativeMeterStep(down,8,.034); + const initialDrop=96-down,nextDrop=down-further; + const split=further; // two 34ms steps vs one 65ms plus 3ms + const mixed=nativeMeterStep(nativeMeterStep(96,8,.065),8,.003); + const zero=nativeMeterStep(8,8,.034); + const landing=nativeMeterStep(8.25,8,.034); + const noOvershoot=nativeMeterStep(2,0,.065); + const retarget=nativeMeterStep(down,99,.034); + const capped=nativeMeterStep(96,8,5); + const bounded=nativeMeterStep(96,8,.065); + return {fast,down,further,initialDrop,nextDrop,split,mixed,zero, + landing,noOvershoot,retarget,capped,bounded, + cap:NATIVE_METER_FRAME_MS,attack:NATIVE_METER_ATTACK_SECONDS, + release:NATIVE_METER_RELEASE_SECONDS, 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 94ballistic['nextDrop']>0,ballistic + assert abs(ballistic['split']-ballistic['mixed'])<1e-6,ballistic + assert ballistic['zero']==8 and ballistic['landing']==8,ballistic + assert 0<=ballistic['noOvershoot']<2,ballistic + assert ballistic['down']{ clipLatch['0']=true; diff --git a/web/app.js b/web/app.js index 281fe2aa7..3bf59497d 100644 --- a/web/app.js +++ b/web/app.js @@ -63,25 +63,23 @@ window.__arMixSetLedMeterLevel=setLedMeterLevel; // 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,fallVelocity,dt){ +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(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(targetlevel?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; @@ -100,8 +98,7 @@ function animateNativeMeters(now){ 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; + s.level=nativeMeterStep(s.level,s.target,dt); setLedMeterLevel(el,s.level); nativeMeterMotionStats.meterPaintCalls++; if(Math.abs(s.level-s.target)>.3)active++; @@ -119,14 +116,14 @@ function setNativeMeterTarget(el,rawValue){ // 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); + 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;s.velocity=0;setLedMeterLevel(el,target); + s.level=target;setLedMeterLevel(el,target); return; } if(Math.abs(s.level-target)>.3)scheduleNativeMeterFrame(); @@ -140,7 +137,7 @@ document.addEventListener('visibilitychange',()=>{ 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); + s.level=s.target;setLedMeterLevel(el,s.level); } nativeMeterMotionStats.active=0; });