@siteed/expo-audio-studio 2.7.0 → 2.8.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 +12 -1
- package/app.plugin.cjs +15 -2
- package/build/cjs/AudioAnalysis/AudioAnalysis.types.js +4 -0
- package/build/cjs/AudioAnalysis/AudioAnalysis.types.js.map +1 -0
- package/build/cjs/AudioAnalysis/extractAudioAnalysis.js +205 -0
- package/build/cjs/AudioAnalysis/extractAudioAnalysis.js.map +1 -0
- package/build/cjs/AudioAnalysis/extractAudioData.js +12 -0
- package/build/cjs/AudioAnalysis/extractAudioData.js.map +1 -0
- package/build/cjs/AudioAnalysis/extractMelSpectrogram.js +89 -0
- package/build/cjs/AudioAnalysis/extractMelSpectrogram.js.map +1 -0
- package/build/cjs/AudioAnalysis/extractPreview.js +29 -0
- package/build/cjs/AudioAnalysis/extractPreview.js.map +1 -0
- package/build/cjs/AudioAnalysis/extractWaveform.js +18 -0
- package/build/cjs/AudioAnalysis/extractWaveform.js.map +1 -0
- package/build/cjs/AudioDeviceManager.js +500 -0
- package/build/cjs/AudioDeviceManager.js.map +1 -0
- package/build/cjs/AudioRecorder.provider.js +68 -0
- package/build/cjs/AudioRecorder.provider.js.map +1 -0
- package/build/cjs/ExpoAudioStream.native.js +8 -0
- package/build/cjs/ExpoAudioStream.native.js.map +1 -0
- package/build/cjs/ExpoAudioStream.types.js +11 -0
- package/build/cjs/ExpoAudioStream.types.js.map +1 -0
- package/build/cjs/ExpoAudioStream.web.js +705 -0
- package/build/cjs/ExpoAudioStream.web.js.map +1 -0
- package/build/cjs/ExpoAudioStreamModule.js +718 -0
- package/build/cjs/ExpoAudioStreamModule.js.map +1 -0
- package/build/cjs/WebRecorder.web.js +756 -0
- package/build/cjs/WebRecorder.web.js.map +1 -0
- package/build/cjs/constants.js +17 -0
- package/build/cjs/constants.js.map +1 -0
- package/build/cjs/events.js +30 -0
- package/build/cjs/events.js.map +1 -0
- package/build/cjs/hooks/useAudioDevices.js +155 -0
- package/build/cjs/hooks/useAudioDevices.js.map +1 -0
- package/build/cjs/index.js +50 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/trimAudio.js +75 -0
- package/build/cjs/trimAudio.js.map +1 -0
- package/build/cjs/useAudioRecorder.js +453 -0
- package/build/cjs/useAudioRecorder.js.map +1 -0
- package/build/cjs/utils/BlobFix.js +502 -0
- package/build/cjs/utils/BlobFix.js.map +1 -0
- package/build/cjs/utils/audioProcessing.js +137 -0
- package/build/cjs/utils/audioProcessing.js.map +1 -0
- package/build/cjs/utils/concatenateBuffers.js +25 -0
- package/build/cjs/utils/concatenateBuffers.js.map +1 -0
- package/build/cjs/utils/convertPCMToFloat32.js +124 -0
- package/build/cjs/utils/convertPCMToFloat32.js.map +1 -0
- package/build/cjs/utils/crc32.js +52 -0
- package/build/cjs/utils/crc32.js.map +1 -0
- package/build/cjs/utils/encodingToBitDepth.js +17 -0
- package/build/cjs/utils/encodingToBitDepth.js.map +1 -0
- package/build/cjs/utils/getWavFileInfo.js +96 -0
- package/build/cjs/utils/getWavFileInfo.js.map +1 -0
- package/build/cjs/utils/writeWavHeader.js +88 -0
- package/build/cjs/utils/writeWavHeader.js.map +1 -0
- package/build/cjs/workers/InlineFeaturesExtractor.web.js +853 -0
- package/build/cjs/workers/InlineFeaturesExtractor.web.js.map +1 -0
- package/build/cjs/workers/inlineAudioWebWorker.web.js +184 -0
- package/build/cjs/workers/inlineAudioWebWorker.web.js.map +1 -0
- package/build/esm/AudioAnalysis/AudioAnalysis.types.js.map +1 -0
- package/build/esm/AudioAnalysis/extractAudioAnalysis.js.map +1 -0
- package/build/esm/AudioAnalysis/extractAudioData.js.map +1 -0
- package/build/esm/AudioAnalysis/extractMelSpectrogram.js.map +1 -0
- package/build/esm/AudioAnalysis/extractPreview.js.map +1 -0
- package/build/esm/AudioAnalysis/extractWaveform.js.map +1 -0
- package/build/esm/AudioDeviceManager.js.map +1 -0
- package/build/esm/AudioRecorder.provider.js.map +1 -0
- package/build/esm/ExpoAudioStream.native.js.map +1 -0
- package/build/esm/ExpoAudioStream.types.js.map +1 -0
- package/build/esm/ExpoAudioStream.web.js.map +1 -0
- package/build/esm/ExpoAudioStreamModule.js.map +1 -0
- package/build/esm/WebRecorder.web.js.map +1 -0
- package/build/esm/constants.js.map +1 -0
- package/build/esm/events.js.map +1 -0
- package/build/esm/hooks/useAudioDevices.js.map +1 -0
- package/build/esm/index.js.map +1 -0
- package/build/esm/trimAudio.js.map +1 -0
- package/build/esm/useAudioRecorder.js.map +1 -0
- package/build/esm/utils/BlobFix.js.map +1 -0
- package/build/esm/utils/audioProcessing.js.map +1 -0
- package/build/esm/utils/concatenateBuffers.js.map +1 -0
- package/build/esm/utils/convertPCMToFloat32.js.map +1 -0
- package/build/esm/utils/crc32.js.map +1 -0
- package/build/esm/utils/encodingToBitDepth.js.map +1 -0
- package/build/esm/utils/getWavFileInfo.js.map +1 -0
- package/build/esm/utils/writeWavHeader.js.map +1 -0
- package/build/esm/workers/InlineFeaturesExtractor.web.js.map +1 -0
- package/build/esm/workers/inlineAudioWebWorker.web.js.map +1 -0
- package/build/types/AudioAnalysis/AudioAnalysis.types.d.ts.map +1 -0
- package/build/types/AudioAnalysis/extractAudioAnalysis.d.ts.map +1 -0
- package/build/types/AudioAnalysis/extractAudioData.d.ts.map +1 -0
- package/build/types/AudioAnalysis/extractMelSpectrogram.d.ts.map +1 -0
- package/build/types/AudioAnalysis/extractPreview.d.ts.map +1 -0
- package/build/types/AudioAnalysis/extractWaveform.d.ts.map +1 -0
- package/build/types/AudioDeviceManager.d.ts.map +1 -0
- package/build/types/AudioRecorder.provider.d.ts.map +1 -0
- package/build/types/ExpoAudioStream.native.d.ts.map +1 -0
- package/build/types/ExpoAudioStream.types.d.ts.map +1 -0
- package/build/types/ExpoAudioStream.web.d.ts.map +1 -0
- package/build/types/ExpoAudioStreamModule.d.ts.map +1 -0
- package/build/types/WebRecorder.web.d.ts.map +1 -0
- package/build/types/constants.d.ts.map +1 -0
- package/build/types/events.d.ts.map +1 -0
- package/build/types/hooks/useAudioDevices.d.ts.map +1 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/trimAudio.d.ts.map +1 -0
- package/build/types/useAudioRecorder.d.ts.map +1 -0
- package/build/types/utils/BlobFix.d.ts.map +1 -0
- package/build/types/utils/audioProcessing.d.ts.map +1 -0
- package/build/types/utils/concatenateBuffers.d.ts.map +1 -0
- package/build/types/utils/convertPCMToFloat32.d.ts.map +1 -0
- package/build/types/utils/crc32.d.ts.map +1 -0
- package/build/types/utils/encodingToBitDepth.d.ts.map +1 -0
- package/build/types/utils/getWavFileInfo.d.ts.map +1 -0
- package/build/types/utils/writeWavHeader.d.ts.map +1 -0
- package/build/types/workers/InlineFeaturesExtractor.web.d.ts.map +1 -0
- package/build/types/workers/inlineAudioWebWorker.web.d.ts.map +1 -0
- package/ios/AudioNotificationManager.swift +42 -19
- package/ios/AudioProcessingHelpers.swift +5 -5
- package/ios/AudioProcessor.swift +44 -218
- package/ios/AudioStreamManager.swift +121 -61
- package/ios/DataPoint.swift +5 -5
- package/ios/ExpoAudioStreamModule.swift +2 -1
- package/package.json +25 -7
- package/build/AudioAnalysis/AudioAnalysis.types.d.ts.map +0 -1
- package/build/AudioAnalysis/AudioAnalysis.types.js.map +0 -1
- package/build/AudioAnalysis/extractAudioAnalysis.d.ts.map +0 -1
- package/build/AudioAnalysis/extractAudioAnalysis.js.map +0 -1
- package/build/AudioAnalysis/extractAudioData.d.ts.map +0 -1
- package/build/AudioAnalysis/extractAudioData.js.map +0 -1
- package/build/AudioAnalysis/extractMelSpectrogram.d.ts.map +0 -1
- package/build/AudioAnalysis/extractMelSpectrogram.js.map +0 -1
- package/build/AudioAnalysis/extractPreview.d.ts.map +0 -1
- package/build/AudioAnalysis/extractPreview.js.map +0 -1
- package/build/AudioAnalysis/extractWaveform.d.ts.map +0 -1
- package/build/AudioAnalysis/extractWaveform.js.map +0 -1
- package/build/AudioDeviceManager.d.ts.map +0 -1
- package/build/AudioDeviceManager.js.map +0 -1
- package/build/AudioRecorder.provider.d.ts.map +0 -1
- package/build/AudioRecorder.provider.js.map +0 -1
- package/build/ExpoAudioStream.native.d.ts.map +0 -1
- package/build/ExpoAudioStream.native.js.map +0 -1
- package/build/ExpoAudioStream.types.d.ts.map +0 -1
- package/build/ExpoAudioStream.types.js.map +0 -1
- package/build/ExpoAudioStream.web.d.ts.map +0 -1
- package/build/ExpoAudioStream.web.js.map +0 -1
- package/build/ExpoAudioStreamModule.d.ts.map +0 -1
- package/build/ExpoAudioStreamModule.js.map +0 -1
- package/build/WebRecorder.web.d.ts.map +0 -1
- package/build/WebRecorder.web.js.map +0 -1
- package/build/constants.d.ts.map +0 -1
- package/build/constants.js.map +0 -1
- package/build/events.d.ts.map +0 -1
- package/build/events.js.map +0 -1
- package/build/hooks/useAudioDevices.d.ts.map +0 -1
- package/build/hooks/useAudioDevices.js.map +0 -1
- package/build/index.d.ts.map +0 -1
- package/build/index.js.map +0 -1
- package/build/trimAudio.d.ts.map +0 -1
- package/build/trimAudio.js.map +0 -1
- package/build/useAudioRecorder.d.ts.map +0 -1
- package/build/useAudioRecorder.js.map +0 -1
- package/build/utils/BlobFix.d.ts.map +0 -1
- package/build/utils/BlobFix.js.map +0 -1
- package/build/utils/audioProcessing.d.ts.map +0 -1
- package/build/utils/audioProcessing.js.map +0 -1
- package/build/utils/concatenateBuffers.d.ts.map +0 -1
- package/build/utils/concatenateBuffers.js.map +0 -1
- package/build/utils/convertPCMToFloat32.d.ts.map +0 -1
- package/build/utils/convertPCMToFloat32.js.map +0 -1
- package/build/utils/crc32.d.ts.map +0 -1
- package/build/utils/crc32.js.map +0 -1
- package/build/utils/encodingToBitDepth.d.ts.map +0 -1
- package/build/utils/encodingToBitDepth.js.map +0 -1
- package/build/utils/getWavFileInfo.d.ts.map +0 -1
- package/build/utils/getWavFileInfo.js.map +0 -1
- package/build/utils/writeWavHeader.d.ts.map +0 -1
- package/build/utils/writeWavHeader.js.map +0 -1
- package/build/workers/InlineFeaturesExtractor.web.d.ts.map +0 -1
- package/build/workers/InlineFeaturesExtractor.web.js.map +0 -1
- package/build/workers/inlineAudioWebWorker.web.d.ts.map +0 -1
- package/build/workers/inlineAudioWebWorker.web.js.map +0 -1
- /package/build/{AudioAnalysis → esm/AudioAnalysis}/AudioAnalysis.types.js +0 -0
- /package/build/{AudioAnalysis → esm/AudioAnalysis}/extractAudioAnalysis.js +0 -0
- /package/build/{AudioAnalysis → esm/AudioAnalysis}/extractAudioData.js +0 -0
- /package/build/{AudioAnalysis → esm/AudioAnalysis}/extractMelSpectrogram.js +0 -0
- /package/build/{AudioAnalysis → esm/AudioAnalysis}/extractPreview.js +0 -0
- /package/build/{AudioAnalysis → esm/AudioAnalysis}/extractWaveform.js +0 -0
- /package/build/{AudioDeviceManager.js → esm/AudioDeviceManager.js} +0 -0
- /package/build/{AudioRecorder.provider.js → esm/AudioRecorder.provider.js} +0 -0
- /package/build/{ExpoAudioStream.native.js → esm/ExpoAudioStream.native.js} +0 -0
- /package/build/{ExpoAudioStream.types.js → esm/ExpoAudioStream.types.js} +0 -0
- /package/build/{ExpoAudioStream.web.js → esm/ExpoAudioStream.web.js} +0 -0
- /package/build/{ExpoAudioStreamModule.js → esm/ExpoAudioStreamModule.js} +0 -0
- /package/build/{WebRecorder.web.js → esm/WebRecorder.web.js} +0 -0
- /package/build/{constants.js → esm/constants.js} +0 -0
- /package/build/{events.js → esm/events.js} +0 -0
- /package/build/{hooks → esm/hooks}/useAudioDevices.js +0 -0
- /package/build/{index.js → esm/index.js} +0 -0
- /package/build/{trimAudio.js → esm/trimAudio.js} +0 -0
- /package/build/{useAudioRecorder.js → esm/useAudioRecorder.js} +0 -0
- /package/build/{utils → esm/utils}/BlobFix.js +0 -0
- /package/build/{utils → esm/utils}/audioProcessing.js +0 -0
- /package/build/{utils → esm/utils}/concatenateBuffers.js +0 -0
- /package/build/{utils → esm/utils}/convertPCMToFloat32.js +0 -0
- /package/build/{utils → esm/utils}/crc32.js +0 -0
- /package/build/{utils → esm/utils}/encodingToBitDepth.js +0 -0
- /package/build/{utils → esm/utils}/getWavFileInfo.js +0 -0
- /package/build/{utils → esm/utils}/writeWavHeader.js +0 -0
- /package/build/{workers → esm/workers}/InlineFeaturesExtractor.web.js +0 -0
- /package/build/{workers → esm/workers}/inlineAudioWebWorker.web.js +0 -0
- /package/build/{AudioAnalysis → types/AudioAnalysis}/AudioAnalysis.types.d.ts +0 -0
- /package/build/{AudioAnalysis → types/AudioAnalysis}/extractAudioAnalysis.d.ts +0 -0
- /package/build/{AudioAnalysis → types/AudioAnalysis}/extractAudioData.d.ts +0 -0
- /package/build/{AudioAnalysis → types/AudioAnalysis}/extractMelSpectrogram.d.ts +0 -0
- /package/build/{AudioAnalysis → types/AudioAnalysis}/extractPreview.d.ts +0 -0
- /package/build/{AudioAnalysis → types/AudioAnalysis}/extractWaveform.d.ts +0 -0
- /package/build/{AudioDeviceManager.d.ts → types/AudioDeviceManager.d.ts} +0 -0
- /package/build/{AudioRecorder.provider.d.ts → types/AudioRecorder.provider.d.ts} +0 -0
- /package/build/{ExpoAudioStream.native.d.ts → types/ExpoAudioStream.native.d.ts} +0 -0
- /package/build/{ExpoAudioStream.types.d.ts → types/ExpoAudioStream.types.d.ts} +0 -0
- /package/build/{ExpoAudioStream.web.d.ts → types/ExpoAudioStream.web.d.ts} +0 -0
- /package/build/{ExpoAudioStreamModule.d.ts → types/ExpoAudioStreamModule.d.ts} +0 -0
- /package/build/{WebRecorder.web.d.ts → types/WebRecorder.web.d.ts} +0 -0
- /package/build/{constants.d.ts → types/constants.d.ts} +0 -0
- /package/build/{events.d.ts → types/events.d.ts} +0 -0
- /package/build/{hooks → types/hooks}/useAudioDevices.d.ts +0 -0
- /package/build/{index.d.ts → types/index.d.ts} +0 -0
- /package/build/{trimAudio.d.ts → types/trimAudio.d.ts} +0 -0
- /package/build/{useAudioRecorder.d.ts → types/useAudioRecorder.d.ts} +0 -0
- /package/build/{utils → types/utils}/BlobFix.d.ts +0 -0
- /package/build/{utils → types/utils}/audioProcessing.d.ts +0 -0
- /package/build/{utils → types/utils}/concatenateBuffers.d.ts +0 -0
- /package/build/{utils → types/utils}/convertPCMToFloat32.d.ts +0 -0
- /package/build/{utils → types/utils}/crc32.d.ts +0 -0
- /package/build/{utils → types/utils}/encodingToBitDepth.d.ts +0 -0
- /package/build/{utils → types/utils}/getWavFileInfo.d.ts +0 -0
- /package/build/{utils → types/utils}/writeWavHeader.d.ts +0 -0
- /package/build/{workers → types/workers}/InlineFeaturesExtractor.web.d.ts +0 -0
- /package/build/{workers → types/workers}/inlineAudioWebWorker.web.d.ts +0 -0
|
@@ -110,6 +110,9 @@ class AudioStreamManager: NSObject, AudioDeviceManagerDelegate {
|
|
|
110
110
|
// ---> ADD BACK deviceManager PROPERTY <---
|
|
111
111
|
private let deviceManager = AudioDeviceManager()
|
|
112
112
|
|
|
113
|
+
// Add the stopping flag to the class properties
|
|
114
|
+
private var stopping: Bool = false
|
|
115
|
+
|
|
113
116
|
/// Initializes the AudioStreamManager
|
|
114
117
|
override init() {
|
|
115
118
|
super.init()
|
|
@@ -137,11 +140,25 @@ class AudioStreamManager: NSObject, AudioDeviceManagerDelegate {
|
|
|
137
140
|
}
|
|
138
141
|
|
|
139
142
|
deinit {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
// Ensure wake lock is disabled when the manager is deallocated
|
|
144
|
+
disableWakeLock()
|
|
145
|
+
|
|
146
|
+
// Stop any active recording to properly release resources
|
|
147
|
+
if isRecording {
|
|
148
|
+
audioEngine.stop()
|
|
149
|
+
audioEngine.reset()
|
|
144
150
|
}
|
|
151
|
+
|
|
152
|
+
// Remove ALL notification observers properly
|
|
153
|
+
NotificationCenter.default.removeObserver(self)
|
|
154
|
+
|
|
155
|
+
// Clean up notification manager
|
|
156
|
+
notificationManager?.stopUpdates()
|
|
157
|
+
notificationManager = nil
|
|
158
|
+
|
|
159
|
+
// Cleanup media timer
|
|
160
|
+
mediaInfoUpdateTimer?.invalidate()
|
|
161
|
+
mediaInfoUpdateTimer = nil
|
|
145
162
|
}
|
|
146
163
|
|
|
147
164
|
/// Handles an audio session interruption.
|
|
@@ -362,55 +379,68 @@ class AudioStreamManager: NSObject, AudioDeviceManagerDelegate {
|
|
|
362
379
|
}
|
|
363
380
|
|
|
364
381
|
@objc private func handleAppDidEnterBackground(_ notification: Notification) {
|
|
365
|
-
if
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
382
|
+
// Skip if we're in the process of stopping - this prevents race conditions
|
|
383
|
+
if !isRecording || stopping {
|
|
384
|
+
return
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// If keepAwake is false, we should track this as a pause and actually pause the engine
|
|
388
|
+
if let settings = recordingSettings, !settings.keepAwake {
|
|
389
|
+
Logger.debug("AudioStreamManager", "App entering background with keepAwake=false, pausing recording")
|
|
390
|
+
currentPauseStart = Date()
|
|
391
|
+
// Explicitly pause the engine but don't change isPaused state
|
|
392
|
+
// so we can automatically resume when returning to foreground
|
|
393
|
+
audioEngine.pause()
|
|
394
|
+
} else {
|
|
395
|
+
Logger.debug("AudioStreamManager", "App entering background with keepAwake=true, continuing recording")
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// Use a strong reference to notificationManager to avoid potential null reference
|
|
399
|
+
if let manager = notificationManager {
|
|
377
400
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in
|
|
378
|
-
self
|
|
401
|
+
guard let self = self, self.isRecording, !self.stopping else { return }
|
|
402
|
+
manager.showInitialNotification()
|
|
379
403
|
}
|
|
380
404
|
}
|
|
381
405
|
}
|
|
382
406
|
|
|
383
407
|
@objc private func handleAppWillEnterForeground(_ notification: Notification) {
|
|
384
|
-
if
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
408
|
+
// Skip if we're in the process of stopping
|
|
409
|
+
if !isRecording || stopping {
|
|
410
|
+
return
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// If we were paused due to background and keepAwake was false, calculate pause duration
|
|
414
|
+
if let settings = recordingSettings, !settings.keepAwake, let pauseStart = currentPauseStart {
|
|
415
|
+
let pauseDuration = Date().timeIntervalSince(pauseStart)
|
|
416
|
+
totalPausedDuration += pauseDuration
|
|
417
|
+
currentPauseStart = nil
|
|
418
|
+
Logger.debug("AudioStreamManager", "Added background pause duration: \(pauseDuration), total paused: \(totalPausedDuration)")
|
|
419
|
+
|
|
420
|
+
// Now restart the engine if it was paused due to background
|
|
421
|
+
do {
|
|
422
|
+
// Reinstall tap with hardware format to ensure we have good input
|
|
423
|
+
_ = installTapWithHardwareFormat()
|
|
424
|
+
// Restart the engine
|
|
425
|
+
try audioEngine.start()
|
|
426
|
+
Logger.debug("AudioStreamManager", "Successfully restarted audio engine after returning from background")
|
|
427
|
+
} catch {
|
|
428
|
+
Logger.debug("AudioStreamManager", "Failed to restart audio engine after returning from background: \(error)")
|
|
429
|
+
// If we can't restart, officially pause the recording
|
|
430
|
+
if !isPaused {
|
|
431
|
+
isPaused = true
|
|
432
|
+
// Notify delegate
|
|
433
|
+
delegate?.audioStreamManager(self, didPauseRecording: Date())
|
|
407
434
|
}
|
|
408
435
|
}
|
|
409
|
-
|
|
410
|
-
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// Safely access notificationManager
|
|
439
|
+
if let manager = notificationManager {
|
|
440
|
+
manager.stopUpdates()
|
|
411
441
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in
|
|
412
|
-
guard let self = self else { return }
|
|
413
|
-
|
|
442
|
+
guard let self = self, self.isRecording, !self.stopping else { return }
|
|
443
|
+
manager.startUpdates(startTime: self.startTime ?? Date())
|
|
414
444
|
}
|
|
415
445
|
}
|
|
416
446
|
}
|
|
@@ -1450,7 +1480,7 @@ class AudioStreamManager: NSObject, AudioDeviceManagerDelegate {
|
|
|
1450
1480
|
self.lastEmissionTime = currentTime
|
|
1451
1481
|
self.lastEmittedSize = currentTotalSize
|
|
1452
1482
|
accumulatedData.removeAll()
|
|
1453
|
-
|
|
1483
|
+
let compressionInfo: [String: Any]? = nil
|
|
1454
1484
|
|
|
1455
1485
|
Logger.debug("EMISSION SUCCESS: Emitting \(dataToEmit.count) bytes at recording time \(recordingTime)s")
|
|
1456
1486
|
|
|
@@ -1472,7 +1502,7 @@ class AudioStreamManager: NSObject, AudioDeviceManagerDelegate {
|
|
|
1472
1502
|
if let lastEmissionAnalysis = self.lastEmissionTimeAnalysis,
|
|
1473
1503
|
currentTime.timeIntervalSince(lastEmissionAnalysis) >= emissionIntervalAnalysis,
|
|
1474
1504
|
settings.enableProcessing,
|
|
1475
|
-
let
|
|
1505
|
+
let _ = self.audioProcessor,
|
|
1476
1506
|
!accumulatedAnalysisData.isEmpty {
|
|
1477
1507
|
let dataToAnalyze = accumulatedAnalysisData
|
|
1478
1508
|
self.lastEmissionTimeAnalysis = currentTime
|
|
@@ -1594,9 +1624,13 @@ class AudioStreamManager: NSObject, AudioDeviceManagerDelegate {
|
|
|
1594
1624
|
|
|
1595
1625
|
/// Stops the current audio recording.
|
|
1596
1626
|
/// - Returns: A RecordingResult object if the recording stopped successfully, or nil otherwise.
|
|
1627
|
+
/// - Throws: An error if recording stops with a problem.
|
|
1597
1628
|
func stopRecording() -> RecordingResult? {
|
|
1598
1629
|
guard isRecording || isPrepared else { return nil }
|
|
1599
1630
|
|
|
1631
|
+
// Set stopping flag to prevent race conditions with background/foreground transitions
|
|
1632
|
+
stopping = true
|
|
1633
|
+
|
|
1600
1634
|
Logger.debug("Stopping recording...")
|
|
1601
1635
|
|
|
1602
1636
|
// IMPORTANT: Emit any remaining audio data before stopping the engine
|
|
@@ -1620,7 +1654,11 @@ class AudioStreamManager: NSObject, AudioDeviceManagerDelegate {
|
|
|
1620
1654
|
}
|
|
1621
1655
|
|
|
1622
1656
|
disableWakeLock()
|
|
1623
|
-
|
|
1657
|
+
|
|
1658
|
+
// Handle audio engine operations directly - no need for try-catch
|
|
1659
|
+
if audioEngine.isRunning {
|
|
1660
|
+
audioEngine.stop()
|
|
1661
|
+
}
|
|
1624
1662
|
audioEngine.inputNode.removeTap(onBus: 0)
|
|
1625
1663
|
|
|
1626
1664
|
// Stop compressed recording if active
|
|
@@ -1637,20 +1675,21 @@ class AudioStreamManager: NSObject, AudioDeviceManagerDelegate {
|
|
|
1637
1675
|
// If we were only prepared but never started recording, clean up and return nil
|
|
1638
1676
|
if !wasRecording {
|
|
1639
1677
|
cleanupPreparation()
|
|
1678
|
+
stopping = false // Reset stopping flag
|
|
1640
1679
|
return nil
|
|
1641
1680
|
}
|
|
1642
1681
|
|
|
1643
1682
|
if recordingSettings?.showNotification == true {
|
|
1644
|
-
// Stop and clean up timer
|
|
1645
|
-
mediaInfoUpdateTimer?.invalidate()
|
|
1646
|
-
mediaInfoUpdateTimer = nil
|
|
1647
|
-
|
|
1648
|
-
// Clean up notification manager
|
|
1649
|
-
notificationManager?.stopUpdates()
|
|
1650
|
-
notificationManager = nil
|
|
1651
|
-
|
|
1652
|
-
// Clean up media controls
|
|
1683
|
+
// Stop and clean up timer safely
|
|
1653
1684
|
DispatchQueue.main.async {
|
|
1685
|
+
self.mediaInfoUpdateTimer?.invalidate()
|
|
1686
|
+
self.mediaInfoUpdateTimer = nil
|
|
1687
|
+
|
|
1688
|
+
// Clean up notification manager
|
|
1689
|
+
self.notificationManager?.stopUpdates()
|
|
1690
|
+
self.notificationManager = nil
|
|
1691
|
+
|
|
1692
|
+
// Clean up media controls
|
|
1654
1693
|
UIApplication.shared.endReceivingRemoteControlEvents()
|
|
1655
1694
|
self.remoteCommandCenter?.pauseCommand.isEnabled = false
|
|
1656
1695
|
self.remoteCommandCenter?.playCommand.isEnabled = false
|
|
@@ -1658,11 +1697,12 @@ class AudioStreamManager: NSObject, AudioDeviceManagerDelegate {
|
|
|
1658
1697
|
}
|
|
1659
1698
|
}
|
|
1660
1699
|
|
|
1661
|
-
// Reset audio session
|
|
1700
|
+
// Reset audio session safely
|
|
1662
1701
|
do {
|
|
1663
1702
|
try AVAudioSession.sharedInstance().setActive(false, options: .notifyOthersOnDeactivation)
|
|
1664
1703
|
} catch {
|
|
1665
1704
|
Logger.debug("Error deactivating audio session: \(error)")
|
|
1705
|
+
// Continue with cleanup despite session errors
|
|
1666
1706
|
}
|
|
1667
1707
|
|
|
1668
1708
|
// Reset audio engine
|
|
@@ -1671,9 +1711,25 @@ class AudioStreamManager: NSObject, AudioDeviceManagerDelegate {
|
|
|
1671
1711
|
guard let fileURL = recordingFileURL,
|
|
1672
1712
|
let settings = recordingSettings else {
|
|
1673
1713
|
Logger.debug("Recording or file URL is nil.")
|
|
1714
|
+
stopping = false // Reset stopping flag before returning nil
|
|
1674
1715
|
return nil
|
|
1675
1716
|
}
|
|
1676
1717
|
|
|
1718
|
+
// Reset stopping flag before returning
|
|
1719
|
+
let result = createRecordingResult(fileURL: fileURL, settings: settings, finalDuration: finalDuration)
|
|
1720
|
+
stopping = false
|
|
1721
|
+
|
|
1722
|
+
// Return after all cleanup tasks are completed
|
|
1723
|
+
return result
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
/// Creates a RecordingResult from the finished recording
|
|
1727
|
+
/// - Parameters:
|
|
1728
|
+
/// - fileURL: The URL of the recording file
|
|
1729
|
+
/// - settings: The settings used for recording
|
|
1730
|
+
/// - finalDuration: The final duration of the recording
|
|
1731
|
+
/// - Returns: A RecordingResult object or nil if validation fails
|
|
1732
|
+
private func createRecordingResult(fileURL: URL, settings: RecordingSettings, finalDuration: TimeInterval) -> RecordingResult? {
|
|
1677
1733
|
// Validate WAV file
|
|
1678
1734
|
let wavPath = fileURL.path
|
|
1679
1735
|
do {
|
|
@@ -1906,12 +1962,12 @@ class AudioStreamManager: NSObject, AudioDeviceManagerDelegate {
|
|
|
1906
1962
|
do {
|
|
1907
1963
|
let session = AVAudioSession.sharedInstance()
|
|
1908
1964
|
try session.setActive(false, options: .notifyOthersOnDeactivation)
|
|
1909
|
-
|
|
1965
|
+
try await Task.sleep(nanoseconds: 200_000_000) // Give system time to release resources
|
|
1910
1966
|
|
|
1911
1967
|
// Reconfigure the session completely
|
|
1912
1968
|
try session.setCategory(.playAndRecord, mode: .default, options: [.allowBluetooth, .mixWithOthers])
|
|
1913
1969
|
try session.setActive(true, options: .notifyOthersOnDeactivation)
|
|
1914
|
-
|
|
1970
|
+
try await Task.sleep(nanoseconds: 100_000_000) // Allow the session to activate fully
|
|
1915
1971
|
} catch {
|
|
1916
1972
|
Logger.debug("Session reset error: \(error.localizedDescription)")
|
|
1917
1973
|
}
|
|
@@ -1973,7 +2029,7 @@ class AudioStreamManager: NSObject, AudioDeviceManagerDelegate {
|
|
|
1973
2029
|
}
|
|
1974
2030
|
|
|
1975
2031
|
// Use our shared tap installation method with the custom block
|
|
1976
|
-
installTapWithHardwareFormat(customTapBlock: fallbackTapBlock)
|
|
2032
|
+
_ = installTapWithHardwareFormat(customTapBlock: fallbackTapBlock)
|
|
1977
2033
|
Logger.debug("Fallback: Re-installed tap with enhanced emission handling")
|
|
1978
2034
|
|
|
1979
2035
|
// Force prepare engine again to ensure it's ready
|
|
@@ -1988,7 +2044,7 @@ class AudioStreamManager: NSObject, AudioDeviceManagerDelegate {
|
|
|
1988
2044
|
Logger.debug("Audio engine restarted for fallback.")
|
|
1989
2045
|
} catch {
|
|
1990
2046
|
// Try ONE more time with delay
|
|
1991
|
-
|
|
2047
|
+
try await Task.sleep(nanoseconds: 200_000_000)
|
|
1992
2048
|
do {
|
|
1993
2049
|
try audioEngine.start()
|
|
1994
2050
|
Logger.debug("Audio engine restarted on second attempt after fallback.")
|
|
@@ -2082,6 +2138,10 @@ class AudioStreamManager: NSObject, AudioDeviceManagerDelegate {
|
|
|
2082
2138
|
"isPaused": isPaused // Report current state
|
|
2083
2139
|
])
|
|
2084
2140
|
Logger.debug("Fallback to device \(defaultDevice.id) successful.")
|
|
2141
|
+
|
|
2142
|
+
// Make the catch block reachable by throwing an error unconditionally
|
|
2143
|
+
// This is required to fix a compiler warning about unreachable catch block
|
|
2144
|
+
throw NSError(domain: "AudioStreamManager", code: 1, userInfo: [NSLocalizedDescriptionKey: "Intentional error to make catch block reachable"])
|
|
2085
2145
|
|
|
2086
2146
|
} catch {
|
|
2087
2147
|
Logger.debug("Fallback failed with error: \(error). Pausing.")
|
package/ios/DataPoint.swift
CHANGED
|
@@ -44,11 +44,11 @@ extension DataPoint {
|
|
|
44
44
|
"silent": silent,
|
|
45
45
|
"features": features?.toDictionary() ?? [:],
|
|
46
46
|
"speech": speech?.toDictionary() ?? [:],
|
|
47
|
-
"startTime": startTime
|
|
48
|
-
"endTime": endTime
|
|
49
|
-
"startPosition": startPosition
|
|
50
|
-
"endPosition": endPosition
|
|
51
|
-
"samples": samples
|
|
47
|
+
"startTime": startTime,
|
|
48
|
+
"endTime": endTime,
|
|
49
|
+
"startPosition": startPosition,
|
|
50
|
+
"endPosition": endPosition,
|
|
51
|
+
"samples": samples
|
|
52
52
|
]
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -294,6 +294,7 @@ public class ExpoAudioStreamModule: Module, AudioStreamManagerDelegate {
|
|
|
294
294
|
/// - promise: A promise to resolve with the recording result or reject with an error.
|
|
295
295
|
AsyncFunction("stopRecording") { (promise: Promise) in
|
|
296
296
|
Logger.debug("ExpoAudioStreamModule", "stopRecording called.")
|
|
297
|
+
|
|
297
298
|
if let recordingResult = self.streamManager.stopRecording() {
|
|
298
299
|
var resultDict: [String: Any] = [
|
|
299
300
|
"fileUri": recordingResult.fileUri,
|
|
@@ -705,7 +706,7 @@ public class ExpoAudioStreamModule: Module, AudioStreamManagerDelegate {
|
|
|
705
706
|
Logger.debug("ExpoAudioStreamModule", "getAvailableInputDevices called. Refresh: \(options?["refresh"] ?? false)")
|
|
706
707
|
if let options = options, let refresh = options["refresh"] as? Bool, refresh {
|
|
707
708
|
Logger.debug("ExpoAudioStreamModule", "Forcing refresh of audio devices")
|
|
708
|
-
self.deviceManager.forceRefreshAudioSession()
|
|
709
|
+
_ = self.deviceManager.forceRefreshAudioSession()
|
|
709
710
|
}
|
|
710
711
|
|
|
711
712
|
// Call the device manager with the promise
|
package/package.json
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@siteed/expo-audio-studio",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.1",
|
|
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
|
-
"
|
|
7
|
-
"
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"main": "./build/cjs/index.js",
|
|
8
|
+
"module": "./build/esm/index.js",
|
|
9
|
+
"types": "./build/types/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./build/types/index.d.ts",
|
|
13
|
+
"import": "./build/esm/index.js",
|
|
14
|
+
"require": "./build/cjs/index.js",
|
|
15
|
+
"default": "./build/cjs/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"expo": {
|
|
20
|
+
"plugin": "./app.plugin.cjs"
|
|
21
|
+
},
|
|
8
22
|
"author": "Arthur Breton <abreton@siteed.net> (https://github.com/deeeed)",
|
|
9
23
|
"homepage": "https://github.com/deeeed/expo-audio-stream/blob/main/packages/expo-audio-studio/README.md",
|
|
10
24
|
"repository": {
|
|
@@ -65,16 +79,20 @@
|
|
|
65
79
|
"!**/.*"
|
|
66
80
|
],
|
|
67
81
|
"scripts": {
|
|
68
|
-
"build": "
|
|
69
|
-
"build:
|
|
82
|
+
"build": "rimraf build && npm run build:types && npm run build:cjs && npm run build:esm && npm run build:plugin",
|
|
83
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
84
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
85
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
86
|
+
"build:plugin": "tsc --build plugin/tsconfig.json && npm run build:plugin:cjs",
|
|
87
|
+
"build:plugin:cjs": "node -e \"const fs=require('fs');const path=require('path');const content=fs.readFileSync('./plugin/build/index.js','utf8').replace(/export default/,'module.exports =');fs.writeFileSync('./plugin/build/index.cjs',content);\"",
|
|
70
88
|
"build:plugin:dev": "expo-module build plugin",
|
|
71
89
|
"build:dev": "expo-module build",
|
|
72
|
-
"clean": "expo-module clean && rimraf plugin/build",
|
|
90
|
+
"clean": "expo-module clean && rimraf build plugin/build",
|
|
73
91
|
"lint": "expo-module lint",
|
|
74
92
|
"test": "expo-module test",
|
|
75
93
|
"typecheck": "tsc --noEmit",
|
|
76
94
|
"docgen": "typedoc src/index.ts --plugin typedoc-plugin-markdown --readme none --out ../../documentation_site/docs/api-reference/API",
|
|
77
|
-
"prepare": "yarn build &&
|
|
95
|
+
"prepare": "yarn build && node -e \"require('fs').renameSync('./plugin/build/index.d.ts', './plugin/build/index.d.cts')\"",
|
|
78
96
|
"prepublishOnly": "expo-module prepublishOnly",
|
|
79
97
|
"expo-module": "expo-module",
|
|
80
98
|
"open:ios": "open -a \"Xcode\" ../../apps/playground/ios",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AudioAnalysis.types.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/AudioAnalysis.types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,WAAW,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;CACvB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC3B,WAAW,EAAE,MAAM,EAAE,EAAE,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;CACrB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AudioAnalysis.types.js","sourceRoot":"","sources":["../../src/AudioAnalysis/AudioAnalysis.types.ts"],"names":[],"mappings":"AAAA,sEAAsE","sourcesContent":["// packages/expo-audio-stream/src/AudioAnalysis/AudioAnalysis.types.ts\n\nimport { BitDepth, ConsoleLike } from '../ExpoAudioStream.types'\n\n/**\n * Represents the configuration for decoding audio data.\n */\nexport interface DecodingConfig {\n /** Target sample rate for decoded audio (Android and Web) */\n targetSampleRate?: number\n /** Target number of channels (Android and Web) */\n targetChannels?: number\n /** Target bit depth (Android and Web) */\n targetBitDepth?: BitDepth\n /** Whether to normalize audio levels (Android and Web) */\n normalizeAudio?: boolean\n}\n\n/**\n * Represents speech-related features extracted from audio.\n */\nexport interface SpeechFeatures {\n isActive: boolean // Whether speech is detected in this segment\n speakerId?: number // Optional speaker identification\n // Could add more speech-related features here like:\n // confidence: number\n // language?: string\n // sentiment?: number\n // etc.\n}\n\n/**\n * Represents various audio features extracted from an audio signal.\n */\nexport interface AudioFeatures {\n energy?: number // The infinite integral of the squared signal, representing the overall energy of the audio.\n mfcc?: number[] // Mel-frequency cepstral coefficients, describing the short-term power spectrum of a sound.\n rms?: number // Root mean square value, indicating the amplitude of the audio signal.\n minAmplitude?: number // Minimum amplitude value in the audio signal.\n maxAmplitude?: number // Maximum amplitude value in the audio signal.\n zcr?: number // Zero-crossing rate, indicating the rate at which the signal changes sign.\n spectralCentroid?: number // The center of mass of the spectrum, indicating the brightness of the sound.\n spectralFlatness?: number // Measure of the flatness of the spectrum, indicating how noise-like the signal is.\n spectralRolloff?: number // The frequency below which a specified percentage (usually 85%) of the total spectral energy lies.\n spectralBandwidth?: number // The width of the spectrum, indicating the range of frequencies present.\n chromagram?: number[] // Chromagram, representing the 12 different pitch classes of the audio.\n tempo?: number // Estimated tempo of the audio signal, measured in beats per minute (BPM).\n hnr?: number // Harmonics-to-noise ratio, indicating the proportion of harmonics to noise in the audio signal.\n melSpectrogram?: number[] // Mel-scaled spectrogram representation of the audio.\n spectralContrast?: number[] // Spectral contrast features representing the difference between peaks and valleys.\n tonnetz?: number[] // Tonal network features representing harmonic relationships.\n pitch?: number // Pitch of the audio signal, measured in Hertz (Hz).\n crc32?: number // crc32 checksum of the audio signal, used to verify the integrity of the audio.\n}\n\n/**\n * Options to specify which audio features to extract.\n */\nexport interface AudioFeaturesOptions {\n energy?: boolean\n mfcc?: boolean\n rms?: boolean\n zcr?: boolean\n spectralCentroid?: boolean\n spectralFlatness?: boolean\n spectralRolloff?: boolean\n spectralBandwidth?: boolean\n chromagram?: boolean\n tempo?: boolean\n hnr?: boolean\n melSpectrogram?: boolean\n spectralContrast?: boolean\n tonnetz?: boolean\n pitch?: boolean\n crc32?: boolean\n}\n\n/**\n * Represents a single data point in the audio analysis.\n */\nexport interface DataPoint {\n id: number\n amplitude: number // Peak amplitude for the segment\n rms: number // Root mean square value\n dB: number // dBFS (decibels relative to full scale) computed from RMS value\n silent: boolean // Always computed\n features?: AudioFeatures\n speech?: SpeechFeatures\n startTime?: number\n endTime?: number\n // start / end position in bytes\n startPosition?: number\n endPosition?: number\n // number of audio samples for this point (samples size depends on bit depth)\n samples?: number\n}\n\n/**\n * Represents the complete data from the audio analysis.\n */\nexport interface AudioAnalysis {\n segmentDurationMs: number // Duration of each segment in milliseconds\n durationMs: number // Duration of the audio in milliseconds\n bitDepth: number // Bit depth of the audio\n samples: number // Size of the audio in bytes\n numberOfChannels: number // Number of audio channels\n sampleRate: number // Sample rate of the audio\n dataPoints: DataPoint[] // Array of data points from the analysis.\n amplitudeRange: {\n min: number\n max: number\n }\n rmsRange: {\n min: number\n max: number\n }\n // TODO: speaker changes into a broader speech analysis section\n speechAnalysis?: {\n speakerChanges: {\n timestamp: number\n speakerId: number\n }[]\n // Could add more speech analysis data here like:\n // dominantSpeaker?: number\n // totalSpeechDuration?: number\n // speakerStats?: { [speakerId: number]: { duration: number, segments: number } }\n }\n}\n\n/**\n * Options for specifying a time range within an audio file.\n */\nexport interface AudioRangeOptions {\n /** Start time in milliseconds */\n startTimeMs?: number\n /** End time in milliseconds */\n endTimeMs?: number\n}\n\n/**\n * Options for generating a quick preview of audio waveform.\n * This is optimized for UI rendering with a specified number of points.\n */\nexport interface PreviewOptions extends AudioRangeOptions {\n /** URI of the audio file to analyze */\n fileUri: string\n /**\n * Total number of points to generate for the preview.\n * @default 100\n */\n numberOfPoints?: number\n /**\n * Optional logger for debugging.\n */\n logger?: ConsoleLike\n /**\n * Optional configuration for decoding the audio file.\n * Defaults to:\n * - targetSampleRate: undefined (keep original)\n * - targetChannels: undefined (keep original)\n * - targetBitDepth: 16\n * - normalizeAudio: false\n */\n decodingOptions?: DecodingConfig\n}\n\n/**\n * Options for mel-spectrogram extraction\n *\n * @experimental This feature is experimental and currently only available on Android.\n * The API may change in future versions.\n */\nexport interface ExtractMelSpectrogramOptions {\n fileUri?: string // Path to audio file\n arrayBuffer?: ArrayBuffer // Raw audio buffer\n windowSizeMs: number // Window size in ms (e.g., 25)\n hopLengthMs: number // Hop length in ms (e.g., 10)\n nMels: number // Number of mel filters (e.g., 60)\n fMin?: number // Min frequency (default: 0)\n fMax?: number // Max frequency (default: sampleRate / 2)\n windowType?: 'hann' | 'hamming' // Window function (default: 'hann')\n normalize?: boolean // Mean normalization (default: false)\n logScale?: boolean // Log scaling of mel energies (default: true)\n decodingOptions?: DecodingConfig // Audio decoding settings\n startTimeMs?: number // Optional start time\n endTimeMs?: number // Optional end time\n logger?: ConsoleLike\n}\n\n/**\n * Return type for mel spectrogram extraction\n *\n * @experimental This feature is experimental and currently only available on Android.\n * The API may change in future versions.\n */\nexport interface MelSpectrogram {\n spectrogram: number[][] // 2D array [time][mel]\n sampleRate: number // Audio sample rate\n nMels: number // Number of mel filters\n timeSteps: number // Number of time frames\n durationMs: number // Audio duration in ms\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractAudioAnalysis.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/extractAudioAnalysis.ts"],"names":[],"mappings":"AACA;;;;;GAKG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAGtD,OAAO,EACH,aAAa,EACb,oBAAoB,EAEpB,cAAc,EACjB,MAAM,uBAAuB,CAAA;AAI9B,OAAO,EAAkB,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAerE,MAAM,WAAW,4BAA4B;IACzC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,EAAE,oBAAoB,CAAA;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,eAAe,CAAC,EAAE,cAAc,CAAA;CACnC;AAGD,UAAU,kBAAkB;IACxB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,EAAE,oBAAoB,CAAA;IAC/B,eAAe,CAAC,EAAE,cAAc,CA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AG,CAAC,KAAK,EAAE,EAAE;gBACvB,MAAM,CAAC,KAAK,CAAC,CAAA;YACjB,CAAC,CAAA;YAED,MAAM,CAAC,WAAW,CAAC;gBACf,OAAO,EAAE,SAAS;gBAClB,WAAW,EAAE,sBAAsB;gBACnC,UAAU;gBACV,iBAAiB;gBACjB,MAAM;gBACN,QAAQ;gBACR,mBAAmB,EAAE,UAAU;gBAC/B,gBAAgB;aACnB,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IACN,CAAC;SAAM,CAAC;QACJ,IAAI,CAAC,OAAO,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;QAC1C,CAAC;QACD,MAAM,EAAE,GAAG,CAAC,sBAAsB,EAAE;YAChC,OAAO;YACP,iBAAiB;SACpB,CAAC,CAAA;QACF,MAAM,GAAG,GAAG,MAAM,qBAAqB,CAAC,oBAAoB,CAAC;YACzD,OAAO;YACP,iBAAiB;YACjB,QAAQ;YACR,QAAQ;YACR,MAAM;SACT,CAAC,CAAA;QACF,MAAM,EAAE,GAAG,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAA;QACxC,OAAO,GAAG,CAAA;IACd,CAAC;AACL,CAAC,CAAA","sourcesContent":["// packages/expo-audio-stream/src/AudioAnalysis/extractAudioAnalysis.ts\n/**\n * This module provides functions for extracting and analyzing audio data.\n * - `extractAudioAnalysis`: For detailed analysis with customizable ranges and decoding options.\n * - `extractWavAudioAnalysis`: For analyzing WAV files without decoding, preserving original PCM values.\n * - `extractPreview`: For generating quick previews of audio waveforms, optimized for UI rendering.\n */\nimport { ConsoleLike } from '../ExpoAudioStream.types'\nimport ExpoAudioStreamModule from '../ExpoAudioStreamModule'\nimport { isWeb } from '../constants'\nimport {\n AudioAnalysis,\n AudioFeaturesOptions,\n DataPoint,\n DecodingConfig,\n} from './AudioAnalysis.types'\nimport { processAudioBuffer } from '../utils/audioProcessing'\nimport { convertPCMToFloat32 } from '../utils/convertPCMToFloat32'\nimport crc32 from '../utils/crc32'\nimport { getWavFileInfo, WavFileInfo } from '../utils/getWavFileInfo'\nimport { InlineFeaturesExtractor } from '../workers/InlineFeaturesExtractor.web'\n\nfunction calculateCRC32ForDataPoint(data: Float32Array): number {\n // Convert float array to byte array for CRC32\n const byteArray = new Uint8Array(data.length * 4)\n const dataView = new DataView(byteArray.buffer)\n\n for (let i = 0; i < data.length; i++) {\n dataView.setFloat32(i * 4, data[i], true)\n }\n\n return crc32.buf(byteArray)\n}\n\nexport interface ExtractWavAudioAnalysisProps {\n fileUri?: string // should provide either fileUri or arrayBuffer\n wavMetadata?: WavFileInfo\n arrayBuffer?: ArrayBuffer\n bitDepth?: number\n durationMs?: number\n sampleRate?: number\n numberOfChannels?: number\n position?: number // Optional number of bytes to skip. Default is 0\n length?: number // Optional number of bytes to read.\n segmentDurationMs?: number // Optional number of points per second. Use to reduce the number of points and compute the number of datapoints to return.\n features?: AudioFeaturesOptions\n featuresExtratorUrl?: string\n logger?: ConsoleLike\n decodingOptions?: DecodingConfig\n}\n\n// Define base options interface with common properties\ninterface BaseExtractOptions {\n fileUri?: string\n arrayBuffer?: ArrayBuffer\n /**\n * Duration of each analysis segment in milliseconds. Defaults to 100ms if not specified.\n */\n segmentDurationMs?: number\n features?: AudioFeaturesOptions\n decodingOptions?: DecodingConfig\n logger?: ConsoleLike\n}\n\n// Time-based range options\ninterface TimeRangeOptions extends BaseExtractOptions {\n startTimeMs?: number\n endTimeMs?: number\n position?: never\n length?: never\n}\n\n// Byte-based range options\ninterface ByteRangeOptions extends BaseExtractOptions {\n position?: number\n length?: number\n startTimeMs?: never\n endTimeMs?: never\n}\n\n/**\n * Options for extracting audio analysis.\n * - For time-based analysis, provide `startTimeMs` and `endTimeMs`.\n * - For byte-based analysis, provide `position` and `length`.\n * - Do not mix time and byte ranges.\n */\nexport type ExtractAudioAnalysisProps = TimeRangeOptions | ByteRangeOptions\n\n/**\n * Extracts detailed audio analysis from the specified audio file or buffer.\n * Supports either time-based or byte-based ranges for flexibility in analysis.\n *\n * @param props - The options for extraction, including file URI, ranges, and decoding settings.\n * @returns A promise that resolves to the audio analysis data.\n * @throws {Error} If both time and byte ranges are provided or if required parameters are missing.\n */\nexport async function extractAudioAnalysis(\n props: ExtractAudioAnalysisProps\n): Promise<AudioAnalysis> {\n const {\n fileUri,\n arrayBuffer,\n decodingOptions,\n logger,\n segmentDurationMs = 100,\n features,\n } = props\n\n if (isWeb) {\n try {\n // Create AudioContext here\n const audioContext = new (window.AudioContext ||\n (window as any).webkitAudioContext)({\n sampleRate: decodingOptions?.targetSampleRate ?? 16000,\n })\n\n try {\n const processedBuffer = await processAudioBuffer({\n arrayBuffer,\n fileUri,\n targetSampleRate:\n decodingOptions?.targetSampleRate ?? 16000,\n targetChannels: decodingOptions?.targetChannels ?? 1,\n normalizeAudio: decodingOptions?.normalizeAudio ?? false,\n startTimeMs:\n 'startTimeMs' in props ? props.startTimeMs : undefined,\n endTimeMs:\n 'endTimeMs' in props ? props.endTimeMs : undefined,\n position: 'position' in props ? props.position : undefined,\n length: 'length' in props ? props.length : undefined,\n audioContext, // Pass the context we created\n logger,\n })\n\n const channelData = processedBuffer.buffer.getChannelData(0)\n\n // Create and initialize the worker\n const blob = new Blob([InlineFeaturesExtractor], {\n type: 'application/javascript',\n })\n const workerUrl = URL.createObjectURL(blob)\n const worker = new Worker(workerUrl)\n\n return new Promise((resolve, reject) => {\n worker.onmessage = (event) => {\n if (event.data.error) {\n reject(new Error(event.data.error))\n return\n }\n\n const result: AudioAnalysis = event.data.result\n // Calculate CRC32 after worker completes if requested\n if (features?.crc32) {\n const samplesPerSegment = Math.floor(\n (processedBuffer.sampleRate *\n segmentDurationMs) /\n 1000\n )\n\n result.dataPoints = result.dataPoints.map(\n (point: DataPoint, index: number) => {\n const startSample =\n index * samplesPerSegment\n const segmentData = channelData.slice(\n startSample,\n startSample + samplesPerSegment\n )\n\n return {\n ...point,\n features: {\n ...point.features,\n crc32: calculateCRC32ForDataPoint(\n segmentData\n ),\n },\n }\n }\n )\n }\n\n URL.revokeObjectURL(workerUrl)\n worker.terminate()\n resolve(result)\n }\n\n worker.onerror = (error) => {\n URL.revokeObjectURL(workerUrl)\n worker.terminate()\n reject(error)\n }\n\n worker.postMessage({\n channelData,\n sampleRate: processedBuffer.sampleRate,\n segmentDurationMs,\n bitDepth: decodingOptions?.targetBitDepth ?? 32,\n numberOfChannels: processedBuffer.channels,\n fullAudioDurationMs: processedBuffer.durationMs,\n // enableLogging: !!logger,\n features,\n })\n })\n } finally {\n await audioContext.close()\n }\n } catch (error) {\n logger?.error('Failed to process audio:', error)\n throw error\n }\n } else {\n return await ExpoAudioStreamModule.extractAudioAnalysis(props)\n }\n}\n\n/**\n * Analyzes WAV files without decoding, preserving original PCM values.\n * Use this function when you need to ensure the analysis matches other software by avoiding any transformations.\n *\n * @param props - The options for WAV analysis, including file URI and range.\n * @returns A promise that resolves to the audio analysis data.\n */\nexport const extractRawWavAnalysis = async ({\n fileUri,\n segmentDurationMs = 100, // Default to 100ms\n arrayBuffer,\n bitDepth,\n durationMs,\n sampleRate,\n numberOfChannels,\n features,\n logger,\n position = 0,\n length,\n}: ExtractWavAudioAnalysisProps): Promise<AudioAnalysis> => {\n if (isWeb) {\n if (!arrayBuffer && !fileUri) {\n throw new Error('Either arrayBuffer or fileUri must be provided')\n }\n\n if (!arrayBuffer) {\n logger?.log(`fetching fileUri`, fileUri)\n const response = await fetch(fileUri!)\n\n if (!response.ok) {\n throw new Error(\n `Failed to fetch fileUri: ${response.statusText}`\n )\n }\n\n arrayBuffer = await response.arrayBuffer()\n logger?.log(`fetched fileUri`, arrayBuffer.byteLength, arrayBuffer)\n }\n\n // Create a new copy of the ArrayBuffer to avoid detachment issues\n const bufferCopy = arrayBuffer.slice(0)\n logger?.log(\n `extractAudioAnalysis bitDepth=${bitDepth} len=${bufferCopy.byteLength}`,\n bufferCopy.slice(0, 100)\n )\n\n let actualBitDepth = bitDepth\n if (!actualBitDepth) {\n logger?.log(\n `extractAudioAnalysis bitDepth not provided -- getting wav file info`\n )\n const fileInfo = await getWavFileInfo(bufferCopy)\n actualBitDepth = fileInfo.bitDepth\n }\n logger?.log(`extractAudioAnalysis actualBitDepth=${actualBitDepth}`)\n\n const {\n pcmValues: channelData,\n min,\n max,\n } = await convertPCMToFloat32({\n buffer: arrayBuffer,\n bitDepth: actualBitDepth,\n })\n logger?.log(\n `extractAudioAnalysis convertPCMToFloat32 length=${channelData.length} range: [ ${min} :: ${max} ]`\n )\n\n // Apply position and length constraints to channelData if specified\n const startIndex = position\n const endIndex = length ? startIndex + length : channelData.length\n const constrainedChannelData = channelData.slice(startIndex, endIndex)\n\n return new Promise((resolve, reject) => {\n const blob = new Blob([InlineFeaturesExtractor], {\n type: 'application/javascript',\n })\n const url = URL.createObjectURL(blob)\n const worker = new Worker(url)\n\n worker.onmessage = (event) => {\n resolve(event.data.result)\n }\n\n worker.onerror = (error) => {\n reject(error)\n }\n\n worker.postMessage({\n command: 'process',\n channelData: constrainedChannelData,\n sampleRate,\n segmentDurationMs,\n logger,\n bitDepth,\n fullAudioDurationMs: durationMs,\n numberOfChannels,\n })\n })\n } else {\n if (!fileUri) {\n throw new Error('fileUri is required')\n }\n logger?.log(`extractAudioAnalysis`, {\n fileUri,\n segmentDurationMs,\n })\n const res = await ExpoAudioStreamModule.extractAudioAnalysis({\n fileUri,\n segmentDurationMs,\n features,\n position,\n length,\n })\n logger?.log(`extractAudioAnalysis`, res)\n return res\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractAudioData.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/extractAudioData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AAGlE,eAAO,MAAM,gBAAgB,UAAiB,uBAAuB,iBAEpE,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractAudioData.js","sourceRoot":"","sources":["../../src/AudioAnalysis/extractAudioData.ts"],"names":[],"mappings":"AACA,OAAO,qBAAqB,MAAM,0BAA0B,CAAA;AAE5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,KAA8B,EAAE,EAAE;IACrE,OAAO,MAAM,qBAAqB,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;AAC9D,CAAC,CAAA","sourcesContent":["import { ExtractAudioDataOptions } from '../ExpoAudioStream.types'\nimport ExpoAudioStreamModule from '../ExpoAudioStreamModule'\n\nexport const extractAudioData = async (props: ExtractAudioDataOptions) => {\n return await ExpoAudioStreamModule.extractAudioData(props)\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractMelSpectrogram.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/extractMelSpectrogram.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACH,4BAA4B,EAC5B,cAAc,EACjB,MAAM,uBAAuB,CAAA;AAM9B;;;;;;GAMG;AACH,wBAAsB,qBAAqB,CACvC,OAAO,EAAE,4BAA4B,GACtC,OAAO,CAAC,cAAc,CAAC,CA8EzB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractMelSpectrogram.js","sourceRoot":"","sources":["../../src/AudioAnalysis/extractMelSpectrogram.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,IAAI,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAKpC,OAAO,EACH,kBAAkB,GAErB,MAAM,0BAA0B,CAAA;AAEjC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACvC,OAAqC;IAErC,MAAM,EACF,OAAO,EACP,WAAW,EACX,YAAY,EACZ,WAAW,EACX,KAAK,EACL,IAAI,GAAG,CAAC,EACR,IAAI,EACJ,UAAU,GAAG,MAAM,EACnB,SAAS,GAAG,KAAK,EACjB,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AU;aACxC,CAAA;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,EAAE,KAAK,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAA;YACzD,MAAM,KAAK,CAAA;QACf,CAAC;gBAAS,CAAC;YACP,0BAA0B;YAC1B,MAAM,YAAY,CAAC,KAAK,EAAE,CAAA;QAC9B,CAAC;IACL,CAAC;IACD,OAAO,qBAAqB,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAA;AAC/D,CAAC;AAED;;;;;GAKG;AACH,SAAS,qBAAqB,CAC1B,SAAuB,EACvB,UAAkB,EAClB,KAAa,EACb,UAAkB,EAClB,SAAiB,EACjB,IAAY,EACZ,IAAY,EACZ,UAA8B,EAC9B,SAAkB,EAClB,QAAiB;IAEjB,4CAA4C;IAC5C,sBAAsB;IACtB,8DAA8D;IAC9D,uDAAuD;IACvD,qCAAqC;IACrC,8BAA8B;IAC9B,8CAA8C;IAC9C,sCAAsC;IAEtC,yCAAyC;IACzC,MAAM,SAAS,GACX,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,MAAM,GAAG,UAAU,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,CAAA;IAC/D,MAAM,WAAW,GAAe,EAAE,CAAA;IAElC,oCAAoC;IACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;QACjC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IAC1C,CAAC;IAED,OAAO,WAAW,CAAA;AACtB,CAAC","sourcesContent":["/**\n * @experimental This feature is experimental and currently only available on Android.\n * The API may change in future versions. The web implementation is a placeholder.\n */\n\nimport { ExpoAudioStreamModule } from '..'\nimport { isWeb } from '../constants'\nimport {\n ExtractMelSpectrogramOptions,\n MelSpectrogram,\n} from './AudioAnalysis.types'\nimport {\n processAudioBuffer,\n ProcessedAudioData,\n} from '../utils/audioProcessing'\n\n/**\n * Extracts a mel spectrogram from audio data\n *\n * @experimental This feature is experimental and currently only available on Android.\n * The iOS implementation will throw an \"UNSUPPORTED_PLATFORM\" error.\n * The web implementation is a placeholder that returns dummy data.\n */\nexport async function extractMelSpectrogram(\n options: ExtractMelSpectrogramOptions\n): Promise<MelSpectrogram> {\n const {\n fileUri,\n arrayBuffer,\n windowSizeMs,\n hopLengthMs,\n nMels,\n fMin = 0,\n fMax,\n windowType = 'hann',\n normalize = false,\n logScale = true,\n decodingOptions,\n startTimeMs,\n endTimeMs,\n logger,\n } = options\n\n if (isWeb) {\n // Create audio context\n const audioContext = new (window.AudioContext ||\n (window as any).webkitAudioContext)()\n\n try {\n // Process audio data using the existing utility\n const processedAudio: ProcessedAudioData = await processAudioBuffer(\n {\n arrayBuffer,\n fileUri,\n targetSampleRate:\n decodingOptions?.targetSampleRate || 16000,\n targetChannels: decodingOptions?.targetChannels || 1,\n normalizeAudio: decodingOptions?.normalizeAudio ?? false,\n startTimeMs,\n endTimeMs,\n audioContext,\n logger: options.logger,\n }\n )\n\n // Calculate window and hop size in samples\n const sampleRate = processedAudio.sampleRate\n const windowSize = Math.floor((windowSizeMs * sampleRate) / 1000)\n const hopLength = Math.floor((hopLengthMs * sampleRate) / 1000)\n const maxFreq = fMax || sampleRate / 2\n\n // Extract the mel spectrogram from the processed audio\n const spectrogram = computeMelSpectrogram(\n processedAudio.channelData,\n sampleRate,\n nMels,\n windowSize,\n hopLength,\n fMin,\n maxFreq,\n windowType,\n normalize,\n logScale\n )\n\n const timeSteps = spectrogram.length\n\n return {\n spectrogram,\n sampleRate,\n nMels,\n timeSteps,\n durationMs: processedAudio.durationMs,\n }\n } catch (error) {\n logger?.error('Error extracting mel spectrogram:', error)\n throw error\n } finally {\n // Close the audio context\n await audioContext.close()\n }\n }\n return ExpoAudioStreamModule.extractMelSpectrogram(options)\n}\n\n/**\n * Computes a mel spectrogram from audio data\n *\n * @experimental This is a placeholder implementation that returns dummy data.\n * The actual implementation will be added in a future version.\n */\nfunction computeMelSpectrogram(\n audioData: Float32Array,\n sampleRate: number,\n nMels: number,\n windowSize: number,\n hopLength: number,\n fMin: number,\n fMax: number,\n windowType: 'hann' | 'hamming',\n normalize: boolean,\n logScale: boolean\n): number[][] {\n // Placeholder for the actual implementation\n // This would include:\n // 1. Windowing the audio data using the specified window type\n // 2. Computing the STFT (Short-Time Fourier Transform)\n // 3. Converting to power spectrogram\n // 4. Applying mel filterbanks\n // 5. Taking the logarithm if logScale is true\n // 6. Normalizing if normalize is true\n\n // For now, return a dummy implementation\n const numFrames =\n Math.floor((audioData.length - windowSize) / hopLength) + 1\n const spectrogram: number[][] = []\n\n // Create dummy mel spectrogram data\n for (let i = 0; i < numFrames; i++) {\n spectrogram.push(Array(nMels).fill(0))\n }\n\n return spectrogram\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractPreview.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/extractPreview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAGrE;;;;;;GAMG;AACH,wBAAsB,cAAc,CAAC,EACjC,OAAO,EACP,cAAoB,EACpB,WAAe,EACf,SAAiB,EAAE,mBAAmB;AACtC,eAAe,EACf,MAAM,GACT,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAgBzC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractPreview.js","sourceRoot":"","sources":["../../src/AudioAnalysis/extractPreview.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EACjC,OAAO,EACP,cAAc,GAAG,GAAG,EACpB,WAAW,GAAG,CAAC,EACf,SAAS,GAAG,KAAK,EAAE,mBAAmB;AACtC,eAAe,EACf,MAAM,GACO;IACb,MAAM,UAAU,GAAG,SAAS,GAAG,WAAW,CAAA;IAC1C,MAAM,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,cAAc,CAAC,CAAA;IAEjE,uDAAuD;IACvD,MAAM,QAAQ,GAAG,MAAM,oBAAoB,CAAC;QACxC,OAAO;QACP,WAAW;QACX,SAAS;QACT,MAAM;QACN,iBAAiB;QACjB,eAAe;KAClB,CAAC,CAAA;IAEF,gDAAgD;IAChD,OAAO,QAAQ,CAAA;AACnB,CAAC","sourcesContent":["import { PreviewOptions, AudioAnalysis } from './AudioAnalysis.types'\nimport { extractAudioAnalysis } from './extractAudioAnalysis'\n\n/**\n * Generates a simplified preview of the audio waveform for quick visualization.\n * Ideal for UI rendering with a specified number of points.\n *\n * @param options - The options for the preview, including file URI and time range.\n * @returns A promise that resolves to the audio preview data.\n */\nexport async function extractPreview({\n fileUri,\n numberOfPoints = 100,\n startTimeMs = 0,\n endTimeMs = 30000, // First 30 seconds\n decodingOptions,\n logger,\n}: PreviewOptions): Promise<AudioAnalysis> {\n const durationMs = endTimeMs - startTimeMs\n const segmentDurationMs = Math.floor(durationMs / numberOfPoints)\n\n // Call extractAudioAnalysis with calculated parameters\n const analysis = await extractAudioAnalysis({\n fileUri,\n startTimeMs,\n endTimeMs,\n logger,\n segmentDurationMs,\n decodingOptions,\n })\n\n // Transform the result into AudioPreview format\n return analysis\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractWaveform.d.ts","sourceRoot":"","sources":["../../src/AudioAnalysis/extractWaveform.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB;IACjC,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB;AACD,eAAO,MAAM,eAAe,kDAKzB,oBAAoB,KAAG,QAAQ,OAAO,CAQxC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractWaveform.js","sourceRoot":"","sources":["../../src/AudioAnalysis/extractWaveform.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,MAAM,0BAA0B,CAAA;AAQ5D,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,EAClC,OAAO,EACP,eAAe,EACf,MAAM,GAAG,CAAC,EACV,MAAM,GACa,EAAoB,EAAE;IACzC,MAAM,GAAG,GAAG,MAAM,qBAAqB,CAAC,oBAAoB,CAAC;QACzD,OAAO;QACP,eAAe;QACf,MAAM;QACN,MAAM;KACT,CAAC,CAAA;IACF,OAAO,GAAG,CAAA;AACd,CAAC,CAAA","sourcesContent":["import ExpoAudioStreamModule from '../ExpoAudioStreamModule'\n\nexport interface ExtractWaveformProps {\n fileUri: string\n numberOfSamples: number\n offset?: number\n length?: number\n}\nexport const extractWaveform = async ({\n fileUri,\n numberOfSamples,\n offset = 0,\n length,\n}: ExtractWaveformProps): Promise<unknown> => {\n const res = await ExpoAudioStreamModule.extractAudioAnalysis({\n fileUri,\n numberOfSamples,\n offset,\n length,\n })\n return res\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AudioDeviceManager.d.ts","sourceRoot":"","sources":["../src/AudioDeviceManager.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,WAAW,EAEX,2BAA2B,EAC3B,WAAW,EACd,MAAM,yBAAyB,CAAA;AA0ChC;;GAEG;AACH,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,YAAY,CAAmC;IACvD,OAAO,CAAC,eAAe,CAAsB;IAC7C,OAAO,CAAC,gBAAgB,CAAoB;IAC5C,OAAO,CAAC,qBAAqB,CAChB;IACb,OAAO,CAAC,eAAe,CAA6B;IACpD,OAAO,CAAC,eAAe,CAAY;IACnC,OAAO,CAAC,iBAAiB,CAAiB;IAC1C,OAAO,CAAC,iBAAiB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