react-native-audio-api 0.8.3-nightly-ea268f4-20251006 → 0.8.3
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 +39 -40
- package/RNAudioAPI.podspec +12 -17
- package/android/build.gradle +4 -44
- package/android/src/main/cpp/audioapi/CMakeLists.txt +0 -65
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.cpp +1 -29
- package/android/src/main/cpp/audioapi/android/AudioAPIModule.h +0 -14
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.cpp +1 -7
- package/android/src/main/cpp/audioapi/android/core/AndroidAudioRecorder.h +1 -6
- package/android/src/main/cpp/audioapi/android/core/AudioPlayer.cpp +1 -1
- package/android/src/main/java/com/swmansion/audioapi/AudioAPIModule.kt +1 -11
- package/android/src/main/java/com/swmansion/audioapi/system/MediaSessionManager.kt +2 -15
- package/common/cpp/audioapi/AudioAPIModuleInstaller.h +18 -53
- package/common/cpp/audioapi/HostObjects/AnalyserNodeHostObject.h +149 -0
- package/common/cpp/audioapi/HostObjects/AudioBufferBaseSourceNodeHostObject.h +76 -0
- package/common/cpp/audioapi/HostObjects/AudioBufferHostObject.h +120 -0
- package/common/cpp/audioapi/HostObjects/AudioBufferQueueSourceNodeHostObject.h +67 -0
- package/common/cpp/audioapi/HostObjects/AudioBufferSourceNodeHostObject.h +142 -0
- package/common/cpp/audioapi/HostObjects/AudioContextHostObject.h +46 -6
- package/common/cpp/audioapi/HostObjects/AudioNodeHostObject.cpp +6 -70
- package/common/cpp/audioapi/HostObjects/AudioNodeHostObject.h +66 -10
- package/common/cpp/audioapi/HostObjects/AudioParamHostObject.h +91 -17
- package/common/cpp/audioapi/HostObjects/AudioRecorderHostObject.h +86 -0
- package/common/cpp/audioapi/HostObjects/AudioScheduledSourceNodeHostObject.h +56 -0
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +6 -362
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +241 -29
- package/common/cpp/audioapi/HostObjects/BiquadFilterNodeHostObject.h +89 -0
- package/common/cpp/audioapi/HostObjects/GainNodeHostObject.h +27 -0
- package/common/cpp/audioapi/HostObjects/OfflineAudioContextHostObject.h +50 -6
- package/common/cpp/audioapi/HostObjects/OscillatorNodeHostObject.h +65 -0
- package/common/cpp/audioapi/HostObjects/{sources/RecorderAdapterNodeHostObject.h → RecorderAdapterNodeHostObject.h} +2 -1
- package/common/cpp/audioapi/HostObjects/StereoPannerNodeHostObject.h +29 -0
- package/common/cpp/audioapi/HostObjects/StreamerNodeHostObject.h +30 -0
- package/common/cpp/audioapi/core/AudioContext.cpp +2 -3
- package/common/cpp/audioapi/core/AudioContext.h +1 -2
- package/common/cpp/audioapi/core/AudioNode.h +1 -1
- package/common/cpp/audioapi/core/AudioParam.cpp +2 -2
- package/common/cpp/audioapi/core/AudioParam.h +1 -1
- package/common/cpp/audioapi/core/{utils/AudioParamEventQueue.cpp → AudioParamEventQueue.cpp} +7 -13
- package/common/cpp/audioapi/core/BaseAudioContext.cpp +3 -47
- package/common/cpp/audioapi/core/BaseAudioContext.h +4 -13
- package/common/cpp/audioapi/core/{utils/Constants.h → Constants.h} +0 -5
- package/common/cpp/audioapi/core/OfflineAudioContext.cpp +3 -4
- package/common/cpp/audioapi/core/OfflineAudioContext.h +1 -2
- package/common/cpp/audioapi/core/effects/PeriodicWave.cpp +1 -1
- package/common/cpp/audioapi/core/effects/StereoPannerNode.cpp +1 -1
- 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 +10 -47
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.h +3 -18
- package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.cpp +12 -94
- package/common/cpp/audioapi/core/sources/AudioBufferQueueSourceNode.h +2 -8
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp +42 -33
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.h +8 -6
- package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.cpp +6 -1
- package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.h +1 -1
- package/common/cpp/audioapi/core/sources/StreamerNode.h +8 -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 +1 -2
- package/common/cpp/audioapi/events/AudioEventHandlerRegistryHostObject.h +48 -0
- package/common/cpp/audioapi/jsi/AudioArrayBuffer.h +1 -14
- package/common/cpp/audioapi/jsi/JsiHostObject.h +12 -6
- package/common/cpp/audioapi/jsi/JsiPromise.cpp +0 -49
- package/common/cpp/audioapi/jsi/JsiPromise.h +1 -29
- package/common/cpp/audioapi/utils/AudioBus.cpp +1 -1
- package/common/cpp/test/CMakeLists.txt +3 -11
- package/common/cpp/test/GainTest.cpp +1 -2
- package/common/cpp/test/OscillatorTest.cpp +1 -2
- package/ios/audioapi/ios/AudioAPIModule.mm +5 -32
- package/ios/audioapi/ios/core/IOSAudioPlayer.mm +1 -1
- package/ios/audioapi/ios/core/IOSAudioRecorder.h +1 -2
- package/ios/audioapi/ios/core/IOSAudioRecorder.mm +1 -1
- package/ios/audioapi/ios/events/IOSAudioEventHandlerRegistry.h +7 -0
- package/ios/audioapi/ios/events/IOSAudioEventHandlerRegistry.mm +12 -0
- package/lib/commonjs/api.js +2 -36
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/api.web.js +0 -8
- package/lib/commonjs/api.web.js.map +1 -1
- package/lib/commonjs/core/AudioBufferBaseSourceNode.js +7 -7
- package/lib/commonjs/core/AudioBufferBaseSourceNode.js.map +1 -1
- package/lib/commonjs/core/AudioBufferQueueSourceNode.js +6 -1
- package/lib/commonjs/core/AudioBufferQueueSourceNode.js.map +1 -1
- package/lib/commonjs/core/AudioBufferSourceNode.js +0 -15
- package/lib/commonjs/core/AudioBufferSourceNode.js.map +1 -1
- package/lib/commonjs/core/AudioContext.js +1 -10
- 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 +11 -66
- package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
- package/lib/commonjs/core/OfflineAudioContext.js +2 -11
- package/lib/commonjs/core/OfflineAudioContext.js.map +1 -1
- package/lib/commonjs/core/OscillatorNode.js +0 -6
- package/lib/commonjs/core/OscillatorNode.js.map +1 -1
- package/lib/commonjs/hooks/{useSystemVolume.js → useSytemVolume.js} +1 -1
- package/lib/commonjs/hooks/useSytemVolume.js.map +1 -0
- package/lib/commonjs/utils/index.js +0 -9
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/web-core/AudioContext.js +0 -4
- 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/OfflineAudioContext.js +0 -4
- package/lib/commonjs/web-core/OfflineAudioContext.js.map +1 -1
- package/lib/module/api.js +2 -6
- package/lib/module/api.js.map +1 -1
- package/lib/module/api.web.js +0 -1
- package/lib/module/api.web.js.map +1 -1
- package/lib/module/core/AudioBufferBaseSourceNode.js +7 -7
- package/lib/module/core/AudioBufferBaseSourceNode.js.map +1 -1
- package/lib/module/core/AudioBufferQueueSourceNode.js +6 -1
- package/lib/module/core/AudioBufferQueueSourceNode.js.map +1 -1
- package/lib/module/core/AudioBufferSourceNode.js +0 -15
- package/lib/module/core/AudioBufferSourceNode.js.map +1 -1
- package/lib/module/core/AudioContext.js +1 -10
- 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 +11 -66
- package/lib/module/core/BaseAudioContext.js.map +1 -1
- package/lib/module/core/OfflineAudioContext.js +2 -11
- package/lib/module/core/OfflineAudioContext.js.map +1 -1
- package/lib/module/core/OscillatorNode.js +0 -6
- package/lib/module/core/OscillatorNode.js.map +1 -1
- package/lib/module/hooks/{useSystemVolume.js → useSytemVolume.js} +1 -1
- package/lib/module/hooks/useSytemVolume.js.map +1 -0
- package/lib/module/utils/index.js +0 -8
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/web-core/AudioContext.js +0 -4
- 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/OfflineAudioContext.js +0 -4
- package/lib/module/web-core/OfflineAudioContext.js.map +1 -1
- package/lib/typescript/api.d.ts +4 -8
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/api.web.d.ts +0 -1
- package/lib/typescript/api.web.d.ts.map +1 -1
- package/lib/typescript/core/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 +0 -4
- package/lib/typescript/core/AudioBufferSourceNode.d.ts.map +1 -1
- package/lib/typescript/core/AudioContext.d.ts +0 -1
- 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 +11 -19
- package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/core/OfflineAudioContext.d.ts +0 -1
- package/lib/typescript/core/OfflineAudioContext.d.ts.map +1 -1
- package/lib/typescript/core/OscillatorNode.d.ts +0 -3
- package/lib/typescript/core/OscillatorNode.d.ts.map +1 -1
- package/lib/typescript/events/types.d.ts +0 -2
- package/lib/typescript/events/types.d.ts.map +1 -1
- package/lib/typescript/hooks/{useSystemVolume.d.ts → useSytemVolume.d.ts} +1 -1
- package/lib/typescript/hooks/useSytemVolume.d.ts.map +1 -0
- package/lib/typescript/interfaces.d.ts +3 -21
- package/lib/typescript/interfaces.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +1 -2
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/utils/index.d.ts +0 -8
- 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 +2 -4
- 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 +0 -2
- package/lib/typescript/web-core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/web-core/OfflineAudioContext.d.ts +2 -4
- package/lib/typescript/web-core/OfflineAudioContext.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/api.ts +3 -12
- package/src/api.web.ts +0 -1
- package/src/core/AudioBufferBaseSourceNode.ts +9 -9
- package/src/core/AudioBufferQueueSourceNode.ts +9 -1
- package/src/core/AudioBufferSourceNode.ts +0 -28
- package/src/core/AudioContext.ts +1 -12
- package/src/core/AudioScheduledSourceNode.ts +5 -5
- package/src/core/BaseAudioContext.ts +13 -149
- package/src/core/OfflineAudioContext.ts +2 -18
- package/src/core/OscillatorNode.ts +0 -11
- package/src/events/types.ts +0 -2
- package/src/interfaces.ts +5 -59
- package/src/types.ts +1 -3
- package/src/utils/index.ts +0 -21
- package/src/web-core/AudioBufferSourceNode.tsx +1 -1
- package/src/web-core/AudioContext.tsx +2 -7
- package/src/web-core/AudioScheduledSourceNode.tsx +1 -1
- package/src/web-core/BaseAudioContext.tsx +0 -2
- package/src/web-core/OfflineAudioContext.tsx +2 -7
- package/android/src/main/cpp/audioapi/android/core/NativeAudioRecorder.hpp +0 -36
- package/android/src/main/java/com/swmansion/audioapi/core/NativeAudioRecorder.kt +0 -24
- package/common/cpp/audioapi/HostObjects/AudioContextHostObject.cpp +0 -57
- package/common/cpp/audioapi/HostObjects/AudioParamHostObject.cpp +0 -105
- package/common/cpp/audioapi/HostObjects/OfflineAudioContextHostObject.cpp +0 -70
- package/common/cpp/audioapi/HostObjects/WorkletNodeHostObject.h +0 -18
- package/common/cpp/audioapi/HostObjects/WorkletProcessingNodeHostObject.h +0 -18
- package/common/cpp/audioapi/HostObjects/analysis/AnalyserNodeHostObject.cpp +0 -148
- package/common/cpp/audioapi/HostObjects/analysis/AnalyserNodeHostObject.h +0 -37
- package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.cpp +0 -92
- package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.h +0 -29
- package/common/cpp/audioapi/HostObjects/effects/GainNodeHostObject.cpp +0 -20
- package/common/cpp/audioapi/HostObjects/effects/GainNodeHostObject.h +0 -19
- package/common/cpp/audioapi/HostObjects/effects/StereoPannerNodeHostObject.cpp +0 -21
- package/common/cpp/audioapi/HostObjects/effects/StereoPannerNodeHostObject.h +0 -21
- package/common/cpp/audioapi/HostObjects/events/AudioEventHandlerRegistryHostObject.cpp +0 -41
- package/common/cpp/audioapi/HostObjects/events/AudioEventHandlerRegistryHostObject.h +0 -28
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.cpp +0 -69
- package/common/cpp/audioapi/HostObjects/inputs/AudioRecorderHostObject.h +0 -33
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferBaseSourceNodeHostObject.cpp +0 -73
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferBaseSourceNodeHostObject.h +0 -29
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferHostObject.cpp +0 -94
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferHostObject.h +0 -46
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferQueueSourceNodeHostObject.cpp +0 -60
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferQueueSourceNodeHostObject.h +0 -25
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferSourceNodeHostObject.cpp +0 -152
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferSourceNodeHostObject.h +0 -37
- package/common/cpp/audioapi/HostObjects/sources/AudioScheduledSourceNodeHostObject.cpp +0 -52
- package/common/cpp/audioapi/HostObjects/sources/AudioScheduledSourceNodeHostObject.h +0 -25
- package/common/cpp/audioapi/HostObjects/sources/ConstantSourceNodeHostObject.cpp +0 -19
- package/common/cpp/audioapi/HostObjects/sources/ConstantSourceNodeHostObject.h +0 -21
- package/common/cpp/audioapi/HostObjects/sources/OscillatorNodeHostObject.cpp +0 -55
- package/common/cpp/audioapi/HostObjects/sources/OscillatorNodeHostObject.h +0 -27
- package/common/cpp/audioapi/HostObjects/sources/StreamerNodeHostObject.cpp +0 -22
- package/common/cpp/audioapi/HostObjects/sources/StreamerNodeHostObject.h +0 -28
- package/common/cpp/audioapi/HostObjects/sources/WorkletSourceNodeHostObject.h +0 -18
- package/common/cpp/audioapi/core/effects/WorkletNode.cpp +0 -87
- package/common/cpp/audioapi/core/effects/WorkletNode.h +0 -65
- package/common/cpp/audioapi/core/effects/WorkletProcessingNode.cpp +0 -89
- package/common/cpp/audioapi/core/effects/WorkletProcessingNode.h +0 -52
- package/common/cpp/audioapi/core/sources/ConstantSourceNode.cpp +0 -51
- package/common/cpp/audioapi/core/sources/ConstantSourceNode.h +0 -26
- package/common/cpp/audioapi/core/sources/WorkletSourceNode.cpp +0 -82
- package/common/cpp/audioapi/core/sources/WorkletSourceNode.h +0 -47
- package/common/cpp/audioapi/core/utils/worklets/SafeIncludes.h +0 -52
- package/common/cpp/audioapi/core/utils/worklets/WorkletsRunner.cpp +0 -9
- package/common/cpp/audioapi/core/utils/worklets/WorkletsRunner.h +0 -73
- package/common/cpp/audioapi/utils/ThreadPool.hpp +0 -104
- package/common/cpp/test/AudioParamTest.cpp +0 -204
- package/lib/commonjs/core/ConstantSourceNode.js +0 -17
- package/lib/commonjs/core/ConstantSourceNode.js.map +0 -1
- package/lib/commonjs/core/WorkletNode.js +0 -11
- package/lib/commonjs/core/WorkletNode.js.map +0 -1
- package/lib/commonjs/core/WorkletProcessingNode.js +0 -11
- package/lib/commonjs/core/WorkletProcessingNode.js.map +0 -1
- package/lib/commonjs/core/WorkletSourceNode.js +0 -11
- package/lib/commonjs/core/WorkletSourceNode.js.map +0 -1
- package/lib/commonjs/hooks/useSystemVolume.js.map +0 -1
- package/lib/commonjs/web-core/ConstantSourceNode.js +0 -17
- package/lib/commonjs/web-core/ConstantSourceNode.js.map +0 -1
- package/lib/module/core/ConstantSourceNode.js +0 -11
- package/lib/module/core/ConstantSourceNode.js.map +0 -1
- package/lib/module/core/WorkletNode.js +0 -5
- package/lib/module/core/WorkletNode.js.map +0 -1
- package/lib/module/core/WorkletProcessingNode.js +0 -5
- package/lib/module/core/WorkletProcessingNode.js.map +0 -1
- package/lib/module/core/WorkletSourceNode.js +0 -5
- package/lib/module/core/WorkletSourceNode.js.map +0 -1
- package/lib/module/hooks/useSystemVolume.js.map +0 -1
- package/lib/module/web-core/ConstantSourceNode.js +0 -11
- package/lib/module/web-core/ConstantSourceNode.js.map +0 -1
- package/lib/typescript/core/ConstantSourceNode.d.ts +0 -9
- package/lib/typescript/core/ConstantSourceNode.d.ts.map +0 -1
- package/lib/typescript/core/WorkletNode.d.ts +0 -4
- package/lib/typescript/core/WorkletNode.d.ts.map +0 -1
- package/lib/typescript/core/WorkletProcessingNode.d.ts +0 -4
- package/lib/typescript/core/WorkletProcessingNode.d.ts.map +0 -1
- package/lib/typescript/core/WorkletSourceNode.d.ts +0 -4
- package/lib/typescript/core/WorkletSourceNode.d.ts.map +0 -1
- package/lib/typescript/hooks/useSystemVolume.d.ts.map +0 -1
- package/lib/typescript/web-core/ConstantSourceNode.d.ts +0 -8
- package/lib/typescript/web-core/ConstantSourceNode.d.ts.map +0 -1
- package/src/core/ConstantSourceNode.ts +0 -13
- package/src/core/WorkletNode.ts +0 -3
- package/src/core/WorkletProcessingNode.ts +0 -3
- package/src/core/WorkletSourceNode.ts +0 -3
- package/src/web-core/ConstantSourceNode.tsx +0 -12
- /package/common/cpp/audioapi/HostObjects/{destinations/AudioDestinationNodeHostObject.h → AudioDestinationNodeHostObject.h} +0 -0
- /package/common/cpp/audioapi/HostObjects/{effects/PeriodicWaveHostObject.h → PeriodicWaveHostObject.h} +0 -0
- /package/common/cpp/audioapi/core/{utils/AudioParamEventQueue.h → AudioParamEventQueue.h} +0 -0
- /package/src/hooks/{useSystemVolume.ts → useSytemVolume.ts} +0 -0
|
@@ -10,7 +10,7 @@ export default class AudioScheduledSourceNode extends AudioNode {
|
|
|
10
10
|
global.AudioEventEmitter
|
|
11
11
|
);
|
|
12
12
|
|
|
13
|
-
private
|
|
13
|
+
private onendedSubscription?: AudioEventSubscription;
|
|
14
14
|
private onEndedCallback?: (event: OnEndedEventType) => void;
|
|
15
15
|
|
|
16
16
|
public start(when: number = 0): void {
|
|
@@ -51,19 +51,19 @@ export default class AudioScheduledSourceNode extends AudioNode {
|
|
|
51
51
|
public set onEnded(callback: ((event: OnEndedEventType) => void) | null) {
|
|
52
52
|
if (!callback) {
|
|
53
53
|
(this.node as IAudioScheduledSourceNode).onEnded = '0';
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
54
|
+
this.onendedSubscription?.remove();
|
|
55
|
+
this.onendedSubscription = undefined;
|
|
56
56
|
this.onEndedCallback = undefined;
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
this.onEndedCallback = callback;
|
|
61
|
-
this.
|
|
61
|
+
this.onendedSubscription = this.audioEventEmitter.addAudioEventListener(
|
|
62
62
|
'ended',
|
|
63
63
|
callback
|
|
64
64
|
);
|
|
65
65
|
|
|
66
66
|
(this.node as IAudioScheduledSourceNode).onEnded =
|
|
67
|
-
this.
|
|
67
|
+
this.onendedSubscription.subscriptionId;
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
import { InvalidAccessError, NotSupportedError } from '../errors';
|
|
2
1
|
import { IBaseAudioContext } from '../interfaces';
|
|
3
2
|
import {
|
|
4
|
-
AudioBufferBaseSourceNodeOptions,
|
|
5
3
|
ContextState,
|
|
6
4
|
PeriodicWaveConstraints,
|
|
7
|
-
|
|
5
|
+
AudioBufferSourceNodeOptions,
|
|
8
6
|
} from '../types';
|
|
9
|
-
import { isWorkletsAvailable, workletsModule } from '../utils';
|
|
10
|
-
import WorkletSourceNode from './WorkletSourceNode';
|
|
11
|
-
import WorkletProcessingNode from './WorkletProcessingNode';
|
|
12
|
-
import AnalyserNode from './AnalyserNode';
|
|
13
|
-
import AudioBuffer from './AudioBuffer';
|
|
14
|
-
import AudioBufferQueueSourceNode from './AudioBufferQueueSourceNode';
|
|
15
|
-
import AudioBufferSourceNode from './AudioBufferSourceNode';
|
|
16
7
|
import AudioDestinationNode from './AudioDestinationNode';
|
|
17
|
-
import BiquadFilterNode from './BiquadFilterNode';
|
|
18
|
-
import GainNode from './GainNode';
|
|
19
8
|
import OscillatorNode from './OscillatorNode';
|
|
20
|
-
import
|
|
21
|
-
import RecorderAdapterNode from './RecorderAdapterNode';
|
|
9
|
+
import GainNode from './GainNode';
|
|
22
10
|
import StereoPannerNode from './StereoPannerNode';
|
|
11
|
+
import BiquadFilterNode from './BiquadFilterNode';
|
|
12
|
+
import AudioBufferSourceNode from './AudioBufferSourceNode';
|
|
13
|
+
import AudioBuffer from './AudioBuffer';
|
|
14
|
+
import PeriodicWave from './PeriodicWave';
|
|
15
|
+
import AnalyserNode from './AnalyserNode';
|
|
16
|
+
import AudioBufferQueueSourceNode from './AudioBufferQueueSourceNode';
|
|
23
17
|
import StreamerNode from './StreamerNode';
|
|
24
|
-
import
|
|
25
|
-
import
|
|
18
|
+
import { InvalidAccessError, NotSupportedError } from '../errors';
|
|
19
|
+
import RecorderAdapterNode from './RecorderAdapterNode';
|
|
26
20
|
|
|
27
21
|
export default class BaseAudioContext {
|
|
28
22
|
readonly destination: AudioDestinationNode;
|
|
@@ -43,128 +37,6 @@ export default class BaseAudioContext {
|
|
|
43
37
|
return this.context.state;
|
|
44
38
|
}
|
|
45
39
|
|
|
46
|
-
createWorkletNode(
|
|
47
|
-
callback: (audioData: Array<Float32Array>, channelCount: number) => void,
|
|
48
|
-
bufferLength: number,
|
|
49
|
-
inputChannelCount: number,
|
|
50
|
-
workletRuntime: AudioWorkletRuntime = 'AudioRuntime'
|
|
51
|
-
): WorkletNode {
|
|
52
|
-
if (inputChannelCount < 1 || inputChannelCount > 32) {
|
|
53
|
-
throw new NotSupportedError(
|
|
54
|
-
`The number of input channels provided (${inputChannelCount}) can not be less than 1 or greater than 32`
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
if (bufferLength < 1) {
|
|
58
|
-
throw new NotSupportedError(
|
|
59
|
-
`The buffer length provided (${bufferLength}) can not be less than 1`
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (isWorkletsAvailable) {
|
|
64
|
-
const shareableWorklet = workletsModule.makeShareableCloneRecursive(
|
|
65
|
-
(audioBuffers: Array<ArrayBuffer>, channelCount: number) => {
|
|
66
|
-
'worklet';
|
|
67
|
-
const floatAudioData: Array<Float32Array> = audioBuffers.map(
|
|
68
|
-
(buffer) => new Float32Array(buffer)
|
|
69
|
-
);
|
|
70
|
-
callback(floatAudioData, channelCount);
|
|
71
|
-
}
|
|
72
|
-
);
|
|
73
|
-
return new WorkletNode(
|
|
74
|
-
this,
|
|
75
|
-
this.context.createWorkletNode(
|
|
76
|
-
shareableWorklet,
|
|
77
|
-
workletRuntime === 'UIRuntime',
|
|
78
|
-
bufferLength,
|
|
79
|
-
inputChannelCount
|
|
80
|
-
)
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
/// User does not have worklets as a dependency so he cannot use the worklet API.
|
|
84
|
-
throw new Error(
|
|
85
|
-
'[RnAudioApi] Worklets are not available, please install react-native-worklets as a dependency. Refer to documentation for more details.'
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
createWorkletProcessingNode(
|
|
90
|
-
callback: (
|
|
91
|
-
inputData: Array<Float32Array>,
|
|
92
|
-
outputData: Array<Float32Array>,
|
|
93
|
-
framesToProcess: number,
|
|
94
|
-
currentTime: number
|
|
95
|
-
) => void,
|
|
96
|
-
workletRuntime: AudioWorkletRuntime = 'AudioRuntime'
|
|
97
|
-
): WorkletProcessingNode {
|
|
98
|
-
if (isWorkletsAvailable) {
|
|
99
|
-
const shareableWorklet = workletsModule.makeShareableCloneRecursive(
|
|
100
|
-
(
|
|
101
|
-
inputBuffers: Array<ArrayBuffer>,
|
|
102
|
-
outputBuffers: Array<ArrayBuffer>,
|
|
103
|
-
framesToProcess: number,
|
|
104
|
-
currentTime: number
|
|
105
|
-
) => {
|
|
106
|
-
'worklet';
|
|
107
|
-
const inputData: Array<Float32Array> = inputBuffers.map(
|
|
108
|
-
(buffer) => new Float32Array(buffer, 0, framesToProcess)
|
|
109
|
-
);
|
|
110
|
-
const outputData: Array<Float32Array> = outputBuffers.map(
|
|
111
|
-
(buffer) => new Float32Array(buffer, 0, framesToProcess)
|
|
112
|
-
);
|
|
113
|
-
callback(inputData, outputData, framesToProcess, currentTime);
|
|
114
|
-
}
|
|
115
|
-
);
|
|
116
|
-
return new WorkletProcessingNode(
|
|
117
|
-
this,
|
|
118
|
-
this.context.createWorkletProcessingNode(
|
|
119
|
-
shareableWorklet,
|
|
120
|
-
workletRuntime === 'UIRuntime'
|
|
121
|
-
)
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
/// User does not have worklets as a dependency so he cannot use the worklet API.
|
|
125
|
-
throw new Error(
|
|
126
|
-
'[RnAudioApi] Worklets are not available, please install react-native-worklets as a dependency. Refer to documentation for more details.'
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
createWorkletSourceNode(
|
|
131
|
-
callback: (
|
|
132
|
-
audioData: Array<Float32Array>,
|
|
133
|
-
framesToProcess: number,
|
|
134
|
-
currentTime: number,
|
|
135
|
-
startOffset: number
|
|
136
|
-
) => void,
|
|
137
|
-
workletRuntime: AudioWorkletRuntime = 'AudioRuntime'
|
|
138
|
-
): WorkletSourceNode {
|
|
139
|
-
if (!isWorkletsAvailable) {
|
|
140
|
-
/// User does not have worklets as a dependency so he cannot use the worklet API.
|
|
141
|
-
throw new Error(
|
|
142
|
-
'[RnAudioApi] Worklets are not available, please install react-native-worklets as a dependency. Refer to documentation for more details.'
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
const shareableWorklet = workletsModule.makeShareableCloneRecursive(
|
|
146
|
-
(
|
|
147
|
-
audioBuffers: Array<ArrayBuffer>,
|
|
148
|
-
framesToProcess: number,
|
|
149
|
-
currentTime: number,
|
|
150
|
-
startOffset: number
|
|
151
|
-
) => {
|
|
152
|
-
'worklet';
|
|
153
|
-
const floatAudioData: Array<Float32Array> = audioBuffers.map(
|
|
154
|
-
(buffer) => new Float32Array(buffer)
|
|
155
|
-
);
|
|
156
|
-
callback(floatAudioData, framesToProcess, currentTime, startOffset);
|
|
157
|
-
}
|
|
158
|
-
);
|
|
159
|
-
return new WorkletSourceNode(
|
|
160
|
-
this,
|
|
161
|
-
this.context.createWorkletSourceNode(
|
|
162
|
-
shareableWorklet,
|
|
163
|
-
workletRuntime === 'UIRuntime'
|
|
164
|
-
)
|
|
165
|
-
);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
40
|
createRecorderAdapter(): RecorderAdapterNode {
|
|
169
41
|
return new RecorderAdapterNode(this, this.context.createRecorderAdapter());
|
|
170
42
|
}
|
|
@@ -177,10 +49,6 @@ export default class BaseAudioContext {
|
|
|
177
49
|
return new StreamerNode(this, this.context.createStreamer());
|
|
178
50
|
}
|
|
179
51
|
|
|
180
|
-
createConstantSource(): ConstantSourceNode {
|
|
181
|
-
return new ConstantSourceNode(this, this.context.createConstantSource());
|
|
182
|
-
}
|
|
183
|
-
|
|
184
52
|
createGain(): GainNode {
|
|
185
53
|
return new GainNode(this, this.context.createGain());
|
|
186
54
|
}
|
|
@@ -194,7 +62,7 @@ export default class BaseAudioContext {
|
|
|
194
62
|
}
|
|
195
63
|
|
|
196
64
|
createBufferSource(
|
|
197
|
-
options?:
|
|
65
|
+
options?: AudioBufferSourceNodeOptions
|
|
198
66
|
): AudioBufferSourceNode {
|
|
199
67
|
const pitchCorrection = options?.pitchCorrection ?? false;
|
|
200
68
|
|
|
@@ -204,14 +72,10 @@ export default class BaseAudioContext {
|
|
|
204
72
|
);
|
|
205
73
|
}
|
|
206
74
|
|
|
207
|
-
createBufferQueueSource(
|
|
208
|
-
options?: AudioBufferBaseSourceNodeOptions
|
|
209
|
-
): AudioBufferQueueSourceNode {
|
|
210
|
-
const pitchCorrection = options?.pitchCorrection ?? false;
|
|
211
|
-
|
|
75
|
+
createBufferQueueSource(): AudioBufferQueueSourceNode {
|
|
212
76
|
return new AudioBufferQueueSourceNode(
|
|
213
77
|
this,
|
|
214
|
-
this.context.createBufferQueueSource(
|
|
78
|
+
this.context.createBufferQueueSource()
|
|
215
79
|
);
|
|
216
80
|
}
|
|
217
81
|
|
|
@@ -3,17 +3,12 @@ import BaseAudioContext from './BaseAudioContext';
|
|
|
3
3
|
import { OfflineAudioContextOptions } from '../types';
|
|
4
4
|
import { InvalidStateError, NotSupportedError } from '../errors';
|
|
5
5
|
import AudioBuffer from './AudioBuffer';
|
|
6
|
-
import { isWorkletsAvailable, workletsModule } from '../utils';
|
|
7
6
|
|
|
8
7
|
export default class OfflineAudioContext extends BaseAudioContext {
|
|
9
8
|
private isSuspended: boolean;
|
|
10
9
|
private isRendering: boolean;
|
|
11
10
|
private duration: number;
|
|
12
11
|
|
|
13
|
-
// We need to keep here a reference to this runtime to better manage its lifecycle
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
|
|
15
|
-
private _audioRuntime: any;
|
|
16
|
-
|
|
17
12
|
constructor(options: OfflineAudioContextOptions);
|
|
18
13
|
constructor(numberOfChannels: number, length: number, sampleRate: number);
|
|
19
14
|
constructor(
|
|
@@ -21,20 +16,10 @@ export default class OfflineAudioContext extends BaseAudioContext {
|
|
|
21
16
|
arg1?: number,
|
|
22
17
|
arg2?: number
|
|
23
18
|
) {
|
|
24
|
-
let audioRuntime = null;
|
|
25
|
-
if (isWorkletsAvailable) {
|
|
26
|
-
audioRuntime = workletsModule.createWorkletRuntime('AudioWorkletRuntime');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
19
|
if (typeof arg0 === 'object') {
|
|
30
20
|
const { numberOfChannels, length, sampleRate } = arg0;
|
|
31
21
|
super(
|
|
32
|
-
global.createOfflineAudioContext(
|
|
33
|
-
numberOfChannels,
|
|
34
|
-
length,
|
|
35
|
-
sampleRate,
|
|
36
|
-
audioRuntime
|
|
37
|
-
)
|
|
22
|
+
global.createOfflineAudioContext(numberOfChannels, length, sampleRate)
|
|
38
23
|
);
|
|
39
24
|
|
|
40
25
|
this.duration = length / sampleRate;
|
|
@@ -43,7 +28,7 @@ export default class OfflineAudioContext extends BaseAudioContext {
|
|
|
43
28
|
typeof arg1 === 'number' &&
|
|
44
29
|
typeof arg2 === 'number'
|
|
45
30
|
) {
|
|
46
|
-
super(global.createOfflineAudioContext(arg0, arg1, arg2
|
|
31
|
+
super(global.createOfflineAudioContext(arg0, arg1, arg2));
|
|
47
32
|
this.duration = arg1 / arg2;
|
|
48
33
|
} else {
|
|
49
34
|
throw new NotSupportedError('Invalid constructor arguments');
|
|
@@ -51,7 +36,6 @@ export default class OfflineAudioContext extends BaseAudioContext {
|
|
|
51
36
|
|
|
52
37
|
this.isSuspended = false;
|
|
53
38
|
this.isRendering = false;
|
|
54
|
-
this._audioRuntime = audioRuntime;
|
|
55
39
|
}
|
|
56
40
|
|
|
57
41
|
async resume(): Promise<undefined> {
|
|
@@ -5,7 +5,6 @@ import AudioParam from './AudioParam';
|
|
|
5
5
|
import BaseAudioContext from './BaseAudioContext';
|
|
6
6
|
import PeriodicWave from './PeriodicWave';
|
|
7
7
|
import { InvalidStateError } from '../errors';
|
|
8
|
-
import { EventEmptyType } from '../events/types';
|
|
9
8
|
|
|
10
9
|
export default class OscillatorNode extends AudioScheduledSourceNode {
|
|
11
10
|
readonly frequency: AudioParam;
|
|
@@ -35,14 +34,4 @@ export default class OscillatorNode extends AudioScheduledSourceNode {
|
|
|
35
34
|
public setPeriodicWave(wave: PeriodicWave): void {
|
|
36
35
|
(this.node as IOscillatorNode).setPeriodicWave(wave.periodicWave);
|
|
37
36
|
}
|
|
38
|
-
|
|
39
|
-
public override get onEnded(): ((event: EventEmptyType) => void) | undefined {
|
|
40
|
-
return super.onEnded as ((event: EventEmptyType) => void) | undefined;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public override set onEnded(
|
|
44
|
-
callback: ((event: EventEmptyType) => void) | null
|
|
45
|
-
) {
|
|
46
|
-
super.onEnded = callback;
|
|
47
|
-
}
|
|
48
37
|
}
|
package/src/events/types.ts
CHANGED
|
@@ -46,7 +46,6 @@ type SystemEvents = RemoteCommandEvents & {
|
|
|
46
46
|
|
|
47
47
|
export interface OnEndedEventType extends EventEmptyType {
|
|
48
48
|
bufferId: string | undefined;
|
|
49
|
-
isLast: boolean | undefined;
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
export interface OnAudioReadyEventType {
|
|
@@ -57,7 +56,6 @@ export interface OnAudioReadyEventType {
|
|
|
57
56
|
|
|
58
57
|
interface AudioAPIEvents {
|
|
59
58
|
ended: OnEndedEventType;
|
|
60
|
-
loopEnded: EventEmptyType;
|
|
61
59
|
audioReady: OnAudioReadyEventType;
|
|
62
60
|
positionChanged: EventTypeWithValue;
|
|
63
61
|
audioError: EventEmptyType; // to change
|
package/src/interfaces.ts
CHANGED
|
@@ -1,36 +1,12 @@
|
|
|
1
|
-
import { AudioEventCallback, AudioEventName } from './events/types';
|
|
2
1
|
import {
|
|
2
|
+
WindowType,
|
|
3
|
+
ContextState,
|
|
4
|
+
OscillatorType,
|
|
3
5
|
BiquadFilterType,
|
|
4
6
|
ChannelCountMode,
|
|
5
7
|
ChannelInterpretation,
|
|
6
|
-
ContextState,
|
|
7
|
-
OscillatorType,
|
|
8
|
-
WindowType,
|
|
9
8
|
} from './types';
|
|
10
|
-
|
|
11
|
-
export type WorkletNodeCallback = (
|
|
12
|
-
audioData: Array<ArrayBuffer>,
|
|
13
|
-
channelCount: number
|
|
14
|
-
) => void;
|
|
15
|
-
|
|
16
|
-
export type WorkletSourceNodeCallback = (
|
|
17
|
-
audioData: Array<ArrayBuffer>,
|
|
18
|
-
framesToProcess: number,
|
|
19
|
-
currentTime: number,
|
|
20
|
-
startOffset: number
|
|
21
|
-
) => void;
|
|
22
|
-
|
|
23
|
-
export type WorkletProcessingNodeCallback = (
|
|
24
|
-
inputData: Array<ArrayBuffer>,
|
|
25
|
-
outputData: Array<ArrayBuffer>,
|
|
26
|
-
framesToProcess: number,
|
|
27
|
-
currentTime: number
|
|
28
|
-
) => void;
|
|
29
|
-
|
|
30
|
-
export type ShareableWorkletCallback =
|
|
31
|
-
| WorkletNodeCallback
|
|
32
|
-
| WorkletSourceNodeCallback
|
|
33
|
-
| WorkletProcessingNodeCallback;
|
|
9
|
+
import { AudioEventName, AudioEventCallback } from './events/types';
|
|
34
10
|
|
|
35
11
|
export interface IBaseAudioContext {
|
|
36
12
|
readonly destination: IAudioDestinationNode;
|
|
@@ -39,29 +15,12 @@ export interface IBaseAudioContext {
|
|
|
39
15
|
readonly currentTime: number;
|
|
40
16
|
|
|
41
17
|
createRecorderAdapter(): IRecorderAdapterNode;
|
|
42
|
-
createWorkletSourceNode(
|
|
43
|
-
shareableWorklet: ShareableWorkletCallback,
|
|
44
|
-
shouldUseUiRuntime: boolean
|
|
45
|
-
): IWorkletSourceNode;
|
|
46
|
-
createWorkletNode(
|
|
47
|
-
shareableWorklet: ShareableWorkletCallback,
|
|
48
|
-
shouldUseUiRuntime: boolean,
|
|
49
|
-
bufferLength: number,
|
|
50
|
-
inputChannelCount: number
|
|
51
|
-
): IWorkletNode;
|
|
52
|
-
createWorkletProcessingNode(
|
|
53
|
-
shareableWorklet: ShareableWorkletCallback,
|
|
54
|
-
shouldUseUiRuntime: boolean
|
|
55
|
-
): IWorkletProcessingNode;
|
|
56
18
|
createOscillator(): IOscillatorNode;
|
|
57
|
-
createConstantSource(): IConstantSourceNode;
|
|
58
19
|
createGain(): IGainNode;
|
|
59
20
|
createStereoPanner(): IStereoPannerNode;
|
|
60
21
|
createBiquadFilter: () => IBiquadFilterNode;
|
|
61
22
|
createBufferSource: (pitchCorrection: boolean) => IAudioBufferSourceNode;
|
|
62
|
-
createBufferQueueSource: (
|
|
63
|
-
pitchCorrection: boolean
|
|
64
|
-
) => IAudioBufferQueueSourceNode;
|
|
23
|
+
createBufferQueueSource: () => IAudioBufferQueueSourceNode;
|
|
65
24
|
createBuffer: (
|
|
66
25
|
channels: number,
|
|
67
26
|
length: number,
|
|
@@ -160,10 +119,6 @@ export interface IStreamerNode extends IAudioNode {
|
|
|
160
119
|
initialize(streamPath: string): boolean;
|
|
161
120
|
}
|
|
162
121
|
|
|
163
|
-
export interface IConstantSourceNode extends IAudioScheduledSourceNode {
|
|
164
|
-
readonly offset: IAudioParam;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
122
|
export interface IAudioBufferSourceNode extends IAudioBufferBaseSourceNode {
|
|
168
123
|
buffer: IAudioBuffer | null;
|
|
169
124
|
loop: boolean;
|
|
@@ -173,9 +128,6 @@ export interface IAudioBufferSourceNode extends IAudioBufferBaseSourceNode {
|
|
|
173
128
|
|
|
174
129
|
start: (when?: number, offset?: number, duration?: number) => void;
|
|
175
130
|
setBuffer: (audioBuffer: IAudioBuffer | null) => void;
|
|
176
|
-
|
|
177
|
-
// passing subscriptionId(uint_64 in cpp, string in js) to the cpp
|
|
178
|
-
onLoopEnded: string;
|
|
179
131
|
}
|
|
180
132
|
|
|
181
133
|
export interface IAudioBufferQueueSourceNode
|
|
@@ -248,12 +200,6 @@ export interface IAnalyserNode extends IAudioNode {
|
|
|
248
200
|
|
|
249
201
|
export interface IRecorderAdapterNode extends IAudioNode {}
|
|
250
202
|
|
|
251
|
-
export interface IWorkletNode extends IAudioNode {}
|
|
252
|
-
|
|
253
|
-
export interface IWorkletSourceNode extends IAudioScheduledSourceNode {}
|
|
254
|
-
|
|
255
|
-
export interface IWorkletProcessingNode extends IAudioNode {}
|
|
256
|
-
|
|
257
203
|
export interface IAudioRecorder {
|
|
258
204
|
start: () => void;
|
|
259
205
|
stop: () => void;
|
package/src/types.ts
CHANGED
|
@@ -14,8 +14,6 @@ export type BiquadFilterType =
|
|
|
14
14
|
|
|
15
15
|
export type ContextState = 'running' | 'closed' | `suspended`;
|
|
16
16
|
|
|
17
|
-
export type AudioWorkletRuntime = 'AudioRuntime' | 'UIRuntime';
|
|
18
|
-
|
|
19
17
|
export type OscillatorType =
|
|
20
18
|
| 'sine'
|
|
21
19
|
| 'square'
|
|
@@ -45,7 +43,7 @@ export interface AudioRecorderOptions {
|
|
|
45
43
|
|
|
46
44
|
export type WindowType = 'blackman' | 'hann';
|
|
47
45
|
|
|
48
|
-
export interface
|
|
46
|
+
export interface AudioBufferSourceNodeOptions {
|
|
49
47
|
pitchCorrection: boolean;
|
|
50
48
|
}
|
|
51
49
|
|
package/src/utils/index.ts
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
import type { ShareableWorkletCallback } from '../interfaces';
|
|
2
|
-
|
|
3
|
-
interface SimplifiedWorkletModule {
|
|
4
|
-
makeShareableCloneRecursive: (
|
|
5
|
-
workletCallback: ShareableWorkletCallback
|
|
6
|
-
) => ShareableWorkletCallback;
|
|
7
|
-
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
-
createWorkletRuntime: (options?: any) => any;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
1
|
export function clamp(value: number, min: number, max: number): number {
|
|
13
2
|
return Math.min(Math.max(value, min), max);
|
|
14
3
|
}
|
|
15
|
-
|
|
16
|
-
export let isWorkletsAvailable = false;
|
|
17
|
-
export let workletsModule: SimplifiedWorkletModule;
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
workletsModule = require('react-native-worklets');
|
|
21
|
-
isWorkletsAvailable = true;
|
|
22
|
-
} catch (error) {
|
|
23
|
-
isWorkletsAvailable = false;
|
|
24
|
-
}
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
ContextState,
|
|
3
3
|
PeriodicWaveConstraints,
|
|
4
4
|
AudioContextOptions,
|
|
5
|
-
|
|
5
|
+
AudioBufferSourceNodeOptions,
|
|
6
6
|
} from '../types';
|
|
7
7
|
import { InvalidAccessError, NotSupportedError } from '../errors';
|
|
8
8
|
import BaseAudioContext from './BaseAudioContext';
|
|
@@ -17,7 +17,6 @@ import PeriodicWave from './PeriodicWave';
|
|
|
17
17
|
import StereoPannerNode from './StereoPannerNode';
|
|
18
18
|
|
|
19
19
|
import { globalWasmPromise, globalTag } from './custom/LoadCustomWasm';
|
|
20
|
-
import ConstantSourceNode from './ConstantSourceNode';
|
|
21
20
|
|
|
22
21
|
export default class AudioContext implements BaseAudioContext {
|
|
23
22
|
readonly context: globalThis.AudioContext;
|
|
@@ -54,10 +53,6 @@ export default class AudioContext implements BaseAudioContext {
|
|
|
54
53
|
return new OscillatorNode(this, this.context.createOscillator());
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
createConstantSource(): ConstantSourceNode {
|
|
58
|
-
return new ConstantSourceNode(this, this.context.createConstantSource());
|
|
59
|
-
}
|
|
60
|
-
|
|
61
56
|
createGain(): GainNode {
|
|
62
57
|
return new GainNode(this, this.context.createGain());
|
|
63
58
|
}
|
|
@@ -71,7 +66,7 @@ export default class AudioContext implements BaseAudioContext {
|
|
|
71
66
|
}
|
|
72
67
|
|
|
73
68
|
async createBufferSource(
|
|
74
|
-
options?:
|
|
69
|
+
options?: AudioBufferSourceNodeOptions
|
|
75
70
|
): Promise<AudioBufferSourceNode> {
|
|
76
71
|
if (!options || !options.pitchCorrection) {
|
|
77
72
|
return new AudioBufferSourceNode(
|
|
@@ -37,7 +37,7 @@ export default class AudioScheduledSourceNode extends AudioNode {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// eslint-disable-next-line accessor-pairs
|
|
40
|
-
public set
|
|
40
|
+
public set onended(callback: (event: EventEmptyType) => void) {
|
|
41
41
|
(this.node as globalThis.AudioScheduledSourceNode).onended = callback;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -8,7 +8,6 @@ import GainNode from './GainNode';
|
|
|
8
8
|
import OscillatorNode from './OscillatorNode';
|
|
9
9
|
import PeriodicWave from './PeriodicWave';
|
|
10
10
|
import StereoPannerNode from './StereoPannerNode';
|
|
11
|
-
import ConstantSourceNode from './ConstantSourceNode';
|
|
12
11
|
|
|
13
12
|
export default interface BaseAudioContext {
|
|
14
13
|
readonly context: globalThis.BaseAudioContext;
|
|
@@ -19,7 +18,6 @@ export default interface BaseAudioContext {
|
|
|
19
18
|
get currentTime(): number;
|
|
20
19
|
get state(): ContextState;
|
|
21
20
|
createOscillator(): OscillatorNode;
|
|
22
|
-
createConstantSource(): ConstantSourceNode;
|
|
23
21
|
createGain(): GainNode;
|
|
24
22
|
createStereoPanner(): StereoPannerNode;
|
|
25
23
|
createBiquadFilter(): BiquadFilterNode;
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
ContextState,
|
|
3
3
|
PeriodicWaveConstraints,
|
|
4
4
|
OfflineAudioContextOptions,
|
|
5
|
-
|
|
5
|
+
AudioBufferSourceNodeOptions,
|
|
6
6
|
} from '../types';
|
|
7
7
|
import { InvalidAccessError, NotSupportedError } from '../errors';
|
|
8
8
|
import BaseAudioContext from './BaseAudioContext';
|
|
@@ -15,7 +15,6 @@ import GainNode from './GainNode';
|
|
|
15
15
|
import OscillatorNode from './OscillatorNode';
|
|
16
16
|
import PeriodicWave from './PeriodicWave';
|
|
17
17
|
import StereoPannerNode from './StereoPannerNode';
|
|
18
|
-
import ConstantSourceNode from './ConstantSourceNode';
|
|
19
18
|
|
|
20
19
|
import { globalWasmPromise, globalTag } from './custom/LoadCustomWasm';
|
|
21
20
|
|
|
@@ -60,10 +59,6 @@ export default class OfflineAudioContext implements BaseAudioContext {
|
|
|
60
59
|
return new OscillatorNode(this, this.context.createOscillator());
|
|
61
60
|
}
|
|
62
61
|
|
|
63
|
-
createConstantSource(): ConstantSourceNode {
|
|
64
|
-
return new ConstantSourceNode(this, this.context.createConstantSource());
|
|
65
|
-
}
|
|
66
|
-
|
|
67
62
|
createGain(): GainNode {
|
|
68
63
|
return new GainNode(this, this.context.createGain());
|
|
69
64
|
}
|
|
@@ -77,7 +72,7 @@ export default class OfflineAudioContext implements BaseAudioContext {
|
|
|
77
72
|
}
|
|
78
73
|
|
|
79
74
|
async createBufferSource(
|
|
80
|
-
options?:
|
|
75
|
+
options?: AudioBufferSourceNodeOptions
|
|
81
76
|
): Promise<AudioBufferSourceNode> {
|
|
82
77
|
if (!options || !options.pitchCorrection) {
|
|
83
78
|
return new AudioBufferSourceNode(
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
#include <fbjni/fbjni.h>
|
|
5
|
-
#include <react/jni/CxxModuleWrapper.h>
|
|
6
|
-
#include <react/jni/JMessageQueueThread.h>
|
|
7
|
-
#include <memory>
|
|
8
|
-
#include <utility>
|
|
9
|
-
#include <unordered_map>
|
|
10
|
-
|
|
11
|
-
namespace audioapi {
|
|
12
|
-
|
|
13
|
-
using namespace facebook;
|
|
14
|
-
using namespace react;
|
|
15
|
-
|
|
16
|
-
class NativeAudioRecorder : public jni::JavaClass<NativeAudioRecorder> {
|
|
17
|
-
public:
|
|
18
|
-
static auto constexpr kJavaDescriptor =
|
|
19
|
-
"Lcom/swmansion/audioapi/core/NativeAudioRecorder;";
|
|
20
|
-
|
|
21
|
-
static jni::local_ref<NativeAudioRecorder> create() {
|
|
22
|
-
return newInstance();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
void start() {
|
|
26
|
-
static const auto method = javaClassStatic()->getMethod<void()>("start");
|
|
27
|
-
method(self());
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
void stop() {
|
|
31
|
-
static const auto method = javaClassStatic()->getMethod<void()>("stop");
|
|
32
|
-
method(self());
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
} // namespace audioapi
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
package com.swmansion.audioapi.core
|
|
2
|
-
|
|
3
|
-
import com.facebook.common.internal.DoNotStrip
|
|
4
|
-
import com.swmansion.audioapi.system.MediaSessionManager
|
|
5
|
-
|
|
6
|
-
@DoNotStrip
|
|
7
|
-
class NativeAudioRecorder {
|
|
8
|
-
private var inputNodeId: String? = null
|
|
9
|
-
|
|
10
|
-
@DoNotStrip
|
|
11
|
-
fun start() {
|
|
12
|
-
this.inputNodeId = MediaSessionManager.attachAudioRecorder(this)
|
|
13
|
-
MediaSessionManager.startForegroundServiceIfNecessary()
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
@DoNotStrip
|
|
17
|
-
fun stop() {
|
|
18
|
-
this.inputNodeId?.let {
|
|
19
|
-
MediaSessionManager.detachAudioRecorder(it)
|
|
20
|
-
this.inputNodeId = null
|
|
21
|
-
}
|
|
22
|
-
MediaSessionManager.stopForegroundServiceIfNecessary()
|
|
23
|
-
}
|
|
24
|
-
}
|