react-native-audio-api 0.12.0-nightly-6993a06-20260122 → 0.12.0-nightly-6a44b58-20260124
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/common/cpp/audioapi/HostObjects/analysis/AnalyserNodeHostObject.cpp +4 -2
- package/common/cpp/audioapi/HostObjects/analysis/AnalyserNodeHostObject.h +1 -2
- package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.cpp +4 -2
- package/common/cpp/audioapi/HostObjects/effects/BiquadFilterNodeHostObject.h +1 -0
- package/common/cpp/audioapi/HostObjects/effects/WaveShaperNodeHostObject.cpp +4 -3
- package/common/cpp/audioapi/HostObjects/effects/WaveShaperNodeHostObject.h +2 -0
- package/common/cpp/audioapi/HostObjects/sources/OscillatorNodeHostObject.cpp +4 -2
- package/common/cpp/audioapi/HostObjects/sources/OscillatorNodeHostObject.h +1 -0
- package/common/cpp/audioapi/HostObjects/utils/JsEnumParser.cpp +127 -0
- package/common/cpp/audioapi/HostObjects/utils/JsEnumParser.h +17 -0
- package/common/cpp/audioapi/core/analysis/AnalyserNode.cpp +8 -8
- package/common/cpp/audioapi/core/analysis/AnalyserNode.h +2 -26
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.cpp +4 -4
- package/common/cpp/audioapi/core/effects/BiquadFilterNode.h +3 -50
- package/common/cpp/audioapi/core/effects/WaveShaperNode.cpp +5 -5
- package/common/cpp/audioapi/core/effects/WaveShaperNode.h +2 -25
- package/common/cpp/audioapi/core/sources/OscillatorNode.cpp +4 -4
- package/common/cpp/audioapi/core/sources/OscillatorNode.h +2 -37
- package/common/cpp/test/src/core/effects/WaveShaperNodeTest.cpp +2 -1
- package/development/react/package.json +6 -0
- package/lib/commonjs/development/react/Audio/Audio.js +26 -0
- package/lib/commonjs/development/react/Audio/Audio.js.map +1 -0
- package/lib/commonjs/development/react/Audio/Audio.web.js +12 -0
- package/lib/commonjs/development/react/Audio/Audio.web.js.map +1 -0
- package/lib/commonjs/development/react/Audio/index.js +14 -0
- package/lib/commonjs/development/react/Audio/index.js.map +1 -0
- package/lib/commonjs/development/react/Audio/types.js +2 -0
- package/lib/commonjs/development/react/Audio/types.js.map +1 -0
- package/lib/commonjs/development/react/Audio/utils.js +67 -0
- package/lib/commonjs/development/react/Audio/utils.js.map +1 -0
- package/lib/commonjs/development/react/index.js +28 -0
- package/lib/commonjs/development/react/index.js.map +1 -0
- package/lib/module/development/react/Audio/Audio.js +22 -0
- package/lib/module/development/react/Audio/Audio.js.map +1 -0
- package/lib/module/development/react/Audio/Audio.web.js +8 -0
- package/lib/module/development/react/Audio/Audio.web.js.map +1 -0
- package/lib/module/development/react/Audio/index.js +4 -0
- package/lib/module/development/react/Audio/index.js.map +1 -0
- package/lib/module/development/react/Audio/types.js +2 -0
- package/lib/module/development/react/Audio/types.js.map +1 -0
- package/lib/module/development/react/Audio/utils.js +62 -0
- package/lib/module/development/react/Audio/utils.js.map +1 -0
- package/lib/module/development/react/index.js +5 -0
- package/lib/module/development/react/index.js.map +1 -0
- package/lib/typescript/development/react/Audio/Audio.d.ts +5 -0
- package/lib/typescript/development/react/Audio/Audio.d.ts.map +1 -0
- package/lib/typescript/development/react/Audio/Audio.web.d.ts +5 -0
- package/lib/typescript/development/react/Audio/Audio.web.d.ts.map +1 -0
- package/lib/typescript/development/react/Audio/index.d.ts +3 -0
- package/lib/typescript/development/react/Audio/index.d.ts.map +1 -0
- package/lib/typescript/development/react/Audio/types.d.ts +47 -0
- package/lib/typescript/development/react/Audio/types.d.ts.map +1 -0
- package/lib/typescript/development/react/Audio/utils.d.ts +4 -0
- package/lib/typescript/development/react/Audio/utils.d.ts.map +1 -0
- package/lib/typescript/development/react/index.d.ts +3 -0
- package/lib/typescript/development/react/index.d.ts.map +1 -0
- package/package.json +2 -1
- package/src/development/react/Audio/Audio.tsx +24 -0
- package/src/development/react/Audio/Audio.web.tsx +9 -0
- package/src/development/react/Audio/index.ts +3 -0
- package/src/development/react/Audio/types.ts +64 -0
- package/src/development/react/Audio/utils.ts +86 -0
- package/src/development/react/index.ts +2 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#include <audioapi/HostObjects/analysis/AnalyserNodeHostObject.h>
|
|
2
2
|
|
|
3
3
|
#include <audioapi/core/analysis/AnalyserNode.h>
|
|
4
|
+
#include <audioapi/HostObjects/utils/JsEnumParser.h>
|
|
4
5
|
#include <memory>
|
|
5
6
|
|
|
6
7
|
namespace audioapi {
|
|
@@ -57,7 +58,7 @@ JSI_PROPERTY_GETTER_IMPL(AnalyserNodeHostObject, smoothingTimeConstant) {
|
|
|
57
58
|
JSI_PROPERTY_GETTER_IMPL(AnalyserNodeHostObject, window) {
|
|
58
59
|
auto analyserNode = std::static_pointer_cast<AnalyserNode>(node_);
|
|
59
60
|
auto windowType = analyserNode->getWindowType();
|
|
60
|
-
return jsi::String::createFromUtf8(runtime, windowType);
|
|
61
|
+
return jsi::String::createFromUtf8(runtime, js_enum_parser::windowTypeToString(windowType));
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
JSI_PROPERTY_SETTER_IMPL(AnalyserNodeHostObject, fftSize) {
|
|
@@ -86,7 +87,8 @@ JSI_PROPERTY_SETTER_IMPL(AnalyserNodeHostObject, smoothingTimeConstant) {
|
|
|
86
87
|
|
|
87
88
|
JSI_PROPERTY_SETTER_IMPL(AnalyserNodeHostObject, window) {
|
|
88
89
|
auto analyserNode = std::static_pointer_cast<AnalyserNode>(node_);
|
|
89
|
-
|
|
90
|
+
auto type = value.asString(runtime).utf8(runtime);
|
|
91
|
+
analyserNode->setWindowType(js_enum_parser::windowTypeFromString(type));
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
JSI_HOST_FUNCTION_IMPL(AnalyserNodeHostObject, getFloatFrequencyData) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <audioapi/HostObjects/AudioNodeHostObject.h>
|
|
4
|
+
#include <audioapi/core/analysis/AnalyserNode.h>
|
|
4
5
|
|
|
5
6
|
#include <memory>
|
|
6
7
|
#include <string>
|
|
@@ -9,8 +10,6 @@
|
|
|
9
10
|
namespace audioapi {
|
|
10
11
|
using namespace facebook;
|
|
11
12
|
|
|
12
|
-
class AnalyserNode;
|
|
13
|
-
|
|
14
13
|
class AnalyserNodeHostObject : public AudioNodeHostObject {
|
|
15
14
|
public:
|
|
16
15
|
explicit AnalyserNodeHostObject(const std::shared_ptr<AnalyserNode> &node);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
#include <audioapi/HostObjects/AudioParamHostObject.h>
|
|
4
4
|
#include <audioapi/core/effects/BiquadFilterNode.h>
|
|
5
|
+
#include <audioapi/HostObjects/utils/JsEnumParser.h>
|
|
5
6
|
#include <memory>
|
|
6
7
|
|
|
7
8
|
namespace audioapi {
|
|
@@ -49,12 +50,13 @@ JSI_PROPERTY_GETTER_IMPL(BiquadFilterNodeHostObject, gain) {
|
|
|
49
50
|
JSI_PROPERTY_GETTER_IMPL(BiquadFilterNodeHostObject, type) {
|
|
50
51
|
auto biquadFilterNode = std::static_pointer_cast<BiquadFilterNode>(node_);
|
|
51
52
|
auto type = biquadFilterNode->getType();
|
|
52
|
-
return jsi::String::createFromUtf8(runtime, type);
|
|
53
|
+
return jsi::String::createFromUtf8(runtime, js_enum_parser::filterTypeToString(type));
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
JSI_PROPERTY_SETTER_IMPL(BiquadFilterNodeHostObject, type) {
|
|
56
57
|
auto biquadFilterNode = std::static_pointer_cast<BiquadFilterNode>(node_);
|
|
57
|
-
|
|
58
|
+
auto type = value.asString(runtime).utf8(runtime);
|
|
59
|
+
biquadFilterNode->setType(js_enum_parser::filterTypeFromString(type));
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
JSI_HOST_FUNCTION_IMPL(BiquadFilterNodeHostObject, getFrequencyResponse) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#include <audioapi/HostObjects/effects/WaveShaperNodeHostObject.h>
|
|
2
2
|
#include <audioapi/core/effects/WaveShaperNode.h>
|
|
3
3
|
#include <audioapi/jsi/AudioArrayBuffer.h>
|
|
4
|
+
#include <audioapi/HostObjects/utils/JsEnumParser.h>
|
|
4
5
|
|
|
5
6
|
#include <memory>
|
|
6
7
|
#include <string>
|
|
@@ -19,7 +20,7 @@ WaveShaperNodeHostObject::WaveShaperNodeHostObject(const std::shared_ptr<WaveSha
|
|
|
19
20
|
|
|
20
21
|
JSI_PROPERTY_GETTER_IMPL(WaveShaperNodeHostObject, oversample) {
|
|
21
22
|
auto waveShaperNode = std::static_pointer_cast<WaveShaperNode>(node_);
|
|
22
|
-
return jsi::String::createFromUtf8(runtime, waveShaperNode->getOversample());
|
|
23
|
+
return jsi::String::createFromUtf8(runtime, js_enum_parser::overSampleTypeToString(waveShaperNode->getOversample()));
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
JSI_PROPERTY_GETTER_IMPL(WaveShaperNodeHostObject, curve) {
|
|
@@ -44,8 +45,8 @@ JSI_PROPERTY_GETTER_IMPL(WaveShaperNodeHostObject, curve) {
|
|
|
44
45
|
|
|
45
46
|
JSI_PROPERTY_SETTER_IMPL(WaveShaperNodeHostObject, oversample) {
|
|
46
47
|
auto waveShaperNode = std::static_pointer_cast<WaveShaperNode>(node_);
|
|
47
|
-
|
|
48
|
-
waveShaperNode->setOversample(type);
|
|
48
|
+
auto type = value.asString(runtime).utf8(runtime);
|
|
49
|
+
waveShaperNode->setOversample(js_enum_parser::overSampleTypeFromString(type));
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
JSI_HOST_FUNCTION_IMPL(WaveShaperNodeHostObject, setCurve) {
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#include <audioapi/HostObjects/AudioParamHostObject.h>
|
|
4
4
|
#include <audioapi/HostObjects/effects/PeriodicWaveHostObject.h>
|
|
5
5
|
#include <audioapi/core/sources/OscillatorNode.h>
|
|
6
|
+
#include <audioapi/HostObjects/utils/JsEnumParser.h>
|
|
6
7
|
#include <memory>
|
|
7
8
|
|
|
8
9
|
namespace audioapi {
|
|
@@ -35,7 +36,7 @@ JSI_PROPERTY_GETTER_IMPL(OscillatorNodeHostObject, detune) {
|
|
|
35
36
|
JSI_PROPERTY_GETTER_IMPL(OscillatorNodeHostObject, type) {
|
|
36
37
|
auto oscillatorNode = std::static_pointer_cast<OscillatorNode>(node_);
|
|
37
38
|
auto waveType = oscillatorNode->getType();
|
|
38
|
-
return jsi::String::createFromUtf8(runtime, waveType);
|
|
39
|
+
return jsi::String::createFromUtf8(runtime, js_enum_parser::oscillatorTypeToString(waveType));
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
JSI_HOST_FUNCTION_IMPL(OscillatorNodeHostObject, setPeriodicWave) {
|
|
@@ -47,7 +48,8 @@ JSI_HOST_FUNCTION_IMPL(OscillatorNodeHostObject, setPeriodicWave) {
|
|
|
47
48
|
|
|
48
49
|
JSI_PROPERTY_SETTER_IMPL(OscillatorNodeHostObject, type) {
|
|
49
50
|
auto oscillatorNode = std::static_pointer_cast<OscillatorNode>(node_);
|
|
50
|
-
|
|
51
|
+
auto type = value.asString(runtime).utf8(runtime);
|
|
52
|
+
oscillatorNode->setType(js_enum_parser::oscillatorTypeFromString(type));
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
} // namespace audioapi
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#include <audioapi/HostObjects/utils/JsEnumParser.h>
|
|
2
|
+
#include <string>
|
|
3
|
+
|
|
4
|
+
using WindowType = audioapi::AnalyserNode::WindowType;
|
|
5
|
+
|
|
6
|
+
namespace audioapi::js_enum_parser {
|
|
7
|
+
|
|
8
|
+
WindowType windowTypeFromString(const std::string &type) {
|
|
9
|
+
if (type == "blackman") {
|
|
10
|
+
return WindowType::BLACKMAN;
|
|
11
|
+
}
|
|
12
|
+
if (type == "hann") {
|
|
13
|
+
return WindowType::HANN;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
throw std::invalid_argument("Unknown window type");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
std::string windowTypeToString(WindowType type) {
|
|
21
|
+
switch (type) {
|
|
22
|
+
case WindowType::BLACKMAN:
|
|
23
|
+
return "blackman";
|
|
24
|
+
case WindowType::HANN:
|
|
25
|
+
return "hann";
|
|
26
|
+
default:
|
|
27
|
+
throw std::invalid_argument("Unknown window type");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
BiquadFilterType filterTypeFromString(const std::string &type) {
|
|
32
|
+
if (type == "lowpass")
|
|
33
|
+
return BiquadFilterType::LOWPASS;
|
|
34
|
+
if (type == "highpass")
|
|
35
|
+
return BiquadFilterType::HIGHPASS;
|
|
36
|
+
if (type == "bandpass")
|
|
37
|
+
return BiquadFilterType::BANDPASS;
|
|
38
|
+
if (type == "lowshelf")
|
|
39
|
+
return BiquadFilterType::LOWSHELF;
|
|
40
|
+
if (type == "highshelf")
|
|
41
|
+
return BiquadFilterType::HIGHSHELF;
|
|
42
|
+
if (type == "peaking")
|
|
43
|
+
return BiquadFilterType::PEAKING;
|
|
44
|
+
if (type == "notch")
|
|
45
|
+
return BiquadFilterType::NOTCH;
|
|
46
|
+
if (type == "allpass")
|
|
47
|
+
return BiquadFilterType::ALLPASS;
|
|
48
|
+
|
|
49
|
+
throw std::invalid_argument("Invalid filter type: " + type);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
std::string filterTypeToString(BiquadFilterType type) {
|
|
53
|
+
switch (type) {
|
|
54
|
+
case BiquadFilterType::LOWPASS:
|
|
55
|
+
return "lowpass";
|
|
56
|
+
case BiquadFilterType::HIGHPASS:
|
|
57
|
+
return "highpass";
|
|
58
|
+
case BiquadFilterType::BANDPASS:
|
|
59
|
+
return "bandpass";
|
|
60
|
+
case BiquadFilterType::LOWSHELF:
|
|
61
|
+
return "lowshelf";
|
|
62
|
+
case BiquadFilterType::HIGHSHELF:
|
|
63
|
+
return "highshelf";
|
|
64
|
+
case BiquadFilterType::PEAKING:
|
|
65
|
+
return "peaking";
|
|
66
|
+
case BiquadFilterType::NOTCH:
|
|
67
|
+
return "notch";
|
|
68
|
+
case BiquadFilterType::ALLPASS:
|
|
69
|
+
return "allpass";
|
|
70
|
+
default:
|
|
71
|
+
throw std::invalid_argument("Unknown filter type");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
OverSampleType overSampleTypeFromString(const std::string &type) {
|
|
76
|
+
if (type == "2x")
|
|
77
|
+
return OverSampleType::OVERSAMPLE_2X;
|
|
78
|
+
if (type == "4x")
|
|
79
|
+
return OverSampleType::OVERSAMPLE_4X;
|
|
80
|
+
|
|
81
|
+
return OverSampleType::OVERSAMPLE_NONE;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
std::string overSampleTypeToString(OverSampleType type) {
|
|
85
|
+
switch (type) {
|
|
86
|
+
case OverSampleType::OVERSAMPLE_2X:
|
|
87
|
+
return "2x";
|
|
88
|
+
case OverSampleType::OVERSAMPLE_4X:
|
|
89
|
+
return "4x";
|
|
90
|
+
default:
|
|
91
|
+
return "none";
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
OscillatorType oscillatorTypeFromString(const std::string &type) {
|
|
96
|
+
if (type == "sine")
|
|
97
|
+
return OscillatorType::SINE;
|
|
98
|
+
if (type == "square")
|
|
99
|
+
return OscillatorType::SQUARE;
|
|
100
|
+
if (type == "sawtooth")
|
|
101
|
+
return OscillatorType::SAWTOOTH;
|
|
102
|
+
if (type == "triangle")
|
|
103
|
+
return OscillatorType::TRIANGLE;
|
|
104
|
+
if (type == "custom")
|
|
105
|
+
return OscillatorType::CUSTOM;
|
|
106
|
+
|
|
107
|
+
throw std::invalid_argument("Unknown oscillator type: " + type);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
std::string oscillatorTypeToString(OscillatorType type) {
|
|
111
|
+
switch (type) {
|
|
112
|
+
case OscillatorType::SINE:
|
|
113
|
+
return "sine";
|
|
114
|
+
case OscillatorType::SQUARE:
|
|
115
|
+
return "square";
|
|
116
|
+
case OscillatorType::SAWTOOTH:
|
|
117
|
+
return "sawtooth";
|
|
118
|
+
case OscillatorType::TRIANGLE:
|
|
119
|
+
return "triangle";
|
|
120
|
+
case OscillatorType::CUSTOM:
|
|
121
|
+
return "custom";
|
|
122
|
+
default:
|
|
123
|
+
throw std::invalid_argument("Unknown oscillator type");
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
} // namespace audioapi::js_enum_parser
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
#include <audioapi/core/analysis/AnalyserNode.h>
|
|
3
|
+
#include <audioapi/core/types/BiquadFilterType.h>
|
|
4
|
+
#include <audioapi/core/types/OscillatorType.h>
|
|
5
|
+
#include <audioapi/core/types/OverSampleType.h>
|
|
6
|
+
#include <string>
|
|
7
|
+
|
|
8
|
+
namespace audioapi::js_enum_parser {
|
|
9
|
+
std::string windowTypeToString(AnalyserNode::WindowType type);
|
|
10
|
+
AnalyserNode::WindowType windowTypeFromString(const std::string &type);
|
|
11
|
+
std::string overSampleTypeToString(OverSampleType type);
|
|
12
|
+
OverSampleType overSampleTypeFromString(const std::string &type);
|
|
13
|
+
std::string oscillatorTypeToString(OscillatorType type);
|
|
14
|
+
OscillatorType oscillatorTypeFromString(const std::string &type);
|
|
15
|
+
std::string filterTypeToString(BiquadFilterType type);
|
|
16
|
+
BiquadFilterType filterTypeFromString(const std::string &type);
|
|
17
|
+
} // namespace audioapi::js_enum_parser
|
|
@@ -51,8 +51,8 @@ float AnalyserNode::getSmoothingTimeConstant() const {
|
|
|
51
51
|
return smoothingTimeConstant_;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
return
|
|
54
|
+
AnalyserNode::WindowType AnalyserNode::getWindowType() const {
|
|
55
|
+
return windowType_;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
void AnalyserNode::setFftSize(int fftSize) {
|
|
@@ -80,9 +80,8 @@ void AnalyserNode::setSmoothingTimeConstant(float smoothingTimeConstant) {
|
|
|
80
80
|
smoothingTimeConstant_ = smoothingTimeConstant;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
void AnalyserNode::setWindowType(
|
|
84
|
-
setWindowData(
|
|
85
|
-
windowType_ = AnalyserNode::fromString(type);
|
|
83
|
+
void AnalyserNode::setWindowType(AnalyserNode::WindowType type) {
|
|
84
|
+
setWindowData(type, fftSize_);
|
|
86
85
|
}
|
|
87
86
|
|
|
88
87
|
void AnalyserNode::getFloatFrequencyData(float *data, int length) {
|
|
@@ -189,12 +188,13 @@ void AnalyserNode::doFFTAnalysis() {
|
|
|
189
188
|
}
|
|
190
189
|
}
|
|
191
190
|
|
|
192
|
-
void AnalyserNode::setWindowData(
|
|
193
|
-
if (windowType_ == type && windowData_ && windowData_->getSize() == size) {
|
|
191
|
+
void AnalyserNode::setWindowData(AnalyserNode::WindowType type, int size) {
|
|
192
|
+
if (windowType_ == type && windowData_ != nullptr && windowData_->getSize() == size) {
|
|
194
193
|
return;
|
|
195
194
|
}
|
|
196
195
|
|
|
197
|
-
|
|
196
|
+
windowType_ = type;
|
|
197
|
+
if (windowData_ == nullptr|| windowData_->getSize() != size) {
|
|
198
198
|
windowData_ = std::make_shared<AudioArray>(size);
|
|
199
199
|
}
|
|
200
200
|
|
|
@@ -27,13 +27,13 @@ class AnalyserNode : public AudioNode {
|
|
|
27
27
|
float getMinDecibels() const;
|
|
28
28
|
float getMaxDecibels() const;
|
|
29
29
|
float getSmoothingTimeConstant() const;
|
|
30
|
-
|
|
30
|
+
AnalyserNode::WindowType getWindowType() const;
|
|
31
31
|
|
|
32
32
|
void setFftSize(int fftSize);
|
|
33
33
|
void setMinDecibels(float minDecibels);
|
|
34
34
|
void setMaxDecibels(float maxDecibels);
|
|
35
35
|
void setSmoothingTimeConstant(float smoothingTimeConstant);
|
|
36
|
-
void setWindowType(
|
|
36
|
+
void setWindowType(AnalyserNode::WindowType);
|
|
37
37
|
|
|
38
38
|
void getFloatFrequencyData(float *data, int length);
|
|
39
39
|
void getByteFrequencyData(uint8_t *data, int length);
|
|
@@ -63,30 +63,6 @@ class AnalyserNode : public AudioNode {
|
|
|
63
63
|
std::unique_ptr<AudioArray> magnitudeBuffer_;
|
|
64
64
|
bool shouldDoFFTAnalysis_{true};
|
|
65
65
|
|
|
66
|
-
static WindowType fromString(const std::string &type) {
|
|
67
|
-
std::string lowerType = type;
|
|
68
|
-
std::transform(lowerType.begin(), lowerType.end(), lowerType.begin(), ::tolower);
|
|
69
|
-
if (lowerType == "blackman") {
|
|
70
|
-
return WindowType::BLACKMAN;
|
|
71
|
-
}
|
|
72
|
-
if (lowerType == "hann") {
|
|
73
|
-
return WindowType::HANN;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
throw std::invalid_argument("Unknown window type");
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
static std::string toString(WindowType type) {
|
|
80
|
-
switch (type) {
|
|
81
|
-
case WindowType::BLACKMAN:
|
|
82
|
-
return "blackman";
|
|
83
|
-
case WindowType::HANN:
|
|
84
|
-
return "hann";
|
|
85
|
-
default:
|
|
86
|
-
throw std::invalid_argument("Unknown window type");
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
66
|
void doFFTAnalysis();
|
|
91
67
|
|
|
92
68
|
void setWindowData(WindowType type, int size);
|
|
@@ -59,12 +59,12 @@ BiquadFilterNode::BiquadFilterNode(std::shared_ptr<BaseAudioContext> context, co
|
|
|
59
59
|
isInitialized_ = true;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
return
|
|
62
|
+
BiquadFilterType BiquadFilterNode::getType() {
|
|
63
|
+
return type_;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
void BiquadFilterNode::setType(
|
|
67
|
-
type_ =
|
|
66
|
+
void BiquadFilterNode::setType(BiquadFilterType type) {
|
|
67
|
+
type_ = type;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
std::shared_ptr<AudioParam> BiquadFilterNode::getFrequencyParam() const {
|
|
@@ -59,8 +59,8 @@ class BiquadFilterNode : public AudioNode {
|
|
|
59
59
|
std::shared_ptr<BaseAudioContext> context,
|
|
60
60
|
const BiquadFilterOptions &options);
|
|
61
61
|
|
|
62
|
-
[[nodiscard]]
|
|
63
|
-
void setType(
|
|
62
|
+
[[nodiscard]] BiquadFilterType getType();
|
|
63
|
+
void setType(BiquadFilterType);
|
|
64
64
|
[[nodiscard]] std::shared_ptr<AudioParam> getFrequencyParam() const;
|
|
65
65
|
[[nodiscard]] std::shared_ptr<AudioParam> getDetuneParam() const;
|
|
66
66
|
[[nodiscard]] std::shared_ptr<AudioParam> getQParam() const;
|
|
@@ -81,7 +81,7 @@ class BiquadFilterNode : public AudioNode {
|
|
|
81
81
|
std::shared_ptr<AudioParam> detuneParam_;
|
|
82
82
|
std::shared_ptr<AudioParam> QParam_;
|
|
83
83
|
std::shared_ptr<AudioParam> gainParam_;
|
|
84
|
-
|
|
84
|
+
BiquadFilterType type_;
|
|
85
85
|
|
|
86
86
|
// delayed samples, one per channel
|
|
87
87
|
std::vector<float> x1_;
|
|
@@ -96,53 +96,6 @@ class BiquadFilterNode : public AudioNode {
|
|
|
96
96
|
float a1_ = 0;
|
|
97
97
|
float a2_ = 0;
|
|
98
98
|
|
|
99
|
-
static BiquadFilterType fromString(const std::string &type) {
|
|
100
|
-
std::string lowerType = type;
|
|
101
|
-
std::transform(lowerType.begin(), lowerType.end(), lowerType.begin(), ::tolower);
|
|
102
|
-
|
|
103
|
-
if (lowerType == "lowpass")
|
|
104
|
-
return BiquadFilterType::LOWPASS;
|
|
105
|
-
if (lowerType == "highpass")
|
|
106
|
-
return BiquadFilterType::HIGHPASS;
|
|
107
|
-
if (lowerType == "bandpass")
|
|
108
|
-
return BiquadFilterType::BANDPASS;
|
|
109
|
-
if (lowerType == "lowshelf")
|
|
110
|
-
return BiquadFilterType::LOWSHELF;
|
|
111
|
-
if (lowerType == "highshelf")
|
|
112
|
-
return BiquadFilterType::HIGHSHELF;
|
|
113
|
-
if (lowerType == "peaking")
|
|
114
|
-
return BiquadFilterType::PEAKING;
|
|
115
|
-
if (lowerType == "notch")
|
|
116
|
-
return BiquadFilterType::NOTCH;
|
|
117
|
-
if (lowerType == "allpass")
|
|
118
|
-
return BiquadFilterType::ALLPASS;
|
|
119
|
-
|
|
120
|
-
throw std::invalid_argument("Invalid filter type: " + type);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
static std::string toString(BiquadFilterType type) {
|
|
124
|
-
switch (type) {
|
|
125
|
-
case BiquadFilterType::LOWPASS:
|
|
126
|
-
return "lowpass";
|
|
127
|
-
case BiquadFilterType::HIGHPASS:
|
|
128
|
-
return "highpass";
|
|
129
|
-
case BiquadFilterType::BANDPASS:
|
|
130
|
-
return "bandpass";
|
|
131
|
-
case BiquadFilterType::LOWSHELF:
|
|
132
|
-
return "lowshelf";
|
|
133
|
-
case BiquadFilterType::HIGHSHELF:
|
|
134
|
-
return "highshelf";
|
|
135
|
-
case BiquadFilterType::PEAKING:
|
|
136
|
-
return "peaking";
|
|
137
|
-
case BiquadFilterType::NOTCH:
|
|
138
|
-
return "notch";
|
|
139
|
-
case BiquadFilterType::ALLPASS:
|
|
140
|
-
return "allpass";
|
|
141
|
-
default:
|
|
142
|
-
throw std::invalid_argument("Unknown filter type");
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
99
|
void setNormalizedCoefficients(float b0, float b1, float b2, float a0, float a1, float a2);
|
|
147
100
|
void setLowpassCoefficients(float frequency, float Q);
|
|
148
101
|
void setHighpassCoefficients(float frequency, float Q);
|
|
@@ -24,16 +24,16 @@ WaveShaperNode::WaveShaperNode(std::shared_ptr<BaseAudioContext> context, const
|
|
|
24
24
|
isInitialized_ = true;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
return
|
|
27
|
+
OverSampleType WaveShaperNode::getOversample() const {
|
|
28
|
+
return oversample_.load(std::memory_order_acquire);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
void WaveShaperNode::setOversample(
|
|
31
|
+
void WaveShaperNode::setOversample(OverSampleType type) {
|
|
32
32
|
std::scoped_lock<std::mutex> lock(mutex_);
|
|
33
|
-
oversample_.store(
|
|
33
|
+
oversample_.store(type, std::memory_order_release);
|
|
34
34
|
|
|
35
35
|
for (int i = 0; i < waveShapers_.size(); i++) {
|
|
36
|
-
waveShapers_[i]->setOversample(
|
|
36
|
+
waveShapers_[i]->setOversample(type);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -24,10 +24,10 @@ class WaveShaperNode : public AudioNode {
|
|
|
24
24
|
std::shared_ptr<BaseAudioContext> context,
|
|
25
25
|
const WaveShaperOptions &options);
|
|
26
26
|
|
|
27
|
-
[[nodiscard]]
|
|
27
|
+
[[nodiscard]] OverSampleType getOversample() const;
|
|
28
28
|
[[nodiscard]] std::shared_ptr<AudioArray> getCurve() const;
|
|
29
29
|
|
|
30
|
-
void setOversample(
|
|
30
|
+
void setOversample(OverSampleType);
|
|
31
31
|
void setCurve(const std::shared_ptr<AudioArray> &curve);
|
|
32
32
|
|
|
33
33
|
protected:
|
|
@@ -41,29 +41,6 @@ class WaveShaperNode : public AudioNode {
|
|
|
41
41
|
mutable std::mutex mutex_;
|
|
42
42
|
|
|
43
43
|
std::vector<std::unique_ptr<WaveShaper>> waveShapers_{};
|
|
44
|
-
|
|
45
|
-
static OverSampleType overSampleTypeFromString(const std::string &type) {
|
|
46
|
-
std::string lowerType = type;
|
|
47
|
-
std::transform(lowerType.begin(), lowerType.end(), lowerType.begin(), ::tolower);
|
|
48
|
-
|
|
49
|
-
if (lowerType == "2x")
|
|
50
|
-
return OverSampleType::OVERSAMPLE_2X;
|
|
51
|
-
if (lowerType == "4x")
|
|
52
|
-
return OverSampleType::OVERSAMPLE_4X;
|
|
53
|
-
|
|
54
|
-
return OverSampleType::OVERSAMPLE_NONE;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
static std::string overSampleTypeToString(OverSampleType type) {
|
|
58
|
-
switch (type) {
|
|
59
|
-
case OverSampleType::OVERSAMPLE_2X:
|
|
60
|
-
return "2x";
|
|
61
|
-
case OverSampleType::OVERSAMPLE_4X:
|
|
62
|
-
return "4x";
|
|
63
|
-
default:
|
|
64
|
-
return "none";
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
44
|
};
|
|
68
45
|
|
|
69
46
|
} // namespace audioapi
|
|
@@ -41,13 +41,13 @@ std::shared_ptr<AudioParam> OscillatorNode::getDetuneParam() const {
|
|
|
41
41
|
return detuneParam_;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
return
|
|
44
|
+
OscillatorType OscillatorNode::getType() {
|
|
45
|
+
return type_;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
void OscillatorNode::setType(
|
|
48
|
+
void OscillatorNode::setType(OscillatorType type) {
|
|
49
49
|
if (std::shared_ptr<BaseAudioContext> context = context_.lock()) {
|
|
50
|
-
type_ =
|
|
50
|
+
type_ = type;
|
|
51
51
|
periodicWave_ = context->getBasicWaveForm(type_);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -23,8 +23,8 @@ class OscillatorNode : public AudioScheduledSourceNode {
|
|
|
23
23
|
|
|
24
24
|
[[nodiscard]] std::shared_ptr<AudioParam> getFrequencyParam() const;
|
|
25
25
|
[[nodiscard]] std::shared_ptr<AudioParam> getDetuneParam() const;
|
|
26
|
-
[[nodiscard]]
|
|
27
|
-
void setType(
|
|
26
|
+
[[nodiscard]] OscillatorType getType();
|
|
27
|
+
void setType(OscillatorType);
|
|
28
28
|
void setPeriodicWave(const std::shared_ptr<PeriodicWave> &periodicWave);
|
|
29
29
|
|
|
30
30
|
protected:
|
|
@@ -38,40 +38,5 @@ class OscillatorNode : public AudioScheduledSourceNode {
|
|
|
38
38
|
OscillatorType type_;
|
|
39
39
|
float phase_ = 0.0;
|
|
40
40
|
std::shared_ptr<PeriodicWave> periodicWave_;
|
|
41
|
-
|
|
42
|
-
static OscillatorType fromString(const std::string &type) {
|
|
43
|
-
std::string lowerType = type;
|
|
44
|
-
std::transform(lowerType.begin(), lowerType.end(), lowerType.begin(), ::tolower);
|
|
45
|
-
|
|
46
|
-
if (lowerType == "sine")
|
|
47
|
-
return OscillatorType::SINE;
|
|
48
|
-
if (lowerType == "square")
|
|
49
|
-
return OscillatorType::SQUARE;
|
|
50
|
-
if (lowerType == "sawtooth")
|
|
51
|
-
return OscillatorType::SAWTOOTH;
|
|
52
|
-
if (lowerType == "triangle")
|
|
53
|
-
return OscillatorType::TRIANGLE;
|
|
54
|
-
if (lowerType == "custom")
|
|
55
|
-
return OscillatorType::CUSTOM;
|
|
56
|
-
|
|
57
|
-
throw std::invalid_argument("Unknown oscillator type: " + type);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
static std::string toString(OscillatorType type) {
|
|
61
|
-
switch (type) {
|
|
62
|
-
case OscillatorType::SINE:
|
|
63
|
-
return "sine";
|
|
64
|
-
case OscillatorType::SQUARE:
|
|
65
|
-
return "square";
|
|
66
|
-
case OscillatorType::SAWTOOTH:
|
|
67
|
-
return "sawtooth";
|
|
68
|
-
case OscillatorType::TRIANGLE:
|
|
69
|
-
return "triangle";
|
|
70
|
-
case OscillatorType::CUSTOM:
|
|
71
|
-
return "custom";
|
|
72
|
-
default:
|
|
73
|
-
throw std::invalid_argument("Unknown oscillator type");
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
41
|
};
|
|
77
42
|
} // namespace audioapi
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#include <audioapi/core/OfflineAudioContext.h>
|
|
3
3
|
#include <audioapi/core/effects/WaveShaperNode.h>
|
|
4
4
|
#include <audioapi/core/utils/worklets/SafeIncludes.h>
|
|
5
|
+
#include <audioapi/core/types/OverSampleType.h>
|
|
5
6
|
#include <audioapi/utils/AudioArray.h>
|
|
6
7
|
#include <audioapi/utils/AudioBus.h>
|
|
7
8
|
#include <gtest/gtest.h>
|
|
@@ -57,7 +58,7 @@ TEST_F(WaveShaperNodeTest, NullCanBeAsignedToCurve) {
|
|
|
57
58
|
TEST_F(WaveShaperNodeTest, NoneOverSamplingProcessesCorrectly) {
|
|
58
59
|
static constexpr int FRAMES_TO_PROCESS = 5;
|
|
59
60
|
auto waveShaper = std::make_shared<TestableWaveShaperNode>(context);
|
|
60
|
-
waveShaper->setOversample(
|
|
61
|
+
waveShaper->setOversample(OverSampleType::OVERSAMPLE_NONE);
|
|
61
62
|
waveShaper->setCurve(waveShaper->testCurve_);
|
|
62
63
|
|
|
63
64
|
auto bus = std::make_shared<audioapi::AudioBus>(FRAMES_TO_PROCESS, 1, sampleRate);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _utils = require("./utils");
|
|
8
|
+
const Audio = inProps => {
|
|
9
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
10
|
+
const {
|
|
11
|
+
autoPlay,
|
|
12
|
+
controls,
|
|
13
|
+
loop,
|
|
14
|
+
muted,
|
|
15
|
+
preload,
|
|
16
|
+
source,
|
|
17
|
+
playbackRate,
|
|
18
|
+
preservesPitch,
|
|
19
|
+
volume
|
|
20
|
+
} = (0, _utils.useStableAudioProps)(inProps);
|
|
21
|
+
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
22
|
+
|
|
23
|
+
return null;
|
|
24
|
+
};
|
|
25
|
+
var _default = exports.default = Audio;
|
|
26
|
+
//# sourceMappingURL=Audio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_utils","require","Audio","inProps","autoPlay","controls","loop","muted","preload","source","playbackRate","preservesPitch","volume","useStableAudioProps","_default","exports","default"],"sourceRoot":"../../../../../src","sources":["development/react/Audio/Audio.tsx"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAEA,MAAMC,KAA2B,GAAIC,OAAO,IAAK;EAC/C;EACA,MAAM;IACJC,QAAQ;IACRC,QAAQ;IACRC,IAAI;IACJC,KAAK;IACLC,OAAO;IACPC,MAAM;IACNC,YAAY;IACZC,cAAc;IACdC;EACF,CAAC,GAAG,IAAAC,0BAAmB,EAACV,OAAO,CAAC;EAChC;;EAEA,OAAO,IAAI;AACb,CAAC;AAAC,IAAAW,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEad,KAAK","ignoreList":[]}
|