react-native-audio-api 0.4.11 → 0.4.12-beta.2

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.
Files changed (128) hide show
  1. package/RNAudioAPI.podspec +11 -1
  2. package/android/CMakeLists.txt +9 -48
  3. package/android/src/main/cpp/audioapi/CMakeLists.txt +44 -0
  4. package/android/src/main/cpp/{AudioAPIModule.cpp → audioapi/android/AudioAPIModule.cpp} +1 -4
  5. package/android/src/main/cpp/{AudioAPIModule.h → audioapi/android/AudioAPIModule.h} +2 -1
  6. package/android/src/main/cpp/{OnLoad.cpp → audioapi/android/OnLoad.cpp} +2 -1
  7. package/android/src/main/cpp/{core → audioapi/android/core}/AudioDecoder.cpp +5 -5
  8. package/android/src/main/cpp/{core → audioapi/android/core}/AudioPlayer.cpp +5 -7
  9. package/android/src/main/cpp/{core → audioapi/android/core}/AudioPlayer.h +1 -0
  10. package/android/src/main/cpp/{libs → audioapi/android/libs}/pffft.c +2 -2
  11. package/android/src/main/java/com/swmansion/audioapi/AudioAPIPackage.kt +1 -0
  12. package/common/cpp/{installer → audioapi}/AudioAPIModuleInstaller.h +9 -7
  13. package/common/cpp/{HostObjects → audioapi/HostObjects}/AnalyserNodeHostObject.h +3 -3
  14. package/common/cpp/{HostObjects → audioapi/HostObjects}/AudioBufferHostObject.h +3 -3
  15. package/common/cpp/{HostObjects → audioapi/HostObjects}/AudioBufferSourceNodeHostObject.h +6 -7
  16. package/common/cpp/{HostObjects → audioapi/HostObjects}/AudioContextHostObject.h +3 -3
  17. package/common/cpp/{HostObjects → audioapi/HostObjects}/AudioDestinationNodeHostObject.h +3 -3
  18. package/common/cpp/{HostObjects → audioapi/HostObjects}/AudioNodeHostObject.h +3 -3
  19. package/common/cpp/{HostObjects → audioapi/HostObjects}/AudioParamHostObject.h +3 -3
  20. package/common/cpp/{HostObjects → audioapi/HostObjects}/AudioScheduledSourceNodeHostObject.h +3 -3
  21. package/common/cpp/{HostObjects → audioapi/HostObjects}/BaseAudioContextHostObject.h +21 -14
  22. package/common/cpp/{HostObjects → audioapi/HostObjects}/BiquadFilterNodeHostObject.h +4 -4
  23. package/common/cpp/{HostObjects → audioapi/HostObjects}/GainNodeHostObject.h +6 -6
  24. package/common/cpp/{HostObjects → audioapi/HostObjects}/OscillatorNodeHostObject.h +5 -5
  25. package/common/cpp/{HostObjects → audioapi/HostObjects}/PeriodicWaveHostObject.h +2 -2
  26. package/common/cpp/{HostObjects → audioapi/HostObjects}/StereoPannerNodeHostObject.h +4 -4
  27. package/common/cpp/audioapi/HostObjects/StretcherNodeHostObject.h +35 -0
  28. package/common/cpp/{core → audioapi/core}/AudioContext.cpp +6 -6
  29. package/common/cpp/{core → audioapi/core}/AudioContext.h +2 -2
  30. package/common/cpp/{core → audioapi/core}/AudioNode.cpp +14 -12
  31. package/common/cpp/{core → audioapi/core}/AudioNode.h +9 -6
  32. package/common/cpp/{core → audioapi/core}/AudioParam.cpp +3 -4
  33. package/common/cpp/{core → audioapi/core}/AudioParam.h +3 -3
  34. package/common/cpp/{core → audioapi/core}/BaseAudioContext.cpp +20 -16
  35. package/common/cpp/{core → audioapi/core}/BaseAudioContext.h +6 -3
  36. package/common/cpp/{core → audioapi/core/analysis}/AnalyserNode.cpp +6 -10
  37. package/common/cpp/{core → audioapi/core/analysis}/AnalyserNode.h +4 -3
  38. package/common/cpp/{core → audioapi/core/destinations}/AudioDestinationNode.cpp +6 -6
  39. package/common/cpp/{core → audioapi/core/destinations}/AudioDestinationNode.h +2 -2
  40. package/common/cpp/{core → audioapi/core/effects}/BiquadFilterNode.cpp +4 -4
  41. package/common/cpp/{core → audioapi/core/effects}/BiquadFilterNode.h +4 -4
  42. package/common/cpp/{core → audioapi/core/effects}/GainNode.cpp +4 -4
  43. package/common/cpp/{core → audioapi/core/effects}/GainNode.h +3 -3
  44. package/common/cpp/{core → audioapi/core/effects}/PeriodicWave.cpp +4 -2
  45. package/common/cpp/{core → audioapi/core/effects}/PeriodicWave.h +2 -4
  46. package/common/cpp/{core → audioapi/core/effects}/StereoPannerNode.cpp +5 -7
  47. package/common/cpp/{core → audioapi/core/effects}/StereoPannerNode.h +4 -3
  48. package/common/cpp/audioapi/core/effects/StretcherNode.cpp +94 -0
  49. package/common/cpp/audioapi/core/effects/StretcherNode.h +35 -0
  50. package/common/cpp/{core → audioapi/core/sources}/AudioBuffer.cpp +3 -3
  51. package/common/cpp/{core → audioapi/core/sources}/AudioBufferSourceNode.cpp +8 -11
  52. package/common/cpp/{core → audioapi/core/sources}/AudioBufferSourceNode.h +5 -3
  53. package/common/cpp/{core → audioapi/core/sources}/AudioScheduledSourceNode.cpp +6 -8
  54. package/common/cpp/{core → audioapi/core/sources}/AudioScheduledSourceNode.h +3 -2
  55. package/common/cpp/{core → audioapi/core/sources}/OscillatorNode.cpp +4 -4
  56. package/common/cpp/{core → audioapi/core/sources}/OscillatorNode.h +5 -5
  57. package/common/cpp/{core → audioapi/core/utils}/AudioArray.cpp +2 -4
  58. package/common/cpp/{core → audioapi/core/utils}/AudioBus.cpp +12 -7
  59. package/common/cpp/{core → audioapi/core/utils}/AudioBus.h +5 -2
  60. package/common/cpp/{core → audioapi/core/utils}/AudioNodeManager.cpp +3 -4
  61. package/common/cpp/{core → audioapi/core/utils}/ParamChangeEvent.cpp +1 -3
  62. package/common/cpp/{core → audioapi/core/utils}/ParamChangeEvent.h +3 -1
  63. package/common/cpp/{utils → audioapi/dsp}/AudioUtils.cpp +1 -1
  64. package/common/cpp/{utils → audioapi/dsp}/FFTFrame.cpp +1 -10
  65. package/common/cpp/{utils → audioapi/dsp}/FFTFrame.h +4 -3
  66. package/common/cpp/{utils → audioapi/dsp}/VectorMath.cpp +2 -5
  67. package/common/cpp/{utils → audioapi/dsp}/VectorMath.h +2 -0
  68. package/common/cpp/{jsi → audioapi/jsi}/JsiHostObject.cpp +1 -1
  69. package/common/cpp/{jsi → audioapi/jsi}/JsiHostObject.h +2 -2
  70. package/common/cpp/{jsi → audioapi/jsi}/JsiPromise.cpp +2 -6
  71. package/common/cpp/{jsi → audioapi/jsi}/RuntimeAwareCache.h +2 -3
  72. package/common/cpp/{jsi → audioapi/jsi}/RuntimeLifecycleMonitor.cpp +1 -5
  73. package/common/cpp/{jsi → audioapi/jsi}/RuntimeLifecycleMonitor.h +3 -0
  74. package/common/cpp/audioapi/libs/dsp/common.h +47 -0
  75. package/common/cpp/audioapi/libs/dsp/delay.h +717 -0
  76. package/common/cpp/audioapi/libs/dsp/fft.h +523 -0
  77. package/common/cpp/audioapi/libs/dsp/perf.h +84 -0
  78. package/common/cpp/audioapi/libs/dsp/spectral.h +496 -0
  79. package/common/cpp/audioapi/libs/dsp/windows.h +219 -0
  80. package/common/cpp/audioapi/libs/signalsmith-stretch.h +637 -0
  81. package/ios/{AudioAPIModule.mm → audioapi/ios/AudioAPIModule.mm} +1 -1
  82. package/ios/{core → audioapi/ios/core}/AudioDecoder.mm +4 -4
  83. package/ios/{core → audioapi/ios/core}/AudioPlayer.m +3 -3
  84. package/ios/{core → audioapi/ios/core}/IOSAudioPlayer.mm +4 -4
  85. package/lib/module/core/BaseAudioContext.js +4 -0
  86. package/lib/module/core/BaseAudioContext.js.map +1 -1
  87. package/lib/module/core/StretcherNode.js +12 -0
  88. package/lib/module/core/StretcherNode.js.map +1 -0
  89. package/lib/module/index.js +1 -0
  90. package/lib/module/index.js.map +1 -1
  91. package/lib/module/index.web.js +1 -1
  92. package/lib/module/index.web.js.map +1 -1
  93. package/lib/typescript/core/BaseAudioContext.d.ts +2 -0
  94. package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -1
  95. package/lib/typescript/core/StretcherNode.d.ts +10 -0
  96. package/lib/typescript/core/StretcherNode.d.ts.map +1 -0
  97. package/lib/typescript/index.d.ts +1 -0
  98. package/lib/typescript/index.d.ts.map +1 -1
  99. package/lib/typescript/index.web.d.ts +1 -1
  100. package/lib/typescript/index.web.d.ts.map +1 -1
  101. package/lib/typescript/interfaces.d.ts +5 -0
  102. package/lib/typescript/interfaces.d.ts.map +1 -1
  103. package/package.json +6 -6
  104. package/src/core/BaseAudioContext.ts +5 -0
  105. package/src/core/StretcherNode.ts +15 -0
  106. package/src/index.ts +1 -0
  107. package/src/index.web.ts +1 -0
  108. package/src/interfaces.ts +6 -0
  109. package/common/cpp/installer/AudioAPIModuleInstaller.cpp +0 -49
  110. /package/android/src/main/cpp/{libs → audioapi/android/libs}/pffft.h +0 -0
  111. /package/common/cpp/{core → audioapi/core}/Constants.h +0 -0
  112. /package/common/cpp/{core → audioapi/core/sources}/AudioBuffer.h +0 -0
  113. /package/common/cpp/{types → audioapi/core/types}/BiquadFilterType.h +0 -0
  114. /package/common/cpp/{types → audioapi/core/types}/ChannelCountMode.h +0 -0
  115. /package/common/cpp/{types → audioapi/core/types}/ChannelInterpretation.h +0 -0
  116. /package/common/cpp/{types → audioapi/core/types}/ContextState.h +0 -0
  117. /package/common/cpp/{types → audioapi/core/types}/OscillatorType.h +0 -0
  118. /package/common/cpp/{types → audioapi/core/types}/ParamChangeEventType.h +0 -0
  119. /package/common/cpp/{core → audioapi/core/utils}/AudioArray.h +0 -0
  120. /package/common/cpp/{core → audioapi/core/utils}/AudioDecoder.h +0 -0
  121. /package/common/cpp/{core → audioapi/core/utils}/AudioNodeManager.h +0 -0
  122. /package/common/cpp/{utils → audioapi/core/utils}/Locker.h +0 -0
  123. /package/common/cpp/{utils → audioapi/dsp}/AudioUtils.h +0 -0
  124. /package/common/cpp/{jsi → audioapi/jsi}/JsiPromise.h +0 -0
  125. /package/common/cpp/{libs → audioapi/libs}/miniaudio.h +0 -0
  126. /package/ios/{AudioAPIModule.h → audioapi/ios/AudioAPIModule.h} +0 -0
  127. /package/ios/{core → audioapi/ios/core}/AudioPlayer.h +0 -0
  128. /package/ios/{core → audioapi/ios/core}/IOSAudioPlayer.h +0 -0
@@ -1,14 +1,14 @@
1
1
  #pragma once
2
2
 
3
+ #include <audioapi/core/AudioParam.h>
4
+ #include <audioapi/core/sources/AudioScheduledSourceNode.h>
5
+ #include <audioapi/core/types/OscillatorType.h>
6
+ #include <audioapi/core/effects/PeriodicWave.h>
7
+
3
8
  #include <cmath>
4
9
  #include <memory>
5
10
  #include <string>
6
11
 
7
- #include "AudioParam.h"
8
- #include "AudioScheduledSourceNode.h"
9
- #include "OscillatorType.h"
10
- #include "PeriodicWave.h"
11
-
12
12
  namespace audioapi {
13
13
 
14
14
  class AudioBus;
@@ -1,7 +1,5 @@
1
- #include <algorithm>
2
-
3
- #include "AudioArray.h"
4
- #include "VectorMath.h"
1
+ #include <audioapi/core/utils/AudioArray.h>
2
+ #include <audioapi/dsp/VectorMath.h>
5
3
 
6
4
  namespace audioapi {
7
5
 
@@ -1,10 +1,7 @@
1
- #include <algorithm>
2
-
3
- #include "AudioArray.h"
4
- #include "AudioBus.h"
5
- #include "BaseAudioContext.h"
6
- #include "Constants.h"
7
- #include "VectorMath.h"
1
+ #include <audioapi/core/Constants.h>
2
+ #include <audioapi/core/utils/AudioArray.h>
3
+ #include <audioapi/core/utils/AudioBus.h>
4
+ #include <audioapi/dsp/VectorMath.h>
8
5
 
9
6
  // Implementation of channel summing/mixing is based on the WebKit approach,
10
7
  // source:
@@ -119,6 +116,14 @@ AudioArray *AudioBus::getChannelByType(int channelType) const {
119
116
  }
120
117
  }
121
118
 
119
+ AudioArray &AudioBus::operator[](size_t index) {
120
+ return *channels_[index];
121
+ }
122
+
123
+ const AudioArray &AudioBus::operator[](size_t index) const {
124
+ return *channels_[index];
125
+ }
126
+
122
127
  /**
123
128
  * Public interfaces - audio processing and setters
124
129
  */
@@ -1,12 +1,12 @@
1
1
  #pragma once
2
2
 
3
+ #include <audioapi/core/types/ChannelInterpretation.h>
4
+
3
5
  #include <algorithm>
4
6
  #include <memory>
5
7
  #include <vector>
6
8
  #include <cstddef>
7
9
 
8
- #include "ChannelInterpretation.h"
9
-
10
10
  namespace audioapi {
11
11
 
12
12
  class BaseAudioContext;
@@ -34,6 +34,9 @@ class AudioBus {
34
34
  [[nodiscard]] AudioArray *getChannel(int index) const;
35
35
  [[nodiscard]] AudioArray *getChannelByType(int channelType) const;
36
36
 
37
+ AudioArray &operator[](size_t index);
38
+ const AudioArray &operator[](size_t index) const;
39
+
37
40
  void normalize();
38
41
  void scale(float value);
39
42
  [[nodiscard]] float maxAbsValue() const;
@@ -1,7 +1,6 @@
1
-
2
- #include "AudioNodeManager.h"
3
- #include "AudioNode.h"
4
- #include "Locker.h"
1
+ #include <audioapi/core/AudioNode.h>
2
+ #include <audioapi/core/utils/AudioNodeManager.h>
3
+ #include <audioapi/core/utils/Locker.h>
5
4
 
6
5
  namespace audioapi {
7
6
 
@@ -1,6 +1,4 @@
1
- #include "ParamChangeEvent.h"
2
-
3
- #include <utility>
1
+ #include <audioapi/core/utils/ParamChangeEvent.h>
4
2
 
5
3
  namespace audioapi {
6
4
 
@@ -1,8 +1,10 @@
1
1
  #pragma once
2
2
 
3
+ #include <audioapi/core/types/ParamChangeEventType.h>
4
+
3
5
  #include <functional>
4
6
  #include <memory>
5
- #include "ParamChangeEventType.h"
7
+ #include <utility>
6
8
 
7
9
  namespace audioapi {
8
10
 
@@ -1,4 +1,4 @@
1
- #include "AudioUtils.h"
1
+ #include <audioapi/dsp/AudioUtils.h>
2
2
 
3
3
  namespace audioapi::AudioUtils {
4
4
  size_t timeToSampleFrame(double time, float sampleRate) {
@@ -1,13 +1,4 @@
1
- #include "FFTFrame.h"
2
-
3
- #if defined(HAVE_ACCELERATE)
4
- #include <Accelerate/Accelerate.h>
5
- #endif
6
-
7
- #if defined(ANDROID)
8
- #include <pffft.h>
9
- #include <complex>
10
- #endif
1
+ #include <audioapi/dsp/FFTFrame.h>
11
2
 
12
3
  namespace audioapi {
13
4
  #if defined(HAVE_ACCELERATE)
@@ -28,19 +28,20 @@
28
28
 
29
29
  #pragma once
30
30
 
31
+ #include <audioapi/dsp/VectorMath.h>
32
+
31
33
  #include <algorithm>
32
34
  #include <cmath>
33
35
  #include <utility>
34
36
  #include <unordered_map>
35
-
36
- #include "VectorMath.h"
37
+ #include <complex>
37
38
 
38
39
  #if defined(HAVE_ACCELERATE)
39
40
  #include <Accelerate/Accelerate.h>
40
41
  #endif
41
42
 
42
43
  #if defined(ANDROID)
43
- #include <pffft.h>
44
+ #include <audioapi/android/libs/pffft.h>
44
45
  #endif
45
46
 
46
47
  namespace audioapi {
@@ -23,8 +23,8 @@
23
23
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
24
  */
25
25
 
26
- #include "VectorMath.h"
27
- #include "AudioUtils.h"
26
+ #include <audioapi/dsp/AudioUtils.h>
27
+ #include <audioapi/dsp/VectorMath.h>
28
28
 
29
29
  #if defined(HAVE_ACCELERATE)
30
30
  #include <Accelerate/Accelerate.h>
@@ -38,9 +38,6 @@
38
38
  #include <arm_neon.h>
39
39
  #endif
40
40
 
41
- #include <algorithm>
42
- #include <cmath>
43
-
44
41
  namespace audioapi::VectorMath {
45
42
 
46
43
  #if defined(HAVE_ACCELERATE)
@@ -29,6 +29,8 @@
29
29
  // will ideally be optimized.
30
30
 
31
31
  #include <cstddef>
32
+ #include <algorithm>
33
+ #include <cmath>
32
34
 
33
35
  namespace audioapi::VectorMath {
34
36
 
@@ -1,4 +1,4 @@
1
- #include "JsiHostObject.h"
1
+ #include <audioapi/jsi/JsiHostObject.h>
2
2
 
3
3
  namespace audioapi {
4
4
  JsiHostObject::JsiHostObject() {
@@ -1,5 +1,7 @@
1
1
  #pragma once
2
2
 
3
+ #include <audioapi/jsi/RuntimeAwareCache.h>
4
+
3
5
  #include <jsi/jsi.h>
4
6
  #include <map>
5
7
  #include <memory>
@@ -8,8 +10,6 @@
8
10
  #include <utility>
9
11
  #include <vector>
10
12
 
11
- #include "RuntimeAwareCache.h"
12
-
13
13
  #define JSI_HOST_FUNCTION(NAME) \
14
14
  jsi::Value NAME( \
15
15
  jsi::Runtime &runtime, \
@@ -1,8 +1,4 @@
1
- #include "JsiPromise.h"
2
-
3
- #include <ReactCommon/CallInvoker.h>
4
- #include <jsi/jsi.h>
5
- #include <functional>
1
+ #include <audioapi/jsi/JsiPromise.h>
6
2
 
7
3
  namespace audioapi {
8
4
 
@@ -37,7 +33,7 @@ jsi::Value PromiseVendor::createPromise(
37
33
 
38
34
  auto resolveWrapper =
39
35
  [resolve, &runtime, callInvoker](
40
- const std::function<jsi::Value(jsi::Runtime &)> resolver)
36
+ const std::function<jsi::Value(jsi::Runtime &)> &resolver)
41
37
  -> void {
42
38
  callInvoker->invokeAsync([resolve, &runtime, resolver]() -> void {
43
39
  auto valueShared = std::make_shared<jsi::Value>(resolver(runtime));
@@ -1,13 +1,12 @@
1
1
  #pragma once
2
2
 
3
- #include <jsi/jsi.h>
3
+ #include <audioapi/jsi/RuntimeLifecycleMonitor.h>
4
4
 
5
+ #include <jsi/jsi.h>
5
6
  #include <memory>
6
7
  #include <unordered_map>
7
8
  #include <utility>
8
9
 
9
- #include "RuntimeLifecycleMonitor.h"
10
-
11
10
  namespace audioapi {
12
11
 
13
12
  using namespace facebook;
@@ -1,8 +1,4 @@
1
- #include "RuntimeLifecycleMonitor.h"
2
-
3
- #include <unordered_map>
4
- #include <unordered_set>
5
- #include <utility>
1
+ #include <audioapi/jsi/RuntimeLifecycleMonitor.h>
6
2
 
7
3
  namespace audioapi {
8
4
 
@@ -2,6 +2,9 @@
2
2
 
3
3
  #include <jsi/jsi.h>
4
4
  #include <memory>
5
+ #include <unordered_map>
6
+ #include <unordered_set>
7
+ #include <utility>
5
8
 
6
9
  namespace audioapi {
7
10
 
@@ -0,0 +1,47 @@
1
+ #ifndef SIGNALSMITH_DSP_COMMON_H
2
+ #define SIGNALSMITH_DSP_COMMON_H
3
+
4
+ #if defined(__FAST_MATH__) && (__apple_build_version__ >= 16000000) && (__apple_build_version__ <= 16000099)
5
+ # error Apple Clang 16.0.0 generates incorrect SIMD for ARM. If you HAVE to use this version of Clang, turn off -ffast-math.
6
+ #endif
7
+
8
+ #ifndef M_PI
9
+ #define M_PI 3.14159265358979323846264338327950288
10
+ #endif
11
+
12
+ namespace signalsmith {
13
+ /** @defgroup Common Common
14
+ @brief Definitions and helper classes used by the rest of the library
15
+
16
+ @{
17
+ @file
18
+ */
19
+
20
+ #define SIGNALSMITH_DSP_VERSION_MAJOR 1
21
+ #define SIGNALSMITH_DSP_VERSION_MINOR 6
22
+ #define SIGNALSMITH_DSP_VERSION_PATCH 1
23
+ #define SIGNALSMITH_DSP_VERSION_STRING "1.6.1"
24
+
25
+ /** Version compatability check.
26
+ \code{.cpp}
27
+ static_assert(signalsmith::version(1, 4, 1), "version check");
28
+ \endcode
29
+ ... or use the equivalent `SIGNALSMITH_DSP_VERSION_CHECK`.
30
+ Major versions are not compatible with each other. Minor and patch versions are backwards-compatible.
31
+ */
32
+ constexpr bool versionCheck(int major, int minor, int patch=0) {
33
+ return major == SIGNALSMITH_DSP_VERSION_MAJOR
34
+ && (SIGNALSMITH_DSP_VERSION_MINOR > minor
35
+ || (SIGNALSMITH_DSP_VERSION_MINOR == minor && SIGNALSMITH_DSP_VERSION_PATCH >= patch));
36
+ }
37
+
38
+ /// Check the library version is compatible (semver).
39
+ #define SIGNALSMITH_DSP_VERSION_CHECK(major, minor, patch) \
40
+ static_assert(::signalsmith::versionCheck(major, minor, patch), "signalsmith library version is " SIGNALSMITH_DSP_VERSION_STRING);
41
+
42
+ /** @} */
43
+ } // signalsmith::
44
+ #else
45
+ // If we've already included it, check it's the same version
46
+ static_assert(SIGNALSMITH_DSP_VERSION_MAJOR == 1 && SIGNALSMITH_DSP_VERSION_MINOR == 6 && SIGNALSMITH_DSP_VERSION_PATCH == 1, "multiple versions of the Signalsmith DSP library");
47
+ #endif // include guard