react-native-audio-api 0.10.0-nightly-98d2e0d-20251106 β 0.10.0
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/README.md +13 -11
- package/common/cpp/audioapi/core/sources/AudioScheduledSourceNode.cpp +3 -3
- package/common/cpp/test/src/AudioParamTest.cpp +1 -1
- package/common/cpp/test/src/ConstantSourceTest.cpp +1 -1
- package/common/cpp/test/src/GainTest.cpp +1 -1
- package/common/cpp/test/src/MockAudioEventHandlerRegistry.h +4 -4
- package/common/cpp/test/src/OscillatorTest.cpp +1 -1
- package/common/cpp/test/src/StereoPannerTest.cpp +1 -1
- package/common/cpp/test/src/biquad/BiquadFilterTest.h +1 -1
- package/package.json +1 -1
- package/common/cpp/test/src/AudioScheduledSourceTest.cpp +0 -134
package/README.md
CHANGED
|
@@ -19,19 +19,8 @@ check out the [Getting Started](https://docs.swmansion.com/react-native-audio-ap
|
|
|
19
19
|
|
|
20
20
|
### Planned
|
|
21
21
|
|
|
22
|
-
### <img src="https://img.shields.io/badge/Coming_in-0.9.0-orange" />
|
|
23
|
-
|
|
24
|
-
- **JS Audio Worklets V1 π**<br />
|
|
25
|
-
Receive events and data callbacks from audio thread to synchronize with UI on UI thread.
|
|
26
|
-
|
|
27
22
|
### <img src="https://img.shields.io/badge/Coming_in-x.x.x-orange" />
|
|
28
23
|
|
|
29
|
-
- **Convolver Node π**<br />
|
|
30
|
-
Realistic reverb and spatial effects in the browser by applying impulse responses. It makes audio sound like itβs being played in real spaces, from small rooms to cathedrals, or through hardware like amps and speakers
|
|
31
|
-
|
|
32
|
-
- **Decoding and utility modules π§**<br />
|
|
33
|
-
Decode and modify audio data without the need to create AudioContext first through a set of utility classes
|
|
34
|
-
|
|
35
24
|
- **DynamicCompressorNode γ½οΈ**<br />
|
|
36
25
|
Reduce the volume of loud sounds and boost quieter nodes to balance the audio signal, avoid clipping or distorted sounds
|
|
37
26
|
|
|
@@ -47,9 +36,22 @@ check out the [Getting Started](https://docs.swmansion.com/react-native-audio-ap
|
|
|
47
36
|
- **Noise Cancellation π¦**<br />
|
|
48
37
|
System-based active noise and echo cancellation support
|
|
49
38
|
|
|
39
|
+
### <a href="https://github.com/software-mansion/react-native-audio-api/releases/tag/0.10.0"><img src="https://img.shields.io/badge/Released_in-0.10.0-green" /></a>
|
|
40
|
+
|
|
41
|
+
- **Decoding and utility modules π§**<br />
|
|
42
|
+
Decode and modify audio data without the need to create AudioContext first through a set of utility classes
|
|
43
|
+
|
|
44
|
+
- **Convolver Node π**<br />
|
|
45
|
+
Realistic reverb and spatial effects in the browser by applying impulse responses. It makes audio sound like itβs being played in real spaces, from small rooms to cathedrals, or through hardware like amps and speakers
|
|
46
|
+
|
|
50
47
|
- **JS Audio Worklets V2 π**<br />
|
|
51
48
|
Customize the process pipeline with JS functions running on audio thread.
|
|
52
49
|
|
|
50
|
+
### <a href="https://github.com/software-mansion/react-native-audio-api/releases/tag/0.9.0"><img src="https://img.shields.io/badge/Released_in-0.9.0-green" /></a>
|
|
51
|
+
|
|
52
|
+
- **JS Audio Worklets V1 π**<br />
|
|
53
|
+
Receive events and data callbacks from audio thread to synchronize with UI on UI thread.
|
|
54
|
+
|
|
53
55
|
### <a href="https://github.com/software-mansion/react-native-audio-api/releases/tag/0.8.0"><img src="https://img.shields.io/badge/Released_in-0.8.0-green" /></a>
|
|
54
56
|
|
|
55
57
|
- **Decoding support for m4a/mp4/aac/ogg/opus π** <br />
|
|
@@ -71,7 +71,7 @@ void AudioScheduledSourceNode::updatePlaybackInfo(
|
|
|
71
71
|
auto sampleRate = context_->getSampleRate();
|
|
72
72
|
|
|
73
73
|
size_t firstFrame = context_->getCurrentSampleFrame();
|
|
74
|
-
size_t lastFrame = firstFrame + framesToProcess
|
|
74
|
+
size_t lastFrame = firstFrame + framesToProcess;
|
|
75
75
|
|
|
76
76
|
size_t startFrame =
|
|
77
77
|
std::max(dsp::timeToSampleFrame(startTime_, sampleRate), firstFrame);
|
|
@@ -100,7 +100,7 @@ void AudioScheduledSourceNode::updatePlaybackInfo(
|
|
|
100
100
|
? std::max(startFrame, firstFrame) - firstFrame
|
|
101
101
|
: 0;
|
|
102
102
|
nonSilentFramesToProcess =
|
|
103
|
-
std::max(std::min(lastFrame, stopFrame)
|
|
103
|
+
std::max(std::min(lastFrame, stopFrame), startFrame) - startFrame;
|
|
104
104
|
|
|
105
105
|
assert(startOffset <= framesToProcess);
|
|
106
106
|
assert(nonSilentFramesToProcess <= framesToProcess);
|
|
@@ -119,7 +119,7 @@ void AudioScheduledSourceNode::updatePlaybackInfo(
|
|
|
119
119
|
|
|
120
120
|
// stop will happen in this render quantum
|
|
121
121
|
// zero remaining frames after stop frame
|
|
122
|
-
if (stopFrame
|
|
122
|
+
if (stopFrame < lastFrame && stopFrame >= firstFrame) {
|
|
123
123
|
playbackState_ = PlaybackState::STOP_SCHEDULED;
|
|
124
124
|
startOffset = 0;
|
|
125
125
|
nonSilentFramesToProcess = stopFrame - firstFrame;
|
|
@@ -8,7 +8,7 @@ using namespace audioapi;
|
|
|
8
8
|
|
|
9
9
|
class AudioParamTest : public ::testing::Test {
|
|
10
10
|
protected:
|
|
11
|
-
std::shared_ptr<
|
|
11
|
+
std::shared_ptr<IAudioEventHandlerRegistry> eventRegistry;
|
|
12
12
|
std::unique_ptr<OfflineAudioContext> context;
|
|
13
13
|
static constexpr int sampleRate = 44100;
|
|
14
14
|
|
|
@@ -10,7 +10,7 @@ using namespace audioapi;
|
|
|
10
10
|
|
|
11
11
|
class ConstantSourceTest : public ::testing::Test {
|
|
12
12
|
protected:
|
|
13
|
-
std::shared_ptr<
|
|
13
|
+
std::shared_ptr<IAudioEventHandlerRegistry> eventRegistry;
|
|
14
14
|
std::unique_ptr<OfflineAudioContext> context;
|
|
15
15
|
static constexpr int sampleRate = 44100;
|
|
16
16
|
|
|
@@ -10,7 +10,7 @@ using namespace audioapi;
|
|
|
10
10
|
|
|
11
11
|
class GainTest : public ::testing::Test {
|
|
12
12
|
protected:
|
|
13
|
-
std::shared_ptr<
|
|
13
|
+
std::shared_ptr<IAudioEventHandlerRegistry> eventRegistry;
|
|
14
14
|
std::unique_ptr<OfflineAudioContext> context;
|
|
15
15
|
static constexpr int sampleRate = 44100;
|
|
16
16
|
|
|
@@ -17,8 +17,8 @@ class MockAudioEventHandlerRegistry : public IAudioEventHandlerRegistry {
|
|
|
17
17
|
MOCK_METHOD(void, unregisterHandler,
|
|
18
18
|
(const std::string &eventName, uint64_t listenerId), (override));
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
(const std::string &eventName, const EventMap &body));
|
|
22
|
-
|
|
23
|
-
(const std::string &eventName, uint64_t listenerId, const EventMap &body));
|
|
20
|
+
MOCK_METHOD(void, invokeHandlerWithEventBody,
|
|
21
|
+
(const std::string &eventName, const EventMap &body), (override));
|
|
22
|
+
MOCK_METHOD(void, invokeHandlerWithEventBody,
|
|
23
|
+
(const std::string &eventName, uint64_t listenerId, const EventMap &body), (override));
|
|
24
24
|
};
|
|
@@ -8,7 +8,7 @@ using namespace audioapi;
|
|
|
8
8
|
|
|
9
9
|
class OscillatorTest : public ::testing::Test {
|
|
10
10
|
protected:
|
|
11
|
-
std::shared_ptr<
|
|
11
|
+
std::shared_ptr<IAudioEventHandlerRegistry> eventRegistry;
|
|
12
12
|
std::unique_ptr<OfflineAudioContext> context;
|
|
13
13
|
static constexpr int sampleRate = 44100;
|
|
14
14
|
|
|
@@ -10,7 +10,7 @@ using namespace audioapi;
|
|
|
10
10
|
|
|
11
11
|
class StereoPannerTest : public ::testing::Test {
|
|
12
12
|
protected:
|
|
13
|
-
std::shared_ptr<
|
|
13
|
+
std::shared_ptr<IAudioEventHandlerRegistry> eventRegistry;
|
|
14
14
|
std::unique_ptr<OfflineAudioContext> context;
|
|
15
15
|
static constexpr int sampleRate = 44100;
|
|
16
16
|
|
|
@@ -14,7 +14,7 @@ static constexpr float tolerance = 0.0001f;
|
|
|
14
14
|
namespace audioapi {
|
|
15
15
|
class BiquadFilterTest : public ::testing::Test {
|
|
16
16
|
protected:
|
|
17
|
-
std::shared_ptr<
|
|
17
|
+
std::shared_ptr<IAudioEventHandlerRegistry> eventRegistry;
|
|
18
18
|
std::unique_ptr<OfflineAudioContext> context;
|
|
19
19
|
|
|
20
20
|
void SetUp() override {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-audio-api",
|
|
3
|
-
"version": "0.10.0
|
|
3
|
+
"version": "0.10.0",
|
|
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"
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
#include <audioapi/core/OfflineAudioContext.h>
|
|
2
|
-
#include <audioapi/core/destinations/AudioDestinationNode.h>
|
|
3
|
-
#include <audioapi/core/sources/AudioScheduledSourceNode.h>
|
|
4
|
-
#include <audioapi/core/utils/worklets/SafeIncludes.h>
|
|
5
|
-
#include <audioapi/utils/AudioBus.h>
|
|
6
|
-
#include <gtest/gtest.h>
|
|
7
|
-
#include <test/src/MockAudioEventHandlerRegistry.h>
|
|
8
|
-
|
|
9
|
-
using namespace audioapi;
|
|
10
|
-
static constexpr int SAMPLE_RATE = 44100;
|
|
11
|
-
static constexpr int RENDER_QUANTUM = 128;
|
|
12
|
-
static constexpr double RENDER_QUANTUM_TIME =
|
|
13
|
-
static_cast<double>(RENDER_QUANTUM) / SAMPLE_RATE;
|
|
14
|
-
|
|
15
|
-
class AudioScheduledSourceTest : public ::testing::Test {
|
|
16
|
-
protected:
|
|
17
|
-
std::shared_ptr<MockAudioEventHandlerRegistry> eventRegistry;
|
|
18
|
-
std::unique_ptr<OfflineAudioContext> context;
|
|
19
|
-
|
|
20
|
-
void SetUp() override {
|
|
21
|
-
eventRegistry = std::make_shared<MockAudioEventHandlerRegistry>();
|
|
22
|
-
context = std::make_unique<OfflineAudioContext>(
|
|
23
|
-
2, 5 * SAMPLE_RATE, SAMPLE_RATE, eventRegistry, RuntimeRegistry{});
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
class TestableAudioScheduledSourceNode : public AudioScheduledSourceNode {
|
|
28
|
-
public:
|
|
29
|
-
explicit TestableAudioScheduledSourceNode(BaseAudioContext *context)
|
|
30
|
-
: AudioScheduledSourceNode(context) {
|
|
31
|
-
isInitialized_ = true;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
void updatePlaybackInfo(
|
|
35
|
-
const std::shared_ptr<AudioBus> &processingBus,
|
|
36
|
-
int framesToProcess,
|
|
37
|
-
size_t &startOffset,
|
|
38
|
-
size_t &nonSilentFramesToProcess) {
|
|
39
|
-
AudioScheduledSourceNode::updatePlaybackInfo(
|
|
40
|
-
processingBus, framesToProcess, startOffset, nonSilentFramesToProcess);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
std::shared_ptr<AudioBus> processNode(const std::shared_ptr<AudioBus> &, int)
|
|
44
|
-
override {
|
|
45
|
-
return nullptr;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
PlaybackState getPlaybackState() const {
|
|
49
|
-
return playbackState_;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
void playFrames(int frames) {
|
|
53
|
-
size_t startOffset = 0;
|
|
54
|
-
size_t nonSilentFramesToProcess = 0;
|
|
55
|
-
auto processingBus =
|
|
56
|
-
std::make_shared<AudioBus>(128, 2, static_cast<float>(SAMPLE_RATE));
|
|
57
|
-
updatePlaybackInfo(
|
|
58
|
-
processingBus, frames, startOffset, nonSilentFramesToProcess);
|
|
59
|
-
context_->getDestination()->renderAudio(processingBus, frames);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
TEST_F(AudioScheduledSourceTest, IsUnscheduledStateSetCorrectly) {
|
|
64
|
-
auto sourceNode = TestableAudioScheduledSourceNode(context.get());
|
|
65
|
-
EXPECT_EQ(
|
|
66
|
-
sourceNode.getPlaybackState(),
|
|
67
|
-
AudioScheduledSourceNode::PlaybackState::UNSCHEDULED);
|
|
68
|
-
|
|
69
|
-
sourceNode.start(RENDER_QUANTUM_TIME);
|
|
70
|
-
EXPECT_NE(
|
|
71
|
-
sourceNode.getPlaybackState(),
|
|
72
|
-
AudioScheduledSourceNode::PlaybackState::UNSCHEDULED);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
TEST_F(AudioScheduledSourceTest, IsScheduledStateSetCorrectly) {
|
|
76
|
-
auto sourceNode = TestableAudioScheduledSourceNode(context.get());
|
|
77
|
-
sourceNode.start(RENDER_QUANTUM_TIME);
|
|
78
|
-
EXPECT_EQ(
|
|
79
|
-
sourceNode.getPlaybackState(),
|
|
80
|
-
AudioScheduledSourceNode::PlaybackState::SCHEDULED);
|
|
81
|
-
|
|
82
|
-
sourceNode.playFrames(RENDER_QUANTUM);
|
|
83
|
-
EXPECT_EQ(
|
|
84
|
-
sourceNode.getPlaybackState(),
|
|
85
|
-
AudioScheduledSourceNode::PlaybackState::SCHEDULED);
|
|
86
|
-
|
|
87
|
-
sourceNode.playFrames(1);
|
|
88
|
-
EXPECT_NE(
|
|
89
|
-
sourceNode.getPlaybackState(),
|
|
90
|
-
AudioScheduledSourceNode::PlaybackState::SCHEDULED);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
TEST_F(AudioScheduledSourceTest, IsPlayingStateSetCorrectly) {
|
|
94
|
-
auto sourceNode = TestableAudioScheduledSourceNode(context.get());
|
|
95
|
-
sourceNode.start(0);
|
|
96
|
-
sourceNode.stop(RENDER_QUANTUM_TIME);
|
|
97
|
-
|
|
98
|
-
sourceNode.playFrames(RENDER_QUANTUM);
|
|
99
|
-
EXPECT_EQ(
|
|
100
|
-
sourceNode.getPlaybackState(),
|
|
101
|
-
AudioScheduledSourceNode::PlaybackState::PLAYING);
|
|
102
|
-
|
|
103
|
-
sourceNode.playFrames(1);
|
|
104
|
-
EXPECT_NE(
|
|
105
|
-
sourceNode.getPlaybackState(),
|
|
106
|
-
AudioScheduledSourceNode::PlaybackState::PLAYING);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
TEST_F(AudioScheduledSourceTest, IsStopScheduledStateSetCorrectly) {
|
|
110
|
-
auto sourceNode = TestableAudioScheduledSourceNode(context.get());
|
|
111
|
-
sourceNode.start(0);
|
|
112
|
-
sourceNode.stop(RENDER_QUANTUM_TIME);
|
|
113
|
-
sourceNode.playFrames(1); // start playing
|
|
114
|
-
sourceNode.playFrames(RENDER_QUANTUM);
|
|
115
|
-
EXPECT_EQ(
|
|
116
|
-
sourceNode.getPlaybackState(),
|
|
117
|
-
AudioScheduledSourceNode::PlaybackState::STOP_SCHEDULED);
|
|
118
|
-
|
|
119
|
-
sourceNode.playFrames(1);
|
|
120
|
-
EXPECT_NE(
|
|
121
|
-
sourceNode.getPlaybackState(),
|
|
122
|
-
AudioScheduledSourceNode::PlaybackState::STOP_SCHEDULED);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
TEST_F(AudioScheduledSourceTest, IsFinishedStateSetCorrectly) {
|
|
126
|
-
auto sourceNode = TestableAudioScheduledSourceNode(context.get());
|
|
127
|
-
sourceNode.start(0);
|
|
128
|
-
sourceNode.stop(RENDER_QUANTUM_TIME);
|
|
129
|
-
sourceNode.playFrames(1); // start playing
|
|
130
|
-
|
|
131
|
-
sourceNode.playFrames(RENDER_QUANTUM);
|
|
132
|
-
sourceNode.playFrames(1);
|
|
133
|
-
EXPECT_TRUE(sourceNode.isFinished());
|
|
134
|
-
}
|