react-native-audio-api 0.11.0-alpha.1 → 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 -142
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +13 -40
- 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 -97
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.h +6 -18
- 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 +82 -36
- package/common/cpp/audioapi/core/inputs/AudioRecorder.h +31 -52
- 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 +10 -28
- package/ios/audioapi/ios/core/IOSAudioRecorder.mm +30 -117
- package/ios/audioapi/ios/core/NativeAudioRecorder.h +9 -4
- package/ios/audioapi/ios/core/NativeAudioRecorder.m +71 -29
- package/ios/audioapi/ios/core/utils/AudioDecoder.mm +0 -1
- 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 +13 -171
- 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 +13 -171
- 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 +7 -62
- 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 +9 -42
- 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 -79
- 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 +24 -211
- 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 +16 -52
- package/src/specs/NativeAudioAPIModule.ts +1 -0
- package/src/system/AudioManager.ts +4 -0
- package/src/types.ts +9 -90
- 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 -37
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.cpp +0 -187
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.h +0 -57
- 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 -429
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h +0 -113
- 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 -269
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h +0 -47
- 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 -36
- package/ios/audioapi/ios/core/IOSAudioFileOptions.mm +0 -140
- package/ios/audioapi/ios/core/IOSAudioFileWriter.h +0 -51
- package/ios/audioapi/ios/core/IOSAudioFileWriter.mm +0 -223
- package/ios/audioapi/ios/core/IOSRecorderCallback.h +0 -57
- package/ios/audioapi/ios/core/IOSRecorderCallback.mm +0 -189
- 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,14 +1,15 @@
|
|
|
1
1
|
import { AudioEventCallback, AudioEventName } from './events/types';
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
3
|
BiquadFilterType,
|
|
4
4
|
ChannelCountMode,
|
|
5
5
|
ChannelInterpretation,
|
|
6
6
|
ContextState,
|
|
7
|
-
FileInfo,
|
|
8
7
|
OscillatorType,
|
|
9
8
|
WindowType,
|
|
10
9
|
} from './types';
|
|
11
10
|
|
|
11
|
+
// IMPORTANT: use only IClass, because it is a part of contract between cpp host object and js layer
|
|
12
|
+
|
|
12
13
|
export type WorkletNodeCallback = (
|
|
13
14
|
audioData: Array<ArrayBuffer>,
|
|
14
15
|
channelCount: number
|
|
@@ -76,6 +77,10 @@ export interface IBaseAudioContext {
|
|
|
76
77
|
disableNormalization: boolean
|
|
77
78
|
) => IPeriodicWave;
|
|
78
79
|
createAnalyser: () => IAnalyserNode;
|
|
80
|
+
createConvolver: (
|
|
81
|
+
buffer: IAudioBuffer | undefined,
|
|
82
|
+
disableNormalization: boolean
|
|
83
|
+
) => IConvolverNode;
|
|
79
84
|
createStreamer: () => IStreamerNode;
|
|
80
85
|
}
|
|
81
86
|
|
|
@@ -185,6 +190,11 @@ export interface IAudioBufferQueueSourceNode
|
|
|
185
190
|
pause: () => void;
|
|
186
191
|
}
|
|
187
192
|
|
|
193
|
+
export interface IConvolverNode extends IAudioNode {
|
|
194
|
+
buffer: IAudioBuffer | null;
|
|
195
|
+
normalize: boolean;
|
|
196
|
+
}
|
|
197
|
+
|
|
188
198
|
export interface IAudioBuffer {
|
|
189
199
|
readonly length: number;
|
|
190
200
|
readonly duration: number;
|
|
@@ -251,60 +261,14 @@ export interface IWorkletSourceNode extends IAudioScheduledSourceNode {}
|
|
|
251
261
|
|
|
252
262
|
export interface IWorkletProcessingNode extends IAudioNode {}
|
|
253
263
|
|
|
254
|
-
type IOSAudioRecorderFileDescriptor = number;
|
|
255
|
-
type AndroidAudioRecorderFileDescriptor = number;
|
|
256
|
-
|
|
257
|
-
interface IAudioRecorderFileOptions {
|
|
258
|
-
sampleRate: number;
|
|
259
|
-
channels: number;
|
|
260
|
-
bitRate: number;
|
|
261
|
-
/**
|
|
262
|
-
* IOS specific file recording options
|
|
263
|
-
*
|
|
264
|
-
* - `format` - IOSFormat, bitmask 0 x 0000000F
|
|
265
|
-
* - `quality` - IOSAudioQuality, bitmask 0 x 000000F0
|
|
266
|
-
* - `flacCompressionLevel` - FlacCompressionLevel, bitmask 0 x 00000F00
|
|
267
|
-
* - `directory` - FileDirectory, bitmask 0 x 0000F000
|
|
268
|
-
* - `bitDepth` - BitDepth, bitmask 0 x 000F0000
|
|
269
|
-
*/
|
|
270
|
-
ios: IOSAudioRecorderFileDescriptor;
|
|
271
|
-
/**
|
|
272
|
-
* Android specific file recording options
|
|
273
|
-
*
|
|
274
|
-
* - He he
|
|
275
|
-
*/
|
|
276
|
-
android: AndroidAudioRecorderFileDescriptor;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
interface IAudioRecorderCallbackOptions {
|
|
280
|
-
sampleRate: number;
|
|
281
|
-
bufferLength: number;
|
|
282
|
-
channelCount: number;
|
|
283
|
-
callbackId: string;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
264
|
export interface IAudioRecorder {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
stop: () => FileInfo;
|
|
290
|
-
isRecording: () => boolean;
|
|
291
|
-
isPaused: () => boolean;
|
|
292
|
-
|
|
293
|
-
enableFileOutput: (options: IAudioRecorderFileOptions) => void;
|
|
294
|
-
disableFileOutput: () => void;
|
|
295
|
-
|
|
296
|
-
// pause and resume methods for file recording
|
|
297
|
-
pause: () => void;
|
|
298
|
-
resume: () => void;
|
|
299
|
-
|
|
300
|
-
// Graph integration methods
|
|
265
|
+
start: () => void;
|
|
266
|
+
stop: () => void;
|
|
301
267
|
connect: (node: IRecorderAdapterNode) => void;
|
|
302
268
|
disconnect: () => void;
|
|
303
269
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
getCurrentDuration: () => number;
|
|
270
|
+
// passing subscriptionId(uint_64 in cpp, string in js) to the cpp
|
|
271
|
+
onAudioReady: string;
|
|
308
272
|
}
|
|
309
273
|
|
|
310
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,30 +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;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export interface FileInfo {
|
|
137
|
-
path: string;
|
|
138
|
-
size: number;
|
|
139
|
-
duration: number;
|
|
56
|
+
export interface ConvolverNodeOptions {
|
|
57
|
+
buffer?: AudioBuffer | null;
|
|
58
|
+
disableNormalization?: boolean;
|
|
140
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,37 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <tuple>
|
|
4
|
-
#include <string>
|
|
5
|
-
#include <memory>
|
|
6
|
-
|
|
7
|
-
namespace audioapi {
|
|
8
|
-
|
|
9
|
-
class AndroidFileWriterBackend {
|
|
10
|
-
public:
|
|
11
|
-
AndroidFileWriterBackend(
|
|
12
|
-
float sampleRate,
|
|
13
|
-
size_t channelCount,
|
|
14
|
-
size_t bitRate,
|
|
15
|
-
size_t androidFlags) {}
|
|
16
|
-
|
|
17
|
-
virtual ~AndroidFileWriterBackend() = default;
|
|
18
|
-
|
|
19
|
-
virtual std::string openFile(int32_t streamSampleRate, int32_t streamChannelCount, int32_t streamMaxBufferSize) = 0;
|
|
20
|
-
virtual std::tuple<double, double> closeFile() = 0;
|
|
21
|
-
|
|
22
|
-
virtual bool writeAudioData(void *data, int numFrames) = 0;
|
|
23
|
-
|
|
24
|
-
std::string getFilePath() const { return filePath_; }
|
|
25
|
-
|
|
26
|
-
double getCurrentDuration() const { return static_cast<double>(framesWritten_.load()) / streamSampleRate_; }
|
|
27
|
-
|
|
28
|
-
protected:
|
|
29
|
-
std::string filePath_{""};
|
|
30
|
-
std::atomic<size_t> framesWritten_{0};
|
|
31
|
-
|
|
32
|
-
int32_t streamSampleRate_{0};
|
|
33
|
-
int32_t streamChannelCount_{0};
|
|
34
|
-
int32_t streamMaxBufferSize_{0};
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
} // namespace audioapi
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
#include <android/log.h>
|
|
2
|
-
#include <audioapi/HostObjects/sources/AudioBufferHostObject.h>
|
|
3
|
-
#include <audioapi/android/core/utils/AndroidRecorderCallback.h>
|
|
4
|
-
#include <audioapi/events/AudioEventHandlerRegistry.h>
|
|
5
|
-
#include <audioapi/libs/miniaudio/miniaudio.h>
|
|
6
|
-
#include <audioapi/utils/AudioArray.h>
|
|
7
|
-
#include <audioapi/utils/AudioBus.h>
|
|
8
|
-
#include <audioapi/utils/CircularAudioArray.h>
|
|
9
|
-
|
|
10
|
-
#include <memory>
|
|
11
|
-
|
|
12
|
-
namespace audioapi {
|
|
13
|
-
|
|
14
|
-
AndroidRecorderCallback::AndroidRecorderCallback(
|
|
15
|
-
const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry,
|
|
16
|
-
float sampleRate,
|
|
17
|
-
size_t bufferLength,
|
|
18
|
-
size_t channelCount,
|
|
19
|
-
uint64_t callbackId)
|
|
20
|
-
: sampleRate_(sampleRate),
|
|
21
|
-
bufferLength_(bufferLength),
|
|
22
|
-
channelCount_(channelCount),
|
|
23
|
-
callbackId_(callbackId),
|
|
24
|
-
audioEventHandlerRegistry_(audioEventHandlerRegistry) {
|
|
25
|
-
ringBufferSize_ = std::max((int)bufferLength * 2, 8192);
|
|
26
|
-
circularBus_.resize(channelCount_);
|
|
27
|
-
|
|
28
|
-
for (size_t i = 0; i < channelCount_; ++i) {
|
|
29
|
-
auto busArray = std::make_shared<CircularAudioArray>(ringBufferSize_);
|
|
30
|
-
circularBus_[i] = busArray;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
AndroidRecorderCallback::~AndroidRecorderCallback() {
|
|
35
|
-
for (size_t i = 0; i < circularBus_.size(); ++i) {
|
|
36
|
-
circularBus_[i].reset();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
void AndroidRecorderCallback::prepare(
|
|
41
|
-
int32_t streamSampleRate,
|
|
42
|
-
int32_t streamChannelCount,
|
|
43
|
-
size_t maxInputBufferLength) {
|
|
44
|
-
ma_result result;
|
|
45
|
-
|
|
46
|
-
streamSampleRate_ = streamSampleRate;
|
|
47
|
-
streamChannelCount_ = streamChannelCount;
|
|
48
|
-
maxInputBufferLength_ = maxInputBufferLength;
|
|
49
|
-
|
|
50
|
-
ma_data_converter_config converterConfig = ma_data_converter_config_init(
|
|
51
|
-
ma_format_f32,
|
|
52
|
-
ma_format_f32,
|
|
53
|
-
streamChannelCount_,
|
|
54
|
-
channelCount_,
|
|
55
|
-
streamSampleRate_,
|
|
56
|
-
static_cast<int32_t>(sampleRate_));
|
|
57
|
-
|
|
58
|
-
converter_ = std::make_unique<ma_data_converter>();
|
|
59
|
-
result = ma_data_converter_init(&converterConfig, NULL, converter_.get());
|
|
60
|
-
|
|
61
|
-
if (result != MA_SUCCESS) {
|
|
62
|
-
__android_log_print(
|
|
63
|
-
ANDROID_LOG_ERROR,
|
|
64
|
-
"AndroidRecorderCallback",
|
|
65
|
-
"Failed to initialize miniaudio data converter");
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
ma_data_converter_get_expected_output_frame_count(
|
|
70
|
-
converter_.get(), maxInputBufferLength_, &processingBufferLength_);
|
|
71
|
-
|
|
72
|
-
processingBufferLength_ =
|
|
73
|
-
std::max(processingBufferLength_, (ma_uint64)maxInputBufferLength_);
|
|
74
|
-
|
|
75
|
-
deinterleavingArray_ = std::make_shared<AudioArray>(processingBufferLength_);
|
|
76
|
-
processingBuffer_ = ma_malloc(
|
|
77
|
-
processingBufferLength_ * channelCount_ *
|
|
78
|
-
ma_get_bytes_per_sample(ma_format_f32),
|
|
79
|
-
NULL);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
void AndroidRecorderCallback::cleanup() {
|
|
83
|
-
if (converter_ != nullptr) {
|
|
84
|
-
ma_data_converter_uninit(converter_.get(), NULL);
|
|
85
|
-
converter_.reset();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (processingBuffer_ != nullptr) {
|
|
89
|
-
ma_free(processingBuffer_, NULL);
|
|
90
|
-
processingBuffer_ = nullptr;
|
|
91
|
-
processingBufferLength_ = 0;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
for (size_t i = 0; i < circularBus_.size(); ++i) {
|
|
95
|
-
circularBus_[i].reset();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
void AndroidRecorderCallback::receiveAudioData(void *data, int numFrames) {
|
|
100
|
-
ma_uint64 inputFrameCount = numFrames;
|
|
101
|
-
ma_uint64 outputFrameCount = 0;
|
|
102
|
-
|
|
103
|
-
if ((float)streamSampleRate_ == sampleRate_ ||
|
|
104
|
-
streamChannelCount_ == channelCount_) {
|
|
105
|
-
deinterleaveAndWriteAudioData(data, numFrames);
|
|
106
|
-
emitAudioData();
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
ma_data_converter_get_expected_output_frame_count(
|
|
111
|
-
converter_.get(), inputFrameCount, &outputFrameCount);
|
|
112
|
-
|
|
113
|
-
ma_data_converter_process_pcm_frames(
|
|
114
|
-
converter_.get(),
|
|
115
|
-
data,
|
|
116
|
-
&inputFrameCount,
|
|
117
|
-
processingBuffer_,
|
|
118
|
-
&outputFrameCount);
|
|
119
|
-
|
|
120
|
-
deinterleaveAndWriteAudioData(
|
|
121
|
-
processingBuffer_, static_cast<int>(outputFrameCount));
|
|
122
|
-
emitAudioData();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
void AndroidRecorderCallback::deinterleaveAndWriteAudioData(
|
|
126
|
-
void *data,
|
|
127
|
-
int numFrames) {
|
|
128
|
-
auto *inputData = static_cast<float *>(data);
|
|
129
|
-
|
|
130
|
-
for (size_t channel = 0; channel < channelCount_; ++channel) {
|
|
131
|
-
float *channelData = deinterleavingArray_->getData();
|
|
132
|
-
|
|
133
|
-
for (int frame = 0; frame < numFrames; ++frame) {
|
|
134
|
-
channelData[frame] = inputData[frame * streamChannelCount_ + channel];
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
circularBus_[channel]->push_back(channelData, numFrames);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
void AndroidRecorderCallback::emitAudioData() {
|
|
142
|
-
while (circularBus_[0]->getNumberOfAvailableFrames() >= bufferLength_) {
|
|
143
|
-
auto bus =
|
|
144
|
-
std::make_shared<AudioBus>(bufferLength_, channelCount_, sampleRate_);
|
|
145
|
-
|
|
146
|
-
for (int i = 0; i < channelCount_; ++i) {
|
|
147
|
-
auto *outputChannel = bus->getChannel(i)->getData();
|
|
148
|
-
circularBus_[i]->pop_front(outputChannel, bufferLength_);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
invokeCallback(bus, (int)bufferLength_);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
void AndroidRecorderCallback::invokeCallback(
|
|
156
|
-
const std::shared_ptr<AudioBus> &bus,
|
|
157
|
-
int numFrames) {
|
|
158
|
-
auto audioBuffer = std::make_shared<AudioBuffer>(bus);
|
|
159
|
-
auto audioBufferHostObject =
|
|
160
|
-
std::make_shared<AudioBufferHostObject>(audioBuffer);
|
|
161
|
-
|
|
162
|
-
std::unordered_map<std::string, EventValue> eventPayload = {};
|
|
163
|
-
eventPayload.insert({"buffer", audioBufferHostObject});
|
|
164
|
-
eventPayload.insert({"numFrames", numFrames});
|
|
165
|
-
|
|
166
|
-
if (audioEventHandlerRegistry_) {
|
|
167
|
-
audioEventHandlerRegistry_->invokeHandlerWithEventBody(
|
|
168
|
-
"audioReady", callbackId_, eventPayload);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
void AndroidRecorderCallback::sendRemainingData() {
|
|
173
|
-
auto numberOfFrames = circularBus_[0]->getNumberOfAvailableFrames();
|
|
174
|
-
auto bus = std::make_shared<AudioBus>(
|
|
175
|
-
circularBus_[0]->getNumberOfAvailableFrames(),
|
|
176
|
-
channelCount_,
|
|
177
|
-
sampleRate_);
|
|
178
|
-
|
|
179
|
-
for (int i = 0; i < channelCount_; ++i) {
|
|
180
|
-
auto *outputChannel = bus->getChannel(i)->getData();
|
|
181
|
-
circularBus_[i]->pop_front(outputChannel, numberOfFrames);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
invokeCallback(bus, (int)numberOfFrames);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
} // namespace audioapi
|