Correct goniometer transport and correlation meter

This commit is contained in:
Mikei386
2026-07-21 20:06:47 +02:00
parent 91aeccb938
commit 54f0f7a450
12 changed files with 297 additions and 80 deletions
+31
View File
@@ -0,0 +1,31 @@
import assert from 'node:assert/strict';
import fs from 'node:fs';
import vm from 'node:vm';
const source = fs.readFileSync(new URL('../www/views/goniometer_rtw.js', import.meta.url), 'utf8');
const functionSource = source.match(/export function resolveGoniometerPersistenceMs[\s\S]*?\n\}/)?.[0];
assert.ok(functionSource, 'persistence resolver must remain testable');
const context = vm.createContext({ Number, String, Math });
vm.runInContext(functionSource.replace('export function', 'function'), context);
assert.equal(context.resolveGoniometerPersistenceMs({ GONIO_PERSISTENCE_MODE: 'fast' }), 50);
assert.equal(context.resolveGoniometerPersistenceMs({ GONIO_PERSISTENCE_MODE: 'medium' }), 150);
assert.equal(context.resolveGoniometerPersistenceMs({ GONIO_PERSISTENCE_MODE: 'slow' }), 300);
assert.equal(context.resolveGoniometerPersistenceMs({
GONIO_PERSISTENCE_MODE: 'custom',
GONIO_LINE_FADE_MS: 470,
}), 470);
assert.equal(context.resolveGoniometerPersistenceMs({
GONIO_PERSISTENCE_MODE: 'custom',
GONIO_LINE_FADE_MS: 900,
}), 600);
assert.match(source, /Math\.min\(targetPoints, total, MAX_TRACE_POINTS\)/,
'drawing must not upsample invented XY points');
assert.match(source, /while \(trails\.length >= MAX_TRAIL_FRAMES\)/,
'trail history must remain bounded');
assert.match(source, /pool\.pop\(\)/, 'trail buffers must be reused');
assert.doesNotMatch(source, /utils\.correlation\(/,
'browser must not recalculate or smooth backend correlation');
console.log('goniometer regression tests passed');
+6
View File
@@ -19,12 +19,18 @@ const forced = context.buildRtaRuntimeConfig({
RTA_BPO_MODE: '1_12',
RTA_FREQ_RANGE: 'lf',
RTA_IIR_ORDER: 2,
CORR_RESPONSE_S: 2.5,
CORR_RESET_TOKEN: 7,
XY_POINTS: 256,
});
assert.equal(forced.engine, 'iir');
assert.equal(forced.bpo, '1_3');
assert.equal(forced.freqRange, 'norm');
assert.equal(forced.order, 6);
assert.equal(forced.rtwCenters.length, 31);
assert.equal(forced.correlationResponseS, 2.5);
assert.equal(forced.correlationResetToken, 7);
assert.equal(forced.xyPoints, 256);
const extension = context.buildRtaRuntimeConfig({
RTA_BAR_LAYOUT: 'iec',