feat: add physically explicit narrowband MUSIC
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user