react-native-audio-api 0.8.3 → 0.9.0-nightly-96a5bcd-20251007
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 +40 -39
- package/RNAudioAPI.podspec +17 -12
- package/android/build.gradle +44 -4
- package/android/src/main/cpp/audioapi/CMakeLists.txt +65 -0
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.cpp +29 -1
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.h +14 -0
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +7 -1
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +6 -1
- package/android/src/main/cpp/audioapi/android/core/AudioPlayer.cpp +1 -1
- package/android/src/main/cpp/audioapi/android/core/NativeAudioRecorder.hpp +36 -0
- package/android/src/main/cpp/audioapi/android/core/{AudioDecoder.cpp → utils/AudioDecoder.cpp} +79 -75
- package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +11 -1
- package/android/src/main/java/com/swmansion/audioapi/core/NativeAudioRecorder.kt +24 -0
- package/android/src/main/java/com/swmansion/audioapi/system/MediaSessionManager.kt +15 -2
- package/common/cpp/audioapi/AudioAPIModuleInstaller.h +129 -38
- package/common/cpp/audioapi/HostObjects/AudioContextHostObject.cpp +57 -0
- package/common/cpp/audioapi/HostObjects/AudioContextHostObject.h +6 -46
- package/common/cpp/audioapi/HostObjects/AudioNodeHostObject.cpp +70 -6
- package/common/cpp/audioapi/HostObjects/AudioNodeHostObject.h +10 -66
- package/common/cpp/audioapi/HostObjects/AudioParamHostObject.cpp +105 -0
- package/common/cpp/audioapi/HostObjects/AudioParamHostObject.h +17 -91
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +262 -6
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +26 -241
- package/common/cpp/audioapi/HostObjects/OfflineAudioContextHostObject.cpp +70 -0
- package/common/cpp/audioapi/HostObjects/OfflineAudioContextHostObject.h +6 -50
- package/common/cpp/audioapi/HostObjects/WorkletNodeHostObject.h +18 -0
- package/common/cpp/audioapi/HostObjects/WorkletProcessingNodeHostObject.h +18 -0
- package/common/cpp/audioapi/HostObjects/analysis/AnalyserNodeHostObject.cpp +148 -0
- package/common/cpp/audioapi/HostObjects/analysis/AnalyserNodeHostObject.h +37 -0
- package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.cpp +92 -0
- package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.h +29 -0
- package/common/cpp/audioapi/HostObjects/effects/GainNodeHostObject.cpp +20 -0
- package/common/cpp/audioapi/HostObjects/effects/GainNodeHostObject.h +19 -0
- package/common/cpp/audioapi/HostObjects/effects/StereoPannerNodeHostObject.cpp +21 -0
- package/common/cpp/audioapi/HostObjects/effects/StereoPannerNodeHostObject.h +21 -0
- package/common/cpp/audioapi/HostObjects/events/AudioEventHandlerRegistryHostObject.cpp +41 -0
- package/common/cpp/audioapi/HostObjects/events/AudioEventHandlerRegistryHostObject.h +28 -0
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +69 -0
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.h +33 -0
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferBaseSourceNodeHostObject.cpp +73 -0
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferBaseSourceNodeHostObject.h +29 -0
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferHostObject.cpp +94 -0
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferHostObject.h +46 -0
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferQueueSourceNodeHostObject.cpp +60 -0
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferQueueSourceNodeHostObject.h +25 -0
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferSourceNodeHostObject.cpp +152 -0
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferSourceNodeHostObject.h +37 -0
- package/common/cpp/audioapi/HostObjects/sources/AudioScheduledSourceNodeHostObject.cpp +52 -0
- package/common/cpp/audioapi/HostObjects/sources/AudioScheduledSourceNodeHostObject.h +25 -0
- package/common/cpp/audioapi/HostObjects/sources/ConstantSourceNodeHostObject.cpp +19 -0
- package/common/cpp/audioapi/HostObjects/sources/ConstantSourceNodeHostObject.h +21 -0
- package/common/cpp/audioapi/HostObjects/sources/OscillatorNodeHostObject.cpp +55 -0
- package/common/cpp/audioapi/HostObjects/sources/OscillatorNodeHostObject.h +27 -0
- package/common/cpp/audioapi/HostObjects/{RecorderAdapterNodeHostObject.h → sources/RecorderAdapterNodeHostObject.h} +1 -2
- package/common/cpp/audioapi/HostObjects/sources/StreamerNodeHostObject.cpp +22 -0
- package/common/cpp/audioapi/HostObjects/sources/StreamerNodeHostObject.h +28 -0
- package/common/cpp/audioapi/HostObjects/sources/WorkletSourceNodeHostObject.h +18 -0
- package/common/cpp/audioapi/HostObjects/utils/AudioDecoderHostObject.cpp +107 -0
- package/common/cpp/audioapi/HostObjects/utils/AudioDecoderHostObject.h +28 -0
- package/common/cpp/audioapi/core/AudioContext.cpp +3 -4
- package/common/cpp/audioapi/core/AudioContext.h +2 -1
- package/common/cpp/audioapi/core/AudioNode.cpp +3 -3
- package/common/cpp/audioapi/core/AudioNode.h +2 -2
- package/common/cpp/audioapi/core/AudioParam.cpp +2 -2
- package/common/cpp/audioapi/core/AudioParam.h +1 -1
- package/common/cpp/audioapi/core/BaseAudioContext.cpp +47 -38
- package/common/cpp/audioapi/core/BaseAudioContext.h +17 -16
- package/common/cpp/audioapi/core/OfflineAudioContext.cpp +4 -5
- package/common/cpp/audioapi/core/OfflineAudioContext.h +2 -1
- package/common/cpp/audioapi/core/analysis/AnalyserNode.cpp +3 -1
- package/common/cpp/audioapi/core/analysis/AnalyserNode.h +1 -1
- package/common/cpp/audioapi/core/destinations/AudioDestinationNode.h +1 -1
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +3 -1
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +1 -1
- package/common/cpp/audioapi/core/effects/GainNode.cpp +3 -1
- package/common/cpp/audioapi/core/effects/GainNode.h +1 -1
- package/common/cpp/audioapi/core/effects/PeriodicWave.cpp +1 -1
- package/common/cpp/audioapi/core/effects/StereoPannerNode.cpp +18 -13
- package/common/cpp/audioapi/core/effects/StereoPannerNode.h +1 -1
- package/common/cpp/audioapi/core/effects/WorkletNode.cpp +89 -0
- package/common/cpp/audioapi/core/effects/WorkletNode.h +65 -0
- package/common/cpp/audioapi/core/effects/WorkletProcessingNode.cpp +91 -0
- package/common/cpp/audioapi/core/effects/WorkletProcessingNode.h +52 -0
- package/common/cpp/audioapi/core/inputs/AudioRecorder.cpp +1 -1
- package/common/cpp/audioapi/core/inputs/AudioRecorder.h +2 -2
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.cpp +47 -10
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.h +18 -3
- package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.cpp +98 -14
- package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.h +9 -3
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp +37 -44
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.h +7 -9
- package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.cpp +1 -6
- package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.h +1 -1
- package/common/cpp/audioapi/core/sources/ConstantSourceNode.cpp +53 -0
- package/common/cpp/audioapi/core/sources/ConstantSourceNode.h +26 -0
- package/common/cpp/audioapi/core/sources/OscillatorNode.cpp +7 -2
- package/common/cpp/audioapi/core/sources/OscillatorNode.h +1 -1
- package/common/cpp/audioapi/core/sources/RecorderAdapterNode.cpp +3 -1
- package/common/cpp/audioapi/core/sources/RecorderAdapterNode.h +1 -1
- package/common/cpp/audioapi/core/sources/StreamerNode.cpp +9 -1
- package/common/cpp/audioapi/core/sources/StreamerNode.h +1 -9
- package/common/cpp/audioapi/core/sources/WorkletSourceNode.cpp +84 -0
- package/common/cpp/audioapi/core/sources/WorkletSourceNode.h +47 -0
- package/common/cpp/audioapi/core/types/AudioFormat.h +16 -0
- package/common/cpp/audioapi/core/utils/AudioDecoder.h +36 -90
- package/common/cpp/audioapi/core/{AudioParamEventQueue.cpp → utils/AudioParamEventQueue.cpp} +13 -7
- package/common/cpp/audioapi/core/{Constants.h → utils/Constants.h} +5 -0
- package/common/cpp/audioapi/core/utils/worklets/SafeIncludes.h +52 -0
- package/common/cpp/audioapi/core/utils/worklets/WorkletsRunner.cpp +9 -0
- package/common/cpp/audioapi/core/utils/worklets/WorkletsRunner.h +73 -0
- package/common/cpp/audioapi/dsp/Windows.cpp +1 -1
- package/common/cpp/audioapi/events/AudioEventHandlerRegistry.cpp +1 -1
- package/common/cpp/audioapi/events/AudioEventHandlerRegistry.h +2 -1
- package/common/cpp/audioapi/jsi/AudioArrayBuffer.h +14 -1
- package/common/cpp/audioapi/jsi/JsiHostObject.h +6 -12
- package/common/cpp/audioapi/jsi/JsiPromise.cpp +49 -0
- package/common/cpp/audioapi/jsi/JsiPromise.h +29 -1
- package/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.cpp +241 -282
- package/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.h +57 -19
- package/common/cpp/audioapi/utils/AudioBus.cpp +1 -1
- package/common/cpp/audioapi/utils/ThreadPool.hpp +104 -0
- package/common/cpp/test/AudioParamTest.cpp +204 -0
- package/common/cpp/test/CMakeLists.txt +13 -4
- package/common/cpp/test/GainTest.cpp +11 -10
- package/common/cpp/test/OscillatorTest.cpp +2 -1
- package/common/cpp/test/StereoPannerTest.cpp +129 -0
- package/ios/audioapi/ios/AudioAPIModule.mm +32 -5
- package/ios/audioapi/ios/core/IOSAudioPlayer.mm +1 -1
- package/ios/audioapi/ios/core/IOSAudioRecorder.mm +1 -1
- package/ios/audioapi/ios/core/utils/AudioDecoder.mm +160 -0
- package/lib/commonjs/api.js +50 -3
- 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/AudioBufferBaseSourceNode.js +7 -7
- package/lib/commonjs/core/AudioBufferBaseSourceNode.js.map +1 -1
- package/lib/commonjs/core/AudioBufferQueueSourceNode.js +1 -6
- package/lib/commonjs/core/AudioBufferQueueSourceNode.js.map +1 -1
- package/lib/commonjs/core/AudioBufferSourceNode.js +15 -0
- package/lib/commonjs/core/AudioBufferSourceNode.js.map +1 -1
- package/lib/commonjs/core/AudioContext.js +10 -1
- package/lib/commonjs/core/AudioContext.js.map +1 -1
- package/lib/commonjs/core/AudioDecoder.js +48 -0
- package/lib/commonjs/core/AudioDecoder.js.map +1 -0
- package/lib/commonjs/core/AudioScheduledSourceNode.js +4 -4
- package/lib/commonjs/core/AudioScheduledSourceNode.js.map +1 -1
- package/lib/commonjs/core/BaseAudioContext.js +76 -28
- package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
- package/lib/commonjs/core/ConstantSourceNode.js +17 -0
- package/lib/commonjs/core/ConstantSourceNode.js.map +1 -0
- package/lib/commonjs/core/OfflineAudioContext.js +11 -2
- package/lib/commonjs/core/OfflineAudioContext.js.map +1 -1
- package/lib/commonjs/core/OscillatorNode.js +6 -0
- package/lib/commonjs/core/OscillatorNode.js.map +1 -1
- package/lib/commonjs/core/WorkletNode.js +11 -0
- package/lib/commonjs/core/WorkletNode.js.map +1 -0
- package/lib/commonjs/core/WorkletProcessingNode.js +11 -0
- package/lib/commonjs/core/WorkletProcessingNode.js.map +1 -0
- package/lib/commonjs/core/WorkletSourceNode.js +11 -0
- package/lib/commonjs/core/WorkletSourceNode.js.map +1 -0
- package/lib/commonjs/hooks/{useSytemVolume.js → useSystemVolume.js} +1 -1
- package/lib/commonjs/hooks/useSystemVolume.js.map +1 -0
- package/lib/commonjs/utils/index.js +9 -0
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/web-core/AudioContext.js +4 -0
- package/lib/commonjs/web-core/AudioContext.js.map +1 -1
- package/lib/commonjs/web-core/AudioScheduledSourceNode.js +1 -1
- package/lib/commonjs/web-core/AudioScheduledSourceNode.js.map +1 -1
- package/lib/commonjs/web-core/ConstantSourceNode.js +17 -0
- package/lib/commonjs/web-core/ConstantSourceNode.js.map +1 -0
- package/lib/commonjs/web-core/OfflineAudioContext.js +4 -0
- package/lib/commonjs/web-core/OfflineAudioContext.js.map +1 -1
- package/lib/module/api.js +8 -3
- 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/AudioBufferBaseSourceNode.js +7 -7
- package/lib/module/core/AudioBufferBaseSourceNode.js.map +1 -1
- package/lib/module/core/AudioBufferQueueSourceNode.js +1 -6
- package/lib/module/core/AudioBufferQueueSourceNode.js.map +1 -1
- package/lib/module/core/AudioBufferSourceNode.js +15 -0
- package/lib/module/core/AudioBufferSourceNode.js.map +1 -1
- package/lib/module/core/AudioContext.js +10 -1
- package/lib/module/core/AudioContext.js.map +1 -1
- package/lib/module/core/AudioDecoder.js +42 -0
- package/lib/module/core/AudioDecoder.js.map +1 -0
- package/lib/module/core/AudioScheduledSourceNode.js +4 -4
- package/lib/module/core/AudioScheduledSourceNode.js.map +1 -1
- package/lib/module/core/BaseAudioContext.js +76 -28
- package/lib/module/core/BaseAudioContext.js.map +1 -1
- package/lib/module/core/ConstantSourceNode.js +11 -0
- package/lib/module/core/ConstantSourceNode.js.map +1 -0
- package/lib/module/core/OfflineAudioContext.js +11 -2
- package/lib/module/core/OfflineAudioContext.js.map +1 -1
- package/lib/module/core/OscillatorNode.js +6 -0
- package/lib/module/core/OscillatorNode.js.map +1 -1
- package/lib/module/core/WorkletNode.js +5 -0
- package/lib/module/core/WorkletNode.js.map +1 -0
- package/lib/module/core/WorkletProcessingNode.js +5 -0
- package/lib/module/core/WorkletProcessingNode.js.map +1 -0
- package/lib/module/core/WorkletSourceNode.js +5 -0
- package/lib/module/core/WorkletSourceNode.js.map +1 -0
- package/lib/module/hooks/{useSytemVolume.js → useSystemVolume.js} +1 -1
- package/lib/module/hooks/useSystemVolume.js.map +1 -0
- package/lib/module/utils/index.js +8 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/web-core/AudioContext.js +4 -0
- package/lib/module/web-core/AudioContext.js.map +1 -1
- package/lib/module/web-core/AudioScheduledSourceNode.js +1 -1
- package/lib/module/web-core/AudioScheduledSourceNode.js.map +1 -1
- package/lib/module/web-core/ConstantSourceNode.js +11 -0
- package/lib/module/web-core/ConstantSourceNode.js.map +1 -0
- package/lib/module/web-core/OfflineAudioContext.js +4 -0
- package/lib/module/web-core/OfflineAudioContext.js.map +1 -1
- package/lib/typescript/api.d.ts +11 -5
- 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/AudioBufferBaseSourceNode.d.ts +2 -2
- package/lib/typescript/core/AudioBufferBaseSourceNode.d.ts.map +1 -1
- package/lib/typescript/core/AudioBufferQueueSourceNode.d.ts +1 -1
- package/lib/typescript/core/AudioBufferQueueSourceNode.d.ts.map +1 -1
- package/lib/typescript/core/AudioBufferSourceNode.d.ts +4 -0
- package/lib/typescript/core/AudioBufferSourceNode.d.ts.map +1 -1
- package/lib/typescript/core/AudioContext.d.ts +1 -0
- package/lib/typescript/core/AudioContext.d.ts.map +1 -1
- package/lib/typescript/core/AudioDecoder.d.ts +4 -0
- package/lib/typescript/core/AudioDecoder.d.ts.map +1 -0
- package/lib/typescript/core/AudioScheduledSourceNode.d.ts +1 -1
- package/lib/typescript/core/BaseAudioContext.d.ts +21 -16
- package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/core/ConstantSourceNode.d.ts +9 -0
- package/lib/typescript/core/ConstantSourceNode.d.ts.map +1 -0
- package/lib/typescript/core/OfflineAudioContext.d.ts +1 -0
- package/lib/typescript/core/OfflineAudioContext.d.ts.map +1 -1
- package/lib/typescript/core/OscillatorNode.d.ts +3 -0
- package/lib/typescript/core/OscillatorNode.d.ts.map +1 -1
- package/lib/typescript/core/WorkletNode.d.ts +4 -0
- package/lib/typescript/core/WorkletNode.d.ts.map +1 -0
- package/lib/typescript/core/WorkletProcessingNode.d.ts +4 -0
- package/lib/typescript/core/WorkletProcessingNode.d.ts.map +1 -0
- package/lib/typescript/core/WorkletSourceNode.d.ts +4 -0
- package/lib/typescript/core/WorkletSourceNode.d.ts.map +1 -0
- package/lib/typescript/events/types.d.ts +2 -0
- package/lib/typescript/events/types.d.ts.map +1 -1
- package/lib/typescript/hooks/{useSytemVolume.d.ts → useSystemVolume.d.ts} +1 -1
- package/lib/typescript/hooks/useSystemVolume.d.ts.map +1 -0
- package/lib/typescript/interfaces.d.ts +27 -6
- package/lib/typescript/interfaces.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +2 -1
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/utils/index.d.ts +8 -0
- package/lib/typescript/utils/index.d.ts.map +1 -1
- package/lib/typescript/web-core/AudioBufferSourceNode.d.ts +1 -1
- package/lib/typescript/web-core/AudioContext.d.ts +4 -2
- package/lib/typescript/web-core/AudioContext.d.ts.map +1 -1
- package/lib/typescript/web-core/AudioScheduledSourceNode.d.ts +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/ConstantSourceNode.d.ts +8 -0
- package/lib/typescript/web-core/ConstantSourceNode.d.ts.map +1 -0
- package/lib/typescript/web-core/OfflineAudioContext.d.ts +4 -2
- package/lib/typescript/web-core/OfflineAudioContext.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/api.ts +17 -3
- package/src/api.web.ts +1 -0
- package/src/core/AudioBufferBaseSourceNode.ts +9 -9
- package/src/core/AudioBufferQueueSourceNode.ts +1 -9
- package/src/core/AudioBufferSourceNode.ts +28 -0
- package/src/core/AudioContext.ts +12 -1
- package/src/core/AudioDecoder.ts +78 -0
- package/src/core/AudioScheduledSourceNode.ts +5 -5
- package/src/core/BaseAudioContext.ts +174 -41
- package/src/core/ConstantSourceNode.ts +13 -0
- package/src/core/OfflineAudioContext.ts +18 -2
- package/src/core/OscillatorNode.ts +11 -0
- package/src/core/WorkletNode.ts +3 -0
- package/src/core/WorkletProcessingNode.ts +3 -0
- package/src/core/WorkletSourceNode.ts +3 -0
- package/src/events/types.ts +2 -0
- package/src/interfaces.ts +77 -11
- package/src/types.ts +3 -1
- package/src/utils/index.ts +21 -0
- package/src/web-core/AudioBufferSourceNode.tsx +1 -1
- package/src/web-core/AudioContext.tsx +7 -2
- package/src/web-core/AudioScheduledSourceNode.tsx +1 -1
- package/src/web-core/BaseAudioContext.tsx +2 -0
- package/src/web-core/ConstantSourceNode.tsx +12 -0
- package/src/web-core/OfflineAudioContext.tsx +7 -2
- package/common/cpp/audioapi/HostObjects/AnalyserNodeHostObject.h +0 -149
- package/common/cpp/audioapi/HostObjects/AudioBufferBaseSourceNodeHostObject.h +0 -76
- package/common/cpp/audioapi/HostObjects/AudioBufferHostObject.h +0 -120
- package/common/cpp/audioapi/HostObjects/AudioBufferQueueSourceNodeHostObject.h +0 -67
- package/common/cpp/audioapi/HostObjects/AudioBufferSourceNodeHostObject.h +0 -142
- package/common/cpp/audioapi/HostObjects/AudioRecorderHostObject.h +0 -86
- package/common/cpp/audioapi/HostObjects/AudioScheduledSourceNodeHostObject.h +0 -56
- package/common/cpp/audioapi/HostObjects/BiquadFilterNodeHostObject.h +0 -89
- package/common/cpp/audioapi/HostObjects/GainNodeHostObject.h +0 -27
- package/common/cpp/audioapi/HostObjects/OscillatorNodeHostObject.h +0 -65
- package/common/cpp/audioapi/HostObjects/StereoPannerNodeHostObject.h +0 -29
- package/common/cpp/audioapi/HostObjects/StreamerNodeHostObject.h +0 -30
- package/common/cpp/audioapi/events/AudioEventHandlerRegistryHostObject.h +0 -48
- package/ios/audioapi/ios/core/AudioDecoder.mm +0 -156
- package/ios/audioapi/ios/events/IOSAudioEventHandlerRegistry.h +0 -7
- package/ios/audioapi/ios/events/IOSAudioEventHandlerRegistry.mm +0 -12
- package/lib/commonjs/hooks/useSytemVolume.js.map +0 -1
- package/lib/module/hooks/useSytemVolume.js.map +0 -1
- package/lib/typescript/hooks/useSytemVolume.d.ts.map +0 -1
- /package/common/cpp/audioapi/HostObjects/{AudioDestinationNodeHostObject.h → destinations/AudioDestinationNodeHostObject.h} +0 -0
- /package/common/cpp/audioapi/HostObjects/{PeriodicWaveHostObject.h → effects/PeriodicWaveHostObject.h} +0 -0
- /package/common/cpp/audioapi/core/{AudioParamEventQueue.h → utils/AudioParamEventQueue.h} +0 -0
- /package/src/hooks/{useSytemVolume.ts → useSystemVolume.ts} +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#include <audioapi/HostObjects/sources/OscillatorNodeHostObject.h>
|
|
2
|
+
|
|
3
|
+
#include <audioapi/HostObjects/AudioParamHostObject.h>
|
|
4
|
+
#include <audioapi/HostObjects/effects/PeriodicWaveHostObject.h>
|
|
5
|
+
#include <audioapi/core/sources/OscillatorNode.h>
|
|
6
|
+
|
|
7
|
+
namespace audioapi {
|
|
8
|
+
|
|
9
|
+
OscillatorNodeHostObject::OscillatorNodeHostObject(
|
|
10
|
+
const std::shared_ptr<OscillatorNode> &node)
|
|
11
|
+
: AudioScheduledSourceNodeHostObject(node) {
|
|
12
|
+
addGetters(
|
|
13
|
+
JSI_EXPORT_PROPERTY_GETTER(OscillatorNodeHostObject, frequency),
|
|
14
|
+
JSI_EXPORT_PROPERTY_GETTER(OscillatorNodeHostObject, detune),
|
|
15
|
+
JSI_EXPORT_PROPERTY_GETTER(OscillatorNodeHostObject, type));
|
|
16
|
+
|
|
17
|
+
addFunctions(JSI_EXPORT_FUNCTION(OscillatorNodeHostObject, setPeriodicWave));
|
|
18
|
+
|
|
19
|
+
addSetters(JSI_EXPORT_PROPERTY_SETTER(OscillatorNodeHostObject, type));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
JSI_PROPERTY_GETTER_IMPL(OscillatorNodeHostObject, frequency) {
|
|
23
|
+
auto oscillatorNode = std::static_pointer_cast<OscillatorNode>(node_);
|
|
24
|
+
auto frequencyParam_ = std::make_shared<AudioParamHostObject>(
|
|
25
|
+
oscillatorNode->getFrequencyParam());
|
|
26
|
+
return jsi::Object::createFromHostObject(runtime, frequencyParam_);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
JSI_PROPERTY_GETTER_IMPL(OscillatorNodeHostObject, detune) {
|
|
30
|
+
auto oscillatorNode = std::static_pointer_cast<OscillatorNode>(node_);
|
|
31
|
+
auto detuneParam_ =
|
|
32
|
+
std::make_shared<AudioParamHostObject>(oscillatorNode->getDetuneParam());
|
|
33
|
+
return jsi::Object::createFromHostObject(runtime, detuneParam_);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
JSI_PROPERTY_GETTER_IMPL(OscillatorNodeHostObject, type) {
|
|
37
|
+
auto oscillatorNode = std::static_pointer_cast<OscillatorNode>(node_);
|
|
38
|
+
auto waveType = oscillatorNode->getType();
|
|
39
|
+
return jsi::String::createFromUtf8(runtime, waveType);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
JSI_HOST_FUNCTION_IMPL(OscillatorNodeHostObject, setPeriodicWave) {
|
|
43
|
+
auto oscillatorNode = std::static_pointer_cast<OscillatorNode>(node_);
|
|
44
|
+
auto periodicWave =
|
|
45
|
+
args[0].getObject(runtime).getHostObject<PeriodicWaveHostObject>(runtime);
|
|
46
|
+
oscillatorNode->setPeriodicWave(periodicWave->periodicWave_);
|
|
47
|
+
return jsi::Value::undefined();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
JSI_PROPERTY_SETTER_IMPL(OscillatorNodeHostObject, type) {
|
|
51
|
+
auto oscillatorNode = std::static_pointer_cast<OscillatorNode>(node_);
|
|
52
|
+
oscillatorNode->setType(value.getString(runtime).utf8(runtime));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <audioapi/HostObjects/sources/AudioScheduledSourceNodeHostObject.h>
|
|
4
|
+
|
|
5
|
+
#include <memory>
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <vector>
|
|
8
|
+
|
|
9
|
+
namespace audioapi {
|
|
10
|
+
using namespace facebook;
|
|
11
|
+
|
|
12
|
+
class OscillatorNode;
|
|
13
|
+
|
|
14
|
+
class OscillatorNodeHostObject : public AudioScheduledSourceNodeHostObject {
|
|
15
|
+
public:
|
|
16
|
+
explicit OscillatorNodeHostObject(
|
|
17
|
+
const std::shared_ptr<OscillatorNode> &node);
|
|
18
|
+
|
|
19
|
+
JSI_PROPERTY_GETTER_DECL(frequency);
|
|
20
|
+
JSI_PROPERTY_GETTER_DECL(detune);
|
|
21
|
+
JSI_PROPERTY_GETTER_DECL(type);
|
|
22
|
+
|
|
23
|
+
JSI_HOST_FUNCTION_DECL(setPeriodicWave);
|
|
24
|
+
|
|
25
|
+
JSI_PROPERTY_SETTER_DECL(type);
|
|
26
|
+
};
|
|
27
|
+
} // namespace audioapi
|
|
@@ -16,8 +16,7 @@ class RecorderAdapterNodeHostObject : public AudioNodeHostObject {
|
|
|
16
16
|
public:
|
|
17
17
|
explicit RecorderAdapterNodeHostObject(
|
|
18
18
|
const std::shared_ptr<RecorderAdapterNode> &node)
|
|
19
|
-
: AudioNodeHostObject(node) {
|
|
20
|
-
}
|
|
19
|
+
: AudioNodeHostObject(node) {}
|
|
21
20
|
|
|
22
21
|
private:
|
|
23
22
|
friend class AudioRecorderHostObject;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#include <audioapi/HostObjects/sources/StreamerNodeHostObject.h>
|
|
2
|
+
|
|
3
|
+
#include <audioapi/HostObjects/AudioParamHostObject.h>
|
|
4
|
+
#include <audioapi/HostObjects/effects/PeriodicWaveHostObject.h>
|
|
5
|
+
#include <audioapi/core/sources/StreamerNode.h>
|
|
6
|
+
|
|
7
|
+
namespace audioapi {
|
|
8
|
+
|
|
9
|
+
StreamerNodeHostObject::StreamerNodeHostObject(
|
|
10
|
+
const std::shared_ptr<StreamerNode> &node)
|
|
11
|
+
: AudioScheduledSourceNodeHostObject(node) {
|
|
12
|
+
addFunctions(JSI_EXPORT_FUNCTION(StreamerNodeHostObject, initialize));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
JSI_HOST_FUNCTION_IMPL(StreamerNodeHostObject, initialize) {
|
|
16
|
+
auto streamerNode = std::static_pointer_cast<StreamerNode>(node_);
|
|
17
|
+
auto path = args[0].getString(runtime).utf8(runtime);
|
|
18
|
+
auto result = streamerNode->initialize(path);
|
|
19
|
+
return {result};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <audioapi/HostObjects/sources/AudioScheduledSourceNodeHostObject.h>
|
|
4
|
+
|
|
5
|
+
#include <memory>
|
|
6
|
+
#include <string>
|
|
7
|
+
#include <vector>
|
|
8
|
+
|
|
9
|
+
namespace audioapi {
|
|
10
|
+
using namespace facebook;
|
|
11
|
+
|
|
12
|
+
class StreamerNode;
|
|
13
|
+
|
|
14
|
+
class StreamerNodeHostObject : public AudioScheduledSourceNodeHostObject {
|
|
15
|
+
public:
|
|
16
|
+
explicit StreamerNodeHostObject(
|
|
17
|
+
const std::shared_ptr<StreamerNode> &node);
|
|
18
|
+
|
|
19
|
+
[[nodiscard]] static inline size_t getSizeInBytes() {
|
|
20
|
+
return SIZE;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
JSI_HOST_FUNCTION_DECL(initialize);
|
|
24
|
+
|
|
25
|
+
private:
|
|
26
|
+
static constexpr size_t SIZE = 4'000'000; // 4MB
|
|
27
|
+
};
|
|
28
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <audioapi/HostObjects/sources/AudioScheduledSourceNodeHostObject.h>
|
|
4
|
+
#include <audioapi/core/sources/WorkletSourceNode.h>
|
|
5
|
+
|
|
6
|
+
#include <memory>
|
|
7
|
+
#include <vector>
|
|
8
|
+
|
|
9
|
+
namespace audioapi {
|
|
10
|
+
using namespace facebook;
|
|
11
|
+
|
|
12
|
+
class WorkletSourceNodeHostObject : public AudioScheduledSourceNodeHostObject {
|
|
13
|
+
public:
|
|
14
|
+
explicit WorkletSourceNodeHostObject(const std::shared_ptr<WorkletSourceNode> &node)
|
|
15
|
+
: AudioScheduledSourceNodeHostObject(node) {
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <audioapi/HostObjects/sources/AudioBufferHostObject.h>
|
|
4
|
+
#include <audioapi/HostObjects/utils/AudioDecoderHostObject.h>
|
|
5
|
+
#include <audioapi/core/utils/AudioDecoder.h>
|
|
6
|
+
#include <audioapi/jsi/JsiPromise.h>
|
|
7
|
+
|
|
8
|
+
#include <jsi/jsi.h>
|
|
9
|
+
#include <memory>
|
|
10
|
+
#include <string>
|
|
11
|
+
#include <thread>
|
|
12
|
+
#include <utility>
|
|
13
|
+
|
|
14
|
+
namespace audioapi {
|
|
15
|
+
AudioDecoderHostObject::AudioDecoderHostObject(
|
|
16
|
+
jsi::Runtime *runtime,
|
|
17
|
+
const std::shared_ptr<react::CallInvoker> &callInvoker) {
|
|
18
|
+
promiseVendor_ = std::make_shared<PromiseVendor>(runtime, callInvoker);
|
|
19
|
+
addFunctions(
|
|
20
|
+
JSI_EXPORT_FUNCTION(AudioDecoderHostObject, decodeWithPCMInBase64),
|
|
21
|
+
JSI_EXPORT_FUNCTION(AudioDecoderHostObject, decodeWithFilePath),
|
|
22
|
+
JSI_EXPORT_FUNCTION(AudioDecoderHostObject, decodeWithMemoryBlock));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
JSI_HOST_FUNCTION_IMPL(AudioDecoderHostObject, decodeWithMemoryBlock) {
|
|
26
|
+
auto arrayBuffer = args[0]
|
|
27
|
+
.getObject(runtime)
|
|
28
|
+
.getPropertyAsObject(runtime, "buffer")
|
|
29
|
+
.getArrayBuffer(runtime);
|
|
30
|
+
auto data = arrayBuffer.data(runtime);
|
|
31
|
+
auto size = static_cast<int>(arrayBuffer.size(runtime));
|
|
32
|
+
|
|
33
|
+
auto sampleRate = args[1].getNumber();
|
|
34
|
+
|
|
35
|
+
return promiseVendor_->createAsyncPromise(
|
|
36
|
+
[data, size, sampleRate](
|
|
37
|
+
jsi::Runtime &runtime) -> std::variant<jsi::Value, std::string> {
|
|
38
|
+
auto result =
|
|
39
|
+
AudioDecoder::decodeWithMemoryBlock(data, size, sampleRate);
|
|
40
|
+
|
|
41
|
+
if (!result) {
|
|
42
|
+
return std::string("Failed to decode audio data.");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
auto audioBufferHostObject =
|
|
46
|
+
std::make_shared<AudioBufferHostObject>(result);
|
|
47
|
+
|
|
48
|
+
auto jsiObject =
|
|
49
|
+
jsi::Object::createFromHostObject(runtime, audioBufferHostObject);
|
|
50
|
+
jsiObject.setExternalMemoryPressure(
|
|
51
|
+
runtime, audioBufferHostObject->getSizeInBytes());
|
|
52
|
+
return jsiObject;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
JSI_HOST_FUNCTION_IMPL(AudioDecoderHostObject, decodeWithFilePath) {
|
|
57
|
+
auto sourcePath = args[0].getString(runtime).utf8(runtime);
|
|
58
|
+
auto sampleRate = args[1].getNumber();
|
|
59
|
+
|
|
60
|
+
return promiseVendor_->createAsyncPromise(
|
|
61
|
+
[sourcePath, sampleRate](
|
|
62
|
+
jsi::Runtime &runtime) -> std::variant<jsi::Value, std::string> {
|
|
63
|
+
auto result = AudioDecoder::decodeWithFilePath(sourcePath, sampleRate);
|
|
64
|
+
|
|
65
|
+
if (!result) {
|
|
66
|
+
return std::string("Failed to decode audio data source.");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
auto audioBufferHostObject =
|
|
70
|
+
std::make_shared<AudioBufferHostObject>(result);
|
|
71
|
+
|
|
72
|
+
auto jsiObject =
|
|
73
|
+
jsi::Object::createFromHostObject(runtime, audioBufferHostObject);
|
|
74
|
+
jsiObject.setExternalMemoryPressure(
|
|
75
|
+
runtime, audioBufferHostObject->getSizeInBytes());
|
|
76
|
+
return jsiObject;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
JSI_HOST_FUNCTION_IMPL(AudioDecoderHostObject, decodeWithPCMInBase64) {
|
|
81
|
+
auto b64 = args[0].getString(runtime).utf8(runtime);
|
|
82
|
+
auto inputSampleRate = args[1].getNumber();
|
|
83
|
+
auto inputChannelCount = args[2].getNumber();
|
|
84
|
+
auto interleaved = args[3].getBool();
|
|
85
|
+
|
|
86
|
+
return promiseVendor_->createAsyncPromise(
|
|
87
|
+
[b64, inputSampleRate, inputChannelCount, interleaved](
|
|
88
|
+
jsi::Runtime &runtime) -> std::variant<jsi::Value, std::string> {
|
|
89
|
+
auto result = AudioDecoder::decodeWithPCMInBase64(
|
|
90
|
+
b64, inputSampleRate, inputChannelCount, interleaved);
|
|
91
|
+
|
|
92
|
+
if (!result) {
|
|
93
|
+
return std::string("Failed to decode audio data source.");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
auto audioBufferHostObject =
|
|
97
|
+
std::make_shared<AudioBufferHostObject>(result);
|
|
98
|
+
|
|
99
|
+
auto jsiObject =
|
|
100
|
+
jsi::Object::createFromHostObject(runtime, audioBufferHostObject);
|
|
101
|
+
jsiObject.setExternalMemoryPressure(
|
|
102
|
+
runtime, audioBufferHostObject->getSizeInBytes());
|
|
103
|
+
return jsiObject;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <audioapi/HostObjects/sources/AudioBufferHostObject.h>
|
|
4
|
+
#include <audioapi/core/utils/AudioDecoder.h>
|
|
5
|
+
#include <audioapi/jsi/JsiPromise.h>
|
|
6
|
+
|
|
7
|
+
#include <jsi/jsi.h>
|
|
8
|
+
#include <memory>
|
|
9
|
+
#include <string>
|
|
10
|
+
#include <thread>
|
|
11
|
+
#include <utility>
|
|
12
|
+
|
|
13
|
+
namespace audioapi {
|
|
14
|
+
using namespace facebook;
|
|
15
|
+
|
|
16
|
+
class AudioDecoderHostObject : public JsiHostObject {
|
|
17
|
+
public:
|
|
18
|
+
explicit AudioDecoderHostObject(
|
|
19
|
+
jsi::Runtime *runtime,
|
|
20
|
+
const std::shared_ptr<react::CallInvoker> &callInvoker);
|
|
21
|
+
JSI_HOST_FUNCTION_DECL(decodeWithMemoryBlock);
|
|
22
|
+
JSI_HOST_FUNCTION_DECL(decodeWithFilePath);
|
|
23
|
+
JSI_HOST_FUNCTION_DECL(decodeWithPCMInBase64);
|
|
24
|
+
|
|
25
|
+
private:
|
|
26
|
+
std::shared_ptr<PromiseVendor> promiseVendor_;
|
|
27
|
+
};
|
|
28
|
+
} // namespace audioapi
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
|
|
7
7
|
#include <audioapi/core/AudioContext.h>
|
|
8
8
|
#include <audioapi/core/destinations/AudioDestinationNode.h>
|
|
9
|
-
#include <audioapi/core/utils/AudioDecoder.h>
|
|
10
9
|
#include <audioapi/core/utils/AudioNodeManager.h>
|
|
11
10
|
|
|
12
11
|
namespace audioapi {
|
|
@@ -14,8 +13,9 @@ AudioContext::AudioContext(
|
|
|
14
13
|
float sampleRate,
|
|
15
14
|
bool initSuspended,
|
|
16
15
|
const std::shared_ptr<IAudioEventHandlerRegistry>
|
|
17
|
-
&audioEventHandlerRegistry
|
|
18
|
-
|
|
16
|
+
&audioEventHandlerRegistry,
|
|
17
|
+
const RuntimeRegistry &runtimeRegistry)
|
|
18
|
+
: BaseAudioContext(audioEventHandlerRegistry, runtimeRegistry) {
|
|
19
19
|
#ifdef ANDROID
|
|
20
20
|
audioPlayer_ = std::make_shared<AudioPlayer>(
|
|
21
21
|
this->renderAudio(), sampleRate, destination_->getChannelCount());
|
|
@@ -25,7 +25,6 @@ AudioContext::AudioContext(
|
|
|
25
25
|
#endif
|
|
26
26
|
|
|
27
27
|
sampleRate_ = sampleRate;
|
|
28
|
-
audioDecoder_ = std::make_shared<AudioDecoder>(sampleRate);
|
|
29
28
|
|
|
30
29
|
if (initSuspended) {
|
|
31
30
|
playerHasBeenStarted_ = false;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <audioapi/core/BaseAudioContext.h>
|
|
4
|
+
#include <audioapi/core/utils/worklets/SafeIncludes.h>
|
|
4
5
|
|
|
5
6
|
#include <memory>
|
|
6
7
|
#include <functional>
|
|
@@ -14,7 +15,7 @@ class IOSAudioPlayer;
|
|
|
14
15
|
|
|
15
16
|
class AudioContext : public BaseAudioContext {
|
|
16
17
|
public:
|
|
17
|
-
explicit AudioContext(float sampleRate, bool initSuspended, const std::shared_ptr<IAudioEventHandlerRegistry> &audioEventHandlerRegistry);
|
|
18
|
+
explicit AudioContext(float sampleRate, bool initSuspended, const std::shared_ptr<IAudioEventHandlerRegistry> &audioEventHandlerRegistry, const RuntimeRegistry &runtimeRegistry);
|
|
18
19
|
~AudioContext() override;
|
|
19
20
|
|
|
20
21
|
void close();
|
|
@@ -142,10 +142,10 @@ std::shared_ptr<AudioBus> AudioNode::processAudio(
|
|
|
142
142
|
mixInputsBuses(processingBus);
|
|
143
143
|
|
|
144
144
|
assert(processingBus != nullptr);
|
|
145
|
-
// Finally, process the node itself.
|
|
146
|
-
processNode(processingBus, framesToProcess);
|
|
147
145
|
|
|
148
|
-
|
|
146
|
+
// Finally, process the node itself.
|
|
147
|
+
return processNode(processingBus, framesToProcess);
|
|
148
|
+
;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
bool AudioNode::isAlreadyProcessed() {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
#include <audioapi/core/types/ChannelCountMode.h>
|
|
4
4
|
#include <audioapi/core/types/ChannelInterpretation.h>
|
|
5
|
-
#include <audioapi/core/Constants.h>
|
|
5
|
+
#include <audioapi/core/utils/Constants.h>
|
|
6
6
|
|
|
7
7
|
#include <memory>
|
|
8
8
|
#include <string>
|
|
@@ -68,7 +68,7 @@ class AudioNode : public std::enable_shared_from_this<AudioNode> {
|
|
|
68
68
|
static std::string toString(ChannelCountMode mode);
|
|
69
69
|
static std::string toString(ChannelInterpretation interpretation);
|
|
70
70
|
|
|
71
|
-
virtual
|
|
71
|
+
virtual std::shared_ptr<AudioBus> processNode(const std::shared_ptr<AudioBus>&, int) = 0;
|
|
72
72
|
|
|
73
73
|
bool isAlreadyProcessed();
|
|
74
74
|
std::shared_ptr<AudioBus> processInputs(const std::shared_ptr<AudioBus>& outputBus, int framesToProcess, bool checkIsAlreadyProcessed);
|
|
@@ -219,9 +219,9 @@ void AudioParam::setValueCurveAtTime(
|
|
|
219
219
|
(time - startTime)));
|
|
220
220
|
// Calculate interpolation factor between adjacent array elements
|
|
221
221
|
auto factor = static_cast<float>(
|
|
222
|
-
k -
|
|
223
222
|
(time - startTime) * static_cast<double>(length - 1) /
|
|
224
|
-
(endTime - startTime)
|
|
223
|
+
(endTime - startTime) -
|
|
224
|
+
k);
|
|
225
225
|
return dsp::linearInterpolate(values->data(), k, k + 1, factor);
|
|
226
226
|
}
|
|
227
227
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
#include <audioapi/core/utils/ParamChangeEvent.h>
|
|
5
5
|
#include <audioapi/utils/AudioBus.h>
|
|
6
6
|
#include <audioapi/core/AudioNode.h>
|
|
7
|
-
#include <audioapi/core/AudioParamEventQueue.h>
|
|
7
|
+
#include <audioapi/core/utils/AudioParamEventQueue.h>
|
|
8
8
|
|
|
9
9
|
#include <cstddef>
|
|
10
10
|
#include <utility>
|
|
@@ -4,14 +4,19 @@
|
|
|
4
4
|
#include <audioapi/core/effects/BiquadFilterNode.h>
|
|
5
5
|
#include <audioapi/core/effects/GainNode.h>
|
|
6
6
|
#include <audioapi/core/effects/StereoPannerNode.h>
|
|
7
|
+
#include <audioapi/core/effects/WorkletNode.h>
|
|
8
|
+
#include <audioapi/core/effects/WorkletProcessingNode.h>
|
|
7
9
|
#include <audioapi/core/sources/AudioBuffer.h>
|
|
8
10
|
#include <audioapi/core/sources/AudioBufferQueueSourceNode.h>
|
|
9
11
|
#include <audioapi/core/sources/AudioBufferSourceNode.h>
|
|
12
|
+
#include <audioapi/core/sources/ConstantSourceNode.h>
|
|
10
13
|
#include <audioapi/core/sources/OscillatorNode.h>
|
|
11
14
|
#include <audioapi/core/sources/RecorderAdapterNode.h>
|
|
12
15
|
#include <audioapi/core/sources/StreamerNode.h>
|
|
16
|
+
#include <audioapi/core/sources/WorkletSourceNode.h>
|
|
13
17
|
#include <audioapi/core/utils/AudioDecoder.h>
|
|
14
18
|
#include <audioapi/core/utils/AudioNodeManager.h>
|
|
19
|
+
#include <audioapi/core/utils/worklets/SafeIncludes.h>
|
|
15
20
|
#include <audioapi/events/AudioEventHandlerRegistry.h>
|
|
16
21
|
#include <audioapi/utils/AudioArray.h>
|
|
17
22
|
#include <audioapi/utils/AudioBus.h>
|
|
@@ -21,11 +26,13 @@ namespace audioapi {
|
|
|
21
26
|
|
|
22
27
|
BaseAudioContext::BaseAudioContext(
|
|
23
28
|
const std::shared_ptr<IAudioEventHandlerRegistry>
|
|
24
|
-
&audioEventHandlerRegistry
|
|
29
|
+
&audioEventHandlerRegistry,
|
|
30
|
+
const RuntimeRegistry &runtimeRegistry) {
|
|
25
31
|
nodeManager_ = std::make_shared<AudioNodeManager>();
|
|
26
32
|
destination_ = std::make_shared<AudioDestinationNode>(this);
|
|
27
33
|
|
|
28
34
|
audioEventHandlerRegistry_ = audioEventHandlerRegistry;
|
|
35
|
+
runtimeRegistry_ = runtimeRegistry;
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
std::string BaseAudioContext::getState() {
|
|
@@ -58,6 +65,36 @@ std::shared_ptr<AudioDestinationNode> BaseAudioContext::getDestination() {
|
|
|
58
65
|
return destination_;
|
|
59
66
|
}
|
|
60
67
|
|
|
68
|
+
std::shared_ptr<WorkletSourceNode> BaseAudioContext::createWorkletSourceNode(
|
|
69
|
+
std::shared_ptr<worklets::SerializableWorklet> &shareableWorklet,
|
|
70
|
+
std::weak_ptr<worklets::WorkletRuntime> runtime) {
|
|
71
|
+
auto workletSourceNode =
|
|
72
|
+
std::make_shared<WorkletSourceNode>(this, shareableWorklet, runtime);
|
|
73
|
+
nodeManager_->addSourceNode(workletSourceNode);
|
|
74
|
+
return workletSourceNode;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
std::shared_ptr<WorkletNode> BaseAudioContext::createWorkletNode(
|
|
78
|
+
std::shared_ptr<worklets::SerializableWorklet> &shareableWorklet,
|
|
79
|
+
std::weak_ptr<worklets::WorkletRuntime> runtime,
|
|
80
|
+
size_t bufferLength,
|
|
81
|
+
size_t inputChannelCount) {
|
|
82
|
+
auto workletNode = std::make_shared<WorkletNode>(
|
|
83
|
+
this, shareableWorklet, runtime, bufferLength, inputChannelCount);
|
|
84
|
+
nodeManager_->addProcessingNode(workletNode);
|
|
85
|
+
return workletNode;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
std::shared_ptr<WorkletProcessingNode>
|
|
89
|
+
BaseAudioContext::createWorkletProcessingNode(
|
|
90
|
+
std::shared_ptr<worklets::SerializableWorklet> &shareableWorklet,
|
|
91
|
+
std::weak_ptr<worklets::WorkletRuntime> runtime) {
|
|
92
|
+
auto workletProcessingNode =
|
|
93
|
+
std::make_shared<WorkletProcessingNode>(this, shareableWorklet, runtime);
|
|
94
|
+
nodeManager_->addProcessingNode(workletProcessingNode);
|
|
95
|
+
return workletProcessingNode;
|
|
96
|
+
}
|
|
97
|
+
|
|
61
98
|
std::shared_ptr<RecorderAdapterNode> BaseAudioContext::createRecorderAdapter() {
|
|
62
99
|
auto recorderAdapter = std::make_shared<RecorderAdapterNode>(this);
|
|
63
100
|
nodeManager_->addProcessingNode(recorderAdapter);
|
|
@@ -70,6 +107,12 @@ std::shared_ptr<OscillatorNode> BaseAudioContext::createOscillator() {
|
|
|
70
107
|
return oscillator;
|
|
71
108
|
}
|
|
72
109
|
|
|
110
|
+
std::shared_ptr<ConstantSourceNode> BaseAudioContext::createConstantSource() {
|
|
111
|
+
auto constantSource = std::make_shared<ConstantSourceNode>(this);
|
|
112
|
+
nodeManager_->addSourceNode(constantSource);
|
|
113
|
+
return constantSource;
|
|
114
|
+
}
|
|
115
|
+
|
|
73
116
|
#ifndef AUDIO_API_TEST_SUITE
|
|
74
117
|
std::shared_ptr<StreamerNode> BaseAudioContext::createStreamer() {
|
|
75
118
|
auto streamer = std::make_shared<StreamerNode>(this);
|
|
@@ -105,8 +148,9 @@ std::shared_ptr<AudioBufferSourceNode> BaseAudioContext::createBufferSource(
|
|
|
105
148
|
}
|
|
106
149
|
|
|
107
150
|
std::shared_ptr<AudioBufferQueueSourceNode>
|
|
108
|
-
BaseAudioContext::createBufferQueueSource() {
|
|
109
|
-
auto bufferSource =
|
|
151
|
+
BaseAudioContext::createBufferQueueSource(bool pitchCorrection) {
|
|
152
|
+
auto bufferSource =
|
|
153
|
+
std::make_shared<AudioBufferQueueSourceNode>(this, pitchCorrection);
|
|
110
154
|
nodeManager_->addSourceNode(bufferSource);
|
|
111
155
|
return bufferSource;
|
|
112
156
|
}
|
|
@@ -132,41 +176,6 @@ std::shared_ptr<AnalyserNode> BaseAudioContext::createAnalyser() {
|
|
|
132
176
|
return analyser;
|
|
133
177
|
}
|
|
134
178
|
|
|
135
|
-
std::shared_ptr<AudioBuffer> BaseAudioContext::decodeAudioDataSource(
|
|
136
|
-
const std::string &path) {
|
|
137
|
-
auto audioBus = audioDecoder_->decodeWithFilePath(path);
|
|
138
|
-
|
|
139
|
-
if (!audioBus) {
|
|
140
|
-
return nullptr;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return std::make_shared<AudioBuffer>(audioBus);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
std::shared_ptr<AudioBuffer> BaseAudioContext::decodeAudioData(
|
|
147
|
-
const void *data,
|
|
148
|
-
size_t size) {
|
|
149
|
-
auto audioBus = audioDecoder_->decodeWithMemoryBlock(data, size);
|
|
150
|
-
|
|
151
|
-
if (!audioBus) {
|
|
152
|
-
return nullptr;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return std::make_shared<AudioBuffer>(audioBus);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
std::shared_ptr<AudioBuffer> BaseAudioContext::decodeWithPCMInBase64(
|
|
159
|
-
const std::string &data,
|
|
160
|
-
float playbackSpeed) {
|
|
161
|
-
auto audioBus = audioDecoder_->decodeWithPCMInBase64(data, playbackSpeed);
|
|
162
|
-
|
|
163
|
-
if (!audioBus) {
|
|
164
|
-
return nullptr;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
return std::make_shared<AudioBuffer>(audioBus);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
179
|
AudioNodeManager *BaseAudioContext::getNodeManager() {
|
|
171
180
|
return nodeManager_.get();
|
|
172
181
|
}
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
#include <audioapi/core/types/ContextState.h>
|
|
4
4
|
#include <audioapi/core/types/OscillatorType.h>
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
#include <audioapi/core/utils/worklets/SafeIncludes.h>
|
|
6
|
+
#include <cassert>
|
|
7
|
+
#include <complex>
|
|
8
|
+
#include <cstddef>
|
|
7
9
|
#include <functional>
|
|
8
10
|
#include <memory>
|
|
9
11
|
#include <string>
|
|
10
12
|
#include <utility>
|
|
11
13
|
#include <vector>
|
|
12
|
-
#include <complex>
|
|
13
|
-
#include <cstddef>
|
|
14
|
-
#include <cassert>
|
|
15
14
|
|
|
16
15
|
namespace audioapi {
|
|
17
16
|
|
|
@@ -20,22 +19,25 @@ class GainNode;
|
|
|
20
19
|
class AudioBuffer;
|
|
21
20
|
class PeriodicWave;
|
|
22
21
|
class OscillatorNode;
|
|
22
|
+
class ConstantSourceNode;
|
|
23
23
|
class StereoPannerNode;
|
|
24
24
|
class AudioNodeManager;
|
|
25
25
|
class BiquadFilterNode;
|
|
26
26
|
class AudioDestinationNode;
|
|
27
27
|
class AudioBufferSourceNode;
|
|
28
28
|
class AudioBufferQueueSourceNode;
|
|
29
|
-
class AudioDecoder;
|
|
30
29
|
class AnalyserNode;
|
|
31
30
|
class AudioEventHandlerRegistry;
|
|
32
31
|
class IAudioEventHandlerRegistry;
|
|
33
32
|
class RecorderAdapterNode;
|
|
33
|
+
class WorkletSourceNode;
|
|
34
|
+
class WorkletNode;
|
|
35
|
+
class WorkletProcessingNode;
|
|
34
36
|
class StreamerNode;
|
|
35
37
|
|
|
36
38
|
class BaseAudioContext {
|
|
37
39
|
public:
|
|
38
|
-
explicit BaseAudioContext(const std::shared_ptr<IAudioEventHandlerRegistry> &audioEventHandlerRegistry);
|
|
40
|
+
explicit BaseAudioContext(const std::shared_ptr<IAudioEventHandlerRegistry> &audioEventHandlerRegistry, const RuntimeRegistry &runtimeRegistry);
|
|
39
41
|
virtual ~BaseAudioContext() = default;
|
|
40
42
|
|
|
41
43
|
std::string getState();
|
|
@@ -45,13 +47,17 @@ class BaseAudioContext {
|
|
|
45
47
|
std::shared_ptr<AudioDestinationNode> getDestination();
|
|
46
48
|
|
|
47
49
|
std::shared_ptr<RecorderAdapterNode> createRecorderAdapter();
|
|
50
|
+
std::shared_ptr<WorkletSourceNode> createWorkletSourceNode(std::shared_ptr<worklets::SerializableWorklet> &shareableWorklet, std::weak_ptr<worklets::WorkletRuntime> runtime);
|
|
51
|
+
std::shared_ptr<WorkletNode> createWorkletNode(std::shared_ptr<worklets::SerializableWorklet> &shareableWorklet, std::weak_ptr<worklets::WorkletRuntime> runtime, size_t bufferLength, size_t inputChannelCount);
|
|
52
|
+
std::shared_ptr<WorkletProcessingNode> createWorkletProcessingNode(std::shared_ptr<worklets::SerializableWorklet> &shareableWorklet, std::weak_ptr<worklets::WorkletRuntime> runtime);
|
|
48
53
|
std::shared_ptr<OscillatorNode> createOscillator();
|
|
54
|
+
std::shared_ptr<ConstantSourceNode> createConstantSource();
|
|
49
55
|
std::shared_ptr<StreamerNode> createStreamer();
|
|
50
56
|
std::shared_ptr<GainNode> createGain();
|
|
51
57
|
std::shared_ptr<StereoPannerNode> createStereoPanner();
|
|
52
58
|
std::shared_ptr<BiquadFilterNode> createBiquadFilter();
|
|
53
59
|
std::shared_ptr<AudioBufferSourceNode> createBufferSource(bool pitchCorrection);
|
|
54
|
-
std::shared_ptr<AudioBufferQueueSourceNode> createBufferQueueSource();
|
|
60
|
+
std::shared_ptr<AudioBufferQueueSourceNode> createBufferQueueSource(bool pitchCorrection);
|
|
55
61
|
static std::shared_ptr<AudioBuffer>
|
|
56
62
|
createBuffer(int numberOfChannels, size_t length, float sampleRate);
|
|
57
63
|
std::shared_ptr<PeriodicWave> createPeriodicWave(
|
|
@@ -60,10 +66,6 @@ class BaseAudioContext {
|
|
|
60
66
|
int length);
|
|
61
67
|
std::shared_ptr<AnalyserNode> createAnalyser();
|
|
62
68
|
|
|
63
|
-
std::shared_ptr<AudioBuffer> decodeAudioDataSource(const std::string &path);
|
|
64
|
-
std::shared_ptr<AudioBuffer> decodeAudioData(const void *data, size_t size);
|
|
65
|
-
std::shared_ptr<AudioBuffer> decodeWithPCMInBase64(const std::string &data, float playbackSpeed);
|
|
66
|
-
|
|
67
69
|
std::shared_ptr<PeriodicWave> getBasicWaveForm(OscillatorType type);
|
|
68
70
|
[[nodiscard]] float getNyquistFrequency() const;
|
|
69
71
|
AudioNodeManager *getNodeManager();
|
|
@@ -77,9 +79,7 @@ class BaseAudioContext {
|
|
|
77
79
|
|
|
78
80
|
std::shared_ptr<AudioDestinationNode> destination_;
|
|
79
81
|
// init in AudioContext or OfflineContext constructor
|
|
80
|
-
|
|
81
|
-
// init in AudioContext or OfflineContext constructor
|
|
82
|
-
float sampleRate_ {};
|
|
82
|
+
float sampleRate_{};
|
|
83
83
|
ContextState state_ = ContextState::RUNNING;
|
|
84
84
|
std::shared_ptr<AudioNodeManager> nodeManager_;
|
|
85
85
|
|
|
@@ -89,10 +89,11 @@ class BaseAudioContext {
|
|
|
89
89
|
std::shared_ptr<PeriodicWave> cachedSawtoothWave_ = nullptr;
|
|
90
90
|
std::shared_ptr<PeriodicWave> cachedTriangleWave_ = nullptr;
|
|
91
91
|
|
|
92
|
-
virtual bool isDriverRunning() const = 0;
|
|
92
|
+
[[nodiscard]] virtual bool isDriverRunning() const = 0;
|
|
93
93
|
|
|
94
94
|
public:
|
|
95
95
|
std::shared_ptr<IAudioEventHandlerRegistry> audioEventHandlerRegistry_;
|
|
96
|
+
RuntimeRegistry runtimeRegistry_;
|
|
96
97
|
};
|
|
97
98
|
|
|
98
99
|
} // namespace audioapi
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
#include "OfflineAudioContext.h"
|
|
2
2
|
|
|
3
3
|
#include <audioapi/core/AudioContext.h>
|
|
4
|
-
#include <audioapi/core/Constants.h>
|
|
5
4
|
#include <audioapi/core/destinations/AudioDestinationNode.h>
|
|
6
5
|
#include <audioapi/core/sources/AudioBuffer.h>
|
|
7
|
-
#include <audioapi/core/utils/AudioDecoder.h>
|
|
8
6
|
#include <audioapi/core/utils/AudioNodeManager.h>
|
|
7
|
+
#include <audioapi/core/utils/Constants.h>
|
|
9
8
|
#include <audioapi/core/utils/Locker.h>
|
|
10
9
|
#include <audioapi/utils/AudioArray.h>
|
|
11
10
|
#include <audioapi/utils/AudioBus.h>
|
|
@@ -23,13 +22,13 @@ OfflineAudioContext::OfflineAudioContext(
|
|
|
23
22
|
size_t length,
|
|
24
23
|
float sampleRate,
|
|
25
24
|
const std::shared_ptr<IAudioEventHandlerRegistry>
|
|
26
|
-
&audioEventHandlerRegistry
|
|
27
|
-
|
|
25
|
+
&audioEventHandlerRegistry,
|
|
26
|
+
const RuntimeRegistry &runtimeRegistry)
|
|
27
|
+
: BaseAudioContext(audioEventHandlerRegistry, runtimeRegistry),
|
|
28
28
|
length_(length),
|
|
29
29
|
numberOfChannels_(numberOfChannels),
|
|
30
30
|
currentSampleFrame_(0) {
|
|
31
31
|
sampleRate_ = sampleRate;
|
|
32
|
-
audioDecoder_ = std::make_shared<AudioDecoder>(sampleRate_);
|
|
33
32
|
resultBus_ = std::make_shared<AudioBus>(
|
|
34
33
|
static_cast<int>(length_), numberOfChannels_, sampleRate_);
|
|
35
34
|
}
|