NOAA APT decoder and encoder (browser, no build step)

Decoder: streaming APT.Decoder (coherent PLL or envelope demod, sync A+B
tracking loop with coasting and timing-jump re-lock), telemetry analysis,
Q-gated impulse (FM click) repair. GUI with fast / realtime decode,
Listen, live input, telemetry table, markers.

Encoder: APT.Encoder with test impairments (noise, clicks, clock offset,
fading, line-timing jump); encoder dialog that feeds the decoder.

Tools: offline decode/encode, quality survey, stub-DOM GUI smoke test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
zefieandClaude Opus 5.5 committed 2026-12-03 20:58:22 -05:00
commit 4bc15bb585
12 files changed
+3375

No files matched your search

+51
View File
@@ -0,0 +1,51 @@
/*
* node tools/survey.js file.wav [...] - per-recording quality figures without
* a reference image: lock %, median sync, and noise = mean within-line std of
* the Space A / Space B words (flat in a clean signal) over the sync contrast.
*/
'use strict';
const fs = require('fs');
const path = require('path');
const APT = require(path.join(__dirname, '..', 'apt.js'));
const Wav = require(path.join(__dirname, '..', 'wav.js'));
function Std(w, a, b)
{
let s = 0, s2 = 0;
for (let k = a; k < b; k++) { s += w[k]; s2 += w[k] * w[k]; }
const n = b - a, m = s / n;
return Math.sqrt(Math.max(0, s2 / n - m * m));
}
function Survey(file, opts)
{
const w = Wav.Parse(fs.readFileSync(file));
const lines = [];
const dec = new APT.Decoder(w.rate, Object.assign({ onLine: (l) => lines.push(l) }, opts || {}));
for (let i = 0; i < w.data.length; i += 8192)
dec.process(w.data.subarray(i, i + 8192));
dec.flush();
let locked = 0, nz = [], sy = [];
for (const l of lines) {
sy.push(l.sync);
if (!l.locked || l.sync < 0.3)
continue;
locked++;
const c = l.hi - l.lo;
if (c <= 0)
continue;
nz.push(0.5 * (Std(l.words, 42, 84) + Std(l.words, 1082, 1124)) / c);
}
const med = (a) => { if (!a.length) return NaN; a.sort((x, y) => x - y); return a[a.length >> 1]; };
return { file: path.basename(file), rate: w.rate, lines: lines.length,
lock: locked / Math.max(1, lines.length), sync: med(sy), noise: med(nz) };
}
module.exports = Survey;
if (require.main === module)
for (const f of process.argv.slice(2)) {
try {
const r = Survey(f);
console.log(`${r.noise.toFixed(4)}\t${r.sync.toFixed(3)}\t${(r.lock * 100).toFixed(0)}%\t${r.lines}\t${r.rate}\t${r.file}`);
} catch (e) { console.log(`ERR\t${path.basename(f)}\t${e.message}`); }
}