@siteed/audio-studio 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1073 -414
- package/README.md +1 -1
- package/android/src/main/CMakeLists.txt +3 -0
- package/build/cjs/AudioAnalysis/audioFeaturesWasm.js +7 -155
- package/build/cjs/AudioAnalysis/audioFeaturesWasm.js.map +1 -1
- package/build/cjs/AudioAnalysis/audioFeaturesWasm.web.js +164 -0
- package/build/cjs/AudioAnalysis/audioFeaturesWasm.web.js.map +1 -0
- package/build/cjs/AudioAnalysis/melSpectrogramWasm.js +8 -140
- package/build/cjs/AudioAnalysis/melSpectrogramWasm.js.map +1 -1
- package/build/cjs/AudioAnalysis/melSpectrogramWasm.web.js +149 -0
- package/build/cjs/AudioAnalysis/melSpectrogramWasm.web.js.map +1 -0
- package/build/cjs/prebuilt/wasm/mel-spectrogram.js +18 -0
- package/build/esm/AudioAnalysis/audioFeaturesWasm.js +7 -122
- package/build/esm/AudioAnalysis/audioFeaturesWasm.js.map +1 -1
- package/build/esm/AudioAnalysis/audioFeaturesWasm.web.js +126 -0
- package/build/esm/AudioAnalysis/audioFeaturesWasm.web.js.map +1 -0
- package/build/esm/AudioAnalysis/melSpectrogramWasm.js +8 -107
- package/build/esm/AudioAnalysis/melSpectrogramWasm.js.map +1 -1
- package/build/esm/AudioAnalysis/melSpectrogramWasm.web.js +111 -0
- package/build/esm/AudioAnalysis/melSpectrogramWasm.web.js.map +1 -0
- package/build/esm/prebuilt/wasm/mel-spectrogram.js +18 -0
- package/build/types/AudioAnalysis/audioFeaturesWasm.d.ts +3 -15
- package/build/types/AudioAnalysis/audioFeaturesWasm.d.ts.map +1 -1
- package/build/types/AudioAnalysis/audioFeaturesWasm.web.d.ts +24 -0
- package/build/types/AudioAnalysis/audioFeaturesWasm.web.d.ts.map +1 -0
- package/build/types/AudioAnalysis/melSpectrogramWasm.d.ts +3 -15
- package/build/types/AudioAnalysis/melSpectrogramWasm.d.ts.map +1 -1
- package/build/types/AudioAnalysis/melSpectrogramWasm.web.d.ts +16 -0
- package/build/types/AudioAnalysis/melSpectrogramWasm.web.d.ts.map +1 -0
- package/package.json +3 -2
- package/src/AudioAnalysis/audioFeaturesWasm.ts +18 -179
- package/src/AudioAnalysis/audioFeaturesWasm.web.ts +200 -0
- package/src/AudioAnalysis/melSpectrogramWasm.ts +23 -169
- package/src/AudioAnalysis/melSpectrogramWasm.web.ts +179 -0
package/README.md
CHANGED
|
@@ -157,7 +157,7 @@ const trimmed = await trimAudio({
|
|
|
157
157
|
- [Getting Started Guide](https://deeeed.github.io/audiolab/docs/)
|
|
158
158
|
- [Contributing](./CONTRIBUTE.md)
|
|
159
159
|
- [AudioPlayground](https://deeeed.github.io/audiolab/playground) — live demo of all features
|
|
160
|
-
- [@siteed/
|
|
160
|
+
- [@siteed/audio-ui](https://github.com/deeeed/audiolab/tree/main/packages/audio-ui) — waveform, spectrogram, and audio control components
|
|
161
161
|
|
|
162
162
|
## License
|
|
163
163
|
|
|
@@ -1,164 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
2
|
+
// Native stub — WASM audio features is web-only.
|
|
35
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
4
|
exports.initAudioFeaturesWasm = initAudioFeaturesWasm;
|
|
37
5
|
exports.computeAudioFeaturesFrameWasm = computeAudioFeaturesFrameWasm;
|
|
38
6
|
exports.computeAudioFeaturesWasm = computeAudioFeaturesWasm;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!modulePromise) {
|
|
42
|
-
modulePromise = (async () => {
|
|
43
|
-
// Same WASM module as mel spectrogram (now includes audio features)
|
|
44
|
-
// @ts-expect-error -- prebuilt Emscripten JS glue has no .d.ts
|
|
45
|
-
const mod = await Promise.resolve().then(() => __importStar(require('../../prebuilt/wasm/mel-spectrogram.js')));
|
|
46
|
-
const factory = mod.default ?? mod;
|
|
47
|
-
return factory();
|
|
48
|
-
})().catch((err) => {
|
|
49
|
-
modulePromise = null;
|
|
50
|
-
throw err;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return modulePromise;
|
|
7
|
+
async function initAudioFeaturesWasm(_sampleRate, _fftLength, _nMfcc, _nMelFilters, _computeMfcc, _computeChroma) {
|
|
8
|
+
throw new Error('WASM audio features is not available on native');
|
|
54
9
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// Offset 4: float spectralFlatness (4 bytes)
|
|
58
|
-
// Offset 8: float spectralRolloff (4 bytes)
|
|
59
|
-
// Offset 12: float spectralBandwidth (4 bytes)
|
|
60
|
-
// Offset 16: float* mfcc (4 bytes pointer)
|
|
61
|
-
// Offset 20: int mfccCount (4 bytes)
|
|
62
|
-
// Offset 24: float* chromagram (4 bytes pointer)
|
|
63
|
-
// Offset 28: int chromagramCount (4 bytes)
|
|
64
|
-
const STRUCT_SIZE = 32;
|
|
65
|
-
function readResult(Module, ptr) {
|
|
66
|
-
const spectralCentroid = Module.getValue(ptr, 'float');
|
|
67
|
-
const spectralFlatness = Module.getValue(ptr + 4, 'float');
|
|
68
|
-
const spectralRolloff = Module.getValue(ptr + 8, 'float');
|
|
69
|
-
const spectralBandwidth = Module.getValue(ptr + 12, 'float');
|
|
70
|
-
const mfccPtr = Module.getValue(ptr + 16, 'i32');
|
|
71
|
-
const mfccCount = Module.getValue(ptr + 20, 'i32');
|
|
72
|
-
const chromaPtr = Module.getValue(ptr + 24, 'i32');
|
|
73
|
-
const chromaCount = Module.getValue(ptr + 28, 'i32');
|
|
74
|
-
const mfcc = [];
|
|
75
|
-
if (mfccPtr && mfccCount > 0) {
|
|
76
|
-
const offset = mfccPtr >> 2;
|
|
77
|
-
for (let i = 0; i < mfccCount; i++) {
|
|
78
|
-
mfcc.push(Module.HEAPF32[offset + i]);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
const chromagram = [];
|
|
82
|
-
if (chromaPtr && chromaCount > 0) {
|
|
83
|
-
const offset = chromaPtr >> 2;
|
|
84
|
-
for (let i = 0; i < chromaCount; i++) {
|
|
85
|
-
chromagram.push(Module.HEAPF32[offset + i]);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return {
|
|
89
|
-
spectralCentroid,
|
|
90
|
-
spectralFlatness,
|
|
91
|
-
spectralRolloff,
|
|
92
|
-
spectralBandwidth,
|
|
93
|
-
mfcc,
|
|
94
|
-
chromagram,
|
|
95
|
-
};
|
|
10
|
+
function computeAudioFeaturesFrameWasm(_samples) {
|
|
11
|
+
return null;
|
|
96
12
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
let streamingFramePtr = 0;
|
|
100
|
-
let streamingFrameCapacity = 0;
|
|
101
|
-
let streamingResultPtr = 0;
|
|
102
|
-
/**
|
|
103
|
-
* Initialise the WASM streaming audio features processor.
|
|
104
|
-
* Call once before computeAudioFeaturesFrameWasm().
|
|
105
|
-
*/
|
|
106
|
-
async function initAudioFeaturesWasm(sampleRate, fftLength = 1024, nMfcc = 13, nMelFilters = 26, computeMfcc = true, computeChroma = true) {
|
|
107
|
-
const Module = await getModule();
|
|
108
|
-
streamingModule = Module;
|
|
109
|
-
Module._audio_features_init(sampleRate, fftLength, nMfcc, nMelFilters, computeMfcc ? 1 : 0, computeChroma ? 1 : 0);
|
|
110
|
-
// Pre-allocate result struct on WASM heap
|
|
111
|
-
if (streamingResultPtr)
|
|
112
|
-
Module._free(streamingResultPtr);
|
|
113
|
-
streamingResultPtr = Module._malloc(STRUCT_SIZE);
|
|
114
|
-
// Zero-initialize to prevent freeing garbage pointers on first use
|
|
115
|
-
Module.HEAPU8.fill(0, streamingResultPtr, streamingResultPtr + STRUCT_SIZE);
|
|
116
|
-
// Frame input buffer allocated on demand
|
|
117
|
-
streamingFrameCapacity = 0;
|
|
118
|
-
streamingFramePtr = 0;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Compute audio features for a single frame via WASM C++.
|
|
122
|
-
* Returns null if not initialised or on error.
|
|
123
|
-
*/
|
|
124
|
-
function computeAudioFeaturesFrameWasm(samples) {
|
|
125
|
-
if (!streamingModule || !streamingResultPtr)
|
|
126
|
-
return null;
|
|
127
|
-
const Module = streamingModule;
|
|
128
|
-
// (Re-)allocate frame input buffer if needed
|
|
129
|
-
if (samples.length > streamingFrameCapacity) {
|
|
130
|
-
if (streamingFramePtr)
|
|
131
|
-
Module._free(streamingFramePtr);
|
|
132
|
-
streamingFramePtr = Module._malloc(samples.length * 4);
|
|
133
|
-
streamingFrameCapacity = samples.length;
|
|
134
|
-
}
|
|
135
|
-
// Copy samples to WASM heap
|
|
136
|
-
Module.HEAPF32.set(samples, streamingFramePtr >> 2);
|
|
137
|
-
const ok = Module._audio_features_compute_frame(streamingFramePtr, samples.length, streamingResultPtr);
|
|
138
|
-
if (!ok)
|
|
139
|
-
return null;
|
|
140
|
-
const result = readResult(Module, streamingResultPtr);
|
|
141
|
-
// Free internal arrays (mfcc, chromagram) allocated by C
|
|
142
|
-
Module._audio_features_free_arrays(streamingResultPtr);
|
|
143
|
-
return result;
|
|
144
|
-
}
|
|
145
|
-
// --- Batch API ---
|
|
146
|
-
/**
|
|
147
|
-
* Compute audio features for a buffer of samples via WASM C++.
|
|
148
|
-
* Lazy-loads the WASM module on first call.
|
|
149
|
-
*/
|
|
150
|
-
async function computeAudioFeaturesWasm(audioData, sampleRate, fftLength = 1024, nMfcc = 13, nMelFilters = 26, computeMfcc = true, computeChroma = true) {
|
|
151
|
-
const Module = await getModule();
|
|
152
|
-
const numSamples = audioData.length;
|
|
153
|
-
const inputPtr = Module._malloc(numSamples * 4);
|
|
154
|
-
Module.HEAPF32.set(audioData, inputPtr >> 2);
|
|
155
|
-
const resultPtr = Module._audio_features_compute(inputPtr, numSamples, sampleRate, fftLength, nMfcc, nMelFilters, computeMfcc ? 1 : 0, computeChroma ? 1 : 0);
|
|
156
|
-
Module._free(inputPtr);
|
|
157
|
-
if (resultPtr === 0) {
|
|
158
|
-
throw new Error('audio_features_compute returned null');
|
|
159
|
-
}
|
|
160
|
-
const result = readResult(Module, resultPtr);
|
|
161
|
-
Module._audio_features_free(resultPtr);
|
|
162
|
-
return result;
|
|
13
|
+
async function computeAudioFeaturesWasm(_audioData, _sampleRate, _fftLength, _nMfcc, _nMelFilters, _computeMfcc, _computeChroma) {
|
|
14
|
+
throw new Error('WASM audio features is not available on native');
|
|
163
15
|
}
|
|
164
16
|
//# sourceMappingURL=audioFeaturesWasm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audioFeaturesWasm.js","sourceRoot":"","sources":["../../../src/AudioAnalysis/audioFeaturesWasm.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,sDA6BC;AAMD,sEA6BC;AAQD,4DAoCC;AA5LD,IAAI,aAAa,GAA4C,IAAI,CAAA;AAEjE,SAAS,SAAS;IACd,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,aAAa,GAAG,CAAC,KAAK,IAAI,EAAE;YACxB,oEAAoE;YACpE,+DAA+D;YAC/D,MAAM,GAAG,GAAG,wDAAa,wCAAwC,GAAC,CAAA;YAClE,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,IAAI,GAAG,CAAA;YAClC,OAAO,OAAO,EAAsC,CAAA;QACxD,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACf,aAAa,GAAG,IAAI,CAAA;YACpB,MAAM,GAAG,CAAA;QACb,CAAC,CAAC,CAAA;IACN,CAAC;IACD,OAAO,aAAa,CAAA;AACxB,CAAC;AAED,0DAA0D;AAC1D,+CAA+C;AAC/C,+CAA+C;AAC/C,+CAA+C;AAC/C,+CAA+C;AAC/C,uDAAuD;AACvD,+CAA+C;AAC/C,uDAAuD;AACvD,+CAA+C;AAC/C,MAAM,WAAW,GAAG,EAAE,CAAA;AAEtB,SAAS,UAAU,CACf,MAA+B,EAC/B,GAAW;IAEX,MAAM,gBAAgB,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IACtD,MAAM,gBAAgB,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,GAAG,CAAC,EAAE,OAAO,CAAC,CAAA;IAC1D,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,GAAG,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ACV,SAAS,EACT,KAAK,EACL,WAAW,EACX,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACnB,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACxB,CAAA;IAED,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAEtB,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;IAC3D,CAAC;IAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAC5C,MAAM,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAA;IAEtC,OAAO,MAAM,CAAA;AACjB,CAAC","sourcesContent":["import type { AudioFeaturesWasmModule } from './audio-features-wasm'\n\nexport interface AudioFeaturesWasmResult {\n spectralCentroid: number\n spectralFlatness: number\n spectralRolloff: number\n spectralBandwidth: number\n mfcc: number[]\n chromagram: number[]\n}\n\nlet modulePromise: Promise<AudioFeaturesWasmModule> | null = null\n\nfunction getModule(): Promise<AudioFeaturesWasmModule> {\n if (!modulePromise) {\n modulePromise = (async () => {\n // Same WASM module as mel spectrogram (now includes audio features)\n // @ts-expect-error -- prebuilt Emscripten JS glue has no .d.ts\n const mod = await import('../../prebuilt/wasm/mel-spectrogram.js')\n const factory = mod.default ?? mod\n return factory() as Promise<AudioFeaturesWasmModule>\n })().catch((err) => {\n modulePromise = null\n throw err\n })\n }\n return modulePromise\n}\n\n// --- Struct layout for CAudioFeaturesResult (wasm32) ---\n// Offset 0: float spectralCentroid (4 bytes)\n// Offset 4: float spectralFlatness (4 bytes)\n// Offset 8: float spectralRolloff (4 bytes)\n// Offset 12: float spectralBandwidth (4 bytes)\n// Offset 16: float* mfcc (4 bytes pointer)\n// Offset 20: int mfccCount (4 bytes)\n// Offset 24: float* chromagram (4 bytes pointer)\n// Offset 28: int chromagramCount (4 bytes)\nconst STRUCT_SIZE = 32\n\nfunction readResult(\n Module: AudioFeaturesWasmModule,\n ptr: number\n): AudioFeaturesWasmResult {\n const spectralCentroid = Module.getValue(ptr, 'float')\n const spectralFlatness = Module.getValue(ptr + 4, 'float')\n const spectralRolloff = Module.getValue(ptr + 8, 'float')\n const spectralBandwidth = Module.getValue(ptr + 12, 'float')\n\n const mfccPtr = Module.getValue(ptr + 16, 'i32')\n const mfccCount = Module.getValue(ptr + 20, 'i32')\n const chromaPtr = Module.getValue(ptr + 24, 'i32')\n const chromaCount = Module.getValue(ptr + 28, 'i32')\n\n const mfcc: number[] = []\n if (mfccPtr && mfccCount > 0) {\n const offset = mfccPtr >> 2\n for (let i = 0; i < mfccCount; i++) {\n mfcc.push(Module.HEAPF32[offset + i])\n }\n }\n\n const chromagram: number[] = []\n if (chromaPtr && chromaCount > 0) {\n const offset = chromaPtr >> 2\n for (let i = 0; i < chromaCount; i++) {\n chromagram.push(Module.HEAPF32[offset + i])\n }\n }\n\n return {\n spectralCentroid,\n spectralFlatness,\n spectralRolloff,\n spectralBandwidth,\n mfcc,\n chromagram,\n }\n}\n\n// --- Streaming (per-frame) API ---\n\nlet streamingModule: AudioFeaturesWasmModule | null = null\nlet streamingFramePtr = 0\nlet streamingFrameCapacity = 0\nlet streamingResultPtr = 0\n\n/**\n * Initialise the WASM streaming audio features processor.\n * Call once before computeAudioFeaturesFrameWasm().\n */\nexport async function initAudioFeaturesWasm(\n sampleRate: number,\n fftLength = 1024,\n nMfcc = 13,\n nMelFilters = 26,\n computeMfcc = true,\n computeChroma = true\n): Promise<void> {\n const Module = await getModule()\n streamingModule = Module\n\n Module._audio_features_init(\n sampleRate,\n fftLength,\n nMfcc,\n nMelFilters,\n computeMfcc ? 1 : 0,\n computeChroma ? 1 : 0\n )\n\n // Pre-allocate result struct on WASM heap\n if (streamingResultPtr) Module._free(streamingResultPtr)\n streamingResultPtr = Module._malloc(STRUCT_SIZE)\n // Zero-initialize to prevent freeing garbage pointers on first use\n Module.HEAPU8.fill(0, streamingResultPtr, streamingResultPtr + STRUCT_SIZE)\n\n // Frame input buffer allocated on demand\n streamingFrameCapacity = 0\n streamingFramePtr = 0\n}\n\n/**\n * Compute audio features for a single frame via WASM C++.\n * Returns null if not initialised or on error.\n */\nexport function computeAudioFeaturesFrameWasm(\n samples: Float32Array\n): AudioFeaturesWasmResult | null {\n if (!streamingModule || !streamingResultPtr) return null\n const Module = streamingModule\n\n // (Re-)allocate frame input buffer if needed\n if (samples.length > streamingFrameCapacity) {\n if (streamingFramePtr) Module._free(streamingFramePtr)\n streamingFramePtr = Module._malloc(samples.length * 4)\n streamingFrameCapacity = samples.length\n }\n\n // Copy samples to WASM heap\n Module.HEAPF32.set(samples, streamingFramePtr >> 2)\n\n const ok = Module._audio_features_compute_frame(\n streamingFramePtr,\n samples.length,\n streamingResultPtr\n )\n if (!ok) return null\n\n const result = readResult(Module, streamingResultPtr)\n\n // Free internal arrays (mfcc, chromagram) allocated by C\n Module._audio_features_free_arrays(streamingResultPtr)\n\n return result\n}\n\n// --- Batch API ---\n\n/**\n * Compute audio features for a buffer of samples via WASM C++.\n * Lazy-loads the WASM module on first call.\n */\nexport async function computeAudioFeaturesWasm(\n audioData: Float32Array,\n sampleRate: number,\n fftLength = 1024,\n nMfcc = 13,\n nMelFilters = 26,\n computeMfcc = true,\n computeChroma = true\n): Promise<AudioFeaturesWasmResult> {\n const Module = await getModule()\n\n const numSamples = audioData.length\n const inputPtr = Module._malloc(numSamples * 4)\n Module.HEAPF32.set(audioData, inputPtr >> 2)\n\n const resultPtr = Module._audio_features_compute(\n inputPtr,\n numSamples,\n sampleRate,\n fftLength,\n nMfcc,\n nMelFilters,\n computeMfcc ? 1 : 0,\n computeChroma ? 1 : 0\n )\n\n Module._free(inputPtr)\n\n if (resultPtr === 0) {\n throw new Error('audio_features_compute returned null')\n }\n\n const result = readResult(Module, resultPtr)\n Module._audio_features_free(resultPtr)\n\n return result\n}\n"]}
|
|
1
|
+
{"version":3,"file":"audioFeaturesWasm.js","sourceRoot":"","sources":["../../../src/AudioAnalysis/audioFeaturesWasm.ts"],"names":[],"mappings":";AAAA,iDAAiD;;AAWjD,sDASC;AAED,sEAIC;AAED,4DAUC;AA3BM,KAAK,UAAU,qBAAqB,CACvC,WAAmB,EACnB,UAAmB,EACnB,MAAe,EACf,YAAqB,EACrB,YAAsB,EACtB,cAAwB;IAExB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAA;AACrE,CAAC;AAED,SAAgB,6BAA6B,CACzC,QAAsB;IAEtB,OAAO,IAAI,CAAA;AACf,CAAC;AAEM,KAAK,UAAU,wBAAwB,CAC1C,UAAwB,EACxB,WAAmB,EACnB,UAAmB,EACnB,MAAe,EACf,YAAqB,EACrB,YAAsB,EACtB,cAAwB;IAExB,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAA;AACrE,CAAC","sourcesContent":["// Native stub — WASM audio features is web-only.\n\nexport interface AudioFeaturesWasmResult {\n spectralCentroid: number\n spectralFlatness: number\n spectralRolloff: number\n spectralBandwidth: number\n mfcc: number[]\n chromagram: number[]\n}\n\nexport async function initAudioFeaturesWasm(\n _sampleRate: number,\n _fftLength?: number,\n _nMfcc?: number,\n _nMelFilters?: number,\n _computeMfcc?: boolean,\n _computeChroma?: boolean\n): Promise<void> {\n throw new Error('WASM audio features is not available on native')\n}\n\nexport function computeAudioFeaturesFrameWasm(\n _samples: Float32Array\n): AudioFeaturesWasmResult | null {\n return null\n}\n\nexport async function computeAudioFeaturesWasm(\n _audioData: Float32Array,\n _sampleRate: number,\n _fftLength?: number,\n _nMfcc?: number,\n _nMelFilters?: number,\n _computeMfcc?: boolean,\n _computeChroma?: boolean\n): Promise<AudioFeaturesWasmResult> {\n throw new Error('WASM audio features is not available on native')\n}\n"]}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.initAudioFeaturesWasm = initAudioFeaturesWasm;
|
|
37
|
+
exports.computeAudioFeaturesFrameWasm = computeAudioFeaturesFrameWasm;
|
|
38
|
+
exports.computeAudioFeaturesWasm = computeAudioFeaturesWasm;
|
|
39
|
+
let modulePromise = null;
|
|
40
|
+
function getModule() {
|
|
41
|
+
if (!modulePromise) {
|
|
42
|
+
modulePromise = (async () => {
|
|
43
|
+
// Same WASM module as mel spectrogram (now includes audio features)
|
|
44
|
+
// @ts-expect-error -- prebuilt Emscripten JS glue has no .d.ts
|
|
45
|
+
const mod = await Promise.resolve().then(() => __importStar(require('../../prebuilt/wasm/mel-spectrogram.js')));
|
|
46
|
+
const factory = mod.default ?? mod;
|
|
47
|
+
return factory();
|
|
48
|
+
})().catch((err) => {
|
|
49
|
+
modulePromise = null;
|
|
50
|
+
throw err;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return modulePromise;
|
|
54
|
+
}
|
|
55
|
+
// --- Struct layout for CAudioFeaturesResult (wasm32) ---
|
|
56
|
+
// Offset 0: float spectralCentroid (4 bytes)
|
|
57
|
+
// Offset 4: float spectralFlatness (4 bytes)
|
|
58
|
+
// Offset 8: float spectralRolloff (4 bytes)
|
|
59
|
+
// Offset 12: float spectralBandwidth (4 bytes)
|
|
60
|
+
// Offset 16: float* mfcc (4 bytes pointer)
|
|
61
|
+
// Offset 20: int mfccCount (4 bytes)
|
|
62
|
+
// Offset 24: float* chromagram (4 bytes pointer)
|
|
63
|
+
// Offset 28: int chromagramCount (4 bytes)
|
|
64
|
+
const STRUCT_SIZE = 32;
|
|
65
|
+
function readResult(Module, ptr) {
|
|
66
|
+
const spectralCentroid = Module.getValue(ptr, 'float');
|
|
67
|
+
const spectralFlatness = Module.getValue(ptr + 4, 'float');
|
|
68
|
+
const spectralRolloff = Module.getValue(ptr + 8, 'float');
|
|
69
|
+
const spectralBandwidth = Module.getValue(ptr + 12, 'float');
|
|
70
|
+
const mfccPtr = Module.getValue(ptr + 16, 'i32');
|
|
71
|
+
const mfccCount = Module.getValue(ptr + 20, 'i32');
|
|
72
|
+
const chromaPtr = Module.getValue(ptr + 24, 'i32');
|
|
73
|
+
const chromaCount = Module.getValue(ptr + 28, 'i32');
|
|
74
|
+
const mfcc = [];
|
|
75
|
+
if (mfccPtr && mfccCount > 0) {
|
|
76
|
+
const offset = mfccPtr >> 2;
|
|
77
|
+
for (let i = 0; i < mfccCount; i++) {
|
|
78
|
+
mfcc.push(Module.HEAPF32[offset + i]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const chromagram = [];
|
|
82
|
+
if (chromaPtr && chromaCount > 0) {
|
|
83
|
+
const offset = chromaPtr >> 2;
|
|
84
|
+
for (let i = 0; i < chromaCount; i++) {
|
|
85
|
+
chromagram.push(Module.HEAPF32[offset + i]);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
spectralCentroid,
|
|
90
|
+
spectralFlatness,
|
|
91
|
+
spectralRolloff,
|
|
92
|
+
spectralBandwidth,
|
|
93
|
+
mfcc,
|
|
94
|
+
chromagram,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// --- Streaming (per-frame) API ---
|
|
98
|
+
let streamingModule = null;
|
|
99
|
+
let streamingFramePtr = 0;
|
|
100
|
+
let streamingFrameCapacity = 0;
|
|
101
|
+
let streamingResultPtr = 0;
|
|
102
|
+
/**
|
|
103
|
+
* Initialise the WASM streaming audio features processor.
|
|
104
|
+
* Call once before computeAudioFeaturesFrameWasm().
|
|
105
|
+
*/
|
|
106
|
+
async function initAudioFeaturesWasm(sampleRate, fftLength = 1024, nMfcc = 13, nMelFilters = 26, computeMfcc = true, computeChroma = true) {
|
|
107
|
+
const Module = await getModule();
|
|
108
|
+
streamingModule = Module;
|
|
109
|
+
Module._audio_features_init(sampleRate, fftLength, nMfcc, nMelFilters, computeMfcc ? 1 : 0, computeChroma ? 1 : 0);
|
|
110
|
+
// Pre-allocate result struct on WASM heap
|
|
111
|
+
if (streamingResultPtr)
|
|
112
|
+
Module._free(streamingResultPtr);
|
|
113
|
+
streamingResultPtr = Module._malloc(STRUCT_SIZE);
|
|
114
|
+
// Zero-initialize to prevent freeing garbage pointers on first use
|
|
115
|
+
Module.HEAPU8.fill(0, streamingResultPtr, streamingResultPtr + STRUCT_SIZE);
|
|
116
|
+
// Frame input buffer allocated on demand
|
|
117
|
+
streamingFrameCapacity = 0;
|
|
118
|
+
streamingFramePtr = 0;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Compute audio features for a single frame via WASM C++.
|
|
122
|
+
* Returns null if not initialised or on error.
|
|
123
|
+
*/
|
|
124
|
+
function computeAudioFeaturesFrameWasm(samples) {
|
|
125
|
+
if (!streamingModule || !streamingResultPtr)
|
|
126
|
+
return null;
|
|
127
|
+
const Module = streamingModule;
|
|
128
|
+
// (Re-)allocate frame input buffer if needed
|
|
129
|
+
if (samples.length > streamingFrameCapacity) {
|
|
130
|
+
if (streamingFramePtr)
|
|
131
|
+
Module._free(streamingFramePtr);
|
|
132
|
+
streamingFramePtr = Module._malloc(samples.length * 4);
|
|
133
|
+
streamingFrameCapacity = samples.length;
|
|
134
|
+
}
|
|
135
|
+
// Copy samples to WASM heap
|
|
136
|
+
Module.HEAPF32.set(samples, streamingFramePtr >> 2);
|
|
137
|
+
const ok = Module._audio_features_compute_frame(streamingFramePtr, samples.length, streamingResultPtr);
|
|
138
|
+
if (!ok)
|
|
139
|
+
return null;
|
|
140
|
+
const result = readResult(Module, streamingResultPtr);
|
|
141
|
+
// Free internal arrays (mfcc, chromagram) allocated by C
|
|
142
|
+
Module._audio_features_free_arrays(streamingResultPtr);
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
// --- Batch API ---
|
|
146
|
+
/**
|
|
147
|
+
* Compute audio features for a buffer of samples via WASM C++.
|
|
148
|
+
* Lazy-loads the WASM module on first call.
|
|
149
|
+
*/
|
|
150
|
+
async function computeAudioFeaturesWasm(audioData, sampleRate, fftLength = 1024, nMfcc = 13, nMelFilters = 26, computeMfcc = true, computeChroma = true) {
|
|
151
|
+
const Module = await getModule();
|
|
152
|
+
const numSamples = audioData.length;
|
|
153
|
+
const inputPtr = Module._malloc(numSamples * 4);
|
|
154
|
+
Module.HEAPF32.set(audioData, inputPtr >> 2);
|
|
155
|
+
const resultPtr = Module._audio_features_compute(inputPtr, numSamples, sampleRate, fftLength, nMfcc, nMelFilters, computeMfcc ? 1 : 0, computeChroma ? 1 : 0);
|
|
156
|
+
Module._free(inputPtr);
|
|
157
|
+
if (resultPtr === 0) {
|
|
158
|
+
throw new Error('audio_features_compute returned null');
|
|
159
|
+
}
|
|
160
|
+
const result = readResult(Module, resultPtr);
|
|
161
|
+
Module._audio_features_free(resultPtr);
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=audioFeaturesWasm.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audioFeaturesWasm.web.js","sourceRoot":"","sources":["../../../src/AudioAnalysis/audioFeaturesWasm.web.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2FA,sDA6BC;AAMD,sEA6BC;AAQD,4DAoCC;AA5LD,IAAI,aAAa,GAA4C,IAAI,CAAA;AAEjE,SAAS,SAAS;IACd,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,aAAa,GAAG,CAAC,KAAK,IAAI,EAAE;YACxB,oEAAoE;YACpE,+DAA+D;YAC/D,MAAM,GAAG,GAAG,wDAAa,wCAAwC,GAAC,CAAA;YAClE,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,IAAI,GAAG,CAAA;YAClC,OAAO,OAAO,EAAsC,CAAA;QACxD,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACf,aAAa,GAAG,IAAI,CAAA;YACpB,MAAM,GAAG,CAAA;QACb,CAAC,CAAC,CAAA;IACN,CAAC;IACD,OAAO,aAAa,CAAA;AACxB,CAAC;AAED,0DAA0D;AAC1D,+CAA+C;AAC/C,+CAA+C;AAC/C,+CAA+C;AAC/C,+CAA+C;AAC/C,uDAAuD;AACvD,+CAA+C;AAC/C,uDAAuD;AACvD,+CAA+C;AAC/C,MAAM,WAAW,GAAG,EAAE,CAAA;AAEtB,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G,SAAS,CAAC,MAAM,CAAA;IACnC,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,CAAC,CAAC,CAAA;IAC/C,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,IAAI,CAAC,CAAC,CAAA;IAE5C,MAAM,SAAS,GAAG,MAAM,CAAC,uBAAuB,CAC5C,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,EACT,KAAK,EACL,WAAW,EACX,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACnB,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CACxB,CAAA;IAED,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAEtB,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;IAC3D,CAAC;IAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAC5C,MAAM,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAA;IAEtC,OAAO,MAAM,CAAA;AACjB,CAAC","sourcesContent":["import type { AudioFeaturesWasmModule } from './audio-features-wasm'\n\nexport interface AudioFeaturesWasmResult {\n spectralCentroid: number\n spectralFlatness: number\n spectralRolloff: number\n spectralBandwidth: number\n mfcc: number[]\n chromagram: number[]\n}\n\nlet modulePromise: Promise<AudioFeaturesWasmModule> | null = null\n\nfunction getModule(): Promise<AudioFeaturesWasmModule> {\n if (!modulePromise) {\n modulePromise = (async () => {\n // Same WASM module as mel spectrogram (now includes audio features)\n // @ts-expect-error -- prebuilt Emscripten JS glue has no .d.ts\n const mod = await import('../../prebuilt/wasm/mel-spectrogram.js')\n const factory = mod.default ?? mod\n return factory() as Promise<AudioFeaturesWasmModule>\n })().catch((err) => {\n modulePromise = null\n throw err\n })\n }\n return modulePromise\n}\n\n// --- Struct layout for CAudioFeaturesResult (wasm32) ---\n// Offset 0: float spectralCentroid (4 bytes)\n// Offset 4: float spectralFlatness (4 bytes)\n// Offset 8: float spectralRolloff (4 bytes)\n// Offset 12: float spectralBandwidth (4 bytes)\n// Offset 16: float* mfcc (4 bytes pointer)\n// Offset 20: int mfccCount (4 bytes)\n// Offset 24: float* chromagram (4 bytes pointer)\n// Offset 28: int chromagramCount (4 bytes)\nconst STRUCT_SIZE = 32\n\nfunction readResult(\n Module: AudioFeaturesWasmModule,\n ptr: number\n): AudioFeaturesWasmResult {\n const spectralCentroid = Module.getValue(ptr, 'float')\n const spectralFlatness = Module.getValue(ptr + 4, 'float')\n const spectralRolloff = Module.getValue(ptr + 8, 'float')\n const spectralBandwidth = Module.getValue(ptr + 12, 'float')\n\n const mfccPtr = Module.getValue(ptr + 16, 'i32')\n const mfccCount = Module.getValue(ptr + 20, 'i32')\n const chromaPtr = Module.getValue(ptr + 24, 'i32')\n const chromaCount = Module.getValue(ptr + 28, 'i32')\n\n const mfcc: number[] = []\n if (mfccPtr && mfccCount > 0) {\n const offset = mfccPtr >> 2\n for (let i = 0; i < mfccCount; i++) {\n mfcc.push(Module.HEAPF32[offset + i])\n }\n }\n\n const chromagram: number[] = []\n if (chromaPtr && chromaCount > 0) {\n const offset = chromaPtr >> 2\n for (let i = 0; i < chromaCount; i++) {\n chromagram.push(Module.HEAPF32[offset + i])\n }\n }\n\n return {\n spectralCentroid,\n spectralFlatness,\n spectralRolloff,\n spectralBandwidth,\n mfcc,\n chromagram,\n }\n}\n\n// --- Streaming (per-frame) API ---\n\nlet streamingModule: AudioFeaturesWasmModule | null = null\nlet streamingFramePtr = 0\nlet streamingFrameCapacity = 0\nlet streamingResultPtr = 0\n\n/**\n * Initialise the WASM streaming audio features processor.\n * Call once before computeAudioFeaturesFrameWasm().\n */\nexport async function initAudioFeaturesWasm(\n sampleRate: number,\n fftLength = 1024,\n nMfcc = 13,\n nMelFilters = 26,\n computeMfcc = true,\n computeChroma = true\n): Promise<void> {\n const Module = await getModule()\n streamingModule = Module\n\n Module._audio_features_init(\n sampleRate,\n fftLength,\n nMfcc,\n nMelFilters,\n computeMfcc ? 1 : 0,\n computeChroma ? 1 : 0\n )\n\n // Pre-allocate result struct on WASM heap\n if (streamingResultPtr) Module._free(streamingResultPtr)\n streamingResultPtr = Module._malloc(STRUCT_SIZE)\n // Zero-initialize to prevent freeing garbage pointers on first use\n Module.HEAPU8.fill(0, streamingResultPtr, streamingResultPtr + STRUCT_SIZE)\n\n // Frame input buffer allocated on demand\n streamingFrameCapacity = 0\n streamingFramePtr = 0\n}\n\n/**\n * Compute audio features for a single frame via WASM C++.\n * Returns null if not initialised or on error.\n */\nexport function computeAudioFeaturesFrameWasm(\n samples: Float32Array\n): AudioFeaturesWasmResult | null {\n if (!streamingModule || !streamingResultPtr) return null\n const Module = streamingModule\n\n // (Re-)allocate frame input buffer if needed\n if (samples.length > streamingFrameCapacity) {\n if (streamingFramePtr) Module._free(streamingFramePtr)\n streamingFramePtr = Module._malloc(samples.length * 4)\n streamingFrameCapacity = samples.length\n }\n\n // Copy samples to WASM heap\n Module.HEAPF32.set(samples, streamingFramePtr >> 2)\n\n const ok = Module._audio_features_compute_frame(\n streamingFramePtr,\n samples.length,\n streamingResultPtr\n )\n if (!ok) return null\n\n const result = readResult(Module, streamingResultPtr)\n\n // Free internal arrays (mfcc, chromagram) allocated by C\n Module._audio_features_free_arrays(streamingResultPtr)\n\n return result\n}\n\n// --- Batch API ---\n\n/**\n * Compute audio features for a buffer of samples via WASM C++.\n * Lazy-loads the WASM module on first call.\n */\nexport async function computeAudioFeaturesWasm(\n audioData: Float32Array,\n sampleRate: number,\n fftLength = 1024,\n nMfcc = 13,\n nMelFilters = 26,\n computeMfcc = true,\n computeChroma = true\n): Promise<AudioFeaturesWasmResult> {\n const Module = await getModule()\n\n const numSamples = audioData.length\n const inputPtr = Module._malloc(numSamples * 4)\n Module.HEAPF32.set(audioData, inputPtr >> 2)\n\n const resultPtr = Module._audio_features_compute(\n inputPtr,\n numSamples,\n sampleRate,\n fftLength,\n nMfcc,\n nMelFilters,\n computeMfcc ? 1 : 0,\n computeChroma ? 1 : 0\n )\n\n Module._free(inputPtr)\n\n if (resultPtr === 0) {\n throw new Error('audio_features_compute returned null')\n }\n\n const result = readResult(Module, resultPtr)\n Module._audio_features_free(resultPtr)\n\n return result\n}\n"]}
|
|
@@ -1,149 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
2
|
+
// Native stub — WASM mel spectrogram is web-only.
|
|
3
|
+
// These functions are only called in web contexts; on native, the C++ TurboModule handles mel spectrograms.
|
|
35
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
5
|
exports.initMelStreamingWasm = initMelStreamingWasm;
|
|
37
6
|
exports.computeMelFrameWasm = computeMelFrameWasm;
|
|
38
7
|
exports.computeMelSpectrogramWasm = computeMelSpectrogramWasm;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!modulePromise) {
|
|
42
|
-
modulePromise = (async () => {
|
|
43
|
-
// Dynamic import of the prebuilt SINGLE_FILE Emscripten module
|
|
44
|
-
// @ts-expect-error -- prebuilt Emscripten JS glue has no .d.ts
|
|
45
|
-
const mod = await Promise.resolve().then(() => __importStar(require('../../prebuilt/wasm/mel-spectrogram.js')));
|
|
46
|
-
const factory = mod.default ?? mod;
|
|
47
|
-
return factory();
|
|
48
|
-
})().catch((err) => {
|
|
49
|
-
modulePromise = null;
|
|
50
|
-
throw err;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return modulePromise;
|
|
8
|
+
async function initMelStreamingWasm(_sampleRate, _nMels, _fftLength, _windowSizeSamples, _hopLengthSamples, _fMin, _fMax) {
|
|
9
|
+
throw new Error('WASM mel spectrogram is not available on native');
|
|
54
10
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
let streamingNMels = 0;
|
|
58
|
-
let streamingFramePtr = 0;
|
|
59
|
-
let streamingMelPtr = 0;
|
|
60
|
-
let streamingFrameCapacity = 0;
|
|
61
|
-
/**
|
|
62
|
-
* Initialise the WASM streaming processor. Call once before computeMelFrame().
|
|
63
|
-
* Re-initialises only when config changes.
|
|
64
|
-
*/
|
|
65
|
-
async function initMelStreamingWasm(sampleRate, nMels = 128, fftLength = 2048, windowSizeSamples = 400, hopLengthSamples = 160, fMin = 0, fMax = 0) {
|
|
66
|
-
const Module = await getModule();
|
|
67
|
-
streamingModule = Module;
|
|
68
|
-
const actualFMax = fMax > 0 ? fMax : sampleRate / 2;
|
|
69
|
-
Module._mel_spectrogram_init(sampleRate, fftLength, windowSizeSamples, hopLengthSamples, nMels, fMin, actualFMax, 0 /* hann */);
|
|
70
|
-
streamingNMels = nMels;
|
|
71
|
-
// Pre-allocate output buffer (fixed size)
|
|
72
|
-
if (streamingMelPtr)
|
|
73
|
-
Module._free(streamingMelPtr);
|
|
74
|
-
streamingMelPtr = Module._malloc(nMels * 4);
|
|
75
|
-
// Frame input buffer allocated on demand in computeMelFrame
|
|
76
|
-
streamingFrameCapacity = 0;
|
|
77
|
-
streamingFramePtr = 0;
|
|
11
|
+
function computeMelFrameWasm(_samples) {
|
|
12
|
+
return null;
|
|
78
13
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
* Returns null if not initialised or on error.
|
|
82
|
-
*/
|
|
83
|
-
function computeMelFrameWasm(samples) {
|
|
84
|
-
if (!streamingModule || !streamingMelPtr)
|
|
85
|
-
return null;
|
|
86
|
-
const Module = streamingModule;
|
|
87
|
-
// (Re-)allocate frame input buffer if needed
|
|
88
|
-
if (samples.length > streamingFrameCapacity) {
|
|
89
|
-
if (streamingFramePtr)
|
|
90
|
-
Module._free(streamingFramePtr);
|
|
91
|
-
streamingFramePtr = Module._malloc(samples.length * 4);
|
|
92
|
-
streamingFrameCapacity = samples.length;
|
|
93
|
-
}
|
|
94
|
-
// Copy samples to WASM heap
|
|
95
|
-
Module.HEAPF32.set(samples, streamingFramePtr >> 2);
|
|
96
|
-
const ok = Module._mel_spectrogram_compute_frame(streamingFramePtr, samples.length, streamingMelPtr);
|
|
97
|
-
if (!ok)
|
|
98
|
-
return null;
|
|
99
|
-
// Read mel output from WASM heap
|
|
100
|
-
const offset = streamingMelPtr >> 2;
|
|
101
|
-
const result = new Array(streamingNMels);
|
|
102
|
-
for (let i = 0; i < streamingNMels; i++) {
|
|
103
|
-
result[i] = Module.HEAPF32[offset + i];
|
|
104
|
-
}
|
|
105
|
-
return result;
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Computes a mel spectrogram via the WASM-compiled C++ implementation.
|
|
109
|
-
* Lazy-loads the WASM module on first call.
|
|
110
|
-
*/
|
|
111
|
-
async function computeMelSpectrogramWasm(audioData, sampleRate, nMels, windowSizeSamples, hopLengthSamples, fMin, fMax, windowType, normalize, logScale) {
|
|
112
|
-
const Module = await getModule();
|
|
113
|
-
const fftLength = 2048;
|
|
114
|
-
const windowTypeInt = windowType === 'hamming' ? 1 : 0;
|
|
115
|
-
// Allocate input buffer on WASM heap
|
|
116
|
-
const numSamples = audioData.length;
|
|
117
|
-
const inputPtr = Module._malloc(numSamples * 4); // 4 bytes per float
|
|
118
|
-
Module.HEAPF32.set(audioData, inputPtr >> 2);
|
|
119
|
-
// Call the C bridge
|
|
120
|
-
const resultPtr = Module._mel_spectrogram_compute(inputPtr, numSamples, sampleRate, fftLength, windowSizeSamples, hopLengthSamples, nMels, fMin, fMax, windowTypeInt, logScale ? 1 : 0, normalize ? 1 : 0);
|
|
121
|
-
// Free input buffer
|
|
122
|
-
Module._free(inputPtr);
|
|
123
|
-
if (resultPtr === 0) {
|
|
124
|
-
throw new Error('mel_spectrogram_compute returned null (too few samples?)');
|
|
125
|
-
}
|
|
126
|
-
// Read CMelSpectrogramResult struct (wasm32 pointers are 4 bytes)
|
|
127
|
-
// struct layout: { float* data (offset 0), int timeSteps (offset 4), int nMels (offset 8) }
|
|
128
|
-
const dataPtr = Module.getValue(resultPtr, 'i32');
|
|
129
|
-
const timeSteps = Module.getValue(resultPtr + 4, 'i32');
|
|
130
|
-
const resultNMels = Module.getValue(resultPtr + 8, 'i32');
|
|
131
|
-
if (!dataPtr || timeSteps <= 0 || resultNMels <= 0) {
|
|
132
|
-
Module._mel_spectrogram_free(resultPtr);
|
|
133
|
-
throw new Error('mel_spectrogram_compute returned invalid result struct');
|
|
134
|
-
}
|
|
135
|
-
// Copy spectrogram data to JS arrays
|
|
136
|
-
const spectrogram = [];
|
|
137
|
-
const heapOffset = dataPtr >> 2; // float32 offset into HEAPF32
|
|
138
|
-
for (let t = 0; t < timeSteps; t++) {
|
|
139
|
-
const row = new Array(resultNMels);
|
|
140
|
-
for (let m = 0; m < resultNMels; m++) {
|
|
141
|
-
row[m] = Module.HEAPF32[heapOffset + t * resultNMels + m];
|
|
142
|
-
}
|
|
143
|
-
spectrogram.push(row);
|
|
144
|
-
}
|
|
145
|
-
// Free the C result
|
|
146
|
-
Module._mel_spectrogram_free(resultPtr);
|
|
147
|
-
return spectrogram;
|
|
14
|
+
async function computeMelSpectrogramWasm(_audioData, _sampleRate, _nMels, _windowSizeSamples, _hopLengthSamples, _fMin, _fMax, _windowType, _normalize, _logScale) {
|
|
15
|
+
throw new Error('WASM mel spectrogram is not available on native');
|
|
148
16
|
}
|
|
149
17
|
//# sourceMappingURL=melSpectrogramWasm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"melSpectrogramWasm.js","sourceRoot":"","sources":["../../../src/AudioAnalysis/melSpectrogramWasm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"melSpectrogramWasm.js","sourceRoot":"","sources":["../../../src/AudioAnalysis/melSpectrogramWasm.ts"],"names":[],"mappings":";AAAA,kDAAkD;AAClD,4GAA4G;;AAE5G,oDAUC;AAED,kDAEC;AAED,8DAaC;AA7BM,KAAK,UAAU,oBAAoB,CACtC,WAAmB,EACnB,MAAe,EACf,UAAmB,EACnB,kBAA2B,EAC3B,iBAA0B,EAC1B,KAAc,EACd,KAAc;IAEd,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;AACtE,CAAC;AAED,SAAgB,mBAAmB,CAAC,QAAsB;IACtD,OAAO,IAAI,CAAA;AACf,CAAC;AAEM,KAAK,UAAU,yBAAyB,CAC3C,UAAwB,EACxB,WAAmB,EACnB,MAAc,EACd,kBAA0B,EAC1B,iBAAyB,EACzB,KAAa,EACb,KAAa,EACb,WAA+B,EAC/B,UAAmB,EACnB,SAAkB;IAElB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;AACtE,CAAC","sourcesContent":["// Native stub — WASM mel spectrogram is web-only.\n// These functions are only called in web contexts; on native, the C++ TurboModule handles mel spectrograms.\n\nexport async function initMelStreamingWasm(\n _sampleRate: number,\n _nMels?: number,\n _fftLength?: number,\n _windowSizeSamples?: number,\n _hopLengthSamples?: number,\n _fMin?: number,\n _fMax?: number\n): Promise<void> {\n throw new Error('WASM mel spectrogram is not available on native')\n}\n\nexport function computeMelFrameWasm(_samples: Float32Array): number[] | null {\n return null\n}\n\nexport async function computeMelSpectrogramWasm(\n _audioData: Float32Array,\n _sampleRate: number,\n _nMels: number,\n _windowSizeSamples: number,\n _hopLengthSamples: number,\n _fMin: number,\n _fMax: number,\n _windowType: 'hann' | 'hamming',\n _normalize: boolean,\n _logScale: boolean\n): Promise<number[][]> {\n throw new Error('WASM mel spectrogram is not available on native')\n}\n"]}
|