feat: add comparable localization algorithms
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
* Flat buffer layouts:
|
||||
* spectrum: [bin][frame][microphone][real, imaginary]
|
||||
* distances: [point][microphone]
|
||||
* calibration: [microphone][inverse sensitivity gain, phase offset radians]
|
||||
* calibration: [microphone][inverse sensitivity gain or unity, phase offset radians]
|
||||
* steering: [bin][point][microphone][real, imaginary]
|
||||
* output: [bin][point]
|
||||
*/
|
||||
@@ -197,9 +197,13 @@ export function packDasCalibration(calibration) {
|
||||
return packed;
|
||||
}
|
||||
|
||||
/** Convert array-definition microphone metadata to the shader calibration layout. */
|
||||
export function packMicrophoneCalibration(microphones) {
|
||||
/**
|
||||
* Convert array-definition microphone metadata to the shader calibration layout.
|
||||
* Phase-only algorithms set includeAmplitude=false while retaining phase offsets.
|
||||
*/
|
||||
export function packMicrophoneCalibration(microphones, options = {}) {
|
||||
if (!Array.isArray(microphones)) throw new TypeError("microphones must be an array.");
|
||||
const includeAmplitude = options.includeAmplitude !== false;
|
||||
const packed = new Float32Array(microphones.length * 2);
|
||||
for (let index = 0; index < microphones.length; index += 1) {
|
||||
const microphone = microphones[index];
|
||||
@@ -213,7 +217,7 @@ export function packMicrophoneCalibration(microphones) {
|
||||
);
|
||||
packed[index * 2] = requireFiniteF32(
|
||||
`microphones[${index}] inverse sensitivity gain`,
|
||||
10 ** (-sensitivityDb / 20),
|
||||
includeAmplitude ? 10 ** (-sensitivityDb / 20) : 1,
|
||||
);
|
||||
packed[index * 2 + 1] = requireFiniteF32(
|
||||
`microphones[${index}] phase offset`,
|
||||
|
||||
Reference in New Issue
Block a user