react-native-audio-api 0.4.12-beta.1 → 0.4.12-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RNAudioAPI.podspec +14 -4
- package/android/CMakeLists.txt +9 -48
- package/android/src/main/cpp/audioapi/CMakeLists.txt +44 -0
- package/android/src/main/cpp/{AudioAPIModule.cpp → audioapi/android/AudioAPIModule.cpp} +1 -4
- package/android/src/main/cpp/{AudioAPIModule.h → audioapi/android/AudioAPIModule.h} +2 -1
- package/android/src/main/cpp/{OnLoad.cpp → audioapi/android/OnLoad.cpp} +2 -1
- package/android/src/main/cpp/{core → audioapi/android/core}/AudioDecoder.cpp +5 -5
- package/android/src/main/cpp/{core → audioapi/android/core}/AudioPlayer.cpp +5 -7
- package/android/src/main/cpp/{core → audioapi/android/core}/AudioPlayer.h +1 -0
- package/android/src/main/cpp/{libs → audioapi/android/libs}/pffft.c +2 -2
- package/android/src/main/java/com/swmansion/audioapi/AudioAPIPackage.kt +1 -0
- package/common/cpp/{installer → audioapi}/AudioAPIModuleInstaller.h +5 -3
- package/common/cpp/{HostObjects → audioapi/HostObjects}/AnalyserNodeHostObject.h +3 -3
- package/common/cpp/{HostObjects → audioapi/HostObjects}/AudioBufferHostObject.h +3 -3
- package/common/cpp/{HostObjects → audioapi/HostObjects}/AudioBufferSourceNodeHostObject.h +5 -5
- package/common/cpp/{HostObjects → audioapi/HostObjects}/AudioContextHostObject.h +3 -3
- package/common/cpp/{HostObjects → audioapi/HostObjects}/AudioDestinationNodeHostObject.h +3 -3
- package/common/cpp/{HostObjects → audioapi/HostObjects}/AudioNodeHostObject.h +3 -3
- package/common/cpp/{HostObjects → audioapi/HostObjects}/AudioParamHostObject.h +3 -3
- package/common/cpp/{HostObjects → audioapi/HostObjects}/AudioScheduledSourceNodeHostObject.h +3 -3
- package/common/cpp/{HostObjects → audioapi/HostObjects}/BaseAudioContextHostObject.h +14 -15
- package/common/cpp/{HostObjects → audioapi/HostObjects}/BiquadFilterNodeHostObject.h +4 -4
- package/common/cpp/{HostObjects → audioapi/HostObjects}/GainNodeHostObject.h +4 -4
- package/common/cpp/{HostObjects → audioapi/HostObjects}/OscillatorNodeHostObject.h +5 -5
- package/common/cpp/{HostObjects → audioapi/HostObjects}/PeriodicWaveHostObject.h +2 -2
- package/common/cpp/{HostObjects → audioapi/HostObjects}/StereoPannerNodeHostObject.h +4 -4
- package/common/cpp/audioapi/HostObjects/StretcherNodeHostObject.h +35 -0
- package/common/cpp/{core → audioapi/core}/AudioContext.cpp +6 -6
- package/common/cpp/{core → audioapi/core}/AudioContext.h +2 -2
- package/common/cpp/{core → audioapi/core}/AudioNode.cpp +5 -7
- package/common/cpp/{core → audioapi/core}/AudioNode.h +5 -4
- package/common/cpp/{core → audioapi/core}/AudioParam.cpp +3 -4
- package/common/cpp/{core → audioapi/core}/AudioParam.h +3 -3
- package/common/cpp/{core → audioapi/core}/BaseAudioContext.cpp +14 -17
- package/common/cpp/{core → audioapi/core}/BaseAudioContext.h +4 -3
- package/common/cpp/{core → audioapi/core/analysis}/AnalyserNode.cpp +6 -10
- package/common/cpp/{core → audioapi/core/analysis}/AnalyserNode.h +4 -3
- package/common/cpp/{core → audioapi/core/destinations}/AudioDestinationNode.cpp +5 -5
- package/common/cpp/{core → audioapi/core/destinations}/AudioDestinationNode.h +2 -2
- package/common/cpp/{core → audioapi/core/effects}/BiquadFilterNode.cpp +4 -4
- package/common/cpp/{core → audioapi/core/effects}/BiquadFilterNode.h +4 -4
- package/common/cpp/{core → audioapi/core/effects}/GainNode.cpp +4 -4
- package/common/cpp/{core → audioapi/core/effects}/GainNode.h +3 -3
- package/common/cpp/{core → audioapi/core/effects}/PeriodicWave.cpp +4 -2
- package/common/cpp/{core → audioapi/core/effects}/PeriodicWave.h +2 -4
- package/common/cpp/{core → audioapi/core/effects}/StereoPannerNode.cpp +5 -7
- package/common/cpp/{core → audioapi/core/effects}/StereoPannerNode.h +4 -3
- package/common/cpp/{core → audioapi/core/effects}/StretcherNode.cpp +4 -6
- package/common/cpp/audioapi/core/effects/StretcherNode.h +35 -0
- package/common/cpp/{core → audioapi/core/sources}/AudioBuffer.cpp +3 -3
- package/common/cpp/{core → audioapi/core/sources}/AudioBufferSourceNode.cpp +8 -11
- package/common/cpp/{core → audioapi/core/sources}/AudioBufferSourceNode.h +5 -3
- package/common/cpp/{core → audioapi/core/sources}/AudioScheduledSourceNode.cpp +6 -8
- package/common/cpp/{core → audioapi/core/sources}/AudioScheduledSourceNode.h +3 -2
- package/common/cpp/{core → audioapi/core/sources}/OscillatorNode.cpp +4 -4
- package/common/cpp/{core → audioapi/core/sources}/OscillatorNode.h +5 -5
- package/common/cpp/{core → audioapi/core/utils}/AudioArray.cpp +2 -4
- package/common/cpp/{core → audioapi/core/utils}/AudioBus.cpp +4 -7
- package/common/cpp/{core → audioapi/core/utils}/AudioBus.h +2 -2
- package/common/cpp/{core → audioapi/core/utils}/AudioNodeManager.cpp +3 -4
- package/common/cpp/{core → audioapi/core/utils}/ParamChangeEvent.cpp +1 -3
- package/common/cpp/{core → audioapi/core/utils}/ParamChangeEvent.h +3 -1
- package/common/cpp/{utils → audioapi/dsp}/AudioUtils.cpp +1 -1
- package/common/cpp/{utils → audioapi/dsp}/FFTFrame.cpp +1 -10
- package/common/cpp/{utils → audioapi/dsp}/FFTFrame.h +4 -3
- package/common/cpp/{utils → audioapi/dsp}/VectorMath.cpp +2 -5
- package/common/cpp/{utils → audioapi/dsp}/VectorMath.h +2 -0
- package/common/cpp/{jsi → audioapi/jsi}/JsiHostObject.cpp +1 -1
- package/common/cpp/{jsi → audioapi/jsi}/JsiHostObject.h +2 -2
- package/common/cpp/{jsi → audioapi/jsi}/JsiPromise.cpp +2 -6
- package/common/cpp/{jsi → audioapi/jsi}/RuntimeAwareCache.h +2 -3
- package/common/cpp/{jsi → audioapi/jsi}/RuntimeLifecycleMonitor.cpp +1 -5
- package/common/cpp/{jsi → audioapi/jsi}/RuntimeLifecycleMonitor.h +3 -0
- package/common/cpp/{libs → audioapi/libs}/dsp/delay.h +35 -35
- package/common/cpp/{libs → audioapi/libs}/dsp/fft.h +21 -21
- package/common/cpp/{libs → audioapi/libs}/dsp/perf.h +3 -3
- package/common/cpp/{libs → audioapi/libs}/dsp/spectral.h +39 -39
- package/common/cpp/{libs → audioapi/libs}/dsp/windows.h +11 -11
- package/common/cpp/{libs → audioapi/libs}/signalsmith-stretch.h +30 -30
- package/ios/{AudioAPIModule.mm → audioapi/ios/AudioAPIModule.mm} +15 -8
- package/ios/{core → audioapi/ios/core}/AudioDecoder.mm +4 -4
- package/ios/{core → audioapi/ios/core}/AudioPlayer.m +1 -1
- package/ios/{core → audioapi/ios/core}/IOSAudioPlayer.mm +4 -4
- package/package.json +6 -6
- package/common/cpp/HostObjects/StretcherNodeHostObject.h +0 -35
- package/common/cpp/core/StretcherNode.h +0 -63
- package/common/cpp/libs/dsp/LICENSE.txt +0 -21
- package/common/cpp/libs/dsp/README.md +0 -40
- package/common/cpp/libs/dsp/curves.h +0 -371
- package/common/cpp/libs/dsp/envelopes.h +0 -523
- package/common/cpp/libs/dsp/filters.h +0 -436
- package/common/cpp/libs/dsp/mix.h +0 -218
- package/common/cpp/libs/dsp/rates.h +0 -184
- package/common/cpp/types/TimeStretchType.h +0 -6
- /package/android/src/main/cpp/{libs → audioapi/android/libs}/pffft.h +0 -0
- /package/common/cpp/{core → audioapi/core}/Constants.h +0 -0
- /package/common/cpp/{core → audioapi/core/sources}/AudioBuffer.h +0 -0
- /package/common/cpp/{types → audioapi/core/types}/BiquadFilterType.h +0 -0
- /package/common/cpp/{types → audioapi/core/types}/ChannelCountMode.h +0 -0
- /package/common/cpp/{types → audioapi/core/types}/ChannelInterpretation.h +0 -0
- /package/common/cpp/{types → audioapi/core/types}/ContextState.h +0 -0
- /package/common/cpp/{types → audioapi/core/types}/OscillatorType.h +0 -0
- /package/common/cpp/{types → audioapi/core/types}/ParamChangeEventType.h +0 -0
- /package/common/cpp/{core → audioapi/core/utils}/AudioArray.h +0 -0
- /package/common/cpp/{core → audioapi/core/utils}/AudioDecoder.h +0 -0
- /package/common/cpp/{core → audioapi/core/utils}/AudioNodeManager.h +0 -0
- /package/common/cpp/{utils → audioapi/core/utils}/Locker.h +0 -0
- /package/common/cpp/{utils → audioapi/dsp}/AudioUtils.h +0 -0
- /package/common/cpp/{jsi → audioapi/jsi}/JsiPromise.h +0 -0
- /package/common/cpp/{libs → audioapi/libs}/dsp/common.h +0 -0
- /package/common/cpp/{libs → audioapi/libs}/miniaudio.h +0 -0
- /package/ios/{AudioAPIModule.h → audioapi/ios/AudioAPIModule.h} +0 -0
- /package/ios/{core → audioapi/ios/core}/AudioPlayer.h +0 -0
- /package/ios/{core → audioapi/ios/core}/IOSAudioPlayer.h +0 -0
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
#include "./common.h"
|
|
2
|
-
|
|
3
|
-
#ifndef SIGNALSMITH_DSP_RATES_H
|
|
4
|
-
#define SIGNALSMITH_DSP_RATES_H
|
|
5
|
-
|
|
6
|
-
#include "./windows.h"
|
|
7
|
-
#include "./delay.h"
|
|
8
|
-
|
|
9
|
-
namespace signalsmith {
|
|
10
|
-
namespace rates {
|
|
11
|
-
/** @defgroup Rates Multi-rate processing
|
|
12
|
-
@brief Classes for oversampling/upsampling/downsampling etc.
|
|
13
|
-
|
|
14
|
-
@{
|
|
15
|
-
@file
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/// @brief Fills a container with a Kaiser-windowed sinc for an FIR lowpass.
|
|
19
|
-
/// \diagram{rates-kaiser-sinc.svg,33-point results for various pass/stop frequencies}
|
|
20
|
-
template<class Data>
|
|
21
|
-
void fillKaiserSinc(Data &&data, int length, double passFreq, double stopFreq) {
|
|
22
|
-
if (length <= 0) return;
|
|
23
|
-
double kaiserBandwidth = (stopFreq - passFreq)*length;
|
|
24
|
-
kaiserBandwidth += 1.25/kaiserBandwidth; // heuristic for transition band, see `InterpolatorKaiserSincN`
|
|
25
|
-
auto kaiser = signalsmith::windows::Kaiser::withBandwidth(kaiserBandwidth);
|
|
26
|
-
kaiser.fill(data, length);
|
|
27
|
-
|
|
28
|
-
double centreIndex = (length - 1)*0.5;
|
|
29
|
-
double sincScale = M_PI*(passFreq + stopFreq);
|
|
30
|
-
double ampScale = (passFreq + stopFreq);
|
|
31
|
-
for (int i = 0; i < length; ++i) {
|
|
32
|
-
double x = (i - centreIndex), px = x*sincScale;
|
|
33
|
-
double sinc = (std::abs(px) > 1e-6) ? std::sin(px)*ampScale/px : ampScale;
|
|
34
|
-
data[i] *= sinc;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
/// @brief If only the centre frequency is specified, a heuristic is used to balance ripples and transition width
|
|
38
|
-
/// \diagram{rates-kaiser-sinc-heuristic.svg,The transition width is set to: 0.9/sqrt(length)}
|
|
39
|
-
template<class Data>
|
|
40
|
-
void fillKaiserSinc(Data &&data, int length, double centreFreq) {
|
|
41
|
-
double halfWidth = 0.45/std::sqrt(length);
|
|
42
|
-
if (halfWidth > centreFreq) halfWidth = (halfWidth + centreFreq)*0.5;
|
|
43
|
-
fillKaiserSinc(data, length, centreFreq - halfWidth, centreFreq + halfWidth);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** 2x FIR oversampling for block-based processing.
|
|
47
|
-
|
|
48
|
-
\diagram{rates-oversampler2xfir-responses-45.svg,Upsample response for various lengths}
|
|
49
|
-
|
|
50
|
-
The oversampled signal is stored inside this object, with channels accessed via `oversampler[c]`. For example, you might do:
|
|
51
|
-
\code{.cpp}
|
|
52
|
-
// Upsample from multi-channel input (inputBuffers[c][i] is a sample)
|
|
53
|
-
oversampler.up(inputBuffers, bufferLength)
|
|
54
|
-
|
|
55
|
-
// Modify the contents at the higher rate
|
|
56
|
-
for (int c = 0; c < 2; ++c) {
|
|
57
|
-
float *channel = oversampler[c];
|
|
58
|
-
for (int i = 0; i < bufferLength*2; ++i) {
|
|
59
|
-
channel[i] = std::abs(channel[i]);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Downsample into the multi-channel output
|
|
64
|
-
oversampler.down(outputBuffers, bufferLength);
|
|
65
|
-
\endcode
|
|
66
|
-
|
|
67
|
-
The performance depends not just on the length, but also on where you end the passband, allowing a wider/narrower transition band. Frequencies above this limit (relative to the lower sample-rate) may alias when upsampling and downsampling.
|
|
68
|
-
|
|
69
|
-
\diagram{rates-oversampler2xfir-lengths.svg,Resample error rates for different passband thresholds}
|
|
70
|
-
|
|
71
|
-
Since both upsample and downsample are stateful, channels are meaningful. If your input channel-count doesn't match your output, you can size it to the larger of the two, and use `.upChannel()` and `.downChannel()` to only process the channels which exist.*/
|
|
72
|
-
template<typename Sample>
|
|
73
|
-
struct Oversampler2xFIR {
|
|
74
|
-
Oversampler2xFIR() : Oversampler2xFIR(0, 0) {}
|
|
75
|
-
Oversampler2xFIR(int channels, int maxBlock, int halfLatency=16, double passFreq=0.43) {
|
|
76
|
-
resize(channels, maxBlock, halfLatency, passFreq);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
void resize(int nChannels, int maxBlockLength) {
|
|
80
|
-
resize(nChannels, maxBlockLength, oneWayLatency);
|
|
81
|
-
}
|
|
82
|
-
void resize(int nChannels, int maxBlockLength, int halfLatency, double passFreq=0.43) {
|
|
83
|
-
oneWayLatency = halfLatency;
|
|
84
|
-
kernelLength = oneWayLatency*2;
|
|
85
|
-
channels = nChannels;
|
|
86
|
-
halfSampleKernel.resize(kernelLength);
|
|
87
|
-
fillKaiserSinc(halfSampleKernel, kernelLength, passFreq, 1 - passFreq);
|
|
88
|
-
inputStride = kernelLength + maxBlockLength;
|
|
89
|
-
inputBuffer.resize(channels*inputStride);
|
|
90
|
-
stride = (maxBlockLength + kernelLength)*2;
|
|
91
|
-
buffer.resize(stride*channels);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
void reset() {
|
|
95
|
-
inputBuffer.assign(inputBuffer.size(), 0);
|
|
96
|
-
buffer.assign(buffer.size(), 0);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/// @brief Round-trip latency (or equivalently: upsample latency at the higher rate).
|
|
100
|
-
/// This will be twice the value passed into the constructor or `.resize()`.
|
|
101
|
-
int latency() const {
|
|
102
|
-
return kernelLength;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/// Upsamples from a multi-channel input into the internal buffer
|
|
106
|
-
template<class Data>
|
|
107
|
-
void up(Data &&data, int lowSamples) {
|
|
108
|
-
for (int c = 0; c < channels; ++c) {
|
|
109
|
-
upChannel(c, data[c], lowSamples);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/// Upsamples a single-channel input into the internal buffer
|
|
114
|
-
template<class Data>
|
|
115
|
-
void upChannel(int c, Data &&data, int lowSamples) {
|
|
116
|
-
Sample *inputChannel = inputBuffer.data() + c*inputStride;
|
|
117
|
-
for (int i = 0; i < lowSamples; ++i) {
|
|
118
|
-
inputChannel[kernelLength + i] = data[i];
|
|
119
|
-
}
|
|
120
|
-
Sample *output = (*this)[c];
|
|
121
|
-
for (int i = 0; i < lowSamples; ++i) {
|
|
122
|
-
output[2*i] = inputChannel[i + oneWayLatency];
|
|
123
|
-
Sample *offsetInput = inputChannel + (i + 1);
|
|
124
|
-
Sample sum = 0;
|
|
125
|
-
for (int o = 0; o < kernelLength; ++o) {
|
|
126
|
-
sum += offsetInput[o]*halfSampleKernel[o];
|
|
127
|
-
}
|
|
128
|
-
output[2*i + 1] = sum;
|
|
129
|
-
}
|
|
130
|
-
// Copy the end of the buffer back to the beginning
|
|
131
|
-
for (int i = 0; i < kernelLength; ++i) {
|
|
132
|
-
inputChannel[i] = inputChannel[lowSamples + i];
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/// Downsamples from the internal buffer to a multi-channel output
|
|
137
|
-
template<class Data>
|
|
138
|
-
void down(Data &&data, int lowSamples) {
|
|
139
|
-
for (int c = 0; c < channels; ++c) {
|
|
140
|
-
downChannel(c, data[c], lowSamples);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/// Downsamples a single channel from the internal buffer to a single-channel output
|
|
145
|
-
template<class Data>
|
|
146
|
-
void downChannel(int c, Data &&data, int lowSamples) {
|
|
147
|
-
Sample *input = buffer.data() + c*stride; // no offset for latency
|
|
148
|
-
for (int i = 0; i < lowSamples; ++i) {
|
|
149
|
-
Sample v1 = input[2*i + kernelLength];
|
|
150
|
-
Sample sum = 0;
|
|
151
|
-
for (int o = 0; o < kernelLength; ++o) {
|
|
152
|
-
Sample v2 = input[2*(i + o) + 1];
|
|
153
|
-
sum += v2*halfSampleKernel[o];
|
|
154
|
-
}
|
|
155
|
-
Sample v2 = sum;
|
|
156
|
-
Sample v = (v1 + v2)*Sample(0.5);
|
|
157
|
-
data[i] = v;
|
|
158
|
-
}
|
|
159
|
-
// Copy the end of the buffer back to the beginning
|
|
160
|
-
for (int i = 0; i < kernelLength*2; ++i) {
|
|
161
|
-
input[i] = input[lowSamples*2 + i];
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/// Gets the samples for a single (higher-rate) channel. The valid length depends how many input samples were passed into `.up()`/`.upChannel()`.
|
|
166
|
-
Sample * operator[](int c) {
|
|
167
|
-
return buffer.data() + kernelLength*2 + stride*c;
|
|
168
|
-
}
|
|
169
|
-
const Sample * operator[](int c) const {
|
|
170
|
-
return buffer.data() + kernelLength*2 + stride*c;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
private:
|
|
174
|
-
int oneWayLatency, kernelLength;
|
|
175
|
-
int channels;
|
|
176
|
-
int stride, inputStride;
|
|
177
|
-
std::vector<Sample> inputBuffer;
|
|
178
|
-
std::vector<Sample> halfSampleKernel;
|
|
179
|
-
std::vector<Sample> buffer;
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
/** @} */
|
|
183
|
-
}} // namespace
|
|
184
|
-
#endif // include guard
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|