Improve phase trail and correlation controls

This commit is contained in:
Mikei386
2026-07-27 18:13:07 +02:00
parent 00fb59f643
commit a4fa0ceb47
13 changed files with 268 additions and 41 deletions
+21 -1
View File
@@ -5,10 +5,26 @@ import { getRtwCenters } from '../www/core/rtw_centers.js';
import { buildRtwTickPositions, selectLocalRtwPacket } from '../www/views/realtime.js';
const source = fs.readFileSync(new URL('../www/core/audio.js', import.meta.url), 'utf8');
const configSource = fs.readFileSync(new URL('../www/core/config.js', import.meta.url), 'utf8');
const correlationNormalizerSource = configSource.match(
/export function normalizeCorrelationResponseSeconds[\s\S]*?\n\}/,
)?.[0];
assert.ok(correlationNormalizerSource, 'correlation response normalization must remain testable');
const correlationContext = vm.createContext({ Number });
vm.runInContext(
correlationNormalizerSource.replace('export function', 'function'),
correlationContext,
);
assert.equal(correlationContext.normalizeCorrelationResponseSeconds(0.5), 0.5);
assert.equal(correlationContext.normalizeCorrelationResponseSeconds(1.0), 1.0);
assert.equal(correlationContext.normalizeCorrelationResponseSeconds(2.5), 2.5);
assert.equal(correlationContext.normalizeCorrelationResponseSeconds(Number.NaN), 1.0);
const functionSource = source.match(/export function buildRtaRuntimeConfig[\s\S]*?\n\}/)?.[0];
assert.ok(functionSource, 'buildRtaRuntimeConfig must remain testable');
const context = vm.createContext({
Number,
normalizeCorrelationResponseSeconds: correlationContext.normalizeCorrelationResponseSeconds,
getRtwCenters(mode) {
if (mode === '1_12') return new Array(121).fill(0);
if (mode === '1_6') return new Array(61).fill(0);
@@ -29,6 +45,7 @@ const forced = context.buildRtaRuntimeConfig({
RTA_PEAK_DECAY_DB_PER_S: 20,
RTA_PEAK_RESET_TOKEN: 9,
CORR_RESPONSE_S: 2.5,
CORR_SILENCE_THRESHOLD_RMS_DBFS: -50,
CORR_RESET_TOKEN: 7,
XY_POINTS: 256,
});
@@ -44,9 +61,13 @@ assert.equal(forced.rtaPeakResetToken, 9);
assert.equal(forced.tauFast, 0.125);
assert.equal(forced.rtwCenters.length, 121);
assert.equal(forced.correlationResponseS, 2.5);
assert.equal(forced.correlationSilenceThresholdRmsDbfs, -50);
assert.equal(forced.correlationResetToken, 7);
assert.equal(forced.xyPoints, 256);
const veryFastCorrelation = context.buildRtaRuntimeConfig({ CORR_RESPONSE_S: 0.5 });
assert.equal(veryFastCorrelation.correlationResponseS, 0.5);
const extension = context.buildRtaRuntimeConfig({
RTA_BAR_LAYOUT: 'iec',
RTA_ENGINE: 'fft',
@@ -59,7 +80,6 @@ assert.equal(extension.bpo, '1_12');
assert.equal(extension.freqRange, 'lf');
assert.equal(extension.order, 8);
const configSource = fs.readFileSync(new URL('../www/core/config.js', import.meta.url), 'utf8');
const selectionSource = configSource.match(/function applyRtaBpoSelection[\s\S]*?\n\}/)?.[0];
assert.ok(selectionSource, 'RTA BPO selection policy must remain testable');
const selectionContext = vm.createContext({