feat: implement free-field CPU beamforming
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { computeDasMap } from "/packages/acoustics-core/das.js";
|
||||
import { distance3 } from "/packages/acoustics-core/math.js";
|
||||
import { synthesizeMicrophoneSignals } from "/packages/acoustics-core/propagation.js";
|
||||
|
||||
async function loadJson(path) {
|
||||
const response = await fetch(path);
|
||||
assert(response.ok, `${path} load failed`);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
test("192채널 · 50×50 CPU baseline이 ground truth를 찾는다", async () => {
|
||||
const [arrayDefinition, scene, experiment] = await Promise.all([
|
||||
loadJson("/assets/array-geometries/rectangular-16x12.array.json"),
|
||||
loadJson("/assets/sample-scenes/single-tone.scene.json"),
|
||||
loadJson("/assets/sample-scenes/single-tone.experiment.json"),
|
||||
]);
|
||||
const startedAt = performance.now();
|
||||
const synthesis = synthesizeMicrophoneSignals({ scene, arrayDefinition });
|
||||
const result = await computeDasMap({
|
||||
channels: synthesis.channels,
|
||||
sampleRate: synthesis.sampleRate,
|
||||
arrayDefinition,
|
||||
scene,
|
||||
experiment,
|
||||
});
|
||||
const elapsedMs = performance.now() - startedAt;
|
||||
const localizationError = distance3(result.bands[0].peak.position, scene.sources[0].position);
|
||||
|
||||
assertEqual(result.microphoneCount, 192, "microphone count");
|
||||
assertEqual(result.pointCount, 2500, "scan point count");
|
||||
assert(localizationError < 0.03, `localization error=${localizationError} m`);
|
||||
assert(Number.isFinite(result.bands[0].peak.rawPower) && result.bands[0].peak.rawPower > 0, "finite peak power");
|
||||
document.documentElement.dataset.cpuBaselineMs = elapsedMs.toFixed(1);
|
||||
});
|
||||
Reference in New Issue
Block a user