fix: expose physical aliasing and delayed arrivals

This commit is contained in:
2026-08-29 10:21:33 +09:00
parent e048ccbadc
commit de0053eae3
38 changed files with 3086 additions and 214 deletions
@@ -152,20 +152,18 @@ function copyScan(scan) {
return Object.freeze({ ...scan, columns, rows });
}
function copyBands(bands, sampleRate) {
function copyBands(bands) {
if (!Array.isArray(bands) || bands.length === 0) {
throw new TypeError("bands must be a non-empty array.");
}
const nyquist = sampleRate / 2;
return Object.freeze(bands.map((band, index) => {
if (
!Number.isFinite(band?.minHz) ||
!Number.isFinite(band?.maxHz) ||
band.minHz < 0 ||
band.maxHz <= band.minHz ||
band.maxHz >= nyquist
band.maxHz <= band.minHz
) {
throw new RangeError(`bands[${index}] must lie inside 0–${nyquist} Hz.`);
throw new RangeError(`bands[${index}] must satisfy 0 <= minHz < maxHz.`);
}
return Object.freeze({
...band,
@@ -285,7 +283,7 @@ export function createLocalizationPlan(config) {
const arrayDefinition = copyArrayDefinition(config.array ?? config.arrayDefinition);
const scan = copyScan(config.scan);
const peakDetection = copyPeakDetection(config.peakDetection, scan);
const frequencyBands = copyBands(config.bands ?? config.frequencyBands, sampleRate);
const frequencyBands = copyBands(config.bands ?? config.frequencyBands);
const fftSize = requirePowerOfTwo(config.stft?.fftSize ?? config.fftSize ?? 512, "fftSize");
const hopSize = requirePositiveInteger(
config.stft?.hopSize ?? config.stftHopSize ?? fftSize / 2,