react-native-audio-api 0.11.0-alpha.1 → 0.11.0-nightly-9f40b78-20251108
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/AudioContextHostObject.cpp +12 -17
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +18 -0
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +1 -0
- package/common/cpp/audioapi/HostObjects/OfflineAudioContextHostObject.cpp +26 -30
- 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/HostObjects/utils/AudioStretcherHostObject.cpp +15 -26
- 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/AudioBufferQueueSourceNode.cpp +7 -0
- package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.h +1 -0
- 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 -19
- package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.h +3 -3
- 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/jsi/JsiPromise.cpp +33 -56
- package/common/cpp/audioapi/jsi/JsiPromise.h +41 -11
- 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 +34 -9
- 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
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const semverPrerelease = require('semver/functions/prerelease');
|
|
3
|
+
const validWorkletsVersions = [
|
|
4
|
+
'0.6.0',
|
|
5
|
+
'0.6.1',
|
|
6
|
+
];
|
|
7
|
+
|
|
8
|
+
function validateVersion() {
|
|
9
|
+
let workletsVersion;
|
|
10
|
+
try {
|
|
11
|
+
const { version } = require('react-native-worklets/package.json');
|
|
12
|
+
workletsVersion = version;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if (semverPrerelease(workletsVersion)) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return validWorkletsVersions.includes(workletsVersion);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (!validateVersion()) {
|
|
24
|
+
console.warn(
|
|
25
|
+
'[RNAudioApi] Incompatible version of react-native-audio-worklets detected. Please install a compatible version if you want to use worklet nodes in react-native-audio-api.',
|
|
26
|
+
);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
package/src/api.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import { NativeAudioAPIModule } from './specs';
|
|
2
|
+
import { AudioRecorderOptions } from './types';
|
|
1
3
|
import type {
|
|
2
4
|
IAudioContext,
|
|
3
5
|
IAudioDecoder,
|
|
4
|
-
IAudioEventEmitter,
|
|
5
6
|
IAudioRecorder,
|
|
6
7
|
IAudioStretcher,
|
|
7
8
|
IOfflineAudioContext,
|
|
9
|
+
IAudioEventEmitter,
|
|
8
10
|
} from './interfaces';
|
|
9
|
-
import { NativeAudioAPIModule } from './specs';
|
|
10
11
|
|
|
11
12
|
/* eslint-disable no-var */
|
|
12
13
|
declare global {
|
|
@@ -24,7 +25,7 @@ declare global {
|
|
|
24
25
|
audioWorkletRuntime: any
|
|
25
26
|
) => IOfflineAudioContext;
|
|
26
27
|
|
|
27
|
-
var createAudioRecorder: () => IAudioRecorder;
|
|
28
|
+
var createAudioRecorder: (options: AudioRecorderOptions) => IAudioRecorder;
|
|
28
29
|
|
|
29
30
|
var createAudioDecoder: () => IAudioDecoder;
|
|
30
31
|
|
|
@@ -51,33 +52,59 @@ if (
|
|
|
51
52
|
NativeAudioAPIModule.install();
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
export { default as
|
|
55
|
+
export { default as WorkletNode } from './core/WorkletNode';
|
|
56
|
+
export { default as WorkletSourceNode } from './core/WorkletSourceNode';
|
|
57
|
+
export { default as WorkletProcessingNode } from './core/WorkletProcessingNode';
|
|
58
|
+
export { default as RecorderAdapterNode } from './core/RecorderAdapterNode';
|
|
55
59
|
export { default as AudioBuffer } from './core/AudioBuffer';
|
|
56
|
-
export { default as AudioBufferQueueSourceNode } from './core/AudioBufferQueueSourceNode';
|
|
57
60
|
export { default as AudioBufferSourceNode } from './core/AudioBufferSourceNode';
|
|
61
|
+
export { default as AudioBufferQueueSourceNode } from './core/AudioBufferQueueSourceNode';
|
|
58
62
|
export { default as AudioContext } from './core/AudioContext';
|
|
59
|
-
export {
|
|
63
|
+
export { default as OfflineAudioContext } from './core/OfflineAudioContext';
|
|
60
64
|
export { default as AudioDestinationNode } from './core/AudioDestinationNode';
|
|
61
65
|
export { default as AudioNode } from './core/AudioNode';
|
|
66
|
+
export { default as AnalyserNode } from './core/AnalyserNode';
|
|
62
67
|
export { default as AudioParam } from './core/AudioParam';
|
|
63
|
-
export { default as AudioRecorder } from './core/AudioRecorder';
|
|
64
68
|
export { default as AudioScheduledSourceNode } from './core/AudioScheduledSourceNode';
|
|
65
|
-
export { default as changePlaybackSpeed } from './core/AudioStretcher';
|
|
66
69
|
export { default as BaseAudioContext } from './core/BaseAudioContext';
|
|
67
70
|
export { default as BiquadFilterNode } from './core/BiquadFilterNode';
|
|
68
|
-
export { default as ConstantSourceNode } from './core/ConstantSourceNode';
|
|
69
71
|
export { default as GainNode } from './core/GainNode';
|
|
70
|
-
export { default as OfflineAudioContext } from './core/OfflineAudioContext';
|
|
71
72
|
export { default as OscillatorNode } from './core/OscillatorNode';
|
|
72
|
-
export { default as RecorderAdapterNode } from './core/RecorderAdapterNode';
|
|
73
73
|
export { default as StereoPannerNode } from './core/StereoPannerNode';
|
|
74
|
+
export { default as AudioRecorder } from './core/AudioRecorder';
|
|
74
75
|
export { default as StreamerNode } from './core/StreamerNode';
|
|
75
|
-
export { default as
|
|
76
|
-
export { default as WorkletProcessingNode } from './core/WorkletProcessingNode';
|
|
77
|
-
export { default as WorkletSourceNode } from './core/WorkletSourceNode';
|
|
78
|
-
export { default as useSystemVolume } from './hooks/useSystemVolume';
|
|
76
|
+
export { default as ConstantSourceNode } from './core/ConstantSourceNode';
|
|
79
77
|
export { default as AudioManager } from './system';
|
|
78
|
+
export { default as ConvolverNode } from './core/ConvolverNode';
|
|
79
|
+
export { default as useSystemVolume } from './hooks/useSystemVolume';
|
|
80
|
+
export { decodeAudioData, decodePCMInBase64 } from './core/AudioDecoder';
|
|
81
|
+
export { default as changePlaybackSpeed } from './core/AudioStretcher';
|
|
82
|
+
|
|
83
|
+
export {
|
|
84
|
+
OscillatorType,
|
|
85
|
+
BiquadFilterType,
|
|
86
|
+
ChannelCountMode,
|
|
87
|
+
ChannelInterpretation,
|
|
88
|
+
ContextState,
|
|
89
|
+
WindowType,
|
|
90
|
+
PeriodicWaveConstraints,
|
|
91
|
+
AudioWorkletRuntime,
|
|
92
|
+
} from './types';
|
|
93
|
+
|
|
94
|
+
export {
|
|
95
|
+
IOSCategory,
|
|
96
|
+
IOSMode,
|
|
97
|
+
IOSOption,
|
|
98
|
+
SessionOptions,
|
|
99
|
+
MediaState,
|
|
100
|
+
LockScreenInfo,
|
|
101
|
+
PermissionStatus,
|
|
102
|
+
} from './system/types';
|
|
80
103
|
|
|
81
|
-
export
|
|
82
|
-
|
|
83
|
-
|
|
104
|
+
export {
|
|
105
|
+
IndexSizeError,
|
|
106
|
+
InvalidAccessError,
|
|
107
|
+
InvalidStateError,
|
|
108
|
+
RangeError,
|
|
109
|
+
NotSupportedError,
|
|
110
|
+
} from './errors';
|
package/src/api.web.ts
CHANGED
|
@@ -13,6 +13,7 @@ export { default as GainNode } from './web-core/GainNode';
|
|
|
13
13
|
export { default as OscillatorNode } from './web-core/OscillatorNode';
|
|
14
14
|
export { default as StereoPannerNode } from './web-core/StereoPannerNode';
|
|
15
15
|
export { default as ConstantSourceNode } from './web-core/ConstantSourceNode';
|
|
16
|
+
export { default as ConvolverNode } from './web-core/ConvolverNode';
|
|
16
17
|
|
|
17
18
|
export * from './web-core/custom';
|
|
18
19
|
|
package/src/core/AudioContext.ts
CHANGED
|
@@ -3,7 +3,7 @@ import BaseAudioContext from './BaseAudioContext';
|
|
|
3
3
|
import AudioManager from '../system';
|
|
4
4
|
import { AudioContextOptions } from '../types';
|
|
5
5
|
import { NotSupportedError } from '../errors';
|
|
6
|
-
import {
|
|
6
|
+
import { isWorkletsVersionSupported, workletsModule } from '../utils';
|
|
7
7
|
|
|
8
8
|
export default class AudioContext extends BaseAudioContext {
|
|
9
9
|
constructor(options?: AudioContextOptions) {
|
|
@@ -17,7 +17,8 @@ export default class AudioContext extends BaseAudioContext {
|
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
let audioRuntime = null;
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
if (isWorkletsVersionSupported) {
|
|
21
22
|
audioRuntime = workletsModule.createWorkletRuntime('AudioWorkletRuntime');
|
|
22
23
|
}
|
|
23
24
|
|
|
@@ -1,143 +1,30 @@
|
|
|
1
|
-
import { AudioEventEmitter, AudioEventSubscription } from '../events';
|
|
2
|
-
import { OnAudioReadyEventType } from '../events/types';
|
|
3
1
|
import { IAudioRecorder } from '../interfaces';
|
|
4
|
-
import {
|
|
5
|
-
AndroidFormat,
|
|
6
|
-
AudioRecorderCallbackOptions,
|
|
7
|
-
AudioRecorderFileOptions,
|
|
8
|
-
BitDepth,
|
|
9
|
-
FileDirectory,
|
|
10
|
-
FileInfo,
|
|
11
|
-
IOSAudioQuality,
|
|
12
|
-
IOSFormat,
|
|
13
|
-
} from '../types';
|
|
14
|
-
import { encodeFlags } from '../utils';
|
|
2
|
+
import { AudioRecorderOptions } from '../types';
|
|
15
3
|
import AudioBuffer from './AudioBuffer';
|
|
4
|
+
import { OnAudioReadyEventType } from '../events/types';
|
|
5
|
+
import { AudioEventEmitter } from '../events';
|
|
16
6
|
import RecorderAdapterNode from './RecorderAdapterNode';
|
|
17
7
|
|
|
18
|
-
function withDefaultOptions(inOptions: AudioRecorderFileOptions) {
|
|
19
|
-
return {
|
|
20
|
-
directory: FileDirectory.Cache,
|
|
21
|
-
sampleRate: 48000,
|
|
22
|
-
channels: 2,
|
|
23
|
-
bitRate: 128000,
|
|
24
|
-
bitDepth: BitDepth.Bit24,
|
|
25
|
-
...inOptions,
|
|
26
|
-
ios: {
|
|
27
|
-
format: IOSFormat.M4A,
|
|
28
|
-
quality: IOSAudioQuality.High,
|
|
29
|
-
...(inOptions.ios ?? {}),
|
|
30
|
-
},
|
|
31
|
-
android: {
|
|
32
|
-
format: AndroidFormat.M4A,
|
|
33
|
-
...(inOptions.android ?? {}),
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function parseFileOptions(inOptions: AudioRecorderFileOptions) {
|
|
39
|
-
const { sampleRate, channels, bitRate, directory, bitDepth, ios, android } =
|
|
40
|
-
withDefaultOptions(inOptions);
|
|
41
|
-
|
|
42
|
-
const iosFlags = encodeFlags(
|
|
43
|
-
ios.format,
|
|
44
|
-
ios.quality,
|
|
45
|
-
ios.flacCompressionLevel || 0,
|
|
46
|
-
directory,
|
|
47
|
-
bitDepth
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
// TODO: ensure directory and bitDepth are last in the bitmask
|
|
51
|
-
const androidFlags = encodeFlags(android.format, directory, bitDepth);
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
sampleRate,
|
|
55
|
-
channels,
|
|
56
|
-
bitRate,
|
|
57
|
-
ios: iosFlags,
|
|
58
|
-
android: androidFlags,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
8
|
export default class AudioRecorder {
|
|
63
|
-
protected onAudioReadySubscription: AudioEventSubscription | null = null;
|
|
64
9
|
protected readonly recorder: IAudioRecorder;
|
|
65
|
-
protected options_: AudioRecorderFileOptions | null = null;
|
|
66
|
-
private isFileOutputEnabled: boolean = false;
|
|
67
10
|
|
|
68
|
-
|
|
11
|
+
private readonly audioEventEmitter = new AudioEventEmitter(
|
|
69
12
|
global.AudioEventEmitter
|
|
70
13
|
);
|
|
71
14
|
|
|
72
|
-
constructor() {
|
|
73
|
-
this.recorder = global.createAudioRecorder();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
enableFileOutput(options: AudioRecorderFileOptions): void {
|
|
77
|
-
if (this.recorder.isRecording()) {
|
|
78
|
-
throw new Error(
|
|
79
|
-
'Cannot enable file output while recording is in progress. Please stop the recorder before changing output options.'
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
this.options_ = options;
|
|
84
|
-
|
|
85
|
-
const parsedOptions = parseFileOptions(options);
|
|
86
|
-
this.recorder.enableFileOutput(parsedOptions);
|
|
87
|
-
this.isFileOutputEnabled = true;
|
|
15
|
+
constructor(options: AudioRecorderOptions) {
|
|
16
|
+
this.recorder = global.createAudioRecorder(options);
|
|
88
17
|
}
|
|
89
18
|
|
|
90
|
-
public
|
|
91
|
-
|
|
19
|
+
public start(): void {
|
|
20
|
+
this.recorder.start();
|
|
92
21
|
}
|
|
93
22
|
|
|
94
|
-
|
|
95
|
-
this.
|
|
96
|
-
this.recorder.disableFileOutput();
|
|
97
|
-
this.isFileOutputEnabled = false;
|
|
23
|
+
public stop(): void {
|
|
24
|
+
this.recorder.stop();
|
|
98
25
|
}
|
|
99
26
|
|
|
100
|
-
|
|
101
|
-
start(): string | void {
|
|
102
|
-
if (!this.isFileOutputEnabled) {
|
|
103
|
-
this.recorder.start();
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return this.recorder.start();
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/** Stops the audio recording process and releases internal resources */
|
|
111
|
-
stop(): FileInfo {
|
|
112
|
-
return this.recorder.stop();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/** Pauses the audio recording process without tearing down anything */
|
|
116
|
-
pause(): void {
|
|
117
|
-
this.recorder.pause();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/** Resumes the audio recording process after being paused */
|
|
121
|
-
resume(): void {
|
|
122
|
-
this.recorder.resume();
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Connects a {@link RecorderAdapterNode} to the recorder’s audio graph.
|
|
127
|
-
*
|
|
128
|
-
* Each node can only be connected once. Attempting to connect a node multiple
|
|
129
|
-
* times will throw an error.
|
|
130
|
-
*
|
|
131
|
-
* @param node - The adapter node to connect to the recorder.
|
|
132
|
-
* @throws If the node has already been connected.
|
|
133
|
-
*/
|
|
134
|
-
connect(node: RecorderAdapterNode): void {
|
|
135
|
-
if (this.recorder.isRecording()) {
|
|
136
|
-
throw new Error(
|
|
137
|
-
'Cannot connect adapter node while recording is in progress. Please stop the recorder before connecting new nodes.'
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
|
|
27
|
+
public connect(node: RecorderAdapterNode): void {
|
|
141
28
|
if (node.wasConnected) {
|
|
142
29
|
throw new Error(
|
|
143
30
|
'RecorderAdapterNode cannot be connected more than once. Refer to the documentation for more details.'
|
|
@@ -147,98 +34,24 @@ export default class AudioRecorder {
|
|
|
147
34
|
this.recorder.connect(node.getNode());
|
|
148
35
|
}
|
|
149
36
|
|
|
150
|
-
|
|
151
|
-
* Disconnects the recorder from all connected adapter nodes.
|
|
152
|
-
*
|
|
153
|
-
* After calling this method, any connected {@link RecorderAdapterNode} will no
|
|
154
|
-
* longer receive audio data until reconnected.
|
|
155
|
-
*/
|
|
156
|
-
disconnect(): void {
|
|
37
|
+
public disconnect(): void {
|
|
157
38
|
this.recorder.disconnect();
|
|
158
39
|
}
|
|
159
40
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
* rate, buffer length, and channel count) guide how audio data is chunked and
|
|
167
|
-
* delivered, though the exact values may vary depending on device
|
|
168
|
-
* capabilities. Values may vary depending on device capabilities.
|
|
169
|
-
*
|
|
170
|
-
* @param options - Preferred configuration for the audio buffers delivered to
|
|
171
|
-
* the callback.
|
|
172
|
-
* @param callback - Function invoked each time a new audio buffer is
|
|
173
|
-
* available. The callback receives an {@link OnAudioReadyEventType} object
|
|
174
|
-
* containing the audio data and associated metadata.
|
|
175
|
-
*/
|
|
176
|
-
onAudioReady(
|
|
177
|
-
options: AudioRecorderCallbackOptions,
|
|
178
|
-
callback: (event: OnAudioReadyEventType) => void
|
|
179
|
-
): void {
|
|
180
|
-
if (this.recorder.isRecording()) {
|
|
181
|
-
throw new Error(
|
|
182
|
-
'Cannot set onAudioReady callback while recording is in progress. Please stop the recorder before setting a new callback.'
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
if (this.onAudioReadySubscription) {
|
|
187
|
-
this.recorder.clearOnAudioReady();
|
|
188
|
-
this.onAudioReadySubscription.remove();
|
|
189
|
-
this.onAudioReadySubscription = null;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
this.onAudioReadySubscription =
|
|
193
|
-
this.audioEventEmitter.addAudioEventListener('audioReady', (event) => {
|
|
194
|
-
const audioBuffer = new AudioBuffer(event.buffer);
|
|
195
|
-
callback({
|
|
196
|
-
...event,
|
|
197
|
-
buffer: audioBuffer,
|
|
198
|
-
});
|
|
41
|
+
public onAudioReady(callback: (event: OnAudioReadyEventType) => void): void {
|
|
42
|
+
const onAudioReadyCallback = (event: OnAudioReadyEventType) => {
|
|
43
|
+
callback({
|
|
44
|
+
buffer: new AudioBuffer(event.buffer),
|
|
45
|
+
numFrames: event.numFrames,
|
|
46
|
+
when: event.when,
|
|
199
47
|
});
|
|
48
|
+
};
|
|
200
49
|
|
|
201
|
-
this.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
callbackId: this.onAudioReadySubscription.subscriptionId,
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Removes the previously registered audio data callback, if any.
|
|
211
|
-
*
|
|
212
|
-
* This stops further `onAudioReady` events from being delivered during
|
|
213
|
-
* recording. Calling this method is safe even if no callback is currently
|
|
214
|
-
* registered.
|
|
215
|
-
*/
|
|
216
|
-
clearOnAudioReady(): void {
|
|
217
|
-
if (this.recorder.isRecording()) {
|
|
218
|
-
throw new Error(
|
|
219
|
-
'Cannot clear onAudioReady callback while recording is in progress. Please stop the recorder before clearing the callback.'
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
if (!this.onAudioReadySubscription) {
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
this.recorder.clearOnAudioReady();
|
|
228
|
-
|
|
229
|
-
this.onAudioReadySubscription.remove();
|
|
230
|
-
this.onAudioReadySubscription = null;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
isRecording(): boolean {
|
|
234
|
-
return this.recorder.isRecording();
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
isPaused(): boolean {
|
|
238
|
-
return this.recorder.isPaused();
|
|
239
|
-
}
|
|
50
|
+
const subscription = this.audioEventEmitter.addAudioEventListener(
|
|
51
|
+
'audioReady',
|
|
52
|
+
onAudioReadyCallback
|
|
53
|
+
);
|
|
240
54
|
|
|
241
|
-
|
|
242
|
-
return this.recorder.getCurrentDuration();
|
|
55
|
+
this.recorder.onAudioReady = subscription.subscriptionId;
|
|
243
56
|
}
|
|
244
57
|
}
|
|
@@ -5,13 +5,15 @@ import {
|
|
|
5
5
|
ContextState,
|
|
6
6
|
PeriodicWaveConstraints,
|
|
7
7
|
AudioWorkletRuntime,
|
|
8
|
+
ConvolverNodeOptions,
|
|
8
9
|
} from '../types';
|
|
9
|
-
import {
|
|
10
|
+
import { assertWorkletsEnabled, workletsModule } from '../utils';
|
|
10
11
|
import WorkletSourceNode from './WorkletSourceNode';
|
|
11
12
|
import WorkletProcessingNode from './WorkletProcessingNode';
|
|
12
13
|
import AnalyserNode from './AnalyserNode';
|
|
13
14
|
import AudioBuffer from './AudioBuffer';
|
|
14
15
|
import AudioBufferQueueSourceNode from './AudioBufferQueueSourceNode';
|
|
16
|
+
import ConvolverNode from './ConvolverNode';
|
|
15
17
|
import AudioBufferSourceNode from './AudioBufferSourceNode';
|
|
16
18
|
import AudioDestinationNode from './AudioDestinationNode';
|
|
17
19
|
import BiquadFilterNode from './BiquadFilterNode';
|
|
@@ -84,30 +86,24 @@ export default class BaseAudioContext {
|
|
|
84
86
|
`The buffer length provided (${bufferLength}) can not be less than 1`
|
|
85
87
|
);
|
|
86
88
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
)
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
/// User does not have worklets as a dependency so he cannot use the worklet API.
|
|
109
|
-
throw new Error(
|
|
110
|
-
'[RnAudioApi] Worklets are not available, please install react-native-worklets as a dependency. Refer to documentation for more details.'
|
|
89
|
+
assertWorkletsEnabled();
|
|
90
|
+
const shareableWorklet = workletsModule.makeShareableCloneRecursive(
|
|
91
|
+
(audioBuffers: Array<ArrayBuffer>, channelCount: number) => {
|
|
92
|
+
'worklet';
|
|
93
|
+
const floatAudioData: Array<Float32Array> = audioBuffers.map(
|
|
94
|
+
(buffer) => new Float32Array(buffer)
|
|
95
|
+
);
|
|
96
|
+
callback(floatAudioData, channelCount);
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
return new WorkletNode(
|
|
100
|
+
this,
|
|
101
|
+
this.context.createWorkletNode(
|
|
102
|
+
shareableWorklet,
|
|
103
|
+
workletRuntime === 'UIRuntime',
|
|
104
|
+
bufferLength,
|
|
105
|
+
inputChannelCount
|
|
106
|
+
)
|
|
111
107
|
);
|
|
112
108
|
}
|
|
113
109
|
|
|
@@ -120,35 +116,30 @@ export default class BaseAudioContext {
|
|
|
120
116
|
) => void,
|
|
121
117
|
workletRuntime: AudioWorkletRuntime = 'AudioRuntime'
|
|
122
118
|
): WorkletProcessingNode {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
/// User does not have worklets as a dependency so he cannot use the worklet API.
|
|
150
|
-
throw new Error(
|
|
151
|
-
'[RnAudioApi] Worklets are not available, please install react-native-worklets as a dependency. Refer to documentation for more details.'
|
|
119
|
+
assertWorkletsEnabled();
|
|
120
|
+
const shareableWorklet = workletsModule.makeShareableCloneRecursive(
|
|
121
|
+
(
|
|
122
|
+
inputBuffers: Array<ArrayBuffer>,
|
|
123
|
+
outputBuffers: Array<ArrayBuffer>,
|
|
124
|
+
framesToProcess: number,
|
|
125
|
+
currentTime: number
|
|
126
|
+
) => {
|
|
127
|
+
'worklet';
|
|
128
|
+
const inputData: Array<Float32Array> = inputBuffers.map(
|
|
129
|
+
(buffer) => new Float32Array(buffer, 0, framesToProcess)
|
|
130
|
+
);
|
|
131
|
+
const outputData: Array<Float32Array> = outputBuffers.map(
|
|
132
|
+
(buffer) => new Float32Array(buffer, 0, framesToProcess)
|
|
133
|
+
);
|
|
134
|
+
callback(inputData, outputData, framesToProcess, currentTime);
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
return new WorkletProcessingNode(
|
|
138
|
+
this,
|
|
139
|
+
this.context.createWorkletProcessingNode(
|
|
140
|
+
shareableWorklet,
|
|
141
|
+
workletRuntime === 'UIRuntime'
|
|
142
|
+
)
|
|
152
143
|
);
|
|
153
144
|
}
|
|
154
145
|
|
|
@@ -161,12 +152,7 @@ export default class BaseAudioContext {
|
|
|
161
152
|
) => void,
|
|
162
153
|
workletRuntime: AudioWorkletRuntime = 'AudioRuntime'
|
|
163
154
|
): WorkletSourceNode {
|
|
164
|
-
|
|
165
|
-
/// User does not have worklets as a dependency so he cannot use the worklet API.
|
|
166
|
-
throw new Error(
|
|
167
|
-
'[RnAudioApi] Worklets are not available, please install react-native-worklets as a dependency. Refer to documentation for more details.'
|
|
168
|
-
);
|
|
169
|
-
}
|
|
155
|
+
assertWorkletsEnabled();
|
|
170
156
|
const shareableWorklet = workletsModule.makeShareableCloneRecursive(
|
|
171
157
|
(
|
|
172
158
|
audioBuffers: Array<ArrayBuffer>,
|
|
@@ -289,4 +275,25 @@ export default class BaseAudioContext {
|
|
|
289
275
|
createAnalyser(): AnalyserNode {
|
|
290
276
|
return new AnalyserNode(this, this.context.createAnalyser());
|
|
291
277
|
}
|
|
278
|
+
|
|
279
|
+
createConvolver(options?: ConvolverNodeOptions): ConvolverNode {
|
|
280
|
+
if (options?.buffer) {
|
|
281
|
+
const numberOfChannels = options.buffer.numberOfChannels;
|
|
282
|
+
if (
|
|
283
|
+
numberOfChannels !== 1 &&
|
|
284
|
+
numberOfChannels !== 2 &&
|
|
285
|
+
numberOfChannels !== 4
|
|
286
|
+
) {
|
|
287
|
+
throw new NotSupportedError(
|
|
288
|
+
`The number of channels provided (${numberOfChannels}) in impulse response for ConvolverNode buffer must be 1 or 2 or 4.`
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
const buffer = options?.buffer ?? null;
|
|
293
|
+
const disableNormalization = options?.disableNormalization ?? false;
|
|
294
|
+
return new ConvolverNode(
|
|
295
|
+
this,
|
|
296
|
+
this.context.createConvolver(buffer?.buffer, disableNormalization)
|
|
297
|
+
);
|
|
298
|
+
}
|
|
292
299
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IConvolverNode } from '../interfaces';
|
|
2
|
+
import BaseAudioContext from './BaseAudioContext';
|
|
3
|
+
import AudioNode from './AudioNode';
|
|
4
|
+
import AudioBuffer from './AudioBuffer';
|
|
5
|
+
|
|
6
|
+
export default class ConvolverNode extends AudioNode {
|
|
7
|
+
constructor(context: BaseAudioContext, node: IConvolverNode) {
|
|
8
|
+
super(context, node);
|
|
9
|
+
this.normalize = node.normalize;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public get buffer(): AudioBuffer | null {
|
|
13
|
+
const buffer = (this.node as IConvolverNode).buffer;
|
|
14
|
+
if (!buffer) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return new AudioBuffer(buffer);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public set buffer(buffer: AudioBuffer | null) {
|
|
21
|
+
if (!buffer) {
|
|
22
|
+
(this.node as IConvolverNode).buffer = null;
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
(this.node as IConvolverNode).buffer = buffer.buffer;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public get normalize(): boolean {
|
|
29
|
+
return (this.node as IConvolverNode).normalize;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public set normalize(value: boolean) {
|
|
33
|
+
(this.node as IConvolverNode).normalize = value;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -3,7 +3,7 @@ import BaseAudioContext from './BaseAudioContext';
|
|
|
3
3
|
import { OfflineAudioContextOptions } from '../types';
|
|
4
4
|
import { InvalidStateError, NotSupportedError } from '../errors';
|
|
5
5
|
import AudioBuffer from './AudioBuffer';
|
|
6
|
-
import {
|
|
6
|
+
import { isWorkletsVersionSupported, workletsModule } from '../utils';
|
|
7
7
|
|
|
8
8
|
export default class OfflineAudioContext extends BaseAudioContext {
|
|
9
9
|
private isSuspended: boolean;
|
|
@@ -18,7 +18,7 @@ export default class OfflineAudioContext extends BaseAudioContext {
|
|
|
18
18
|
arg2?: number
|
|
19
19
|
) {
|
|
20
20
|
let audioRuntime = null;
|
|
21
|
-
if (
|
|
21
|
+
if (isWorkletsVersionSupported) {
|
|
22
22
|
audioRuntime = workletsModule.createWorkletRuntime('AudioWorkletRuntime');
|
|
23
23
|
}
|
|
24
24
|
|
package/src/events/types.ts
CHANGED
|
@@ -49,27 +49,9 @@ export interface OnEndedEventType extends EventEmptyType {
|
|
|
49
49
|
isLast: boolean | undefined;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
/**
|
|
53
|
-
* Represents the data payload received by the audio recorder callback each time
|
|
54
|
-
* a new audio buffer becomes available during recording.
|
|
55
|
-
*/
|
|
56
52
|
export interface OnAudioReadyEventType {
|
|
57
|
-
/**
|
|
58
|
-
* The audio buffer containing the recorded PCM data. This buffer includes one
|
|
59
|
-
* or more channels of floating-point samples in the range of -1.0 to 1.0.
|
|
60
|
-
*/
|
|
61
53
|
buffer: AudioBuffer;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* The number of audio frames contained in this buffer. A frame represents a
|
|
65
|
-
* single sample across all channels.
|
|
66
|
-
*/
|
|
67
54
|
numFrames: number;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* The timestamp (in seconds) indicating when this buffer was captured,
|
|
71
|
-
* relative to the start of the recording session.
|
|
72
|
-
*/
|
|
73
55
|
when: number;
|
|
74
56
|
}
|
|
75
57
|
|