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
|
@@ -14,97 +14,35 @@
|
|
|
14
14
|
namespace audioapi {
|
|
15
15
|
|
|
16
16
|
AudioRecorderHostObject::AudioRecorderHostObject(
|
|
17
|
-
const std::shared_ptr<AudioEventHandlerRegistry>
|
|
18
|
-
|
|
17
|
+
const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry,
|
|
18
|
+
float sampleRate,
|
|
19
|
+
int bufferLength) {
|
|
19
20
|
#ifdef ANDROID
|
|
20
|
-
audioRecorder_ =
|
|
21
|
-
|
|
21
|
+
audioRecorder_ = std::make_shared<AndroidAudioRecorder>(
|
|
22
|
+
sampleRate, bufferLength, audioEventHandlerRegistry);
|
|
22
23
|
#else
|
|
23
|
-
audioRecorder_ =
|
|
24
|
-
|
|
24
|
+
audioRecorder_ = std::make_shared<IOSAudioRecorder>(
|
|
25
|
+
sampleRate, bufferLength, audioEventHandlerRegistry);
|
|
25
26
|
#endif
|
|
26
27
|
|
|
28
|
+
addSetters(JSI_EXPORT_PROPERTY_SETTER(AudioRecorderHostObject, onAudioReady));
|
|
29
|
+
|
|
27
30
|
addFunctions(
|
|
28
31
|
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, start),
|
|
29
32
|
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, stop),
|
|
30
|
-
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, isRecording),
|
|
31
|
-
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, enableFileOutput),
|
|
32
|
-
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, disableFileOutput),
|
|
33
|
-
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, pause),
|
|
34
|
-
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, resume),
|
|
35
33
|
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, connect),
|
|
36
|
-
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, disconnect)
|
|
37
|
-
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, setOnAudioReady),
|
|
38
|
-
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, clearOnAudioReady),
|
|
39
|
-
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, getCurrentDuration));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, start) {
|
|
43
|
-
std::string filePath = audioRecorder_->start();
|
|
44
|
-
|
|
45
|
-
return jsi::Value(runtime, jsi::String::createFromUtf8(runtime, filePath));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, stop) {
|
|
49
|
-
auto [path, size, duration] = audioRecorder_->stop();
|
|
50
|
-
auto result = jsi::Object(runtime);
|
|
51
|
-
|
|
52
|
-
result.setProperty(
|
|
53
|
-
runtime, "path", jsi::String::createFromUtf8(runtime, path));
|
|
54
|
-
result.setProperty(runtime, "size", size);
|
|
55
|
-
result.setProperty(runtime, "duration", duration);
|
|
56
|
-
|
|
57
|
-
return result;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, isRecording) {
|
|
61
|
-
return jsi::Value(audioRecorder_->isRecording());
|
|
34
|
+
JSI_EXPORT_FUNCTION(AudioRecorderHostObject, disconnect));
|
|
62
35
|
}
|
|
63
36
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, enableFileOutput) {
|
|
69
|
-
auto options = args[0].getObject(runtime);
|
|
70
|
-
|
|
71
|
-
auto sampleRate = static_cast<float>(
|
|
72
|
-
options.getProperty(runtime, "sampleRate").getNumber());
|
|
73
|
-
auto channelCount =
|
|
74
|
-
static_cast<size_t>(options.getProperty(runtime, "channels").getNumber());
|
|
75
|
-
auto bitRate =
|
|
76
|
-
static_cast<size_t>(options.getProperty(runtime, "bitRate").getNumber());
|
|
77
|
-
auto iosFlags =
|
|
78
|
-
static_cast<size_t>(options.getProperty(runtime, "ios").getNumber());
|
|
79
|
-
auto androidFlags =
|
|
80
|
-
static_cast<size_t>(options.getProperty(runtime, "android").getNumber());
|
|
81
|
-
|
|
82
|
-
audioRecorder_->enableFileOutput(
|
|
83
|
-
sampleRate, channelCount, bitRate, iosFlags, androidFlags);
|
|
84
|
-
return jsi::Value::undefined();
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, disableFileOutput) {
|
|
88
|
-
audioRecorder_->disableFileOutput();
|
|
89
|
-
return jsi::Value::undefined();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, pause) {
|
|
93
|
-
audioRecorder_->pause();
|
|
94
|
-
|
|
95
|
-
return jsi::Value::undefined();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, resume) {
|
|
99
|
-
audioRecorder_->resume();
|
|
100
|
-
return jsi::Value::undefined();
|
|
37
|
+
JSI_PROPERTY_SETTER_IMPL(AudioRecorderHostObject, onAudioReady) {
|
|
38
|
+
audioRecorder_->setOnAudioReadyCallbackId(
|
|
39
|
+
std::stoull(value.getString(runtime).utf8(runtime)));
|
|
101
40
|
}
|
|
102
41
|
|
|
103
42
|
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, connect) {
|
|
104
43
|
auto adapterNodeHostObject =
|
|
105
44
|
args[0].getObject(runtime).getHostObject<RecorderAdapterNodeHostObject>(
|
|
106
45
|
runtime);
|
|
107
|
-
|
|
108
46
|
audioRecorder_->connect(
|
|
109
47
|
std::static_pointer_cast<RecorderAdapterNode>(
|
|
110
48
|
adapterNodeHostObject->node_));
|
|
@@ -113,36 +51,19 @@ JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, connect) {
|
|
|
113
51
|
|
|
114
52
|
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, disconnect) {
|
|
115
53
|
audioRecorder_->disconnect();
|
|
116
|
-
|
|
117
54
|
return jsi::Value::undefined();
|
|
118
55
|
}
|
|
119
56
|
|
|
120
|
-
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
auto sampleRate = static_cast<float>(
|
|
124
|
-
options.getProperty(runtime, "sampleRate").getNumber());
|
|
125
|
-
auto bufferLength = static_cast<size_t>(
|
|
126
|
-
options.getProperty(runtime, "bufferLength").getNumber());
|
|
127
|
-
auto channelCount = static_cast<size_t>(
|
|
128
|
-
options.getProperty(runtime, "channelCount").getNumber());
|
|
129
|
-
uint64_t callbackId = std::stoull(options.getProperty(runtime, "callbackId")
|
|
130
|
-
.getString(runtime)
|
|
131
|
-
.utf8(runtime));
|
|
57
|
+
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, start) {
|
|
58
|
+
audioRecorder_->start();
|
|
132
59
|
|
|
133
|
-
audioRecorder_->setOnAudioReadyCallback(
|
|
134
|
-
sampleRate, bufferLength, channelCount, callbackId);
|
|
135
60
|
return jsi::Value::undefined();
|
|
136
61
|
}
|
|
137
62
|
|
|
138
|
-
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject,
|
|
139
|
-
audioRecorder_->
|
|
140
|
-
return jsi::Value::undefined();
|
|
141
|
-
}
|
|
63
|
+
JSI_HOST_FUNCTION_IMPL(AudioRecorderHostObject, stop) {
|
|
64
|
+
audioRecorder_->stop();
|
|
142
65
|
|
|
143
|
-
|
|
144
|
-
double duration = audioRecorder_->getCurrentDuration();
|
|
145
|
-
return jsi::Value(duration);
|
|
66
|
+
return jsi::Value::undefined();
|
|
146
67
|
}
|
|
147
68
|
|
|
148
69
|
} // namespace audioapi
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
#include <utility>
|
|
7
7
|
#include <vector>
|
|
8
8
|
#include <cstdio>
|
|
9
|
-
#include <string>
|
|
10
9
|
|
|
11
10
|
namespace audioapi {
|
|
12
11
|
using namespace facebook;
|
|
@@ -17,29 +16,18 @@ class AudioEventHandlerRegistry;
|
|
|
17
16
|
class AudioRecorderHostObject : public JsiHostObject {
|
|
18
17
|
public:
|
|
19
18
|
explicit AudioRecorderHostObject(
|
|
20
|
-
const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry
|
|
19
|
+
const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry,
|
|
20
|
+
float sampleRate,
|
|
21
|
+
int bufferLength);
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
JSI_HOST_FUNCTION_DECL(stop);
|
|
24
|
-
JSI_HOST_FUNCTION_DECL(isRecording);
|
|
25
|
-
JSI_HOST_FUNCTION_DECL(isPaused);
|
|
26
|
-
|
|
27
|
-
JSI_HOST_FUNCTION_DECL(enableFileOutput);
|
|
28
|
-
JSI_HOST_FUNCTION_DECL(disableFileOutput);
|
|
29
|
-
|
|
30
|
-
JSI_HOST_FUNCTION_DECL(pause);
|
|
31
|
-
JSI_HOST_FUNCTION_DECL(resume);
|
|
23
|
+
JSI_PROPERTY_SETTER_DECL(onAudioReady);
|
|
32
24
|
|
|
33
25
|
JSI_HOST_FUNCTION_DECL(connect);
|
|
34
26
|
JSI_HOST_FUNCTION_DECL(disconnect);
|
|
35
|
-
|
|
36
|
-
JSI_HOST_FUNCTION_DECL(
|
|
37
|
-
JSI_HOST_FUNCTION_DECL(clearOnAudioReady);
|
|
38
|
-
|
|
39
|
-
JSI_HOST_FUNCTION_DECL(getCurrentDuration);
|
|
27
|
+
JSI_HOST_FUNCTION_DECL(start);
|
|
28
|
+
JSI_HOST_FUNCTION_DECL(stop);
|
|
40
29
|
|
|
41
30
|
private:
|
|
42
31
|
std::shared_ptr<AudioRecorder> audioRecorder_;
|
|
43
32
|
};
|
|
44
|
-
|
|
45
33
|
} // namespace audioapi
|
|
@@ -28,7 +28,7 @@ AudioBufferBaseSourceNodeHostObject::~AudioBufferBaseSourceNodeHostObject() {
|
|
|
28
28
|
// When JSI object is garbage collected (together with the eventual callback),
|
|
29
29
|
// underlying source node might still be active and try to call the
|
|
30
30
|
// non-existing callback.
|
|
31
|
-
sourceNode->
|
|
31
|
+
sourceNode->setOnPositionChangedCallbackId(0);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
JSI_PROPERTY_GETTER_IMPL(AudioBufferBaseSourceNodeHostObject, detune) {
|
|
@@ -37,7 +37,7 @@ AudioBufferSourceNodeHostObject::~AudioBufferSourceNodeHostObject() {
|
|
|
37
37
|
// When JSI object is garbage collected (together with the eventual callback),
|
|
38
38
|
// underlying source node might still be active and try to call the
|
|
39
39
|
// non-existing callback.
|
|
40
|
-
audioBufferSourceNode->
|
|
40
|
+
audioBufferSourceNode->setOnLoopEndedCallbackId(0);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
JSI_PROPERTY_GETTER_IMPL(AudioBufferSourceNodeHostObject, loop) {
|
|
@@ -22,7 +22,7 @@ AudioScheduledSourceNodeHostObject::~AudioScheduledSourceNodeHostObject() {
|
|
|
22
22
|
// When JSI object is garbage collected (together with the eventual callback),
|
|
23
23
|
// underlying source node might still be active and try to call the
|
|
24
24
|
// non-existing callback.
|
|
25
|
-
audioScheduledSourceNode->
|
|
25
|
+
audioScheduledSourceNode->setOnEndedCallbackId(0);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
JSI_PROPERTY_SETTER_IMPL(AudioScheduledSourceNodeHostObject, onEnded) {
|
|
@@ -24,32 +24,21 @@ JSI_HOST_FUNCTION_IMPL(AudioStretcherHostObject, changePlaybackSpeed) {
|
|
|
24
24
|
args[0].getObject(runtime).asHostObject<AudioBufferHostObject>(runtime);
|
|
25
25
|
auto playbackSpeed = static_cast<float>(args[1].asNumber());
|
|
26
26
|
|
|
27
|
-
auto promise = promiseVendor_->
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
promise->resolve([audioBufferHostObject = std::move(
|
|
44
|
-
audioBufferHostObject)](jsi::Runtime &runtime) {
|
|
45
|
-
auto jsiObject = jsi::Object::createFromHostObject(
|
|
46
|
-
runtime, audioBufferHostObject);
|
|
47
|
-
jsiObject.setExternalMemoryPressure(
|
|
48
|
-
runtime, audioBufferHostObject->getSizeInBytes());
|
|
49
|
-
return jsiObject;
|
|
50
|
-
});
|
|
51
|
-
}).detach();
|
|
52
|
-
});
|
|
27
|
+
auto promise = promiseVendor_->createAsyncPromise([=]() -> PromiseResolver {
|
|
28
|
+
auto result = AudioStretcher::changePlaybackSpeed(
|
|
29
|
+
*audioBuffer->audioBuffer_, playbackSpeed);
|
|
30
|
+
|
|
31
|
+
if (result == nullptr) {
|
|
32
|
+
return [](jsi::Runtime &runtime) {
|
|
33
|
+
return std::string("Failed to change audio playback speed.");
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return [result](jsi::Runtime &runtime) {
|
|
37
|
+
auto audioBufferHostObject =
|
|
38
|
+
std::make_shared<AudioBufferHostObject>(result);
|
|
39
|
+
return jsi::Object::createFromHostObject(runtime, audioBufferHostObject);
|
|
40
|
+
};
|
|
41
|
+
});
|
|
53
42
|
return promise;
|
|
54
43
|
}
|
|
55
44
|
|
|
@@ -41,6 +41,7 @@ class AudioNode : public std::enable_shared_from_this<AudioNode> {
|
|
|
41
41
|
protected:
|
|
42
42
|
friend class AudioNodeManager;
|
|
43
43
|
friend class AudioDestinationNode;
|
|
44
|
+
friend class ConvolverNode;
|
|
44
45
|
|
|
45
46
|
BaseAudioContext *context_;
|
|
46
47
|
std::shared_ptr<AudioBus> audioBus_;
|
|
@@ -68,10 +69,10 @@ class AudioNode : public std::enable_shared_from_this<AudioNode> {
|
|
|
68
69
|
static std::string toString(ChannelCountMode mode);
|
|
69
70
|
static std::string toString(ChannelInterpretation interpretation);
|
|
70
71
|
|
|
72
|
+
virtual std::shared_ptr<AudioBus> processInputs(const std::shared_ptr<AudioBus>& outputBus, int framesToProcess, bool checkIsAlreadyProcessed);
|
|
71
73
|
virtual std::shared_ptr<AudioBus> processNode(const std::shared_ptr<AudioBus>&, int) = 0;
|
|
72
74
|
|
|
73
75
|
bool isAlreadyProcessed();
|
|
74
|
-
std::shared_ptr<AudioBus> processInputs(const std::shared_ptr<AudioBus>& outputBus, int framesToProcess, bool checkIsAlreadyProcessed);
|
|
75
76
|
std::shared_ptr<AudioBus> applyChannelCountMode(const std::shared_ptr<AudioBus> &processingBus);
|
|
76
77
|
void mixInputsBuses(const std::shared_ptr<AudioBus>& processingBus);
|
|
77
78
|
|
|
@@ -81,7 +82,7 @@ class AudioNode : public std::enable_shared_from_this<AudioNode> {
|
|
|
81
82
|
void disconnectParam(const std::shared_ptr<AudioParam> ¶m);
|
|
82
83
|
|
|
83
84
|
void onInputEnabled();
|
|
84
|
-
void onInputDisabled();
|
|
85
|
+
virtual void onInputDisabled();
|
|
85
86
|
void onInputConnected(AudioNode *node);
|
|
86
87
|
void onInputDisconnected(AudioNode *node);
|
|
87
88
|
|
|
@@ -56,7 +56,7 @@ float AudioParam::getValueAtTime(double time) {
|
|
|
56
56
|
void AudioParam::setValueAtTime(float value, double startTime) {
|
|
57
57
|
auto event = [value, startTime](AudioParam ¶m) {
|
|
58
58
|
// Ignore events scheduled before the end of existing automation
|
|
59
|
-
if (startTime
|
|
59
|
+
if (startTime < param.getQueueEndTime()) {
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
|
|
@@ -87,7 +87,7 @@ void AudioParam::setValueAtTime(float value, double startTime) {
|
|
|
87
87
|
void AudioParam::linearRampToValueAtTime(float value, double endTime) {
|
|
88
88
|
auto event = [value, endTime](AudioParam ¶m) {
|
|
89
89
|
// Ignore events scheduled before the end of existing automation
|
|
90
|
-
if (endTime
|
|
90
|
+
if (endTime < param.getQueueEndTime()) {
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#include <audioapi/core/analysis/AnalyserNode.h>
|
|
3
3
|
#include <audioapi/core/destinations/AudioDestinationNode.h>
|
|
4
4
|
#include <audioapi/core/effects/BiquadFilterNode.h>
|
|
5
|
+
#include <audioapi/core/effects/ConvolverNode.h>
|
|
5
6
|
#include <audioapi/core/effects/GainNode.h>
|
|
6
7
|
#include <audioapi/core/effects/StereoPannerNode.h>
|
|
7
8
|
#include <audioapi/core/effects/WorkletNode.h>
|
|
@@ -182,6 +183,15 @@ std::shared_ptr<AnalyserNode> BaseAudioContext::createAnalyser() {
|
|
|
182
183
|
return analyser;
|
|
183
184
|
}
|
|
184
185
|
|
|
186
|
+
std::shared_ptr<ConvolverNode> BaseAudioContext::createConvolver(
|
|
187
|
+
std::shared_ptr<AudioBuffer> buffer,
|
|
188
|
+
bool disableNormalization) {
|
|
189
|
+
auto convolver =
|
|
190
|
+
std::make_shared<ConvolverNode>(this, buffer, disableNormalization);
|
|
191
|
+
nodeManager_->addProcessingNode(convolver);
|
|
192
|
+
return convolver;
|
|
193
|
+
}
|
|
194
|
+
|
|
185
195
|
AudioNodeManager *BaseAudioContext::getNodeManager() {
|
|
186
196
|
return nodeManager_.get();
|
|
187
197
|
}
|
|
@@ -28,6 +28,7 @@ class AudioBufferSourceNode;
|
|
|
28
28
|
class AudioBufferQueueSourceNode;
|
|
29
29
|
class AnalyserNode;
|
|
30
30
|
class AudioEventHandlerRegistry;
|
|
31
|
+
class ConvolverNode;
|
|
31
32
|
class IAudioEventHandlerRegistry;
|
|
32
33
|
class RecorderAdapterNode;
|
|
33
34
|
class WorkletSourceNode;
|
|
@@ -76,6 +77,7 @@ class BaseAudioContext {
|
|
|
76
77
|
bool disableNormalization,
|
|
77
78
|
int length);
|
|
78
79
|
std::shared_ptr<AnalyserNode> createAnalyser();
|
|
80
|
+
std::shared_ptr<ConvolverNode> createConvolver(std::shared_ptr<AudioBuffer> buffer, bool disableNormalization);
|
|
79
81
|
|
|
80
82
|
std::shared_ptr<PeriodicWave> getBasicWaveForm(OscillatorType type);
|
|
81
83
|
[[nodiscard]] float getNyquistFrequency() const;
|
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2010 Google Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Redistribution and use in source and binary forms, with or without
|
|
5
|
+
* modification, are permitted provided that the following conditions
|
|
6
|
+
* are met:
|
|
7
|
+
*
|
|
8
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
9
|
+
* notice, this list of conditions and the following disclaimer.
|
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
11
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
12
|
+
* documentation and/or other materials provided with the distribution.
|
|
13
|
+
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
|
14
|
+
* its contributors may be used to endorse or promote products derived
|
|
15
|
+
* from this software without specific prior written permission.
|
|
16
|
+
*
|
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
|
|
18
|
+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
+
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
|
|
21
|
+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
22
|
+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
23
|
+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
24
|
+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
25
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
26
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
*/
|
|
28
|
+
|
|
1
29
|
#include <audioapi/core/BaseAudioContext.h>
|
|
2
30
|
#include <audioapi/core/effects/BiquadFilterNode.h>
|
|
3
31
|
#include <audioapi/utils/AudioArray.h>
|
|
@@ -13,14 +41,14 @@ BiquadFilterNode::BiquadFilterNode(BaseAudioContext *context)
|
|
|
13
41
|
frequencyParam_ = std::make_shared<AudioParam>(
|
|
14
42
|
350.0, 0.0f, context->getNyquistFrequency(), context);
|
|
15
43
|
detuneParam_ = std::make_shared<AudioParam>(
|
|
16
|
-
0.
|
|
44
|
+
0.0f,
|
|
17
45
|
-1200 * LOG2_MOST_POSITIVE_SINGLE_FLOAT,
|
|
18
46
|
1200 * LOG2_MOST_POSITIVE_SINGLE_FLOAT,
|
|
19
47
|
context);
|
|
20
48
|
QParam_ = std::make_shared<AudioParam>(
|
|
21
|
-
1.
|
|
49
|
+
1.0f, MOST_NEGATIVE_SINGLE_FLOAT, MOST_POSITIVE_SINGLE_FLOAT, context);
|
|
22
50
|
gainParam_ = std::make_shared<AudioParam>(
|
|
23
|
-
0.
|
|
51
|
+
0.0f,
|
|
24
52
|
MOST_NEGATIVE_SINGLE_FLOAT,
|
|
25
53
|
40 * LOG10_MOST_POSITIVE_SINGLE_FLOAT,
|
|
26
54
|
context);
|
|
@@ -76,27 +104,35 @@ void BiquadFilterNode::getFrequencyResponse(
|
|
|
76
104
|
const float *frequencyArray,
|
|
77
105
|
float *magResponseOutput,
|
|
78
106
|
float *phaseResponseOutput,
|
|
79
|
-
const
|
|
107
|
+
const size_t length) {
|
|
108
|
+
#ifndef AUDIO_API_TEST_SUITE
|
|
80
109
|
applyFilter();
|
|
110
|
+
#endif
|
|
81
111
|
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
112
|
+
// Use double precision for later calculations
|
|
113
|
+
double b0 = static_cast<double>(b0_);
|
|
114
|
+
double b1 = static_cast<double>(b1_);
|
|
115
|
+
double b2 = static_cast<double>(b2_);
|
|
116
|
+
double a1 = static_cast<double>(a1_);
|
|
117
|
+
double a2 = static_cast<double>(a2_);
|
|
118
|
+
|
|
119
|
+
float nyquist = context_->getNyquistFrequency();
|
|
88
120
|
|
|
89
121
|
for (size_t i = 0; i < length; i++) {
|
|
90
|
-
|
|
122
|
+
// Convert from frequency in Hz to normalized frequency [0, 1]
|
|
123
|
+
float normalizedFreq = frequencyArray[i] / nyquist;
|
|
124
|
+
|
|
125
|
+
if (normalizedFreq < 0.0f || normalizedFreq > 1.0f) {
|
|
126
|
+
// Out-of-bounds frequencies should return NaN.
|
|
91
127
|
magResponseOutput[i] = std::nanf("");
|
|
92
128
|
phaseResponseOutput[i] = std::nanf("");
|
|
93
129
|
continue;
|
|
94
130
|
}
|
|
95
131
|
|
|
96
|
-
|
|
97
|
-
auto z = std::complex<
|
|
132
|
+
double omega = -PI * normalizedFreq;
|
|
133
|
+
auto z = std::complex<double>(std::cos(omega), std::sin(omega));
|
|
98
134
|
auto response = (b0 + (b1 + b2 * z) * z) /
|
|
99
|
-
(std::complex<
|
|
135
|
+
(std::complex<double>(1, 0) + (a1 + a2 * z) * z);
|
|
100
136
|
magResponseOutput[i] = static_cast<float>(std::abs(response));
|
|
101
137
|
phaseResponseOutput[i] =
|
|
102
138
|
static_cast<float>(atan2(imag(response), real(response)));
|
|
@@ -120,17 +156,16 @@ void BiquadFilterNode::setNormalizedCoefficients(
|
|
|
120
156
|
|
|
121
157
|
void BiquadFilterNode::setLowpassCoefficients(float frequency, float Q) {
|
|
122
158
|
// Limit frequency to [0, 1] range
|
|
123
|
-
if (frequency >= 1.
|
|
159
|
+
if (frequency >= 1.0f) {
|
|
124
160
|
setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
125
161
|
return;
|
|
126
162
|
}
|
|
127
163
|
|
|
128
|
-
if (frequency <= 0.
|
|
164
|
+
if (frequency <= 0.0f) {
|
|
129
165
|
setNormalizedCoefficients(0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
130
166
|
return;
|
|
131
167
|
}
|
|
132
168
|
|
|
133
|
-
Q = std::max(0.0f, Q);
|
|
134
169
|
float g = std::pow(10.0f, 0.05f * Q);
|
|
135
170
|
|
|
136
171
|
float theta = PI * frequency;
|
|
@@ -143,16 +178,15 @@ void BiquadFilterNode::setLowpassCoefficients(float frequency, float Q) {
|
|
|
143
178
|
}
|
|
144
179
|
|
|
145
180
|
void BiquadFilterNode::setHighpassCoefficients(float frequency, float Q) {
|
|
146
|
-
if (frequency >= 1.
|
|
181
|
+
if (frequency >= 1.0f) {
|
|
147
182
|
setNormalizedCoefficients(0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
148
183
|
return;
|
|
149
184
|
}
|
|
150
|
-
if (frequency <= 0.
|
|
185
|
+
if (frequency <= 0.0f) {
|
|
151
186
|
setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
152
187
|
return;
|
|
153
188
|
}
|
|
154
189
|
|
|
155
|
-
Q = std::max(0.0f, Q);
|
|
156
190
|
float g = std::pow(10.0f, 0.05f * Q);
|
|
157
191
|
|
|
158
192
|
float theta = PI * frequency;
|
|
@@ -166,13 +200,13 @@ void BiquadFilterNode::setHighpassCoefficients(float frequency, float Q) {
|
|
|
166
200
|
|
|
167
201
|
void BiquadFilterNode::setBandpassCoefficients(float frequency, float Q) {
|
|
168
202
|
// Limit frequency to [0, 1] range
|
|
169
|
-
if (frequency <= 0.
|
|
203
|
+
if (frequency <= 0.0f || frequency >= 1.0f) {
|
|
170
204
|
setNormalizedCoefficients(0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
171
205
|
return;
|
|
172
206
|
}
|
|
173
207
|
|
|
174
208
|
// Limit Q to positive values
|
|
175
|
-
if (Q <= 0.
|
|
209
|
+
if (Q <= 0.0f) {
|
|
176
210
|
setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
177
211
|
return;
|
|
178
212
|
}
|
|
@@ -188,12 +222,12 @@ void BiquadFilterNode::setBandpassCoefficients(float frequency, float Q) {
|
|
|
188
222
|
void BiquadFilterNode::setLowshelfCoefficients(float frequency, float gain) {
|
|
189
223
|
float A = std::pow(10.0f, gain / 40.0f);
|
|
190
224
|
|
|
191
|
-
if (frequency >= 1.
|
|
225
|
+
if (frequency >= 1.0f) {
|
|
192
226
|
setNormalizedCoefficients(A * A, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
193
227
|
return;
|
|
194
228
|
}
|
|
195
229
|
|
|
196
|
-
if (frequency <= 0.
|
|
230
|
+
if (frequency <= 0.0f) {
|
|
197
231
|
setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
198
232
|
return;
|
|
199
233
|
}
|
|
@@ -215,12 +249,12 @@ void BiquadFilterNode::setLowshelfCoefficients(float frequency, float gain) {
|
|
|
215
249
|
void BiquadFilterNode::setHighshelfCoefficients(float frequency, float gain) {
|
|
216
250
|
float A = std::pow(10.0f, gain / 40.0f);
|
|
217
251
|
|
|
218
|
-
if (frequency >= 1.
|
|
252
|
+
if (frequency >= 1.0f) {
|
|
219
253
|
setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
220
254
|
return;
|
|
221
255
|
}
|
|
222
256
|
|
|
223
|
-
if (frequency <= 0.
|
|
257
|
+
if (frequency <= 0.0f) {
|
|
224
258
|
setNormalizedCoefficients(A * A, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
225
259
|
return;
|
|
226
260
|
}
|
|
@@ -247,12 +281,12 @@ void BiquadFilterNode::setPeakingCoefficients(
|
|
|
247
281
|
float gain) {
|
|
248
282
|
float A = std::pow(10.0f, gain / 40.0f);
|
|
249
283
|
|
|
250
|
-
if (frequency <= 0.
|
|
284
|
+
if (frequency <= 0.0f || frequency >= 1.0f) {
|
|
251
285
|
setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
252
286
|
return;
|
|
253
287
|
}
|
|
254
288
|
|
|
255
|
-
if (Q <= 0.
|
|
289
|
+
if (Q <= 0.0f) {
|
|
256
290
|
setNormalizedCoefficients(A * A, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
257
291
|
return;
|
|
258
292
|
}
|
|
@@ -271,12 +305,12 @@ void BiquadFilterNode::setPeakingCoefficients(
|
|
|
271
305
|
}
|
|
272
306
|
|
|
273
307
|
void BiquadFilterNode::setNotchCoefficients(float frequency, float Q) {
|
|
274
|
-
if (frequency <= 0.
|
|
308
|
+
if (frequency <= 0.0f || frequency >= 1.0f) {
|
|
275
309
|
setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
276
310
|
return;
|
|
277
311
|
}
|
|
278
312
|
|
|
279
|
-
if (Q <= 0.
|
|
313
|
+
if (Q <= 0.0f) {
|
|
280
314
|
setNormalizedCoefficients(0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
281
315
|
return;
|
|
282
316
|
}
|
|
@@ -290,12 +324,12 @@ void BiquadFilterNode::setNotchCoefficients(float frequency, float Q) {
|
|
|
290
324
|
}
|
|
291
325
|
|
|
292
326
|
void BiquadFilterNode::setAllpassCoefficients(float frequency, float Q) {
|
|
293
|
-
if (frequency <= 0.
|
|
327
|
+
if (frequency <= 0.0f || frequency >= 1.0f) {
|
|
294
328
|
setNormalizedCoefficients(1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
295
329
|
return;
|
|
296
330
|
}
|
|
297
331
|
|
|
298
|
-
if (Q <= 0.
|
|
332
|
+
if (Q <= 0.0f) {
|
|
299
333
|
setNormalizedCoefficients(-1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f);
|
|
300
334
|
return;
|
|
301
335
|
}
|
|
@@ -318,6 +352,9 @@ void BiquadFilterNode::applyFilter() {
|
|
|
318
352
|
auto Q = QParam_->processKRateParam(RENDER_QUANTUM_SIZE, currentTime);
|
|
319
353
|
auto gain = gainParam_->processKRateParam(RENDER_QUANTUM_SIZE, currentTime);
|
|
320
354
|
|
|
355
|
+
// NyquistFrequency is half of the sample rate.
|
|
356
|
+
// Normalized frequency is therefore:
|
|
357
|
+
// frequency / (sampleRate / 2) = (2 * frequency) / sampleRate
|
|
321
358
|
float normalizedFrequency = frequency / context_->getNyquistFrequency();
|
|
322
359
|
if (detune != 0.0f) {
|
|
323
360
|
normalizedFrequency *= std::pow(2.0f, detune / 1200.0f);
|
|
@@ -1,8 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2010 Google Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Redistribution and use in source and binary forms, with or without
|
|
5
|
+
* modification, are permitted provided that the following conditions
|
|
6
|
+
* are met:
|
|
7
|
+
*
|
|
8
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
9
|
+
* notice, this list of conditions and the following disclaimer.
|
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
11
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
12
|
+
* documentation and/or other materials provided with the distribution.
|
|
13
|
+
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
|
|
14
|
+
* its contributors may be used to endorse or promote products derived
|
|
15
|
+
* from this software without specific prior written permission.
|
|
16
|
+
*
|
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
|
|
18
|
+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
+
* DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
|
|
21
|
+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
22
|
+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
23
|
+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
24
|
+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
25
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
26
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
*/
|
|
28
|
+
|
|
1
29
|
#pragma once
|
|
2
30
|
|
|
3
31
|
#include <audioapi/core/AudioNode.h>
|
|
4
32
|
#include <audioapi/core/AudioParam.h>
|
|
5
33
|
#include <audioapi/core/types/BiquadFilterType.h>
|
|
34
|
+
#ifdef AUDIO_API_TEST_SUITE
|
|
35
|
+
#include <gtest/gtest_prod.h>
|
|
36
|
+
#endif
|
|
6
37
|
|
|
7
38
|
#include <algorithm>
|
|
8
39
|
#include <cmath>
|
|
@@ -17,6 +48,11 @@ namespace audioapi {
|
|
|
17
48
|
class AudioBus;
|
|
18
49
|
|
|
19
50
|
class BiquadFilterNode : public AudioNode {
|
|
51
|
+
#ifdef AUDIO_API_TEST_SUITE
|
|
52
|
+
friend class BiquadFilterTest;
|
|
53
|
+
FRIEND_TEST(BiquadFilterTest, GetFrequencyResponse);
|
|
54
|
+
#endif
|
|
55
|
+
|
|
20
56
|
public:
|
|
21
57
|
explicit BiquadFilterNode(BaseAudioContext *context);
|
|
22
58
|
|
|
@@ -30,7 +66,7 @@ class BiquadFilterNode : public AudioNode {
|
|
|
30
66
|
const float *frequencyArray,
|
|
31
67
|
float *magResponseOutput,
|
|
32
68
|
float *phaseResponseOutput,
|
|
33
|
-
|
|
69
|
+
size_t length);
|
|
34
70
|
|
|
35
71
|
protected:
|
|
36
72
|
std::shared_ptr<AudioBus> processNode(
|