react-native-audio-api 0.11.0-alpha.0 → 0.11.0-nightly-bfab178-20251107
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 -11
- package/RNAudioAPI.podspec +20 -15
- package/android/build.gradle +33 -3
- package/android/src/main/cpp/audioapi/CMakeLists.txt +6 -3
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.cpp +5 -0
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.h +1 -0
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +30 -94
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +14 -28
- package/android/src/main/cpp/audioapi/android/core/AudioPlayer.cpp +4 -2
- package/android/src/main/cpp/audioapi/android/core/NativeAudioRecorder.hpp +9 -9
- package/android/src/main/cpp/audioapi/android/core/utils/AudioDecoder.cpp +6 -0
- package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +31 -3
- package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +21 -9
- package/android/src/main/java/com/swmansion/audioapi/system/LockScreenManager.kt +27 -6
- package/android/src/main/java/com/swmansion/audioapi/system/MediaNotificationManager.kt +11 -0
- package/android/src/oldarch/NativeAudioAPIModuleSpec.java +4 -0
- package/common/cpp/audioapi/AudioAPIModuleInstaller.h +30 -2
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +18 -0
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +1 -0
- package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.cpp +1 -1
- package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.cpp +47 -0
- package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.h +20 -0
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +18 -80
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.h +6 -15
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferBaseSourceNodeHostObject.cpp +1 -1
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferSourceNodeHostObject.cpp +1 -1
- package/common/cpp/audioapi/HostObjects/sources/AudioScheduledSourceNodeHostObject.cpp +1 -1
- package/common/cpp/audioapi/core/AudioNode.h +3 -2
- package/common/cpp/audioapi/core/AudioParam.cpp +2 -2
- package/common/cpp/audioapi/core/BaseAudioContext.cpp +10 -0
- package/common/cpp/audioapi/core/BaseAudioContext.h +2 -0
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +69 -32
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +37 -1
- package/common/cpp/audioapi/core/effects/ConvolverNode.cpp +210 -0
- package/common/cpp/audioapi/core/effects/ConvolverNode.h +55 -0
- package/common/cpp/audioapi/core/inputs/AudioRecorder.cpp +49 -102
- package/common/cpp/audioapi/core/inputs/AudioRecorder.h +28 -46
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.cpp +14 -17
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.h +0 -1
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp +8 -14
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.h +0 -1
- package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.cpp +14 -18
- package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.h +2 -2
- package/common/cpp/audioapi/core/sources/StreamerNode.cpp +64 -64
- package/common/cpp/audioapi/core/sources/StreamerNode.h +38 -10
- package/common/cpp/audioapi/core/utils/AudioNodeManager.cpp +5 -0
- package/common/cpp/audioapi/core/utils/Constants.h +2 -1
- package/common/cpp/audioapi/core/utils/worklets/SafeIncludes.h +12 -8
- package/common/cpp/audioapi/core/utils/worklets/WorkletsRunner.cpp +3 -3
- package/common/cpp/audioapi/core/utils/worklets/WorkletsRunner.h +1 -1
- package/common/cpp/audioapi/dsp/AudioUtils.cpp +1 -1
- package/common/cpp/audioapi/dsp/Convolver.cpp +213 -0
- package/common/cpp/audioapi/dsp/Convolver.h +45 -0
- package/common/cpp/audioapi/dsp/FFT.cpp +0 -26
- package/common/cpp/audioapi/dsp/FFT.h +26 -2
- package/common/cpp/audioapi/events/AudioEventHandlerRegistry.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/avcodec.h +4 -4
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_desc.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_id.h +3 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_par.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/defs.h +3 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/packet.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/smpte_436m.h +254 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/version.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavformat/avformat.h +6 -6
- package/common/cpp/audioapi/external/ffmpeg_include/libavformat/version.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavformat/version_major.h +2 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avassert.h +5 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avutil.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/channel_layout.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/csp.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/dict.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/ffversion.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/film_grain_params.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/frame.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hdr_dynamic_vivid_metadata.h +3 -3
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_opencl.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_qsv.h +0 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/hwcontext_vulkan.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/iamf.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/lfg.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/log.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/mathematics.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/opt.h +4 -4
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/rational.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/rc4.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/refstruct.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/spherical.h +6 -0
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/tdrdi.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/tx.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/version.h +3 -3
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/video_hint.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libswresample/swresample.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libswresample/version.h +1 -1
- package/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.cpp +2 -3
- package/common/cpp/audioapi/libs/ffmpeg/relinking.md +24 -0
- package/common/cpp/audioapi/utils/AlignedAllocator.hpp +50 -0
- package/common/cpp/audioapi/utils/AudioBus.cpp +28 -0
- package/common/cpp/audioapi/utils/AudioBus.h +3 -0
- package/common/cpp/audioapi/utils/ThreadPool.hpp +59 -1
- package/common/cpp/test/CMakeLists.txt +19 -14
- package/common/cpp/test/src/AudioParamTest.cpp +1 -1
- package/common/cpp/test/src/AudioScheduledSourceTest.cpp +134 -0
- package/common/cpp/test/src/ConstantSourceTest.cpp +1 -1
- package/common/cpp/test/src/GainTest.cpp +1 -1
- package/common/cpp/test/src/MockAudioEventHandlerRegistry.h +4 -4
- package/common/cpp/test/src/OscillatorTest.cpp +1 -1
- package/common/cpp/test/src/StereoPannerTest.cpp +1 -1
- package/common/cpp/test/src/biquad/BiquadFilterChromium.cpp +389 -0
- package/common/cpp/test/src/biquad/BiquadFilterChromium.h +64 -0
- package/common/cpp/test/src/biquad/BiquadFilterTest.cpp +284 -0
- package/common/cpp/test/src/biquad/BiquadFilterTest.h +40 -0
- package/ios/audioapi/ios/AudioAPIModule.h +2 -1
- package/ios/audioapi/ios/AudioAPIModule.mm +13 -0
- package/ios/audioapi/ios/core/IOSAudioRecorder.h +9 -18
- package/ios/audioapi/ios/core/IOSAudioRecorder.mm +28 -70
- package/ios/audioapi/ios/core/NativeAudioRecorder.h +6 -2
- package/ios/audioapi/ios/core/NativeAudioRecorder.m +73 -5
- package/ios/audioapi/ios/system/AudioEngine.mm +3 -3
- package/ios/audioapi/ios/system/AudioSessionManager.h +2 -0
- package/ios/audioapi/ios/system/AudioSessionManager.mm +24 -0
- package/ios/audioapi/ios/system/LockScreenManager.h +0 -1
- package/ios/audioapi/ios/system/LockScreenManager.mm +6 -19
- package/lib/commonjs/api.js +141 -76
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/api.web.js +8 -0
- package/lib/commonjs/api.web.js.map +1 -1
- package/lib/commonjs/core/AudioContext.js +1 -1
- package/lib/commonjs/core/AudioContext.js.map +1 -1
- package/lib/commonjs/core/AudioRecorder.js +12 -157
- package/lib/commonjs/core/AudioRecorder.js.map +1 -1
- package/lib/commonjs/core/BaseAudioContext.js +28 -25
- package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
- package/lib/commonjs/core/ConvolverNode.js +37 -0
- package/lib/commonjs/core/ConvolverNode.js.map +1 -0
- package/lib/commonjs/core/OfflineAudioContext.js +1 -1
- package/lib/commonjs/core/OfflineAudioContext.js.map +1 -1
- package/lib/commonjs/specs/NativeAudioAPIModule.js.map +1 -1
- package/lib/commonjs/system/AudioManager.js +3 -0
- package/lib/commonjs/system/AudioManager.js.map +1 -1
- package/lib/commonjs/types.js +0 -46
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/index.js +19 -21
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/web-core/AudioContext.js +12 -0
- package/lib/commonjs/web-core/AudioContext.js.map +1 -1
- package/lib/commonjs/web-core/ConvolverNode.js +40 -0
- package/lib/commonjs/web-core/ConvolverNode.js.map +1 -0
- package/lib/commonjs/web-core/ConvolverNodeOptions.js +6 -0
- package/lib/commonjs/web-core/ConvolverNodeOptions.js.map +1 -0
- package/lib/commonjs/web-core/OfflineAudioContext.js +12 -0
- package/lib/commonjs/web-core/OfflineAudioContext.js.map +1 -1
- package/lib/module/api.js +16 -15
- package/lib/module/api.js.map +1 -1
- package/lib/module/api.web.js +1 -0
- package/lib/module/api.web.js.map +1 -1
- package/lib/module/core/AudioContext.js +2 -2
- package/lib/module/core/AudioContext.js.map +1 -1
- package/lib/module/core/AudioRecorder.js +12 -157
- package/lib/module/core/AudioRecorder.js.map +1 -1
- package/lib/module/core/BaseAudioContext.js +29 -26
- package/lib/module/core/BaseAudioContext.js.map +1 -1
- package/lib/module/core/ConvolverNode.js +31 -0
- package/lib/module/core/ConvolverNode.js.map +1 -0
- package/lib/module/core/OfflineAudioContext.js +2 -2
- package/lib/module/core/OfflineAudioContext.js.map +1 -1
- package/lib/module/specs/NativeAudioAPIModule.js.map +1 -1
- package/lib/module/system/AudioManager.js +3 -0
- package/lib/module/system/AudioManager.js.map +1 -1
- package/lib/module/types.js +1 -45
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/index.js +15 -2
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/web-core/AudioContext.js +12 -0
- package/lib/module/web-core/AudioContext.js.map +1 -1
- package/lib/module/web-core/ConvolverNode.js +34 -0
- package/lib/module/web-core/ConvolverNode.js.map +1 -0
- package/lib/module/web-core/ConvolverNodeOptions.js +4 -0
- package/lib/module/web-core/ConvolverNodeOptions.js.map +1 -0
- package/lib/module/web-core/OfflineAudioContext.js +12 -0
- package/lib/module/web-core/OfflineAudioContext.js.map +1 -1
- package/lib/typescript/api.d.ts +19 -17
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/api.web.d.ts +1 -0
- package/lib/typescript/api.web.d.ts.map +1 -1
- package/lib/typescript/core/AudioContext.d.ts.map +1 -1
- package/lib/typescript/core/AudioRecorder.d.ts +6 -58
- package/lib/typescript/core/AudioRecorder.d.ts.map +1 -1
- package/lib/typescript/core/BaseAudioContext.d.ts +3 -1
- package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/core/ConvolverNode.d.ts +12 -0
- package/lib/typescript/core/ConvolverNode.d.ts.map +1 -0
- package/lib/typescript/events/types.d.ts +0 -16
- package/lib/typescript/events/types.d.ts.map +1 -1
- package/lib/typescript/interfaces.d.ts +8 -39
- package/lib/typescript/interfaces.d.ts.map +1 -1
- package/lib/typescript/specs/NativeAudioAPIModule.d.ts +1 -0
- package/lib/typescript/specs/NativeAudioAPIModule.d.ts.map +1 -1
- package/lib/typescript/system/AudioManager.d.ts +1 -0
- package/lib/typescript/system/AudioManager.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +8 -74
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/utils/index.d.ts +5 -2
- package/lib/typescript/utils/index.d.ts.map +1 -1
- package/lib/typescript/web-core/AudioContext.d.ts +3 -0
- package/lib/typescript/web-core/AudioContext.d.ts.map +1 -1
- package/lib/typescript/web-core/BaseAudioContext.d.ts +2 -0
- package/lib/typescript/web-core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/web-core/ConvolverNode.d.ts +11 -0
- package/lib/typescript/web-core/ConvolverNode.d.ts.map +1 -0
- package/lib/typescript/web-core/ConvolverNodeOptions.d.ts +6 -0
- package/lib/typescript/web-core/ConvolverNodeOptions.d.ts.map +1 -0
- package/lib/typescript/web-core/OfflineAudioContext.d.ts +3 -0
- package/lib/typescript/web-core/OfflineAudioContext.d.ts.map +1 -1
- package/package.json +14 -5
- package/scripts/download-prebuilt-binaries.sh +61 -0
- package/scripts/rnaa_utils.rb +8 -0
- package/scripts/validate-worklets-version.js +28 -0
- package/src/api.ts +45 -18
- package/src/api.web.ts +1 -0
- package/src/core/AudioContext.ts +3 -2
- package/src/core/AudioRecorder.ts +20 -190
- package/src/core/BaseAudioContext.ts +67 -60
- package/src/core/ConvolverNode.ts +35 -0
- package/src/core/OfflineAudioContext.ts +2 -2
- package/src/events/types.ts +0 -18
- package/src/interfaces.ts +15 -47
- package/src/specs/NativeAudioAPIModule.ts +1 -0
- package/src/system/AudioManager.ts +4 -0
- package/src/types.ts +9 -84
- package/src/utils/index.ts +22 -2
- package/src/web-core/AudioContext.tsx +25 -0
- package/src/web-core/BaseAudioContext.tsx +2 -0
- package/src/web-core/ConvolverNode.tsx +43 -0
- package/src/web-core/ConvolverNodeOptions.tsx +6 -0
- package/src/web-core/OfflineAudioContext.tsx +25 -0
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidFileWriterBackend.h +0 -33
- package/android/src/main/cpp/audioapi/android/core/utils/FileUtils.h +0 -34
- package/android/src/main/cpp/audioapi/android/core/utils/FileUtilts.cpp +0 -133
- package/android/src/main/cpp/audioapi/android/core/utils/MiniaudioImplementation.cpp +0 -3
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.cpp +0 -154
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.h +0 -41
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.cpp +0 -431
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h +0 -112
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.cpp +0 -47
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.h +0 -28
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.cpp +0 -237
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h +0 -46
- package/android/src/main/cpp/audioapi/android/system/NativeFileInfo.hpp +0 -31
- package/android/src/main/java/com/swmansion/audioapi/system/NativeFileInfo.kt +0 -18
- package/android/src/main/jniLibs/arm64-v8a/libavcodec.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libavformat.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libavutil.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libswresample.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libavcodec.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libavformat.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libavutil.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libswresample.so +0 -0
- package/android/src/main/jniLibs/x86/libavcodec.so +0 -0
- package/android/src/main/jniLibs/x86/libavformat.so +0 -0
- package/android/src/main/jniLibs/x86/libavutil.so +0 -0
- package/android/src/main/jniLibs/x86/libswresample.so +0 -0
- package/android/src/main/jniLibs/x86_64/libavcodec.so +0 -0
- package/android/src/main/jniLibs/x86_64/libavformat.so +0 -0
- package/android/src/main/jniLibs/x86_64/libavutil.so +0 -0
- package/android/src/main/jniLibs/x86_64/libswresample.so +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libogg.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libopus.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libssl.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libogg.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libopus.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libssl.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libogg.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libopus.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libssl.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libogg.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libopus.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libssl.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/libavcodec.xcframework/Info.plist +0 -44
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/Info.plist +0 -1
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/libavcodec +0 -0
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/Info.plist +0 -1
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/libavcodec +0 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/Info.plist +0 -44
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/Info.plist +0 -1
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/libavformat +0 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/Info.plist +0 -1
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/libavformat +0 -0
- package/common/cpp/audioapi/external/libavutil.xcframework/Info.plist +0 -44
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/Info.plist +0 -1
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/libavutil +0 -0
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/Info.plist +0 -1
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/libavutil +0 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/Info.plist +0 -44
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/Info.plist +0 -1
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/libswresample +0 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/Info.plist +0 -1
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/libswresample +0 -0
- package/common/cpp/audioapi/external/x86/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/x86/libogg.a +0 -0
- package/common/cpp/audioapi/external/x86/libopus.a +0 -0
- package/common/cpp/audioapi/external/x86/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/x86/libssl.a +0 -0
- package/common/cpp/audioapi/external/x86/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/x86/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/x86/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libcrypto.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libogg.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libopus.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libssl.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/libs/ffmpeg/INSTRUCTIONS.md +0 -32
- package/common/cpp/audioapi/libs/ffmpeg/create_xcframework.sh +0 -111
- package/common/cpp/audioapi/libs/ffmpeg/ffmpeg_setup.sh +0 -391
- package/ios/audioapi/ios/core/IOSAudioFileOptions.h +0 -35
- package/ios/audioapi/ios/core/IOSAudioFileOptions.mm +0 -135
- package/ios/audioapi/ios/core/IOSAudioFileWriter.h +0 -38
- package/ios/audioapi/ios/core/IOSAudioFileWriter.mm +0 -187
- package/lib/commonjs/utils/bitEnums.js +0 -33
- package/lib/commonjs/utils/bitEnums.js.map +0 -1
- package/lib/module/utils/bitEnums.js +0 -27
- package/lib/module/utils/bitEnums.js.map +0 -1
- package/lib/typescript/utils/bitEnums.d.ts +0 -4
- package/lib/typescript/utils/bitEnums.d.ts.map +0 -1
- package/src/utils/bitEnums.ts +0 -51
package/src/interfaces.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AudioEventCallback, AudioEventName } from './events/types';
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
3
|
BiquadFilterType,
|
|
4
4
|
ChannelCountMode,
|
|
5
5
|
ChannelInterpretation,
|
|
@@ -8,6 +8,8 @@ import type {
|
|
|
8
8
|
WindowType,
|
|
9
9
|
} from './types';
|
|
10
10
|
|
|
11
|
+
// IMPORTANT: use only IClass, because it is a part of contract between cpp host object and js layer
|
|
12
|
+
|
|
11
13
|
export type WorkletNodeCallback = (
|
|
12
14
|
audioData: Array<ArrayBuffer>,
|
|
13
15
|
channelCount: number
|
|
@@ -75,6 +77,10 @@ export interface IBaseAudioContext {
|
|
|
75
77
|
disableNormalization: boolean
|
|
76
78
|
) => IPeriodicWave;
|
|
77
79
|
createAnalyser: () => IAnalyserNode;
|
|
80
|
+
createConvolver: (
|
|
81
|
+
buffer: IAudioBuffer | undefined,
|
|
82
|
+
disableNormalization: boolean
|
|
83
|
+
) => IConvolverNode;
|
|
78
84
|
createStreamer: () => IStreamerNode;
|
|
79
85
|
}
|
|
80
86
|
|
|
@@ -184,6 +190,11 @@ export interface IAudioBufferQueueSourceNode
|
|
|
184
190
|
pause: () => void;
|
|
185
191
|
}
|
|
186
192
|
|
|
193
|
+
export interface IConvolverNode extends IAudioNode {
|
|
194
|
+
buffer: IAudioBuffer | null;
|
|
195
|
+
normalize: boolean;
|
|
196
|
+
}
|
|
197
|
+
|
|
187
198
|
export interface IAudioBuffer {
|
|
188
199
|
readonly length: number;
|
|
189
200
|
readonly duration: number;
|
|
@@ -250,57 +261,14 @@ export interface IWorkletSourceNode extends IAudioScheduledSourceNode {}
|
|
|
250
261
|
|
|
251
262
|
export interface IWorkletProcessingNode extends IAudioNode {}
|
|
252
263
|
|
|
253
|
-
type IOSAudioRecorderFileDescriptor = number;
|
|
254
|
-
type AndroidAudioRecorderFileDescriptor = number;
|
|
255
|
-
|
|
256
|
-
interface IAudioRecorderFileOptions {
|
|
257
|
-
sampleRate: number;
|
|
258
|
-
channels: number;
|
|
259
|
-
bitRate: number;
|
|
260
|
-
/**
|
|
261
|
-
* IOS specific file recording options
|
|
262
|
-
*
|
|
263
|
-
* - `format` - IOSFormat, bitmask 0 x 0000000F
|
|
264
|
-
* - `quality` - IOSAudioQuality, bitmask 0 x 000000F0
|
|
265
|
-
* - `flacCompressionLevel` - FlacCompressionLevel, bitmask 0 x 00000F00
|
|
266
|
-
* - `directory` - FileDirectory, bitmask 0 x 0000F000
|
|
267
|
-
* - `bitDepth` - BitDepth, bitmask 0 x 000F0000
|
|
268
|
-
*/
|
|
269
|
-
ios: IOSAudioRecorderFileDescriptor;
|
|
270
|
-
/**
|
|
271
|
-
* Android specific file recording options
|
|
272
|
-
*
|
|
273
|
-
* - He he
|
|
274
|
-
*/
|
|
275
|
-
android: AndroidAudioRecorderFileDescriptor;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
interface IAudioRecorderCallbackOptions {
|
|
279
|
-
sampleRate: number;
|
|
280
|
-
bufferLength: number;
|
|
281
|
-
channelCount: number;
|
|
282
|
-
callbackId: string;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
264
|
export interface IAudioRecorder {
|
|
286
|
-
// default recorder methods
|
|
287
265
|
start: () => void;
|
|
288
|
-
stop: () =>
|
|
289
|
-
isRecording: () => boolean;
|
|
290
|
-
|
|
291
|
-
enableFileOutput: (options: IAudioRecorderFileOptions) => void;
|
|
292
|
-
disableFileOutput: () => void;
|
|
293
|
-
|
|
294
|
-
// pause and resume methods for file recording
|
|
295
|
-
pause: () => void;
|
|
296
|
-
resume: () => void;
|
|
297
|
-
|
|
298
|
-
// Graph integration methods
|
|
266
|
+
stop: () => void;
|
|
299
267
|
connect: (node: IRecorderAdapterNode) => void;
|
|
300
268
|
disconnect: () => void;
|
|
301
269
|
|
|
302
|
-
|
|
303
|
-
|
|
270
|
+
// passing subscriptionId(uint_64 in cpp, string in js) to the cpp
|
|
271
|
+
onAudioReady: string;
|
|
304
272
|
}
|
|
305
273
|
|
|
306
274
|
export interface IAudioDecoder {
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import AudioBuffer from './core/AudioBuffer';
|
|
2
|
+
|
|
1
3
|
export type ChannelCountMode = 'max' | 'clamped-max' | 'explicit';
|
|
2
4
|
|
|
3
5
|
export type ChannelInterpretation = 'speakers' | 'discrete';
|
|
@@ -12,7 +14,7 @@ export type BiquadFilterType =
|
|
|
12
14
|
| 'notch'
|
|
13
15
|
| 'allpass';
|
|
14
16
|
|
|
15
|
-
export type ContextState = 'running' | 'closed' |
|
|
17
|
+
export type ContextState = 'running' | 'closed' | `suspended`;
|
|
16
18
|
|
|
17
19
|
export type AudioWorkletRuntime = 'AudioRuntime' | 'UIRuntime';
|
|
18
20
|
|
|
@@ -38,69 +40,9 @@ export interface OfflineAudioContextOptions {
|
|
|
38
40
|
sampleRate: number;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export enum IOSFormat {
|
|
47
|
-
Wav = 1,
|
|
48
|
-
Caf = 2,
|
|
49
|
-
M4A = 3,
|
|
50
|
-
Flac = 4,
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export enum IOSAudioQuality {
|
|
54
|
-
Min = 1,
|
|
55
|
-
Low = 2,
|
|
56
|
-
Medium = 3,
|
|
57
|
-
High = 4,
|
|
58
|
-
Max = 5,
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export enum AndroidFormat {
|
|
62
|
-
Wav = 1,
|
|
63
|
-
Caf = 2,
|
|
64
|
-
M4A = 3,
|
|
65
|
-
Flac = 4,
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export enum FlacCompressionLevel {
|
|
69
|
-
L0 = 1,
|
|
70
|
-
L1 = 2,
|
|
71
|
-
L2 = 3,
|
|
72
|
-
L3 = 4,
|
|
73
|
-
L4 = 5,
|
|
74
|
-
L5 = 6,
|
|
75
|
-
L6 = 7,
|
|
76
|
-
L7 = 8,
|
|
77
|
-
L8 = 9,
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export enum BitDepth {
|
|
81
|
-
Bit16 = 1,
|
|
82
|
-
Bit24 = 2,
|
|
83
|
-
Bit32 = 3,
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface AudioRecorderFileOptionsIOS {
|
|
87
|
-
format?: IOSFormat;
|
|
88
|
-
quality?: IOSAudioQuality;
|
|
89
|
-
flacCompressionLevel?: FlacCompressionLevel;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export interface AudioRecorderFileOptionsAndroid {
|
|
93
|
-
format?: AndroidFormat;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export interface AudioRecorderFileOptions {
|
|
97
|
-
directory?: FileDirectory;
|
|
98
|
-
sampleRate?: number;
|
|
99
|
-
channels?: number;
|
|
100
|
-
bitRate?: number;
|
|
101
|
-
bitDepth?: BitDepth;
|
|
102
|
-
ios?: AudioRecorderFileOptionsIOS;
|
|
103
|
-
android?: AudioRecorderFileOptionsAndroid;
|
|
43
|
+
export interface AudioRecorderOptions {
|
|
44
|
+
sampleRate: number;
|
|
45
|
+
bufferLengthInSamples: number;
|
|
104
46
|
}
|
|
105
47
|
|
|
106
48
|
export type WindowType = 'blackman' | 'hann';
|
|
@@ -111,24 +53,7 @@ export interface AudioBufferBaseSourceNodeOptions {
|
|
|
111
53
|
|
|
112
54
|
export type ProcessorMode = 'processInPlace' | 'processThrough';
|
|
113
55
|
|
|
114
|
-
export interface
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
* recording callback. Common values include 44100 or 48000 Hz. The actual
|
|
118
|
-
* sample rate may differ depending on hardware and system capabilities.
|
|
119
|
-
*/
|
|
120
|
-
sampleRate: number;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* The preferred size of each audio buffer, expressed as the number of samples
|
|
124
|
-
* per channel. Smaller buffers reduce latency but increase CPU load, while
|
|
125
|
-
* larger buffers improve efficiency at the cost of higher latency.
|
|
126
|
-
*/
|
|
127
|
-
bufferLength: number;
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* The desired number of audio channels per buffer. Typically 1 for mono or 2
|
|
131
|
-
* for stereo recordings.
|
|
132
|
-
*/
|
|
133
|
-
channelCount: number;
|
|
56
|
+
export interface ConvolverNodeOptions {
|
|
57
|
+
buffer?: AudioBuffer | null;
|
|
58
|
+
disableNormalization?: boolean;
|
|
134
59
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ShareableWorkletCallback } from '../interfaces';
|
|
2
|
-
export * from './bitEnums';
|
|
3
2
|
|
|
4
3
|
interface SimplifiedWorkletModule {
|
|
5
4
|
makeShareableCloneRecursive: (
|
|
@@ -14,12 +13,33 @@ export function clamp(value: number, min: number, max: number): number {
|
|
|
14
13
|
return Math.min(Math.max(value, min), max);
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
let isWorkletsAvailable = false;
|
|
17
|
+
export let isWorkletsVersionSupported = false;
|
|
18
|
+
export let workletsVersion = 'unknown';
|
|
19
|
+
export const supportedWorkletsVersions = ['0.6.0', '0.6.1'];
|
|
18
20
|
export let workletsModule: SimplifiedWorkletModule;
|
|
19
21
|
|
|
22
|
+
export function assertWorkletsEnabled() {
|
|
23
|
+
if (!isWorkletsAvailable) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
'[react-native-audio-api]: Worklets are not available. Please install react-native-worklets to use this feature.'
|
|
26
|
+
);
|
|
27
|
+
} else if (!isWorkletsVersionSupported) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`[react-native-audio-api]: Worklets version ${workletsVersion} is not supported.
|
|
30
|
+
Please install react-native-worklets of one of the following versions: [${supportedWorkletsVersions.join(', ')}] to use this feature.`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
20
35
|
try {
|
|
21
36
|
workletsModule = require('react-native-worklets');
|
|
37
|
+
const workletsModuleJson = require('react-native-worklets/package.json');
|
|
38
|
+
isWorkletsVersionSupported = supportedWorkletsVersions.includes(
|
|
39
|
+
workletsModuleJson.version
|
|
40
|
+
);
|
|
22
41
|
isWorkletsAvailable = true;
|
|
42
|
+
workletsVersion = workletsModuleJson.version;
|
|
23
43
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
24
44
|
} catch (error) {
|
|
25
45
|
isWorkletsAvailable = false;
|
|
@@ -15,6 +15,8 @@ import GainNode from './GainNode';
|
|
|
15
15
|
import OscillatorNode from './OscillatorNode';
|
|
16
16
|
import PeriodicWave from './PeriodicWave';
|
|
17
17
|
import StereoPannerNode from './StereoPannerNode';
|
|
18
|
+
import ConvolverNode from './ConvolverNode';
|
|
19
|
+
import { ConvolverNodeOptions } from './ConvolverNodeOptions';
|
|
18
20
|
|
|
19
21
|
import { globalWasmPromise, globalTag } from './custom/LoadCustomWasm';
|
|
20
22
|
import ConstantSourceNode from './ConstantSourceNode';
|
|
@@ -70,6 +72,29 @@ export default class AudioContext implements BaseAudioContext {
|
|
|
70
72
|
return new BiquadFilterNode(this, this.context.createBiquadFilter());
|
|
71
73
|
}
|
|
72
74
|
|
|
75
|
+
createConvolver(options?: ConvolverNodeOptions): ConvolverNode {
|
|
76
|
+
if (options?.buffer) {
|
|
77
|
+
const numberOfChannels = options.buffer.numberOfChannels;
|
|
78
|
+
if (
|
|
79
|
+
numberOfChannels !== 1 &&
|
|
80
|
+
numberOfChannels !== 2 &&
|
|
81
|
+
numberOfChannels !== 4
|
|
82
|
+
) {
|
|
83
|
+
throw new NotSupportedError(
|
|
84
|
+
`The number of channels provided (${numberOfChannels}) in impulse response for ConvolverNode buffer must be 1 or 2 or 4.`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const buffer = options?.buffer ?? null;
|
|
89
|
+
const disableNormalization = options?.disableNormalization ?? false;
|
|
90
|
+
return new ConvolverNode(
|
|
91
|
+
this,
|
|
92
|
+
this.context.createConvolver(),
|
|
93
|
+
buffer,
|
|
94
|
+
disableNormalization
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
73
98
|
async createBufferSource(
|
|
74
99
|
options?: AudioBufferBaseSourceNodeOptions
|
|
75
100
|
): Promise<AudioBufferSourceNode> {
|
|
@@ -9,6 +9,7 @@ import OscillatorNode from './OscillatorNode';
|
|
|
9
9
|
import PeriodicWave from './PeriodicWave';
|
|
10
10
|
import StereoPannerNode from './StereoPannerNode';
|
|
11
11
|
import ConstantSourceNode from './ConstantSourceNode';
|
|
12
|
+
import ConvolverNode from './ConvolverNode';
|
|
12
13
|
|
|
13
14
|
export default interface BaseAudioContext {
|
|
14
15
|
readonly context: globalThis.BaseAudioContext;
|
|
@@ -23,6 +24,7 @@ export default interface BaseAudioContext {
|
|
|
23
24
|
createGain(): GainNode;
|
|
24
25
|
createStereoPanner(): StereoPannerNode;
|
|
25
26
|
createBiquadFilter(): BiquadFilterNode;
|
|
27
|
+
createConvolver(): ConvolverNode;
|
|
26
28
|
createBufferSource(): Promise<AudioBufferSourceNode>;
|
|
27
29
|
createBuffer(
|
|
28
30
|
numOfChannels: number,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import BaseAudioContext from './BaseAudioContext';
|
|
2
|
+
import AudioNode from './AudioNode';
|
|
3
|
+
import AudioBuffer from './AudioBuffer';
|
|
4
|
+
|
|
5
|
+
export default class ConvolverNode extends AudioNode {
|
|
6
|
+
constructor(
|
|
7
|
+
context: BaseAudioContext,
|
|
8
|
+
node: globalThis.ConvolverNode,
|
|
9
|
+
buffer: AudioBuffer | null = null,
|
|
10
|
+
disableNormalization: boolean = false
|
|
11
|
+
) {
|
|
12
|
+
super(context, node);
|
|
13
|
+
|
|
14
|
+
(this.node as globalThis.ConvolverNode).normalize = !disableNormalization;
|
|
15
|
+
if (buffer) {
|
|
16
|
+
(this.node as globalThis.ConvolverNode).buffer = buffer.buffer;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public get buffer(): AudioBuffer | null {
|
|
21
|
+
const buffer = (this.node as globalThis.ConvolverNode).buffer;
|
|
22
|
+
if (!buffer) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return new AudioBuffer(buffer);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public set buffer(buffer: AudioBuffer | null) {
|
|
29
|
+
if (!buffer) {
|
|
30
|
+
(this.node as globalThis.ConvolverNode).buffer = null;
|
|
31
|
+
} else {
|
|
32
|
+
(this.node as globalThis.ConvolverNode).buffer = buffer.buffer;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public get normalize(): boolean {
|
|
37
|
+
return (this.node as globalThis.ConvolverNode).normalize;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public set normalize(value: boolean) {
|
|
41
|
+
(this.node as globalThis.ConvolverNode).normalize = value;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -18,6 +18,8 @@ import StereoPannerNode from './StereoPannerNode';
|
|
|
18
18
|
import ConstantSourceNode from './ConstantSourceNode';
|
|
19
19
|
|
|
20
20
|
import { globalWasmPromise, globalTag } from './custom/LoadCustomWasm';
|
|
21
|
+
import ConvolverNode from './ConvolverNode';
|
|
22
|
+
import { ConvolverNodeOptions } from './ConvolverNodeOptions';
|
|
21
23
|
|
|
22
24
|
export default class OfflineAudioContext implements BaseAudioContext {
|
|
23
25
|
readonly context: globalThis.OfflineAudioContext;
|
|
@@ -76,6 +78,29 @@ export default class OfflineAudioContext implements BaseAudioContext {
|
|
|
76
78
|
return new BiquadFilterNode(this, this.context.createBiquadFilter());
|
|
77
79
|
}
|
|
78
80
|
|
|
81
|
+
createConvolver(options?: ConvolverNodeOptions): ConvolverNode {
|
|
82
|
+
if (options?.buffer) {
|
|
83
|
+
const numberOfChannels = options.buffer.numberOfChannels;
|
|
84
|
+
if (
|
|
85
|
+
numberOfChannels !== 1 &&
|
|
86
|
+
numberOfChannels !== 2 &&
|
|
87
|
+
numberOfChannels !== 4
|
|
88
|
+
) {
|
|
89
|
+
throw new NotSupportedError(
|
|
90
|
+
`The number of channels provided (${numberOfChannels}) in impulse response for ConvolverNode buffer must be 1 or 2 or 4.`
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const buffer = options?.buffer ?? null;
|
|
95
|
+
const disableNormalization = options?.disableNormalization ?? false;
|
|
96
|
+
return new ConvolverNode(
|
|
97
|
+
this,
|
|
98
|
+
this.context.createConvolver(),
|
|
99
|
+
buffer,
|
|
100
|
+
disableNormalization
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
79
104
|
async createBufferSource(
|
|
80
105
|
options?: AudioBufferBaseSourceNodeOptions
|
|
81
106
|
): Promise<AudioBufferSourceNode> {
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <string>
|
|
4
|
-
#include <memory>
|
|
5
|
-
|
|
6
|
-
namespace audioapi {
|
|
7
|
-
|
|
8
|
-
class AndroidFileWriterBackend {
|
|
9
|
-
public:
|
|
10
|
-
AndroidFileWriterBackend(
|
|
11
|
-
float sampleRate,
|
|
12
|
-
size_t channelCount,
|
|
13
|
-
size_t bitRate,
|
|
14
|
-
size_t androidFlags) {}
|
|
15
|
-
|
|
16
|
-
virtual ~AndroidFileWriterBackend() = default;
|
|
17
|
-
|
|
18
|
-
virtual void openFile(int32_t streamSampleRate, int32_t streamChannelCount, int32_t streamMaxBufferSize) = 0;
|
|
19
|
-
virtual std::string closeFile() = 0;
|
|
20
|
-
|
|
21
|
-
virtual bool writeAudioData(void *data, int numFrames) = 0;
|
|
22
|
-
|
|
23
|
-
std::string getFilePath() const { return filePath_; }
|
|
24
|
-
|
|
25
|
-
protected:
|
|
26
|
-
std::string filePath_{""};
|
|
27
|
-
|
|
28
|
-
int32_t streamSampleRate_{0};
|
|
29
|
-
int32_t streamChannelCount_{0};
|
|
30
|
-
int32_t streamMaxBufferSize_{0};
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
} // namespace audioapi
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <string>
|
|
4
|
-
|
|
5
|
-
namespace audioapi::android::fileutils {
|
|
6
|
-
|
|
7
|
-
enum class FileDirectory {
|
|
8
|
-
FILES_DIR,
|
|
9
|
-
CACHE_DIR,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
enum class FileFormat {
|
|
13
|
-
WAV,
|
|
14
|
-
CAF,
|
|
15
|
-
M4A,
|
|
16
|
-
FLAC,
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
enum class BitDepth {
|
|
20
|
-
BIT_16,
|
|
21
|
-
BIT_24,
|
|
22
|
-
BIT_32,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
bool createDirectoryIfNotExists(const std::string &directoryPath);
|
|
26
|
-
std::string getTimestampString();
|
|
27
|
-
std::string getISODateString();
|
|
28
|
-
FileFormat formatFromFlags(size_t flags);
|
|
29
|
-
FileDirectory directoryFromFlags(size_t flags);
|
|
30
|
-
BitDepth bitDepthFromFlags(size_t flags);
|
|
31
|
-
std::string getDirectory(FileDirectory dir);
|
|
32
|
-
std::string getFilePath(const FileDirectory &directory, const std::string &baseFileName, const std::string &extension);
|
|
33
|
-
|
|
34
|
-
} // namespace audioapi::android::fileutils
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
#include <android/log.h>
|
|
3
|
-
#include <audioapi/android/core/utils/FileUtils.h>
|
|
4
|
-
#include <audioapi/android/system/NativeFileInfo.hpp>
|
|
5
|
-
#include <chrono>
|
|
6
|
-
#include <filesystem>
|
|
7
|
-
#include <format>
|
|
8
|
-
#include <iostream>
|
|
9
|
-
|
|
10
|
-
namespace audioapi::android::fileutils {
|
|
11
|
-
|
|
12
|
-
bool createDirectoryIfNotExists(const std::string &directoryPath) {
|
|
13
|
-
std::error_code ec;
|
|
14
|
-
|
|
15
|
-
if (!std::filesystem::exists(directoryPath, ec)) {
|
|
16
|
-
bool created = std::filesystem::create_directories(directoryPath, ec);
|
|
17
|
-
|
|
18
|
-
if (ec) {
|
|
19
|
-
__android_log_print(
|
|
20
|
-
ANDROID_LOG_ERROR,
|
|
21
|
-
"FileUtils",
|
|
22
|
-
"Error creating directory at path: %s, error: %s",
|
|
23
|
-
directoryPath.c_str(),
|
|
24
|
-
ec.message().c_str());
|
|
25
|
-
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return created;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (ec) {
|
|
33
|
-
__android_log_print(
|
|
34
|
-
ANDROID_LOG_ERROR,
|
|
35
|
-
"FileUtils",
|
|
36
|
-
"Error checking existence of directory at path: %s, error: %s",
|
|
37
|
-
directoryPath.c_str(),
|
|
38
|
-
ec.message().c_str());
|
|
39
|
-
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
std::string getTimestampString() {
|
|
47
|
-
auto tNow = std::chrono::system_clock::now();
|
|
48
|
-
return std::format(
|
|
49
|
-
"{:%Y%m%d_%H%M%S}", std::chrono::floor<std::chrono::seconds>(tNow));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
std::string getISODateString() {
|
|
53
|
-
auto tNow = std::chrono::system_clock::now();
|
|
54
|
-
return std::format(
|
|
55
|
-
"{:%Y-%m-%d}", std::chrono::floor<std::chrono::days>(tNow));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
FileFormat formatFromFlags(size_t flags) {
|
|
59
|
-
uint8_t formatFlag = static_cast<uint8_t>(flags & 0xF);
|
|
60
|
-
|
|
61
|
-
switch (formatFlag) {
|
|
62
|
-
case 1:
|
|
63
|
-
return FileFormat::WAV;
|
|
64
|
-
case 2:
|
|
65
|
-
return FileFormat::CAF;
|
|
66
|
-
case 3:
|
|
67
|
-
return FileFormat::M4A;
|
|
68
|
-
case 4:
|
|
69
|
-
return FileFormat::FLAC;
|
|
70
|
-
default:
|
|
71
|
-
return FileFormat::M4A;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
FileDirectory directoryFromFlags(size_t flags) {
|
|
76
|
-
uint8_t directoryFlag = static_cast<uint8_t>((flags >> 4) & 0xF);
|
|
77
|
-
|
|
78
|
-
switch (directoryFlag) {
|
|
79
|
-
case 1:
|
|
80
|
-
return FileDirectory::FILES_DIR;
|
|
81
|
-
case 2:
|
|
82
|
-
return FileDirectory::CACHE_DIR;
|
|
83
|
-
default:
|
|
84
|
-
return FileDirectory::CACHE_DIR;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
BitDepth bitDepthFromFlags(size_t flags) {
|
|
89
|
-
uint8_t bitDepthFlag = static_cast<uint8_t>((flags >> 8) & 0xF);
|
|
90
|
-
|
|
91
|
-
switch (bitDepthFlag) {
|
|
92
|
-
case 1:
|
|
93
|
-
return BitDepth::BIT_16;
|
|
94
|
-
case 2:
|
|
95
|
-
return BitDepth::BIT_24;
|
|
96
|
-
case 3:
|
|
97
|
-
return BitDepth::BIT_32;
|
|
98
|
-
default:
|
|
99
|
-
return BitDepth::BIT_32;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
std::string getDirectory(FileDirectory dir) {
|
|
104
|
-
switch (dir) {
|
|
105
|
-
case FileDirectory::FILES_DIR:
|
|
106
|
-
return NativeFileInfo::getFilesDir();
|
|
107
|
-
case FileDirectory::CACHE_DIR:
|
|
108
|
-
return NativeFileInfo::getCacheDir();
|
|
109
|
-
default:
|
|
110
|
-
return NativeFileInfo::getCacheDir();
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
std::string getFilePath(
|
|
115
|
-
const FileDirectory &directory,
|
|
116
|
-
const std::string &baseFileName,
|
|
117
|
-
const std::string &extension) {
|
|
118
|
-
std::string basePath = getDirectory(directory);
|
|
119
|
-
std::string subDirectory = getISODateString();
|
|
120
|
-
std::string fileTimestamp = getTimestampString();
|
|
121
|
-
|
|
122
|
-
std::string subDirectoryPath =
|
|
123
|
-
std::format("{}/AudioAPI/{}", basePath, subDirectory);
|
|
124
|
-
|
|
125
|
-
if (!createDirectoryIfNotExists(subDirectoryPath)) {
|
|
126
|
-
return "";
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return std::format(
|
|
130
|
-
"{}/{}_{}.{}", subDirectoryPath, baseFileName, fileTimestamp, extension);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
} // namespace audioapi::android::fileutils
|