react-native-audio-api 0.9.0-nightly-7ecb495-20251008 → 0.9.1
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/android/src/main/cpp/audioapi/android/core/{utils/AudioDecoder.cpp → AudioDecoder.cpp} +75 -79
- package/android/src/main/jniLibs/arm64-v8a/libavcodec.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libavformat.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libavutil.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libswresample.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libavcodec.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libavformat.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libavutil.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libswresample.so +0 -0
- package/android/src/main/jniLibs/x86/libavcodec.so +0 -0
- package/android/src/main/jniLibs/x86/libavformat.so +0 -0
- package/android/src/main/jniLibs/x86/libavutil.so +0 -0
- package/android/src/main/jniLibs/x86/libswresample.so +0 -0
- package/android/src/main/jniLibs/x86_64/libavcodec.so +0 -0
- package/android/src/main/jniLibs/x86_64/libavformat.so +0 -0
- package/android/src/main/jniLibs/x86_64/libavutil.so +0 -0
- package/android/src/main/jniLibs/x86_64/libswresample.so +0 -0
- package/common/cpp/audioapi/AudioAPIModuleInstaller.h +43 -124
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.cpp +101 -1
- package/common/cpp/audioapi/HostObjects/BaseAudioContextHostObject.h +3 -0
- package/common/cpp/audioapi/HostObjects/sources/AudioBufferHostObject.cpp +3 -8
- package/common/cpp/audioapi/core/AudioContext.cpp +2 -0
- package/common/cpp/audioapi/core/BaseAudioContext.cpp +35 -0
- package/common/cpp/audioapi/core/BaseAudioContext.h +12 -4
- package/common/cpp/audioapi/core/OfflineAudioContext.cpp +2 -0
- package/common/cpp/audioapi/core/effects/WorkletNode.cpp +16 -28
- package/common/cpp/audioapi/core/effects/WorkletNode.h +2 -3
- package/common/cpp/audioapi/core/effects/WorkletProcessingNode.cpp +5 -6
- package/common/cpp/audioapi/core/sources/AudioBuffer.h +1 -0
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.cpp +0 -4
- package/common/cpp/audioapi/core/sources/AudioBufferBaseSourceNode.h +0 -1
- package/common/cpp/audioapi/core/sources/AudioBufferSourceNode.cpp +0 -2
- package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.cpp +0 -4
- package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.h +0 -1
- package/common/cpp/audioapi/core/sources/StreamerNode.cpp +16 -6
- package/common/cpp/audioapi/core/sources/StreamerNode.h +3 -1
- package/common/cpp/audioapi/core/sources/WorkletSourceNode.cpp +2 -3
- package/common/cpp/audioapi/core/utils/AudioDecoder.h +91 -36
- package/common/cpp/audioapi/core/utils/Constants.h +0 -4
- package/common/cpp/audioapi/events/AudioEventHandlerRegistry.cpp +5 -1
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64/libavcodec.framework/libavcodec +0 -0
- package/common/cpp/audioapi/external/libavcodec.xcframework/ios-arm64_x86_64-simulator/libavcodec.framework/libavcodec +0 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/Info.plist +5 -5
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64/libavformat.framework/libavformat +0 -0
- package/common/cpp/audioapi/external/libavformat.xcframework/ios-arm64_x86_64-simulator/libavformat.framework/libavformat +0 -0
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64/libavutil.framework/libavutil +0 -0
- package/common/cpp/audioapi/external/libavutil.xcframework/ios-arm64_x86_64-simulator/libavutil.framework/libavutil +0 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/Info.plist +5 -5
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64/libswresample.framework/libswresample +0 -0
- package/common/cpp/audioapi/external/libswresample.xcframework/ios-arm64_x86_64-simulator/libswresample.framework/libswresample +0 -0
- package/common/cpp/audioapi/jsi/AudioArrayBuffer.cpp +2 -2
- package/common/cpp/audioapi/jsi/AudioArrayBuffer.h +10 -11
- package/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.cpp +282 -241
- package/common/cpp/audioapi/libs/ffmpeg/FFmpegDecoding.h +19 -57
- package/common/cpp/audioapi/libs/ffmpeg/ffmpeg_setup.sh +1 -1
- package/common/cpp/audioapi/utils/AudioBus.cpp +4 -0
- package/common/cpp/audioapi/utils/AudioBus.h +1 -0
- package/common/cpp/test/CMakeLists.txt +8 -5
- package/common/cpp/test/RunTests.sh +2 -2
- package/common/cpp/test/{AudioParamTest.cpp → src/AudioParamTest.cpp} +1 -1
- package/common/cpp/test/src/ConstantSourceTest.cpp +64 -0
- package/common/cpp/test/{GainTest.cpp → src/GainTest.cpp} +11 -10
- package/common/cpp/test/{MockAudioEventHandlerRegistry.h → src/MockAudioEventHandlerRegistry.h} +4 -2
- package/common/cpp/test/{OscillatorTest.cpp → src/OscillatorTest.cpp} +6 -4
- package/common/cpp/test/{StereoPannerTest.cpp → src/StereoPannerTest.cpp} +1 -1
- package/ios/audioapi/ios/core/AudioDecoder.mm +156 -0
- package/lib/commonjs/api.js +1 -21
- package/lib/commonjs/api.js.map +1 -1
- package/lib/commonjs/core/BaseAudioContext.js +18 -11
- package/lib/commonjs/core/BaseAudioContext.js.map +1 -1
- package/lib/module/api.js +1 -3
- package/lib/module/api.js.map +1 -1
- package/lib/module/core/BaseAudioContext.js +18 -11
- package/lib/module/core/BaseAudioContext.js.map +1 -1
- package/lib/typescript/api.d.ts +1 -5
- package/lib/typescript/api.d.ts.map +1 -1
- package/lib/typescript/core/BaseAudioContext.d.ts +6 -3
- package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
- package/lib/typescript/interfaces.d.ts +3 -10
- package/lib/typescript/interfaces.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/api.ts +0 -10
- package/src/core/BaseAudioContext.ts +29 -26
- package/src/interfaces.ts +6 -26
- package/common/cpp/audioapi/HostObjects/utils/AudioDecoderHostObject.cpp +0 -133
- package/common/cpp/audioapi/HostObjects/utils/AudioDecoderHostObject.h +0 -28
- package/common/cpp/audioapi/HostObjects/utils/AudioStretcherHostObject.cpp +0 -58
- package/common/cpp/audioapi/HostObjects/utils/AudioStretcherHostObject.h +0 -26
- package/common/cpp/audioapi/core/types/AudioFormat.h +0 -16
- package/common/cpp/audioapi/core/utils/AudioStretcher.cpp +0 -75
- package/common/cpp/audioapi/core/utils/AudioStretcher.h +0 -30
- package/ios/audioapi/ios/core/utils/AudioDecoder.mm +0 -160
- package/lib/commonjs/core/AudioDecoder.js +0 -48
- package/lib/commonjs/core/AudioDecoder.js.map +0 -1
- package/lib/commonjs/core/AudioStretcher.js +0 -31
- package/lib/commonjs/core/AudioStretcher.js.map +0 -1
- package/lib/module/core/AudioDecoder.js +0 -42
- package/lib/module/core/AudioDecoder.js.map +0 -1
- package/lib/module/core/AudioStretcher.js +0 -26
- package/lib/module/core/AudioStretcher.js.map +0 -1
- package/lib/typescript/core/AudioDecoder.d.ts +0 -4
- package/lib/typescript/core/AudioDecoder.d.ts.map +0 -1
- package/lib/typescript/core/AudioStretcher.d.ts +0 -3
- package/lib/typescript/core/AudioStretcher.d.ts.map +0 -1
- package/src/core/AudioDecoder.ts +0 -78
- package/src/core/AudioStretcher.ts +0 -43
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* This file dynamically links to the FFmpeg library, which is licensed under
|
|
3
|
-
*
|
|
2
|
+
* This file dynamically links to the FFmpeg library, which is licensed under the
|
|
3
|
+
* GNU Lesser General Public License (LGPL) version 2.1 or later.
|
|
4
4
|
*
|
|
5
|
-
* Our own code in this file is licensed under the MIT License and dynamic
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* Our own code in this file is licensed under the MIT License and dynamic linking
|
|
6
|
+
* allows you to use this code without your entire project being subject to the
|
|
7
|
+
* terms of the LGPL. However, note that if you link statically to FFmpeg, you must
|
|
8
|
+
* comply with the terms of the LGPL for FFmpeg itself.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
#include <audioapi/utils/AudioBus.h>
|
|
@@ -14,62 +14,24 @@
|
|
|
14
14
|
#include <vector>
|
|
15
15
|
|
|
16
16
|
extern "C" {
|
|
17
|
-
#include <libavcodec/avcodec.h>
|
|
18
|
-
#include <libavformat/avformat.h>
|
|
19
|
-
#include <libavutil/opt.h>
|
|
20
|
-
#include <libswresample/swresample.h>
|
|
17
|
+
#include <libavcodec/avcodec.h>
|
|
18
|
+
#include <libavformat/avformat.h>
|
|
19
|
+
#include <libavutil/opt.h>
|
|
20
|
+
#include <libswresample/swresample.h>
|
|
21
21
|
}
|
|
22
|
-
class AudioBuffer;
|
|
23
22
|
|
|
24
|
-
namespace audioapi::
|
|
23
|
+
namespace audioapi::ffmpegdecoding {
|
|
25
24
|
// Custom IO context for reading from memory
|
|
26
25
|
struct MemoryIOContext {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
struct AudioStreamContext {
|
|
33
|
-
AVFormatContext *fmt_ctx = nullptr;
|
|
34
|
-
AVCodecContext *codec_ctx = nullptr;
|
|
35
|
-
int audio_stream_index = -1;
|
|
36
|
-
};
|
|
26
|
+
const uint8_t *data;
|
|
27
|
+
size_t size;
|
|
28
|
+
size_t pos;
|
|
29
|
+
};
|
|
37
30
|
|
|
38
31
|
int read_packet(void *opaque, uint8_t *buf, int buf_size);
|
|
39
32
|
int64_t seek_packet(void *opaque, int64_t offset, int whence);
|
|
40
|
-
|
|
41
|
-
std::vector<
|
|
42
|
-
|
|
43
|
-
AVCodecContext *codec_ctx,
|
|
44
|
-
int out_sample_rate,
|
|
45
|
-
int output_channel_count,
|
|
46
|
-
int audio_stream_index,
|
|
47
|
-
size_t &framesRead);
|
|
48
|
-
|
|
49
|
-
void convertFrameToBuffer(
|
|
50
|
-
SwrContext *swr,
|
|
51
|
-
AVFrame *frame,
|
|
52
|
-
int output_channel_count,
|
|
53
|
-
std::vector<float> &buffer,
|
|
54
|
-
size_t &framesRead,
|
|
55
|
-
uint8_t **&resampled_data,
|
|
56
|
-
int &max_resampled_samples);
|
|
57
|
-
bool setupDecoderContext(
|
|
58
|
-
AVFormatContext *fmt_ctx,
|
|
59
|
-
int &audio_stream_index,
|
|
60
|
-
std::unique_ptr<AVCodecContext, decltype(&avcodec_free_context)>
|
|
61
|
-
&codec_ctx);
|
|
62
|
-
std::shared_ptr<AudioBuffer> decodeAudioFrames(
|
|
63
|
-
AVFormatContext *fmt_ctx,
|
|
64
|
-
AVCodecContext *codec_ctx,
|
|
65
|
-
int audio_stream_index,
|
|
66
|
-
int sample_rate);
|
|
67
|
-
|
|
68
|
-
std::shared_ptr<AudioBuffer>
|
|
69
|
-
decodeWithMemoryBlock(const void *data, size_t size, int sample_rate);
|
|
70
|
-
|
|
71
|
-
std::shared_ptr<AudioBuffer> decodeWithFilePath(
|
|
72
|
-
const std::string &path,
|
|
73
|
-
int sample_rate);
|
|
33
|
+
std::vector<int16_t> readAllPcmFrames(AVFormatContext *fmt_ctx, AVCodecContext *codec_ctx, int out_sample_rate, int audio_stream_index, int channels, size_t &framesRead);
|
|
34
|
+
std::vector<int16_t> decodeWithMemoryBlock(const void *data, size_t size, const int channel_count, int sample_rate);
|
|
35
|
+
std::vector<int16_t> decodeWithFilePath(const std::string &path, const int channel_count, int sample_rate);
|
|
74
36
|
|
|
75
|
-
} // namespace audioapi::ffmpegdecoder
|
|
37
|
+
} // namespace audioapi::ffmpegdecoder
|
|
@@ -128,6 +128,10 @@ AudioArray *AudioBus::getChannelByType(int channelType) const {
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
std::shared_ptr<AudioArray> AudioBus::getSharedChannel(int index) const {
|
|
132
|
+
return channels_[index];
|
|
133
|
+
}
|
|
134
|
+
|
|
131
135
|
AudioArray &AudioBus::operator[](size_t index) {
|
|
132
136
|
return *channels_[index];
|
|
133
137
|
}
|
|
@@ -34,6 +34,7 @@ class AudioBus {
|
|
|
34
34
|
[[nodiscard]] size_t getSize() const;
|
|
35
35
|
[[nodiscard]] AudioArray *getChannel(int index) const;
|
|
36
36
|
[[nodiscard]] AudioArray *getChannelByType(int channelType) const;
|
|
37
|
+
[[nodiscard]] std::shared_ptr<AudioArray> getSharedChannel(int index) const;
|
|
37
38
|
|
|
38
39
|
AudioArray &operator[](size_t index);
|
|
39
40
|
const AudioArray &operator[](size_t index) const;
|
|
@@ -21,7 +21,7 @@ enable_testing()
|
|
|
21
21
|
file(GLOB_RECURSE RNAUDIOAPI_SRC
|
|
22
22
|
CONFIGURE_DEPENDS
|
|
23
23
|
"${ROOT}/node_modules/react-native-audio-api/common/cpp/audioapi/*.cpp"
|
|
24
|
-
"${ROOT}/node_modules/react-native-audio-api/android/src/main/cpp/audioapi/android/core/
|
|
24
|
+
"${ROOT}/node_modules/react-native-audio-api/android/src/main/cpp/audioapi/android/core/AudioDecoder.cpp"
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
# exclude HostObjects from tests
|
|
@@ -62,12 +62,15 @@ target_include_directories(rnaudioapi PUBLIC
|
|
|
62
62
|
target_include_directories(rnaudioapi_libs PUBLIC
|
|
63
63
|
${ROOT}/packages/react-native-audio-api/common/cpp
|
|
64
64
|
)
|
|
65
|
+
|
|
66
|
+
file(GLOB_RECURSE test_src
|
|
67
|
+
CONFIGURE_DEPENDS
|
|
68
|
+
"src/*.cpp"
|
|
69
|
+
)
|
|
70
|
+
|
|
65
71
|
add_executable(
|
|
66
72
|
tests
|
|
67
|
-
|
|
68
|
-
GainTest.cpp
|
|
69
|
-
AudioParamTest.cpp
|
|
70
|
-
StereoPannerTest.cpp
|
|
73
|
+
${test_src}
|
|
71
74
|
)
|
|
72
75
|
|
|
73
76
|
add_compile_definitions(AUDIO_API_TEST_SUITE)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#include <audioapi/core/OfflineAudioContext.h>
|
|
2
|
+
#include <audioapi/core/sources/ConstantSourceNode.h>
|
|
3
|
+
#include <audioapi/core/utils/worklets/SafeIncludes.h>
|
|
4
|
+
#include <audioapi/utils/AudioArray.h>
|
|
5
|
+
#include <audioapi/utils/AudioBus.h>
|
|
6
|
+
#include <gtest/gtest.h>
|
|
7
|
+
#include <test/src/MockAudioEventHandlerRegistry.h>
|
|
8
|
+
|
|
9
|
+
using namespace audioapi;
|
|
10
|
+
|
|
11
|
+
class ConstantSourceTest : public ::testing::Test {
|
|
12
|
+
protected:
|
|
13
|
+
std::shared_ptr<IAudioEventHandlerRegistry> eventRegistry;
|
|
14
|
+
std::unique_ptr<OfflineAudioContext> context;
|
|
15
|
+
static constexpr int sampleRate = 44100;
|
|
16
|
+
|
|
17
|
+
void SetUp() override {
|
|
18
|
+
eventRegistry = std::make_shared<MockAudioEventHandlerRegistry>();
|
|
19
|
+
context = std::make_unique<OfflineAudioContext>(
|
|
20
|
+
2, 5 * sampleRate, sampleRate, eventRegistry, RuntimeRegistry{});
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
class TestableConstantSourceNode : public ConstantSourceNode {
|
|
25
|
+
public:
|
|
26
|
+
explicit TestableConstantSourceNode(BaseAudioContext *context)
|
|
27
|
+
: ConstantSourceNode(context) {}
|
|
28
|
+
|
|
29
|
+
void setOffsetParam(float value) {
|
|
30
|
+
getOffsetParam()->setValue(value);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
std::shared_ptr<AudioBus> processNode(
|
|
34
|
+
const std::shared_ptr<AudioBus> &processingBus,
|
|
35
|
+
int framesToProcess) override {
|
|
36
|
+
return ConstantSourceNode::processNode(processingBus, framesToProcess);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
TEST_F(ConstantSourceTest, ConstantSourceCanBeCreated) {
|
|
41
|
+
auto constantSource = context->createConstantSource();
|
|
42
|
+
ASSERT_NE(constantSource, nullptr);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
TEST_F(ConstantSourceTest, ConstantSourceOutputsConstantValue) {
|
|
46
|
+
static constexpr int FRAMES_TO_PROCESS = 4;
|
|
47
|
+
|
|
48
|
+
auto bus =
|
|
49
|
+
std::make_shared<audioapi::AudioBus>(FRAMES_TO_PROCESS, 1, sampleRate);
|
|
50
|
+
auto constantSource =
|
|
51
|
+
std::make_shared<TestableConstantSourceNode>(context.get());
|
|
52
|
+
constantSource->start(context->getCurrentTime());
|
|
53
|
+
auto resultBus = constantSource->processNode(bus, FRAMES_TO_PROCESS);
|
|
54
|
+
|
|
55
|
+
for (int i = 0; i < FRAMES_TO_PROCESS; ++i) {
|
|
56
|
+
EXPECT_FLOAT_EQ((*resultBus->getChannel(0))[i], 1.0f);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
constantSource->setOffsetParam(0.5f);
|
|
60
|
+
resultBus = constantSource->processNode(bus, FRAMES_TO_PROCESS);
|
|
61
|
+
for (int i = 0; i < FRAMES_TO_PROCESS; ++i) {
|
|
62
|
+
EXPECT_FLOAT_EQ((*resultBus->getChannel(0))[i], 0.5f);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -4,34 +4,35 @@
|
|
|
4
4
|
#include <audioapi/utils/AudioArray.h>
|
|
5
5
|
#include <audioapi/utils/AudioBus.h>
|
|
6
6
|
#include <gtest/gtest.h>
|
|
7
|
-
#include
|
|
7
|
+
#include <test/src/MockAudioEventHandlerRegistry.h>
|
|
8
|
+
|
|
9
|
+
using namespace audioapi;
|
|
8
10
|
|
|
9
11
|
class GainTest : public ::testing::Test {
|
|
10
12
|
protected:
|
|
11
|
-
std::shared_ptr<
|
|
12
|
-
std::unique_ptr<
|
|
13
|
+
std::shared_ptr<IAudioEventHandlerRegistry> eventRegistry;
|
|
14
|
+
std::unique_ptr<OfflineAudioContext> context;
|
|
13
15
|
static constexpr int sampleRate = 44100;
|
|
14
16
|
|
|
15
17
|
void SetUp() override {
|
|
16
18
|
eventRegistry = std::make_shared<MockAudioEventHandlerRegistry>();
|
|
17
|
-
context = std::make_unique<
|
|
19
|
+
context = std::make_unique<OfflineAudioContext>(
|
|
18
20
|
2, 5 * sampleRate, sampleRate, eventRegistry, RuntimeRegistry{});
|
|
19
21
|
}
|
|
20
22
|
};
|
|
21
23
|
|
|
22
|
-
class TestableGainNode : public
|
|
24
|
+
class TestableGainNode : public GainNode {
|
|
23
25
|
public:
|
|
24
|
-
explicit TestableGainNode(
|
|
25
|
-
: audioapi::GainNode(context) {}
|
|
26
|
+
explicit TestableGainNode(BaseAudioContext *context) : GainNode(context) {}
|
|
26
27
|
|
|
27
28
|
void setGainParam(float value) {
|
|
28
29
|
getGainParam()->setValue(value);
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
std::shared_ptr<
|
|
32
|
-
const std::shared_ptr<
|
|
32
|
+
std::shared_ptr<AudioBus> processNode(
|
|
33
|
+
const std::shared_ptr<AudioBus> &processingBus,
|
|
33
34
|
int framesToProcess) override {
|
|
34
|
-
return
|
|
35
|
+
return GainNode::processNode(processingBus, framesToProcess);
|
|
35
36
|
}
|
|
36
37
|
};
|
|
37
38
|
|
package/common/cpp/test/{MockAudioEventHandlerRegistry.h → src/MockAudioEventHandlerRegistry.h}
RENAMED
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
#include <string>
|
|
7
7
|
#include <memory>
|
|
8
8
|
|
|
9
|
-
using
|
|
9
|
+
using namespace audioapi;
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
using EventMap = std::unordered_map<std::string, EventValue>;
|
|
12
|
+
|
|
13
|
+
class MockAudioEventHandlerRegistry : public IAudioEventHandlerRegistry {
|
|
12
14
|
public:
|
|
13
15
|
MOCK_METHOD(uint64_t, registerHandler,
|
|
14
16
|
(const std::string &eventName, const std::shared_ptr<facebook::jsi::Function> &handler), (override));
|
|
@@ -2,17 +2,19 @@
|
|
|
2
2
|
#include <audioapi/core/sources/OscillatorNode.h>
|
|
3
3
|
#include <audioapi/core/utils/worklets/SafeIncludes.h>
|
|
4
4
|
#include <gtest/gtest.h>
|
|
5
|
-
#include
|
|
5
|
+
#include <test/src/MockAudioEventHandlerRegistry.h>
|
|
6
|
+
|
|
7
|
+
using namespace audioapi;
|
|
6
8
|
|
|
7
9
|
class OscillatorTest : public ::testing::Test {
|
|
8
10
|
protected:
|
|
9
|
-
std::shared_ptr<
|
|
10
|
-
std::unique_ptr<
|
|
11
|
+
std::shared_ptr<IAudioEventHandlerRegistry> eventRegistry;
|
|
12
|
+
std::unique_ptr<OfflineAudioContext> context;
|
|
11
13
|
static constexpr int sampleRate = 44100;
|
|
12
14
|
|
|
13
15
|
void SetUp() override {
|
|
14
16
|
eventRegistry = std::make_shared<MockAudioEventHandlerRegistry>();
|
|
15
|
-
context = std::make_unique<
|
|
17
|
+
context = std::make_unique<OfflineAudioContext>(
|
|
16
18
|
2, 5 * sampleRate, sampleRate, eventRegistry, RuntimeRegistry{});
|
|
17
19
|
}
|
|
18
20
|
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#define MINIAUDIO_IMPLEMENTATION
|
|
2
|
+
#import <audioapi/libs/miniaudio/miniaudio.h>
|
|
3
|
+
|
|
4
|
+
#include <audioapi/libs/miniaudio/decoders/libopus/miniaudio_libopus.h>
|
|
5
|
+
#include <audioapi/libs/miniaudio/decoders/libvorbis/miniaudio_libvorbis.h>
|
|
6
|
+
|
|
7
|
+
#include <audioapi/core/utils/AudioDecoder.h>
|
|
8
|
+
#include <audioapi/dsp/VectorMath.h>
|
|
9
|
+
#include <audioapi/libs/audio-stretch/stretch.h>
|
|
10
|
+
#include <audioapi/libs/base64/base64.h>
|
|
11
|
+
#include <audioapi/libs/ffmpeg/FFmpegDecoding.h>
|
|
12
|
+
#include <audioapi/utils/AudioArray.h>
|
|
13
|
+
#include <audioapi/utils/AudioBus.h>
|
|
14
|
+
|
|
15
|
+
namespace audioapi {
|
|
16
|
+
|
|
17
|
+
// Decoding audio in fixed-size chunks because total frame count can't be
|
|
18
|
+
// determined in advance. Note: ma_decoder_get_length_in_pcm_frames() always
|
|
19
|
+
// returns 0 for Vorbis decoders.
|
|
20
|
+
std::vector<int16_t> AudioDecoder::readAllPcmFrames(ma_decoder &decoder, int numChannels, ma_uint64 &outFramesRead)
|
|
21
|
+
{
|
|
22
|
+
std::vector<int16_t> buffer;
|
|
23
|
+
std::vector<int16_t> temp(CHUNK_SIZE * numChannels);
|
|
24
|
+
outFramesRead = 0;
|
|
25
|
+
|
|
26
|
+
while (true) {
|
|
27
|
+
ma_uint64 tempFramesDecoded = 0;
|
|
28
|
+
ma_decoder_read_pcm_frames(&decoder, temp.data(), CHUNK_SIZE, &tempFramesDecoded);
|
|
29
|
+
if (tempFramesDecoded == 0) {
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
buffer.insert(buffer.end(), temp.data(), temp.data() + tempFramesDecoded * numChannels);
|
|
34
|
+
outFramesRead += tempFramesDecoded;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return buffer;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
std::shared_ptr<AudioBus>
|
|
41
|
+
AudioDecoder::makeAudioBusFromInt16Buffer(const std::vector<int16_t> &buffer, int numChannels, float sampleRate)
|
|
42
|
+
{
|
|
43
|
+
auto outputFrames = buffer.size() / numChannels;
|
|
44
|
+
auto audioBus = std::make_shared<AudioBus>(outputFrames, numChannels, sampleRate);
|
|
45
|
+
|
|
46
|
+
for (int ch = 0; ch < numChannels; ++ch) {
|
|
47
|
+
auto channelData = audioBus->getChannel(ch)->getData();
|
|
48
|
+
for (int i = 0; i < outputFrames; ++i) {
|
|
49
|
+
channelData[i] = int16ToFloat(buffer[i * numChannels + ch]);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return audioBus;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
std::shared_ptr<AudioBus> AudioDecoder::decodeWithFilePath(const std::string &path) const
|
|
56
|
+
{
|
|
57
|
+
std::vector<int16_t> buffer;
|
|
58
|
+
if (AudioDecoder::pathHasExtension(path, {".mp4", ".m4a", ".aac"})) {
|
|
59
|
+
buffer = ffmpegdecoding::decodeWithFilePath(path, numChannels_, static_cast<int>(sampleRate_));
|
|
60
|
+
if (buffer.empty()) {
|
|
61
|
+
NSLog(@"Failed to decode with FFmpeg: %s", path.c_str());
|
|
62
|
+
return nullptr;
|
|
63
|
+
}
|
|
64
|
+
return makeAudioBusFromInt16Buffer(buffer, numChannels_, sampleRate_);
|
|
65
|
+
}
|
|
66
|
+
ma_decoding_backend_vtable *customBackends[] = {ma_decoding_backend_libvorbis, ma_decoding_backend_libopus};
|
|
67
|
+
|
|
68
|
+
ma_decoder decoder;
|
|
69
|
+
ma_decoder_config config = ma_decoder_config_init(ma_format_s16, numChannels_, static_cast<int>(sampleRate_));
|
|
70
|
+
config.ppCustomBackendVTables = customBackends;
|
|
71
|
+
config.customBackendCount = sizeof(customBackends) / sizeof(customBackends[0]);
|
|
72
|
+
|
|
73
|
+
if (ma_decoder_init_file(path.c_str(), &config, &decoder) != MA_SUCCESS) {
|
|
74
|
+
NSLog(@"Failed to initialize decoder for file: %s", path.c_str());
|
|
75
|
+
ma_decoder_uninit(&decoder);
|
|
76
|
+
return nullptr;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
ma_uint64 framesRead = 0;
|
|
80
|
+
buffer = readAllPcmFrames(decoder, numChannels_, framesRead);
|
|
81
|
+
if (framesRead == 0) {
|
|
82
|
+
NSLog(@"Failed to decode");
|
|
83
|
+
ma_decoder_uninit(&decoder);
|
|
84
|
+
return nullptr;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
ma_decoder_uninit(&decoder);
|
|
88
|
+
return makeAudioBusFromInt16Buffer(buffer, numChannels_, sampleRate_);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
std::shared_ptr<AudioBus> AudioDecoder::decodeWithMemoryBlock(const void *data, size_t size) const
|
|
92
|
+
{
|
|
93
|
+
std::vector<int16_t> buffer;
|
|
94
|
+
const AudioFormat format = AudioDecoder::detectAudioFormat(data, size);
|
|
95
|
+
if (format == AudioFormat::MP4 || format == AudioFormat::M4A || format == AudioFormat::AAC) {
|
|
96
|
+
buffer = ffmpegdecoding::decodeWithMemoryBlock(data, size, numChannels_, static_cast<int>(sampleRate_));
|
|
97
|
+
if (buffer.empty()) {
|
|
98
|
+
NSLog(@"Failed to decode with FFmpeg");
|
|
99
|
+
return nullptr;
|
|
100
|
+
}
|
|
101
|
+
return makeAudioBusFromInt16Buffer(buffer, numChannels_, sampleRate_);
|
|
102
|
+
}
|
|
103
|
+
ma_decoding_backend_vtable *customBackends[] = {ma_decoding_backend_libvorbis, ma_decoding_backend_libopus};
|
|
104
|
+
|
|
105
|
+
ma_decoder decoder;
|
|
106
|
+
ma_decoder_config config = ma_decoder_config_init(ma_format_s16, numChannels_, static_cast<int>(sampleRate_));
|
|
107
|
+
config.ppCustomBackendVTables = customBackends;
|
|
108
|
+
config.customBackendCount = sizeof(customBackends) / sizeof(customBackends[0]);
|
|
109
|
+
|
|
110
|
+
if (ma_decoder_init_memory(data, size, &config, &decoder) != MA_SUCCESS) {
|
|
111
|
+
NSLog(@"Failed to initialize decoder for memory block");
|
|
112
|
+
ma_decoder_uninit(&decoder);
|
|
113
|
+
return nullptr;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
ma_uint64 framesRead = 0;
|
|
117
|
+
buffer = readAllPcmFrames(decoder, numChannels_, framesRead);
|
|
118
|
+
if (framesRead == 0) {
|
|
119
|
+
NSLog(@"Failed to decode");
|
|
120
|
+
ma_decoder_uninit(&decoder);
|
|
121
|
+
return nullptr;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
ma_decoder_uninit(&decoder);
|
|
125
|
+
return makeAudioBusFromInt16Buffer(buffer, numChannels_, sampleRate_);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
std::shared_ptr<AudioBus> AudioDecoder::decodeWithPCMInBase64(const std::string &data, float playbackSpeed) const
|
|
129
|
+
{
|
|
130
|
+
auto decodedData = base64_decode(data, false);
|
|
131
|
+
|
|
132
|
+
const auto uint8Data = reinterpret_cast<uint8_t *>(decodedData.data());
|
|
133
|
+
size_t framesDecoded = decodedData.size() / 2;
|
|
134
|
+
|
|
135
|
+
std::vector<int16_t> buffer(framesDecoded);
|
|
136
|
+
for (size_t i = 0; i < framesDecoded; ++i) {
|
|
137
|
+
buffer[i] = static_cast<int16_t>((uint8Data[i * 2 + 1] << 8) | uint8Data[i * 2]);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
changePlaybackSpeedIfNeeded(buffer, framesDecoded, 1, playbackSpeed);
|
|
141
|
+
auto outputFrames = buffer.size();
|
|
142
|
+
|
|
143
|
+
auto audioBus = std::make_shared<AudioBus>(outputFrames, numChannels_, sampleRate_);
|
|
144
|
+
auto leftChannelData = audioBus->getChannel(0)->getData();
|
|
145
|
+
auto rightChannelData = audioBus->getChannel(1)->getData();
|
|
146
|
+
|
|
147
|
+
for (size_t i = 0; i < outputFrames; ++i) {
|
|
148
|
+
auto sample = int16ToFloat(buffer[i]);
|
|
149
|
+
leftChannelData[i] = sample;
|
|
150
|
+
rightChannelData[i] = sample;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return audioBus;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
} // namespace audioapi
|
package/lib/commonjs/api.js
CHANGED
|
@@ -219,24 +219,6 @@ Object.defineProperty(exports, "WorkletSourceNode", {
|
|
|
219
219
|
return _WorkletSourceNode.default;
|
|
220
220
|
}
|
|
221
221
|
});
|
|
222
|
-
Object.defineProperty(exports, "changePlaybackSpeed", {
|
|
223
|
-
enumerable: true,
|
|
224
|
-
get: function () {
|
|
225
|
-
return _AudioStretcher.default;
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
Object.defineProperty(exports, "decodeAudioData", {
|
|
229
|
-
enumerable: true,
|
|
230
|
-
get: function () {
|
|
231
|
-
return _AudioDecoder.decodeAudioData;
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
Object.defineProperty(exports, "decodePCMInBase64", {
|
|
235
|
-
enumerable: true,
|
|
236
|
-
get: function () {
|
|
237
|
-
return _AudioDecoder.decodePCMInBase64;
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
222
|
Object.defineProperty(exports, "useSystemVolume", {
|
|
241
223
|
enumerable: true,
|
|
242
224
|
get: function () {
|
|
@@ -268,8 +250,6 @@ var _StreamerNode = _interopRequireDefault(require("./core/StreamerNode"));
|
|
|
268
250
|
var _ConstantSourceNode = _interopRequireDefault(require("./core/ConstantSourceNode"));
|
|
269
251
|
var _system = _interopRequireDefault(require("./system"));
|
|
270
252
|
var _useSystemVolume = _interopRequireDefault(require("./hooks/useSystemVolume"));
|
|
271
|
-
var _AudioDecoder = require("./core/AudioDecoder");
|
|
272
|
-
var _AudioStretcher = _interopRequireDefault(require("./core/AudioStretcher"));
|
|
273
253
|
var _types = require("./types");
|
|
274
254
|
var _errors = require("./errors");
|
|
275
255
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -277,7 +257,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
277
257
|
|
|
278
258
|
/* eslint-disable no-var */
|
|
279
259
|
|
|
280
|
-
if (global.createAudioContext == null || global.createOfflineAudioContext == null || global.createAudioRecorder == null || global.
|
|
260
|
+
if (global.createAudioContext == null || global.createOfflineAudioContext == null || global.createAudioRecorder == null || global.AudioEventEmitter == null) {
|
|
281
261
|
if (!_specs.NativeAudioAPIModule) {
|
|
282
262
|
throw new Error(`Failed to install react-native-audio-api: The native module could not be found.`);
|
|
283
263
|
}
|
package/lib/commonjs/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_specs","require","_WorkletNode","_interopRequireDefault","_WorkletSourceNode","_WorkletProcessingNode","_RecorderAdapterNode","_AudioBuffer","_AudioBufferSourceNode","_AudioBufferQueueSourceNode","_AudioContext","_OfflineAudioContext","_AudioDestinationNode","_AudioNode","_AnalyserNode","_AudioParam","_AudioScheduledSourceNode","_BaseAudioContext","_BiquadFilterNode","_GainNode","_OscillatorNode","_StereoPannerNode","_AudioRecorder","_StreamerNode","_ConstantSourceNode","_system","_useSystemVolume","
|
|
1
|
+
{"version":3,"names":["_specs","require","_WorkletNode","_interopRequireDefault","_WorkletSourceNode","_WorkletProcessingNode","_RecorderAdapterNode","_AudioBuffer","_AudioBufferSourceNode","_AudioBufferQueueSourceNode","_AudioContext","_OfflineAudioContext","_AudioDestinationNode","_AudioNode","_AnalyserNode","_AudioParam","_AudioScheduledSourceNode","_BaseAudioContext","_BiquadFilterNode","_GainNode","_OscillatorNode","_StereoPannerNode","_AudioRecorder","_StreamerNode","_ConstantSourceNode","_system","_useSystemVolume","_types","_errors","e","__esModule","default","global","createAudioContext","createOfflineAudioContext","createAudioRecorder","AudioEventEmitter","NativeAudioAPIModule","Error","install"],"sourceRoot":"../../src","sources":["api.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AA8CA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,kBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,sBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,oBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,YAAA,GAAAJ,sBAAA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IAAI,IAClCH,MAAM,CAACI,iBAAiB,IAAI,IAAI,EAChC;EACA,IAAI,CAACC,2BAAoB,EAAE;IACzB,MAAM,IAAIC,KAAK,CACb,iFACF,CAAC;EACH;EAEAD,2BAAoB,CAACE,OAAO,CAAC,CAAC;AAChC","ignoreList":[]}
|
|
@@ -14,7 +14,6 @@ var _AudioBufferQueueSourceNode = _interopRequireDefault(require("./AudioBufferQ
|
|
|
14
14
|
var _AudioBufferSourceNode = _interopRequireDefault(require("./AudioBufferSourceNode"));
|
|
15
15
|
var _AudioDestinationNode = _interopRequireDefault(require("./AudioDestinationNode"));
|
|
16
16
|
var _BiquadFilterNode = _interopRequireDefault(require("./BiquadFilterNode"));
|
|
17
|
-
var _ConstantSourceNode = _interopRequireDefault(require("./ConstantSourceNode"));
|
|
18
17
|
var _GainNode = _interopRequireDefault(require("./GainNode"));
|
|
19
18
|
var _OscillatorNode = _interopRequireDefault(require("./OscillatorNode"));
|
|
20
19
|
var _PeriodicWave = _interopRequireDefault(require("./PeriodicWave"));
|
|
@@ -22,7 +21,7 @@ var _RecorderAdapterNode = _interopRequireDefault(require("./RecorderAdapterNode
|
|
|
22
21
|
var _StereoPannerNode = _interopRequireDefault(require("./StereoPannerNode"));
|
|
23
22
|
var _StreamerNode = _interopRequireDefault(require("./StreamerNode"));
|
|
24
23
|
var _WorkletNode = _interopRequireDefault(require("./WorkletNode"));
|
|
25
|
-
var
|
|
24
|
+
var _ConstantSourceNode = _interopRequireDefault(require("./ConstantSourceNode"));
|
|
26
25
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
27
26
|
class BaseAudioContext {
|
|
28
27
|
constructor(context) {
|
|
@@ -36,15 +35,6 @@ class BaseAudioContext {
|
|
|
36
35
|
get state() {
|
|
37
36
|
return this.context.state;
|
|
38
37
|
}
|
|
39
|
-
async decodeAudioData(input, sampleRate) {
|
|
40
|
-
if (!(typeof input === 'string' || input instanceof ArrayBuffer)) {
|
|
41
|
-
throw new TypeError('Input must be a string or ArrayBuffer');
|
|
42
|
-
}
|
|
43
|
-
return await (0, _AudioDecoder.decodeAudioData)(input, sampleRate ?? this.sampleRate);
|
|
44
|
-
}
|
|
45
|
-
async decodePCMInBase64(base64String, inputSampleRate, inputChannelCount, isInterleaved = true) {
|
|
46
|
-
return await (0, _AudioDecoder.decodePCMInBase64)(base64String, inputSampleRate, inputChannelCount, isInterleaved);
|
|
47
|
-
}
|
|
48
38
|
createWorkletNode(callback, bufferLength, inputChannelCount, workletRuntime = 'AudioRuntime') {
|
|
49
39
|
if (inputChannelCount < 1 || inputChannelCount > 32) {
|
|
50
40
|
throw new _errors.NotSupportedError(`The number of input channels provided (${inputChannelCount}) can not be less than 1 or greater than 32`);
|
|
@@ -142,6 +132,23 @@ class BaseAudioContext {
|
|
|
142
132
|
createAnalyser() {
|
|
143
133
|
return new _AnalyserNode.default(this, this.context.createAnalyser());
|
|
144
134
|
}
|
|
135
|
+
|
|
136
|
+
/** Decodes audio data from a local file path. */
|
|
137
|
+
async decodeAudioDataSource(sourcePath) {
|
|
138
|
+
// Remove the file:// prefix if it exists
|
|
139
|
+
if (sourcePath.startsWith('file://')) {
|
|
140
|
+
sourcePath = sourcePath.replace('file://', '');
|
|
141
|
+
}
|
|
142
|
+
return new _AudioBuffer.default(await this.context.decodeAudioDataSource(sourcePath));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Decodes audio data from an ArrayBuffer. */
|
|
146
|
+
async decodeAudioData(data) {
|
|
147
|
+
return new _AudioBuffer.default(await this.context.decodeAudioData(new Uint8Array(data)));
|
|
148
|
+
}
|
|
149
|
+
async decodePCMInBase64Data(base64, playbackRate = 1.0) {
|
|
150
|
+
return new _AudioBuffer.default(await this.context.decodePCMAudioDataInBase64(base64, playbackRate));
|
|
151
|
+
}
|
|
145
152
|
}
|
|
146
153
|
exports.default = BaseAudioContext;
|
|
147
154
|
//# sourceMappingURL=BaseAudioContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_errors","require","_utils","_WorkletSourceNode","_interopRequireDefault","_WorkletProcessingNode","_AnalyserNode","_AudioBuffer","_AudioBufferQueueSourceNode","_AudioBufferSourceNode","_AudioDestinationNode","_BiquadFilterNode","
|
|
1
|
+
{"version":3,"names":["_errors","require","_utils","_WorkletSourceNode","_interopRequireDefault","_WorkletProcessingNode","_AnalyserNode","_AudioBuffer","_AudioBufferQueueSourceNode","_AudioBufferSourceNode","_AudioDestinationNode","_BiquadFilterNode","_GainNode","_OscillatorNode","_PeriodicWave","_RecorderAdapterNode","_StereoPannerNode","_StreamerNode","_WorkletNode","_ConstantSourceNode","e","__esModule","default","BaseAudioContext","constructor","context","destination","AudioDestinationNode","sampleRate","currentTime","state","createWorkletNode","callback","bufferLength","inputChannelCount","workletRuntime","NotSupportedError","isWorkletsAvailable","shareableWorklet","workletsModule","makeShareableCloneRecursive","audioBuffers","channelCount","floatAudioData","map","buffer","Float32Array","WorkletNode","Error","createWorkletProcessingNode","inputBuffers","outputBuffers","framesToProcess","inputData","outputData","WorkletProcessingNode","createWorkletSourceNode","startOffset","WorkletSourceNode","createRecorderAdapter","RecorderAdapterNode","createOscillator","OscillatorNode","createStreamer","StreamerNode","createConstantSource","ConstantSourceNode","createGain","GainNode","createStereoPanner","StereoPannerNode","createBiquadFilter","BiquadFilterNode","createBufferSource","options","pitchCorrection","AudioBufferSourceNode","createBufferQueueSource","AudioBufferQueueSourceNode","createBuffer","numOfChannels","length","AudioBuffer","createPeriodicWave","real","imag","constraints","InvalidAccessError","disableNormalization","PeriodicWave","createAnalyser","AnalyserNode","decodeAudioDataSource","sourcePath","startsWith","replace","decodeAudioData","data","Uint8Array","decodePCMInBase64Data","base64","playbackRate","decodePCMAudioDataInBase64","exports"],"sourceRoot":"../../../src","sources":["core/BaseAudioContext.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAC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