react-native-audio-api 0.10.0-nightly-e16d7ff-20251030 → 0.11.0-alpha.1
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/RNAudioAPI.podspec +11 -16
- package/android/build.gradle +3 -33
- package/android/src/main/cpp/audioapi/CMakeLists.txt +0 -6
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.cpp +0 -5
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.h +0 -1
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +142 -28
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +40 -13
- package/android/src/main/cpp/audioapi/android/core/AudioPlayer.cpp +2 -4
- package/android/src/main/cpp/audioapi/android/core/NativeAudioRecorder.hpp +9 -9
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidFileWriterBackend.h +37 -0
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.cpp +187 -0
- package/android/src/main/cpp/audioapi/android/core/utils/AndroidRecorderCallback.h +57 -0
- package/android/src/main/cpp/audioapi/android/core/utils/AudioDecoder.cpp +0 -6
- package/android/src/main/cpp/audioapi/android/core/utils/FileUtils.h +34 -0
- package/android/src/main/cpp/audioapi/android/core/utils/FileUtilts.cpp +133 -0
- package/android/src/main/cpp/audioapi/android/core/utils/MiniaudioImplementation.cpp +3 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.cpp +154 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegAudioFileOptions.h +41 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.cpp +429 -0
- package/android/src/main/cpp/audioapi/android/core/utils/ffmpegBackend/FFmpegFileWriter.h +113 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.cpp +47 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileOptions.h +28 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.cpp +269 -0
- package/android/src/main/cpp/audioapi/android/core/utils/miniaudioBackend/MiniAudioFileWriter.h +47 -0
- package/android/src/main/cpp/audioapi/android/system/NativeFileInfo.hpp +31 -0
- package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +3 -29
- package/android/src/main/java/com/swmansion/audioapi/system/AudioFocusListener.kt +9 -21
- package/android/src/main/java/com/swmansion/audioapi/system/LockScreenManager.kt +6 -27
- package/android/src/main/java/com/swmansion/audioapi/system/MediaNotificationManager.kt +0 -11
- package/android/src/main/java/com/swmansion/audioapi/system/NativeFileInfo.kt +18 -0
- 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/AudioAPIModuleInstaller.h +2 -30
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +0 -18
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +0 -1
- package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.cpp +1 -1
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +97 -18
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.h +18 -6
- package/common/cpp/audioapi/core/AudioNode.h +2 -3
- package/common/cpp/audioapi/core/AudioParam.cpp +2 -2
- package/common/cpp/audioapi/core/BaseAudioContext.cpp +0 -10
- package/common/cpp/audioapi/core/BaseAudioContext.h +0 -2
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +32 -69
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +1 -37
- package/common/cpp/audioapi/core/inputs/AudioRecorder.cpp +36 -82
- package/common/cpp/audioapi/core/inputs/AudioRecorder.h +52 -31
- package/common/cpp/audioapi/core/sources/StreamerNode.cpp +58 -59
- package/common/cpp/audioapi/core/sources/StreamerNode.h +8 -37
- package/common/cpp/audioapi/core/utils/AudioNodeManager.cpp +0 -5
- package/common/cpp/audioapi/core/utils/Constants.h +1 -2
- package/common/cpp/audioapi/core/utils/worklets/SafeIncludes.h +10 -0
- package/common/cpp/audioapi/dsp/AudioUtils.cpp +1 -1
- package/common/cpp/audioapi/dsp/FFT.cpp +26 -0
- package/common/cpp/audioapi/dsp/FFT.h +2 -26
- 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/ffmpeg_include/libavcodec/avcodec.h +2 -2
- 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 +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavcodec/codec_par.h +1 -1
- package/common/cpp/audioapi/external/ffmpeg_include/libavformat/avformat.h +2 -2
- package/common/cpp/audioapi/external/ffmpeg_include/libavutil/avutil.h +2 -2
- 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 +44 -0
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/Info.plist +1 -0
- 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 +1 -0
- 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 +44 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/Info.plist +1 -0
- 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 +1 -0
- 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 +44 -0
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/Info.plist +1 -0
- 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 +1 -0
- 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 +44 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/Info.plist +1 -0
- 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 +1 -0
- 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/FFmpegDecoding.cpp +3 -2
- package/common/cpp/audioapi/libs/ffmpeg/INSTRUCTIONS.md +32 -0
- package/common/cpp/audioapi/libs/ffmpeg/create_xcframework.sh +111 -0
- package/common/cpp/audioapi/libs/ffmpeg/ffmpeg_setup.sh +391 -0
- package/common/cpp/audioapi/utils/AudioBus.cpp +0 -28
- package/common/cpp/audioapi/utils/AudioBus.h +0 -3
- package/common/cpp/audioapi/utils/ThreadPool.hpp +1 -59
- package/common/cpp/test/CMakeLists.txt +14 -19
- package/ios/audioapi/ios/AudioAPIModule.h +1 -2
- package/ios/audioapi/ios/AudioAPIModule.mm +0 -2
- package/ios/audioapi/ios/core/IOSAudioFileOptions.h +36 -0
- package/ios/audioapi/ios/core/IOSAudioFileOptions.mm +140 -0
- package/ios/audioapi/ios/core/IOSAudioFileWriter.h +51 -0
- package/ios/audioapi/ios/core/IOSAudioFileWriter.mm +223 -0
- package/ios/audioapi/ios/core/IOSAudioRecorder.h +28 -10
- package/ios/audioapi/ios/core/IOSAudioRecorder.mm +117 -30
- package/ios/audioapi/ios/core/IOSRecorderCallback.h +57 -0
- package/ios/audioapi/ios/core/IOSRecorderCallback.mm +189 -0
- package/ios/audioapi/ios/core/NativeAudioRecorder.h +4 -9
- package/ios/audioapi/ios/core/NativeAudioRecorder.m +29 -71
- package/ios/audioapi/ios/core/utils/AudioDecoder.mm +1 -0
- package/ios/audioapi/ios/system/AudioEngine.mm +3 -3
- package/ios/audioapi/ios/system/AudioSessionManager.mm +0 -9
- package/ios/audioapi/ios/system/LockScreenManager.h +1 -0
- package/ios/audioapi/ios/system/LockScreenManager.mm +19 -6
- package/lib/commonjs/api.js +76 -141
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/api.web.js +0 -8
- 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 +171 -13
- package/lib/commonjs/core/AudioRecorder.js.map +1 -1
- package/lib/commonjs/core/BaseAudioContext.js +25 -28
- package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
- package/lib/commonjs/core/OfflineAudioContext.js +1 -1
- package/lib/commonjs/core/OfflineAudioContext.js.map +1 -1
- package/lib/commonjs/types.js +46 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/bitEnums.js +33 -0
- package/lib/commonjs/utils/bitEnums.js.map +1 -0
- package/lib/commonjs/utils/index.js +21 -19
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/web-core/AudioContext.js +0 -12
- package/lib/commonjs/web-core/AudioContext.js.map +1 -1
- package/lib/commonjs/web-core/OfflineAudioContext.js +0 -12
- package/lib/commonjs/web-core/OfflineAudioContext.js.map +1 -1
- package/lib/module/api.js +15 -16
- package/lib/module/api.js.map +1 -1
- package/lib/module/api.web.js +0 -1
- 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 +171 -13
- package/lib/module/core/AudioRecorder.js.map +1 -1
- package/lib/module/core/BaseAudioContext.js +26 -29
- package/lib/module/core/BaseAudioContext.js.map +1 -1
- package/lib/module/core/OfflineAudioContext.js +2 -2
- package/lib/module/core/OfflineAudioContext.js.map +1 -1
- package/lib/module/types.js +45 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/bitEnums.js +27 -0
- package/lib/module/utils/bitEnums.js.map +1 -0
- package/lib/module/utils/index.js +2 -15
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/web-core/AudioContext.js +0 -12
- package/lib/module/web-core/AudioContext.js.map +1 -1
- package/lib/module/web-core/OfflineAudioContext.js +0 -12
- package/lib/module/web-core/OfflineAudioContext.js.map +1 -1
- package/lib/typescript/api.d.ts +17 -19
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/api.web.d.ts +0 -1
- 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 +62 -7
- package/lib/typescript/core/AudioRecorder.d.ts.map +1 -1
- package/lib/typescript/core/BaseAudioContext.d.ts +1 -3
- package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/events/types.d.ts +16 -0
- package/lib/typescript/events/types.d.ts.map +1 -1
- package/lib/typescript/interfaces.d.ts +42 -9
- package/lib/typescript/interfaces.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +79 -8
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/utils/bitEnums.d.ts +4 -0
- package/lib/typescript/utils/bitEnums.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts +2 -5
- package/lib/typescript/utils/index.d.ts.map +1 -1
- package/lib/typescript/web-core/AudioContext.d.ts +0 -3
- package/lib/typescript/web-core/AudioContext.d.ts.map +1 -1
- package/lib/typescript/web-core/BaseAudioContext.d.ts +0 -2
- package/lib/typescript/web-core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/web-core/OfflineAudioContext.d.ts +0 -3
- package/lib/typescript/web-core/OfflineAudioContext.d.ts.map +1 -1
- package/package.json +4 -7
- package/src/api.ts +18 -45
- package/src/api.web.ts +0 -1
- package/src/core/AudioContext.ts +2 -3
- package/src/core/AudioRecorder.ts +211 -24
- package/src/core/BaseAudioContext.ts +60 -67
- package/src/core/OfflineAudioContext.ts +2 -2
- package/src/events/types.ts +18 -0
- package/src/interfaces.ts +52 -16
- package/src/types.ts +90 -9
- package/src/utils/bitEnums.ts +51 -0
- package/src/utils/index.ts +2 -22
- package/src/web-core/AudioContext.tsx +0 -25
- package/src/web-core/BaseAudioContext.tsx +0 -2
- package/src/web-core/OfflineAudioContext.tsx +0 -25
- package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.cpp +0 -47
- package/common/cpp/audioapi/HostObjects/effects/ConvolverNodeHostObject.h +0 -20
- package/common/cpp/audioapi/core/effects/ConvolverNode.cpp +0 -210
- package/common/cpp/audioapi/core/effects/ConvolverNode.h +0 -55
- package/common/cpp/audioapi/dsp/Convolver.cpp +0 -213
- package/common/cpp/audioapi/dsp/Convolver.h +0 -45
- package/common/cpp/audioapi/libs/ffmpeg/relinking.md +0 -24
- package/common/cpp/audioapi/utils/AlignedAllocator.hpp +0 -50
- package/common/cpp/test/src/biquad/BiquadFilterChromium.cpp +0 -389
- package/common/cpp/test/src/biquad/BiquadFilterChromium.h +0 -64
- package/common/cpp/test/src/biquad/BiquadFilterTest.cpp +0 -284
- package/common/cpp/test/src/biquad/BiquadFilterTest.h +0 -40
- package/lib/commonjs/core/ConvolverNode.js +0 -37
- package/lib/commonjs/core/ConvolverNode.js.map +0 -1
- package/lib/commonjs/web-core/ConvolverNode.js +0 -40
- package/lib/commonjs/web-core/ConvolverNode.js.map +0 -1
- package/lib/commonjs/web-core/ConvolverNodeOptions.js +0 -6
- package/lib/commonjs/web-core/ConvolverNodeOptions.js.map +0 -1
- package/lib/module/core/ConvolverNode.js +0 -31
- package/lib/module/core/ConvolverNode.js.map +0 -1
- package/lib/module/web-core/ConvolverNode.js +0 -34
- package/lib/module/web-core/ConvolverNode.js.map +0 -1
- package/lib/module/web-core/ConvolverNodeOptions.js +0 -4
- package/lib/module/web-core/ConvolverNodeOptions.js.map +0 -1
- package/lib/typescript/core/ConvolverNode.d.ts +0 -12
- package/lib/typescript/core/ConvolverNode.d.ts.map +0 -1
- package/lib/typescript/web-core/ConvolverNode.d.ts +0 -11
- package/lib/typescript/web-core/ConvolverNode.d.ts.map +0 -1
- package/lib/typescript/web-core/ConvolverNodeOptions.d.ts +0 -6
- package/lib/typescript/web-core/ConvolverNodeOptions.d.ts.map +0 -1
- package/scripts/download-prebuilt-binaries.sh +0 -52
- package/scripts/rnaa_utils.rb +0 -8
- package/scripts/validate-worklets-version.js +0 -28
- package/src/core/ConvolverNode.ts +0 -35
- package/src/web-core/ConvolverNode.tsx +0 -43
- package/src/web-core/ConvolverNodeOptions.tsx +0 -6
|
@@ -1,82 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
void AudioRecorder::
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
body.insert({"buffer", audioBufferHostObject});
|
|
38
|
-
body.insert({"numFrames", numFrames});
|
|
39
|
-
|
|
40
|
-
if (audioEventHandlerRegistry_ != nullptr) {
|
|
41
|
-
audioEventHandlerRegistry_->invokeHandlerWithEventBody(
|
|
42
|
-
"audioReady", onAudioReadyCallbackId_, body);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
void AudioRecorder::sendRemainingData() {
|
|
47
|
-
auto bus = std::make_shared<AudioBus>(
|
|
48
|
-
circularBuffer_->getNumberOfAvailableFrames(), 1, sampleRate_);
|
|
49
|
-
auto *outputChannel = bus->getChannel(0)->getData();
|
|
50
|
-
auto availableFrames =
|
|
51
|
-
static_cast<int>(circularBuffer_->getNumberOfAvailableFrames());
|
|
52
|
-
|
|
53
|
-
circularBuffer_->pop_front(
|
|
54
|
-
outputChannel, circularBuffer_->getNumberOfAvailableFrames());
|
|
55
|
-
|
|
56
|
-
invokeOnAudioReadyCallback(bus, availableFrames);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
void AudioRecorder::connect(const std::shared_ptr<RecorderAdapterNode> &node) {
|
|
60
|
-
node->init(ringBufferSize_);
|
|
61
|
-
adapterNodeLock_.lock();
|
|
62
|
-
adapterNode_ = node;
|
|
63
|
-
adapterNodeLock_.unlock();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
void AudioRecorder::disconnect() {
|
|
67
|
-
adapterNodeLock_.lock();
|
|
68
|
-
adapterNode_ = nullptr;
|
|
69
|
-
adapterNodeLock_.unlock();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
void AudioRecorder::writeToBuffers(const float *data, int numFrames) {
|
|
73
|
-
if (adapterNodeLock_.try_lock()) {
|
|
74
|
-
if (adapterNode_ != nullptr) {
|
|
75
|
-
adapterNode_->buff_->write(data, numFrames);
|
|
76
|
-
}
|
|
77
|
-
adapterNodeLock_.unlock();
|
|
78
|
-
}
|
|
79
|
-
circularBuffer_->push_back(data, numFrames);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
} // namespace audioapi
|
|
1
|
+
// void AudioRecorder::connect(const std::shared_ptr<RecorderAdapterNode> &node)
|
|
2
|
+
// { node->init(); adapterNodeLock_.lock(); adapterNode_ = node;
|
|
3
|
+
// adapterNodeLock_.unlock();
|
|
4
|
+
// isConnected_.store(true);
|
|
5
|
+
// node->init(ringBufferSize_);
|
|
6
|
+
// adapterNodeLock_.lock();
|
|
7
|
+
// adapterNode_ = node;
|
|
8
|
+
// adapterNodeLock_.unlock();
|
|
9
|
+
// }
|
|
10
|
+
|
|
11
|
+
// void AudioRecorder::disconnect() {
|
|
12
|
+
// adapterNodeLock_.lock();
|
|
13
|
+
// adapterNode_ = nullptr;
|
|
14
|
+
// adapterNodeLock_.unlock();
|
|
15
|
+
// isConnected_.store(false);
|
|
16
|
+
// }
|
|
17
|
+
|
|
18
|
+
// AudioRecorder::AudioRecorder(
|
|
19
|
+
// const std::shared_ptr<AudioEventHandlerRegistry>
|
|
20
|
+
// &audioEventHandlerRegistry)
|
|
21
|
+
// audioEventHandlerRegistry_(audioEventHandlerRegistry) {
|
|
22
|
+
// constexpr int minRingBufferSize = 8192;
|
|
23
|
+
// ringBufferSize_ = std::max(2 * bufferLength, minRingBufferSize);
|
|
24
|
+
|
|
25
|
+
// circularBuffer_ = std::make_shared<CircularAudioArray>(ringBufferSize_);
|
|
26
|
+
// state_.store(RecorderState::Idle);
|
|
27
|
+
// }
|
|
28
|
+
|
|
29
|
+
// void AudioRecorder::writeToBuffers(const float *data, int numFrames) {
|
|
30
|
+
// if (adapterNodeLock_.try_lock()) {
|
|
31
|
+
// if (adapterNode_ != nullptr) {
|
|
32
|
+
// adapterNode_->buff_->write(data, numFrames);
|
|
33
|
+
// }
|
|
34
|
+
// adapterNodeLock_.unlock();
|
|
35
|
+
// }
|
|
36
|
+
// }
|
|
@@ -3,61 +3,82 @@
|
|
|
3
3
|
#include <memory>
|
|
4
4
|
#include <atomic>
|
|
5
5
|
#include <mutex>
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <tuple>
|
|
6
8
|
|
|
7
9
|
namespace audioapi {
|
|
8
10
|
|
|
9
11
|
class RecorderAdapterNode;
|
|
10
12
|
class AudioBus;
|
|
11
13
|
class CircularAudioArray;
|
|
12
|
-
class CircularOverflowableAudioArray;
|
|
13
14
|
class AudioEventHandlerRegistry;
|
|
14
15
|
|
|
15
16
|
class AudioRecorder {
|
|
16
17
|
public:
|
|
17
|
-
|
|
18
|
+
enum RecorderState { Idle, Recording, Paused };
|
|
19
|
+
explicit AudioRecorder(const std::shared_ptr<AudioEventHandlerRegistry> &audioEventHandlerRegistry):
|
|
20
|
+
audioEventHandlerRegistry_(audioEventHandlerRegistry) {}
|
|
21
|
+
virtual ~AudioRecorder() = default;
|
|
22
|
+
|
|
23
|
+
virtual std::string start() = 0;
|
|
24
|
+
virtual std::tuple<std::string, double, double> stop() = 0;
|
|
25
|
+
|
|
26
|
+
virtual void enableFileOutput(
|
|
18
27
|
float sampleRate,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
28
|
+
size_t channelCount,
|
|
29
|
+
size_t bitRate,
|
|
30
|
+
size_t iosFlags,
|
|
31
|
+
size_t androidFlags) = 0;
|
|
32
|
+
virtual void disableFileOutput() = 0;
|
|
22
33
|
|
|
23
|
-
virtual
|
|
34
|
+
virtual void pause() = 0;
|
|
35
|
+
virtual void resume() = 0;
|
|
36
|
+
|
|
37
|
+
void connect(const std::shared_ptr<RecorderAdapterNode> &node) {}
|
|
38
|
+
void disconnect() {}
|
|
24
39
|
|
|
25
|
-
void
|
|
26
|
-
|
|
27
|
-
|
|
40
|
+
virtual void setOnAudioReadyCallback(
|
|
41
|
+
float sampleRate,
|
|
42
|
+
size_t bufferLength,
|
|
43
|
+
size_t channelCount,
|
|
44
|
+
uint64_t callbackId) = 0;
|
|
45
|
+
virtual void clearOnAudioReadyCallback() = 0;
|
|
46
|
+
|
|
47
|
+
virtual double getCurrentDuration() const = 0;
|
|
48
|
+
|
|
49
|
+
bool usesCallback() const {
|
|
50
|
+
return callbackOutputEnabled_.load();
|
|
51
|
+
}
|
|
28
52
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/// The adapter node will be used to read audio data from the recorder.
|
|
33
|
-
/// @note Few frames of audio might not yet be written to the buffer when connecting.
|
|
34
|
-
void connect(const std::shared_ptr<RecorderAdapterNode> &node);
|
|
53
|
+
bool usesFileOutput() const {
|
|
54
|
+
return fileOutputEnabled_.load();
|
|
55
|
+
}
|
|
35
56
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
/// The adapter node will no longer be used to read audio data from the recorder.
|
|
40
|
-
/// @note Last few frames of audio might be written to the buffer after disconnecting.
|
|
41
|
-
void disconnect();
|
|
57
|
+
bool isConnected() const {
|
|
58
|
+
return isConnected_.load();
|
|
59
|
+
}
|
|
42
60
|
|
|
43
|
-
|
|
44
|
-
|
|
61
|
+
bool isRecording() const {
|
|
62
|
+
return state_.load() == RecorderState::Recording;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
bool isPaused() const {
|
|
66
|
+
return state_.load() == RecorderState::Paused;
|
|
67
|
+
}
|
|
45
68
|
|
|
46
69
|
protected:
|
|
47
|
-
|
|
48
|
-
int bufferLength_;
|
|
49
|
-
size_t ringBufferSize_;
|
|
70
|
+
// size_t ringBufferSize_;
|
|
50
71
|
|
|
51
|
-
std::atomic<
|
|
52
|
-
std::
|
|
72
|
+
std::atomic<RecorderState> state_{ RecorderState::Idle };
|
|
73
|
+
std::atomic<bool> fileOutputEnabled_{false};
|
|
74
|
+
std::atomic<bool> callbackOutputEnabled_{false};
|
|
75
|
+
std::atomic<bool> isConnected_{false};
|
|
76
|
+
// std::shared_ptr<CircularAudioArray> circularBuffer_;
|
|
53
77
|
|
|
54
78
|
mutable std::mutex adapterNodeLock_;
|
|
55
79
|
std::shared_ptr<RecorderAdapterNode> adapterNode_ = nullptr;
|
|
56
80
|
|
|
57
81
|
std::shared_ptr<AudioEventHandlerRegistry> audioEventHandlerRegistry_;
|
|
58
|
-
uint64_t onAudioReadyCallbackId_ = 0;
|
|
59
|
-
|
|
60
|
-
void writeToBuffers(const float *data, int numFrames);
|
|
61
82
|
};
|
|
62
83
|
|
|
63
84
|
} // namespace audioapi
|
|
@@ -25,12 +25,14 @@ StreamerNode::StreamerNode(BaseAudioContext *context)
|
|
|
25
25
|
codecpar_(nullptr),
|
|
26
26
|
pkt_(nullptr),
|
|
27
27
|
frame_(nullptr),
|
|
28
|
+
pendingFrame_(nullptr),
|
|
28
29
|
bufferedBus_(nullptr),
|
|
30
|
+
bufferedBusIndex_(0),
|
|
31
|
+
maxBufferSize_(0),
|
|
29
32
|
audio_stream_index_(-1),
|
|
30
33
|
swrCtx_(nullptr),
|
|
31
34
|
resampledData_(nullptr),
|
|
32
|
-
maxResampledSamples_(0)
|
|
33
|
-
processedSamples_(0) {}
|
|
35
|
+
maxResampledSamples_(0) {}
|
|
34
36
|
|
|
35
37
|
StreamerNode::~StreamerNode() {
|
|
36
38
|
cleanup();
|
|
@@ -64,30 +66,24 @@ bool StreamerNode::initialize(const std::string &input_url) {
|
|
|
64
66
|
return false;
|
|
65
67
|
}
|
|
66
68
|
|
|
69
|
+
maxBufferSize_ = BUFFER_LENGTH_SECONDS * codecCtx_->sample_rate;
|
|
70
|
+
// If decoding is faster than playing, we buffer few seconds of audio
|
|
71
|
+
bufferedBus_ = std::make_shared<AudioBus>(
|
|
72
|
+
maxBufferSize_, codecpar_->ch_layout.nb_channels, codecCtx_->sample_rate);
|
|
73
|
+
|
|
67
74
|
channelCount_ = codecpar_->ch_layout.nb_channels;
|
|
68
75
|
audioBus_ = std::make_shared<AudioBus>(
|
|
69
76
|
RENDER_QUANTUM_SIZE, channelCount_, context_->getSampleRate());
|
|
70
77
|
|
|
71
|
-
auto [sender, receiver] = channels::spsc::channel<
|
|
72
|
-
StreamingData,
|
|
73
|
-
channels::spsc::OverflowStrategy::WAIT_ON_FULL,
|
|
74
|
-
channels::spsc::WaitStrategy::ATOMIC_WAIT>(CHANNEL_CAPACITY);
|
|
75
|
-
sender_ = std::move(sender);
|
|
76
|
-
receiver_ = std::move(receiver);
|
|
77
|
-
|
|
78
78
|
streamingThread_ = std::thread(&StreamerNode::streamAudio, this);
|
|
79
|
-
streamFlag.store(true
|
|
79
|
+
streamFlag.store(true);
|
|
80
80
|
isInitialized_ = true;
|
|
81
81
|
return true;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
void StreamerNode::stop(double when) {
|
|
85
85
|
AudioScheduledSourceNode::stop(when);
|
|
86
|
-
streamFlag.store(false
|
|
87
|
-
StreamingData dummy;
|
|
88
|
-
while (receiver_.try_receive(dummy) ==
|
|
89
|
-
channels::spsc::ResponseStatus::SUCCESS)
|
|
90
|
-
; // clear the receiver
|
|
86
|
+
streamFlag.store(false);
|
|
91
87
|
}
|
|
92
88
|
|
|
93
89
|
bool StreamerNode::setupResampler() {
|
|
@@ -126,22 +122,29 @@ bool StreamerNode::setupResampler() {
|
|
|
126
122
|
}
|
|
127
123
|
|
|
128
124
|
void StreamerNode::streamAudio() {
|
|
129
|
-
while (streamFlag.load(
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
}
|
|
133
|
-
if (pkt_->stream_index == audio_stream_index_) {
|
|
134
|
-
if (avcodec_send_packet(codecCtx_, pkt_) != 0) {
|
|
125
|
+
while (streamFlag.load()) {
|
|
126
|
+
if (pendingFrame_ != nullptr) {
|
|
127
|
+
if (!processFrameWithResampler(pendingFrame_)) {
|
|
135
128
|
return;
|
|
136
129
|
}
|
|
137
|
-
|
|
130
|
+
} else {
|
|
131
|
+
if (av_read_frame(fmtCtx_, pkt_) < 0) {
|
|
138
132
|
return;
|
|
139
133
|
}
|
|
140
|
-
if (
|
|
141
|
-
|
|
134
|
+
if (pkt_->stream_index == audio_stream_index_) {
|
|
135
|
+
if (avcodec_send_packet(codecCtx_, pkt_) != 0) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (avcodec_receive_frame(codecCtx_, frame_) != 0) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (!processFrameWithResampler(frame_)) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
142
144
|
}
|
|
145
|
+
av_packet_unref(pkt_);
|
|
143
146
|
}
|
|
144
|
-
|
|
147
|
+
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
145
148
|
}
|
|
146
149
|
}
|
|
147
150
|
|
|
@@ -157,33 +160,28 @@ std::shared_ptr<AudioBus> StreamerNode::processNode(
|
|
|
157
160
|
return processingBus;
|
|
158
161
|
}
|
|
159
162
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (bufferedBus_ != nullptr) {
|
|
164
|
-
for (int ch = 0; ch < processingBus->getNumberOfChannels(); ch++) {
|
|
165
|
-
memcpy(
|
|
166
|
-
processingBus->getChannel(ch)->getData(),
|
|
167
|
-
bufferedBus_->getChannel(ch)->getData() + processedSamples_,
|
|
168
|
-
bufferRemaining * sizeof(float));
|
|
169
|
-
}
|
|
170
|
-
framesToProcess -= bufferRemaining;
|
|
171
|
-
alreadyProcessed += bufferRemaining;
|
|
172
|
-
}
|
|
173
|
-
StreamingData data;
|
|
174
|
-
receiver_.try_receive(data);
|
|
175
|
-
bufferedBus_ = std::make_shared<AudioBus>(std::move(data.bus));
|
|
176
|
-
bufferedBusSize_ = data.size;
|
|
177
|
-
processedSamples_ = 0;
|
|
178
|
-
}
|
|
179
|
-
if (bufferedBus_ != nullptr) {
|
|
163
|
+
// If we have enough buffered data, copy to output bus
|
|
164
|
+
if (bufferedBusIndex_ >= framesToProcess) {
|
|
165
|
+
Locker locker(mutex_);
|
|
180
166
|
for (int ch = 0; ch < processingBus->getNumberOfChannels(); ch++) {
|
|
181
167
|
memcpy(
|
|
182
|
-
processingBus->getChannel(ch)->getData()
|
|
183
|
-
bufferedBus_->getChannel(ch)->getData()
|
|
184
|
-
|
|
168
|
+
processingBus->getChannel(ch)->getData(),
|
|
169
|
+
bufferedBus_->getChannel(ch)->getData(),
|
|
170
|
+
offsetLength * sizeof(float));
|
|
171
|
+
|
|
172
|
+
memmove(
|
|
173
|
+
bufferedBus_->getChannel(ch)->getData(),
|
|
174
|
+
bufferedBus_->getChannel(ch)->getData() + offsetLength,
|
|
175
|
+
(maxBufferSize_ - offsetLength) * sizeof(float));
|
|
185
176
|
}
|
|
186
|
-
|
|
177
|
+
bufferedBusIndex_ -= offsetLength;
|
|
178
|
+
} else {
|
|
179
|
+
if (VERBOSE)
|
|
180
|
+
printf(
|
|
181
|
+
"Buffer underrun: have %zu, need %zu\n",
|
|
182
|
+
bufferedBusIndex_,
|
|
183
|
+
(size_t)framesToProcess);
|
|
184
|
+
processingBus->zero();
|
|
187
185
|
}
|
|
188
186
|
|
|
189
187
|
return processingBus;
|
|
@@ -222,21 +220,22 @@ bool StreamerNode::processFrameWithResampler(AVFrame *frame) {
|
|
|
222
220
|
return false;
|
|
223
221
|
}
|
|
224
222
|
|
|
225
|
-
// if
|
|
226
|
-
if (
|
|
223
|
+
// Check if converted data fits in buffer
|
|
224
|
+
if (bufferedBusIndex_ + converted_samples > maxBufferSize_) {
|
|
225
|
+
pendingFrame_ = frame;
|
|
227
226
|
return true;
|
|
227
|
+
} else {
|
|
228
|
+
pendingFrame_ = nullptr;
|
|
228
229
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
context_->getSampleRate());
|
|
230
|
+
|
|
231
|
+
// Copy converted data to our buffer
|
|
232
|
+
Locker locker(mutex_);
|
|
233
233
|
for (int ch = 0; ch < codecCtx_->ch_layout.nb_channels; ch++) {
|
|
234
234
|
auto *src = reinterpret_cast<float *>(resampledData_[ch]);
|
|
235
|
-
float *dst =
|
|
235
|
+
float *dst = bufferedBus_->getChannel(ch)->getData() + bufferedBusIndex_;
|
|
236
236
|
memcpy(dst, src, converted_samples * sizeof(float));
|
|
237
237
|
}
|
|
238
|
-
|
|
239
|
-
sender_.send(std::move(data));
|
|
238
|
+
bufferedBusIndex_ += converted_samples;
|
|
240
239
|
return true;
|
|
241
240
|
}
|
|
242
241
|
|
|
@@ -281,7 +280,7 @@ bool StreamerNode::setupDecoder() {
|
|
|
281
280
|
}
|
|
282
281
|
|
|
283
282
|
void StreamerNode::cleanup() {
|
|
284
|
-
streamFlag.store(false
|
|
283
|
+
streamFlag.store(false);
|
|
285
284
|
// cleanup cannot be called from the streaming thread so there is no need to
|
|
286
285
|
// check if we are in the same thread
|
|
287
286
|
streamingThread_.join();
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
#pragma once
|
|
12
12
|
|
|
13
13
|
#include <audioapi/core/sources/AudioScheduledSourceNode.h>
|
|
14
|
-
#include <audioapi/utils/AudioBus.h>
|
|
15
14
|
|
|
16
15
|
#ifndef AUDIO_API_TEST_SUITE
|
|
17
16
|
extern "C" {
|
|
@@ -28,35 +27,8 @@ extern "C" {
|
|
|
28
27
|
#include <memory>
|
|
29
28
|
#include <string>
|
|
30
29
|
#include <atomic>
|
|
31
|
-
#include <utility>
|
|
32
|
-
#ifndef AUDIO_API_TEST_SUITE
|
|
33
|
-
#include <audioapi/utils/SpscChannel.hpp>
|
|
34
30
|
|
|
35
|
-
static constexpr
|
|
36
|
-
audioapi::channels::spsc::OverflowStrategy::WAIT_ON_FULL;
|
|
37
|
-
static constexpr audioapi::channels::spsc::WaitStrategy STREAMER_NODE_SPSC_WAIT_STRATEGY =
|
|
38
|
-
audioapi::channels::spsc::WaitStrategy::ATOMIC_WAIT;
|
|
39
|
-
#endif
|
|
40
|
-
|
|
41
|
-
static constexpr bool VERBOSE = false;
|
|
42
|
-
static constexpr int CHANNEL_CAPACITY = 32;
|
|
43
|
-
|
|
44
|
-
struct StreamingData{
|
|
45
|
-
audioapi::AudioBus bus;
|
|
46
|
-
size_t size;
|
|
47
|
-
StreamingData() = default;
|
|
48
|
-
StreamingData(audioapi::AudioBus b, size_t s) : bus(b), size(s) {}
|
|
49
|
-
StreamingData(const StreamingData& data) : bus(data.bus), size(data.size) {}
|
|
50
|
-
StreamingData(StreamingData&& data) noexcept : bus(std::move(data.bus)), size(data.size) {}
|
|
51
|
-
StreamingData& operator=(const StreamingData& data) {
|
|
52
|
-
if (this == &data) {
|
|
53
|
-
return *this;
|
|
54
|
-
}
|
|
55
|
-
bus = data.bus;
|
|
56
|
-
size = data.size;
|
|
57
|
-
return *this;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
31
|
+
static bool constexpr VERBOSE = false;
|
|
60
32
|
|
|
61
33
|
namespace audioapi {
|
|
62
34
|
|
|
@@ -84,20 +56,19 @@ class StreamerNode : public AudioScheduledSourceNode {
|
|
|
84
56
|
AVCodecParameters* codecpar_;
|
|
85
57
|
AVPacket* pkt_;
|
|
86
58
|
AVFrame* frame_; // Frame that is currently being processed
|
|
87
|
-
|
|
88
|
-
uint8_t** resampledData_; // weird ffmpeg way of using raw byte pointers for resampled data
|
|
89
|
-
|
|
59
|
+
AVFrame* pendingFrame_; // Frame that is saved if bufferedBus is full
|
|
90
60
|
std::shared_ptr<AudioBus> bufferedBus_; // audio bus for buffering hls frames
|
|
91
|
-
size_t
|
|
61
|
+
size_t bufferedBusIndex_; // index in the buffered bus where we write the next frame
|
|
62
|
+
size_t maxBufferSize_; // maximum size of the buffered bus
|
|
92
63
|
int audio_stream_index_; // index of the audio stream channel in the input
|
|
64
|
+
SwrContext* swrCtx_;
|
|
65
|
+
uint8_t** resampledData_; // weird ffmpeg way of using raw byte pointers for resampled data
|
|
93
66
|
int maxResampledSamples_;
|
|
94
|
-
|
|
95
|
-
|
|
67
|
+
std::mutex mutex_;
|
|
96
68
|
std::thread streamingThread_;
|
|
97
69
|
std::atomic<bool> streamFlag; // Flag to control the streaming thread
|
|
70
|
+
static constexpr float BUFFER_LENGTH_SECONDS = 5.0f; // Length of the buffer in seconds
|
|
98
71
|
static constexpr int INITIAL_MAX_RESAMPLED_SAMPLES = 8192; // Initial size for resampled data
|
|
99
|
-
channels::spsc::Sender<StreamingData, STREAMER_NODE_SPSC_OVERFLOW_STRATEGY, STREAMER_NODE_SPSC_WAIT_STRATEGY> sender_;
|
|
100
|
-
channels::spsc::Receiver<StreamingData, STREAMER_NODE_SPSC_OVERFLOW_STRATEGY, STREAMER_NODE_SPSC_WAIT_STRATEGY> receiver_;
|
|
101
72
|
|
|
102
73
|
/**
|
|
103
74
|
* @brief Setting up the resampler
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#include <audioapi/core/AudioNode.h>
|
|
2
2
|
#include <audioapi/core/AudioParam.h>
|
|
3
|
-
#include <audioapi/core/effects/ConvolverNode.h>
|
|
4
3
|
#include <audioapi/core/sources/AudioScheduledSourceNode.h>
|
|
5
4
|
#include <audioapi/core/utils/AudioNodeManager.h>
|
|
6
5
|
#include <audioapi/core/utils/Locker.h>
|
|
@@ -222,10 +221,6 @@ inline bool AudioNodeManager::nodeCanBeDestructed(
|
|
|
222
221
|
if constexpr (std::is_base_of_v<AudioScheduledSourceNode, U>) {
|
|
223
222
|
return node.use_count() == 1 &&
|
|
224
223
|
(node->isUnscheduled() || node->isFinished());
|
|
225
|
-
} else if constexpr (std::is_base_of_v<
|
|
226
|
-
ConvolverNode,
|
|
227
|
-
U>) { // convolver overrides disabling behavior
|
|
228
|
-
return node.use_count() == 1 && !node->isEnabled();
|
|
229
224
|
}
|
|
230
225
|
return node.use_count() == 1;
|
|
231
226
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
-
#include <numbers>
|
|
4
3
|
#include <cmath>
|
|
5
4
|
#include <limits>
|
|
6
5
|
|
|
@@ -20,7 +19,7 @@ static constexpr float MOST_POSITIVE_SINGLE_FLOAT = static_cast<float>(std::nume
|
|
|
20
19
|
static constexpr float MOST_NEGATIVE_SINGLE_FLOAT = static_cast<float>(std::numeric_limits<float>::lowest());
|
|
21
20
|
static float LOG2_MOST_POSITIVE_SINGLE_FLOAT = std::log2(MOST_POSITIVE_SINGLE_FLOAT);
|
|
22
21
|
static float LOG10_MOST_POSITIVE_SINGLE_FLOAT = std::log10(MOST_POSITIVE_SINGLE_FLOAT);
|
|
23
|
-
static constexpr float PI =
|
|
22
|
+
static constexpr float PI = static_cast<float>(M_PI);
|
|
24
23
|
|
|
25
24
|
// buffer sizes
|
|
26
25
|
static constexpr size_t PROMISE_VENDOR_THREAD_POOL_WORKER_COUNT = 4;
|
|
@@ -5,6 +5,16 @@
|
|
|
5
5
|
#include <string>
|
|
6
6
|
#include <memory>
|
|
7
7
|
|
|
8
|
+
#ifdef __APPLE__
|
|
9
|
+
/// We cannot make any conditional logic inside podspec but it should automatically compile those files
|
|
10
|
+
/// they should be accessible if someone has react-native-worklets in node_modules
|
|
11
|
+
#if __has_include(<worklets/WorkletRuntime/WorkletRuntime.h>)
|
|
12
|
+
#define RN_AUDIO_API_ENABLE_WORKLETS 1
|
|
13
|
+
#else
|
|
14
|
+
#define RN_AUDIO_API_ENABLE_WORKLETS 0
|
|
15
|
+
#endif
|
|
16
|
+
#endif
|
|
17
|
+
|
|
8
18
|
#ifndef RN_AUDIO_API_TEST
|
|
9
19
|
#define RN_AUDIO_API_TEST 0
|
|
10
20
|
#endif
|
|
@@ -12,4 +12,30 @@ FFT::~FFT() {
|
|
|
12
12
|
pffft_aligned_free(work_);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
void FFT::doFFT(float *in, std::vector<std::complex<float>> &out) {
|
|
16
|
+
pffft_transform_ordered(
|
|
17
|
+
pffftSetup_,
|
|
18
|
+
in,
|
|
19
|
+
reinterpret_cast<float *>(&out[0]),
|
|
20
|
+
work_,
|
|
21
|
+
PFFFT_FORWARD);
|
|
22
|
+
|
|
23
|
+
dsp::multiplyByScalar(
|
|
24
|
+
reinterpret_cast<float *>(&out[0]),
|
|
25
|
+
0.5f,
|
|
26
|
+
reinterpret_cast<float *>(&out[0]),
|
|
27
|
+
size_ * 2);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
void FFT::doInverseFFT(std::vector<std::complex<float>> &in, float *out) {
|
|
31
|
+
pffft_transform_ordered(
|
|
32
|
+
pffftSetup_,
|
|
33
|
+
reinterpret_cast<float *>(&in[0]),
|
|
34
|
+
out,
|
|
35
|
+
work_,
|
|
36
|
+
PFFFT_BACKWARD);
|
|
37
|
+
|
|
38
|
+
dsp::multiplyByScalar(out, 1.0f / static_cast<float>(size_), out, size_);
|
|
39
|
+
}
|
|
40
|
+
|
|
15
41
|
} // namespace audioapi::dsp
|
|
@@ -16,32 +16,8 @@ class FFT {
|
|
|
16
16
|
explicit FFT(int size);
|
|
17
17
|
~FFT();
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
void
|
|
21
|
-
pffft_transform_ordered(
|
|
22
|
-
pffftSetup_,
|
|
23
|
-
in,
|
|
24
|
-
reinterpret_cast<float *>(&out[0]),
|
|
25
|
-
work_,
|
|
26
|
-
PFFFT_FORWARD);
|
|
27
|
-
// this is a possible place for bugs and mistakes
|
|
28
|
-
// due to pffft implementation and how it stores results
|
|
29
|
-
// keep this information in mind
|
|
30
|
-
// out[0].real = DC component - should be pure real
|
|
31
|
-
// out[0].imag = Nyquist component - should be pure real
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
template<typename Allocator>
|
|
35
|
-
void doInverseFFT(std::vector<std::complex<float>, Allocator> &in, float *out) {
|
|
36
|
-
pffft_transform_ordered(
|
|
37
|
-
pffftSetup_,
|
|
38
|
-
reinterpret_cast<float *>(&in[0]),
|
|
39
|
-
out,
|
|
40
|
-
work_,
|
|
41
|
-
PFFFT_BACKWARD);
|
|
42
|
-
|
|
43
|
-
dsp::multiplyByScalar(out, 1.0f / static_cast<float>(size_), out, size_);
|
|
44
|
-
}
|
|
19
|
+
void doFFT(float *in, std::vector<std::complex<float>> &out);
|
|
20
|
+
void doInverseFFT(std::vector<std::complex<float>> &in, float *out);
|
|
45
21
|
|
|
46
22
|
private:
|
|
47
23
|
int size_;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|