react-native-audio-api 0.7.1-nightly-5a218c6-20250810 → 0.7.1-nightly-4d86c14-20250811
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 +31 -7
- package/android/src/main/cpp/audioapi/CMakeLists.txt +22 -1
- package/android/src/main/cpp/audioapi/android/core/AudioDecoder.cpp +81 -63
- package/common/cpp/audioapi/core/utils/AudioDecoder.h +54 -29
- package/common/cpp/audioapi/external/arm64-v8a/libogg.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libopus.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/arm64-v8a/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libogg.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libopus.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/armeabi-v7a/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/include/ogg/config_types.h +26 -0
- package/common/cpp/audioapi/external/include/ogg/config_types.h.in +26 -0
- package/common/cpp/audioapi/external/include/ogg/ogg.h +212 -0
- package/common/cpp/audioapi/external/include/ogg/os_types.h +157 -0
- package/common/cpp/audioapi/external/include/opus/opus.h +1286 -0
- package/common/cpp/audioapi/external/include/opus/opus_custom.h +390 -0
- package/common/cpp/audioapi/external/include/opus/opus_defines.h +896 -0
- package/common/cpp/audioapi/external/include/opus/opus_multistream.h +728 -0
- package/common/cpp/audioapi/external/include/opus/opus_projection.h +621 -0
- package/common/cpp/audioapi/external/include/opus/opus_types.h +170 -0
- package/common/cpp/audioapi/external/include/opusfile/opusfile.h +2151 -0
- package/common/cpp/audioapi/external/include/vorbis/codec.h +241 -0
- package/common/cpp/audioapi/external/include/vorbis/vorbisenc.h +446 -0
- package/common/cpp/audioapi/external/include/vorbis/vorbisfile.h +226 -0
- package/common/cpp/audioapi/external/iphoneos/libogg.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libopus.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/iphoneos/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libogg.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libopus.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/iphonesimulator/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/x86/libogg.a +0 -0
- package/common/cpp/audioapi/external/x86/libopus.a +0 -0
- package/common/cpp/audioapi/external/x86/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/x86/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/x86/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/x86/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libogg.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libopus.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libopusfile.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libvorbis.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libvorbisenc.a +0 -0
- package/common/cpp/audioapi/external/x86_64/libvorbisfile.a +0 -0
- package/common/cpp/audioapi/libs/miniaudio/decoders/libopus/miniaudio_libopus.c +623 -0
- package/common/cpp/audioapi/libs/miniaudio/decoders/libopus/miniaudio_libopus.h +71 -0
- package/common/cpp/audioapi/libs/miniaudio/decoders/libvorbis/miniaudio_libvorbis.c +574 -0
- package/common/cpp/audioapi/libs/miniaudio/decoders/libvorbis/miniaudio_libvorbis.h +41 -0
- package/common/cpp/test/CMakeLists.txt +7 -0
- package/common/cpp/test/RunTests.sh +3 -8
- package/ios/audioapi/ios/core/AudioDecoder.mm +62 -51
- package/package.json +1 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
#define MINIAUDIO_IMPLEMENTATION
|
|
2
2
|
#import <audioapi/libs/miniaudio/miniaudio.h>
|
|
3
3
|
|
|
4
|
+
#include <audioapi/libs/miniaudio/decoders/libopus/miniaudio_libopus.h>
|
|
5
|
+
#include <audioapi/libs/miniaudio/decoders/libvorbis/miniaudio_libvorbis.h>
|
|
6
|
+
|
|
4
7
|
#include <audioapi/core/utils/AudioDecoder.h>
|
|
5
8
|
#include <audioapi/dsp/VectorMath.h>
|
|
6
9
|
#include <audioapi/libs/audio-stretch/stretch.h>
|
|
@@ -10,89 +13,97 @@
|
|
|
10
13
|
|
|
11
14
|
namespace audioapi {
|
|
12
15
|
|
|
16
|
+
// Decoding audio in fixed-size chunks because total frame count can't be
|
|
17
|
+
// determined in advance. Note: ma_decoder_get_length_in_pcm_frames() always
|
|
18
|
+
// returns 0 for Vorbis decoders.
|
|
19
|
+
std::vector<int16_t> AudioDecoder::readAllPcmFrames(ma_decoder &decoder, int numChannels, ma_uint64 &outFramesRead)
|
|
20
|
+
const
|
|
21
|
+
{
|
|
22
|
+
std::vector<int16_t> buffer;
|
|
23
|
+
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, CHUNK_SIZE, &tempFramesDecoded);
|
|
29
|
+
if (tempFramesDecoded == 0) {
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
buffer.insert(buffer.end(), temp, temp + 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) const
|
|
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
|
+
|
|
13
55
|
std::shared_ptr<AudioBus> AudioDecoder::decodeWithFilePath(const std::string &path) const
|
|
14
56
|
{
|
|
57
|
+
ma_decoding_backend_vtable *customBackends[] = {ma_decoding_backend_libvorbis, ma_decoding_backend_libopus};
|
|
58
|
+
|
|
15
59
|
ma_decoder decoder;
|
|
16
60
|
ma_decoder_config config = ma_decoder_config_init(ma_format_s16, numChannels_, static_cast<int>(sampleRate_));
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
NSLog(@"Failed to initialize decoder for file: %s", path.c_str());
|
|
61
|
+
config.ppCustomBackendVTables = customBackends;
|
|
62
|
+
config.customBackendCount = sizeof(customBackends) / sizeof(customBackends[0]);
|
|
20
63
|
|
|
64
|
+
if (ma_decoder_init_file(path.c_str(), &config, &decoder) != MA_SUCCESS) {
|
|
65
|
+
NSLog(@"Failed to initialize decoder for file: %s", path.c_str());
|
|
21
66
|
ma_decoder_uninit(&decoder);
|
|
22
|
-
|
|
23
67
|
return nullptr;
|
|
24
68
|
}
|
|
25
69
|
|
|
26
|
-
ma_uint64
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
std::vector<int16_t> buffer(totalFrameCount * numChannels_);
|
|
30
|
-
|
|
31
|
-
ma_uint64 framesDecoded;
|
|
32
|
-
ma_decoder_read_pcm_frames(&decoder, buffer.data(), totalFrameCount, &framesDecoded);
|
|
33
|
-
if (framesDecoded == 0) {
|
|
70
|
+
ma_uint64 framesRead = 0;
|
|
71
|
+
auto buffer = readAllPcmFrames(decoder, numChannels_, framesRead);
|
|
72
|
+
if (framesRead == 0) {
|
|
34
73
|
NSLog(@"Failed to decode");
|
|
35
|
-
|
|
36
74
|
ma_decoder_uninit(&decoder);
|
|
37
75
|
return nullptr;
|
|
38
76
|
}
|
|
39
77
|
|
|
40
|
-
auto outputFrames = buffer.size() / numChannels_;
|
|
41
|
-
auto audioBus = std::make_shared<AudioBus>(outputFrames, numChannels_, sampleRate_);
|
|
42
|
-
|
|
43
|
-
for (int i = 0; i < numChannels_; ++i) {
|
|
44
|
-
auto channelData = audioBus->getChannel(i)->getData();
|
|
45
|
-
for (int j = 0; j < outputFrames; ++j) {
|
|
46
|
-
channelData[j] = int16ToFloat(buffer[j * numChannels_ + i]);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
78
|
ma_decoder_uninit(&decoder);
|
|
51
|
-
|
|
52
|
-
return audioBus;
|
|
79
|
+
return makeAudioBusFromInt16Buffer(buffer, numChannels_, sampleRate_);
|
|
53
80
|
}
|
|
54
81
|
|
|
55
82
|
std::shared_ptr<AudioBus> AudioDecoder::decodeWithMemoryBlock(const void *data, size_t size) const
|
|
56
83
|
{
|
|
84
|
+
ma_decoding_backend_vtable *customBackends[] = {ma_decoding_backend_libvorbis, ma_decoding_backend_libopus};
|
|
85
|
+
|
|
57
86
|
ma_decoder decoder;
|
|
58
87
|
ma_decoder_config config = ma_decoder_config_init(ma_format_s16, numChannels_, static_cast<int>(sampleRate_));
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
NSLog(@"Failed to initialize decoder for memory block");
|
|
88
|
+
config.ppCustomBackendVTables = customBackends;
|
|
89
|
+
config.customBackendCount = sizeof(customBackends) / sizeof(customBackends[0]);
|
|
62
90
|
|
|
91
|
+
if (ma_decoder_init_memory(data, size, &config, &decoder) != MA_SUCCESS) {
|
|
92
|
+
NSLog(@"Failed to initialize decoder for memory block");
|
|
63
93
|
ma_decoder_uninit(&decoder);
|
|
64
|
-
|
|
65
94
|
return nullptr;
|
|
66
95
|
}
|
|
67
96
|
|
|
68
|
-
ma_uint64
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
std::vector<int16_t> buffer(totalFrameCount * numChannels_);
|
|
72
|
-
|
|
73
|
-
ma_uint64 framesDecoded;
|
|
74
|
-
ma_decoder_read_pcm_frames(&decoder, buffer.data(), totalFrameCount, &framesDecoded);
|
|
75
|
-
|
|
76
|
-
if (framesDecoded == 0) {
|
|
97
|
+
ma_uint64 framesRead = 0;
|
|
98
|
+
auto buffer = readAllPcmFrames(decoder, numChannels_, framesRead);
|
|
99
|
+
if (framesRead == 0) {
|
|
77
100
|
NSLog(@"Failed to decode");
|
|
78
|
-
|
|
79
101
|
ma_decoder_uninit(&decoder);
|
|
80
102
|
return nullptr;
|
|
81
103
|
}
|
|
82
104
|
|
|
83
|
-
auto outputFrames = buffer.size() / numChannels_;
|
|
84
|
-
auto audioBus = std::make_shared<AudioBus>(outputFrames, numChannels_, sampleRate_);
|
|
85
|
-
|
|
86
|
-
for (int i = 0; i < numChannels_; ++i) {
|
|
87
|
-
auto channelData = audioBus->getChannel(i)->getData();
|
|
88
|
-
for (int j = 0; j < outputFrames; ++j) {
|
|
89
|
-
channelData[j] = int16ToFloat(buffer[j * numChannels_ + i]);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
105
|
ma_decoder_uninit(&decoder);
|
|
94
|
-
|
|
95
|
-
return audioBus;
|
|
106
|
+
return makeAudioBusFromInt16Buffer(buffer, numChannels_, sampleRate_);
|
|
96
107
|
}
|
|
97
108
|
|
|
98
109
|
std::shared_ptr<AudioBus> AudioDecoder::decodeWithPCMInBase64(const std::string &data, float playbackSpeed) const
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-audio-api",
|
|
3
|
-
"version": "0.7.1-nightly-
|
|
3
|
+
"version": "0.7.1-nightly-4d86c14-20250811",
|
|
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"
|