@siteed/audio-studio 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/CHANGELOG.md +535 -0
- package/LICENSE +21 -0
- package/README.md +167 -0
- package/android/build.gradle +143 -0
- 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/audiostudio/AudioProcessorInstrumentedTest.kt +197 -0
- package/android/src/androidTest/java/net/siteed/audiostudio/AudioRecorderInstrumentedTest.kt +541 -0
- package/android/src/androidTest/java/net/siteed/audiostudio/AudioRecorderPerformanceInstrumentedTest.kt +234 -0
- package/android/src/androidTest/java/net/siteed/audiostudio/integration/AudioFocusStrategyIntegrationTest.kt +332 -0
- package/android/src/androidTest/java/net/siteed/audiostudio/integration/BufferDurationIntegrationTest.kt +324 -0
- package/android/src/androidTest/java/net/siteed/audiostudio/integration/CompressedOnlyOutputTest.kt +253 -0
- package/android/src/androidTest/java/net/siteed/audiostudio/integration/DeviceDisconnectionFallbackTest.kt +218 -0
- package/android/src/androidTest/java/net/siteed/audiostudio/integration/EventEmissionIntervalTest.kt +120 -0
- package/android/src/androidTest/java/net/siteed/audiostudio/integration/M4aFormatTest.kt +345 -0
- package/android/src/androidTest/java/net/siteed/audiostudio/integration/OutputControlIntegrationTest.kt +340 -0
- package/android/src/androidTest/java/net/siteed/audiostudio/integration/PcmStreamingDurationTest.kt +252 -0
- package/android/src/androidTest/java/net/siteed/audiostudio/integration/README.md +95 -0
- package/android/src/androidTest/java/net/siteed/audiostudio/integration/run_integration_tests.sh +43 -0
- package/android/src/main/AndroidManifest.xml +30 -0
- package/android/src/main/CMakeLists.txt +29 -0
- package/android/src/main/java/net/siteed/audiostudio/AudioAnalysisData.kt +188 -0
- package/android/src/main/java/net/siteed/audiostudio/AudioDataEncoder.kt +9 -0
- package/android/src/main/java/net/siteed/audiostudio/AudioDeviceManager.kt +1741 -0
- package/android/src/main/java/net/siteed/audiostudio/AudioFeaturesNative.kt +26 -0
- package/android/src/main/java/net/siteed/audiostudio/AudioFileHandler.kt +136 -0
- package/android/src/main/java/net/siteed/audiostudio/AudioFormatUtils.kt +354 -0
- package/android/src/main/java/net/siteed/audiostudio/AudioNotificationsManager.kt +439 -0
- package/android/src/main/java/net/siteed/audiostudio/AudioProcessor.kt +2237 -0
- package/android/src/main/java/net/siteed/audiostudio/AudioRecorderManager.kt +2163 -0
- package/android/src/main/java/net/siteed/audiostudio/AudioRecordingService.kt +167 -0
- package/android/src/main/java/net/siteed/audiostudio/AudioStudioModule.kt +1112 -0
- package/android/src/main/java/net/siteed/audiostudio/AudioTrimmer.kt +1099 -0
- package/android/src/main/java/net/siteed/audiostudio/Constants.kt +37 -0
- package/android/src/main/java/net/siteed/audiostudio/EventSender.kt +7 -0
- package/android/src/main/java/net/siteed/audiostudio/FFT.kt +100 -0
- package/android/src/main/java/net/siteed/audiostudio/Features.kt +98 -0
- package/android/src/main/java/net/siteed/audiostudio/LogUtils.kt +93 -0
- package/android/src/main/java/net/siteed/audiostudio/MelSpectrogramNative.kt +36 -0
- package/android/src/main/java/net/siteed/audiostudio/NotificationConfig.kt +72 -0
- package/android/src/main/java/net/siteed/audiostudio/PermissionUtils.kt +68 -0
- package/android/src/main/java/net/siteed/audiostudio/RecordingActionReceiver.kt +59 -0
- package/android/src/main/java/net/siteed/audiostudio/RecordingConfig.kt +259 -0
- package/android/src/main/java/net/siteed/audiostudio/WaveformConfig.kt +19 -0
- package/android/src/main/java/net/siteed/audiostudio/WaveformRenderer.kt +159 -0
- package/android/src/main/jni/AudioFeaturesJNI.cpp +152 -0
- package/android/src/main/jni/MelSpectrogramJNI.cpp +165 -0
- package/android/src/main/res/drawable/ic_default_action_icon.xml +16 -0
- package/android/src/main/res/drawable/ic_microphone.xml +13 -0
- package/android/src/main/res/drawable/ic_pause.xml +10 -0
- package/android/src/main/res/drawable/ic_play.xml +10 -0
- package/android/src/main/res/drawable/ic_stop.xml +10 -0
- package/android/src/main/res/layout/notification_recording.xml +37 -0
- package/android/src/test/java/net/siteed/audiostudio/AudioFileHandlerTest.kt +279 -0
- package/android/src/test/java/net/siteed/audiostudio/AudioFocusStrategyTest.kt +249 -0
- package/android/src/test/java/net/siteed/audiostudio/AudioFormatTest.kt +151 -0
- package/android/src/test/java/net/siteed/audiostudio/AudioFormatUtilsTest.kt +273 -0
- package/android/src/test/java/net/siteed/audiostudio/DeviceDisconnectionFallbackUnitTest.kt +140 -0
- package/android/src/test/resources/chorus.wav +0 -0
- package/android/src/test/resources/generate_test_audio.py +94 -0
- 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 +3 -0
- package/build/cjs/AudioAnalysis/AudioAnalysis.types.js +4 -0
- package/build/cjs/AudioAnalysis/AudioAnalysis.types.js.map +1 -0
- package/build/cjs/AudioAnalysis/audioFeaturesWasm.js +164 -0
- package/build/cjs/AudioAnalysis/audioFeaturesWasm.js.map +1 -0
- package/build/cjs/AudioAnalysis/extractAudioAnalysis.js +213 -0
- package/build/cjs/AudioAnalysis/extractAudioAnalysis.js.map +1 -0
- package/build/cjs/AudioAnalysis/extractAudioData.js +21 -0
- package/build/cjs/AudioAnalysis/extractAudioData.js.map +1 -0
- package/build/cjs/AudioAnalysis/extractMelSpectrogram.js +90 -0
- package/build/cjs/AudioAnalysis/extractMelSpectrogram.js.map +1 -0
- package/build/cjs/AudioAnalysis/extractPreview.js +28 -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/AudioAnalysis/melSpectrogramWasm.js +149 -0
- package/build/cjs/AudioAnalysis/melSpectrogramWasm.js.map +1 -0
- package/build/cjs/AudioDeviceManager.js +688 -0
- package/build/cjs/AudioDeviceManager.js.map +1 -0
- package/build/cjs/AudioRecorder.provider.js +78 -0
- package/build/cjs/AudioRecorder.provider.js.map +1 -0
- package/build/cjs/AudioStudio.native.js +8 -0
- package/build/cjs/AudioStudio.native.js.map +1 -0
- package/build/cjs/AudioStudio.types.js +11 -0
- package/build/cjs/AudioStudio.types.js.map +1 -0
- package/build/cjs/AudioStudio.web.js +708 -0
- package/build/cjs/AudioStudio.web.js.map +1 -0
- package/build/cjs/AudioStudioModule.js +718 -0
- package/build/cjs/AudioStudioModule.js.map +1 -0
- package/build/cjs/WebRecorder.web.js +865 -0
- package/build/cjs/WebRecorder.web.js.map +1 -0
- package/build/cjs/constants/platformLimitations.js +99 -0
- package/build/cjs/constants/platformLimitations.js.map +1 -0
- package/build/cjs/constants.js +20 -0
- package/build/cjs/constants.js.map +1 -0
- package/build/cjs/events.js +29 -0
- package/build/cjs/events.js.map +1 -0
- package/build/cjs/hooks/useAudioDevices.js +179 -0
- package/build/cjs/hooks/useAudioDevices.js.map +1 -0
- package/build/cjs/index.js +64 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/trimAudio.js +76 -0
- package/build/cjs/trimAudio.js.map +1 -0
- package/build/cjs/useAudioRecorder.js +535 -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 +136 -0
- package/build/cjs/utils/audioProcessing.js.map +1 -0
- package/build/cjs/utils/cleanNativeOptions.js +22 -0
- package/build/cjs/utils/cleanNativeOptions.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 +294 -0
- package/build/cjs/workers/InlineFeaturesExtractor.web.js.map +1 -0
- package/build/cjs/workers/inlineAudioWebWorker.web.js +190 -0
- package/build/cjs/workers/inlineAudioWebWorker.web.js.map +1 -0
- package/build/cjs/workers/wasmGlueString.web.js +27 -0
- package/build/cjs/workers/wasmGlueString.web.js.map +1 -0
- package/build/esm/AudioAnalysis/AudioAnalysis.types.js +3 -0
- package/build/esm/AudioAnalysis/AudioAnalysis.types.js.map +1 -0
- package/build/esm/AudioAnalysis/audioFeaturesWasm.js +126 -0
- package/build/esm/AudioAnalysis/audioFeaturesWasm.js.map +1 -0
- package/build/esm/AudioAnalysis/extractAudioAnalysis.js +205 -0
- package/build/esm/AudioAnalysis/extractAudioAnalysis.js.map +1 -0
- package/build/esm/AudioAnalysis/extractAudioData.js +14 -0
- package/build/esm/AudioAnalysis/extractAudioData.js.map +1 -0
- package/build/esm/AudioAnalysis/extractMelSpectrogram.js +86 -0
- package/build/esm/AudioAnalysis/extractMelSpectrogram.js.map +1 -0
- package/build/esm/AudioAnalysis/extractPreview.js +25 -0
- package/build/esm/AudioAnalysis/extractPreview.js.map +1 -0
- package/build/esm/AudioAnalysis/extractWaveform.js +11 -0
- package/build/esm/AudioAnalysis/extractWaveform.js.map +1 -0
- package/build/esm/AudioAnalysis/melSpectrogramWasm.js +111 -0
- package/build/esm/AudioAnalysis/melSpectrogramWasm.js.map +1 -0
- package/build/esm/AudioDeviceManager.js +681 -0
- package/build/esm/AudioDeviceManager.js.map +1 -0
- package/build/esm/AudioRecorder.provider.js +40 -0
- package/build/esm/AudioRecorder.provider.js.map +1 -0
- package/build/esm/AudioStudio.native.js +6 -0
- package/build/esm/AudioStudio.native.js.map +1 -0
- package/build/esm/AudioStudio.types.js +8 -0
- package/build/esm/AudioStudio.types.js.map +1 -0
- package/build/esm/AudioStudio.web.js +704 -0
- package/build/esm/AudioStudio.web.js.map +1 -0
- package/build/esm/AudioStudioModule.js +713 -0
- package/build/esm/AudioStudioModule.js.map +1 -0
- package/build/esm/WebRecorder.web.js +861 -0
- package/build/esm/WebRecorder.web.js.map +1 -0
- package/build/esm/constants/platformLimitations.js +90 -0
- package/build/esm/constants/platformLimitations.js.map +1 -0
- package/build/esm/constants.js +17 -0
- package/build/esm/constants.js.map +1 -0
- package/build/esm/events.js +21 -0
- package/build/esm/events.js.map +1 -0
- package/build/esm/hooks/useAudioDevices.js +176 -0
- package/build/esm/hooks/useAudioDevices.js.map +1 -0
- package/build/esm/index.js +23 -0
- package/build/esm/index.js.map +1 -0
- package/build/esm/trimAudio.js +69 -0
- package/build/esm/trimAudio.js.map +1 -0
- package/build/esm/useAudioRecorder.js +529 -0
- package/build/esm/useAudioRecorder.js.map +1 -0
- package/build/esm/utils/BlobFix.js +498 -0
- package/build/esm/utils/BlobFix.js.map +1 -0
- package/build/esm/utils/audioProcessing.js +133 -0
- package/build/esm/utils/audioProcessing.js.map +1 -0
- package/build/esm/utils/cleanNativeOptions.js +19 -0
- package/build/esm/utils/cleanNativeOptions.js.map +1 -0
- package/build/esm/utils/concatenateBuffers.js +21 -0
- package/build/esm/utils/concatenateBuffers.js.map +1 -0
- package/build/esm/utils/convertPCMToFloat32.js +120 -0
- package/build/esm/utils/convertPCMToFloat32.js.map +1 -0
- package/build/esm/utils/crc32.js +50 -0
- package/build/esm/utils/crc32.js.map +1 -0
- package/build/esm/utils/encodingToBitDepth.js +13 -0
- package/build/esm/utils/encodingToBitDepth.js.map +1 -0
- package/build/esm/utils/getWavFileInfo.js +92 -0
- package/build/esm/utils/getWavFileInfo.js.map +1 -0
- package/build/esm/utils/writeWavHeader.js +84 -0
- package/build/esm/utils/writeWavHeader.js.map +1 -0
- package/build/esm/workers/InlineFeaturesExtractor.web.js +291 -0
- package/build/esm/workers/InlineFeaturesExtractor.web.js.map +1 -0
- package/build/esm/workers/inlineAudioWebWorker.web.js +187 -0
- package/build/esm/workers/inlineAudioWebWorker.web.js.map +1 -0
- package/build/esm/workers/wasmGlueString.web.js +24 -0
- package/build/esm/workers/wasmGlueString.web.js.map +1 -0
- package/build/types/AudioAnalysis/AudioAnalysis.types.d.ts +198 -0
- package/build/types/AudioAnalysis/AudioAnalysis.types.d.ts.map +1 -0
- package/build/types/AudioAnalysis/audioFeaturesWasm.d.ts +24 -0
- package/build/types/AudioAnalysis/audioFeaturesWasm.d.ts.map +1 -0
- package/build/types/AudioAnalysis/extractAudioAnalysis.d.ts +74 -0
- package/build/types/AudioAnalysis/extractAudioAnalysis.d.ts.map +1 -0
- package/build/types/AudioAnalysis/extractAudioData.d.ts +3 -0
- package/build/types/AudioAnalysis/extractAudioData.d.ts.map +1 -0
- package/build/types/AudioAnalysis/extractMelSpectrogram.d.ts +20 -0
- package/build/types/AudioAnalysis/extractMelSpectrogram.d.ts.map +1 -0
- package/build/types/AudioAnalysis/extractPreview.d.ts +11 -0
- package/build/types/AudioAnalysis/extractPreview.d.ts.map +1 -0
- package/build/types/AudioAnalysis/extractWaveform.d.ts +8 -0
- package/build/types/AudioAnalysis/extractWaveform.d.ts.map +1 -0
- package/build/types/AudioAnalysis/melSpectrogramWasm.d.ts +16 -0
- package/build/types/AudioAnalysis/melSpectrogramWasm.d.ts.map +1 -0
- package/build/types/AudioDeviceManager.d.ts +187 -0
- package/build/types/AudioDeviceManager.d.ts.map +1 -0
- package/build/types/AudioRecorder.provider.d.ts +11 -0
- package/build/types/AudioRecorder.provider.d.ts.map +1 -0
- package/build/types/AudioStudio.native.d.ts +3 -0
- package/build/types/AudioStudio.native.d.ts.map +1 -0
- package/build/types/AudioStudio.types.d.ts +760 -0
- package/build/types/AudioStudio.types.d.ts.map +1 -0
- package/build/types/AudioStudio.web.d.ts +96 -0
- package/build/types/AudioStudio.web.d.ts.map +1 -0
- package/build/types/AudioStudioModule.d.ts +3 -0
- package/build/types/AudioStudioModule.d.ts.map +1 -0
- package/build/types/WebRecorder.web.d.ts +208 -0
- package/build/types/WebRecorder.web.d.ts.map +1 -0
- package/build/types/constants/platformLimitations.d.ts +40 -0
- package/build/types/constants/platformLimitations.d.ts.map +1 -0
- package/build/types/constants.d.ts +14 -0
- package/build/types/constants.d.ts.map +1 -0
- package/build/types/events.d.ts +29 -0
- package/build/types/events.d.ts.map +1 -0
- package/build/types/hooks/useAudioDevices.d.ts +15 -0
- package/build/types/hooks/useAudioDevices.d.ts.map +1 -0
- package/build/types/index.d.ts +21 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/trimAudio.d.ts +25 -0
- package/build/types/trimAudio.d.ts.map +1 -0
- package/build/types/useAudioRecorder.d.ts +22 -0
- package/build/types/useAudioRecorder.d.ts.map +1 -0
- package/build/types/utils/BlobFix.d.ts +9 -0
- package/build/types/utils/BlobFix.d.ts.map +1 -0
- package/build/types/utils/audioProcessing.d.ts +24 -0
- package/build/types/utils/audioProcessing.d.ts.map +1 -0
- package/build/types/utils/cleanNativeOptions.d.ts +15 -0
- package/build/types/utils/cleanNativeOptions.d.ts.map +1 -0
- package/build/types/utils/concatenateBuffers.d.ts +8 -0
- package/build/types/utils/concatenateBuffers.d.ts.map +1 -0
- package/build/types/utils/convertPCMToFloat32.d.ts +13 -0
- package/build/types/utils/convertPCMToFloat32.d.ts.map +1 -0
- package/build/types/utils/crc32.d.ts +7 -0
- package/build/types/utils/crc32.d.ts.map +1 -0
- package/build/types/utils/encodingToBitDepth.d.ts +5 -0
- package/build/types/utils/encodingToBitDepth.d.ts.map +1 -0
- package/build/types/utils/getWavFileInfo.d.ts +26 -0
- package/build/types/utils/getWavFileInfo.d.ts.map +1 -0
- package/build/types/utils/writeWavHeader.d.ts +34 -0
- package/build/types/utils/writeWavHeader.d.ts.map +1 -0
- package/build/types/workers/InlineFeaturesExtractor.web.d.ts +2 -0
- package/build/types/workers/InlineFeaturesExtractor.web.d.ts.map +1 -0
- package/build/types/workers/inlineAudioWebWorker.web.d.ts +2 -0
- package/build/types/workers/inlineAudioWebWorker.web.d.ts.map +1 -0
- package/build/types/workers/wasmGlueString.web.d.ts +2 -0
- package/build/types/workers/wasmGlueString.web.d.ts.map +1 -0
- package/cpp/AudioFeatures.cpp +274 -0
- package/cpp/AudioFeatures.h +85 -0
- package/cpp/AudioFeaturesBridge.cpp +146 -0
- package/cpp/AudioFeaturesBridge.h +47 -0
- package/cpp/MelSpectrogram.cpp +227 -0
- package/cpp/MelSpectrogram.h +82 -0
- package/cpp/MelSpectrogramBridge.cpp +112 -0
- package/cpp/MelSpectrogramBridge.h +33 -0
- package/cpp/kiss_fft/COPYING +11 -0
- package/cpp/kiss_fft/_kiss_fft_guts.h +167 -0
- package/cpp/kiss_fft/kiss_fft.c +424 -0
- package/cpp/kiss_fft/kiss_fft.h +160 -0
- package/cpp/kiss_fft/kiss_fft_log.h +36 -0
- package/cpp/kiss_fft/kiss_fftr.c +155 -0
- package/cpp/kiss_fft/kiss_fftr.h +54 -0
- package/expo-module.config.json +10 -0
- package/ios/AudioAnalysisData.swift +74 -0
- package/ios/AudioDeviceManager.swift +670 -0
- package/ios/AudioFeaturesWrapper.h +21 -0
- package/ios/AudioFeaturesWrapper.mm +63 -0
- package/ios/AudioNotificationManager.swift +154 -0
- package/ios/AudioProcessingHelpers.swift +797 -0
- package/ios/AudioProcessor.swift +1191 -0
- package/ios/AudioStreamError.swift +7 -0
- package/ios/AudioStreamManager.swift +2369 -0
- package/ios/AudioStreamManagerDelegate.swift +16 -0
- package/ios/AudioStudio.podspec +39 -0
- package/ios/AudioStudioModule.swift +1111 -0
- package/ios/AudioStudioTests/AudioFileHandlerTests.swift +338 -0
- package/ios/AudioStudioTests/AudioFormatUtilsTests.swift +331 -0
- package/ios/AudioStudioTests/AudioTestHelpers.swift +130 -0
- package/ios/AudioStudioTests/CompressedOnlyOutputTests.swift +294 -0
- package/ios/AudioStudioTests/EventEmissionIntervalTests.swift +105 -0
- package/ios/AudioStudioTests/Info.plist +22 -0
- package/ios/AudioStudioTests/README.md +39 -0
- package/ios/AudioStudioTests/SimpleAudioTest.swift +98 -0
- package/ios/AudioStudioTests/TestAudioGenerator.swift +75 -0
- package/ios/DataPoint.swift +54 -0
- package/ios/DecodingConfig.swift +59 -0
- package/ios/FFT.swift +62 -0
- package/ios/Features.swift +95 -0
- package/ios/ISSUE_IOS.md +68 -0
- package/ios/Logger.swift +39 -0
- package/ios/MelSpectrogramWrapper.h +30 -0
- package/ios/MelSpectrogramWrapper.mm +97 -0
- package/ios/NotificationExtension.swift +15 -0
- package/ios/RecordingResult.swift +22 -0
- package/ios/RecordingSettings.swift +311 -0
- package/ios/WaveformExtractor.swift +105 -0
- package/ios/tests/README.md +41 -0
- package/ios/tests/integration/buffer_and_fallback_test.swift +178 -0
- package/ios/tests/integration/buffer_duration_test.swift +185 -0
- package/ios/tests/integration/compressed_only_output_test.swift +271 -0
- package/ios/tests/integration/output_control_test.swift +322 -0
- package/ios/tests/integration/run_integration_tests.sh +37 -0
- package/ios/tests/opus_support_test_macos.swift +154 -0
- package/ios/tests/standalone/audio_processing_test.swift +144 -0
- package/ios/tests/standalone/audio_recording_test.swift +277 -0
- package/ios/tests/standalone/audio_streaming_test.swift +249 -0
- package/ios/tests/standalone/standalone_test.swift +144 -0
- package/package.json +146 -0
- package/plugin/build/index.cjs +194 -0
- package/plugin/build/index.d.cts +22 -0
- package/plugin/build/index.js +194 -0
- package/plugin/src/index.ts +285 -0
- package/plugin/tsconfig.json +10 -0
- package/plugin/tsconfig.tsbuildinfo +1 -0
- package/prebuilt/wasm/mel-spectrogram.js +18 -0
- package/src/AudioAnalysis/AudioAnalysis.types.ts +226 -0
- package/src/AudioAnalysis/audio-features-wasm.d.ts +37 -0
- package/src/AudioAnalysis/audioFeaturesWasm.ts +200 -0
- package/src/AudioAnalysis/extractAudioAnalysis.ts +350 -0
- package/src/AudioAnalysis/extractAudioData.ts +17 -0
- package/src/AudioAnalysis/extractMelSpectrogram.ts +140 -0
- package/src/AudioAnalysis/extractPreview.ts +34 -0
- package/src/AudioAnalysis/extractWaveform.ts +22 -0
- package/src/AudioAnalysis/mel-spectrogram-wasm.d.ts +48 -0
- package/src/AudioAnalysis/melSpectrogramWasm.ts +179 -0
- package/src/AudioDeviceManager.ts +800 -0
- package/src/AudioRecorder.provider.tsx +57 -0
- package/src/AudioStudio.native.ts +6 -0
- package/src/AudioStudio.types.ts +899 -0
- package/src/AudioStudio.web.ts +911 -0
- package/src/AudioStudioModule.ts +984 -0
- package/src/WebRecorder.web.ts +1114 -0
- package/src/constants/platformLimitations.ts +118 -0
- package/src/constants.ts +21 -0
- package/src/events.ts +63 -0
- package/src/hooks/useAudioDevices.ts +213 -0
- package/src/index.ts +67 -0
- package/src/trimAudio.ts +94 -0
- package/src/types/crc-32.d.ts +9 -0
- package/src/useAudioRecorder.tsx +784 -0
- package/src/utils/BlobFix.ts +561 -0
- package/src/utils/audioProcessing.ts +205 -0
- package/src/utils/cleanNativeOptions.ts +18 -0
- package/src/utils/concatenateBuffers.ts +24 -0
- package/src/utils/convertPCMToFloat32.ts +170 -0
- package/src/utils/crc32.ts +59 -0
- package/src/utils/encodingToBitDepth.ts +18 -0
- package/src/utils/getWavFileInfo.ts +132 -0
- package/src/utils/writeWavHeader.ts +115 -0
- package/src/workers/InlineFeaturesExtractor.web.tsx +291 -0
- package/src/workers/inlineAudioWebWorker.web.tsx +186 -0
- package/src/workers/wasmGlueString.web.ts +23 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2003-2010, Mark Borgerding. All rights reserved.
|
|
3
|
+
* This file is part of KISS FFT - https://github.com/mborgerding/kissfft
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
+
* See COPYING file for more information.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#ifndef KISS_FFT_H
|
|
10
|
+
#define KISS_FFT_H
|
|
11
|
+
|
|
12
|
+
#include <stdlib.h>
|
|
13
|
+
#include <stdio.h>
|
|
14
|
+
#include <math.h>
|
|
15
|
+
#include <string.h>
|
|
16
|
+
|
|
17
|
+
// Define KISS_FFT_SHARED macro to properly export symbols
|
|
18
|
+
#ifdef KISS_FFT_SHARED
|
|
19
|
+
# ifdef _WIN32
|
|
20
|
+
# ifdef KISS_FFT_BUILD
|
|
21
|
+
# define KISS_FFT_API __declspec(dllexport)
|
|
22
|
+
# else
|
|
23
|
+
# define KISS_FFT_API __declspec(dllimport)
|
|
24
|
+
# endif
|
|
25
|
+
# else
|
|
26
|
+
# define KISS_FFT_API __attribute__ ((visibility ("default")))
|
|
27
|
+
# endif
|
|
28
|
+
#else
|
|
29
|
+
# define KISS_FFT_API
|
|
30
|
+
#endif
|
|
31
|
+
|
|
32
|
+
#ifdef __cplusplus
|
|
33
|
+
extern "C" {
|
|
34
|
+
#endif
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
ATTENTION!
|
|
38
|
+
If you would like a :
|
|
39
|
+
-- a utility that will handle the caching of fft objects
|
|
40
|
+
-- real-only (no imaginary time component ) FFT
|
|
41
|
+
-- a multi-dimensional FFT
|
|
42
|
+
-- a command-line utility to perform ffts
|
|
43
|
+
-- a command-line utility to perform fast-convolution filtering
|
|
44
|
+
|
|
45
|
+
Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c
|
|
46
|
+
in the tools/ directory.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/* User may override KISS_FFT_MALLOC and/or KISS_FFT_FREE. */
|
|
50
|
+
#ifdef USE_SIMD
|
|
51
|
+
# include <xmmintrin.h>
|
|
52
|
+
# define kiss_fft_scalar __m128
|
|
53
|
+
# ifndef KISS_FFT_MALLOC
|
|
54
|
+
# define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes,16)
|
|
55
|
+
# define KISS_FFT_ALIGN_CHECK(ptr)
|
|
56
|
+
# define KISS_FFT_ALIGN_SIZE_UP(size) ((size + 15UL) & ~0xFUL)
|
|
57
|
+
# endif
|
|
58
|
+
# ifndef KISS_FFT_FREE
|
|
59
|
+
# define KISS_FFT_FREE _mm_free
|
|
60
|
+
# endif
|
|
61
|
+
#else
|
|
62
|
+
# define KISS_FFT_ALIGN_CHECK(ptr)
|
|
63
|
+
# define KISS_FFT_ALIGN_SIZE_UP(size) (size)
|
|
64
|
+
# ifndef KISS_FFT_MALLOC
|
|
65
|
+
# define KISS_FFT_MALLOC malloc
|
|
66
|
+
# endif
|
|
67
|
+
# ifndef KISS_FFT_FREE
|
|
68
|
+
# define KISS_FFT_FREE free
|
|
69
|
+
# endif
|
|
70
|
+
#endif
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
#ifdef FIXED_POINT
|
|
74
|
+
#include <stdint.h>
|
|
75
|
+
# if (FIXED_POINT == 32)
|
|
76
|
+
# define kiss_fft_scalar int32_t
|
|
77
|
+
# else
|
|
78
|
+
# define kiss_fft_scalar int16_t
|
|
79
|
+
# endif
|
|
80
|
+
#else
|
|
81
|
+
# ifndef kiss_fft_scalar
|
|
82
|
+
/* default is float */
|
|
83
|
+
# define kiss_fft_scalar float
|
|
84
|
+
# endif
|
|
85
|
+
#endif
|
|
86
|
+
|
|
87
|
+
typedef struct {
|
|
88
|
+
kiss_fft_scalar r;
|
|
89
|
+
kiss_fft_scalar i;
|
|
90
|
+
}kiss_fft_cpx;
|
|
91
|
+
|
|
92
|
+
typedef struct kiss_fft_state* kiss_fft_cfg;
|
|
93
|
+
|
|
94
|
+
/*
|
|
95
|
+
* kiss_fft_alloc
|
|
96
|
+
*
|
|
97
|
+
* Initialize a FFT (or IFFT) algorithm's cfg/state buffer.
|
|
98
|
+
*
|
|
99
|
+
* typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL);
|
|
100
|
+
*
|
|
101
|
+
* The return value from fft_alloc is a cfg buffer used internally
|
|
102
|
+
* by the fft routine or NULL.
|
|
103
|
+
*
|
|
104
|
+
* If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc.
|
|
105
|
+
* The returned value should be free()d when done to avoid memory leaks.
|
|
106
|
+
*
|
|
107
|
+
* The state can be placed in a user supplied buffer 'mem':
|
|
108
|
+
* If lenmem is not NULL and mem is not NULL and *lenmem is large enough,
|
|
109
|
+
* then the function places the cfg in mem and the size used in *lenmem
|
|
110
|
+
* and returns mem.
|
|
111
|
+
*
|
|
112
|
+
* If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough),
|
|
113
|
+
* then the function returns NULL and places the minimum cfg
|
|
114
|
+
* buffer size in *lenmem.
|
|
115
|
+
* */
|
|
116
|
+
|
|
117
|
+
kiss_fft_cfg KISS_FFT_API kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem);
|
|
118
|
+
|
|
119
|
+
/*
|
|
120
|
+
* kiss_fft(cfg,in_out_buf)
|
|
121
|
+
*
|
|
122
|
+
* Perform an FFT on a complex input buffer.
|
|
123
|
+
* for a forward FFT,
|
|
124
|
+
* fin should be f[0] , f[1] , ... ,f[nfft-1]
|
|
125
|
+
* fout will be F[0] , F[1] , ... ,F[nfft-1]
|
|
126
|
+
* Note that each element is complex and can be accessed like
|
|
127
|
+
f[k].r and f[k].i
|
|
128
|
+
* */
|
|
129
|
+
void KISS_FFT_API kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout);
|
|
130
|
+
|
|
131
|
+
/*
|
|
132
|
+
A more generic version of the above function. It reads its input from every Nth sample.
|
|
133
|
+
* */
|
|
134
|
+
void KISS_FFT_API kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride);
|
|
135
|
+
|
|
136
|
+
/* If kiss_fft_alloc allocated a buffer, it is one contiguous
|
|
137
|
+
buffer and can be simply free()d when no longer needed*/
|
|
138
|
+
#define kiss_fft_free KISS_FFT_FREE
|
|
139
|
+
|
|
140
|
+
/*
|
|
141
|
+
Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up
|
|
142
|
+
your compiler output to call this before you exit.
|
|
143
|
+
*/
|
|
144
|
+
void KISS_FFT_API kiss_fft_cleanup(void);
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
/*
|
|
148
|
+
* Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5)
|
|
149
|
+
*/
|
|
150
|
+
int KISS_FFT_API kiss_fft_next_fast_size(int n);
|
|
151
|
+
|
|
152
|
+
/* for real ffts, we need an even size */
|
|
153
|
+
#define kiss_fftr_next_fast_size_real(n) \
|
|
154
|
+
(kiss_fft_next_fast_size( ((n)+1)>>1)<<1)
|
|
155
|
+
|
|
156
|
+
#ifdef __cplusplus
|
|
157
|
+
}
|
|
158
|
+
#endif
|
|
159
|
+
|
|
160
|
+
#endif
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2003-2010, Mark Borgerding. All rights reserved.
|
|
3
|
+
* This file is part of KISS FFT - https://github.com/mborgerding/kissfft
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
+
* See COPYING file for more information.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#ifndef kiss_fft_log_h
|
|
10
|
+
#define kiss_fft_log_h
|
|
11
|
+
|
|
12
|
+
#define ERROR 1
|
|
13
|
+
#define WARNING 2
|
|
14
|
+
#define INFO 3
|
|
15
|
+
#define DEBUG 4
|
|
16
|
+
|
|
17
|
+
#define STRINGIFY(x) #x
|
|
18
|
+
#define TOSTRING(x) STRINGIFY(x)
|
|
19
|
+
|
|
20
|
+
#if defined(NDEBUG)
|
|
21
|
+
# define KISS_FFT_LOG_MSG(severity, ...) ((void)0)
|
|
22
|
+
#else
|
|
23
|
+
# define KISS_FFT_LOG_MSG(severity, ...) \
|
|
24
|
+
fprintf(stderr, "[" #severity "] " __FILE__ ":" TOSTRING(__LINE__) " "); \
|
|
25
|
+
fprintf(stderr, __VA_ARGS__); \
|
|
26
|
+
fprintf(stderr, "\n")
|
|
27
|
+
#endif
|
|
28
|
+
|
|
29
|
+
#define KISS_FFT_ERROR(...) KISS_FFT_LOG_MSG(ERROR, __VA_ARGS__)
|
|
30
|
+
#define KISS_FFT_WARNING(...) KISS_FFT_LOG_MSG(WARNING, __VA_ARGS__)
|
|
31
|
+
#define KISS_FFT_INFO(...) KISS_FFT_LOG_MSG(INFO, __VA_ARGS__)
|
|
32
|
+
#define KISS_FFT_DEBUG(...) KISS_FFT_LOG_MSG(DEBUG, __VA_ARGS__)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
#endif /* kiss_fft_log_h */
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2003-2004, Mark Borgerding. All rights reserved.
|
|
3
|
+
* This file is part of KISS FFT - https://github.com/mborgerding/kissfft
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
+
* See COPYING file for more information.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#include "kiss_fftr.h"
|
|
10
|
+
#include "_kiss_fft_guts.h"
|
|
11
|
+
|
|
12
|
+
struct kiss_fftr_state{
|
|
13
|
+
kiss_fft_cfg substate;
|
|
14
|
+
kiss_fft_cpx * tmpbuf;
|
|
15
|
+
kiss_fft_cpx * super_twiddles;
|
|
16
|
+
#ifdef USE_SIMD
|
|
17
|
+
void * pad;
|
|
18
|
+
#endif
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
kiss_fftr_cfg kiss_fftr_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem)
|
|
22
|
+
{
|
|
23
|
+
KISS_FFT_ALIGN_CHECK(mem)
|
|
24
|
+
|
|
25
|
+
int i;
|
|
26
|
+
kiss_fftr_cfg st = NULL;
|
|
27
|
+
size_t subsize = 0, memneeded;
|
|
28
|
+
|
|
29
|
+
if (nfft & 1) {
|
|
30
|
+
KISS_FFT_ERROR("Real FFT optimization must be even.");
|
|
31
|
+
return NULL;
|
|
32
|
+
}
|
|
33
|
+
nfft >>= 1;
|
|
34
|
+
|
|
35
|
+
kiss_fft_alloc (nfft, inverse_fft, NULL, &subsize);
|
|
36
|
+
memneeded = sizeof(struct kiss_fftr_state) + subsize + sizeof(kiss_fft_cpx) * ( nfft * 3 / 2);
|
|
37
|
+
|
|
38
|
+
if (lenmem == NULL) {
|
|
39
|
+
st = (kiss_fftr_cfg) KISS_FFT_MALLOC (memneeded);
|
|
40
|
+
} else {
|
|
41
|
+
if (*lenmem >= memneeded)
|
|
42
|
+
st = (kiss_fftr_cfg) mem;
|
|
43
|
+
*lenmem = memneeded;
|
|
44
|
+
}
|
|
45
|
+
if (!st)
|
|
46
|
+
return NULL;
|
|
47
|
+
|
|
48
|
+
st->substate = (kiss_fft_cfg) (st + 1); /*just beyond kiss_fftr_state struct */
|
|
49
|
+
st->tmpbuf = (kiss_fft_cpx *) (((char *) st->substate) + subsize);
|
|
50
|
+
st->super_twiddles = st->tmpbuf + nfft;
|
|
51
|
+
kiss_fft_alloc(nfft, inverse_fft, st->substate, &subsize);
|
|
52
|
+
|
|
53
|
+
for (i = 0; i < nfft/2; ++i) {
|
|
54
|
+
double phase =
|
|
55
|
+
-3.14159265358979323846264338327 * ((double) (i+1) / nfft + .5);
|
|
56
|
+
if (inverse_fft)
|
|
57
|
+
phase *= -1;
|
|
58
|
+
kf_cexp (st->super_twiddles+i,phase);
|
|
59
|
+
}
|
|
60
|
+
return st;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
void kiss_fftr(kiss_fftr_cfg st,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata)
|
|
64
|
+
{
|
|
65
|
+
/* input buffer timedata is stored row-wise */
|
|
66
|
+
int k,ncfft;
|
|
67
|
+
kiss_fft_cpx fpnk,fpk,f1k,f2k,tw,tdc;
|
|
68
|
+
|
|
69
|
+
if ( st->substate->inverse) {
|
|
70
|
+
KISS_FFT_ERROR("kiss fft usage error: improper alloc");
|
|
71
|
+
return;/* The caller did not call the correct function */
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
ncfft = st->substate->nfft;
|
|
75
|
+
|
|
76
|
+
/*perform the parallel fft of two real signals packed in real,imag*/
|
|
77
|
+
kiss_fft( st->substate , (const kiss_fft_cpx*)timedata, st->tmpbuf );
|
|
78
|
+
/* The real part of the DC element of the frequency spectrum in st->tmpbuf
|
|
79
|
+
* contains the sum of the even-numbered elements of the input time sequence
|
|
80
|
+
* The imag part is the sum of the odd-numbered elements
|
|
81
|
+
*
|
|
82
|
+
* The sum of tdc.r and tdc.i is the sum of the input time sequence.
|
|
83
|
+
* yielding DC of input time sequence
|
|
84
|
+
* The difference of tdc.r - tdc.i is the sum of the input (dot product) [1,-1,1,-1...
|
|
85
|
+
* yielding Nyquist bin of input time sequence
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
tdc.r = st->tmpbuf[0].r;
|
|
89
|
+
tdc.i = st->tmpbuf[0].i;
|
|
90
|
+
C_FIXDIV(tdc,2);
|
|
91
|
+
CHECK_OVERFLOW_OP(tdc.r ,+, tdc.i);
|
|
92
|
+
CHECK_OVERFLOW_OP(tdc.r ,-, tdc.i);
|
|
93
|
+
freqdata[0].r = tdc.r + tdc.i;
|
|
94
|
+
freqdata[ncfft].r = tdc.r - tdc.i;
|
|
95
|
+
#ifdef USE_SIMD
|
|
96
|
+
freqdata[ncfft].i = freqdata[0].i = _mm_set1_ps(0);
|
|
97
|
+
#else
|
|
98
|
+
freqdata[ncfft].i = freqdata[0].i = 0;
|
|
99
|
+
#endif
|
|
100
|
+
|
|
101
|
+
for ( k=1;k <= ncfft/2 ; ++k ) {
|
|
102
|
+
fpk = st->tmpbuf[k];
|
|
103
|
+
fpnk.r = st->tmpbuf[ncfft-k].r;
|
|
104
|
+
fpnk.i = - st->tmpbuf[ncfft-k].i;
|
|
105
|
+
C_FIXDIV(fpk,2);
|
|
106
|
+
C_FIXDIV(fpnk,2);
|
|
107
|
+
|
|
108
|
+
C_ADD( f1k, fpk , fpnk );
|
|
109
|
+
C_SUB( f2k, fpk , fpnk );
|
|
110
|
+
C_MUL( tw , f2k , st->super_twiddles[k-1]);
|
|
111
|
+
|
|
112
|
+
freqdata[k].r = HALF_OF(f1k.r + tw.r);
|
|
113
|
+
freqdata[k].i = HALF_OF(f1k.i + tw.i);
|
|
114
|
+
freqdata[ncfft-k].r = HALF_OF(f1k.r - tw.r);
|
|
115
|
+
freqdata[ncfft-k].i = HALF_OF(tw.i - f1k.i);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
void kiss_fftri(kiss_fftr_cfg st,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata)
|
|
120
|
+
{
|
|
121
|
+
/* input buffer timedata is stored row-wise */
|
|
122
|
+
int k, ncfft;
|
|
123
|
+
|
|
124
|
+
if (st->substate->inverse == 0) {
|
|
125
|
+
KISS_FFT_ERROR("kiss fft usage error: improper alloc");
|
|
126
|
+
return;/* The caller did not call the correct function */
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
ncfft = st->substate->nfft;
|
|
130
|
+
|
|
131
|
+
st->tmpbuf[0].r = freqdata[0].r + freqdata[ncfft].r;
|
|
132
|
+
st->tmpbuf[0].i = freqdata[0].r - freqdata[ncfft].r;
|
|
133
|
+
C_FIXDIV(st->tmpbuf[0],2);
|
|
134
|
+
|
|
135
|
+
for (k = 1; k <= ncfft / 2; ++k) {
|
|
136
|
+
kiss_fft_cpx fk, fnkc, fek, fok, tmp;
|
|
137
|
+
fk = freqdata[k];
|
|
138
|
+
fnkc.r = freqdata[ncfft - k].r;
|
|
139
|
+
fnkc.i = -freqdata[ncfft - k].i;
|
|
140
|
+
C_FIXDIV( fk , 2 );
|
|
141
|
+
C_FIXDIV( fnkc , 2 );
|
|
142
|
+
|
|
143
|
+
C_ADD (fek, fk, fnkc);
|
|
144
|
+
C_SUB (tmp, fk, fnkc);
|
|
145
|
+
C_MUL (fok, tmp, st->super_twiddles[k-1]);
|
|
146
|
+
C_ADD (st->tmpbuf[k], fek, fok);
|
|
147
|
+
C_SUB (st->tmpbuf[ncfft - k], fek, fok);
|
|
148
|
+
#ifdef USE_SIMD
|
|
149
|
+
st->tmpbuf[ncfft - k].i *= _mm_set1_ps(-1.0);
|
|
150
|
+
#else
|
|
151
|
+
st->tmpbuf[ncfft - k].i *= -1;
|
|
152
|
+
#endif
|
|
153
|
+
}
|
|
154
|
+
kiss_fft (st->substate, st->tmpbuf, (kiss_fft_cpx *) timedata);
|
|
155
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2003-2004, Mark Borgerding. All rights reserved.
|
|
3
|
+
* This file is part of KISS FFT - https://github.com/mborgerding/kissfft
|
|
4
|
+
*
|
|
5
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
6
|
+
* See COPYING file for more information.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#ifndef KISS_FTR_H
|
|
10
|
+
#define KISS_FTR_H
|
|
11
|
+
|
|
12
|
+
#include "kiss_fft.h"
|
|
13
|
+
#ifdef __cplusplus
|
|
14
|
+
extern "C" {
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
|
|
20
|
+
Real optimized version can save about 45% cpu time vs. complex fft of a real seq.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
typedef struct kiss_fftr_state *kiss_fftr_cfg;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
kiss_fftr_cfg KISS_FFT_API kiss_fftr_alloc(int nfft,int inverse_fft,void * mem, size_t * lenmem);
|
|
30
|
+
/*
|
|
31
|
+
nfft must be even
|
|
32
|
+
|
|
33
|
+
If you don't care to allocate space, use mem = lenmem = NULL
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
void KISS_FFT_API kiss_fftr(kiss_fftr_cfg cfg,const kiss_fft_scalar *timedata,kiss_fft_cpx *freqdata);
|
|
38
|
+
/*
|
|
39
|
+
input timedata has nfft scalar points
|
|
40
|
+
output freqdata has nfft/2+1 complex points
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
void KISS_FFT_API kiss_fftri(kiss_fftr_cfg cfg,const kiss_fft_cpx *freqdata,kiss_fft_scalar *timedata);
|
|
44
|
+
/*
|
|
45
|
+
input freqdata has nfft/2+1 complex points
|
|
46
|
+
output timedata has nfft scalar points
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
#define kiss_fftr_free KISS_FFT_FREE
|
|
50
|
+
|
|
51
|
+
#ifdef __cplusplus
|
|
52
|
+
}
|
|
53
|
+
#endif
|
|
54
|
+
#endif
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AudioAnalysisData.swift
|
|
3
|
+
// AudioStudio
|
|
4
|
+
//
|
|
5
|
+
// Created by Arthur Breton on 23/6/2024.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
public struct AudioAnalysisData {
|
|
11
|
+
public let segmentDurationMs: Int
|
|
12
|
+
public let durationMs: Int
|
|
13
|
+
public let bitDepth: Int
|
|
14
|
+
public let numberOfChannels: Int
|
|
15
|
+
public let sampleRate: Int
|
|
16
|
+
public let samples: Int
|
|
17
|
+
public let dataPoints: [DataPoint]
|
|
18
|
+
public let amplitudeRange: AmplitudeRange
|
|
19
|
+
public let rmsRange: AmplitudeRange
|
|
20
|
+
public let speechAnalysis: SpeechAnalysis?
|
|
21
|
+
public let extractionTimeMs: Float
|
|
22
|
+
|
|
23
|
+
public struct AmplitudeRange {
|
|
24
|
+
public let min: Float
|
|
25
|
+
public let max: Float
|
|
26
|
+
|
|
27
|
+
func toDictionary() -> [String: Float] {
|
|
28
|
+
return [
|
|
29
|
+
"min": min,
|
|
30
|
+
"max": max
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public struct SpeechAnalysis {
|
|
36
|
+
public let speakerChanges: [SpeakerChange]
|
|
37
|
+
|
|
38
|
+
func toDictionary() -> [String: Any] {
|
|
39
|
+
return [
|
|
40
|
+
"speakerChanges": speakerChanges.map { $0.toDictionary() }
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public struct SpeakerChange {
|
|
46
|
+
public let timestamp: Int64
|
|
47
|
+
public let speakerId: Int
|
|
48
|
+
|
|
49
|
+
func toDictionary() -> [String: Any] {
|
|
50
|
+
return [
|
|
51
|
+
"timestamp": timestamp,
|
|
52
|
+
"speakerId": speakerId
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
extension AudioAnalysisData {
|
|
59
|
+
func toDictionary() -> [String: Any?] {
|
|
60
|
+
return [
|
|
61
|
+
"segmentDurationMs": segmentDurationMs,
|
|
62
|
+
"durationMs": durationMs,
|
|
63
|
+
"bitDepth": bitDepth,
|
|
64
|
+
"numberOfChannels": numberOfChannels,
|
|
65
|
+
"sampleRate": sampleRate,
|
|
66
|
+
"samples": samples,
|
|
67
|
+
"dataPoints": dataPoints.map { $0.toDictionary() },
|
|
68
|
+
"amplitudeRange": amplitudeRange.toDictionary(),
|
|
69
|
+
"rmsRange": rmsRange.toDictionary(),
|
|
70
|
+
"speechAnalysis": speechAnalysis?.toDictionary(),
|
|
71
|
+
"extractionTimeMs": extractionTimeMs
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
}
|