jenkins af45190bfb bstein: serve the phone sound source and 30-minute RCT microphone detector
Vendor the web assets from Lesavka a5758755. The RCT browser performs signal recognition and sends numeric observations through the existing receipt service.
2026-12-03 12:11:53 -06:00

24 lines
1.1 KiB
JavaScript

// Every ordered pair in the repeating marker sequence occurs once. This lets
// a receiver joining mid-cycle identify position without synchronized clocks.
export const ANCHOR_HZ = 900;
export const MARKERS_HZ = [1400, 1800, 2200, 2600];
export const ORDER = [0,1,0,2,0,3,1,2,1,3,2,3];
export const SYMBOL_SECONDS = 0.1;
export const TRIAL_SECONDS = 30 * 60;
export const SOURCE_SECONDS = TRIAL_SECONDS + 120;
export function referenceLoop(rate) {
const data = new Float32Array(Math.round(rate * SYMBOL_SECONDS * ORDER.length));
for (let i = 0; i < data.length; i++) {
const t = i / rate;
const slot = Math.min(ORDER.length - 1, Math.floor(i * ORDER.length / data.length));
const tone = MARKERS_HZ[ORDER[slot]];
const oldTone = MARKERS_HZ[ORDER[(slot + ORDER.length - 1) % ORDER.length]];
const fade = Math.min(1, Math.max(0, (t - slot * SYMBOL_SECONDS) / 0.004));
const phase = 2 * Math.PI * t;
data[i] = 0.15 * Math.sin(phase * ANCHOR_HZ) +
0.15 * (fade * Math.sin(phase * tone) + (1 - fade) * Math.sin(phase * oldTone));
}
return data;
}