feat: add physically explicit narrowband MUSIC

This commit is contained in:
2026-08-29 12:40:48 +09:00
parent 044be3cf92
commit 11fee76280
40 changed files with 6473 additions and 275 deletions
+9 -8
View File
@@ -1,5 +1,6 @@
import { computeDasMap } from "../acoustics-core/das.js";
import { computeGccPhatMap } from "../acoustics-core/gcc-phat.js";
import { computeLocalizationMap } from "../acoustics-core/localization.js";
import {
isDasAlgorithm,
requireLocalizationAlgorithmDefinition,
@@ -79,9 +80,10 @@ export async function computeDasWithBackend(options, dependencies = {}) {
}
/**
* Execute any registered localization algorithm. GCC-PHAT currently uses its
* portable CPU implementation for both `auto` and `cpu`; an explicit WebGPU
* request is rejected instead of silently changing the requested backend.
* Execute any registered localization algorithm. CPU-only algorithms use
* their portable implementation for both `auto` and `cpu`; an explicit
* WebGPU request is rejected instead of silently changing the requested
* backend.
*/
export async function computeLocalizationWithBackend(options, dependencies = {}) {
const algorithm = requireLocalizationAlgorithmDefinition(
@@ -90,7 +92,7 @@ export async function computeLocalizationWithBackend(options, dependencies = {})
if (isDasAlgorithm(algorithm.id)) {
return computeDasBackend(options, dependencies);
}
if (algorithm.id !== "gcc-phat") {
if (algorithm.id !== "gcc-phat" && algorithm.id !== "music") {
throw new RangeError("No backend dispatcher is registered for " + algorithm.id + ".");
}
@@ -103,9 +105,8 @@ export async function computeLocalizationWithBackend(options, dependencies = {})
if (requestedBackend !== "auto" && requestedBackend !== "cpu") {
throw new TypeError(`unsupported localization backend: ${requestedBackend}`);
}
const computeCpu =
dependencies.computeGccCpu ??
dependencies.computeCpu ??
computeGccPhatMap;
const computeCpu = algorithm.id === "gcc-phat"
? dependencies.computeGccCpu ?? dependencies.computeCpu ?? computeGccPhatMap
: dependencies.computeMusicCpu ?? dependencies.computeCpu ?? computeLocalizationMap;
return computeCpu(options);
}