react-native-audio-api 0.13.1 → 0.13.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 +53 -16
- package/android/src/main/cpp/audioapi/CMakeLists.txt +15 -0
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferBaseSourceNodeHostObject.cpp +1 -1
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.cpp +1 -1
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.h +1 -1
- package/common/cpp/audioapi/core/sources/AudioFileSourceNode.h +1 -1
- package/common/cpp/audioapi/core/utils/decoding/SeekDecoderDaemon.h +1 -1
- package/common/cpp/audioapi/dsp/VectorMath.cpp +81 -1
- package/common/cpp/audioapi/dsp/VectorMath.h +9 -0
- package/common/cpp/audioapi/{core/utils → dsp}/WsolaTimeStretcher.cpp +23 -16
- package/common/cpp/audioapi/{core/utils → dsp}/WsolaTimeStretcher.h +6 -4
- package/ios/audioapi/ios/system/AudioEngine.mm +10 -0
- package/lib/commonjs/core/AudioParam.js +1 -0
- package/lib/commonjs/core/AudioParam.js.map +1 -1
- package/lib/module/core/AudioParam.js +1 -0
- package/lib/module/core/AudioParam.js.map +1 -1
- package/lib/typescript/core/AudioParam.d.ts.map +1 -1
- package/package.json +1 -1
- package/scripts/download-prebuilt-binaries.sh +94 -6
- package/src/core/AudioParam.ts +1 -0
package/RNAudioAPI.podspec
CHANGED
|
@@ -18,7 +18,7 @@ worklets_preprocessor_flag = worklets_enabled ? '-DRN_AUDIO_API_ENABLE_WORKLETS=
|
|
|
18
18
|
ffmpeg_flag = $RN_AUDIO_API_FFMPEG_DISABLED ? '-DRN_AUDIO_API_FFMPEG_DISABLED=1' : ''
|
|
19
19
|
static_external_libs_flag = $RN_AUDIO_API_STATIC_EXTERNAL_LIBS_DISABLED ? '-DRN_AUDIO_API_STATIC_EXTERNAL_LIBS_DISABLED=1 -DMA_NO_LIBOPUS=1 -DMA_NO_LIBVORBIS=1' : ''
|
|
20
20
|
skip_ffmpeg_argument = $RN_AUDIO_API_FFMPEG_DISABLED ? 'skipffmpeg' : ''
|
|
21
|
-
|
|
21
|
+
download_script_env_prefix = $RN_AUDIO_API_STATIC_EXTERNAL_LIBS_DISABLED ? 'DISABLE_AUDIOAPI_STATIC_EXTERNAL_LIBS=1 ' : ''
|
|
22
22
|
|
|
23
23
|
Pod::Spec.new do |s|
|
|
24
24
|
s.name = "RNAudioAPI"
|
|
@@ -67,18 +67,60 @@ Pod::Spec.new do |s|
|
|
|
67
67
|
|
|
68
68
|
s.prepare_command = <<-CMD
|
|
69
69
|
chmod +x scripts/download-prebuilt-binaries.sh
|
|
70
|
-
#{
|
|
70
|
+
#{download_script_env_prefix}scripts/download-prebuilt-binaries.sh ios #{skip_ffmpeg_argument}
|
|
71
71
|
CMD
|
|
72
72
|
|
|
73
73
|
external_dir_relative = "common/cpp/audioapi/external"
|
|
74
74
|
lib_dir = "$(PODS_ROOT)/#{$audio_api_config[:dynamic_frameworks_audio_api_dir]}/#{external_dir_relative}/$(PLATFORM_NAME)"
|
|
75
|
+
ffmpeg_dir = "$(PODS_ROOT)/#{$audio_api_config[:dynamic_frameworks_audio_api_dir]}/#{external_dir_relative}/ffmpeg_ios"
|
|
76
|
+
|
|
77
|
+
ffmpeg_framework_names = %w[libavcodec libavformat libavutil libswresample]
|
|
78
|
+
static_external_libs_names = %w[libopusfile libopus libogg libvorbis libvorbisenc libvorbisfile]
|
|
79
|
+
|
|
80
|
+
# `prepare_command` hydrates binaries on a fresh `pod install` so CocoaPods can
|
|
81
|
+
# register all vendored `.xcframework`s in `[CP] Copy XCFrameworks`. When `Pods/`
|
|
82
|
+
# is restored from cache while `node_modules/` is reinstalled, `prepare_command`
|
|
83
|
+
# does not re-run — the build-time phase below re-hydrates on every build.
|
|
84
|
+
#
|
|
85
|
+
# It must run at `:before_headers` so it lands ahead of CocoaPods' own
|
|
86
|
+
# `[CP] Copy XCFrameworks` phase, which consumes the FFmpeg xcframeworks. If it
|
|
87
|
+
# ran later (e.g. `:before_compile`, which is after Copy XCFrameworks), Xcode
|
|
88
|
+
# would reject the build when the xcframeworks are missing before we download.
|
|
89
|
+
#
|
|
90
|
+
# `output_files` declares everything the linker (`-force_load` static libs in
|
|
91
|
+
# `s.xcconfig`) and Copy XCFrameworks (FFmpeg) consume, so Xcode's build graph
|
|
92
|
+
# knows this phase produces them.
|
|
93
|
+
unless $RN_AUDIO_API_STATIC_EXTERNAL_LIBS_DISABLED && $RN_AUDIO_API_FFMPEG_DISABLED
|
|
94
|
+
download_output_files = []
|
|
95
|
+
|
|
96
|
+
unless $RN_AUDIO_API_STATIC_EXTERNAL_LIBS_DISABLED
|
|
97
|
+
static_external_libs_names.each do |lib|
|
|
98
|
+
download_output_files << "#{lib_dir}/#{lib}.a"
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
unless $RN_AUDIO_API_FFMPEG_DISABLED
|
|
103
|
+
ffmpeg_framework_names.each do |framework|
|
|
104
|
+
download_output_files << "#{ffmpeg_dir}/#{framework}.xcframework"
|
|
105
|
+
end
|
|
106
|
+
end
|
|
75
107
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
108
|
+
s.script_phase = {
|
|
109
|
+
:name => 'Download RNAudioAPI prebuilt binaries',
|
|
110
|
+
:execution_position => :before_headers,
|
|
111
|
+
:always_out_of_date => '1',
|
|
112
|
+
:output_files => download_output_files,
|
|
113
|
+
:script => <<-SCRIPT
|
|
114
|
+
cd "$PODS_TARGET_SRCROOT"
|
|
115
|
+
chmod +x scripts/download-prebuilt-binaries.sh
|
|
116
|
+
#{download_script_env_prefix}scripts/download-prebuilt-binaries.sh ios #{skip_ffmpeg_argument}
|
|
117
|
+
SCRIPT
|
|
118
|
+
}
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
s.ios.vendored_frameworks = $RN_AUDIO_API_FFMPEG_DISABLED ? [] : ffmpeg_framework_names.map { |framework|
|
|
122
|
+
"common/cpp/audioapi/external/ffmpeg_ios/#{framework}.xcframework"
|
|
123
|
+
}
|
|
82
124
|
|
|
83
125
|
s.pod_target_xcconfig = {
|
|
84
126
|
"USE_HEADERMAP" => "YES",
|
|
@@ -133,14 +175,9 @@ Pod::Spec.new do |s|
|
|
|
133
175
|
'OTHER_LDFLAGS' => %W[
|
|
134
176
|
$(inherited)
|
|
135
177
|
]
|
|
136
|
-
.concat($RN_AUDIO_API_STATIC_EXTERNAL_LIBS_DISABLED ? [] :
|
|
137
|
-
-force_load #{lib_dir}
|
|
138
|
-
|
|
139
|
-
-force_load #{lib_dir}/libogg.a
|
|
140
|
-
-force_load #{lib_dir}/libvorbis.a
|
|
141
|
-
-force_load #{lib_dir}/libvorbisenc.a
|
|
142
|
-
-force_load #{lib_dir}/libvorbisfile.a
|
|
143
|
-
])
|
|
178
|
+
.concat($RN_AUDIO_API_STATIC_EXTERNAL_LIBS_DISABLED ? [] : static_external_libs_names.flat_map { |lib|
|
|
179
|
+
['-force_load', "#{lib_dir}/#{lib}.a"]
|
|
180
|
+
})
|
|
144
181
|
.join(" "),
|
|
145
182
|
}
|
|
146
183
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
@@ -165,6 +165,21 @@ if (RN_AUDIO_API_FFMPEG_DISABLED)
|
|
|
165
165
|
)
|
|
166
166
|
endif()
|
|
167
167
|
|
|
168
|
+
target_compile_definitions(
|
|
169
|
+
react-native-audio-api
|
|
170
|
+
PRIVATE $<$<CONFIG:Debug>:DEBUG>
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
# Forward the SIMD capability detected in the top-level android/CMakeLists.txt so
|
|
174
|
+
# the dsp/ vector math (VectorMath, WsolaTimeStretcher) compiles its NEON/SSE2
|
|
175
|
+
# intrinsic paths instead of the scalar fallback. arm64-v8a always has NEON and
|
|
176
|
+
# x86_64 always has SSE2, so these are safe baselines for their ABIs.
|
|
177
|
+
if(HAVE_ARM_NEON_INTRINSICS)
|
|
178
|
+
target_compile_definitions(react-native-audio-api PRIVATE HAVE_ARM_NEON_INTRINSICS=1)
|
|
179
|
+
elseif(HAVE_X86_SSE2)
|
|
180
|
+
target_compile_definitions(react-native-audio-api PRIVATE HAVE_X86_SSE2=1)
|
|
181
|
+
endif()
|
|
182
|
+
|
|
168
183
|
if (RN_AUDIO_API_STATIC_EXTERNAL_LIBS_DISABLED)
|
|
169
184
|
target_compile_definitions(
|
|
170
185
|
react-native-audio-api
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#include <audioapi/HostObjects/sources/AudioBufferBaseSourceNodeHostObject.h>
|
|
3
3
|
#include <audioapi/core/sources/AudioBufferBaseSourceNode.h>
|
|
4
4
|
#include <audioapi/core/utils/Constants.h>
|
|
5
|
-
#include <audioapi/
|
|
5
|
+
#include <audioapi/dsp/WsolaTimeStretcher.h>
|
|
6
6
|
#include <audioapi/types/NodeOptions.h>
|
|
7
7
|
|
|
8
8
|
#include <algorithm>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <audioapi/core/sources/AudioScheduledSourceNode.h>
|
|
4
|
-
#include <audioapi/
|
|
4
|
+
#include <audioapi/dsp/WsolaTimeStretcher.h>
|
|
5
5
|
#include <audioapi/utils/AudioBuffer.hpp>
|
|
6
6
|
#include <audioapi/utils/events/PositionChangedDispatcher.h>
|
|
7
7
|
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
#include <audioapi/core/AudioNode.h>
|
|
4
4
|
#include <audioapi/core/sources/AudioScheduledSourceNode.h>
|
|
5
|
-
#include <audioapi/core/utils/WsolaTimeStretcher.h>
|
|
6
5
|
#include <audioapi/core/utils/decoding/SeekDecoderDaemon.h>
|
|
6
|
+
#include <audioapi/dsp/WsolaTimeStretcher.h>
|
|
7
7
|
#include <audioapi/libs/decoding/IncrementalAudioDecoder.h>
|
|
8
8
|
#include <audioapi/types/NodeOptions.h>
|
|
9
9
|
#include <audioapi/utils/events/PositionChangedDispatcher.h>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
3
|
#include <audioapi/core/utils/Constants.h>
|
|
4
|
-
#include <audioapi/
|
|
4
|
+
#include <audioapi/dsp/WsolaTimeStretcher.h>
|
|
5
5
|
#include <audioapi/libs/decoding/IncrementalAudioDecoder.h>
|
|
6
6
|
#if !RN_AUDIO_API_FFMPEG_DISABLED
|
|
7
7
|
#include <audioapi/libs/ffmpeg/FFmpegDecoding.h>
|
|
@@ -89,6 +89,21 @@ float maximumMagnitude(const float *inputVector, size_t numberOfElementsToProces
|
|
|
89
89
|
return maximumValue;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
float dotProduct(
|
|
93
|
+
const float *inputVector1,
|
|
94
|
+
const float *inputVector2,
|
|
95
|
+
size_t numberOfElementsToProcess) {
|
|
96
|
+
float result = 0;
|
|
97
|
+
vDSP_dotpr(inputVector1, 1, inputVector2, 1, &result, numberOfElementsToProcess);
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
float sumOfSquares(const float *inputVector, size_t numberOfElementsToProcess) {
|
|
102
|
+
float result = 0;
|
|
103
|
+
vDSP_svesq(inputVector, 1, &result, numberOfElementsToProcess);
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
|
|
92
107
|
void multiplyByScalarThenAddToOutput(
|
|
93
108
|
const float *inputVector,
|
|
94
109
|
float scalar,
|
|
@@ -578,7 +593,7 @@ float maximumMagnitude(const float *inputVector, size_t numberOfElementsToProces
|
|
|
578
593
|
max = std::max(max, groupMaxP[3]);
|
|
579
594
|
|
|
580
595
|
n = tailFrames;
|
|
581
|
-
#elif defined(
|
|
596
|
+
#elif defined(HAVE_ARM_NEON_INTRINSICS)
|
|
582
597
|
size_t tailFrames = n % 4;
|
|
583
598
|
const float *endP = inputVector + n - tailFrames;
|
|
584
599
|
|
|
@@ -780,6 +795,71 @@ void interleaveStereo(
|
|
|
780
795
|
}
|
|
781
796
|
}
|
|
782
797
|
|
|
798
|
+
float dotProduct(
|
|
799
|
+
const float *inputVector1,
|
|
800
|
+
const float *inputVector2,
|
|
801
|
+
size_t numberOfElementsToProcess) {
|
|
802
|
+
size_t n = numberOfElementsToProcess;
|
|
803
|
+
size_t i = 0;
|
|
804
|
+
float sum = 0.0f;
|
|
805
|
+
|
|
806
|
+
#ifdef HAVE_X86_SSE2
|
|
807
|
+
__m128 acc = _mm_setzero_ps();
|
|
808
|
+
for (; i + 4 <= n; i += 4) {
|
|
809
|
+
__m128 v1 = _mm_loadu_ps(inputVector1 + i);
|
|
810
|
+
__m128 v2 = _mm_loadu_ps(inputVector2 + i);
|
|
811
|
+
acc = _mm_add_ps(acc, _mm_mul_ps(v1, v2));
|
|
812
|
+
}
|
|
813
|
+
float lanes[4];
|
|
814
|
+
_mm_storeu_ps(lanes, acc);
|
|
815
|
+
sum = lanes[0] + lanes[1] + lanes[2] + lanes[3];
|
|
816
|
+
#elif defined(HAVE_ARM_NEON_INTRINSICS)
|
|
817
|
+
float32x4_t acc = vdupq_n_f32(0.0f);
|
|
818
|
+
for (; i + 4 <= n; i += 4) {
|
|
819
|
+
float32x4_t v1 = vld1q_f32(inputVector1 + i);
|
|
820
|
+
float32x4_t v2 = vld1q_f32(inputVector2 + i);
|
|
821
|
+
acc = vmlaq_f32(acc, v1, v2);
|
|
822
|
+
}
|
|
823
|
+
float32x2_t pair = vadd_f32(vget_low_f32(acc), vget_high_f32(acc));
|
|
824
|
+
sum = vget_lane_f32(vpadd_f32(pair, pair), 0);
|
|
825
|
+
#endif
|
|
826
|
+
|
|
827
|
+
for (; i < n; ++i) {
|
|
828
|
+
sum += inputVector1[i] * inputVector2[i];
|
|
829
|
+
}
|
|
830
|
+
return sum;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
float sumOfSquares(const float *inputVector, size_t numberOfElementsToProcess) {
|
|
834
|
+
size_t n = numberOfElementsToProcess;
|
|
835
|
+
size_t i = 0;
|
|
836
|
+
float sum = 0.0f;
|
|
837
|
+
|
|
838
|
+
#ifdef HAVE_X86_SSE2
|
|
839
|
+
__m128 acc = _mm_setzero_ps();
|
|
840
|
+
for (; i + 4 <= n; i += 4) {
|
|
841
|
+
__m128 v = _mm_loadu_ps(inputVector + i);
|
|
842
|
+
acc = _mm_add_ps(acc, _mm_mul_ps(v, v));
|
|
843
|
+
}
|
|
844
|
+
float lanes[4];
|
|
845
|
+
_mm_storeu_ps(lanes, acc);
|
|
846
|
+
sum = lanes[0] + lanes[1] + lanes[2] + lanes[3];
|
|
847
|
+
#elif defined(HAVE_ARM_NEON_INTRINSICS)
|
|
848
|
+
float32x4_t acc = vdupq_n_f32(0.0f);
|
|
849
|
+
for (; i + 4 <= n; i += 4) {
|
|
850
|
+
float32x4_t v = vld1q_f32(inputVector + i);
|
|
851
|
+
acc = vmlaq_f32(acc, v, v);
|
|
852
|
+
}
|
|
853
|
+
float32x2_t pair = vadd_f32(vget_low_f32(acc), vget_high_f32(acc));
|
|
854
|
+
sum = vget_lane_f32(vpadd_f32(pair, pair), 0);
|
|
855
|
+
#endif
|
|
856
|
+
|
|
857
|
+
for (; i < n; ++i) {
|
|
858
|
+
sum += inputVector[i] * inputVector[i];
|
|
859
|
+
}
|
|
860
|
+
return sum;
|
|
861
|
+
}
|
|
862
|
+
|
|
783
863
|
#endif
|
|
784
864
|
|
|
785
865
|
} // namespace audioapi::dsp
|
|
@@ -67,6 +67,15 @@ void multiply(
|
|
|
67
67
|
// Finds the maximum magnitude of a float vector.
|
|
68
68
|
float maximumMagnitude(const float *inputVector, size_t numberOfElementsToProcess);
|
|
69
69
|
|
|
70
|
+
// Returns the dot product of two float vectors (sum of element-wise products).
|
|
71
|
+
float dotProduct(
|
|
72
|
+
const float *inputVector1,
|
|
73
|
+
const float *inputVector2,
|
|
74
|
+
size_t numberOfElementsToProcess);
|
|
75
|
+
|
|
76
|
+
// Returns the sum of squares of a float vector
|
|
77
|
+
float sumOfSquares(const float *inputVector, size_t numberOfElementsToProcess);
|
|
78
|
+
|
|
70
79
|
void interleaveStereo(
|
|
71
80
|
const float *inputLeft,
|
|
72
81
|
const float *inputRight,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#include <audioapi/core/utils/Constants.h>
|
|
2
|
-
#include <audioapi/
|
|
2
|
+
#include <audioapi/dsp/VectorMath.h>
|
|
3
|
+
#include <audioapi/dsp/WsolaTimeStretcher.h>
|
|
3
4
|
|
|
4
5
|
#include <algorithm>
|
|
5
6
|
#include <cmath>
|
|
@@ -56,6 +57,9 @@ void WsolaTimeStretcher::configure(size_t channels, float sampleRate) {
|
|
|
56
57
|
targetBlock_.assign(channels_, std::vector<float>(windowSize_, 0.0f));
|
|
57
58
|
optimalBlock_.assign(channels_, std::vector<float>(windowSize_, 0.0f));
|
|
58
59
|
targetEnergy_.assign(channels_, 0.0f);
|
|
60
|
+
// Search span covers every candidate offset [0, searchIntervalFrames_) plus a
|
|
61
|
+
// full trailing window, so any candidate slice stays in bounds.
|
|
62
|
+
searchSpan_.assign(channels_, std::vector<float>(searchIntervalFrames_ + windowSize_, 0.0f));
|
|
59
63
|
|
|
60
64
|
reset();
|
|
61
65
|
}
|
|
@@ -266,9 +270,20 @@ bool WsolaTimeStretcher::targetIsWithinSearchRegion() const {
|
|
|
266
270
|
targetBlockIndex_ + static_cast<int>(windowSize_) <= searchBlockIndex_ + searchBlockSize;
|
|
267
271
|
}
|
|
268
272
|
|
|
273
|
+
void WsolaTimeStretcher::fillSearchSpan() {
|
|
274
|
+
const size_t spanLength = searchIntervalFrames_ + windowSize_;
|
|
275
|
+
for (size_t channel = 0; channel < channels_; ++channel) {
|
|
276
|
+
auto &span = searchSpan_[channel];
|
|
277
|
+
for (size_t j = 0; j < spanLength; ++j) {
|
|
278
|
+
span[j] = sampleAt(channel, searchBlockIndex_ + static_cast<int>(j));
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
269
283
|
int WsolaTimeStretcher::findOptimalBlockIndex() {
|
|
270
284
|
fillBlock(targetBlock_, targetBlockIndex_);
|
|
271
285
|
computeTargetEnergy();
|
|
286
|
+
fillSearchSpan();
|
|
272
287
|
|
|
273
288
|
const int candidateCount = static_cast<int>(searchIntervalFrames_);
|
|
274
289
|
if (candidateCount <= 1) {
|
|
@@ -322,18 +337,15 @@ int WsolaTimeStretcher::findOptimalBlockIndex() {
|
|
|
322
337
|
|
|
323
338
|
float WsolaTimeStretcher::similarityAt(int candidateIndex) const {
|
|
324
339
|
static constexpr float EPSILON = 1e-12f;
|
|
340
|
+
const int offset = candidateIndex - searchBlockIndex_;
|
|
325
341
|
float score = 0.0f;
|
|
326
342
|
|
|
327
343
|
for (size_t channel = 0; channel < channels_; ++channel) {
|
|
328
|
-
float
|
|
329
|
-
float
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
const float candidate = sampleAt(channel, candidateIndex + static_cast<int>(frame));
|
|
334
|
-
dot += target * candidate;
|
|
335
|
-
candidateEnergy += candidate * candidate;
|
|
336
|
-
}
|
|
344
|
+
const float *target = targetBlock_[channel].data();
|
|
345
|
+
const float *candidate = searchSpan_[channel].data() + offset;
|
|
346
|
+
|
|
347
|
+
const float dot = dsp::dotProduct(target, candidate, windowSize_);
|
|
348
|
+
const float candidateEnergy = dsp::sumOfSquares(candidate, windowSize_);
|
|
337
349
|
|
|
338
350
|
score += dot / std::sqrt(targetEnergy_[channel] * candidateEnergy + EPSILON);
|
|
339
351
|
}
|
|
@@ -387,12 +399,7 @@ void WsolaTimeStretcher::fillBlock(std::vector<std::vector<float>> &block, int f
|
|
|
387
399
|
|
|
388
400
|
void WsolaTimeStretcher::computeTargetEnergy() {
|
|
389
401
|
for (size_t channel = 0; channel < channels_; ++channel) {
|
|
390
|
-
|
|
391
|
-
for (size_t frame = 0; frame < windowSize_; frame += SIMILARITY_FRAME_STRIDE) {
|
|
392
|
-
const float value = targetBlock_[channel][frame];
|
|
393
|
-
energy += value * value;
|
|
394
|
-
}
|
|
395
|
-
targetEnergy_[channel] = energy;
|
|
402
|
+
targetEnergy_[channel] = dsp::sumOfSquares(targetBlock_[channel].data(), windowSize_);
|
|
396
403
|
}
|
|
397
404
|
}
|
|
398
405
|
|
|
@@ -48,11 +48,7 @@ class WsolaTimeStretcher {
|
|
|
48
48
|
private:
|
|
49
49
|
static constexpr float OLA_WINDOW_MS = 20.0f;
|
|
50
50
|
static constexpr float SEARCH_INTERVAL_MS = 30.0f;
|
|
51
|
-
// Chromium uses a denser decimated search, but pairs it with SIMD dot products
|
|
52
|
-
// and precomputed moving energies. This lighter search keeps iOS route changes
|
|
53
|
-
// from overloading the real-time audio callback in the current implementation.
|
|
54
51
|
static constexpr size_t SEARCH_DECIMATION = 12;
|
|
55
|
-
static constexpr size_t SIMILARITY_FRAME_STRIDE = 4;
|
|
56
52
|
static constexpr size_t QUEUE_COMPACT_THRESHOLD_FRAMES = 4096;
|
|
57
53
|
|
|
58
54
|
size_t channels_{0};
|
|
@@ -82,6 +78,11 @@ class WsolaTimeStretcher {
|
|
|
82
78
|
std::vector<std::vector<float>> targetBlock_;
|
|
83
79
|
std::vector<std::vector<float>> optimalBlock_;
|
|
84
80
|
std::vector<float> targetEnergy_;
|
|
81
|
+
// Contiguous, pitch-resampled copy of the current search region per channel.
|
|
82
|
+
// Materialized once per findOptimalBlockIndex() so every candidate window is a
|
|
83
|
+
// contiguous slice, enabling SIMD cross-correlation instead of per-sample
|
|
84
|
+
// interpolation inside the search loop.
|
|
85
|
+
std::vector<std::vector<float>> searchSpan_;
|
|
85
86
|
|
|
86
87
|
void appendInput(const DSPAudioBuffer &input, size_t inputFrames);
|
|
87
88
|
size_t availableOutputFrames() const;
|
|
@@ -91,6 +92,7 @@ class WsolaTimeStretcher {
|
|
|
91
92
|
bool canRunIteration() const;
|
|
92
93
|
bool targetIsWithinSearchRegion() const;
|
|
93
94
|
int findOptimalBlockIndex();
|
|
95
|
+
void fillSearchSpan();
|
|
94
96
|
float similarityAt(int candidateIndex) const;
|
|
95
97
|
[[nodiscard]] int maxSourceIndexForBlock(int blockStartFrame) const;
|
|
96
98
|
float sampleAt(size_t channel, int frameIndex) const;
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
@interface AudioEngine () {
|
|
27
27
|
std::mutex _engineLock;
|
|
28
|
+
BOOL _isRebuildingAudioEngine;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
@property (nonatomic, strong)
|
|
@@ -408,15 +409,24 @@ static AudioEngine *_sharedInstance = nil;
|
|
|
408
409
|
|
|
409
410
|
- (void)rebuildAudioEngineAndResumeIfNeeded
|
|
410
411
|
{
|
|
412
|
+
if (_isRebuildingAudioEngine) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
_isRebuildingAudioEngine = YES;
|
|
417
|
+
|
|
411
418
|
if ([self.audioEngine isRunning]) {
|
|
412
419
|
[self.audioEngine stop];
|
|
413
420
|
}
|
|
414
421
|
|
|
415
422
|
[self rebuildAudioEngine];
|
|
423
|
+
self.sessionDeactivationInvalidatedGraph = false;
|
|
416
424
|
|
|
417
425
|
if (self.state == AudioEngineState::AudioEngineStateRunning) {
|
|
418
426
|
[self startEngine];
|
|
419
427
|
}
|
|
428
|
+
|
|
429
|
+
_isRebuildingAudioEngine = NO;
|
|
420
430
|
}
|
|
421
431
|
|
|
422
432
|
- (void)rebuildAudioEngine
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_types","require","_errors","AudioParam","constructor","audioParam","context","value","defaultValue","minValue","maxValue","setValueAtTime","startTime","RangeError","checkCurveExclusion","type","AutomationEventType","SET_VALUE","automationTime","clampedTime","Math","max","
|
|
1
|
+
{"version":3,"names":["_types","require","_errors","AudioParam","constructor","audioParam","context","value","defaultValue","minValue","maxValue","setValueAtTime","currentTime","startTime","RangeError","checkCurveExclusion","type","AutomationEventType","SET_VALUE","automationTime","clampedTime","Math","max","linearRampToValueAtTime","endTime","LINEAR_RAMP","exponentialRampToValueAtTime","EXPONENTIAL_RAMP","setTargetAtTime","target","timeConstant","SET_TARGET","setValueCurveAtTime","values","duration","length","InvalidStateError","SET_VALUE_CURVE","cancelScheduledValues","cancelTime","cancelAndHoldAtTime","eventData","checkExclusionResult","status","NotSupportedError","message","exports","default"],"sourceRoot":"../../../src","sources":["core/AudioParam.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAIe,MAAME,UAAU,CAAC;EAK9BC,WAAWA,CACOC,UAAuB,EACvBC,OAAyB,EACzC;IAAA,KAFgBD,UAAuB,GAAvBA,UAAuB;IAAA,KACvBC,OAAyB,GAAzBA,OAAyB;IAEzC,IAAI,CAACC,KAAK,GAAGF,UAAU,CAACE,KAAK;IAC7B,IAAI,CAACC,YAAY,GAAGH,UAAU,CAACG,YAAY;IAC3C,IAAI,CAACC,QAAQ,GAAGJ,UAAU,CAACI,QAAQ;IACnC,IAAI,CAACC,QAAQ,GAAGL,UAAU,CAACK,QAAQ;EACrC;EAEA,IAAWH,KAAKA,CAAA,EAAW;IACzB,OAAO,IAAI,CAACF,UAAU,CAACE,KAAK;EAC9B;EAEA,IAAWA,KAAKA,CAACA,KAAa,EAAE;IAC9B,IAAI,CAACF,UAAU,CAACE,KAAK,GAAGA,KAAK;IAC7B,IAAI,CAACI,cAAc,CAACJ,KAAK,EAAE,IAAI,CAACD,OAAO,CAACM,WAAW,CAAC;EACtD;EAEOD,cAAcA,CAACJ,KAAa,EAAEM,SAAiB,EAAc;IAClE,IAAIA,SAAS,GAAG,CAAC,EAAE;MACjB,MAAM,IAAIC,kBAAU,CAClB,mDAAmDD,SAAS,EAC9D,CAAC;IACH;IAEA,IAAI,CAACE,mBAAmB,CAAC;MACvBC,IAAI,EAAEC,0BAAmB,CAACC,SAAS;MACnCC,cAAc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,CAAC7B,UAAU,CAAC2B,mBAAmB,CAACC,MAAM,EAAEb,WAAW,EAAEc,QAAQ,CAAC;IAElE,OAAO,IAAI;EACb;EAEOI,qBAAqBA,CAACC,UAAkB,EAAc;IAC3D,IAAIA,UAAU,GAAG,CAAC,EAAE;MAClB,MAAM,IAAIzB,kBAAU,CAClB,oDAAoDyB,UAAU,EAChE,CAAC;IACH;IAEA,MAAMnB,WAAW,GAAGC,IAAI,CAACC,GAAG,CAACiB,UAAU,EAAE,IAAI,CAACjC,OAAO,CAACM,WAAW,CAAC;IAClE,IAAI,CAACP,UAAU,CAACiC,qBAAqB,CAAClB,WAAW,CAAC;IAElD,OAAO,IAAI;EACb;EAEOoB,mBAAmBA,CAACD,UAAkB,EAAc;IACzD,IAAIA,UAAU,GAAG,CAAC,EAAE;MAClB,MAAM,IAAIzB,kBAAU,CAClB,oDAAoDyB,UAAU,EAChE,CAAC;IACH;IAEA,MAAMnB,WAAW,GAAGC,IAAI,CAACC,GAAG,CAACiB,UAAU,EAAE,IAAI,CAACjC,OAAO,CAACM,WAAW,CAAC;IAClE,IAAI,CAACP,UAAU,CAACmC,mBAAmB,CAACpB,WAAW,CAAC;IAEhD,OAAO,IAAI;EACb;EAEQL,mBAAmBA,CAAC0B,SAA8B,EAAQ;IAChE,MAAMC,oBAAoB,GAAG,IAAI,CAACrC,UAAU,CAACU,mBAAmB,CAAC0B,SAAS,CAAC;IAE3E,IAAIC,oBAAoB,CAACC,MAAM,KAAK,OAAO,EAAE;MAC3C,MAAM,IAAIC,yBAAiB,CAACF,oBAAoB,CAACG,OAAO,CAAC;IAC3D;EACF;AACF;AAACC,OAAA,CAAAC,OAAA,GAAA5C,UAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AutomationEventType","InvalidStateError","NotSupportedError","RangeError","AudioParam","constructor","audioParam","context","value","defaultValue","minValue","maxValue","setValueAtTime","startTime","checkCurveExclusion","type","SET_VALUE","automationTime","clampedTime","Math","max","
|
|
1
|
+
{"version":3,"names":["AutomationEventType","InvalidStateError","NotSupportedError","RangeError","AudioParam","constructor","audioParam","context","value","defaultValue","minValue","maxValue","setValueAtTime","currentTime","startTime","checkCurveExclusion","type","SET_VALUE","automationTime","clampedTime","Math","max","linearRampToValueAtTime","endTime","LINEAR_RAMP","exponentialRampToValueAtTime","EXPONENTIAL_RAMP","setTargetAtTime","target","timeConstant","SET_TARGET","setValueCurveAtTime","values","duration","length","SET_VALUE_CURVE","cancelScheduledValues","cancelTime","cancelAndHoldAtTime","eventData","checkExclusionResult","status","message"],"sourceRoot":"../../../src","sources":["core/AudioParam.ts"],"mappings":";;AAAA,SAA8BA,mBAAmB,QAAQ,aAAU;AACnE,SAASC,iBAAiB,EAAEC,iBAAiB,EAAEC,UAAU,QAAQ,oBAAW;AAI5E,eAAe,MAAMC,UAAU,CAAC;EAK9BC,WAAWA,CACOC,UAAuB,EACvBC,OAAyB,EACzC;IAAA,KAFgBD,UAAuB,GAAvBA,UAAuB;IAAA,KACvBC,OAAyB,GAAzBA,OAAyB;IAEzC,IAAI,CAACC,KAAK,GAAGF,UAAU,CAACE,KAAK;IAC7B,IAAI,CAACC,YAAY,GAAGH,UAAU,CAACG,YAAY;IAC3C,IAAI,CAACC,QAAQ,GAAGJ,UAAU,CAACI,QAAQ;IACnC,IAAI,CAACC,QAAQ,GAAGL,UAAU,CAACK,QAAQ;EACrC;EAEA,IAAWH,KAAKA,CAAA,EAAW;IACzB,OAAO,IAAI,CAACF,UAAU,CAACE,KAAK;EAC9B;EAEA,IAAWA,KAAKA,CAACA,KAAa,EAAE;IAC9B,IAAI,CAACF,UAAU,CAACE,KAAK,GAAGA,KAAK;IAC7B,IAAI,CAACI,cAAc,CAACJ,KAAK,EAAE,IAAI,CAACD,OAAO,CAACM,WAAW,CAAC;EACtD;EAEOD,cAAcA,CAACJ,KAAa,EAAEM,SAAiB,EAAc;IAClE,IAAIA,SAAS,GAAG,CAAC,EAAE;MACjB,MAAM,IA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pB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,GACnB,UAAU;IAwBN,mBAAmB,CACxB,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,UAAU;IA6BN,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU;IAarD,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU;IAa1D,OAAO,CAAC,mBAAmB;CAO5B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-audio-api",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.3",
|
|
4
4
|
"description": "react-native-audio-api provides system for controlling audio in React Native environment compatible with Web Audio API specification",
|
|
5
5
|
"bin": {
|
|
6
6
|
"setup-rn-audio-api-web": "./scripts/setup-rn-audio-api-web.js"
|
|
@@ -3,23 +3,59 @@
|
|
|
3
3
|
|
|
4
4
|
MAIN_DOWNLOAD_URL="https://github.com/software-mansion-labs/rn-audio-libs/releases/download"
|
|
5
5
|
TAG="v3.1.0"
|
|
6
|
-
|
|
6
|
+
ANDROID_DOWNLOAD_NAMES=(
|
|
7
7
|
"android.zip"
|
|
8
|
+
"jniLibs.zip"
|
|
9
|
+
)
|
|
10
|
+
IOS_DOWNLOAD_NAMES=(
|
|
8
11
|
"ffmpeg_ios.zip"
|
|
9
12
|
"iphoneos.zip"
|
|
10
13
|
"iphonesimulator.zip"
|
|
11
|
-
"jniLibs.zip"
|
|
12
14
|
"macosx.zip"
|
|
13
15
|
)
|
|
16
|
+
STATIC_LIB_NAMES=(
|
|
17
|
+
"libopusfile.a"
|
|
18
|
+
"libopus.a"
|
|
19
|
+
"libogg.a"
|
|
20
|
+
"libvorbis.a"
|
|
21
|
+
"libvorbisenc.a"
|
|
22
|
+
"libvorbisfile.a"
|
|
23
|
+
)
|
|
24
|
+
FFMPEG_IOS_FRAMEWORKS=(
|
|
25
|
+
"libavcodec.xcframework"
|
|
26
|
+
"libavformat.xcframework"
|
|
27
|
+
"libavutil.xcframework"
|
|
28
|
+
"libswresample.xcframework"
|
|
29
|
+
)
|
|
30
|
+
FFMPEG_ANDROID_SO_LIBS=(
|
|
31
|
+
"libavcodec.so"
|
|
32
|
+
"libavformat.so"
|
|
33
|
+
"libavutil.so"
|
|
34
|
+
"libswresample.so"
|
|
35
|
+
)
|
|
36
|
+
ANDROID_JNI_ABIS=(
|
|
37
|
+
"armeabi-v7a"
|
|
38
|
+
"arm64-v8a"
|
|
39
|
+
"x86_64"
|
|
40
|
+
"x86"
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
PLATFORM="$1"
|
|
44
|
+
if [ "$PLATFORM" != "android" ] && [ "$PLATFORM" != "ios" ]; then
|
|
45
|
+
echo "Error: platform argument required. Usage: $0 <android|ios> [skipffmpeg]"
|
|
46
|
+
exit 1
|
|
47
|
+
fi
|
|
14
48
|
|
|
15
49
|
# Use a temporary directory for downloads, ensuring it exists
|
|
16
50
|
TEMP_DOWNLOAD_DIR="$(pwd)/audioapi-binaries-temp"
|
|
17
51
|
mkdir -p "$TEMP_DOWNLOAD_DIR"
|
|
18
52
|
|
|
19
|
-
if [ "$
|
|
53
|
+
if [ "$PLATFORM" == "android" ]; then
|
|
20
54
|
PROJECT_ROOT="$(pwd)/.."
|
|
55
|
+
DOWNLOAD_NAMES=("${ANDROID_DOWNLOAD_NAMES[@]}")
|
|
21
56
|
else
|
|
22
57
|
PROJECT_ROOT="$(pwd)"
|
|
58
|
+
DOWNLOAD_NAMES=("${IOS_DOWNLOAD_NAMES[@]}")
|
|
23
59
|
fi
|
|
24
60
|
|
|
25
61
|
if [ "$2" == "skipffmpeg" ]; then
|
|
@@ -68,6 +104,56 @@ restore_versioned_framework_symlinks() {
|
|
|
68
104
|
done
|
|
69
105
|
}
|
|
70
106
|
|
|
107
|
+
artifacts_present() {
|
|
108
|
+
local extracted_dir_name="$1"
|
|
109
|
+
local final_check_path="$2"
|
|
110
|
+
local abi
|
|
111
|
+
local lib
|
|
112
|
+
local framework
|
|
113
|
+
local so_lib
|
|
114
|
+
|
|
115
|
+
case "$extracted_dir_name" in
|
|
116
|
+
ffmpeg_ios)
|
|
117
|
+
for framework in "${FFMPEG_IOS_FRAMEWORKS[@]}"; do
|
|
118
|
+
if [ ! -d "${final_check_path}/${framework}" ]; then
|
|
119
|
+
return 1
|
|
120
|
+
fi
|
|
121
|
+
done
|
|
122
|
+
;;
|
|
123
|
+
jniLibs)
|
|
124
|
+
for abi in "${ANDROID_JNI_ABIS[@]}"; do
|
|
125
|
+
for so_lib in "${FFMPEG_ANDROID_SO_LIBS[@]}"; do
|
|
126
|
+
if [ ! -f "${final_check_path}/${abi}/${so_lib}" ]; then
|
|
127
|
+
return 1
|
|
128
|
+
fi
|
|
129
|
+
done
|
|
130
|
+
done
|
|
131
|
+
;;
|
|
132
|
+
android)
|
|
133
|
+
for abi in "${ANDROID_JNI_ABIS[@]}"; do
|
|
134
|
+
for lib in "${STATIC_LIB_NAMES[@]}"; do
|
|
135
|
+
if [ ! -f "${final_check_path}/${abi}/${lib}" ]; then
|
|
136
|
+
return 1
|
|
137
|
+
fi
|
|
138
|
+
done
|
|
139
|
+
done
|
|
140
|
+
;;
|
|
141
|
+
iphoneos|iphonesimulator|macosx)
|
|
142
|
+
for lib in "${STATIC_LIB_NAMES[@]}"; do
|
|
143
|
+
if [ ! -f "${final_check_path}/${lib}" ]; then
|
|
144
|
+
return 1
|
|
145
|
+
fi
|
|
146
|
+
done
|
|
147
|
+
;;
|
|
148
|
+
*)
|
|
149
|
+
[ -d "$final_check_path" ]
|
|
150
|
+
return
|
|
151
|
+
;;
|
|
152
|
+
esac
|
|
153
|
+
|
|
154
|
+
return 0
|
|
155
|
+
}
|
|
156
|
+
|
|
71
157
|
for name in "${DOWNLOAD_NAMES[@]}"; do
|
|
72
158
|
ARCH_URL="${MAIN_DOWNLOAD_URL}/${TAG}/${name}"
|
|
73
159
|
ZIP_FILE_PATH="${TEMP_DOWNLOAD_DIR}/${name}"
|
|
@@ -91,11 +177,11 @@ for name in "${DOWNLOAD_NAMES[@]}"; do
|
|
|
91
177
|
fi
|
|
92
178
|
FINAL_CHECK_PATH="${OUTPUT_DIR}/${EXTRACTED_DIR_NAME}"
|
|
93
179
|
|
|
94
|
-
if
|
|
180
|
+
if artifacts_present "$EXTRACTED_DIR_NAME" "$FINAL_CHECK_PATH"; then
|
|
95
181
|
continue
|
|
96
182
|
fi
|
|
97
183
|
|
|
98
|
-
# If we are here, the
|
|
184
|
+
# If we are here, the artifacts are missing, so we download and unzip.
|
|
99
185
|
echo "Downloading from: $ARCH_URL"
|
|
100
186
|
curl -fsSL "$ARCH_URL" -o "$ZIP_FILE_PATH"
|
|
101
187
|
|
|
@@ -113,6 +199,8 @@ for name in "${DOWNLOAD_NAMES[@]}"; do
|
|
|
113
199
|
|
|
114
200
|
done
|
|
115
201
|
|
|
116
|
-
|
|
202
|
+
if [ "$PLATFORM" == "ios" ]; then
|
|
203
|
+
restore_versioned_framework_symlinks
|
|
204
|
+
fi
|
|
117
205
|
|
|
118
206
|
rm -rf "$TEMP_DOWNLOAD_DIR"
|
package/src/core/AudioParam.ts
CHANGED