react-native-audio-api 0.0.1 → 0.1.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 +58 -1
- package/RNAudioAPI.podspec +41 -0
- package/android/CMakeLists.txt +63 -0
- package/android/build.gradle +194 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +3 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/cpp/AudioAPIInstaller/AudioAPIInstaller.cpp +22 -0
- package/android/src/main/cpp/AudioAPIInstaller/AudioAPIInstaller.h +48 -0
- package/android/src/main/cpp/AudioPlayer/AudioPlayer.cpp +45 -0
- package/android/src/main/cpp/AudioPlayer/AudioPlayer.h +30 -0
- package/android/src/main/cpp/OnLoad.cpp +9 -0
- package/android/src/main/java/com/swmansion/audioapi/AudioAPIPackage.kt +14 -0
- package/android/src/main/java/com/swmansion/audioapi/module/AudioAPIInstaller.kt +21 -0
- package/android/src/main/java/com/swmansion/audioapi/nativemodules/AudioAPIModule.kt +25 -0
- package/common/cpp/AudioAPIInstaller/AudioAPIInstallerHostObject.cpp +52 -0
- package/common/cpp/AudioAPIInstaller/AudioAPIInstallerHostObject.h +45 -0
- package/common/cpp/AudioAPIInstaller/AudioAPIInstallerWrapper.h +38 -0
- package/common/cpp/AudioAPIInstaller/android/AudioAPIInstallerWrapper.cpp +16 -0
- package/common/cpp/AudioAPIInstaller/ios/AudioAPIInstallerWrapper.cpp +12 -0
- package/common/cpp/HostObjects/AudioBufferHostObject.cpp +143 -0
- package/common/cpp/HostObjects/AudioBufferHostObject.h +33 -0
- package/common/cpp/HostObjects/AudioBufferSourceNodeHostObject.cpp +67 -0
- package/common/cpp/HostObjects/AudioBufferSourceNodeHostObject.h +37 -0
- package/common/cpp/HostObjects/AudioContextHostObject.cpp +191 -0
- package/common/cpp/HostObjects/AudioContextHostObject.h +43 -0
- package/common/cpp/HostObjects/AudioDestinationNodeHostObject.cpp +33 -0
- package/common/cpp/HostObjects/AudioDestinationNodeHostObject.h +31 -0
- package/common/cpp/HostObjects/AudioNodeHostObject.cpp +108 -0
- package/common/cpp/HostObjects/AudioNodeHostObject.h +29 -0
- package/common/cpp/HostObjects/AudioParamHostObject.cpp +115 -0
- package/common/cpp/HostObjects/AudioParamHostObject.h +34 -0
- package/common/cpp/HostObjects/AudioScheduledSourceNodeHostObject.cpp +73 -0
- package/common/cpp/HostObjects/AudioScheduledSourceNodeHostObject.h +31 -0
- package/common/cpp/HostObjects/BiquadFilterNodeHostObject.cpp +81 -0
- package/common/cpp/HostObjects/BiquadFilterNodeHostObject.h +42 -0
- package/common/cpp/HostObjects/Constants.h +22 -0
- package/common/cpp/HostObjects/GainNodeHostObject.cpp +41 -0
- package/common/cpp/HostObjects/GainNodeHostObject.h +32 -0
- package/common/cpp/HostObjects/OscillatorNodeHostObject.cpp +67 -0
- package/common/cpp/HostObjects/OscillatorNodeHostObject.h +40 -0
- package/common/cpp/HostObjects/StereoPannerNodeHostObject.cpp +41 -0
- package/common/cpp/HostObjects/StereoPannerNodeHostObject.h +36 -0
- package/common/cpp/core/AudioBuffer.cpp +115 -0
- package/common/cpp/core/AudioBuffer.h +42 -0
- package/common/cpp/core/AudioBufferSourceNode.cpp +58 -0
- package/common/cpp/core/AudioBufferSourceNode.h +26 -0
- package/common/cpp/core/AudioContext.cpp +90 -0
- package/common/cpp/core/AudioContext.h +73 -0
- package/common/cpp/core/AudioDestinationNode.cpp +35 -0
- package/common/cpp/core/AudioDestinationNode.h +24 -0
- package/common/cpp/core/AudioNode.cpp +68 -0
- package/common/cpp/core/AudioNode.h +74 -0
- package/common/cpp/core/AudioParam.cpp +136 -0
- package/common/cpp/core/AudioParam.h +50 -0
- package/common/cpp/core/AudioScheduledSourceNode.cpp +39 -0
- package/common/cpp/core/AudioScheduledSourceNode.h +30 -0
- package/common/cpp/core/BiquadFilterNode.cpp +364 -0
- package/common/cpp/core/BiquadFilterNode.h +128 -0
- package/common/cpp/core/GainNode.cpp +30 -0
- package/common/cpp/core/GainNode.h +23 -0
- package/common/cpp/core/OscillatorNode.cpp +66 -0
- package/common/cpp/core/OscillatorNode.h +112 -0
- package/common/cpp/core/ParamChange.cpp +46 -0
- package/common/cpp/core/ParamChange.h +34 -0
- package/common/cpp/core/StereoPannerNode.cpp +58 -0
- package/common/cpp/core/StereoPannerNode.h +26 -0
- package/common/cpp/utils/VectorMath.cpp +609 -0
- package/common/cpp/utils/VectorMath.h +65 -0
- package/common/cpp/wrappers/AudioBufferSourceNodeWrapper.cpp +35 -0
- package/common/cpp/wrappers/AudioBufferSourceNodeWrapper.h +25 -0
- package/common/cpp/wrappers/AudioBufferWrapper.cpp +46 -0
- package/common/cpp/wrappers/AudioBufferWrapper.h +30 -0
- package/common/cpp/wrappers/AudioContextWrapper.cpp +70 -0
- package/common/cpp/wrappers/AudioContextWrapper.h +40 -0
- package/common/cpp/wrappers/AudioDestinationNodeWrapper.h +16 -0
- package/common/cpp/wrappers/AudioNodeWrapper.cpp +37 -0
- package/common/cpp/wrappers/AudioNodeWrapper.h +25 -0
- package/common/cpp/wrappers/AudioParamWrapper.cpp +42 -0
- package/common/cpp/wrappers/AudioParamWrapper.h +25 -0
- package/common/cpp/wrappers/AudioScheduledSourceNodeWrapper.cpp +23 -0
- package/common/cpp/wrappers/AudioScheduledSourceNodeWrapper.h +23 -0
- package/common/cpp/wrappers/BiquadFilterNodeWrapper.cpp +51 -0
- package/common/cpp/wrappers/BiquadFilterNodeWrapper.h +32 -0
- package/common/cpp/wrappers/GainNodeWrapper.cpp +14 -0
- package/common/cpp/wrappers/GainNodeWrapper.h +20 -0
- package/common/cpp/wrappers/OscillatorNodeWrapper.cpp +38 -0
- package/common/cpp/wrappers/OscillatorNodeWrapper.h +28 -0
- package/common/cpp/wrappers/StereoPannerNodeWrapper.cpp +16 -0
- package/common/cpp/wrappers/StereoPannerNodeWrapper.h +21 -0
- package/ios/AudioAPIModule.h +5 -0
- package/ios/AudioAPIModule.mm +44 -0
- package/ios/AudioPlayer/AudioPlayer.h +27 -0
- package/ios/AudioPlayer/AudioPlayer.m +121 -0
- package/ios/AudioPlayer/IOSAudioPlayer.h +29 -0
- package/ios/AudioPlayer/IOSAudioPlayer.mm +34 -0
- package/lib/module/index.js +39 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/modules/global.d.js +2 -0
- package/lib/module/modules/global.d.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/utils/install.js +22 -0
- package/lib/module/utils/install.js.map +1 -0
- package/lib/typescript/index.d.ts +18 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +76 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/lib/typescript/utils/install.d.ts +7 -0
- package/lib/typescript/utils/install.d.ts.map +1 -0
- package/package.json +104 -5
- package/src/index.ts +79 -0
- package/src/modules/global.d.ts +10 -0
- package/src/types.ts +108 -0
- package/src/utils/install.ts +39 -0
- package/index.ts +0 -1
package/src/types.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
export interface BaseAudioContext {
|
|
2
|
+
readonly destination: AudioDestinationNode;
|
|
3
|
+
readonly state: ContextState;
|
|
4
|
+
readonly sampleRate: number;
|
|
5
|
+
readonly currentTime: number;
|
|
6
|
+
createOscillator(): OscillatorNode;
|
|
7
|
+
createGain(): GainNode;
|
|
8
|
+
createStereoPanner(): StereoPannerNode;
|
|
9
|
+
createBiquadFilter: () => BiquadFilterNode;
|
|
10
|
+
createBufferSource: () => AudioBufferSourceNode;
|
|
11
|
+
createBuffer: (
|
|
12
|
+
channels: number,
|
|
13
|
+
length: number,
|
|
14
|
+
sampleRate: number
|
|
15
|
+
) => AudioBuffer;
|
|
16
|
+
close(): void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type channelCountMode = 'max' | 'clamped-max' | 'explicit';
|
|
20
|
+
|
|
21
|
+
type channelInterpretation = 'speakers' | 'discrete';
|
|
22
|
+
|
|
23
|
+
export interface AudioNode {
|
|
24
|
+
readonly context: BaseAudioContext;
|
|
25
|
+
readonly numberOfInputs: number;
|
|
26
|
+
readonly numberOfOutputs: number;
|
|
27
|
+
readonly channelCount: number;
|
|
28
|
+
readonly channelCountMode: channelCountMode;
|
|
29
|
+
readonly channelInterpretation: channelInterpretation;
|
|
30
|
+
connect: (node: AudioNode) => void;
|
|
31
|
+
disconnect: (node: AudioNode) => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface AudioParam {
|
|
35
|
+
value: number;
|
|
36
|
+
defaultValue: number;
|
|
37
|
+
minValue: number;
|
|
38
|
+
maxValue: number;
|
|
39
|
+
setValueAtTime: (value: number, startTime: number) => void;
|
|
40
|
+
linearRampToValueAtTime: (value: number, endTime: number) => void;
|
|
41
|
+
exponentialRampToValueAtTime: (value: number, endTime: number) => void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface AudioDestinationNode extends AudioNode {}
|
|
45
|
+
|
|
46
|
+
export interface AudioScheduledSourceNode extends AudioNode {
|
|
47
|
+
start: (time: number) => void;
|
|
48
|
+
stop: (time: number) => void;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type WaveType = 'sine' | 'square' | 'sawtooth' | 'triangle';
|
|
52
|
+
|
|
53
|
+
export interface OscillatorNode extends AudioScheduledSourceNode {
|
|
54
|
+
frequency: AudioParam;
|
|
55
|
+
type: WaveType;
|
|
56
|
+
detune: AudioParam;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface GainNode extends AudioNode {
|
|
60
|
+
gain: AudioParam;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface StereoPannerNode extends AudioNode {
|
|
64
|
+
pan: AudioParam;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
type FilterType =
|
|
68
|
+
| 'lowpass'
|
|
69
|
+
| 'highpass'
|
|
70
|
+
| 'bandpass'
|
|
71
|
+
| 'lowshelf'
|
|
72
|
+
| 'highshelf'
|
|
73
|
+
| 'peaking'
|
|
74
|
+
| 'notch'
|
|
75
|
+
| 'allpass';
|
|
76
|
+
|
|
77
|
+
export interface BiquadFilterNode extends AudioNode {
|
|
78
|
+
frequency: AudioParam;
|
|
79
|
+
detune: AudioParam;
|
|
80
|
+
Q: AudioParam;
|
|
81
|
+
gain: AudioParam;
|
|
82
|
+
type: FilterType;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type ContextState = 'running' | 'closed' | 'suspended';
|
|
86
|
+
|
|
87
|
+
export interface AudioBuffer {
|
|
88
|
+
readonly length: number;
|
|
89
|
+
readonly duration: number;
|
|
90
|
+
readonly sampleRate: number;
|
|
91
|
+
readonly numberOfChannels: number;
|
|
92
|
+
getChannelData(channel: number): number[];
|
|
93
|
+
copyFromChannel(
|
|
94
|
+
destination: number[],
|
|
95
|
+
channelNumber: number,
|
|
96
|
+
startInChannel: number
|
|
97
|
+
): void;
|
|
98
|
+
copyToChannel(
|
|
99
|
+
source: number[],
|
|
100
|
+
channelNumber: number,
|
|
101
|
+
startInChannel: number
|
|
102
|
+
): void;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface AudioBufferSourceNode extends AudioScheduledSourceNode {
|
|
106
|
+
buffer: AudioBuffer;
|
|
107
|
+
loop: boolean;
|
|
108
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { TurboModuleRegistry, TurboModule } from 'react-native';
|
|
2
|
+
|
|
3
|
+
interface AudioAPIModuleSpec extends TurboModule {
|
|
4
|
+
install(): boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function installModule() {
|
|
8
|
+
const AudioAPIModule =
|
|
9
|
+
TurboModuleRegistry.getEnforcing<AudioAPIModuleSpec>('AudioAPIModule');
|
|
10
|
+
|
|
11
|
+
if (AudioAPIModule == null) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
`Failed to install react-native-audio-api: The native module could not be found.`
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
runInstall(AudioAPIModule);
|
|
18
|
+
verifyInstallation();
|
|
19
|
+
|
|
20
|
+
return AudioAPIModule;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function runInstall(Module: any) {
|
|
24
|
+
const result = Module.install();
|
|
25
|
+
|
|
26
|
+
if (result !== true) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
`Failed to install react-native-audio-api: The native Audio API Module could not be installed! Looks like something went wrong when installing JSI bindings: ${result}`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function verifyInstallation() {
|
|
34
|
+
if (global.__AudioAPIInstaller == null) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
'Failed to install react-native-audio-api, the native initializer private does not exist. Are you trying to use Audio API from different JS Runtimes?'
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
}
|
package/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default {};
|