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
|
@@ -5,29 +5,12 @@ using namespace facebook;
|
|
|
5
5
|
|
|
6
6
|
AudioContextHostObject::AudioContextHostObject(
|
|
7
7
|
const std::shared_ptr<AudioContextWrapper> &wrapper)
|
|
8
|
-
:
|
|
9
|
-
auto destinationNodeWrapper = wrapper_->getDestination();
|
|
10
|
-
destination_ =
|
|
11
|
-
AudioDestinationNodeHostObject::createFromWrapper(destinationNodeWrapper);
|
|
12
|
-
}
|
|
8
|
+
: BaseAudioContextHostObject(wrapper) {}
|
|
13
9
|
|
|
14
10
|
std::vector<jsi::PropNameID> AudioContextHostObject::getPropertyNames(
|
|
15
11
|
jsi::Runtime &runtime) {
|
|
16
|
-
std::vector<jsi::PropNameID> propertyNames
|
|
17
|
-
|
|
18
|
-
propertyNames.push_back(jsi::PropNameID::forUtf8(runtime, "state"));
|
|
19
|
-
propertyNames.push_back(jsi::PropNameID::forUtf8(runtime, "sampleRate"));
|
|
20
|
-
propertyNames.push_back(jsi::PropNameID::forUtf8(runtime, "currentTime"));
|
|
21
|
-
propertyNames.push_back(
|
|
22
|
-
jsi::PropNameID::forUtf8(runtime, "createOscillator"));
|
|
23
|
-
propertyNames.push_back(jsi::PropNameID::forUtf8(runtime, "createGain"));
|
|
24
|
-
propertyNames.push_back(
|
|
25
|
-
jsi::PropNameID::forUtf8(runtime, "createStereoPanner"));
|
|
26
|
-
propertyNames.push_back(
|
|
27
|
-
jsi::PropNameID::forUtf8(runtime, "createBiquadFilter"));
|
|
28
|
-
propertyNames.push_back(
|
|
29
|
-
jsi::PropNameID::forUtf8(runtime, "createBufferSource"));
|
|
30
|
-
propertyNames.push_back(jsi::PropNameID::forUtf8(runtime, "createBuffer"));
|
|
12
|
+
std::vector<jsi::PropNameID> propertyNames =
|
|
13
|
+
BaseAudioContextHostObject::getPropertyNames(runtime);
|
|
31
14
|
propertyNames.push_back(jsi::PropNameID::forUtf8(runtime, "close"));
|
|
32
15
|
return propertyNames;
|
|
33
16
|
}
|
|
@@ -37,131 +20,6 @@ jsi::Value AudioContextHostObject::get(
|
|
|
37
20
|
const jsi::PropNameID &propNameId) {
|
|
38
21
|
auto propName = propNameId.utf8(runtime);
|
|
39
22
|
|
|
40
|
-
if (propName == "destination") {
|
|
41
|
-
return jsi::Object::createFromHostObject(runtime, destination_);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (propName == "state") {
|
|
45
|
-
return jsi::String::createFromUtf8(runtime, wrapper_->getState());
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (propName == "sampleRate") {
|
|
49
|
-
return {wrapper_->getSampleRate()};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (propName == "currentTime") {
|
|
53
|
-
return {wrapper_->getCurrentTime()};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (propName == "createOscillator") {
|
|
57
|
-
return jsi::Function::createFromHostFunction(
|
|
58
|
-
runtime,
|
|
59
|
-
propNameId,
|
|
60
|
-
0,
|
|
61
|
-
[this](
|
|
62
|
-
jsi::Runtime &runtime,
|
|
63
|
-
const jsi::Value &thisValue,
|
|
64
|
-
const jsi::Value *arguments,
|
|
65
|
-
size_t count) -> jsi::Value {
|
|
66
|
-
auto oscillator = wrapper_->createOscillator();
|
|
67
|
-
auto oscillatorHostObject =
|
|
68
|
-
OscillatorNodeHostObject::createFromWrapper(oscillator);
|
|
69
|
-
return jsi::Object::createFromHostObject(
|
|
70
|
-
runtime, oscillatorHostObject);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (propName == "createGain") {
|
|
75
|
-
return jsi::Function::createFromHostFunction(
|
|
76
|
-
runtime,
|
|
77
|
-
propNameId,
|
|
78
|
-
0,
|
|
79
|
-
[this](
|
|
80
|
-
jsi::Runtime &runtime,
|
|
81
|
-
const jsi::Value &thisValue,
|
|
82
|
-
const jsi::Value *arguments,
|
|
83
|
-
size_t count) -> jsi::Value {
|
|
84
|
-
auto gain = wrapper_->createGain();
|
|
85
|
-
auto gainHostObject = GainNodeHostObject::createFromWrapper(gain);
|
|
86
|
-
return jsi::Object::createFromHostObject(runtime, gainHostObject);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
if (propName == "createStereoPanner") {
|
|
91
|
-
return jsi::Function::createFromHostFunction(
|
|
92
|
-
runtime,
|
|
93
|
-
propNameId,
|
|
94
|
-
0,
|
|
95
|
-
[this](
|
|
96
|
-
jsi::Runtime &runtime,
|
|
97
|
-
const jsi::Value &thisValue,
|
|
98
|
-
const jsi::Value *arguments,
|
|
99
|
-
size_t count) -> jsi::Value {
|
|
100
|
-
auto stereoPanner = wrapper_->createStereoPanner();
|
|
101
|
-
auto stereoPannerHostObject =
|
|
102
|
-
StereoPannerNodeHostObject::createFromWrapper(stereoPanner);
|
|
103
|
-
return jsi::Object::createFromHostObject(
|
|
104
|
-
runtime, stereoPannerHostObject);
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (propName == "createBiquadFilter") {
|
|
109
|
-
return jsi::Function::createFromHostFunction(
|
|
110
|
-
runtime,
|
|
111
|
-
propNameId,
|
|
112
|
-
0,
|
|
113
|
-
[this](
|
|
114
|
-
jsi::Runtime &runtime,
|
|
115
|
-
const jsi::Value &thisValue,
|
|
116
|
-
const jsi::Value *arguments,
|
|
117
|
-
size_t count) -> jsi::Value {
|
|
118
|
-
auto biquadFilter = wrapper_->createBiquadFilter();
|
|
119
|
-
auto biquadFilterHostObject =
|
|
120
|
-
BiquadFilterNodeHostObject::createFromWrapper(biquadFilter);
|
|
121
|
-
return jsi::Object::createFromHostObject(
|
|
122
|
-
runtime, biquadFilterHostObject);
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (propName == "createBufferSource") {
|
|
127
|
-
return jsi::Function::createFromHostFunction(
|
|
128
|
-
runtime,
|
|
129
|
-
propNameId,
|
|
130
|
-
0,
|
|
131
|
-
[this](
|
|
132
|
-
jsi::Runtime &runtime,
|
|
133
|
-
const jsi::Value &thisValue,
|
|
134
|
-
const jsi::Value *arguments,
|
|
135
|
-
size_t count) -> jsi::Value {
|
|
136
|
-
auto bufferSource = wrapper_->createBufferSource();
|
|
137
|
-
auto bufferSourceHostObject =
|
|
138
|
-
AudioBufferSourceNodeHostObject::createFromWrapper(bufferSource);
|
|
139
|
-
return jsi::Object::createFromHostObject(
|
|
140
|
-
runtime, bufferSourceHostObject);
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (propName == "createBuffer") {
|
|
145
|
-
return jsi::Function::createFromHostFunction(
|
|
146
|
-
runtime,
|
|
147
|
-
propNameId,
|
|
148
|
-
3,
|
|
149
|
-
[this](
|
|
150
|
-
jsi::Runtime &runtime,
|
|
151
|
-
const jsi::Value &thisValue,
|
|
152
|
-
const jsi::Value *arguments,
|
|
153
|
-
size_t count) -> jsi::Value {
|
|
154
|
-
auto numberOfChannels = static_cast<int>(arguments[0].getNumber());
|
|
155
|
-
auto length = static_cast<int>(arguments[1].getNumber());
|
|
156
|
-
auto sampleRate = static_cast<int>(arguments[2].getNumber());
|
|
157
|
-
auto buffer =
|
|
158
|
-
wrapper_->createBuffer(numberOfChannels, length, sampleRate);
|
|
159
|
-
auto bufferHostObject =
|
|
160
|
-
AudioBufferHostObject::createFromWrapper(buffer);
|
|
161
|
-
return jsi::Object::createFromHostObject(runtime, bufferHostObject);
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
|
|
165
23
|
if (propName == "close") {
|
|
166
24
|
return jsi::Function::createFromHostFunction(
|
|
167
25
|
runtime,
|
|
@@ -172,12 +30,12 @@ jsi::Value AudioContextHostObject::get(
|
|
|
172
30
|
const jsi::Value &thisValue,
|
|
173
31
|
const jsi::Value *arguments,
|
|
174
32
|
size_t count) -> jsi::Value {
|
|
175
|
-
|
|
33
|
+
getAudioContextWrapperFromBaseAudioContextWrapper()->close();
|
|
176
34
|
return jsi::Value::undefined();
|
|
177
35
|
});
|
|
178
36
|
}
|
|
179
37
|
|
|
180
|
-
|
|
38
|
+
return BaseAudioContextHostObject::get(runtime, propNameId);
|
|
181
39
|
}
|
|
182
40
|
|
|
183
41
|
void AudioContextHostObject::set(
|
|
@@ -186,6 +44,11 @@ void AudioContextHostObject::set(
|
|
|
186
44
|
const jsi::Value &value) {
|
|
187
45
|
auto propName = propNameId.utf8(runtime);
|
|
188
46
|
|
|
189
|
-
|
|
47
|
+
return BaseAudioContextHostObject::set(runtime, propNameId, value);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
std::shared_ptr<AudioContextWrapper>
|
|
51
|
+
AudioContextHostObject::getAudioContextWrapperFromBaseAudioContextWrapper() {
|
|
52
|
+
return std::static_pointer_cast<AudioContextWrapper>(wrapper_);
|
|
190
53
|
}
|
|
191
54
|
} // namespace audioapi
|
|
@@ -2,22 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
#include <jsi/jsi.h>
|
|
4
4
|
#include <memory>
|
|
5
|
-
#include <utility>
|
|
6
5
|
#include <vector>
|
|
7
6
|
|
|
8
|
-
#include "AudioBufferHostObject.h"
|
|
9
|
-
#include "AudioBufferSourceNodeHostObject.h"
|
|
10
7
|
#include "AudioContextWrapper.h"
|
|
11
|
-
#include "
|
|
12
|
-
#include "BiquadFilterNodeHostObject.h"
|
|
13
|
-
#include "GainNodeHostObject.h"
|
|
14
|
-
#include "OscillatorNodeHostObject.h"
|
|
15
|
-
#include "StereoPannerNodeHostObject.h"
|
|
8
|
+
#include "BaseAudioContextHostObject.h"
|
|
16
9
|
|
|
17
10
|
namespace audioapi {
|
|
18
11
|
using namespace facebook;
|
|
19
12
|
|
|
20
|
-
class AudioContextHostObject : public
|
|
13
|
+
class AudioContextHostObject : public BaseAudioContextHostObject {
|
|
21
14
|
public:
|
|
22
15
|
explicit AudioContextHostObject(
|
|
23
16
|
const std::shared_ptr<AudioContextWrapper> &wrapper);
|
|
@@ -37,7 +30,7 @@ class AudioContextHostObject : public jsi::HostObject {
|
|
|
37
30
|
}
|
|
38
31
|
|
|
39
32
|
private:
|
|
40
|
-
std::shared_ptr<AudioContextWrapper>
|
|
41
|
-
|
|
33
|
+
std::shared_ptr<AudioContextWrapper>
|
|
34
|
+
getAudioContextWrapperFromBaseAudioContextWrapper();
|
|
42
35
|
};
|
|
43
36
|
} // namespace audioapi
|
|
@@ -21,7 +21,6 @@ std::vector<jsi::PropNameID> AudioNodeHostObject::getPropertyNames(
|
|
|
21
21
|
jsi::PropNameID::forAscii(runtime, "channelCountMode"));
|
|
22
22
|
propertyNames.push_back(
|
|
23
23
|
jsi::PropNameID::forAscii(runtime, "channelInterpretation"));
|
|
24
|
-
propertyNames.push_back(jsi::PropNameID::forAscii(runtime, "context"));
|
|
25
24
|
return propertyNames;
|
|
26
25
|
}
|
|
27
26
|
|
|
@@ -88,11 +87,6 @@ jsi::Value AudioNodeHostObject::get(
|
|
|
88
87
|
runtime, wrapper_->getChannelInterpretation());
|
|
89
88
|
}
|
|
90
89
|
|
|
91
|
-
if (propName == "context") {
|
|
92
|
-
// TODO fix this
|
|
93
|
-
return jsi::Value::undefined();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
90
|
throw std::runtime_error("Not yet implemented!");
|
|
97
91
|
}
|
|
98
92
|
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
#include "BaseAudioContextHostObject.h"
|
|
2
|
+
|
|
3
|
+
namespace audioapi {
|
|
4
|
+
using namespace facebook;
|
|
5
|
+
|
|
6
|
+
BaseAudioContextHostObject::BaseAudioContextHostObject(
|
|
7
|
+
const std::shared_ptr<BaseAudioContextWrapper> &wrapper)
|
|
8
|
+
: wrapper_(wrapper) {
|
|
9
|
+
auto destinationNodeWrapper = wrapper_->getDestination();
|
|
10
|
+
destination_ =
|
|
11
|
+
AudioDestinationNodeHostObject::createFromWrapper(destinationNodeWrapper);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
std::vector<jsi::PropNameID> BaseAudioContextHostObject::getPropertyNames(
|
|
15
|
+
jsi::Runtime &runtime) {
|
|
16
|
+
std::vector<jsi::PropNameID> propertyNames;
|
|
17
|
+
propertyNames.push_back(jsi::PropNameID::forUtf8(runtime, "destination"));
|
|
18
|
+
propertyNames.push_back(jsi::PropNameID::forUtf8(runtime, "state"));
|
|
19
|
+
propertyNames.push_back(jsi::PropNameID::forUtf8(runtime, "sampleRate"));
|
|
20
|
+
propertyNames.push_back(jsi::PropNameID::forUtf8(runtime, "currentTime"));
|
|
21
|
+
propertyNames.push_back(
|
|
22
|
+
jsi::PropNameID::forUtf8(runtime, "createOscillator"));
|
|
23
|
+
propertyNames.push_back(jsi::PropNameID::forUtf8(runtime, "createGain"));
|
|
24
|
+
propertyNames.push_back(
|
|
25
|
+
jsi::PropNameID::forUtf8(runtime, "createStereoPanner"));
|
|
26
|
+
propertyNames.push_back(
|
|
27
|
+
jsi::PropNameID::forUtf8(runtime, "createBiquadFilter"));
|
|
28
|
+
propertyNames.push_back(
|
|
29
|
+
jsi::PropNameID::forUtf8(runtime, "createBufferSource"));
|
|
30
|
+
propertyNames.push_back(jsi::PropNameID::forUtf8(runtime, "createBuffer"));
|
|
31
|
+
propertyNames.push_back(
|
|
32
|
+
jsi::PropNameID::forUtf8(runtime, "createPeriodicWave"));
|
|
33
|
+
return propertyNames;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
jsi::Value BaseAudioContextHostObject::get(
|
|
37
|
+
jsi::Runtime &runtime,
|
|
38
|
+
const jsi::PropNameID &propNameId) {
|
|
39
|
+
auto propName = propNameId.utf8(runtime);
|
|
40
|
+
|
|
41
|
+
if (propName == "destination") {
|
|
42
|
+
return jsi::Object::createFromHostObject(runtime, destination_);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (propName == "state") {
|
|
46
|
+
return jsi::String::createFromUtf8(runtime, wrapper_->getState());
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (propName == "sampleRate") {
|
|
50
|
+
return {wrapper_->getSampleRate()};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (propName == "currentTime") {
|
|
54
|
+
return {wrapper_->getCurrentTime()};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (propName == "createOscillator") {
|
|
58
|
+
return jsi::Function::createFromHostFunction(
|
|
59
|
+
runtime,
|
|
60
|
+
propNameId,
|
|
61
|
+
0,
|
|
62
|
+
[this](
|
|
63
|
+
jsi::Runtime &runtime,
|
|
64
|
+
const jsi::Value &thisValue,
|
|
65
|
+
const jsi::Value *arguments,
|
|
66
|
+
size_t count) -> jsi::Value {
|
|
67
|
+
auto oscillator = wrapper_->createOscillator();
|
|
68
|
+
auto oscillatorHostObject =
|
|
69
|
+
OscillatorNodeHostObject::createFromWrapper(oscillator);
|
|
70
|
+
return jsi::Object::createFromHostObject(
|
|
71
|
+
runtime, oscillatorHostObject);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (propName == "createGain") {
|
|
76
|
+
return jsi::Function::createFromHostFunction(
|
|
77
|
+
runtime,
|
|
78
|
+
propNameId,
|
|
79
|
+
0,
|
|
80
|
+
[this](
|
|
81
|
+
jsi::Runtime &runtime,
|
|
82
|
+
const jsi::Value &thisValue,
|
|
83
|
+
const jsi::Value *arguments,
|
|
84
|
+
size_t count) -> jsi::Value {
|
|
85
|
+
auto gain = wrapper_->createGain();
|
|
86
|
+
auto gainHostObject = GainNodeHostObject::createFromWrapper(gain);
|
|
87
|
+
return jsi::Object::createFromHostObject(runtime, gainHostObject);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (propName == "createStereoPanner") {
|
|
92
|
+
return jsi::Function::createFromHostFunction(
|
|
93
|
+
runtime,
|
|
94
|
+
propNameId,
|
|
95
|
+
0,
|
|
96
|
+
[this](
|
|
97
|
+
jsi::Runtime &runtime,
|
|
98
|
+
const jsi::Value &thisValue,
|
|
99
|
+
const jsi::Value *arguments,
|
|
100
|
+
size_t count) -> jsi::Value {
|
|
101
|
+
auto stereoPanner = wrapper_->createStereoPanner();
|
|
102
|
+
auto stereoPannerHostObject =
|
|
103
|
+
StereoPannerNodeHostObject::createFromWrapper(stereoPanner);
|
|
104
|
+
return jsi::Object::createFromHostObject(
|
|
105
|
+
runtime, stereoPannerHostObject);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (propName == "createBiquadFilter") {
|
|
110
|
+
return jsi::Function::createFromHostFunction(
|
|
111
|
+
runtime,
|
|
112
|
+
propNameId,
|
|
113
|
+
0,
|
|
114
|
+
[this](
|
|
115
|
+
jsi::Runtime &runtime,
|
|
116
|
+
const jsi::Value &thisValue,
|
|
117
|
+
const jsi::Value *arguments,
|
|
118
|
+
size_t count) -> jsi::Value {
|
|
119
|
+
auto biquadFilter = wrapper_->createBiquadFilter();
|
|
120
|
+
auto biquadFilterHostObject =
|
|
121
|
+
BiquadFilterNodeHostObject::createFromWrapper(biquadFilter);
|
|
122
|
+
return jsi::Object::createFromHostObject(
|
|
123
|
+
runtime, biquadFilterHostObject);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (propName == "createBufferSource") {
|
|
128
|
+
return jsi::Function::createFromHostFunction(
|
|
129
|
+
runtime,
|
|
130
|
+
propNameId,
|
|
131
|
+
0,
|
|
132
|
+
[this](
|
|
133
|
+
jsi::Runtime &runtime,
|
|
134
|
+
const jsi::Value &thisValue,
|
|
135
|
+
const jsi::Value *arguments,
|
|
136
|
+
size_t count) -> jsi::Value {
|
|
137
|
+
auto bufferSource = wrapper_->createBufferSource();
|
|
138
|
+
auto bufferSourceHostObject =
|
|
139
|
+
AudioBufferSourceNodeHostObject::createFromWrapper(bufferSource);
|
|
140
|
+
return jsi::Object::createFromHostObject(
|
|
141
|
+
runtime, bufferSourceHostObject);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (propName == "createBuffer") {
|
|
146
|
+
return jsi::Function::createFromHostFunction(
|
|
147
|
+
runtime,
|
|
148
|
+
propNameId,
|
|
149
|
+
3,
|
|
150
|
+
[this](
|
|
151
|
+
jsi::Runtime &runtime,
|
|
152
|
+
const jsi::Value &thisValue,
|
|
153
|
+
const jsi::Value *arguments,
|
|
154
|
+
size_t count) -> jsi::Value {
|
|
155
|
+
auto numberOfChannels = static_cast<int>(arguments[0].getNumber());
|
|
156
|
+
auto length = static_cast<int>(arguments[1].getNumber());
|
|
157
|
+
auto sampleRate = static_cast<int>(arguments[2].getNumber());
|
|
158
|
+
auto buffer =
|
|
159
|
+
wrapper_->createBuffer(numberOfChannels, length, sampleRate);
|
|
160
|
+
auto bufferHostObject =
|
|
161
|
+
AudioBufferHostObject::createFromWrapper(buffer);
|
|
162
|
+
return jsi::Object::createFromHostObject(runtime, bufferHostObject);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (propName == "createPeriodicWave") {
|
|
167
|
+
return jsi::Function::createFromHostFunction(
|
|
168
|
+
runtime,
|
|
169
|
+
propNameId,
|
|
170
|
+
3,
|
|
171
|
+
[this](
|
|
172
|
+
jsi::Runtime &runtime,
|
|
173
|
+
const jsi::Value &thisValue,
|
|
174
|
+
const jsi::Value *arguments,
|
|
175
|
+
size_t count) -> jsi::Value {
|
|
176
|
+
auto real = arguments[0].getObject(runtime).getArray(runtime);
|
|
177
|
+
auto imag = arguments[1].getObject(runtime).getArray(runtime);
|
|
178
|
+
auto disableNormalization = arguments[2].getBool();
|
|
179
|
+
auto length =
|
|
180
|
+
static_cast<int>(real.getProperty(runtime, "length").asNumber());
|
|
181
|
+
|
|
182
|
+
auto *realData = new float[length];
|
|
183
|
+
auto *imagData = new float[length];
|
|
184
|
+
|
|
185
|
+
for (size_t i = 0; i < real.length(runtime); i++) {
|
|
186
|
+
realData[i] = static_cast<float>(
|
|
187
|
+
real.getValueAtIndex(runtime, i).getNumber());
|
|
188
|
+
}
|
|
189
|
+
for (size_t i = 0; i < imag.length(runtime); i++) {
|
|
190
|
+
realData[i] = static_cast<float>(
|
|
191
|
+
imag.getValueAtIndex(runtime, i).getNumber());
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
auto periodicWave = wrapper_->createPeriodicWave(
|
|
195
|
+
realData, imagData, disableNormalization, length);
|
|
196
|
+
auto periodicWaveHostObject =
|
|
197
|
+
PeriodicWaveHostObject::createFromWrapper(periodicWave);
|
|
198
|
+
return jsi::Object::createFromHostObject(
|
|
199
|
+
runtime, periodicWaveHostObject);
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
throw std::runtime_error("Not yet implemented!");
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
void BaseAudioContextHostObject::set(
|
|
207
|
+
jsi::Runtime &runtime,
|
|
208
|
+
const jsi::PropNameID &propNameId,
|
|
209
|
+
const jsi::Value &value) {
|
|
210
|
+
auto propName = propNameId.utf8(runtime);
|
|
211
|
+
|
|
212
|
+
throw std::runtime_error("Not yet implemented!");
|
|
213
|
+
}
|
|
214
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <utility>
|
|
6
|
+
#include <vector>
|
|
7
|
+
|
|
8
|
+
#include "AudioBufferHostObject.h"
|
|
9
|
+
#include "AudioBufferSourceNodeHostObject.h"
|
|
10
|
+
#include "AudioDestinationNodeHostObject.h"
|
|
11
|
+
#include "BaseAudioContextWrapper.h"
|
|
12
|
+
#include "BiquadFilterNodeHostObject.h"
|
|
13
|
+
#include "GainNodeHostObject.h"
|
|
14
|
+
#include "OscillatorNodeHostObject.h"
|
|
15
|
+
#include "PeriodicWaveHostObject.h"
|
|
16
|
+
#include "StereoPannerNodeHostObject.h"
|
|
17
|
+
|
|
18
|
+
namespace audioapi {
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class BaseAudioContextHostObject : public jsi::HostObject {
|
|
22
|
+
public:
|
|
23
|
+
explicit BaseAudioContextHostObject(
|
|
24
|
+
const std::shared_ptr<BaseAudioContextWrapper> &wrapper);
|
|
25
|
+
|
|
26
|
+
jsi::Value get(jsi::Runtime &runtime, const jsi::PropNameID &name) override;
|
|
27
|
+
|
|
28
|
+
void set(
|
|
29
|
+
jsi::Runtime &runtime,
|
|
30
|
+
const jsi::PropNameID &name,
|
|
31
|
+
const jsi::Value &value) override;
|
|
32
|
+
|
|
33
|
+
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;
|
|
34
|
+
|
|
35
|
+
protected:
|
|
36
|
+
std::shared_ptr<BaseAudioContextWrapper> wrapper_;
|
|
37
|
+
std::shared_ptr<AudioDestinationNodeHostObject> destination_;
|
|
38
|
+
};
|
|
39
|
+
} // namespace audioapi
|
|
@@ -30,6 +30,8 @@ std::vector<jsi::PropNameID> BiquadFilterNodeHostObject::getPropertyNames(
|
|
|
30
30
|
propertyNames.push_back(jsi::PropNameID::forAscii(runtime, "Q"));
|
|
31
31
|
propertyNames.push_back(jsi::PropNameID::forAscii(runtime, "gain"));
|
|
32
32
|
propertyNames.push_back(jsi::PropNameID::forAscii(runtime, "type"));
|
|
33
|
+
propertyNames.push_back(
|
|
34
|
+
jsi::PropNameID::forAscii(runtime, "getFrequencyResponse"));
|
|
33
35
|
return propertyNames;
|
|
34
36
|
}
|
|
35
37
|
|
|
@@ -60,6 +62,48 @@ jsi::Value BiquadFilterNodeHostObject::get(
|
|
|
60
62
|
return jsi::String::createFromUtf8(runtime, waveType);
|
|
61
63
|
}
|
|
62
64
|
|
|
65
|
+
if (propName == "getFrequencyResponse") {
|
|
66
|
+
return jsi::Function::createFromHostFunction(
|
|
67
|
+
runtime,
|
|
68
|
+
propNameId,
|
|
69
|
+
3,
|
|
70
|
+
[this](
|
|
71
|
+
jsi::Runtime &rt,
|
|
72
|
+
const jsi::Value &thisVal,
|
|
73
|
+
const jsi::Value *args,
|
|
74
|
+
size_t count) -> jsi::Value {
|
|
75
|
+
auto frequencyArray = args[0].getObject(rt).asArray(rt);
|
|
76
|
+
auto magResponseOut = args[1].getObject(rt).asArray(rt);
|
|
77
|
+
auto phaseResponseOut = args[2].getObject(rt).asArray(rt);
|
|
78
|
+
|
|
79
|
+
std::vector<float> frequencyArrayVector(frequencyArray.length(rt));
|
|
80
|
+
for (size_t i = 0; i < frequencyArray.length(rt); i++) {
|
|
81
|
+
frequencyArrayVector[i] = static_cast<float>(
|
|
82
|
+
frequencyArray.getValueAtIndex(rt, i).getNumber());
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
std::vector<float> magResponseOutVector(magResponseOut.length(rt));
|
|
86
|
+
std::vector<float> phaseResponseOutVector(
|
|
87
|
+
phaseResponseOut.length(rt));
|
|
88
|
+
|
|
89
|
+
auto wrapper = getBiquadFilterNodeWrapperFromAudioNodeWrapper();
|
|
90
|
+
wrapper->getFrequencyResponse(
|
|
91
|
+
frequencyArrayVector,
|
|
92
|
+
magResponseOutVector,
|
|
93
|
+
phaseResponseOutVector);
|
|
94
|
+
|
|
95
|
+
for (size_t i = 0; i < magResponseOutVector.size(); i++) {
|
|
96
|
+
magResponseOut.setValueAtIndex(rt, i, magResponseOutVector[i]);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
for (size_t i = 0; i < phaseResponseOutVector.size(); i++) {
|
|
100
|
+
phaseResponseOut.setValueAtIndex(rt, i, phaseResponseOutVector[i]);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return jsi::Value::undefined();
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
63
107
|
return AudioNodeHostObject::get(runtime, propNameId);
|
|
64
108
|
}
|
|
65
109
|
|
|
@@ -24,6 +24,8 @@ std::vector<jsi::PropNameID> OscillatorNodeHostObject::getPropertyNames(
|
|
|
24
24
|
propertyNames.push_back(jsi::PropNameID::forAscii(runtime, "frequency"));
|
|
25
25
|
propertyNames.push_back(jsi::PropNameID::forAscii(runtime, "detune"));
|
|
26
26
|
propertyNames.push_back(jsi::PropNameID::forAscii(runtime, "type"));
|
|
27
|
+
propertyNames.push_back(
|
|
28
|
+
jsi::PropNameID::forAscii(runtime, "setPeriodicWave"));
|
|
27
29
|
return propertyNames;
|
|
28
30
|
}
|
|
29
31
|
|
|
@@ -46,6 +48,25 @@ jsi::Value OscillatorNodeHostObject::get(
|
|
|
46
48
|
return jsi::String::createFromUtf8(runtime, waveType);
|
|
47
49
|
}
|
|
48
50
|
|
|
51
|
+
if (propName == "setPeriodicWave") {
|
|
52
|
+
return jsi::Function::createFromHostFunction(
|
|
53
|
+
runtime,
|
|
54
|
+
propNameId,
|
|
55
|
+
1,
|
|
56
|
+
[this](
|
|
57
|
+
jsi::Runtime &rt,
|
|
58
|
+
const jsi::Value &thisVal,
|
|
59
|
+
const jsi::Value *args,
|
|
60
|
+
size_t count) -> jsi::Value {
|
|
61
|
+
auto wrapper = getOscillatorNodeWrapperFromAudioNodeWrapper();
|
|
62
|
+
auto periodicWaveHostObject =
|
|
63
|
+
args[0].getObject(rt).asHostObject<PeriodicWaveHostObject>(rt);
|
|
64
|
+
|
|
65
|
+
wrapper->setPeriodicWave(periodicWaveHostObject->wrapper_);
|
|
66
|
+
return jsi::Value::undefined();
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
49
70
|
return AudioScheduledSourceNodeHostObject::get(runtime, propNameId);
|
|
50
71
|
}
|
|
51
72
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#include "PeriodicWaveHostObject.h"
|
|
2
|
+
|
|
3
|
+
namespace audioapi {
|
|
4
|
+
using namespace facebook;
|
|
5
|
+
|
|
6
|
+
PeriodicWaveHostObject::PeriodicWaveHostObject(
|
|
7
|
+
const std::shared_ptr<PeriodicWaveWrapper> &wrapper)
|
|
8
|
+
: wrapper_(wrapper) {}
|
|
9
|
+
|
|
10
|
+
std::vector<jsi::PropNameID> PeriodicWaveHostObject::getPropertyNames(
|
|
11
|
+
jsi::Runtime &runtime) {
|
|
12
|
+
std::vector<jsi::PropNameID> propertyNames;
|
|
13
|
+
return propertyNames;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
jsi::Value PeriodicWaveHostObject::get(
|
|
17
|
+
jsi::Runtime &runtime,
|
|
18
|
+
const jsi::PropNameID &propNameId) {
|
|
19
|
+
auto propName = propNameId.utf8(runtime);
|
|
20
|
+
|
|
21
|
+
throw std::runtime_error("Not yet implemented!");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
void PeriodicWaveHostObject::set(
|
|
25
|
+
jsi::Runtime &runtime,
|
|
26
|
+
const jsi::PropNameID &propNameId,
|
|
27
|
+
const jsi::Value &value) {
|
|
28
|
+
auto propName = propNameId.utf8(runtime);
|
|
29
|
+
|
|
30
|
+
throw std::runtime_error("Not yet implemented!");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
} // namespace audioapi
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <jsi/jsi.h>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <vector>
|
|
6
|
+
|
|
7
|
+
#include "PeriodicWaveWrapper.h"
|
|
8
|
+
|
|
9
|
+
namespace audioapi {
|
|
10
|
+
using namespace facebook;
|
|
11
|
+
|
|
12
|
+
class PeriodicWaveHostObject : public jsi::HostObject {
|
|
13
|
+
public:
|
|
14
|
+
std::shared_ptr<PeriodicWaveWrapper> wrapper_;
|
|
15
|
+
|
|
16
|
+
explicit PeriodicWaveHostObject(
|
|
17
|
+
const std::shared_ptr<PeriodicWaveWrapper> &wrapper);
|
|
18
|
+
|
|
19
|
+
jsi::Value get(jsi::Runtime &runtime, const jsi::PropNameID &name) override;
|
|
20
|
+
|
|
21
|
+
void set(
|
|
22
|
+
jsi::Runtime &runtime,
|
|
23
|
+
const jsi::PropNameID &name,
|
|
24
|
+
const jsi::Value &value) override;
|
|
25
|
+
|
|
26
|
+
std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;
|
|
27
|
+
|
|
28
|
+
static std::shared_ptr<PeriodicWaveHostObject> createFromWrapper(
|
|
29
|
+
const std::shared_ptr<PeriodicWaveWrapper> &wrapper) {
|
|
30
|
+
return std::make_shared<PeriodicWaveHostObject>(wrapper);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
} // namespace audioapi
|