@siteed/expo-audio-studio 2.18.6 → 3.0.0
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/README.md +13 -297
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +6 -135
- package/CHANGELOG.md +0 -501
- package/LICENSE +0 -21
- package/android/build.gradle +0 -129
- package/android/src/androidTest/assets/chorus.wav +0 -0
- package/android/src/androidTest/assets/jfk.wav +0 -0
- package/android/src/androidTest/assets/osr_us_000_0010_8k.wav +0 -0
- package/android/src/androidTest/assets/recorder_hello_world.wav +0 -0
- package/android/src/androidTest/java/net/siteed/audiostream/AudioProcessorInstrumentedTest.kt +0 -197
- package/android/src/androidTest/java/net/siteed/audiostream/AudioRecorderInstrumentedTest.kt +0 -541
- package/android/src/androidTest/java/net/siteed/audiostream/AudioRecorderPerformanceInstrumentedTest.kt +0 -234
- package/android/src/androidTest/java/net/siteed/audiostream/integration/AudioFocusStrategyIntegrationTest.kt +0 -332
- package/android/src/androidTest/java/net/siteed/audiostream/integration/BufferDurationIntegrationTest.kt +0 -324
- package/android/src/androidTest/java/net/siteed/audiostream/integration/CompressedOnlyOutputTest.kt +0 -253
- package/android/src/androidTest/java/net/siteed/audiostream/integration/DeviceDisconnectionFallbackTest.kt +0 -218
- package/android/src/androidTest/java/net/siteed/audiostream/integration/EventEmissionIntervalTest.kt +0 -120
- package/android/src/androidTest/java/net/siteed/audiostream/integration/M4aFormatTest.kt +0 -345
- package/android/src/androidTest/java/net/siteed/audiostream/integration/OutputControlIntegrationTest.kt +0 -340
- package/android/src/androidTest/java/net/siteed/audiostream/integration/PcmStreamingDurationTest.kt +0 -252
- package/android/src/androidTest/java/net/siteed/audiostream/integration/README.md +0 -95
- package/android/src/androidTest/java/net/siteed/audiostream/integration/run_integration_tests.sh +0 -43
- package/android/src/main/AndroidManifest.xml +0 -30
- package/android/src/main/java/net/siteed/audiostream/AudioAnalysisData.kt +0 -188
- package/android/src/main/java/net/siteed/audiostream/AudioDataEncoder.kt +0 -9
- package/android/src/main/java/net/siteed/audiostream/AudioDeviceManager.kt +0 -1741
- package/android/src/main/java/net/siteed/audiostream/AudioFileHandler.kt +0 -136
- package/android/src/main/java/net/siteed/audiostream/AudioFormatUtils.kt +0 -354
- package/android/src/main/java/net/siteed/audiostream/AudioNotificationsManager.kt +0 -439
- package/android/src/main/java/net/siteed/audiostream/AudioProcessor.kt +0 -2237
- package/android/src/main/java/net/siteed/audiostream/AudioRecorderManager.kt +0 -2141
- package/android/src/main/java/net/siteed/audiostream/AudioRecordingService.kt +0 -167
- package/android/src/main/java/net/siteed/audiostream/AudioTrimmer.kt +0 -1099
- package/android/src/main/java/net/siteed/audiostream/Constants.kt +0 -37
- package/android/src/main/java/net/siteed/audiostream/EventSender.kt +0 -7
- package/android/src/main/java/net/siteed/audiostream/ExpoAudioStreamModule.kt +0 -1113
- package/android/src/main/java/net/siteed/audiostream/FFT.kt +0 -99
- package/android/src/main/java/net/siteed/audiostream/Features.kt +0 -98
- package/android/src/main/java/net/siteed/audiostream/LogUtils.kt +0 -93
- package/android/src/main/java/net/siteed/audiostream/NotificationConfig.kt +0 -72
- package/android/src/main/java/net/siteed/audiostream/PermissionUtils.kt +0 -68
- package/android/src/main/java/net/siteed/audiostream/RecordingActionReceiver.kt +0 -59
- package/android/src/main/java/net/siteed/audiostream/RecordingConfig.kt +0 -257
- package/android/src/main/java/net/siteed/audiostream/WaveformConfig.kt +0 -19
- package/android/src/main/java/net/siteed/audiostream/WaveformRenderer.kt +0 -159
- package/android/src/main/res/drawable/ic_default_action_icon.xml +0 -16
- package/android/src/main/res/drawable/ic_microphone.xml +0 -13
- package/android/src/main/res/drawable/ic_pause.xml +0 -10
- package/android/src/main/res/drawable/ic_play.xml +0 -10
- package/android/src/main/res/drawable/ic_stop.xml +0 -10
- package/android/src/main/res/layout/notification_recording.xml +0 -37
- package/android/src/test/java/net/siteed/audiostream/AudioFileHandlerTest.kt +0 -279
- package/android/src/test/java/net/siteed/audiostream/AudioFocusStrategyTest.kt +0 -249
- package/android/src/test/java/net/siteed/audiostream/AudioFormatTest.kt +0 -151
- package/android/src/test/java/net/siteed/audiostream/AudioFormatUtilsTest.kt +0 -273
- package/android/src/test/java/net/siteed/audiostream/DeviceDisconnectionFallbackUnitTest.kt +0 -140
- package/android/src/test/resources/chorus.wav +0 -0
- package/android/src/test/resources/generate_test_audio.py +0 -94
- package/android/src/test/resources/jfk.wav +0 -0
- package/android/src/test/resources/osr_us_000_0010_8k.wav +0 -0
- package/android/src/test/resources/recorder_hello_world.wav +0 -0
- package/app.plugin.js +0 -3
- package/build/cjs/AudioAnalysis/AudioAnalysis.types.js +0 -4
- package/build/cjs/AudioAnalysis/AudioAnalysis.types.js.map +0 -1
- package/build/cjs/AudioAnalysis/extractAudioAnalysis.js +0 -210
- package/build/cjs/AudioAnalysis/extractAudioAnalysis.js.map +0 -1
- package/build/cjs/AudioAnalysis/extractAudioData.js +0 -21
- package/build/cjs/AudioAnalysis/extractAudioData.js.map +0 -1
- package/build/cjs/AudioAnalysis/extractMelSpectrogram.js +0 -92
- package/build/cjs/AudioAnalysis/extractMelSpectrogram.js.map +0 -1
- package/build/cjs/AudioAnalysis/extractPreview.js +0 -28
- package/build/cjs/AudioAnalysis/extractPreview.js.map +0 -1
- package/build/cjs/AudioAnalysis/extractWaveform.js +0 -18
- package/build/cjs/AudioAnalysis/extractWaveform.js.map +0 -1
- package/build/cjs/AudioDeviceManager.js +0 -689
- package/build/cjs/AudioDeviceManager.js.map +0 -1
- package/build/cjs/AudioRecorder.provider.js +0 -78
- package/build/cjs/AudioRecorder.provider.js.map +0 -1
- package/build/cjs/ExpoAudioStream.native.js +0 -8
- package/build/cjs/ExpoAudioStream.native.js.map +0 -1
- package/build/cjs/ExpoAudioStream.types.js +0 -11
- package/build/cjs/ExpoAudioStream.types.js.map +0 -1
- package/build/cjs/ExpoAudioStream.web.js +0 -708
- package/build/cjs/ExpoAudioStream.web.js.map +0 -1
- package/build/cjs/ExpoAudioStreamModule.js +0 -718
- package/build/cjs/ExpoAudioStreamModule.js.map +0 -1
- package/build/cjs/WebRecorder.web.js +0 -777
- package/build/cjs/WebRecorder.web.js.map +0 -1
- package/build/cjs/constants/platformLimitations.js +0 -99
- package/build/cjs/constants/platformLimitations.js.map +0 -1
- package/build/cjs/constants.js +0 -17
- package/build/cjs/constants.js.map +0 -1
- package/build/cjs/events.js +0 -29
- package/build/cjs/events.js.map +0 -1
- package/build/cjs/hooks/useAudioDevices.js +0 -179
- package/build/cjs/hooks/useAudioDevices.js.map +0 -1
- package/build/cjs/index.js +0 -58
- package/build/cjs/index.js.map +0 -1
- package/build/cjs/trimAudio.js +0 -76
- package/build/cjs/trimAudio.js.map +0 -1
- package/build/cjs/useAudioRecorder.js +0 -518
- package/build/cjs/useAudioRecorder.js.map +0 -1
- package/build/cjs/utils/BlobFix.js +0 -502
- package/build/cjs/utils/BlobFix.js.map +0 -1
- package/build/cjs/utils/audioProcessing.js +0 -136
- package/build/cjs/utils/audioProcessing.js.map +0 -1
- package/build/cjs/utils/cleanNativeOptions.js +0 -22
- package/build/cjs/utils/cleanNativeOptions.js.map +0 -1
- package/build/cjs/utils/concatenateBuffers.js +0 -25
- package/build/cjs/utils/concatenateBuffers.js.map +0 -1
- package/build/cjs/utils/convertPCMToFloat32.js +0 -124
- package/build/cjs/utils/convertPCMToFloat32.js.map +0 -1
- package/build/cjs/utils/crc32.js +0 -52
- package/build/cjs/utils/crc32.js.map +0 -1
- package/build/cjs/utils/encodingToBitDepth.js +0 -17
- package/build/cjs/utils/encodingToBitDepth.js.map +0 -1
- package/build/cjs/utils/getWavFileInfo.js +0 -96
- package/build/cjs/utils/getWavFileInfo.js.map +0 -1
- package/build/cjs/utils/writeWavHeader.js +0 -88
- package/build/cjs/utils/writeWavHeader.js.map +0 -1
- package/build/cjs/workers/InlineFeaturesExtractor.web.js +0 -859
- package/build/cjs/workers/InlineFeaturesExtractor.web.js.map +0 -1
- package/build/cjs/workers/inlineAudioWebWorker.web.js +0 -184
- package/build/cjs/workers/inlineAudioWebWorker.web.js.map +0 -1
- package/build/esm/AudioAnalysis/AudioAnalysis.types.js +0 -3
- package/build/esm/AudioAnalysis/AudioAnalysis.types.js.map +0 -1
- package/build/esm/AudioAnalysis/extractAudioAnalysis.js +0 -202
- package/build/esm/AudioAnalysis/extractAudioAnalysis.js.map +0 -1
- package/build/esm/AudioAnalysis/extractAudioData.js +0 -14
- package/build/esm/AudioAnalysis/extractAudioData.js.map +0 -1
- package/build/esm/AudioAnalysis/extractMelSpectrogram.js +0 -89
- package/build/esm/AudioAnalysis/extractMelSpectrogram.js.map +0 -1
- package/build/esm/AudioAnalysis/extractPreview.js +0 -25
- package/build/esm/AudioAnalysis/extractPreview.js.map +0 -1
- package/build/esm/AudioAnalysis/extractWaveform.js +0 -11
- package/build/esm/AudioAnalysis/extractWaveform.js.map +0 -1
- package/build/esm/AudioDeviceManager.js +0 -682
- package/build/esm/AudioDeviceManager.js.map +0 -1
- package/build/esm/AudioRecorder.provider.js +0 -40
- package/build/esm/AudioRecorder.provider.js.map +0 -1
- package/build/esm/ExpoAudioStream.native.js +0 -6
- package/build/esm/ExpoAudioStream.native.js.map +0 -1
- package/build/esm/ExpoAudioStream.types.js +0 -8
- package/build/esm/ExpoAudioStream.types.js.map +0 -1
- package/build/esm/ExpoAudioStream.web.js +0 -704
- package/build/esm/ExpoAudioStream.web.js.map +0 -1
- package/build/esm/ExpoAudioStreamModule.js +0 -713
- package/build/esm/ExpoAudioStreamModule.js.map +0 -1
- package/build/esm/WebRecorder.web.js +0 -773
- package/build/esm/WebRecorder.web.js.map +0 -1
- package/build/esm/constants/platformLimitations.js +0 -90
- package/build/esm/constants/platformLimitations.js.map +0 -1
- package/build/esm/constants.js +0 -14
- package/build/esm/constants.js.map +0 -1
- package/build/esm/events.js +0 -21
- package/build/esm/events.js.map +0 -1
- package/build/esm/hooks/useAudioDevices.js +0 -176
- package/build/esm/hooks/useAudioDevices.js.map +0 -1
- package/build/esm/index.js +0 -20
- package/build/esm/index.js.map +0 -1
- package/build/esm/trimAudio.js +0 -69
- package/build/esm/trimAudio.js.map +0 -1
- package/build/esm/useAudioRecorder.js +0 -512
- package/build/esm/useAudioRecorder.js.map +0 -1
- package/build/esm/utils/BlobFix.js +0 -498
- package/build/esm/utils/BlobFix.js.map +0 -1
- package/build/esm/utils/audioProcessing.js +0 -133
- package/build/esm/utils/audioProcessing.js.map +0 -1
- package/build/esm/utils/cleanNativeOptions.js +0 -19
- package/build/esm/utils/cleanNativeOptions.js.map +0 -1
- package/build/esm/utils/concatenateBuffers.js +0 -21
- package/build/esm/utils/concatenateBuffers.js.map +0 -1
- package/build/esm/utils/convertPCMToFloat32.js +0 -120
- package/build/esm/utils/convertPCMToFloat32.js.map +0 -1
- package/build/esm/utils/crc32.js +0 -50
- package/build/esm/utils/crc32.js.map +0 -1
- package/build/esm/utils/encodingToBitDepth.js +0 -13
- package/build/esm/utils/encodingToBitDepth.js.map +0 -1
- package/build/esm/utils/getWavFileInfo.js +0 -92
- package/build/esm/utils/getWavFileInfo.js.map +0 -1
- package/build/esm/utils/writeWavHeader.js +0 -84
- package/build/esm/utils/writeWavHeader.js.map +0 -1
- package/build/esm/workers/InlineFeaturesExtractor.web.js +0 -856
- package/build/esm/workers/InlineFeaturesExtractor.web.js.map +0 -1
- package/build/esm/workers/inlineAudioWebWorker.web.js +0 -181
- package/build/esm/workers/inlineAudioWebWorker.web.js.map +0 -1
- package/build/types/AudioAnalysis/AudioAnalysis.types.d.ts +0 -196
- package/build/types/AudioAnalysis/AudioAnalysis.types.d.ts.map +0 -1
- package/build/types/AudioAnalysis/extractAudioAnalysis.d.ts +0 -74
- package/build/types/AudioAnalysis/extractAudioAnalysis.d.ts.map +0 -1
- package/build/types/AudioAnalysis/extractAudioData.d.ts +0 -3
- package/build/types/AudioAnalysis/extractAudioData.d.ts.map +0 -1
- package/build/types/AudioAnalysis/extractMelSpectrogram.d.ts +0 -14
- package/build/types/AudioAnalysis/extractMelSpectrogram.d.ts.map +0 -1
- package/build/types/AudioAnalysis/extractPreview.d.ts +0 -11
- package/build/types/AudioAnalysis/extractPreview.d.ts.map +0 -1
- package/build/types/AudioAnalysis/extractWaveform.d.ts +0 -8
- package/build/types/AudioAnalysis/extractWaveform.d.ts.map +0 -1
- package/build/types/AudioDeviceManager.d.ts +0 -187
- package/build/types/AudioDeviceManager.d.ts.map +0 -1
- package/build/types/AudioRecorder.provider.d.ts +0 -11
- package/build/types/AudioRecorder.provider.d.ts.map +0 -1
- package/build/types/ExpoAudioStream.native.d.ts +0 -3
- package/build/types/ExpoAudioStream.native.d.ts.map +0 -1
- package/build/types/ExpoAudioStream.types.d.ts +0 -738
- package/build/types/ExpoAudioStream.types.d.ts.map +0 -1
- package/build/types/ExpoAudioStream.web.d.ts +0 -96
- package/build/types/ExpoAudioStream.web.d.ts.map +0 -1
- package/build/types/ExpoAudioStreamModule.d.ts +0 -3
- package/build/types/ExpoAudioStreamModule.d.ts.map +0 -1
- package/build/types/WebRecorder.web.d.ts +0 -198
- package/build/types/WebRecorder.web.d.ts.map +0 -1
- package/build/types/constants/platformLimitations.d.ts +0 -40
- package/build/types/constants/platformLimitations.d.ts.map +0 -1
- package/build/types/constants.d.ts +0 -11
- package/build/types/constants.d.ts.map +0 -1
- package/build/types/events.d.ts +0 -26
- package/build/types/events.d.ts.map +0 -1
- package/build/types/hooks/useAudioDevices.d.ts +0 -15
- package/build/types/hooks/useAudioDevices.d.ts.map +0 -1
- package/build/types/index.d.ts +0 -18
- package/build/types/index.d.ts.map +0 -1
- package/build/types/trimAudio.d.ts +0 -25
- package/build/types/trimAudio.d.ts.map +0 -1
- package/build/types/useAudioRecorder.d.ts +0 -22
- package/build/types/useAudioRecorder.d.ts.map +0 -1
- package/build/types/utils/BlobFix.d.ts +0 -9
- package/build/types/utils/BlobFix.d.ts.map +0 -1
- package/build/types/utils/audioProcessing.d.ts +0 -24
- package/build/types/utils/audioProcessing.d.ts.map +0 -1
- package/build/types/utils/cleanNativeOptions.d.ts +0 -15
- package/build/types/utils/cleanNativeOptions.d.ts.map +0 -1
- package/build/types/utils/concatenateBuffers.d.ts +0 -8
- package/build/types/utils/concatenateBuffers.d.ts.map +0 -1
- package/build/types/utils/convertPCMToFloat32.d.ts +0 -13
- package/build/types/utils/convertPCMToFloat32.d.ts.map +0 -1
- package/build/types/utils/crc32.d.ts +0 -7
- package/build/types/utils/crc32.d.ts.map +0 -1
- package/build/types/utils/encodingToBitDepth.d.ts +0 -5
- package/build/types/utils/encodingToBitDepth.d.ts.map +0 -1
- package/build/types/utils/getWavFileInfo.d.ts +0 -26
- package/build/types/utils/getWavFileInfo.d.ts.map +0 -1
- package/build/types/utils/writeWavHeader.d.ts +0 -34
- package/build/types/utils/writeWavHeader.d.ts.map +0 -1
- package/build/types/workers/InlineFeaturesExtractor.web.d.ts +0 -2
- package/build/types/workers/InlineFeaturesExtractor.web.d.ts.map +0 -1
- package/build/types/workers/inlineAudioWebWorker.web.d.ts +0 -2
- package/build/types/workers/inlineAudioWebWorker.web.d.ts.map +0 -1
- package/expo-module.config.json +0 -10
- package/ios/AudioAnalysisData.swift +0 -74
- package/ios/AudioDeviceManager.swift +0 -670
- package/ios/AudioNotificationManager.swift +0 -154
- package/ios/AudioProcessingHelpers.swift +0 -743
- package/ios/AudioProcessor.swift +0 -1151
- package/ios/AudioStreamError.swift +0 -7
- package/ios/AudioStreamManager.swift +0 -2369
- package/ios/AudioStreamManagerDelegate.swift +0 -16
- package/ios/DataPoint.swift +0 -54
- package/ios/DecodingConfig.swift +0 -59
- package/ios/ExpoAudioStream.podspec +0 -33
- package/ios/ExpoAudioStreamModule.swift +0 -1019
- package/ios/ExpoAudioStudioTests/AudioFileHandlerTests.swift +0 -338
- package/ios/ExpoAudioStudioTests/AudioFormatUtilsTests.swift +0 -331
- package/ios/ExpoAudioStudioTests/AudioTestHelpers.swift +0 -130
- package/ios/ExpoAudioStudioTests/CompressedOnlyOutputTests.swift +0 -294
- package/ios/ExpoAudioStudioTests/EventEmissionIntervalTests.swift +0 -105
- package/ios/ExpoAudioStudioTests/Info.plist +0 -22
- package/ios/ExpoAudioStudioTests/README.md +0 -39
- package/ios/ExpoAudioStudioTests/SimpleAudioTest.swift +0 -98
- package/ios/ExpoAudioStudioTests/TestAudioGenerator.swift +0 -75
- package/ios/FFT.swift +0 -62
- package/ios/Features.swift +0 -95
- package/ios/ISSUE_IOS.md +0 -68
- package/ios/Logger.swift +0 -39
- package/ios/NotificationExtension.swift +0 -15
- package/ios/RecordingResult.swift +0 -22
- package/ios/RecordingSettings.swift +0 -308
- package/ios/WaveformExtractor.swift +0 -105
- package/ios/tests/README.md +0 -41
- package/ios/tests/integration/buffer_and_fallback_test.swift +0 -178
- package/ios/tests/integration/buffer_duration_test.swift +0 -185
- package/ios/tests/integration/compressed_only_output_test.swift +0 -271
- package/ios/tests/integration/output_control_test.swift +0 -322
- package/ios/tests/integration/run_integration_tests.sh +0 -37
- package/ios/tests/opus_support_test_macos.swift +0 -154
- package/ios/tests/standalone/audio_processing_test.swift +0 -144
- package/ios/tests/standalone/audio_recording_test.swift +0 -277
- package/ios/tests/standalone/audio_streaming_test.swift +0 -249
- package/ios/tests/standalone/standalone_test.swift +0 -144
- package/plugin/build/index.cjs +0 -194
- package/plugin/build/index.d.cts +0 -22
- package/plugin/build/index.js +0 -194
- package/plugin/src/index.ts +0 -285
- package/plugin/tsconfig.json +0 -10
- package/plugin/tsconfig.tsbuildinfo +0 -1
- package/src/AudioAnalysis/AudioAnalysis.types.ts +0 -224
- package/src/AudioAnalysis/extractAudioAnalysis.ts +0 -344
- package/src/AudioAnalysis/extractAudioData.ts +0 -17
- package/src/AudioAnalysis/extractMelSpectrogram.ts +0 -154
- package/src/AudioAnalysis/extractPreview.ts +0 -34
- package/src/AudioAnalysis/extractWaveform.ts +0 -22
- package/src/AudioDeviceManager.ts +0 -803
- package/src/AudioRecorder.provider.tsx +0 -57
- package/src/ExpoAudioStream.native.ts +0 -6
- package/src/ExpoAudioStream.types.ts +0 -874
- package/src/ExpoAudioStream.web.ts +0 -905
- package/src/ExpoAudioStreamModule.ts +0 -990
- package/src/WebRecorder.web.ts +0 -1005
- package/src/constants/platformLimitations.ts +0 -118
- package/src/constants.ts +0 -18
- package/src/events.ts +0 -60
- package/src/hooks/useAudioDevices.ts +0 -213
- package/src/index.ts +0 -54
- package/src/trimAudio.ts +0 -94
- package/src/types/crc-32.d.ts +0 -9
- package/src/useAudioRecorder.tsx +0 -766
- package/src/utils/BlobFix.ts +0 -561
- package/src/utils/audioProcessing.ts +0 -205
- package/src/utils/cleanNativeOptions.ts +0 -18
- package/src/utils/concatenateBuffers.ts +0 -24
- package/src/utils/convertPCMToFloat32.ts +0 -170
- package/src/utils/crc32.ts +0 -59
- package/src/utils/encodingToBitDepth.ts +0 -18
- package/src/utils/getWavFileInfo.ts +0 -132
- package/src/utils/writeWavHeader.ts +0 -115
- package/src/workers/InlineFeaturesExtractor.web.tsx +0 -855
- package/src/workers/inlineAudioWebWorker.web.tsx +0 -180
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @experimental This feature is experimental and currently only available on Android.
|
|
3
|
-
* The API may change in future versions. The web implementation is a placeholder.
|
|
4
|
-
*/
|
|
5
|
-
import { ExpoAudioStreamModule } from '..';
|
|
6
|
-
import { isWeb } from '../constants';
|
|
7
|
-
import { processAudioBuffer, } from '../utils/audioProcessing';
|
|
8
|
-
import { cleanNativeOptions } from '../utils/cleanNativeOptions';
|
|
9
|
-
/**
|
|
10
|
-
* Extracts a mel spectrogram from audio data
|
|
11
|
-
*
|
|
12
|
-
* @experimental This feature is experimental and currently only available on Android.
|
|
13
|
-
* The iOS implementation will throw an "UNSUPPORTED_PLATFORM" error.
|
|
14
|
-
* The web implementation is a placeholder that returns dummy data.
|
|
15
|
-
*/
|
|
16
|
-
export async function extractMelSpectrogram(options) {
|
|
17
|
-
const { fileUri, arrayBuffer, windowSizeMs, hopLengthMs, nMels, fMin = 0, fMax, windowType = 'hann', normalize = false, logScale = true, decodingOptions, startTimeMs, endTimeMs, logger, } = options;
|
|
18
|
-
if (isWeb) {
|
|
19
|
-
// Create audio context
|
|
20
|
-
const audioContext = new (window.AudioContext ||
|
|
21
|
-
window.webkitAudioContext)();
|
|
22
|
-
try {
|
|
23
|
-
// Process audio data using the existing utility
|
|
24
|
-
const processedAudio = await processAudioBuffer({
|
|
25
|
-
arrayBuffer,
|
|
26
|
-
fileUri,
|
|
27
|
-
targetSampleRate: decodingOptions?.targetSampleRate || 16000,
|
|
28
|
-
targetChannels: decodingOptions?.targetChannels || 1,
|
|
29
|
-
normalizeAudio: decodingOptions?.normalizeAudio ?? false,
|
|
30
|
-
startTimeMs,
|
|
31
|
-
endTimeMs,
|
|
32
|
-
audioContext,
|
|
33
|
-
logger: options.logger,
|
|
34
|
-
});
|
|
35
|
-
// Calculate window and hop size in samples
|
|
36
|
-
const sampleRate = processedAudio.sampleRate;
|
|
37
|
-
const windowSize = Math.floor((windowSizeMs * sampleRate) / 1000);
|
|
38
|
-
const hopLength = Math.floor((hopLengthMs * sampleRate) / 1000);
|
|
39
|
-
const maxFreq = fMax || sampleRate / 2;
|
|
40
|
-
// Extract the mel spectrogram from the processed audio
|
|
41
|
-
const spectrogram = computeMelSpectrogram(processedAudio.channelData, sampleRate, nMels, windowSize, hopLength, fMin, maxFreq, windowType, normalize, logScale);
|
|
42
|
-
const timeSteps = spectrogram.length;
|
|
43
|
-
return {
|
|
44
|
-
spectrogram,
|
|
45
|
-
sampleRate,
|
|
46
|
-
nMels,
|
|
47
|
-
timeSteps,
|
|
48
|
-
durationMs: processedAudio.durationMs,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
logger?.error('Error extracting mel spectrogram:', error);
|
|
53
|
-
throw error;
|
|
54
|
-
}
|
|
55
|
-
finally {
|
|
56
|
-
// Close the audio context
|
|
57
|
-
await audioContext.close();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
// Strip logger/arrayBuffer (non-serializable) then clean undefined values
|
|
61
|
-
// to avoid Android "Cannot convert '[object Object]' to Kotlin type" crash
|
|
62
|
-
const { logger: _logger, arrayBuffer: _arrayBuffer, ...nativeOptions } = options;
|
|
63
|
-
return ExpoAudioStreamModule.extractMelSpectrogram(cleanNativeOptions(nativeOptions));
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Computes a mel spectrogram from audio data
|
|
67
|
-
*
|
|
68
|
-
* @experimental This is a placeholder implementation that returns dummy data.
|
|
69
|
-
* The actual implementation will be added in a future version.
|
|
70
|
-
*/
|
|
71
|
-
function computeMelSpectrogram(audioData, sampleRate, nMels, windowSize, hopLength, fMin, fMax, windowType, normalize, logScale) {
|
|
72
|
-
// Placeholder for the actual implementation
|
|
73
|
-
// This would include:
|
|
74
|
-
// 1. Windowing the audio data using the specified window type
|
|
75
|
-
// 2. Computing the STFT (Short-Time Fourier Transform)
|
|
76
|
-
// 3. Converting to power spectrogram
|
|
77
|
-
// 4. Applying mel filterbanks
|
|
78
|
-
// 5. Taking the logarithm if logScale is true
|
|
79
|
-
// 6. Normalizing if normalize is true
|
|
80
|
-
// For now, return a dummy implementation
|
|
81
|
-
const numFrames = Math.floor((audioData.length - windowSize) / hopLength) + 1;
|
|
82
|
-
const spectrogram = [];
|
|
83
|
-
// Create dummy mel spectrogram data
|
|
84
|
-
for (let i = 0; i < numFrames; i++) {
|
|
85
|
-
spectrogram.push(Array(nMels).fill(0));
|
|
86
|
-
}
|
|
87
|
-
return spectrogram;
|
|
88
|
-
}
|
|
89
|
-
//# sourceMappingURL=extractMelSpectrogram.js.map
|
|
@@ -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,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AAS,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'\nimport { cleanNativeOptions } from '../utils/cleanNativeOptions'\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 // Strip logger/arrayBuffer (non-serializable) then clean undefined values\n // to avoid Android \"Cannot convert '[object Object]' to Kotlin type\" crash\n const {\n logger: _logger,\n arrayBuffer: _arrayBuffer,\n ...nativeOptions\n } = options\n return ExpoAudioStreamModule.extractMelSpectrogram(\n cleanNativeOptions(nativeOptions)\n )\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,25 +0,0 @@
|
|
|
1
|
-
import { extractAudioAnalysis } from './extractAudioAnalysis';
|
|
2
|
-
/**
|
|
3
|
-
* Generates a simplified preview of the audio waveform for quick visualization.
|
|
4
|
-
* Ideal for UI rendering with a specified number of points.
|
|
5
|
-
*
|
|
6
|
-
* @param options - The options for the preview, including file URI and time range.
|
|
7
|
-
* @returns A promise that resolves to the audio preview data.
|
|
8
|
-
*/
|
|
9
|
-
export async function extractPreview({ fileUri, numberOfPoints = 100, startTimeMs = 0, endTimeMs = 30000, // First 30 seconds
|
|
10
|
-
decodingOptions, logger, }) {
|
|
11
|
-
const durationMs = endTimeMs - startTimeMs;
|
|
12
|
-
const segmentDurationMs = Math.floor(durationMs / numberOfPoints);
|
|
13
|
-
// Call extractAudioAnalysis with calculated parameters
|
|
14
|
-
const analysis = await extractAudioAnalysis({
|
|
15
|
-
fileUri,
|
|
16
|
-
startTimeMs,
|
|
17
|
-
endTimeMs,
|
|
18
|
-
logger,
|
|
19
|
-
segmentDurationMs,
|
|
20
|
-
decodingOptions,
|
|
21
|
-
});
|
|
22
|
-
// Transform the result into AudioPreview format
|
|
23
|
-
return analysis;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=extractPreview.js.map
|
|
@@ -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,11 +0,0 @@
|
|
|
1
|
-
import ExpoAudioStreamModule from '../ExpoAudioStreamModule';
|
|
2
|
-
export const extractWaveform = async ({ fileUri, numberOfSamples, offset = 0, length, }) => {
|
|
3
|
-
const res = await ExpoAudioStreamModule.extractAudioAnalysis({
|
|
4
|
-
fileUri,
|
|
5
|
-
numberOfSamples,
|
|
6
|
-
offset,
|
|
7
|
-
length,
|
|
8
|
-
});
|
|
9
|
-
return res;
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=extractWaveform.js.map
|
|
@@ -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"]}
|