react-native-audio-api 0.8.3 → 0.9.0
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/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 +53 -18
- 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 +362 -6
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +29 -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/core/AudioContext.cpp +3 -2
- 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 -3
- package/common/cpp/audioapi/core/BaseAudioContext.h +13 -4
- package/common/cpp/audioapi/core/OfflineAudioContext.cpp +4 -3
- 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/{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/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 +12 -3
- 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/lib/commonjs/api.js +36 -2
- 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/AudioScheduledSourceNode.js +4 -4
- package/lib/commonjs/core/AudioScheduledSourceNode.js.map +1 -1
- package/lib/commonjs/core/BaseAudioContext.js +66 -11
- 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 +6 -2
- 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/AudioScheduledSourceNode.js +4 -4
- package/lib/module/core/AudioScheduledSourceNode.js.map +1 -1
- package/lib/module/core/BaseAudioContext.js +66 -11
- 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 +8 -4
- 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/AudioScheduledSourceNode.d.ts +1 -1
- package/lib/typescript/core/BaseAudioContext.d.ts +19 -11
- 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 +21 -3
- 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 +12 -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/AudioScheduledSourceNode.ts +5 -5
- package/src/core/BaseAudioContext.ts +149 -13
- 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 +59 -5
- 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/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,25 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <audioapi/HostObjects/AudioNodeHostObject.h>
|
|
4
|
+
|
|
5
|
+
#include <memory>
|
|
6
|
+
#include <vector>
|
|
7
|
+
|
|
8
|
+
namespace audioapi {
|
|
9
|
+
using namespace facebook;
|
|
10
|
+
|
|
11
|
+
class AudioScheduledSourceNode;
|
|
12
|
+
|
|
13
|
+
class AudioScheduledSourceNodeHostObject : public AudioNodeHostObject {
|
|
14
|
+
public:
|
|
15
|
+
explicit AudioScheduledSourceNodeHostObject(
|
|
16
|
+
const std::shared_ptr<AudioScheduledSourceNode> &node);
|
|
17
|
+
|
|
18
|
+
~AudioScheduledSourceNodeHostObject() override;
|
|
19
|
+
|
|
20
|
+
JSI_PROPERTY_SETTER_DECL(onEnded);
|
|
21
|
+
|
|
22
|
+
JSI_HOST_FUNCTION_DECL(start);
|
|
23
|
+
JSI_HOST_FUNCTION_DECL(stop);
|
|
24
|
+
};
|
|
25
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#include <audioapi/HostObjects/AudioParamHostObject.h>
|
|
2
|
+
#include <audioapi/HostObjects/sources/ConstantSourceNodeHostObject.h>
|
|
3
|
+
#include <audioapi/core/sources/ConstantSourceNode.h>
|
|
4
|
+
|
|
5
|
+
namespace audioapi {
|
|
6
|
+
|
|
7
|
+
ConstantSourceNodeHostObject::ConstantSourceNodeHostObject(
|
|
8
|
+
const std::shared_ptr<ConstantSourceNode> &node)
|
|
9
|
+
: AudioScheduledSourceNodeHostObject(node) {
|
|
10
|
+
addGetters(JSI_EXPORT_PROPERTY_GETTER(ConstantSourceNodeHostObject, offset));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
JSI_PROPERTY_GETTER_IMPL(ConstantSourceNodeHostObject, offset) {
|
|
14
|
+
auto constantSourceNode = std::static_pointer_cast<ConstantSourceNode>(node_);
|
|
15
|
+
auto offsetParam_ = std::make_shared<AudioParamHostObject>(
|
|
16
|
+
constantSourceNode->getOffsetParam());
|
|
17
|
+
return jsi::Object::createFromHostObject(runtime, offsetParam_);
|
|
18
|
+
}
|
|
19
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,21 @@
|
|
|
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 ConstantSourceNode;
|
|
13
|
+
|
|
14
|
+
class ConstantSourceNodeHostObject : public AudioScheduledSourceNodeHostObject {
|
|
15
|
+
public:
|
|
16
|
+
explicit ConstantSourceNodeHostObject(
|
|
17
|
+
const std::shared_ptr<ConstantSourceNode> &node);
|
|
18
|
+
|
|
19
|
+
JSI_PROPERTY_GETTER_DECL(offset);
|
|
20
|
+
};
|
|
21
|
+
} // namespace audioapi
|
|
@@ -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
|
|
@@ -14,8 +14,9 @@ AudioContext::AudioContext(
|
|
|
14
14
|
float sampleRate,
|
|
15
15
|
bool initSuspended,
|
|
16
16
|
const std::shared_ptr<IAudioEventHandlerRegistry>
|
|
17
|
-
&audioEventHandlerRegistry
|
|
18
|
-
|
|
17
|
+
&audioEventHandlerRegistry,
|
|
18
|
+
const RuntimeRegistry &runtimeRegistry)
|
|
19
|
+
: BaseAudioContext(audioEventHandlerRegistry, runtimeRegistry) {
|
|
19
20
|
#ifdef ANDROID
|
|
20
21
|
audioPlayer_ = std::make_shared<AudioPlayer>(
|
|
21
22
|
this->renderAudio(), sampleRate, destination_->getChannelCount());
|
|
@@ -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
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
#include <audioapi/core/types/ContextState.h>
|
|
4
4
|
#include <audioapi/core/types/OscillatorType.h>
|
|
5
|
-
|
|
5
|
+
#include <audioapi/core/utils/worklets/SafeIncludes.h>
|
|
6
6
|
|
|
7
7
|
#include <functional>
|
|
8
8
|
#include <memory>
|
|
@@ -20,6 +20,7 @@ class GainNode;
|
|
|
20
20
|
class AudioBuffer;
|
|
21
21
|
class PeriodicWave;
|
|
22
22
|
class OscillatorNode;
|
|
23
|
+
class ConstantSourceNode;
|
|
23
24
|
class StereoPannerNode;
|
|
24
25
|
class AudioNodeManager;
|
|
25
26
|
class BiquadFilterNode;
|
|
@@ -31,11 +32,14 @@ class AnalyserNode;
|
|
|
31
32
|
class AudioEventHandlerRegistry;
|
|
32
33
|
class IAudioEventHandlerRegistry;
|
|
33
34
|
class RecorderAdapterNode;
|
|
35
|
+
class WorkletSourceNode;
|
|
36
|
+
class WorkletNode;
|
|
37
|
+
class WorkletProcessingNode;
|
|
34
38
|
class StreamerNode;
|
|
35
39
|
|
|
36
40
|
class BaseAudioContext {
|
|
37
41
|
public:
|
|
38
|
-
explicit BaseAudioContext(const std::shared_ptr<IAudioEventHandlerRegistry> &audioEventHandlerRegistry);
|
|
42
|
+
explicit BaseAudioContext(const std::shared_ptr<IAudioEventHandlerRegistry> &audioEventHandlerRegistry, const RuntimeRegistry &runtimeRegistry);
|
|
39
43
|
virtual ~BaseAudioContext() = default;
|
|
40
44
|
|
|
41
45
|
std::string getState();
|
|
@@ -45,13 +49,17 @@ class BaseAudioContext {
|
|
|
45
49
|
std::shared_ptr<AudioDestinationNode> getDestination();
|
|
46
50
|
|
|
47
51
|
std::shared_ptr<RecorderAdapterNode> createRecorderAdapter();
|
|
52
|
+
std::shared_ptr<WorkletSourceNode> createWorkletSourceNode(std::shared_ptr<worklets::SerializableWorklet> &shareableWorklet, std::weak_ptr<worklets::WorkletRuntime> runtime);
|
|
53
|
+
std::shared_ptr<WorkletNode> createWorkletNode(std::shared_ptr<worklets::SerializableWorklet> &shareableWorklet, std::weak_ptr<worklets::WorkletRuntime> runtime, size_t bufferLength, size_t inputChannelCount);
|
|
54
|
+
std::shared_ptr<WorkletProcessingNode> createWorkletProcessingNode(std::shared_ptr<worklets::SerializableWorklet> &shareableWorklet, std::weak_ptr<worklets::WorkletRuntime> runtime);
|
|
48
55
|
std::shared_ptr<OscillatorNode> createOscillator();
|
|
56
|
+
std::shared_ptr<ConstantSourceNode> createConstantSource();
|
|
49
57
|
std::shared_ptr<StreamerNode> createStreamer();
|
|
50
58
|
std::shared_ptr<GainNode> createGain();
|
|
51
59
|
std::shared_ptr<StereoPannerNode> createStereoPanner();
|
|
52
60
|
std::shared_ptr<BiquadFilterNode> createBiquadFilter();
|
|
53
61
|
std::shared_ptr<AudioBufferSourceNode> createBufferSource(bool pitchCorrection);
|
|
54
|
-
std::shared_ptr<AudioBufferQueueSourceNode> createBufferQueueSource();
|
|
62
|
+
std::shared_ptr<AudioBufferQueueSourceNode> createBufferQueueSource(bool pitchCorrection);
|
|
55
63
|
static std::shared_ptr<AudioBuffer>
|
|
56
64
|
createBuffer(int numberOfChannels, size_t length, float sampleRate);
|
|
57
65
|
std::shared_ptr<PeriodicWave> createPeriodicWave(
|
|
@@ -89,10 +97,11 @@ class BaseAudioContext {
|
|
|
89
97
|
std::shared_ptr<PeriodicWave> cachedSawtoothWave_ = nullptr;
|
|
90
98
|
std::shared_ptr<PeriodicWave> cachedTriangleWave_ = nullptr;
|
|
91
99
|
|
|
92
|
-
virtual bool isDriverRunning() const = 0;
|
|
100
|
+
[[nodiscard]] virtual bool isDriverRunning() const = 0;
|
|
93
101
|
|
|
94
102
|
public:
|
|
95
103
|
std::shared_ptr<IAudioEventHandlerRegistry> audioEventHandlerRegistry_;
|
|
104
|
+
RuntimeRegistry runtimeRegistry_;
|
|
96
105
|
};
|
|
97
106
|
|
|
98
107
|
} // namespace audioapi
|
|
@@ -1,11 +1,11 @@
|
|
|
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
6
|
#include <audioapi/core/utils/AudioDecoder.h>
|
|
8
7
|
#include <audioapi/core/utils/AudioNodeManager.h>
|
|
8
|
+
#include <audioapi/core/utils/Constants.h>
|
|
9
9
|
#include <audioapi/core/utils/Locker.h>
|
|
10
10
|
#include <audioapi/utils/AudioArray.h>
|
|
11
11
|
#include <audioapi/utils/AudioBus.h>
|
|
@@ -23,8 +23,9 @@ OfflineAudioContext::OfflineAudioContext(
|
|
|
23
23
|
size_t length,
|
|
24
24
|
float sampleRate,
|
|
25
25
|
const std::shared_ptr<IAudioEventHandlerRegistry>
|
|
26
|
-
&audioEventHandlerRegistry
|
|
27
|
-
|
|
26
|
+
&audioEventHandlerRegistry,
|
|
27
|
+
const RuntimeRegistry &runtimeRegistry)
|
|
28
|
+
: BaseAudioContext(audioEventHandlerRegistry, runtimeRegistry),
|
|
28
29
|
length_(length),
|
|
29
30
|
numberOfChannels_(numberOfChannels),
|
|
30
31
|
currentSampleFrame_(0) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include "BaseAudioContext.h"
|
|
4
|
+
#include <audioapi/core/utils/worklets/SafeIncludes.h>
|
|
4
5
|
|
|
5
6
|
#include <mutex>
|
|
6
7
|
#include <map>
|
|
@@ -14,7 +15,7 @@ using OfflineAudioContextResultCallback = std::function<void(std::shared_ptr<Aud
|
|
|
14
15
|
|
|
15
16
|
class OfflineAudioContext : public BaseAudioContext {
|
|
16
17
|
public:
|
|
17
|
-
explicit OfflineAudioContext(int numberOfChannels, size_t length, float sampleRate, const std::shared_ptr<IAudioEventHandlerRegistry> &audioEventHandlerRegistry);
|
|
18
|
+
explicit OfflineAudioContext(int numberOfChannels, size_t length, float sampleRate, const std::shared_ptr<IAudioEventHandlerRegistry> &audioEventHandlerRegistry, const RuntimeRegistry &runtimeRegistry);
|
|
18
19
|
~OfflineAudioContext() override;
|
|
19
20
|
|
|
20
21
|
void resume();
|
|
@@ -143,7 +143,7 @@ void AnalyserNode::getByteTimeDomainData(uint8_t *data, int length) {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
std::shared_ptr<AudioBus> AnalyserNode::processNode(
|
|
147
147
|
const std::shared_ptr<AudioBus> &processingBus,
|
|
148
148
|
int framesToProcess) {
|
|
149
149
|
// Analyser should behave like a sniffer node, it should not modify the
|
|
@@ -156,6 +156,8 @@ void AnalyserNode::processNode(
|
|
|
156
156
|
downMixBus_->getChannel(0)->getData(), framesToProcess, true);
|
|
157
157
|
|
|
158
158
|
shouldDoFFTAnalysis_ = true;
|
|
159
|
+
|
|
160
|
+
return processingBus;
|
|
159
161
|
}
|
|
160
162
|
|
|
161
163
|
void AnalyserNode::doFFTAnalysis() {
|
|
@@ -39,7 +39,7 @@ class AnalyserNode : public AudioNode {
|
|
|
39
39
|
void getByteTimeDomainData(uint8_t *data, int length);
|
|
40
40
|
|
|
41
41
|
protected:
|
|
42
|
-
|
|
42
|
+
std::shared_ptr<AudioBus> processNode(const std::shared_ptr<AudioBus>& processingBus, int framesToProcess) override;
|
|
43
43
|
|
|
44
44
|
private:
|
|
45
45
|
int fftSize_;
|
|
@@ -24,7 +24,7 @@ class AudioDestinationNode : public AudioNode {
|
|
|
24
24
|
protected:
|
|
25
25
|
// DestinationNode is triggered by AudioContext using renderAudio
|
|
26
26
|
// processNode function is not necessary and is never called.
|
|
27
|
-
|
|
27
|
+
std::shared_ptr<AudioBus> processNode(const std::shared_ptr<AudioBus>& processingBus, int) final { return processingBus; };
|
|
28
28
|
|
|
29
29
|
private:
|
|
30
30
|
std::size_t currentSampleFrame_;
|
|
@@ -353,7 +353,7 @@ void BiquadFilterNode::applyFilter() {
|
|
|
353
353
|
}
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
|
|
356
|
+
std::shared_ptr<AudioBus> BiquadFilterNode::processNode(
|
|
357
357
|
const std::shared_ptr<AudioBus> &processingBus,
|
|
358
358
|
int framesToProcess) {
|
|
359
359
|
int numChannels = processingBus->getNumberOfChannels();
|
|
@@ -393,6 +393,8 @@ void BiquadFilterNode::processNode(
|
|
|
393
393
|
x2_ = x2;
|
|
394
394
|
y1_ = y1;
|
|
395
395
|
y2_ = y2;
|
|
396
|
+
|
|
397
|
+
return processingBus;
|
|
396
398
|
}
|
|
397
399
|
|
|
398
400
|
} // namespace audioapi
|
|
@@ -16,7 +16,7 @@ std::shared_ptr<AudioParam> GainNode::getGainParam() const {
|
|
|
16
16
|
return gainParam_;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
std::shared_ptr<AudioBus> GainNode::processNode(
|
|
20
20
|
const std::shared_ptr<AudioBus> &processingBus,
|
|
21
21
|
int framesToProcess) {
|
|
22
22
|
double time = context_->getCurrentTime();
|
|
@@ -28,6 +28,8 @@ void GainNode::processNode(
|
|
|
28
28
|
processingBus->getChannel(i)->getData(),
|
|
29
29
|
framesToProcess);
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
return processingBus;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
} // namespace audioapi
|
|
@@ -16,7 +16,7 @@ class GainNode : public AudioNode {
|
|
|
16
16
|
[[nodiscard]] std::shared_ptr<AudioParam> getGainParam() const;
|
|
17
17
|
|
|
18
18
|
protected:
|
|
19
|
-
|
|
19
|
+
std::shared_ptr<AudioBus> processNode(const std::shared_ptr<AudioBus>& processingBus, int framesToProcess) override;
|
|
20
20
|
|
|
21
21
|
private:
|
|
22
22
|
std::shared_ptr<AudioParam> gainParam_;
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
-
#include <audioapi/core/Constants.h>
|
|
30
29
|
#include <audioapi/core/effects/PeriodicWave.h>
|
|
30
|
+
#include <audioapi/core/utils/Constants.h>
|
|
31
31
|
#include <audioapi/dsp/VectorMath.h>
|
|
32
32
|
|
|
33
33
|
constexpr unsigned NumberOfOctaveBands = 3;
|