react-native-audio-api 0.1.0 → 0.2.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 +10 -8
- package/RNAudioAPI.podspec +5 -0
- package/android/CMakeLists.txt +21 -10
- package/android/libs/fftw3/arm64-v8a/libfftw3.a +0 -0
- package/android/libs/fftw3/armeabi-v7a/libfftw3.a +0 -0
- package/android/libs/fftw3/x86/libfftw3.a +0 -0
- package/android/libs/fftw3/x86_64/libfftw3.a +0 -0
- package/android/libs/include/fftw3/fftw3.h +413 -0
- package/android/src/main/cpp/AudioPlayer/AudioPlayer.cpp +23 -2
- package/android/src/main/cpp/AudioPlayer/AudioPlayer.h +5 -2
- package/common/cpp/HostObjects/AudioBufferSourceNodeHostObject.cpp +13 -1
- package/common/cpp/HostObjects/AudioContextHostObject.cpp +11 -148
- package/common/cpp/HostObjects/AudioContextHostObject.h +4 -11
- package/common/cpp/HostObjects/AudioNodeHostObject.cpp +0 -6
- package/common/cpp/HostObjects/BaseAudioContextHostObject.cpp +214 -0
- package/common/cpp/HostObjects/BaseAudioContextHostObject.h +39 -0
- package/common/cpp/HostObjects/BiquadFilterNodeHostObject.cpp +44 -0
- package/common/cpp/HostObjects/OscillatorNodeHostObject.cpp +21 -0
- package/common/cpp/HostObjects/OscillatorNodeHostObject.h +1 -0
- package/common/cpp/HostObjects/PeriodicWaveHostObject.cpp +33 -0
- package/common/cpp/HostObjects/PeriodicWaveHostObject.h +33 -0
- package/common/cpp/core/AudioArray.cpp +103 -0
- package/common/cpp/core/AudioArray.h +42 -0
- package/common/cpp/core/AudioBuffer.cpp +23 -83
- package/common/cpp/core/AudioBuffer.h +11 -13
- package/common/cpp/core/AudioBufferSourceNode.cpp +102 -25
- package/common/cpp/core/AudioBufferSourceNode.h +10 -6
- package/common/cpp/core/AudioBus.cpp +357 -0
- package/common/cpp/core/AudioBus.h +63 -0
- package/common/cpp/core/AudioContext.cpp +6 -72
- package/common/cpp/core/AudioContext.h +3 -60
- package/common/cpp/core/AudioDestinationNode.cpp +25 -15
- package/common/cpp/core/AudioDestinationNode.h +15 -7
- package/common/cpp/core/AudioNode.cpp +176 -22
- package/common/cpp/core/AudioNode.h +37 -37
- package/common/cpp/core/AudioNodeManager.cpp +72 -0
- package/common/cpp/core/AudioNodeManager.h +35 -0
- package/common/cpp/core/AudioParam.cpp +8 -11
- package/common/cpp/core/AudioParam.h +8 -8
- package/common/cpp/core/AudioScheduledSourceNode.cpp +19 -5
- package/common/cpp/core/AudioScheduledSourceNode.h +6 -2
- package/common/cpp/core/BaseAudioContext.cpp +157 -0
- package/common/cpp/core/BaseAudioContext.h +80 -0
- package/common/cpp/core/BiquadFilterNode.cpp +90 -69
- package/common/cpp/core/BiquadFilterNode.h +53 -57
- package/common/cpp/core/GainNode.cpp +12 -12
- package/common/cpp/core/GainNode.h +5 -3
- package/common/cpp/core/OscillatorNode.cpp +38 -29
- package/common/cpp/core/OscillatorNode.h +29 -69
- package/common/cpp/core/ParamChange.h +6 -6
- package/common/cpp/core/PeriodicWave.cpp +362 -0
- package/common/cpp/core/PeriodicWave.h +119 -0
- package/common/cpp/core/StereoPannerNode.cpp +28 -30
- package/common/cpp/core/StereoPannerNode.h +6 -6
- package/common/cpp/types/BiquadFilterType.h +19 -0
- package/common/cpp/types/ChannelCountMode.h +10 -0
- package/common/cpp/types/ChannelInterpretation.h +10 -0
- package/common/cpp/types/ContextState.h +10 -0
- package/common/cpp/types/OscillatorType.h +11 -0
- package/common/cpp/utils/FFTFrame.h +63 -0
- package/common/cpp/utils/Locker.h +47 -0
- package/common/cpp/utils/VectorMath.cpp +72 -3
- package/common/cpp/utils/VectorMath.h +7 -1
- package/common/cpp/utils/android/FFTFrame.cpp +22 -0
- package/common/cpp/utils/ios/FFTFrame.cpp +24 -0
- package/common/cpp/wrappers/AudioBufferSourceNodeWrapper.cpp +10 -0
- package/common/cpp/wrappers/AudioBufferSourceNodeWrapper.h +3 -2
- package/common/cpp/wrappers/AudioBufferWrapper.h +5 -5
- package/common/cpp/wrappers/AudioContextWrapper.cpp +7 -60
- package/common/cpp/wrappers/AudioContextWrapper.h +5 -26
- package/common/cpp/wrappers/AudioNodeWrapper.h +5 -5
- package/common/cpp/wrappers/AudioParamWrapper.h +4 -4
- package/common/cpp/wrappers/BaseAudioContextWrapper.cpp +76 -0
- package/common/cpp/wrappers/BaseAudioContextWrapper.h +49 -0
- package/common/cpp/wrappers/BiquadFilterNodeWrapper.cpp +9 -0
- package/common/cpp/wrappers/BiquadFilterNodeWrapper.h +9 -4
- package/common/cpp/wrappers/GainNodeWrapper.h +1 -1
- package/common/cpp/wrappers/OscillatorNodeWrapper.cpp +6 -0
- package/common/cpp/wrappers/OscillatorNodeWrapper.h +5 -2
- package/common/cpp/wrappers/PeriodicWaveWrapper.h +17 -0
- package/common/cpp/wrappers/StereoPannerNodeWrapper.h +1 -1
- package/ios/AudioAPIModule.h +20 -1
- package/ios/AudioAPIModule.mm +3 -3
- package/ios/AudioPlayer/AudioPlayer.h +3 -2
- package/ios/AudioPlayer/AudioPlayer.m +15 -17
- package/ios/AudioPlayer/IOSAudioPlayer.h +8 -4
- package/ios/AudioPlayer/IOSAudioPlayer.mm +30 -7
- package/lib/module/core/AudioBuffer.js +37 -0
- package/lib/module/core/AudioBuffer.js.map +1 -0
- package/lib/module/core/AudioBufferSourceNode.js +28 -0
- package/lib/module/core/AudioBufferSourceNode.js.map +1 -0
- package/lib/module/core/AudioContext.js +10 -0
- package/lib/module/core/AudioContext.js.map +1 -0
- package/lib/module/core/AudioDestinationNode.js +7 -0
- package/lib/module/core/AudioDestinationNode.js.map +1 -0
- package/lib/module/core/AudioNode.js +22 -0
- package/lib/module/core/AudioNode.js.map +1 -0
- package/lib/module/core/AudioParam.js +35 -0
- package/lib/module/core/AudioParam.js.map +1 -0
- package/lib/module/core/AudioScheduledSourceNode.js +28 -0
- package/lib/module/core/AudioScheduledSourceNode.js.map +1 -0
- package/lib/module/core/BaseAudioContext.js +57 -0
- package/lib/module/core/BaseAudioContext.js.map +1 -0
- package/lib/module/core/BiquadFilterNode.js +25 -0
- package/lib/module/core/BiquadFilterNode.js.map +1 -0
- package/lib/module/core/GainNode.js +9 -0
- package/lib/module/core/GainNode.js.map +1 -0
- package/lib/module/core/OscillatorNode.js +24 -0
- package/lib/module/core/OscillatorNode.js.map +1 -0
- package/lib/module/core/PeriodicWave.js +8 -0
- package/lib/module/core/PeriodicWave.js.map +1 -0
- package/lib/module/core/StereoPannerNode.js +9 -0
- package/lib/module/core/StereoPannerNode.js.map +1 -0
- package/lib/module/core/types.js.map +1 -0
- package/lib/module/errors/IndexSizeError.js +8 -0
- package/lib/module/errors/IndexSizeError.js.map +1 -0
- package/lib/module/errors/InvalidAccessError.js +8 -0
- package/lib/module/errors/InvalidAccessError.js.map +1 -0
- package/lib/module/errors/InvalidStateError.js +8 -0
- package/lib/module/errors/InvalidStateError.js.map +1 -0
- package/lib/module/errors/RangeError.js +8 -0
- package/lib/module/errors/RangeError.js.map +1 -0
- package/lib/module/errors/index.js +5 -0
- package/lib/module/errors/index.js.map +1 -0
- package/lib/module/index.js +13 -34
- package/lib/module/index.js.map +1 -1
- package/lib/module/interfaces.js +2 -0
- package/lib/module/interfaces.js.map +1 -0
- package/lib/typescript/core/AudioBuffer.d.ts +12 -0
- package/lib/typescript/core/AudioBuffer.d.ts.map +1 -0
- package/lib/typescript/core/AudioBufferSourceNode.d.ts +12 -0
- package/lib/typescript/core/AudioBufferSourceNode.d.ts.map +1 -0
- package/lib/typescript/core/AudioContext.d.ts +6 -0
- package/lib/typescript/core/AudioContext.d.ts.map +1 -0
- package/lib/typescript/core/AudioDestinationNode.d.ts +7 -0
- package/lib/typescript/core/AudioDestinationNode.d.ts.map +1 -0
- package/lib/typescript/core/AudioNode.d.ts +16 -0
- package/lib/typescript/core/AudioNode.d.ts.map +1 -0
- package/lib/typescript/core/AudioParam.d.ts +14 -0
- package/lib/typescript/core/AudioParam.d.ts.map +1 -0
- package/lib/typescript/core/AudioScheduledSourceNode.d.ts +10 -0
- package/lib/typescript/core/AudioScheduledSourceNode.d.ts.map +1 -0
- package/lib/typescript/core/BaseAudioContext.d.ts +26 -0
- package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -0
- package/lib/typescript/core/BiquadFilterNode.d.ts +16 -0
- package/lib/typescript/core/BiquadFilterNode.d.ts.map +1 -0
- package/lib/typescript/core/GainNode.d.ts +9 -0
- package/lib/typescript/core/GainNode.d.ts.map +1 -0
- package/lib/typescript/core/OscillatorNode.d.ts +15 -0
- package/lib/typescript/core/OscillatorNode.d.ts.map +1 -0
- package/lib/typescript/core/PeriodicWave.d.ts +5 -0
- package/lib/typescript/core/PeriodicWave.d.ts.map +1 -0
- package/lib/typescript/core/StereoPannerNode.d.ts +9 -0
- package/lib/typescript/core/StereoPannerNode.d.ts.map +1 -0
- package/lib/typescript/core/types.d.ts +9 -0
- package/lib/typescript/core/types.d.ts.map +1 -0
- package/lib/typescript/errors/IndexSizeError.d.ts +5 -0
- package/lib/typescript/errors/IndexSizeError.d.ts.map +1 -0
- package/lib/typescript/errors/InvalidAccessError.d.ts +5 -0
- package/lib/typescript/errors/InvalidAccessError.d.ts.map +1 -0
- package/lib/typescript/errors/InvalidStateError.d.ts +5 -0
- package/lib/typescript/errors/InvalidStateError.d.ts.map +1 -0
- package/lib/typescript/errors/RangeError.d.ts +5 -0
- package/lib/typescript/errors/RangeError.d.ts.map +1 -0
- package/lib/typescript/errors/index.d.ts +5 -0
- package/lib/typescript/errors/index.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +13 -17
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/interfaces.d.ts +78 -0
- package/lib/typescript/interfaces.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/core/AudioBuffer.ts +68 -0
- package/src/core/AudioBufferSourceNode.ts +35 -0
- package/src/core/AudioContext.ts +12 -0
- package/src/core/AudioDestinationNode.ts +9 -0
- package/src/core/AudioNode.ts +38 -0
- package/src/core/AudioParam.ts +55 -0
- package/src/core/AudioScheduledSourceNode.ts +43 -0
- package/src/core/BaseAudioContext.ts +97 -0
- package/src/core/BiquadFilterNode.ts +49 -0
- package/src/core/GainNode.ts +13 -0
- package/src/core/OscillatorNode.ts +37 -0
- package/src/core/PeriodicWave.ts +10 -0
- package/src/core/StereoPannerNode.ts +13 -0
- package/src/core/types.ts +26 -0
- package/src/errors/IndexSizeError.ts +8 -0
- package/src/errors/InvalidAccessError.ts +8 -0
- package/src/errors/InvalidStateError.ts +8 -0
- package/src/errors/RangeError.ts +8 -0
- package/src/errors/index.ts +4 -0
- package/src/index.ts +19 -73
- package/src/interfaces.ts +120 -0
- package/src/modules/global.d.ts +3 -3
- package/lib/module/types.js.map +0 -1
- package/lib/typescript/types.d.ts +0 -76
- package/lib/typescript/types.d.ts.map +0 -1
- package/src/types.ts +0 -108
- /package/lib/module/{types.js → core/types.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/interfaces.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-audio-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "react-native-audio-api provides system for controlling audio in React Native environment compatible with Web Audio API specification",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { IAudioBuffer } from '../interfaces';
|
|
2
|
+
import { IndexSizeError } from '../errors';
|
|
3
|
+
|
|
4
|
+
export default class AudioBuffer {
|
|
5
|
+
readonly length: number;
|
|
6
|
+
readonly duration: number;
|
|
7
|
+
readonly sampleRate: number;
|
|
8
|
+
readonly numberOfChannels: number;
|
|
9
|
+
/** @internal */
|
|
10
|
+
public readonly buffer: IAudioBuffer;
|
|
11
|
+
|
|
12
|
+
constructor(buffer: IAudioBuffer) {
|
|
13
|
+
this.buffer = buffer;
|
|
14
|
+
this.length = buffer.length;
|
|
15
|
+
this.duration = buffer.duration;
|
|
16
|
+
this.sampleRate = buffer.sampleRate;
|
|
17
|
+
this.numberOfChannels = buffer.numberOfChannels;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public getChannelData(channel: number): number[] {
|
|
21
|
+
if (channel < 0 || channel >= this.numberOfChannels) {
|
|
22
|
+
throw new IndexSizeError(
|
|
23
|
+
`The channel number provided (${channel}) is outside the range [0, ${this.numberOfChannels - 1}]`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return this.buffer.getChannelData(channel);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public copyFromChannel(
|
|
30
|
+
destination: number[],
|
|
31
|
+
channelNumber: number,
|
|
32
|
+
startInChannel: number = 0
|
|
33
|
+
): void {
|
|
34
|
+
if (channelNumber < 0 || channelNumber >= this.numberOfChannels) {
|
|
35
|
+
throw new IndexSizeError(
|
|
36
|
+
`The channel number provided (${channelNumber}) is outside the range [0, ${this.numberOfChannels - 1}]`
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (startInChannel < 0 || startInChannel >= this.length) {
|
|
41
|
+
throw new IndexSizeError(
|
|
42
|
+
`The startInChannel number provided (${startInChannel}) is outside the range [0, ${this.length - 1}]`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this.buffer.copyFromChannel(destination, channelNumber, startInChannel);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public copyToChannel(
|
|
50
|
+
source: number[],
|
|
51
|
+
channelNumber: number,
|
|
52
|
+
startInChannel: number = 0
|
|
53
|
+
): void {
|
|
54
|
+
if (channelNumber < 0 || channelNumber >= this.numberOfChannels) {
|
|
55
|
+
throw new IndexSizeError(
|
|
56
|
+
`The channel number provided (${channelNumber}) is outside the range [0, ${this.numberOfChannels - 1}]`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (startInChannel < 0 || startInChannel >= this.length) {
|
|
61
|
+
throw new IndexSizeError(
|
|
62
|
+
`The startInChannel number provided (${startInChannel}) is outside the range [0, ${this.length - 1}]`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
this.buffer.copyToChannel(source, channelNumber, startInChannel);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IAudioBufferSourceNode } from '../interfaces';
|
|
2
|
+
import AudioScheduledSourceNode from './AudioScheduledSourceNode';
|
|
3
|
+
import BaseAudioContext from './BaseAudioContext';
|
|
4
|
+
import AudioBuffer from './AudioBuffer';
|
|
5
|
+
|
|
6
|
+
export default class AudioBufferSourceNode extends AudioScheduledSourceNode {
|
|
7
|
+
constructor(context: BaseAudioContext, node: IAudioBufferSourceNode) {
|
|
8
|
+
super(context, node);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public get buffer(): AudioBuffer | null {
|
|
12
|
+
const buffer = (this.node as IAudioBufferSourceNode).buffer;
|
|
13
|
+
if (!buffer) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return new AudioBuffer(buffer);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public set buffer(buffer: AudioBuffer | null) {
|
|
20
|
+
if (!buffer) {
|
|
21
|
+
(this.node as IAudioBufferSourceNode).buffer = null;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
(this.node as IAudioBufferSourceNode).buffer = buffer.buffer;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public get loop(): boolean {
|
|
29
|
+
return (this.node as IAudioBufferSourceNode).loop;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public set loop(value: boolean) {
|
|
33
|
+
(this.node as IAudioBufferSourceNode).loop = value;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IAudioContext } from '../interfaces';
|
|
2
|
+
import BaseAudioContext from './BaseAudioContext';
|
|
3
|
+
|
|
4
|
+
export default class AudioContext extends BaseAudioContext {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(global.__AudioAPIInstaller.createAudioContext());
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
close(): void {
|
|
10
|
+
(this.context as IAudioContext).close();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IAudioDestinationNode } from '../interfaces';
|
|
2
|
+
import AudioNode from './AudioNode';
|
|
3
|
+
import BaseAudioContext from './BaseAudioContext';
|
|
4
|
+
|
|
5
|
+
export default class AudioDestinationNode extends AudioNode {
|
|
6
|
+
constructor(context: BaseAudioContext, destination: IAudioDestinationNode) {
|
|
7
|
+
super(context, destination);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { IAudioNode } from '../interfaces';
|
|
2
|
+
import { ChannelCountMode, ChannelInterpretation } from './types';
|
|
3
|
+
import BaseAudioContext from './BaseAudioContext';
|
|
4
|
+
import { InvalidAccessError } from '../errors';
|
|
5
|
+
|
|
6
|
+
export default class AudioNode {
|
|
7
|
+
readonly context: BaseAudioContext;
|
|
8
|
+
readonly numberOfInputs: number;
|
|
9
|
+
readonly numberOfOutputs: number;
|
|
10
|
+
readonly channelCount: number;
|
|
11
|
+
readonly channelCountMode: ChannelCountMode;
|
|
12
|
+
readonly channelInterpretation: ChannelInterpretation;
|
|
13
|
+
protected readonly node: IAudioNode;
|
|
14
|
+
|
|
15
|
+
constructor(context: BaseAudioContext, node: IAudioNode) {
|
|
16
|
+
this.context = context;
|
|
17
|
+
this.node = node;
|
|
18
|
+
this.numberOfInputs = this.node.numberOfInputs;
|
|
19
|
+
this.numberOfOutputs = this.node.numberOfOutputs;
|
|
20
|
+
this.channelCount = this.node.channelCount;
|
|
21
|
+
this.channelCountMode = this.node.channelCountMode;
|
|
22
|
+
this.channelInterpretation = this.node.channelInterpretation;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public connect(node: AudioNode): void {
|
|
26
|
+
if (this.context !== node.context) {
|
|
27
|
+
throw new InvalidAccessError(
|
|
28
|
+
'The AudioNodes are from different BaseAudioContexts'
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
this.node.connect(node.node);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public disconnect(node: AudioNode): void {
|
|
36
|
+
this.node.disconnect(node.node);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { IAudioParam } from '../interfaces';
|
|
2
|
+
import { RangeError } from '../errors';
|
|
3
|
+
|
|
4
|
+
export default class AudioParam {
|
|
5
|
+
readonly defaultValue: number;
|
|
6
|
+
readonly minValue: number;
|
|
7
|
+
readonly maxValue: number;
|
|
8
|
+
private readonly audioParam: IAudioParam;
|
|
9
|
+
|
|
10
|
+
constructor(audioParam: IAudioParam) {
|
|
11
|
+
this.audioParam = audioParam;
|
|
12
|
+
this.value = audioParam.value;
|
|
13
|
+
this.defaultValue = audioParam.defaultValue;
|
|
14
|
+
this.minValue = audioParam.minValue;
|
|
15
|
+
this.maxValue = audioParam.maxValue;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public get value(): number {
|
|
19
|
+
return this.audioParam.value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public set value(value: number) {
|
|
23
|
+
this.audioParam.value = value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public setValueAtTime(value: number, startTime: number): void {
|
|
27
|
+
if (startTime < 0) {
|
|
28
|
+
throw new RangeError(
|
|
29
|
+
`Time must be a finite non-negative number: ${startTime}`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
this.audioParam.setValueAtTime(value, startTime);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public linearRampToValueAtTime(value: number, endTime: number): void {
|
|
37
|
+
if (endTime < 0) {
|
|
38
|
+
throw new RangeError(
|
|
39
|
+
`Time must be a finite non-negative number: ${endTime}`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.audioParam.linearRampToValueAtTime(value, endTime);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public exponentialRampToValueAtTime(value: number, endTime: number): void {
|
|
47
|
+
if (endTime < 0) {
|
|
48
|
+
throw new RangeError(
|
|
49
|
+
`Time must be a finite non-negative number: ${endTime}`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
this.audioParam.exponentialRampToValueAtTime(value, endTime);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { IAudioScheduledSourceNode } from '../interfaces';
|
|
2
|
+
import AudioNode from './AudioNode';
|
|
3
|
+
import BaseAudioContext from './BaseAudioContext';
|
|
4
|
+
import { InvalidStateError, RangeError } from '../errors';
|
|
5
|
+
|
|
6
|
+
export default class AudioScheduledSourceNode extends AudioNode {
|
|
7
|
+
private hasBeenStarted: boolean = false;
|
|
8
|
+
|
|
9
|
+
constructor(context: BaseAudioContext, node: IAudioScheduledSourceNode) {
|
|
10
|
+
super(context, node);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public start(when: number = 0): void {
|
|
14
|
+
if (when < 0) {
|
|
15
|
+
throw new RangeError(
|
|
16
|
+
`Time must be a finite non-negative number: ${when}`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (this.hasBeenStarted) {
|
|
21
|
+
throw new InvalidStateError('Cannot call start more than once');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
this.hasBeenStarted = true;
|
|
25
|
+
(this.node as IAudioScheduledSourceNode).start(when);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public stop(when: number = 0): void {
|
|
29
|
+
if (when < 0) {
|
|
30
|
+
throw new RangeError(
|
|
31
|
+
`Time must be a finite non-negative number: ${when}`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!this.hasBeenStarted) {
|
|
36
|
+
throw new InvalidStateError(
|
|
37
|
+
'Cannot call stop without calling start first'
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
(this.node as IAudioScheduledSourceNode).stop(when);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { IBaseAudioContext } from '../interfaces';
|
|
2
|
+
import { ContextState, PeriodicWaveConstraints } from './types';
|
|
3
|
+
import AudioDestinationNode from './AudioDestinationNode';
|
|
4
|
+
import OscillatorNode from './OscillatorNode';
|
|
5
|
+
import GainNode from './GainNode';
|
|
6
|
+
import StereoPannerNode from './StereoPannerNode';
|
|
7
|
+
import BiquadFilterNode from './BiquadFilterNode';
|
|
8
|
+
import AudioBufferSourceNode from './AudioBufferSourceNode';
|
|
9
|
+
import AudioBuffer from './AudioBuffer';
|
|
10
|
+
import PeriodicWave from './PeriodicWave';
|
|
11
|
+
import { InvalidAccessError } from '../errors';
|
|
12
|
+
|
|
13
|
+
export default class BaseAudioContext {
|
|
14
|
+
readonly destination: AudioDestinationNode;
|
|
15
|
+
readonly sampleRate: number;
|
|
16
|
+
protected readonly context: IBaseAudioContext;
|
|
17
|
+
|
|
18
|
+
constructor(context: IBaseAudioContext) {
|
|
19
|
+
this.context = context;
|
|
20
|
+
this.destination = new AudioDestinationNode(this, context.destination);
|
|
21
|
+
this.sampleRate = context.sampleRate;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public get currentTime(): number {
|
|
25
|
+
return this.context.currentTime;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public get state(): ContextState {
|
|
29
|
+
return this.context.state;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
createOscillator(): OscillatorNode {
|
|
33
|
+
return new OscillatorNode(this, this.context.createOscillator());
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
createGain(): GainNode {
|
|
37
|
+
return new GainNode(this, this.context.createGain());
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
createStereoPanner(): StereoPannerNode {
|
|
41
|
+
return new StereoPannerNode(this, this.context.createStereoPanner());
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
createBiquadFilter(): BiquadFilterNode {
|
|
45
|
+
return new BiquadFilterNode(this, this.context.createBiquadFilter());
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
createBufferSource(): AudioBufferSourceNode {
|
|
49
|
+
return new AudioBufferSourceNode(this, this.context.createBufferSource());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
createBuffer(
|
|
53
|
+
numOfChannels: number,
|
|
54
|
+
length: number,
|
|
55
|
+
sampleRate: number
|
|
56
|
+
): AudioBuffer {
|
|
57
|
+
if (numOfChannels < 1 || numOfChannels > 3) {
|
|
58
|
+
throw new RangeError(
|
|
59
|
+
`The number of channels provided (${numOfChannels}) is outside the range [1, 2]`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (length <= 0) {
|
|
64
|
+
throw new RangeError(
|
|
65
|
+
`The number of frames provided (${length}) is less than or equal to the minimum bound (0)`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (sampleRate <= 0) {
|
|
70
|
+
throw new RangeError(
|
|
71
|
+
`The sample rate provided (${sampleRate}) is outside the range [3000, 768000]`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return new AudioBuffer(
|
|
76
|
+
this.context.createBuffer(numOfChannels, length, sampleRate)
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
createPeriodicWave(
|
|
81
|
+
real: number[],
|
|
82
|
+
imag: number[],
|
|
83
|
+
constraints?: PeriodicWaveConstraints
|
|
84
|
+
): PeriodicWave {
|
|
85
|
+
if (real.length !== imag.length) {
|
|
86
|
+
throw new InvalidAccessError(
|
|
87
|
+
`The lengths of the real (${real.length}) and imaginary (${imag.length}) arrays must match.`
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const disableNormalization = constraints?.disableNormalization ?? false;
|
|
92
|
+
|
|
93
|
+
return new PeriodicWave(
|
|
94
|
+
this.context.createPeriodicWave(real, imag, disableNormalization)
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { InvalidAccessError } from '../errors';
|
|
2
|
+
import { IBiquadFilterNode } from '../interfaces';
|
|
3
|
+
import AudioNode from './AudioNode';
|
|
4
|
+
import AudioParam from './AudioParam';
|
|
5
|
+
import BaseAudioContext from './BaseAudioContext';
|
|
6
|
+
import { BiquadFilterType } from './types';
|
|
7
|
+
|
|
8
|
+
export default class BiquadFilterNode extends AudioNode {
|
|
9
|
+
readonly frequency: AudioParam;
|
|
10
|
+
readonly detune: AudioParam;
|
|
11
|
+
readonly Q: AudioParam;
|
|
12
|
+
readonly gain: AudioParam;
|
|
13
|
+
|
|
14
|
+
constructor(context: BaseAudioContext, biquadFilter: IBiquadFilterNode) {
|
|
15
|
+
super(context, biquadFilter);
|
|
16
|
+
this.frequency = new AudioParam(biquadFilter.frequency);
|
|
17
|
+
this.detune = new AudioParam(biquadFilter.detune);
|
|
18
|
+
this.Q = new AudioParam(biquadFilter.Q);
|
|
19
|
+
this.gain = new AudioParam(biquadFilter.gain);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public get type(): BiquadFilterType {
|
|
23
|
+
return (this.node as IBiquadFilterNode).type;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public set type(value: BiquadFilterType) {
|
|
27
|
+
(this.node as IBiquadFilterNode).type = value;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public getFrequencyResponse(
|
|
31
|
+
frequencyArray: number[],
|
|
32
|
+
magResponseOutput: number[],
|
|
33
|
+
phaseResponseOutput: number[]
|
|
34
|
+
) {
|
|
35
|
+
if (
|
|
36
|
+
frequencyArray.length !== magResponseOutput.length ||
|
|
37
|
+
frequencyArray.length !== phaseResponseOutput.length
|
|
38
|
+
) {
|
|
39
|
+
throw new InvalidAccessError(
|
|
40
|
+
`The lengths of the arrays are not the same frequencyArray: ${frequencyArray.length}, magResponseOutput: ${magResponseOutput.length}, phaseResponseOutput: ${phaseResponseOutput.length}`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
(this.node as IBiquadFilterNode).getFrequencyResponse(
|
|
44
|
+
frequencyArray,
|
|
45
|
+
magResponseOutput,
|
|
46
|
+
phaseResponseOutput
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IGainNode } from '../interfaces';
|
|
2
|
+
import AudioNode from './AudioNode';
|
|
3
|
+
import AudioParam from './AudioParam';
|
|
4
|
+
import BaseAudioContext from './BaseAudioContext';
|
|
5
|
+
|
|
6
|
+
export default class GainNode extends AudioNode {
|
|
7
|
+
readonly gain: AudioParam;
|
|
8
|
+
|
|
9
|
+
constructor(context: BaseAudioContext, gain: IGainNode) {
|
|
10
|
+
super(context, gain);
|
|
11
|
+
this.gain = new AudioParam(gain.gain);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { IOscillatorNode } from '../interfaces';
|
|
2
|
+
import { OscillatorType } from './types';
|
|
3
|
+
import AudioScheduledSourceNode from './AudioScheduledSourceNode';
|
|
4
|
+
import AudioParam from './AudioParam';
|
|
5
|
+
import BaseAudioContext from './BaseAudioContext';
|
|
6
|
+
import PeriodicWave from './PeriodicWave';
|
|
7
|
+
import { InvalidStateError } from '../errors';
|
|
8
|
+
|
|
9
|
+
export default class OscillatorNode extends AudioScheduledSourceNode {
|
|
10
|
+
readonly frequency: AudioParam;
|
|
11
|
+
readonly detune: AudioParam;
|
|
12
|
+
|
|
13
|
+
constructor(context: BaseAudioContext, node: IOscillatorNode) {
|
|
14
|
+
super(context, node);
|
|
15
|
+
this.frequency = new AudioParam(node.frequency);
|
|
16
|
+
this.detune = new AudioParam(node.detune);
|
|
17
|
+
this.type = node.type;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public get type(): OscillatorType {
|
|
21
|
+
return (this.node as IOscillatorNode).type;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public set type(value: OscillatorType) {
|
|
25
|
+
if (value === 'custom') {
|
|
26
|
+
throw new InvalidStateError(
|
|
27
|
+
"'type' cannot be set directly to 'custom'. Use setPeriodicWave() to create a custom Oscillator type."
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
(this.node as IOscillatorNode).type = value;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public setPeriodicWave(wave: PeriodicWave): void {
|
|
35
|
+
(this.node as IOscillatorNode).setPeriodicWave(wave.periodicWave);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IStereoPannerNode } from '../interfaces';
|
|
2
|
+
import AudioNode from './AudioNode';
|
|
3
|
+
import AudioParam from './AudioParam';
|
|
4
|
+
import BaseAudioContext from './BaseAudioContext';
|
|
5
|
+
|
|
6
|
+
export default class StereoPannerNode extends AudioNode {
|
|
7
|
+
readonly pan: AudioParam;
|
|
8
|
+
|
|
9
|
+
constructor(context: BaseAudioContext, pan: IStereoPannerNode) {
|
|
10
|
+
super(context, pan);
|
|
11
|
+
this.pan = new AudioParam(pan.pan);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type ChannelCountMode = 'max' | 'clamped-max' | 'explicit';
|
|
2
|
+
|
|
3
|
+
export type ChannelInterpretation = 'speakers' | 'discrete';
|
|
4
|
+
|
|
5
|
+
export type BiquadFilterType =
|
|
6
|
+
| 'lowpass'
|
|
7
|
+
| 'highpass'
|
|
8
|
+
| 'bandpass'
|
|
9
|
+
| 'lowshelf'
|
|
10
|
+
| 'highshelf'
|
|
11
|
+
| 'peaking'
|
|
12
|
+
| 'notch'
|
|
13
|
+
| 'allpass';
|
|
14
|
+
|
|
15
|
+
export type ContextState = 'running' | 'closed';
|
|
16
|
+
|
|
17
|
+
export type OscillatorType =
|
|
18
|
+
| 'sine'
|
|
19
|
+
| 'square'
|
|
20
|
+
| 'sawtooth'
|
|
21
|
+
| 'triangle'
|
|
22
|
+
| 'custom';
|
|
23
|
+
|
|
24
|
+
export interface PeriodicWaveConstraints {
|
|
25
|
+
disableNormalization: boolean;
|
|
26
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,79 +1,25 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
BaseAudioContext,
|
|
3
|
-
AudioDestinationNode,
|
|
4
|
-
GainNode,
|
|
5
|
-
StereoPannerNode,
|
|
6
|
-
OscillatorNode,
|
|
7
|
-
BiquadFilterNode,
|
|
8
|
-
AudioBufferSourceNode,
|
|
9
|
-
AudioBuffer,
|
|
10
|
-
WaveType,
|
|
11
|
-
} from './types';
|
|
12
1
|
import { installModule } from './utils/install';
|
|
13
2
|
|
|
14
3
|
if (global.__AudioAPIInstaller == null) {
|
|
15
4
|
installModule();
|
|
16
5
|
}
|
|
17
6
|
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
createOscillator(): OscillatorNode {
|
|
39
|
-
return this.__AudioContext.createOscillator();
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
createGain(): GainNode {
|
|
43
|
-
return this.__AudioContext.createGain();
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
createStereoPanner(): StereoPannerNode {
|
|
47
|
-
return this.__AudioContext.createStereoPanner();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
createBiquadFilter(): BiquadFilterNode {
|
|
51
|
-
return this.__AudioContext.createBiquadFilter();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
createBufferSource(): AudioBufferSourceNode {
|
|
55
|
-
return this.__AudioContext.createBufferSource();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
createBuffer(
|
|
59
|
-
numOfChannels: number,
|
|
60
|
-
length: number,
|
|
61
|
-
sampleRate: number
|
|
62
|
-
): AudioBuffer {
|
|
63
|
-
return this.__AudioContext.createBuffer(numOfChannels, length, sampleRate);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
close(): void {
|
|
67
|
-
this.__AudioContext.close();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export type {
|
|
72
|
-
GainNode,
|
|
73
|
-
StereoPannerNode,
|
|
74
|
-
OscillatorNode,
|
|
75
|
-
BiquadFilterNode,
|
|
76
|
-
AudioBufferSourceNode,
|
|
77
|
-
AudioBuffer,
|
|
78
|
-
WaveType,
|
|
79
|
-
};
|
|
7
|
+
export { default as AudioBuffer } from './core/AudioBuffer';
|
|
8
|
+
export { default as AudioBufferSourceNode } from './core/AudioBufferSourceNode';
|
|
9
|
+
export { default as AudioContext } from './core/AudioContext';
|
|
10
|
+
export { default as AudioDestinationNode } from './core/AudioDestinationNode';
|
|
11
|
+
export { default as AudioNode } from './core/AudioNode';
|
|
12
|
+
export { default as AudioParam } from './core/AudioParam';
|
|
13
|
+
export { default as AudioScheduledSourceNode } from './core/AudioScheduledSourceNode';
|
|
14
|
+
export { default as BaseAudioContext } from './core/BaseAudioContext';
|
|
15
|
+
export { default as BiquadFilterNode } from './core/BiquadFilterNode';
|
|
16
|
+
export { default as GainNode } from './core/GainNode';
|
|
17
|
+
export { default as OscillatorNode } from './core/OscillatorNode';
|
|
18
|
+
export { default as StereoPannerNode } from './core/StereoPannerNode';
|
|
19
|
+
export {
|
|
20
|
+
OscillatorType,
|
|
21
|
+
BiquadFilterType,
|
|
22
|
+
ChannelCountMode,
|
|
23
|
+
ChannelInterpretation,
|
|
24
|
+
ContextState,
|
|
25
|
+
} from './core/types';
|