react-native-audio-api 0.6.4-nightly-00c1dfe-20250704 → 0.6.4-nightly-ff577c8-20250704

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.
@@ -127,15 +127,18 @@ std::shared_ptr<AudioBus> AudioDecoder::decodeWithPCMInBase64(
127
127
  static_cast<int16_t>((uint8Data[i * 2 + 1] << 8) | uint8Data[i * 2]);
128
128
  }
129
129
 
130
- changePlaybackSpeedIfNeeded(buffer, framesDecoded, playbackSpeed);
130
+ changePlaybackSpeedIfNeeded(buffer, framesDecoded, 1, playbackSpeed);
131
131
  auto outputFrames = buffer.size();
132
132
 
133
133
  auto audioBus =
134
134
  std::make_shared<AudioBus>(outputFrames, numChannels_, sampleRate_);
135
- auto channelData = audioBus->getChannel(0)->getData();
135
+ auto leftChannelData = audioBus->getChannel(0)->getData();
136
+ auto rightChannelData = audioBus->getChannel(1)->getData();
136
137
 
137
138
  for (size_t i = 0; i < outputFrames; ++i) {
138
- channelData[i] = int16ToFloat(buffer[i]);
139
+ auto sample = int16ToFloat(buffer[i]);
140
+ leftChannelData[i] = sample;
141
+ rightChannelData[i] = sample;
139
142
  }
140
143
 
141
144
  return audioBus;
@@ -12,9 +12,6 @@ class AudioBus;
12
12
  class AudioDecoder {
13
13
  public:
14
14
  explicit AudioDecoder(float sampleRate): sampleRate_(sampleRate) {}
15
- ~AudioDecoder() {
16
- stretch_deinit(stretcher_);
17
- }
18
15
 
19
16
  [[nodiscard]] std::shared_ptr<AudioBus> decodeWithFilePath(const std::string &path) const;
20
17
  [[nodiscard]] std::shared_ptr<AudioBus> decodeWithMemoryBlock(const void *data, size_t size) const;
@@ -23,31 +20,31 @@ class AudioDecoder {
23
20
  private:
24
21
  float sampleRate_;
25
22
  int numChannels_ = 2;
26
- StretchHandle stretcher_ =
27
- stretch_init(static_cast<int>(sampleRate_ / 333.0f), static_cast<int>(sampleRate_ / 55.0f), 1, 0x1);
28
23
 
29
- void changePlaybackSpeedIfNeeded(std::vector<int16_t> &buffer, size_t framesDecoded, float playbackSpeed) const {
24
+ void changePlaybackSpeedIfNeeded(std::vector<int16_t> &buffer, size_t framesDecoded, int numChannels, float playbackSpeed) const {
30
25
  if (playbackSpeed == 1.0f) {
31
26
  return;
32
27
  }
33
28
 
34
- int maxOutputFrames = stretch_output_capacity(stretcher_, static_cast<int>(framesDecoded), 1 / playbackSpeed);
29
+ auto stretcher = stretch_init(static_cast<int>(sampleRate_ / 333.0f), static_cast<int>(sampleRate_ / 55.0f), numChannels, 0x1);
30
+
31
+ int maxOutputFrames = stretch_output_capacity(stretcher, static_cast<int>(framesDecoded), 1 / playbackSpeed);
35
32
  std::vector<int16_t> stretchedBuffer(maxOutputFrames);
36
33
 
37
34
  int outputFrames = stretch_samples(
38
- stretcher_,
35
+ stretcher,
39
36
  buffer.data(),
40
37
  static_cast<int>(framesDecoded),
41
38
  stretchedBuffer.data(),
42
39
  1 / playbackSpeed
43
40
  );
44
41
 
45
- outputFrames += stretch_flush(stretcher_, stretchedBuffer.data() + (outputFrames));
42
+ outputFrames += stretch_flush(stretcher, stretchedBuffer.data() + (outputFrames));
46
43
  stretchedBuffer.resize(outputFrames);
47
44
 
48
45
  buffer = stretchedBuffer;
49
46
 
50
- stretch_reset(stretcher_);
47
+ stretch_deinit(stretcher);
51
48
  }
52
49
 
53
50
  [[nodiscard]] static inline int16_t floatToInt16(float sample) {
@@ -107,14 +107,17 @@ std::shared_ptr<AudioBus> AudioDecoder::decodeWithPCMInBase64(const std::string
107
107
  buffer[i] = static_cast<int16_t>((uint8Data[i * 2 + 1] << 8) | uint8Data[i * 2]);
108
108
  }
109
109
 
110
- changePlaybackSpeedIfNeeded(buffer, framesDecoded, playbackSpeed);
110
+ changePlaybackSpeedIfNeeded(buffer, framesDecoded, 1, playbackSpeed);
111
111
  auto outputFrames = buffer.size();
112
112
 
113
113
  auto audioBus = std::make_shared<AudioBus>(outputFrames, numChannels_, sampleRate_);
114
- auto channelData = audioBus->getChannel(0)->getData();
114
+ auto leftChannelData = audioBus->getChannel(0)->getData();
115
+ auto rightChannelData = audioBus->getChannel(1)->getData();
115
116
 
116
117
  for (size_t i = 0; i < outputFrames; ++i) {
117
- channelData[i] = int16ToFloat(buffer[i]);
118
+ auto sample = int16ToFloat(buffer[i]);
119
+ leftChannelData[i] = sample;
120
+ rightChannelData[i] = sample;
118
121
  }
119
122
 
120
123
  return audioBus;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-audio-api",
3
- "version": "0.6.4-nightly-00c1dfe-20250704",
3
+ "version": "0.6.4-nightly-ff577c8-20250704",
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"