@siteed/audio-studio 3.0.2-beta.1 → 3.0.2
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 +8 -150
- package/build/cjs/AudioAnalysis/audioFeaturesWasm.web.js +2 -1
- package/build/cjs/AudioAnalysis/audioFeaturesWasm.web.js.map +1 -1
- package/build/cjs/AudioAnalysis/melSpectrogramWasm.web.js +2 -1
- package/build/cjs/AudioAnalysis/melSpectrogramWasm.web.js.map +1 -1
- package/build/cjs/AudioAnalysis/wasmConfig.js +1 -1
- package/build/cjs/AudioAnalysis/wasmConfig.js.map +1 -1
- package/build/esm/AudioAnalysis/audioFeaturesWasm.web.js +2 -1
- package/build/esm/AudioAnalysis/audioFeaturesWasm.web.js.map +1 -1
- package/build/esm/AudioAnalysis/melSpectrogramWasm.web.js +2 -1
- package/build/esm/AudioAnalysis/melSpectrogramWasm.web.js.map +1 -1
- package/build/esm/AudioAnalysis/wasmConfig.js +1 -1
- package/build/esm/AudioAnalysis/wasmConfig.js.map +1 -1
- package/build/types/AudioAnalysis/audioFeaturesWasm.web.d.ts.map +1 -1
- package/build/types/AudioAnalysis/melSpectrogramWasm.web.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/AudioAnalysis/audioFeaturesWasm.web.ts +3 -1
- package/src/AudioAnalysis/melSpectrogramWasm.web.ts +3 -1
- package/src/AudioAnalysis/wasmConfig.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,15 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
## [3.0.1] - 2026-03-21
|
|
11
10
|
|
|
11
|
+
## [3.0.2] - 2026-03-21
|
|
12
|
+
### Changed
|
|
13
|
+
- fix(audio-studio): load WASM via CDN URL instead of broken relative path ([7427f28](https://github.com/deeeed/audiolab/commit/7427f289d273ffad609a4c6b0fb45c5094445dde))
|
|
14
|
+
- chore(audio-studio): disable conventionalCommits in publisher config, rewrite clean CHANGELOG ([4a2bbfa](https://github.com/deeeed/audiolab/commit/4a2bbfa605a56cab06618c0ca1afe6ff8cb19441))
|
|
15
|
+
- chore(audio-studio): release @siteed/audio-studio@3.0.1 ([04fe6f7](https://github.com/deeeed/audiolab/commit/04fe6f706d372e3ced0f83b796923c490bebd64d))
|
|
16
|
+
## [3.0.1] - 2026-03-21
|
|
12
17
|
### Fixed
|
|
13
18
|
- Add `@expo/config-plugins` to `peerDependencies` — fixes Yarn PnP `ambiguous require` error during `expo prebuild` (#341)
|
|
14
19
|
- WASM path resolution in build output — `prebuilt/` is now copied into `build/cjs/` and `build/esm/` so Metro resolves WASM imports correctly after install (#341)
|
|
15
20
|
- Split WASM modules into separate web/native platform files to prevent Metro bundling issues (#338)
|
|
16
|
-
|
|
17
21
|
## [3.0.0] - 2026-03-20
|
|
18
|
-
|
|
19
22
|
### BREAKING CHANGES
|
|
20
23
|
- Package renamed from `@siteed/expo-audio-studio` to `@siteed/audio-studio`. The old package continues as a backwards-compatible shim.
|
|
21
24
|
- Native module renamed from `ExpoAudioStream` to `AudioStudio`
|
|
@@ -36,214 +39,140 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
36
39
|
|
|
37
40
|
### Performance
|
|
38
41
|
- Optimized mel spectrogram C++ implementation
|
|
39
|
-
|
|
40
42
|
## [2.18.5] - 2026-02-23
|
|
41
|
-
|
|
42
43
|
### Fixed
|
|
43
44
|
- Android: guard Bluetooth API calls behind permission check on API 31+ (#294)
|
|
44
45
|
- Android: migrate phone state listener to `TelephonyCallback` on API 31+ (#275)
|
|
45
46
|
- Android: reset `startTime` in `startRecording` and validate hardware format (#298, #223)
|
|
46
47
|
- Android: gate foreground service on `enableBackgroundAudio` (#288, #294)
|
|
47
48
|
- Android: sanitize options before native bridge calls to prevent crash
|
|
48
|
-
|
|
49
49
|
## [2.18.4] - 2026-02-16
|
|
50
|
-
|
|
51
50
|
### Added
|
|
52
51
|
- Expo SDK 54 (React Native 0.81, React 19) support (#305)
|
|
53
52
|
|
|
54
53
|
### Fixed
|
|
55
54
|
- iOS: include compression data in `onAudioStream` events
|
|
56
55
|
- Android: properly emit final chunk of audio data on stop (#293)
|
|
57
|
-
|
|
58
56
|
## [2.18.1] - 2025-08-02
|
|
59
|
-
|
|
60
57
|
### Added
|
|
61
58
|
- Improved memory monitoring
|
|
62
|
-
|
|
63
59
|
## [2.18.0] - 2025-08-01
|
|
64
|
-
|
|
65
60
|
### Fixed
|
|
66
61
|
- Android: optimize buffer size to prevent OOM errors
|
|
67
62
|
- Android: invalid paused duration calculation
|
|
68
|
-
|
|
69
63
|
## [2.17.0] - 2025-07-31
|
|
70
|
-
|
|
71
64
|
### Fixed
|
|
72
65
|
- Android: fix `OutOfMemoryError` by tracking stream position correctly
|
|
73
|
-
|
|
74
66
|
## [2.16.1] - 2025-07-27
|
|
75
|
-
|
|
76
67
|
### Fixed
|
|
77
68
|
- Android: audio analysis accumulation showing 0 bytes
|
|
78
|
-
|
|
79
69
|
## [2.16.0] - 2025-07-27
|
|
80
|
-
|
|
81
70
|
### Performance
|
|
82
71
|
- Android: optimize stop recording performance for long recordings
|
|
83
|
-
|
|
84
72
|
## [2.15.0] - 2025-07-15
|
|
85
|
-
|
|
86
73
|
### Added
|
|
87
74
|
- Android: `showPauseResumeActions` option to notification config (#282)
|
|
88
|
-
|
|
89
75
|
## [2.14.4] - 2025-07-15
|
|
90
|
-
|
|
91
76
|
### Fixed
|
|
92
77
|
- Plugin: respect `enableDeviceDetection` configuration for Android permissions
|
|
93
78
|
- Android: add missing `BLUETOOTH_ADMIN` permission for device detection
|
|
94
|
-
|
|
95
79
|
## [2.14.3] - 2025-06-12
|
|
96
|
-
|
|
97
80
|
### Changed
|
|
98
81
|
- Remove analysis bit depth logging for cleaner debug output
|
|
99
|
-
|
|
100
82
|
## [2.14.2] - 2025-06-11
|
|
101
|
-
|
|
102
83
|
### Added
|
|
103
84
|
- Platform limitations validation and documentation
|
|
104
85
|
|
|
105
86
|
### Fixed
|
|
106
87
|
- iOS: update compressed file size when primary output is disabled
|
|
107
|
-
|
|
108
88
|
## [2.14.1] - 2025-06-11
|
|
109
|
-
|
|
110
89
|
### Fixed
|
|
111
90
|
- Android: fix duration returning 0 when primary output is disabled (#244)
|
|
112
|
-
|
|
113
91
|
## [2.14.0] - 2025-06-11
|
|
114
|
-
|
|
115
92
|
### Performance
|
|
116
93
|
- Comprehensive cross-platform stop recording performance optimization
|
|
117
|
-
|
|
118
94
|
## [2.13.2] - 2025-06-10
|
|
119
|
-
|
|
120
95
|
### Fixed
|
|
121
96
|
- Invalid type exports
|
|
122
|
-
|
|
123
97
|
## [2.13.1] - 2025-06-09
|
|
124
|
-
|
|
125
98
|
### Added
|
|
126
99
|
- Sub-100ms audio events analysis and improvements (#270)
|
|
127
100
|
|
|
128
101
|
### Fixed
|
|
129
102
|
- Update `expo-modules-core` peer dependency for Expo SDK 53 compatibility
|
|
130
|
-
|
|
131
103
|
## [2.13.0] - 2025-06-09
|
|
132
|
-
|
|
133
104
|
### Added
|
|
134
105
|
- Enhanced device detection and management — configurable `enableDeviceDetection`, automatic connect/disconnect events, force refresh (#269)
|
|
135
|
-
|
|
136
106
|
## [2.12.3] - 2025-06-07
|
|
137
|
-
|
|
138
107
|
### Changed
|
|
139
108
|
- Adjust audio focus request timing in `AudioRecorderManager`
|
|
140
|
-
|
|
141
109
|
## [2.12.2] - 2025-06-07
|
|
142
|
-
|
|
143
110
|
### Fixed
|
|
144
111
|
- Android: audio focus strategy for background recording (#267)
|
|
145
|
-
|
|
146
112
|
## [2.12.0] - 2025-06-07
|
|
147
|
-
|
|
148
113
|
### Added
|
|
149
114
|
- Android-only `audioFocusStrategy` option (#264)
|
|
150
115
|
|
|
151
116
|
### Fixed
|
|
152
117
|
- Android: PCM streaming duration calculation bug (#263, #265)
|
|
153
|
-
|
|
154
118
|
## [2.11.0] - 2025-06-05
|
|
155
|
-
|
|
156
119
|
### Added
|
|
157
120
|
- M4A support with `preferRawStream` option (#261)
|
|
158
121
|
|
|
159
122
|
### Fixed
|
|
160
123
|
- Enforce 10ms minimum interval on both platforms (#262)
|
|
161
124
|
- Android: proper `MediaCodec` resource cleanup in `AudioProcessor`
|
|
162
|
-
|
|
163
125
|
## [2.10.6] - 2025-06-04
|
|
164
|
-
|
|
165
126
|
### Fixed
|
|
166
127
|
- iOS: prevent `durationMs` returning 0 (#244, #260)
|
|
167
|
-
|
|
168
128
|
## [2.10.5] - 2025-06-04
|
|
169
|
-
|
|
170
129
|
### Fixed
|
|
171
130
|
- iOS: enable audio streaming when primary output is disabled (#259)
|
|
172
|
-
|
|
173
131
|
## [2.10.4] - 2025-06-03
|
|
174
|
-
|
|
175
132
|
### Fixed
|
|
176
133
|
- iOS: resolve Swift compilation scope error in `AudioStreamManager` (#256)
|
|
177
|
-
|
|
178
134
|
## [2.10.3] - 2025-06-02
|
|
179
|
-
|
|
180
135
|
### Fixed
|
|
181
136
|
- Prevent `UninitializedPropertyAccessException` crash in developer menu (#250)
|
|
182
137
|
- Return compression info when primary output is disabled (#244, #249)
|
|
183
|
-
|
|
184
138
|
## [2.10.2] - 2025-05-31
|
|
185
|
-
|
|
186
139
|
### Fixed
|
|
187
140
|
- Buffer size calculation and duplicate emission fix (#248)
|
|
188
|
-
|
|
189
141
|
## [2.10.1] - 2025-05-27
|
|
190
|
-
|
|
191
142
|
### Fixed
|
|
192
143
|
- `useAudioRecorder`: update `intervalId` type for better type safety
|
|
193
|
-
|
|
194
144
|
## [2.10.0] - 2025-05-26
|
|
195
|
-
|
|
196
145
|
### Added
|
|
197
146
|
- Buffer duration control and `skipFileWriting` options
|
|
198
147
|
- Enhanced testing framework with instrumented tests (#242)
|
|
199
|
-
|
|
200
148
|
## [2.9.0] - 2025-05-15
|
|
201
|
-
|
|
202
149
|
### Added
|
|
203
150
|
- Web audio chunk handling improvements (#240)
|
|
204
|
-
|
|
205
151
|
## [2.8.4] - 2025-05-11
|
|
206
|
-
|
|
207
152
|
### Fixed
|
|
208
153
|
- Expo plugin setup
|
|
209
|
-
|
|
210
154
|
## [2.8.3] - 2025-05-06
|
|
211
|
-
|
|
212
155
|
### Changed
|
|
213
156
|
- Update plugin configuration to use ESM format
|
|
214
|
-
|
|
215
157
|
## [2.8.2] - 2025-05-06
|
|
216
|
-
|
|
217
158
|
### Changed
|
|
218
159
|
- TypeScript configurations for dual module (ESM/CJS) support
|
|
219
|
-
|
|
220
160
|
## [2.8.1] - 2025-05-06
|
|
221
|
-
|
|
222
161
|
### Added
|
|
223
162
|
- Dual module format (ESM/CommonJS) to resolve module resolution issues (#235)
|
|
224
|
-
|
|
225
163
|
## [2.7.0] - 2025-05-04
|
|
226
|
-
|
|
227
164
|
### Fixed
|
|
228
165
|
- iOS: enhance background audio recording and audio format conversion (#228)
|
|
229
|
-
|
|
230
166
|
## [2.6.2] - 2025-05-01
|
|
231
|
-
|
|
232
167
|
### Fixed
|
|
233
168
|
- Android: ensure foreground-only audio recording works with `FOREGROUND_SERVICE` (#202, #221)
|
|
234
|
-
|
|
235
169
|
## [2.6.1] - 2025-05-01
|
|
236
|
-
|
|
237
170
|
### Fixed
|
|
238
171
|
- iOS: resolve hardware format mismatch crash and enhance logging (#220)
|
|
239
|
-
|
|
240
172
|
## [2.6.0] - 2025-05-01
|
|
241
|
-
|
|
242
173
|
### Fixed
|
|
243
174
|
- Web: resolve audio recording issue without compression (#217, #219)
|
|
244
|
-
|
|
245
175
|
## [2.5.0] - 2025-04-30
|
|
246
|
-
|
|
247
176
|
### Added
|
|
248
177
|
- Complete Android implementation for audio device API (#214)
|
|
249
178
|
- Cross-platform audio device detection, selection, and fallback handling (#213)
|
|
@@ -251,49 +180,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
251
180
|
|
|
252
181
|
### Fixed
|
|
253
182
|
- iOS: ensure complete audio data emission on recording stop/pause (#215)
|
|
254
|
-
|
|
255
183
|
## [2.4.1] - 2025-04-08
|
|
256
|
-
|
|
257
184
|
### Added
|
|
258
185
|
- Enhanced background audio handling and permission checks (#200)
|
|
259
|
-
|
|
260
186
|
## [2.4.0] - 2025-04-03
|
|
261
|
-
|
|
262
187
|
### Fixed
|
|
263
188
|
- iOS: resolve sample rate mismatch and enhance recording stability (#198)
|
|
264
189
|
- Android: enhance permission handling for phone state and notifications (#196)
|
|
265
|
-
|
|
266
190
|
## [2.3.1] - 2025-04-03
|
|
267
|
-
|
|
268
191
|
### Changed
|
|
269
192
|
- Remove external CRC32 library dependency (#195)
|
|
270
|
-
|
|
271
193
|
## [2.3.0] - 2025-03-29
|
|
272
|
-
|
|
273
194
|
### Fixed
|
|
274
195
|
- Always generate a new UUID unless filename is provided (#182)
|
|
275
|
-
|
|
276
196
|
## [2.2.0] - 2025-03-28
|
|
277
|
-
|
|
278
197
|
### Changed
|
|
279
198
|
- Platform-specific CRC32 handling
|
|
280
|
-
|
|
281
199
|
## [2.1.0] - 2025-03-04
|
|
282
|
-
|
|
283
200
|
### Added
|
|
284
201
|
- Mel spectrogram extraction and language detection (#157)
|
|
285
202
|
- Audio import functionality and decibel visualization (#156)
|
|
286
203
|
- iOS trim support with custom filename (#152)
|
|
287
204
|
- Sample rate control and web trimming support (#151)
|
|
288
205
|
- Audio trimming with optimized processing and detailed feedback (#150, #149)
|
|
289
|
-
|
|
290
206
|
## [2.0.1] - 2025-02-27
|
|
291
|
-
|
|
292
207
|
### Changed
|
|
293
208
|
- Update background mode handling for audio stream plugin
|
|
294
|
-
|
|
295
209
|
## [2.0.0] - 2025-02-27
|
|
296
|
-
|
|
297
210
|
### Added
|
|
298
211
|
- Full audio analysis with spectral features and time range controls (#132)
|
|
299
212
|
- `extractAudioData` API
|
|
@@ -302,166 +215,110 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
302
215
|
|
|
303
216
|
### Fixed
|
|
304
217
|
- Audio recording reliability improvements and web IndexedDB management (#146)
|
|
305
|
-
|
|
306
218
|
## [1.17.0] - 2025-02-18
|
|
307
|
-
|
|
308
219
|
### Added
|
|
309
220
|
- Interval audio analysis for web, Android, and iOS (#125, #126)
|
|
310
|
-
|
|
311
221
|
## [1.16.0] - 2025-02-17
|
|
312
|
-
|
|
313
222
|
### Fixed
|
|
314
223
|
- iOS: prevent adding background modes when disabled
|
|
315
224
|
- iOS: replace CallKit with `AVAudioSession` for phone call detection
|
|
316
|
-
|
|
317
225
|
## [1.15.1] - 2025-02-17
|
|
318
|
-
|
|
319
226
|
### Fixed
|
|
320
227
|
- iOS: restore Opus compression support (#122)
|
|
321
228
|
- Emit audio analysis without blocking the recording thread
|
|
322
|
-
|
|
323
229
|
## [1.15.0] - 2025-02-15
|
|
324
|
-
|
|
325
230
|
### Fixed
|
|
326
231
|
- iOS: improve audio recording interruption handling and auto-resume (#119)
|
|
327
232
|
- Android: improve background recording and call interruption handling (#118)
|
|
328
|
-
|
|
329
233
|
## [1.14.2] - 2025-02-13
|
|
330
|
-
|
|
331
234
|
### Fixed
|
|
332
235
|
- Clear recording metadata on STOP action
|
|
333
|
-
|
|
334
236
|
## [1.14.1] - 2025-02-12
|
|
335
|
-
|
|
336
237
|
### Fixed
|
|
337
238
|
- Enable background recording by default (#114)
|
|
338
|
-
|
|
339
239
|
## [1.14.0] - 2025-02-12
|
|
340
|
-
|
|
341
240
|
### Fixed
|
|
342
241
|
- `keepAwake` issue on iOS and auto-resume after call (#113)
|
|
343
|
-
|
|
344
242
|
## [1.13.2] - 2025-02-10
|
|
345
|
-
|
|
346
243
|
### Fixed
|
|
347
244
|
- Ensure foreground service starts within required timeframe
|
|
348
|
-
|
|
349
245
|
## [1.13.0] - 2025-02-09
|
|
350
|
-
|
|
351
246
|
### Added
|
|
352
247
|
- Audio decode support (#104)
|
|
353
248
|
|
|
354
249
|
### Fixed
|
|
355
250
|
- Background recording issues and status checking (#103)
|
|
356
|
-
|
|
357
251
|
## [1.12.1] - 2025-02-01
|
|
358
|
-
|
|
359
252
|
### Fixed
|
|
360
253
|
- Improve audio recording interruption handling and consistency (#98)
|
|
361
|
-
|
|
362
254
|
## [1.12.0] - 2025-01-31
|
|
363
|
-
|
|
364
255
|
### Added
|
|
365
256
|
- Call state checks before starting or resuming recording (#94)
|
|
366
257
|
- Custom filename and directory support for recordings (#92)
|
|
367
258
|
- Compressed recording info with file size (#90)
|
|
368
|
-
|
|
369
259
|
## [1.11.3] - 2025-01-25
|
|
370
|
-
|
|
371
260
|
### Fixed
|
|
372
261
|
- Disable duplicate notification alerts (#82)
|
|
373
|
-
|
|
374
262
|
## [1.11.2] - 2025-01-22
|
|
375
|
-
|
|
376
263
|
### Fixed
|
|
377
264
|
- Resources not cleaned up properly on app kill (#80)
|
|
378
|
-
|
|
379
265
|
## [1.11.0] - 2025-01-22
|
|
380
|
-
|
|
381
266
|
### Added
|
|
382
267
|
- Intelligent call interruption handling and compression improvements (#78)
|
|
383
|
-
|
|
384
268
|
## [1.10.0] - 2025-01-14
|
|
385
|
-
|
|
386
269
|
### Added
|
|
387
270
|
- Support for pausing and resuming compressed recordings
|
|
388
271
|
- Optimized notification channel settings
|
|
389
|
-
|
|
390
272
|
## [1.9.2] - 2025-01-12
|
|
391
|
-
|
|
392
273
|
### Fixed
|
|
393
274
|
- iOS: bitrate verification to prevent invalid values
|
|
394
|
-
|
|
395
275
|
## [1.9.1] - 2025-01-12
|
|
396
|
-
|
|
397
276
|
### Fixed
|
|
398
277
|
- iOS: potentially missing compressed file info
|
|
399
|
-
|
|
400
278
|
## [1.9.0] - 2025-01-11
|
|
401
|
-
|
|
402
279
|
### Performance
|
|
403
280
|
- Optimize memory usage and streaming performance for web audio recording (#75)
|
|
404
|
-
|
|
405
281
|
## [1.8.0] - 2025-01-10
|
|
406
|
-
|
|
407
282
|
### Added
|
|
408
283
|
- Audio compression support
|
|
409
|
-
|
|
410
284
|
## [1.7.2] - 2025-01-07
|
|
411
|
-
|
|
412
285
|
### Fixed
|
|
413
286
|
- Web: correct WAV header handling in audio recording
|
|
414
|
-
|
|
415
287
|
## [1.7.1] - 2025-01-07
|
|
416
|
-
|
|
417
288
|
### Fixed
|
|
418
289
|
- Notification: avoid triggering new alerts on update (#71)
|
|
419
|
-
|
|
420
290
|
## [1.7.0] - 2025-01-05
|
|
421
|
-
|
|
422
291
|
### Fixed
|
|
423
292
|
- iOS: improve audio resampling and duration tracking (#69)
|
|
424
293
|
- Handle paused state in `stopRecording` (#68)
|
|
425
294
|
- Reset audio recording state properly on iOS and Android (#66)
|
|
426
295
|
- Android: total size not resetting on new recording (#64)
|
|
427
|
-
|
|
428
296
|
## [1.3.1] - 2024-12-05
|
|
429
|
-
|
|
430
297
|
### Added
|
|
431
298
|
- Web: throttling and optimized event processing (#49)
|
|
432
|
-
|
|
433
299
|
## [1.3.0] - 2024-11-28
|
|
434
|
-
|
|
435
300
|
### Added
|
|
436
301
|
- Standardize permission status response structure across platforms (#44)
|
|
437
|
-
|
|
438
302
|
## [1.2.4] - 2024-11-05
|
|
439
|
-
|
|
440
303
|
### Changed
|
|
441
304
|
- Android: minimum audio interval set to 10ms
|
|
442
305
|
- Plugin: do not include `notification` config by default to prevent iOS version mismatch
|
|
443
306
|
|
|
444
307
|
### Fixed
|
|
445
308
|
- Remove frequently firing log statements on web
|
|
446
|
-
|
|
447
309
|
## [1.2.0] - 2024-10-24
|
|
448
|
-
|
|
449
310
|
### Added
|
|
450
311
|
- `keepAwake` — continue recording when app is in background (default: true)
|
|
451
312
|
- Customizable recording notifications for Android and iOS
|
|
452
313
|
- Android: rich notification with live waveform, configurable actions/colors/priorities
|
|
453
314
|
- iOS: media player integration
|
|
454
|
-
|
|
455
315
|
## [1.1.17] - 2024-10-21
|
|
456
|
-
|
|
457
316
|
### Added
|
|
458
317
|
- Bluetooth headset support on iOS
|
|
459
318
|
|
|
460
319
|
### Fixed
|
|
461
320
|
- Android: not reading custom interval audio update
|
|
462
|
-
|
|
463
321
|
## [1.0.0] - 2024-04-01
|
|
464
|
-
|
|
465
322
|
### Added
|
|
466
323
|
- Initial release
|
|
467
324
|
- Real-time audio streaming across iOS, Android, and web
|
|
@@ -471,6 +328,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
471
328
|
- Audio features extraction during recording
|
|
472
329
|
- Consistent WAV PCM recording format across all platforms
|
|
473
330
|
|
|
474
|
-
[unreleased]: https://github.com/deeeed/audiolab/compare/@siteed/audio-studio@3.0.
|
|
331
|
+
[unreleased]: https://github.com/deeeed/audiolab/compare/@siteed/audio-studio@3.0.2...HEAD
|
|
332
|
+
[3.0.2]: https://github.com/deeeed/audiolab/compare/@siteed/audio-studio@3.0.2-beta.2...@siteed/audio-studio@3.0.2
|
|
475
333
|
[3.0.1]: https://github.com/deeeed/audiolab/compare/@siteed/audio-studio@3.0.0...@siteed/audio-studio@3.0.1
|
|
476
334
|
[3.0.0]: https://github.com/deeeed/audiolab/compare/@siteed/audio-studio@2.18.5...@siteed/audio-studio@3.0.0
|
|
@@ -43,7 +43,8 @@ function getModule() {
|
|
|
43
43
|
modulePromise = (async () => {
|
|
44
44
|
const url = (0, wasmConfig_1.getMelSpectrogramWasmUrl)();
|
|
45
45
|
// webpackIgnore + @vite-ignore prevent bundlers from trying to resolve the URL
|
|
46
|
-
const mod = await Promise.resolve(`${
|
|
46
|
+
const mod = await Promise.resolve(`${
|
|
47
|
+
/* webpackIgnore: true */ /* @vite-ignore */ url}`).then(s => __importStar(require(s)));
|
|
47
48
|
const factory = mod.default ?? mod;
|
|
48
49
|
return factory();
|
|
49
50
|
})().catch((err) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audioFeaturesWasm.web.js","sourceRoot":"","sources":["../../../src/AudioAnalysis/audioFeaturesWasm.web.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4FA,sDA6BC;AAMD,sEA6BC;AAQD,4DAoCC;AAvMD,6CAAuD;AAWvD,IAAI,aAAa,GAA4C,IAAI,CAAA;A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,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'\nimport { getMelSpectrogramWasmUrl } from './wasmConfig'\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 const url = getMelSpectrogramWasmUrl()\n // webpackIgnore + @vite-ignore prevent bundlers from trying to resolve the URL\n const mod = await import(/* webpackIgnore: true */ /* @vite-ignore */ url)\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.web.js","sourceRoot":"","sources":["../../../src/AudioAnalysis/audioFeaturesWasm.web.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8FA,sDA6BC;AAMD,sEA6BC;AAQD,4DAoCC;AAzMD,6CAAuD;AAWvD,IAAI,aAAa,GAA4C,IAAI,CAAA;AAEjE,SAAS,SAAS;IACd,IAAI,CAAC,aAAa,E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A;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'\nimport { getMelSpectrogramWasmUrl } from './wasmConfig'\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 const url = getMelSpectrogramWasmUrl()\n // webpackIgnore + @vite-ignore prevent bundlers from trying to resolve the URL\n const mod = await import(\n /* webpackIgnore: true */ /* @vite-ignore */ url\n )\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"]}
|
|
@@ -46,7 +46,8 @@ function getModule() {
|
|
|
46
46
|
modulePromise = (async () => {
|
|
47
47
|
const url = (0, wasmConfig_1.getMelSpectrogramWasmUrl)();
|
|
48
48
|
// webpackIgnore + @vite-ignore prevent bundlers from trying to resolve the URL
|
|
49
|
-
const mod = await Promise.resolve(`${
|
|
49
|
+
const mod = await Promise.resolve(`${
|
|
50
|
+
/* webpackIgnore: true */ /* @vite-ignore */ url}`).then(s => __importStar(require(s)));
|
|
50
51
|
const factory = mod.default ?? mod;
|
|
51
52
|
return factory();
|
|
52
53
|
})().catch((err) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"melSpectrogramWasm.web.js","sourceRoot":"","sources":["../../../src/AudioAnalysis/melSpectrogramWasm.web.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,oDA+BC;AAMD,kDA4BC;AAMD,8DA2EC;AAtLD,6CAA6E;AAE7E,IAAI,aAAa,GAA6C,IAAI,CAAA;AAElE,IAAA,iCAAoB,EAAC,GAAG,EAAE;IACtB,aAAa,GAAG,IAAI,CAAA;AACxB,CAAC,CAAC,CAAA;AAEF,SAAS,SAAS;IACd,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,aAAa,GAAG,CAAC,KAAK,IAAI,EAAE;YACxB,MAAM,GAAG,GAAG,IAAA,qCAAwB,GAAE,CAAA;YACtC,+EAA+E;YAC/E,MAAM,GAAG,GAAG,yBAA0D,GAAG,uCAAC,CAAA;YAC1E,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,IAAI,GAAG,CAAA;YAClC,OAAO,OAAO,EAAuC,CAAA;QACzD,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,6DAA6D;AAE7D,IAAI,eAAe,GAAoC,IAAI,CAAA;AAC3D,IAAI,cAAc,GAAG,CAAC,CAAA;AACtB,IAAI,iBAAiB,GAAG,CAAC,CAAA;AACzB,IAAI,eAAe,GAAG,CAAC,CAAA;AACvB,IAAI,sBAAsB,GAAG,CAAC,CAAA;AAE9B;;;GAGG;AACI,KAAK,UAAU,oBAAoB,CACtC,UAAkB,EAClB,KAAK,GAAG,GAAG,EACX,SAAS,GAAG,IAAI,EAChB,iBAAiB,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AG,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,CAAC,GAAG,WAAW,GAAG,CAAC,CAAC,CAAA;QAC7D,CAAC;QACD,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;IAED,oBAAoB;IACpB,MAAM,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAA;IAEvC,OAAO,WAAW,CAAA;AACtB,CAAC","sourcesContent":["import type { MelSpectrogramWasmModule } from './mel-spectrogram-wasm'\nimport { getMelSpectrogramWasmUrl, _registerModuleReset } from './wasmConfig'\n\nlet modulePromise: Promise<MelSpectrogramWasmModule> | null = null\n\n_registerModuleReset(() => {\n modulePromise = null\n})\n\nfunction getModule(): Promise<MelSpectrogramWasmModule> {\n if (!modulePromise) {\n modulePromise = (async () => {\n const url = getMelSpectrogramWasmUrl()\n // webpackIgnore + @vite-ignore prevent bundlers from trying to resolve the URL\n const mod = await import(/* webpackIgnore: true */ /* @vite-ignore */ url)\n const factory = mod.default ?? mod\n return factory() as Promise<MelSpectrogramWasmModule>\n })().catch((err) => {\n modulePromise = null\n throw err\n })\n }\n return modulePromise\n}\n\n// --- Streaming (per-frame) API for live mel spectrogram ---\n\nlet streamingModule: MelSpectrogramWasmModule | null = null\nlet streamingNMels = 0\nlet streamingFramePtr = 0\nlet streamingMelPtr = 0\nlet streamingFrameCapacity = 0\n\n/**\n * Initialise the WASM streaming processor. Call once before computeMelFrame().\n * Re-initialises only when config changes.\n */\nexport async function initMelStreamingWasm(\n sampleRate: number,\n nMels = 128,\n fftLength = 2048,\n windowSizeSamples = 400,\n hopLengthSamples = 160,\n fMin = 0,\n fMax = 0\n): Promise<void> {\n const Module = await getModule()\n streamingModule = Module\n const actualFMax = fMax > 0 ? fMax : sampleRate / 2\n Module._mel_spectrogram_init(\n sampleRate,\n fftLength,\n windowSizeSamples,\n hopLengthSamples,\n nMels,\n fMin,\n actualFMax,\n 0 /* hann */\n )\n streamingNMels = nMels\n\n // Pre-allocate output buffer (fixed size)\n if (streamingMelPtr) Module._free(streamingMelPtr)\n streamingMelPtr = Module._malloc(nMels * 4)\n\n // Frame input buffer allocated on demand in computeMelFrame\n streamingFrameCapacity = 0\n streamingFramePtr = 0\n}\n\n/**\n * Compute a single mel spectrogram frame from raw PCM samples via WASM C++.\n * Returns null if not initialised or on error.\n */\nexport function computeMelFrameWasm(samples: Float32Array): number[] | null {\n if (!streamingModule || !streamingMelPtr) 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._mel_spectrogram_compute_frame(\n streamingFramePtr,\n samples.length,\n streamingMelPtr\n )\n if (!ok) return null\n\n // Read mel output from WASM heap\n const offset = streamingMelPtr >> 2\n const result = new Array(streamingNMels)\n for (let i = 0; i < streamingNMels; i++) {\n result[i] = Module.HEAPF32[offset + i]\n }\n return result\n}\n\n/**\n * Computes a mel spectrogram via the WASM-compiled C++ implementation.\n * Lazy-loads the WASM module on first call.\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 const Module = await getModule()\n\n const fftLength = 2048\n const windowTypeInt = windowType === 'hamming' ? 1 : 0\n\n // Allocate input buffer on WASM heap\n const numSamples = audioData.length\n const inputPtr = Module._malloc(numSamples * 4) // 4 bytes per float\n Module.HEAPF32.set(audioData, inputPtr >> 2)\n\n // Call the C bridge\n const resultPtr = Module._mel_spectrogram_compute(\n inputPtr,\n numSamples,\n sampleRate,\n fftLength,\n windowSizeSamples,\n hopLengthSamples,\n nMels,\n fMin,\n fMax,\n windowTypeInt,\n logScale ? 1 : 0,\n normalize ? 1 : 0\n )\n\n // Free input buffer\n Module._free(inputPtr)\n\n if (resultPtr === 0) {\n throw new Error(\n 'mel_spectrogram_compute returned null (too few samples?)'\n )\n }\n\n // Read CMelSpectrogramResult struct (wasm32 pointers are 4 bytes)\n // struct layout: { float* data (offset 0), int timeSteps (offset 4), int nMels (offset 8) }\n const dataPtr = Module.getValue(resultPtr, 'i32')\n const timeSteps = Module.getValue(resultPtr + 4, 'i32')\n const resultNMels = Module.getValue(resultPtr + 8, 'i32')\n\n if (!dataPtr || timeSteps <= 0 || resultNMels <= 0) {\n Module._mel_spectrogram_free(resultPtr)\n throw new Error(\n 'mel_spectrogram_compute returned invalid result struct'\n )\n }\n\n // Copy spectrogram data to JS arrays\n const spectrogram: number[][] = []\n const heapOffset = dataPtr >> 2 // float32 offset into HEAPF32\n for (let t = 0; t < timeSteps; t++) {\n const row = new Array(resultNMels)\n for (let m = 0; m < resultNMels; m++) {\n row[m] = Module.HEAPF32[heapOffset + t * resultNMels + m]\n }\n spectrogram.push(row)\n }\n\n // Free the C result\n Module._mel_spectrogram_free(resultPtr)\n\n return spectrogram\n}\n"]}
|
|
1
|
+
{"version":3,"file":"melSpectrogramWasm.web.js","sourceRoot":"","sources":["../../../src/AudioAnalysis/melSpectrogramWasm.web.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,oDA+BC;AAMD,kDA4BC;AAMD,8DA2EC;AAxLD,6CAA6E;AAE7E,IAAI,aAAa,GAA6C,IAAI,CAAA;AAElE,IAAA,iCAAoB,EAAC,GAAG,EAAE;IACtB,aAAa,GAAG,IAAI,CAAA;AACxB,CAAC,CAAC,CAAA;AAEF,SAAS,SAAS;IACd,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,aAAa,GAAG,CAAC,KAAK,IAAI,EAAE;YACxB,MAAM,GAAG,GAAG,IAAA,qCAAwB,GAAE,CAAA;YACtC,+EAA+E;YAC/E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AAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,GAAG,CAAC,EAAE,KAAK,CAAC,CAAA;IAEzD,IAAI,CAAC,OAAO,IAAI,SAAS,IAAI,CAAC,IAAI,WAAW,IAAI,CAAC,EAAE,CAAC;QACjD,MAAM,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAA;QACvC,MAAM,IAAI,KAAK,CACX,wDAAwD,CAC3D,CAAA;IACL,CAAC;IAED,qCAAqC;IACrC,MAAM,WAAW,GAAe,EAAE,CAAA;IAClC,MAAM,UAAU,GAAG,OAAO,IAAI,CAAC,CAAA,CAAC,8BAA8B;IAC9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;QACjC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,WAAW,CAAC,CAAA;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC;YACnC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,CAAC,GAAG,WAAW,GAAG,CAAC,CAAC,CAAA;QAC7D,CAAC;QACD,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;IAED,oBAAoB;IACpB,MAAM,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAA;IAEvC,OAAO,WAAW,CAAA;AACtB,CAAC","sourcesContent":["import type { MelSpectrogramWasmModule } from './mel-spectrogram-wasm'\nimport { getMelSpectrogramWasmUrl, _registerModuleReset } from './wasmConfig'\n\nlet modulePromise: Promise<MelSpectrogramWasmModule> | null = null\n\n_registerModuleReset(() => {\n modulePromise = null\n})\n\nfunction getModule(): Promise<MelSpectrogramWasmModule> {\n if (!modulePromise) {\n modulePromise = (async () => {\n const url = getMelSpectrogramWasmUrl()\n // webpackIgnore + @vite-ignore prevent bundlers from trying to resolve the URL\n const mod = await import(\n /* webpackIgnore: true */ /* @vite-ignore */ url\n )\n const factory = mod.default ?? mod\n return factory() as Promise<MelSpectrogramWasmModule>\n })().catch((err) => {\n modulePromise = null\n throw err\n })\n }\n return modulePromise\n}\n\n// --- Streaming (per-frame) API for live mel spectrogram ---\n\nlet streamingModule: MelSpectrogramWasmModule | null = null\nlet streamingNMels = 0\nlet streamingFramePtr = 0\nlet streamingMelPtr = 0\nlet streamingFrameCapacity = 0\n\n/**\n * Initialise the WASM streaming processor. Call once before computeMelFrame().\n * Re-initialises only when config changes.\n */\nexport async function initMelStreamingWasm(\n sampleRate: number,\n nMels = 128,\n fftLength = 2048,\n windowSizeSamples = 400,\n hopLengthSamples = 160,\n fMin = 0,\n fMax = 0\n): Promise<void> {\n const Module = await getModule()\n streamingModule = Module\n const actualFMax = fMax > 0 ? fMax : sampleRate / 2\n Module._mel_spectrogram_init(\n sampleRate,\n fftLength,\n windowSizeSamples,\n hopLengthSamples,\n nMels,\n fMin,\n actualFMax,\n 0 /* hann */\n )\n streamingNMels = nMels\n\n // Pre-allocate output buffer (fixed size)\n if (streamingMelPtr) Module._free(streamingMelPtr)\n streamingMelPtr = Module._malloc(nMels * 4)\n\n // Frame input buffer allocated on demand in computeMelFrame\n streamingFrameCapacity = 0\n streamingFramePtr = 0\n}\n\n/**\n * Compute a single mel spectrogram frame from raw PCM samples via WASM C++.\n * Returns null if not initialised or on error.\n */\nexport function computeMelFrameWasm(samples: Float32Array): number[] | null {\n if (!streamingModule || !streamingMelPtr) 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._mel_spectrogram_compute_frame(\n streamingFramePtr,\n samples.length,\n streamingMelPtr\n )\n if (!ok) return null\n\n // Read mel output from WASM heap\n const offset = streamingMelPtr >> 2\n const result = new Array(streamingNMels)\n for (let i = 0; i < streamingNMels; i++) {\n result[i] = Module.HEAPF32[offset + i]\n }\n return result\n}\n\n/**\n * Computes a mel spectrogram via the WASM-compiled C++ implementation.\n * Lazy-loads the WASM module on first call.\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 const Module = await getModule()\n\n const fftLength = 2048\n const windowTypeInt = windowType === 'hamming' ? 1 : 0\n\n // Allocate input buffer on WASM heap\n const numSamples = audioData.length\n const inputPtr = Module._malloc(numSamples * 4) // 4 bytes per float\n Module.HEAPF32.set(audioData, inputPtr >> 2)\n\n // Call the C bridge\n const resultPtr = Module._mel_spectrogram_compute(\n inputPtr,\n numSamples,\n sampleRate,\n fftLength,\n windowSizeSamples,\n hopLengthSamples,\n nMels,\n fMin,\n fMax,\n windowTypeInt,\n logScale ? 1 : 0,\n normalize ? 1 : 0\n )\n\n // Free input buffer\n Module._free(inputPtr)\n\n if (resultPtr === 0) {\n throw new Error(\n 'mel_spectrogram_compute returned null (too few samples?)'\n )\n }\n\n // Read CMelSpectrogramResult struct (wasm32 pointers are 4 bytes)\n // struct layout: { float* data (offset 0), int timeSteps (offset 4), int nMels (offset 8) }\n const dataPtr = Module.getValue(resultPtr, 'i32')\n const timeSteps = Module.getValue(resultPtr + 4, 'i32')\n const resultNMels = Module.getValue(resultPtr + 8, 'i32')\n\n if (!dataPtr || timeSteps <= 0 || resultNMels <= 0) {\n Module._mel_spectrogram_free(resultPtr)\n throw new Error(\n 'mel_spectrogram_compute returned invalid result struct'\n )\n }\n\n // Copy spectrogram data to JS arrays\n const spectrogram: number[][] = []\n const heapOffset = dataPtr >> 2 // float32 offset into HEAPF32\n for (let t = 0; t < timeSteps; t++) {\n const row = new Array(resultNMels)\n for (let m = 0; m < resultNMels; m++) {\n row[m] = Module.HEAPF32[heapOffset + t * resultNMels + m]\n }\n spectrogram.push(row)\n }\n\n // Free the C result\n Module._mel_spectrogram_free(resultPtr)\n\n return spectrogram\n}\n"]}
|
|
@@ -5,7 +5,7 @@ exports.setMelSpectrogramWasmUrl = setMelSpectrogramWasmUrl;
|
|
|
5
5
|
exports.getMelSpectrogramWasmUrl = getMelSpectrogramWasmUrl;
|
|
6
6
|
// Version is inlined here — keep in sync with package.json when releasing.
|
|
7
7
|
// The publish.sh script should bump this string alongside package.json.
|
|
8
|
-
const WASM_VERSION = '3.0.2';
|
|
8
|
+
const WASM_VERSION = '3.0.2-beta.1';
|
|
9
9
|
// jsDelivr syncs from npm automatically within ~5 min of publish.
|
|
10
10
|
// GitHub release fallback (attach mel-spectrogram.js as a release asset):
|
|
11
11
|
// https://github.com/deeeed/audiolab/releases/download/@siteed/audio-studio@VERSION/mel-spectrogram.js
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasmConfig.js","sourceRoot":"","sources":["../../../src/AudioAnalysis/wasmConfig.ts"],"names":[],"mappings":";;AAYA,oDAEC;AAED,4DAGC;AAED,4DAEC;AAvBD,2EAA2E;AAC3E,wEAAwE;AACxE,MAAM,YAAY,GAAG,
|
|
1
|
+
{"version":3,"file":"wasmConfig.js","sourceRoot":"","sources":["../../../src/AudioAnalysis/wasmConfig.ts"],"names":[],"mappings":";;AAYA,oDAEC;AAED,4DAGC;AAED,4DAEC;AAvBD,2EAA2E;AAC3E,wEAAwE;AACxE,MAAM,YAAY,GAAG,cAAc,CAAA;AACnC,kEAAkE;AAClE,0EAA0E;AAC1E,yGAAyG;AACzG,8FAA8F;AAC9F,MAAM,gBAAgB,GAAG,qDAAqD,YAAY,mCAAmC,CAAA;AAE7H,IAAI,QAAQ,GAAW,gBAAgB,CAAA;AACvC,IAAI,mBAAmB,GAAwB,IAAI,CAAA;AAEnD,SAAgB,oBAAoB,CAAC,EAAc;IAC/C,mBAAmB,GAAG,EAAE,CAAA;AAC5B,CAAC;AAED,SAAgB,wBAAwB,CAAC,GAAW;IAChD,QAAQ,GAAG,GAAG,CAAA;IACd,mBAAmB,EAAE,EAAE,CAAA,CAAC,mDAAmD;AAC/E,CAAC;AAED,SAAgB,wBAAwB;IACpC,OAAO,QAAQ,CAAA;AACnB,CAAC","sourcesContent":["// Version is inlined here — keep in sync with package.json when releasing.\n// The publish.sh script should bump this string alongside package.json.\nconst WASM_VERSION = '3.0.2-beta.1'\n// jsDelivr syncs from npm automatically within ~5 min of publish.\n// GitHub release fallback (attach mel-spectrogram.js as a release asset):\n// https://github.com/deeeed/audiolab/releases/download/@siteed/audio-studio@VERSION/mel-spectrogram.js\n// To use the fallback: setMelSpectrogramWasmUrl('<url>') before any mel-spectrogram API call.\nconst DEFAULT_WASM_CDN = `https://cdn.jsdelivr.net/npm/@siteed/audio-studio@${WASM_VERSION}/prebuilt/wasm/mel-spectrogram.js`\n\nlet _wasmUrl: string = DEFAULT_WASM_CDN\nlet _modulePromiseReset: (() => void) | null = null\n\nexport function _registerModuleReset(fn: () => void): void {\n _modulePromiseReset = fn\n}\n\nexport function setMelSpectrogramWasmUrl(url: string): void {\n _wasmUrl = url\n _modulePromiseReset?.() // invalidate cached module so next call re-fetches\n}\n\nexport function getMelSpectrogramWasmUrl(): string {\n return _wasmUrl\n}\n"]}
|
|
@@ -5,7 +5,8 @@ function getModule() {
|
|
|
5
5
|
modulePromise = (async () => {
|
|
6
6
|
const url = getMelSpectrogramWasmUrl();
|
|
7
7
|
// webpackIgnore + @vite-ignore prevent bundlers from trying to resolve the URL
|
|
8
|
-
const mod = await import(
|
|
8
|
+
const mod = await import(
|
|
9
|
+
/* webpackIgnore: true */ /* @vite-ignore */ url);
|
|
9
10
|
const factory = mod.default ?? mod;
|
|
10
11
|
return factory();
|
|
11
12
|
})().catch((err) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audioFe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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'\nimport { getMelSpectrogramWasmUrl } from './wasmConfig'\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 const url = getMelSpectrogramWasmUrl()\n // webpackIgnore + @vite-ignore prevent bundlers from trying to resolve the URL\n const mod = await import(/* webpackIgnore: true */ /* @vite-ignore */ url)\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.web.js","sourceRoot":"","sources":["../../../src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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'\nimport { getMelSpectrogramWasmUrl } from './wasmConfig'\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 const url = getMelSpectrogramWasmUrl()\n // webpackIgnore + @vite-ignore prevent bundlers from trying to resolve the URL\n const mod = await import(\n /* webpackIgnore: true */ /* @vite-ignore */ url\n )\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"]}
|
|
@@ -8,7 +8,8 @@ function getModule() {
|
|
|
8
8
|
modulePromise = (async () => {
|
|
9
9
|
const url = getMelSpectrogramWasmUrl();
|
|
10
10
|
// webpackIgnore + @vite-ignore prevent bundlers from trying to resolve the URL
|
|
11
|
-
const mod = await import(
|
|
11
|
+
const mod = await import(
|
|
12
|
+
/* webpackIgnore: true */ /* @vite-ignore */ url);
|
|
12
13
|
const factory = mod.default ?? mod;
|
|
13
14
|
return factory();
|
|
14
15
|
})().catch((err) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"melSpectrogramWasm.web.js","sourceRoot":"","sources":["../../../src/AudioAnalysis/melSpectrogramWasm.web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAE7E,IAAI,aAAa,GAA6C,IAAI,CAAA;AAElE,oBAAoB,CAAC,GAAG,EAAE;IACtB,aAAa,GAAG,IAAI,CAAA;AACxB,CAAC,CAAC,CAAA;AAEF,SAAS,SAAS;IACd,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,aAAa,GAAG,CAAC,KAAK,IAAI,EAAE;YACxB,MAAM,GAAG,GAAG,wBAAwB,EAAE,CAAA;YACtC,+EAA+E;YAC/E,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAA;YAC1E,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,IAAI,GAAG,CAAA;YAClC,OAAO,OAAO,EAAuC,CAAA;QACzD,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,6DAA6D;AAE7D,IAAI,eAAe,GAAoC,IAAI,CAAA;AAC3D,IAAI,cAAc,GAAG,CAAC,CAAA;AACtB,IAAI,iBAAiB,GAAG,CAAC,CAAA;AACzB,IAAI,eAAe,GAAG,CAAC,CAAA;AACvB,IA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AM,GAAG,GAAG,IAAI,KAAK,CAAC,WAAW,CAAC,CAAA;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC;YACnC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,CAAC,GAAG,WAAW,GAAG,CAAC,CAAC,CAAA;QAC7D,CAAC;QACD,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;IAED,oBAAoB;IACpB,MAAM,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAA;IAEvC,OAAO,WAAW,CAAA;AACtB,CAAC","sourcesContent":["import type { MelSpectrogramWasmModule } from './mel-spectrogram-wasm'\nimport { getMelSpectrogramWasmUrl, _registerModuleReset } from './wasmConfig'\n\nlet modulePromise: Promise<MelSpectrogramWasmModule> | null = null\n\n_registerModuleReset(() => {\n modulePromise = null\n})\n\nfunction getModule(): Promise<MelSpectrogramWasmModule> {\n if (!modulePromise) {\n modulePromise = (async () => {\n const url = getMelSpectrogramWasmUrl()\n // webpackIgnore + @vite-ignore prevent bundlers from trying to resolve the URL\n const mod = await import(/* webpackIgnore: true */ /* @vite-ignore */ url)\n const factory = mod.default ?? mod\n return factory() as Promise<MelSpectrogramWasmModule>\n })().catch((err) => {\n modulePromise = null\n throw err\n })\n }\n return modulePromise\n}\n\n// --- Streaming (per-frame) API for live mel spectrogram ---\n\nlet streamingModule: MelSpectrogramWasmModule | null = null\nlet streamingNMels = 0\nlet streamingFramePtr = 0\nlet streamingMelPtr = 0\nlet streamingFrameCapacity = 0\n\n/**\n * Initialise the WASM streaming processor. Call once before computeMelFrame().\n * Re-initialises only when config changes.\n */\nexport async function initMelStreamingWasm(\n sampleRate: number,\n nMels = 128,\n fftLength = 2048,\n windowSizeSamples = 400,\n hopLengthSamples = 160,\n fMin = 0,\n fMax = 0\n): Promise<void> {\n const Module = await getModule()\n streamingModule = Module\n const actualFMax = fMax > 0 ? fMax : sampleRate / 2\n Module._mel_spectrogram_init(\n sampleRate,\n fftLength,\n windowSizeSamples,\n hopLengthSamples,\n nMels,\n fMin,\n actualFMax,\n 0 /* hann */\n )\n streamingNMels = nMels\n\n // Pre-allocate output buffer (fixed size)\n if (streamingMelPtr) Module._free(streamingMelPtr)\n streamingMelPtr = Module._malloc(nMels * 4)\n\n // Frame input buffer allocated on demand in computeMelFrame\n streamingFrameCapacity = 0\n streamingFramePtr = 0\n}\n\n/**\n * Compute a single mel spectrogram frame from raw PCM samples via WASM C++.\n * Returns null if not initialised or on error.\n */\nexport function computeMelFrameWasm(samples: Float32Array): number[] | null {\n if (!streamingModule || !streamingMelPtr) 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._mel_spectrogram_compute_frame(\n streamingFramePtr,\n samples.length,\n streamingMelPtr\n )\n if (!ok) return null\n\n // Read mel output from WASM heap\n const offset = streamingMelPtr >> 2\n const result = new Array(streamingNMels)\n for (let i = 0; i < streamingNMels; i++) {\n result[i] = Module.HEAPF32[offset + i]\n }\n return result\n}\n\n/**\n * Computes a mel spectrogram via the WASM-compiled C++ implementation.\n * Lazy-loads the WASM module on first call.\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 const Module = await getModule()\n\n const fftLength = 2048\n const windowTypeInt = windowType === 'hamming' ? 1 : 0\n\n // Allocate input buffer on WASM heap\n const numSamples = audioData.length\n const inputPtr = Module._malloc(numSamples * 4) // 4 bytes per float\n Module.HEAPF32.set(audioData, inputPtr >> 2)\n\n // Call the C bridge\n const resultPtr = Module._mel_spectrogram_compute(\n inputPtr,\n numSamples,\n sampleRate,\n fftLength,\n windowSizeSamples,\n hopLengthSamples,\n nMels,\n fMin,\n fMax,\n windowTypeInt,\n logScale ? 1 : 0,\n normalize ? 1 : 0\n )\n\n // Free input buffer\n Module._free(inputPtr)\n\n if (resultPtr === 0) {\n throw new Error(\n 'mel_spectrogram_compute returned null (too few samples?)'\n )\n }\n\n // Read CMelSpectrogramResult struct (wasm32 pointers are 4 bytes)\n // struct layout: { float* data (offset 0), int timeSteps (offset 4), int nMels (offset 8) }\n const dataPtr = Module.getValue(resultPtr, 'i32')\n const timeSteps = Module.getValue(resultPtr + 4, 'i32')\n const resultNMels = Module.getValue(resultPtr + 8, 'i32')\n\n if (!dataPtr || timeSteps <= 0 || resultNMels <= 0) {\n Module._mel_spectrogram_free(resultPtr)\n throw new Error(\n 'mel_spectrogram_compute returned invalid result struct'\n )\n }\n\n // Copy spectrogram data to JS arrays\n const spectrogram: number[][] = []\n const heapOffset = dataPtr >> 2 // float32 offset into HEAPF32\n for (let t = 0; t < timeSteps; t++) {\n const row = new Array(resultNMels)\n for (let m = 0; m < resultNMels; m++) {\n row[m] = Module.HEAPF32[heapOffset + t * resultNMels + m]\n }\n spectrogram.push(row)\n }\n\n // Free the C result\n Module._mel_spectrogram_free(resultPtr)\n\n return spectrogram\n}\n"]}
|
|
1
|
+
{"version":3,"file":"melSpectrogramWasm.web.js","sourceRoot":"","sources":["../../../src/AudioAnalysis/melSpectrogramWasm.web.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAE7E,IAAI,aAAa,GAA6C,IAAI,CAAA;AAElE,oBAAoB,CAAC,GAAG,EAAE;IACtB,aAAa,GAAG,IAAI,CAAA;AACxB,CAAC,CAAC,CAAA;AAEF,SAAS,SAAS;IACd,IAAI,CAAC,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OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;IACjD,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,GAAG,CAAC,EAAE,KAAK,CAAC,CAAA;IACvD,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,GAAG,CAAC,EAAE,KAAK,CAAC,CAAA;IAEzD,IAAI,CAAC,OAAO,IAAI,SAAS,IAAI,CAAC,IAAI,WAAW,IAAI,CAAC,EAAE,CAAC;QACjD,MAAM,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAA;QACvC,MAAM,IAAI,KAAK,CACX,wDAAwD,CAC3D,CAAA;IACL,CAAC;IAED,qCAAqC;IACrC,MAAM,WAAW,GAAe,EAAE,CAAA;IAClC,MAAM,UAAU,GAAG,OAAO,IAAI,CAAC,CAAA,CAAC,8BAA8B;IAC9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;QACjC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,WAAW,CAAC,CAAA;QAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,EAAE,CAAC,EAAE,EAAE,CAAC;YACnC,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,GAAG,CAAC,GAAG,WAAW,GAAG,CAAC,CAAC,CAAA;QAC7D,CAAC;QACD,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;IAED,oBAAoB;IACpB,MAAM,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAA;IAEvC,OAAO,WAAW,CAAA;AACtB,CAAC","sourcesContent":["import type { MelSpectrogramWasmModule } from './mel-spectrogram-wasm'\nimport { getMelSpectrogramWasmUrl, _registerModuleReset } from './wasmConfig'\n\nlet modulePromise: Promise<MelSpectrogramWasmModule> | null = null\n\n_registerModuleReset(() => {\n modulePromise = null\n})\n\nfunction getModule(): Promise<MelSpectrogramWasmModule> {\n if (!modulePromise) {\n modulePromise = (async () => {\n const url = getMelSpectrogramWasmUrl()\n // webpackIgnore + @vite-ignore prevent bundlers from trying to resolve the URL\n const mod = await import(\n /* webpackIgnore: true */ /* @vite-ignore */ url\n )\n const factory = mod.default ?? mod\n return factory() as Promise<MelSpectrogramWasmModule>\n })().catch((err) => {\n modulePromise = null\n throw err\n })\n }\n return modulePromise\n}\n\n// --- Streaming (per-frame) API for live mel spectrogram ---\n\nlet streamingModule: MelSpectrogramWasmModule | null = null\nlet streamingNMels = 0\nlet streamingFramePtr = 0\nlet streamingMelPtr = 0\nlet streamingFrameCapacity = 0\n\n/**\n * Initialise the WASM streaming processor. Call once before computeMelFrame().\n * Re-initialises only when config changes.\n */\nexport async function initMelStreamingWasm(\n sampleRate: number,\n nMels = 128,\n fftLength = 2048,\n windowSizeSamples = 400,\n hopLengthSamples = 160,\n fMin = 0,\n fMax = 0\n): Promise<void> {\n const Module = await getModule()\n streamingModule = Module\n const actualFMax = fMax > 0 ? fMax : sampleRate / 2\n Module._mel_spectrogram_init(\n sampleRate,\n fftLength,\n windowSizeSamples,\n hopLengthSamples,\n nMels,\n fMin,\n actualFMax,\n 0 /* hann */\n )\n streamingNMels = nMels\n\n // Pre-allocate output buffer (fixed size)\n if (streamingMelPtr) Module._free(streamingMelPtr)\n streamingMelPtr = Module._malloc(nMels * 4)\n\n // Frame input buffer allocated on demand in computeMelFrame\n streamingFrameCapacity = 0\n streamingFramePtr = 0\n}\n\n/**\n * Compute a single mel spectrogram frame from raw PCM samples via WASM C++.\n * Returns null if not initialised or on error.\n */\nexport function computeMelFrameWasm(samples: Float32Array): number[] | null {\n if (!streamingModule || !streamingMelPtr) 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._mel_spectrogram_compute_frame(\n streamingFramePtr,\n samples.length,\n streamingMelPtr\n )\n if (!ok) return null\n\n // Read mel output from WASM heap\n const offset = streamingMelPtr >> 2\n const result = new Array(streamingNMels)\n for (let i = 0; i < streamingNMels; i++) {\n result[i] = Module.HEAPF32[offset + i]\n }\n return result\n}\n\n/**\n * Computes a mel spectrogram via the WASM-compiled C++ implementation.\n * Lazy-loads the WASM module on first call.\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 const Module = await getModule()\n\n const fftLength = 2048\n const windowTypeInt = windowType === 'hamming' ? 1 : 0\n\n // Allocate input buffer on WASM heap\n const numSamples = audioData.length\n const inputPtr = Module._malloc(numSamples * 4) // 4 bytes per float\n Module.HEAPF32.set(audioData, inputPtr >> 2)\n\n // Call the C bridge\n const resultPtr = Module._mel_spectrogram_compute(\n inputPtr,\n numSamples,\n sampleRate,\n fftLength,\n windowSizeSamples,\n hopLengthSamples,\n nMels,\n fMin,\n fMax,\n windowTypeInt,\n logScale ? 1 : 0,\n normalize ? 1 : 0\n )\n\n // Free input buffer\n Module._free(inputPtr)\n\n if (resultPtr === 0) {\n throw new Error(\n 'mel_spectrogram_compute returned null (too few samples?)'\n )\n }\n\n // Read CMelSpectrogramResult struct (wasm32 pointers are 4 bytes)\n // struct layout: { float* data (offset 0), int timeSteps (offset 4), int nMels (offset 8) }\n const dataPtr = Module.getValue(resultPtr, 'i32')\n const timeSteps = Module.getValue(resultPtr + 4, 'i32')\n const resultNMels = Module.getValue(resultPtr + 8, 'i32')\n\n if (!dataPtr || timeSteps <= 0 || resultNMels <= 0) {\n Module._mel_spectrogram_free(resultPtr)\n throw new Error(\n 'mel_spectrogram_compute returned invalid result struct'\n )\n }\n\n // Copy spectrogram data to JS arrays\n const spectrogram: number[][] = []\n const heapOffset = dataPtr >> 2 // float32 offset into HEAPF32\n for (let t = 0; t < timeSteps; t++) {\n const row = new Array(resultNMels)\n for (let m = 0; m < resultNMels; m++) {\n row[m] = Module.HEAPF32[heapOffset + t * resultNMels + m]\n }\n spectrogram.push(row)\n }\n\n // Free the C result\n Module._mel_spectrogram_free(resultPtr)\n\n return spectrogram\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Version is inlined here — keep in sync with package.json when releasing.
|
|
2
2
|
// The publish.sh script should bump this string alongside package.json.
|
|
3
|
-
const WASM_VERSION = '3.0.2';
|
|
3
|
+
const WASM_VERSION = '3.0.2-beta.1';
|
|
4
4
|
// jsDelivr syncs from npm automatically within ~5 min of publish.
|
|
5
5
|
// GitHub release fallback (attach mel-spectrogram.js as a release asset):
|
|
6
6
|
// https://github.com/deeeed/audiolab/releases/download/@siteed/audio-studio@VERSION/mel-spectrogram.js
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasmConfig.js","sourceRoot":"","sources":["../../../src/AudioAnalysis/wasmConfig.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,wEAAwE;AACxE,MAAM,YAAY,GAAG,
|
|
1
|
+
{"version":3,"file":"wasmConfig.js","sourceRoot":"","sources":["../../../src/AudioAnalysis/wasmConfig.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,wEAAwE;AACxE,MAAM,YAAY,GAAG,cAAc,CAAA;AACnC,kEAAkE;AAClE,0EAA0E;AAC1E,yGAAyG;AACzG,8FAA8F;AAC9F,MAAM,gBAAgB,GAAG,qDAAqD,YAAY,mCAAmC,CAAA;AAE7H,IAAI,QAAQ,GAAW,gBAAgB,CAAA;AACvC,IAAI,mBAAmB,GAAwB,IAAI,CAAA;AAEnD,MAAM,UAAU,oBAAoB,CAAC,EAAc;IAC/C,mBAAmB,GAAG,EAAE,CAAA;AAC5B,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,GAAW;IAChD,QAAQ,GAAG,GAAG,CAAA;IACd,mBAAmB,EAAE,EAAE,CAAA,CAAC,mDAAmD;AAC/E,CAAC;AAED,MAAM,UAAU,wBAAwB;IACpC,OAAO,QAAQ,CAAA;AACnB,CAAC","sourcesContent":["// Version is inlined here — keep in sync with package.json when releasing.\n// The publish.sh script should bump this string alongside package.json.\nconst WASM_VERSION = '3.0.2-beta.1'\n// jsDelivr syncs from npm automatically within ~5 min of publish.\n// GitHub release fallback (attach mel-spectrogram.js as a release asset):\n// https://github.com/deeeed/audiolab/releases/download/@siteed/audio-studio@VERSION/mel-spectrogram.js\n// To use the fallback: setMelSpectrogramWasmUrl('<url>') before any mel-spectrogram API call.\nconst DEFAULT_WASM_CDN = `https://cdn.jsdelivr.net/npm/@siteed/audio-studio@${WASM_VERSION}/prebuilt/wasm/mel-spectrogram.js`\n\nlet _wasmUrl: string = DEFAULT_WASM_CDN\nlet _modulePromiseReset: (() => void) | null = null\n\nexport function _registerModuleReset(fn: () => void): void {\n _modulePromiseReset = fn\n}\n\nexport function setMelSpectrogramWasmUrl(url: string): void {\n _wasmUrl = url\n _modulePromiseReset?.() // invalidate cached module so next call re-fetches\n}\n\nexport function getMelSpectrogramWasmUrl(): string {\n return _wasmUrl\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audioFeaturesWasm.web.d.ts","sourceRoot":"","sources":["../../../src/AudioAnalysis/audioFeaturesWasm.web.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,uBAAuB;IACpC,gBAAgB,EAAE,MAAM,CAAA;IACxB,gBAAgB,EAAE,MAAM,CAAA;IACxB,eAAe,EAAE,MAAM,CAAA;IACvB,iBAAiB,EAAE,MAAM,CAAA;IACzB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,UAAU,EAAE,MAAM,EAAE,CAAA;CACvB;
|
|
1
|
+
{"version":3,"file":"audioFeaturesWasm.web.d.ts","sourceRoot":"","sources":["../../../src/AudioAnalysis/audioFeaturesWasm.web.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,uBAAuB;IACpC,gBAAgB,EAAE,MAAM,CAAA;IACxB,gBAAgB,EAAE,MAAM,CAAA;IACxB,eAAe,EAAE,MAAM,CAAA;IACvB,iBAAiB,EAAE,MAAM,CAAA;IACzB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,UAAU,EAAE,MAAM,EAAE,CAAA;CACvB;AAgFD;;;GAGG;AACH,wBAAsB,qBAAqB,CACvC,UAAU,EAAE,MAAM,EAClB,SAAS,SAAO,EAChB,KAAK,SAAK,EACV,WAAW,SAAK,EAChB,WAAW,UAAO,EAClB,aAAa,UAAO,GACrB,OAAO,CAAC,IAAI,CAAC,CAsBf;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CACzC,OAAO,EAAE,YAAY,GACtB,uBAAuB,GAAG,IAAI,CA2BhC;AAID;;;GAGG;AACH,wBAAsB,wBAAwB,CAC1C,SAAS,EAAE,YAAY,EACvB,UAAU,EAAE,MAAM,EAClB,SAAS,SAAO,EAChB,KAAK,SAAK,EACV,WAAW,SAAK,EAChB,WAAW,UAAO,EAClB,aAAa,UAAO,GACrB,OAAO,CAAC,uBAAuB,CAAC,CA4BlC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"melSpectrogramWasm.web.d.ts","sourceRoot":"","sources":["../../../src/AudioAnalysis/melSpectrogramWasm.web.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"melSpectrogramWasm.web.d.ts","sourceRoot":"","sources":["../../../src/AudioAnalysis/melSpectrogramWasm.web.ts"],"names":[],"mappings":"AAmCA;;;GAGG;AACH,wBAAsB,oBAAoB,CACtC,UAAU,EAAE,MAAM,EAClB,KAAK,SAAM,EACX,SAAS,SAAO,EAChB,iBAAiB,SAAM,EACvB,gBAAgB,SAAM,EACtB,IAAI,SAAI,EACR,IAAI,SAAI,GACT,OAAO,CAAC,IAAI,CAAC,CAuBf;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,EAAE,GAAG,IAAI,CA4B1E;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAC3C,SAAS,EAAE,YAAY,EACvB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,iBAAiB,EAAE,MAAM,EACzB,gBAAgB,EAAE,MAAM,EACxB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,OAAO,GAClB,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAgErB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@siteed/audio-studio",
|
|
3
|
-
"version": "3.0.2
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "Comprehensive audio processing library for React Native and Expo with recording, analysis, visualization, and streaming capabilities across iOS, Android, and web",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -17,7 +17,9 @@ function getModule(): Promise<AudioFeaturesWasmModule> {
|
|
|
17
17
|
modulePromise = (async () => {
|
|
18
18
|
const url = getMelSpectrogramWasmUrl()
|
|
19
19
|
// webpackIgnore + @vite-ignore prevent bundlers from trying to resolve the URL
|
|
20
|
-
const mod = await import(
|
|
20
|
+
const mod = await import(
|
|
21
|
+
/* webpackIgnore: true */ /* @vite-ignore */ url
|
|
22
|
+
)
|
|
21
23
|
const factory = mod.default ?? mod
|
|
22
24
|
return factory() as Promise<AudioFeaturesWasmModule>
|
|
23
25
|
})().catch((err) => {
|
|
@@ -12,7 +12,9 @@ function getModule(): Promise<MelSpectrogramWasmModule> {
|
|
|
12
12
|
modulePromise = (async () => {
|
|
13
13
|
const url = getMelSpectrogramWasmUrl()
|
|
14
14
|
// webpackIgnore + @vite-ignore prevent bundlers from trying to resolve the URL
|
|
15
|
-
const mod = await import(
|
|
15
|
+
const mod = await import(
|
|
16
|
+
/* webpackIgnore: true */ /* @vite-ignore */ url
|
|
17
|
+
)
|
|
16
18
|
const factory = mod.default ?? mod
|
|
17
19
|
return factory() as Promise<MelSpectrogramWasmModule>
|
|
18
20
|
})().catch((err) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Version is inlined here — keep in sync with package.json when releasing.
|
|
2
2
|
// The publish.sh script should bump this string alongside package.json.
|
|
3
|
-
const WASM_VERSION = '3.0.2'
|
|
3
|
+
const WASM_VERSION = '3.0.2-beta.1'
|
|
4
4
|
// jsDelivr syncs from npm automatically within ~5 min of publish.
|
|
5
5
|
// GitHub release fallback (attach mel-spectrogram.js as a release asset):
|
|
6
6
|
// https://github.com/deeeed/audiolab/releases/download/@siteed/audio-studio@VERSION/mel-spectrogram.js
|