react-native-audio-api 0.1.0 → 0.3.0-rc1

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 (217) hide show
  1. package/README.md +10 -8
  2. package/RNAudioAPI.podspec +5 -0
  3. package/android/CMakeLists.txt +21 -10
  4. package/android/libs/fftw3/arm64-v8a/libfftw3.a +0 -0
  5. package/android/libs/fftw3/armeabi-v7a/libfftw3.a +0 -0
  6. package/android/libs/fftw3/x86/libfftw3.a +0 -0
  7. package/android/libs/fftw3/x86_64/libfftw3.a +0 -0
  8. package/android/libs/include/fftw3/fftw3.h +413 -0
  9. package/android/src/main/cpp/AudioPlayer/AudioPlayer.cpp +32 -2
  10. package/android/src/main/cpp/AudioPlayer/AudioPlayer.h +6 -2
  11. package/common/cpp/AudioAPIInstaller/AudioAPIInstallerHostObject.cpp +5 -3
  12. package/common/cpp/AudioAPIInstaller/AudioAPIInstallerHostObject.h +5 -1
  13. package/common/cpp/HostObjects/AudioBufferHostObject.cpp +6 -0
  14. package/common/cpp/HostObjects/AudioBufferSourceNodeHostObject.cpp +13 -1
  15. package/common/cpp/HostObjects/AudioContextHostObject.cpp +12 -149
  16. package/common/cpp/HostObjects/AudioContextHostObject.h +8 -14
  17. package/common/cpp/HostObjects/AudioNodeHostObject.cpp +0 -6
  18. package/common/cpp/HostObjects/BaseAudioContextHostObject.cpp +240 -0
  19. package/common/cpp/HostObjects/BaseAudioContextHostObject.h +41 -0
  20. package/common/cpp/HostObjects/BiquadFilterNodeHostObject.cpp +44 -0
  21. package/common/cpp/HostObjects/OscillatorNodeHostObject.cpp +21 -0
  22. package/common/cpp/HostObjects/OscillatorNodeHostObject.h +1 -0
  23. package/common/cpp/HostObjects/PeriodicWaveHostObject.cpp +33 -0
  24. package/common/cpp/HostObjects/PeriodicWaveHostObject.h +33 -0
  25. package/common/cpp/core/AudioArray.cpp +117 -0
  26. package/common/cpp/core/AudioArray.h +48 -0
  27. package/common/cpp/core/AudioBuffer.cpp +23 -80
  28. package/common/cpp/core/AudioBuffer.h +12 -13
  29. package/common/cpp/core/AudioBufferSourceNode.cpp +112 -25
  30. package/common/cpp/core/AudioBufferSourceNode.h +10 -6
  31. package/common/cpp/core/AudioBus.cpp +518 -0
  32. package/common/cpp/core/AudioBus.h +83 -0
  33. package/common/cpp/core/AudioContext.cpp +7 -77
  34. package/common/cpp/core/AudioContext.h +3 -60
  35. package/common/cpp/core/AudioDestinationNode.cpp +27 -15
  36. package/common/cpp/core/AudioDestinationNode.h +13 -5
  37. package/common/cpp/core/AudioNode.cpp +184 -22
  38. package/common/cpp/core/AudioNode.h +37 -37
  39. package/common/cpp/core/AudioNodeManager.cpp +75 -0
  40. package/common/cpp/core/AudioNodeManager.h +42 -0
  41. package/common/cpp/core/AudioParam.cpp +8 -11
  42. package/common/cpp/core/AudioParam.h +8 -8
  43. package/common/cpp/core/AudioScheduledSourceNode.cpp +19 -5
  44. package/common/cpp/core/AudioScheduledSourceNode.h +6 -2
  45. package/common/cpp/core/BaseAudioContext.cpp +191 -0
  46. package/common/cpp/core/BaseAudioContext.h +87 -0
  47. package/common/cpp/core/BiquadFilterNode.cpp +92 -69
  48. package/common/cpp/core/BiquadFilterNode.h +53 -57
  49. package/common/cpp/core/GainNode.cpp +12 -12
  50. package/common/cpp/core/GainNode.h +5 -3
  51. package/common/cpp/core/OscillatorNode.cpp +38 -29
  52. package/common/cpp/core/OscillatorNode.h +29 -69
  53. package/common/cpp/core/ParamChange.h +6 -6
  54. package/common/cpp/core/PeriodicWave.cpp +362 -0
  55. package/common/cpp/core/PeriodicWave.h +119 -0
  56. package/common/cpp/core/StereoPannerNode.cpp +31 -30
  57. package/common/cpp/core/StereoPannerNode.h +6 -6
  58. package/common/cpp/types/BiquadFilterType.h +19 -0
  59. package/common/cpp/types/ChannelCountMode.h +10 -0
  60. package/common/cpp/types/ChannelInterpretation.h +10 -0
  61. package/common/cpp/types/ContextState.h +10 -0
  62. package/common/cpp/types/OscillatorType.h +11 -0
  63. package/common/cpp/utils/FFTFrame.h +67 -0
  64. package/common/cpp/utils/JsiPromise.cpp +59 -0
  65. package/common/cpp/utils/JsiPromise.h +42 -0
  66. package/common/cpp/utils/Locker.h +49 -0
  67. package/common/cpp/utils/VectorMath.cpp +88 -3
  68. package/common/cpp/utils/VectorMath.h +7 -1
  69. package/common/cpp/utils/android/FFTFrame.cpp +23 -0
  70. package/common/cpp/utils/ios/FFTFrame.cpp +29 -0
  71. package/common/cpp/wrappers/AudioBufferSourceNodeWrapper.cpp +10 -0
  72. package/common/cpp/wrappers/AudioBufferSourceNodeWrapper.h +3 -2
  73. package/common/cpp/wrappers/AudioBufferWrapper.h +5 -5
  74. package/common/cpp/wrappers/AudioContextWrapper.cpp +7 -60
  75. package/common/cpp/wrappers/AudioContextWrapper.h +5 -26
  76. package/common/cpp/wrappers/AudioNodeWrapper.h +5 -5
  77. package/common/cpp/wrappers/AudioParamWrapper.h +4 -4
  78. package/common/cpp/wrappers/BaseAudioContextWrapper.cpp +83 -0
  79. package/common/cpp/wrappers/BaseAudioContextWrapper.h +50 -0
  80. package/common/cpp/wrappers/BiquadFilterNodeWrapper.cpp +9 -0
  81. package/common/cpp/wrappers/BiquadFilterNodeWrapper.h +9 -4
  82. package/common/cpp/wrappers/GainNodeWrapper.h +1 -1
  83. package/common/cpp/wrappers/OscillatorNodeWrapper.cpp +6 -0
  84. package/common/cpp/wrappers/OscillatorNodeWrapper.h +5 -2
  85. package/common/cpp/wrappers/PeriodicWaveWrapper.h +17 -0
  86. package/common/cpp/wrappers/StereoPannerNodeWrapper.h +1 -1
  87. package/ios/AudioAPIModule.h +20 -1
  88. package/ios/AudioAPIModule.mm +6 -4
  89. package/ios/AudioDecoder/AudioDecoder.h +17 -0
  90. package/ios/AudioDecoder/AudioDecoder.m +167 -0
  91. package/ios/AudioDecoder/IOSAudioDecoder.h +26 -0
  92. package/ios/AudioDecoder/IOSAudioDecoder.mm +40 -0
  93. package/ios/AudioPlayer/AudioPlayer.h +3 -2
  94. package/ios/AudioPlayer/AudioPlayer.m +14 -17
  95. package/ios/AudioPlayer/IOSAudioPlayer.h +7 -3
  96. package/ios/AudioPlayer/IOSAudioPlayer.mm +31 -7
  97. package/lib/module/core/AudioBuffer.js +37 -0
  98. package/lib/module/core/AudioBuffer.js.map +1 -0
  99. package/lib/module/core/AudioBufferSourceNode.js +28 -0
  100. package/lib/module/core/AudioBufferSourceNode.js.map +1 -0
  101. package/lib/module/core/AudioContext.js +10 -0
  102. package/lib/module/core/AudioContext.js.map +1 -0
  103. package/lib/module/core/AudioDestinationNode.js +7 -0
  104. package/lib/module/core/AudioDestinationNode.js.map +1 -0
  105. package/lib/module/core/AudioNode.js +22 -0
  106. package/lib/module/core/AudioNode.js.map +1 -0
  107. package/lib/module/core/AudioParam.js +35 -0
  108. package/lib/module/core/AudioParam.js.map +1 -0
  109. package/lib/module/core/AudioScheduledSourceNode.js +28 -0
  110. package/lib/module/core/AudioScheduledSourceNode.js.map +1 -0
  111. package/lib/module/core/BaseAudioContext.js +62 -0
  112. package/lib/module/core/BaseAudioContext.js.map +1 -0
  113. package/lib/module/core/BiquadFilterNode.js +25 -0
  114. package/lib/module/core/BiquadFilterNode.js.map +1 -0
  115. package/lib/module/core/GainNode.js +9 -0
  116. package/lib/module/core/GainNode.js.map +1 -0
  117. package/lib/module/core/OscillatorNode.js +24 -0
  118. package/lib/module/core/OscillatorNode.js.map +1 -0
  119. package/lib/module/core/PeriodicWave.js +8 -0
  120. package/lib/module/core/PeriodicWave.js.map +1 -0
  121. package/lib/module/core/StereoPannerNode.js +9 -0
  122. package/lib/module/core/StereoPannerNode.js.map +1 -0
  123. package/lib/module/core/types.js.map +1 -0
  124. package/lib/module/errors/IndexSizeError.js +8 -0
  125. package/lib/module/errors/IndexSizeError.js.map +1 -0
  126. package/lib/module/errors/InvalidAccessError.js +8 -0
  127. package/lib/module/errors/InvalidAccessError.js.map +1 -0
  128. package/lib/module/errors/InvalidStateError.js +8 -0
  129. package/lib/module/errors/InvalidStateError.js.map +1 -0
  130. package/lib/module/errors/RangeError.js +8 -0
  131. package/lib/module/errors/RangeError.js.map +1 -0
  132. package/lib/module/errors/index.js +5 -0
  133. package/lib/module/errors/index.js.map +1 -0
  134. package/lib/module/index.js +212 -15
  135. package/lib/module/index.js.map +1 -1
  136. package/lib/module/index.native.js +18 -0
  137. package/lib/module/index.native.js.map +1 -0
  138. package/lib/module/interfaces.js +2 -0
  139. package/lib/module/interfaces.js.map +1 -0
  140. package/lib/module/utils/resolveAudioSource.js +10 -0
  141. package/lib/module/utils/resolveAudioSource.js.map +1 -0
  142. package/lib/typescript/core/AudioBuffer.d.ts +12 -0
  143. package/lib/typescript/core/AudioBuffer.d.ts.map +1 -0
  144. package/lib/typescript/core/AudioBufferSourceNode.d.ts +12 -0
  145. package/lib/typescript/core/AudioBufferSourceNode.d.ts.map +1 -0
  146. package/lib/typescript/core/AudioContext.d.ts +6 -0
  147. package/lib/typescript/core/AudioContext.d.ts.map +1 -0
  148. package/lib/typescript/core/AudioDestinationNode.d.ts +7 -0
  149. package/lib/typescript/core/AudioDestinationNode.d.ts.map +1 -0
  150. package/lib/typescript/core/AudioNode.d.ts +16 -0
  151. package/lib/typescript/core/AudioNode.d.ts.map +1 -0
  152. package/lib/typescript/core/AudioParam.d.ts +14 -0
  153. package/lib/typescript/core/AudioParam.d.ts.map +1 -0
  154. package/lib/typescript/core/AudioScheduledSourceNode.d.ts +10 -0
  155. package/lib/typescript/core/AudioScheduledSourceNode.d.ts.map +1 -0
  156. package/lib/typescript/core/BaseAudioContext.d.ts +27 -0
  157. package/lib/typescript/core/BaseAudioContext.d.ts.map +1 -0
  158. package/lib/typescript/core/BiquadFilterNode.d.ts +16 -0
  159. package/lib/typescript/core/BiquadFilterNode.d.ts.map +1 -0
  160. package/lib/typescript/core/GainNode.d.ts +9 -0
  161. package/lib/typescript/core/GainNode.d.ts.map +1 -0
  162. package/lib/typescript/core/OscillatorNode.d.ts +15 -0
  163. package/lib/typescript/core/OscillatorNode.d.ts.map +1 -0
  164. package/lib/typescript/core/PeriodicWave.d.ts +5 -0
  165. package/lib/typescript/core/PeriodicWave.d.ts.map +1 -0
  166. package/lib/typescript/core/StereoPannerNode.d.ts +9 -0
  167. package/lib/typescript/core/StereoPannerNode.d.ts.map +1 -0
  168. package/lib/typescript/core/types.d.ts +15 -0
  169. package/lib/typescript/core/types.d.ts.map +1 -0
  170. package/lib/typescript/errors/IndexSizeError.d.ts +5 -0
  171. package/lib/typescript/errors/IndexSizeError.d.ts.map +1 -0
  172. package/lib/typescript/errors/InvalidAccessError.d.ts +5 -0
  173. package/lib/typescript/errors/InvalidAccessError.d.ts.map +1 -0
  174. package/lib/typescript/errors/InvalidStateError.d.ts +5 -0
  175. package/lib/typescript/errors/InvalidStateError.d.ts.map +1 -0
  176. package/lib/typescript/errors/RangeError.d.ts +5 -0
  177. package/lib/typescript/errors/RangeError.d.ts.map +1 -0
  178. package/lib/typescript/errors/index.d.ts +5 -0
  179. package/lib/typescript/errors/index.d.ts.map +1 -0
  180. package/lib/typescript/index.d.ts +88 -5
  181. package/lib/typescript/index.d.ts.map +1 -1
  182. package/lib/typescript/index.native.d.ts +14 -0
  183. package/lib/typescript/index.native.d.ts.map +1 -0
  184. package/lib/typescript/interfaces.d.ts +79 -0
  185. package/lib/typescript/interfaces.d.ts.map +1 -0
  186. package/lib/typescript/utils/resolveAudioSource.d.ts +3 -0
  187. package/lib/typescript/utils/resolveAudioSource.d.ts.map +1 -0
  188. package/package.json +4 -2
  189. package/src/core/AudioBuffer.ts +68 -0
  190. package/src/core/AudioBufferSourceNode.ts +35 -0
  191. package/src/core/AudioContext.ts +12 -0
  192. package/src/core/AudioDestinationNode.ts +9 -0
  193. package/src/core/AudioNode.ts +38 -0
  194. package/src/core/AudioParam.ts +55 -0
  195. package/src/core/AudioScheduledSourceNode.ts +43 -0
  196. package/src/core/BaseAudioContext.ts +108 -0
  197. package/src/core/BiquadFilterNode.ts +49 -0
  198. package/src/core/GainNode.ts +13 -0
  199. package/src/core/OscillatorNode.ts +37 -0
  200. package/src/core/PeriodicWave.ts +10 -0
  201. package/src/core/StereoPannerNode.ts +13 -0
  202. package/src/core/types.ts +33 -0
  203. package/src/errors/IndexSizeError.ts +8 -0
  204. package/src/errors/InvalidAccessError.ts +8 -0
  205. package/src/errors/InvalidStateError.ts +8 -0
  206. package/src/errors/RangeError.ts +8 -0
  207. package/src/errors/index.ts +4 -0
  208. package/src/index.native.ts +25 -0
  209. package/src/index.ts +380 -40
  210. package/src/interfaces.ts +121 -0
  211. package/src/modules/global.d.ts +3 -3
  212. package/src/utils/resolveAudioSource.ts +14 -0
  213. package/lib/module/types.js.map +0 -1
  214. package/lib/typescript/types.d.ts +0 -76
  215. package/lib/typescript/types.d.ts.map +0 -1
  216. package/src/types.ts +0 -108
  217. /package/lib/module/{types.js → core/types.js} +0 -0
package/README.md CHANGED
@@ -1,11 +1,5 @@
1
1
  <img src="./docs/assets/react-native-audio-api-gh-cover.png?v0.0.1" alt="React Native Audio API" width="100%">
2
2
 
3
- ### ⚠️ Pre-Alpha
4
-
5
- This library is at a very early stage of development. There are known performance issues and the library is not yet suitable for real production applications. We will be publishing the first alpha version of the library in the upcoming days, stay tuned! 🎶
6
-
7
- If you have questions about the library, our progress, plans or just want to say "hi!" you can reach us in our <a href="https://discord.swmansion.com" target="_blank" rel="noopener noreferrer">discord server</a>
8
-
9
3
  ### React Native Audio API
10
4
 
11
5
  `react-native-audio-api` provides system for controlling audio in React Native environment compatible with Web Audio API specification,
@@ -35,7 +29,15 @@ Our current coverage of Web Audio API specification can be found here: [Web Audi
35
29
 
36
30
  ## Examples
37
31
 
38
- The source code for the example application is under the [`/apps/common-app`](./apps/common-app/) directory. If you want to play with the API but don't feel like trying it on a real app, you can run the example project. Check [Example README](./apps/common-example/README.md) for installation instructions.
32
+ <div align="center">
33
+
34
+ <a href="https://www.youtube.com/watch?v=npALr9IIDkI" target="_blank" rel="noopener noreferrer">
35
+ <img src="./docs/assets/rnaa-example-01-thumbnail.png" width="640" />
36
+ </a>
37
+
38
+ </div>
39
+
40
+ The source code for the example application is under the [`/apps/common-app`](./apps/common-app/) directory. If you want to play with the API but don't feel like trying it on a real app, you can run the example project. Check [Example README](./apps/fabric-example/README.md) for installation instructions.
39
41
 
40
42
  ## Your feedback
41
43
 
@@ -57,4 +59,4 @@ This project has been built and is maintained thanks to the support from [Softwa
57
59
 
58
60
  ## react-native-audio-api is created by Software Mansion
59
61
 
60
- Since 2012 [Software Mansion](https://swmansion.com) is a software agency with experience in building web and mobile apps. We are Core React Native Contributors and experts in dealing with all kinds of React Native issues. We can help you build your next dream product – [Hire us](https://swmansion.com/contact/projects?utm_source=reanimated&utm_medium=readme).
62
+ Since 2012 [Software Mansion](https://swmansion.com) is a software agency with experience in building web and mobile apps. We are Core React Native Contributors and experts in dealing with all kinds of React Native issues. We can help you build your next dream product – [Hire us](https://swmansion.com/contact/projects?utm_source=audioapi&utm_medium=readme).
@@ -16,6 +16,11 @@ Pod::Spec.new do |s|
16
16
 
17
17
  s.source_files = "ios/**/*.{h,m,mm}", "common/cpp/**/*.{hpp,cpp,c,h}"
18
18
 
19
+ s.ios.frameworks = 'Accelerate'
20
+ s.xcconfig = {
21
+ 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) HAVE_ACCELERATE=1'
22
+ }
23
+
19
24
  # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
20
25
  # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
21
26
  if respond_to?(:install_modules_dependencies, true)
@@ -1,13 +1,8 @@
1
- cmake_minimum_required(VERSION 3.9.0)
1
+ cmake_minimum_required(VERSION 3.12.0)
2
2
  project(react-native-audio-api)
3
3
 
4
4
  set(CMAKE_VERBOSE_MAKEFILE ON)
5
- set(CMAKE_CXX_STANDARD 17)
6
-
7
- # Detect the operating system
8
- if(APPLE)
9
- set(HAVE_ACCELERATE TRUE)
10
- endif()
5
+ set(CMAKE_CXX_STANDARD 20)
11
6
 
12
7
  # Detect the processor and SIMD support
13
8
  if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
@@ -32,6 +27,7 @@ file(GLOB_RECURSE SOURCE_FILES
32
27
  "../common/cpp/HostObjects/*.h"
33
28
  "../common/cpp/utils/*.cpp"
34
29
  "../common/cpp/utils/*.h"
30
+ "../common/cpp/types/*.h"
35
31
  )
36
32
 
37
33
  add_library(react-native-audio-api SHARED ${SOURCE_FILES})
@@ -45,19 +41,34 @@ target_include_directories(
45
41
  "${REACT_NATIVE_DIR}/ReactCommon/jsi"
46
42
  "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/react/jni"
47
43
  "${REACT_NATIVE_DIR}/ReactAndroid/src/main/jni/third-party/folly"
44
+ "${CMAKE_CURRENT_SOURCE_DIR}/libs/include/fftw3"
48
45
  )
49
46
 
47
+ set(fftw3 ${CMAKE_CURRENT_SOURCE_DIR}/libs/fftw3/${ANDROID_ABI}/libfftw3.a)
48
+
50
49
  find_package(ReactAndroid REQUIRED CONFIG)
51
50
  find_package(fbjni REQUIRED CONFIG)
52
- find_package (oboe REQUIRED CONFIG)
51
+ find_package(oboe REQUIRED CONFIG)
53
52
 
54
53
  set(LINK_LIBRARIES
55
- ReactAndroid::reactnative
56
54
  ReactAndroid::jsi
57
55
  fbjni::fbjni
58
56
  android
59
57
  log
60
58
  oboe::oboe
59
+ ${fftw3}
61
60
  )
62
61
 
63
- target_link_libraries(react-native-audio-api ${LINK_LIBRARIES})
62
+ if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
63
+ set(RN_VERSION_LINK_LIBRARIES
64
+ ReactAndroid::reactnative
65
+ )
66
+ else()
67
+ set(RN_VERSION_LINK_LIBRARIES
68
+ ReactAndroid::folly_runtime
69
+ ReactAndroid::glog
70
+ ReactAndroid::reactnativejni
71
+ )
72
+ endif()
73
+
74
+ target_link_libraries(react-native-audio-api ${LINK_LIBRARIES} ${RN_VERSION_LINK_LIBRARIES})
@@ -0,0 +1,413 @@
1
+ /*
2
+ * Copyright (c) 2003, 2007-14 Matteo Frigo
3
+ * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
4
+ *
5
+ * The following statement of license applies *only* to this header file,
6
+ * and *not* to the other files distributed with FFTW or derived therefrom:
7
+ *
8
+ * Redistribution and use in source and binary forms, with or without
9
+ * modification, are permitted provided that the following conditions
10
+ * are met:
11
+ *
12
+ * 1. Redistributions of source code must retain the above copyright
13
+ * notice, this list of conditions and the following disclaimer.
14
+ *
15
+ * 2. Redistributions in binary form must reproduce the above copyright
16
+ * notice, this list of conditions and the following disclaimer in the
17
+ * documentation and/or other materials provided with the distribution.
18
+ *
19
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
20
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
25
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
27
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+ */
31
+
32
+ /***************************** NOTE TO USERS *********************************
33
+ *
34
+ * THIS IS A HEADER FILE, NOT A MANUAL
35
+ *
36
+ * If you want to know how to use FFTW, please read the manual,
37
+ * online at http://www.fftw.org/doc/ and also included with FFTW.
38
+ * For a quick start, see the manual's tutorial section.
39
+ *
40
+ * (Reading header files to learn how to use a library is a habit
41
+ * stemming from code lacking a proper manual. Arguably, it's a
42
+ * *bad* habit in most cases, because header files can contain
43
+ * interfaces that are not part of the public, stable API.)
44
+ *
45
+ ****************************************************************************/
46
+
47
+ #ifndef FFTW3_H
48
+ #define FFTW3_H
49
+
50
+ #include <stdio.h>
51
+
52
+ #ifdef __cplusplus
53
+ extern "C"
54
+ {
55
+ #endif /* __cplusplus */
56
+
57
+ /* If <complex.h> is included, use the C99 complex type. Otherwise
58
+ define a type bit-compatible with C99 complex */
59
+ #if !defined(FFTW_NO_Complex) && defined(_Complex_I) && defined(complex) && defined(I)
60
+ # define FFTW_DEFINE_COMPLEX(R, C) typedef R _Complex C
61
+ #else
62
+ # define FFTW_DEFINE_COMPLEX(R, C) typedef R C[2]
63
+ #endif
64
+
65
+ #define FFTW_CONCAT(prefix, name) prefix ## name
66
+ #define FFTW_MANGLE_DOUBLE(name) FFTW_CONCAT(fftw_, name)
67
+ #define FFTW_MANGLE_FLOAT(name) FFTW_CONCAT(fftwf_, name)
68
+ #define FFTW_MANGLE_LONG_DOUBLE(name) FFTW_CONCAT(fftwl_, name)
69
+ #define FFTW_MANGLE_QUAD(name) FFTW_CONCAT(fftwq_, name)
70
+
71
+ /* IMPORTANT: for Windows compilers, you should add a line
72
+ #define FFTW_DLL
73
+ here and in kernel/ifftw.h if you are compiling/using FFTW as a
74
+ DLL, in order to do the proper importing/exporting, or
75
+ alternatively compile with -DFFTW_DLL or the equivalent
76
+ command-line flag. This is not necessary under MinGW/Cygwin, where
77
+ libtool does the imports/exports automatically. */
78
+ #if defined(FFTW_DLL) && (defined(_WIN32) || defined(__WIN32__))
79
+ /* annoying Windows syntax for shared-library declarations */
80
+ # if defined(COMPILING_FFTW) /* defined in api.h when compiling FFTW */
81
+ # define FFTW_EXTERN extern __declspec(dllexport)
82
+ # else /* user is calling FFTW; import symbol */
83
+ # define FFTW_EXTERN extern __declspec(dllimport)
84
+ # endif
85
+ #else
86
+ # define FFTW_EXTERN extern
87
+ #endif
88
+
89
+ enum fftw_r2r_kind_do_not_use_me {
90
+ FFTW_R2HC=0, FFTW_HC2R=1, FFTW_DHT=2,
91
+ FFTW_REDFT00=3, FFTW_REDFT01=4, FFTW_REDFT10=5, FFTW_REDFT11=6,
92
+ FFTW_RODFT00=7, FFTW_RODFT01=8, FFTW_RODFT10=9, FFTW_RODFT11=10
93
+ };
94
+
95
+ struct fftw_iodim_do_not_use_me {
96
+ int n; /* dimension size */
97
+ int is; /* input stride */
98
+ int os; /* output stride */
99
+ };
100
+
101
+ #include <stddef.h> /* for ptrdiff_t */
102
+ struct fftw_iodim64_do_not_use_me {
103
+ ptrdiff_t n; /* dimension size */
104
+ ptrdiff_t is; /* input stride */
105
+ ptrdiff_t os; /* output stride */
106
+ };
107
+
108
+ typedef void (*fftw_write_char_func_do_not_use_me)(char c, void *);
109
+ typedef int (*fftw_read_char_func_do_not_use_me)(void *);
110
+
111
+ /*
112
+ huge second-order macro that defines prototypes for all API
113
+ functions. We expand this macro for each supported precision
114
+
115
+ X: name-mangling macro
116
+ R: real data type
117
+ C: complex data type
118
+ */
119
+
120
+ #define FFTW_DEFINE_API(X, R, C) \
121
+ \
122
+ FFTW_DEFINE_COMPLEX(R, C); \
123
+ \
124
+ typedef struct X(plan_s) *X(plan); \
125
+ \
126
+ typedef struct fftw_iodim_do_not_use_me X(iodim); \
127
+ typedef struct fftw_iodim64_do_not_use_me X(iodim64); \
128
+ \
129
+ typedef enum fftw_r2r_kind_do_not_use_me X(r2r_kind); \
130
+ \
131
+ typedef fftw_write_char_func_do_not_use_me X(write_char_func); \
132
+ typedef fftw_read_char_func_do_not_use_me X(read_char_func); \
133
+ \
134
+ FFTW_EXTERN void X(execute)(const X(plan) p); \
135
+ \
136
+ FFTW_EXTERN X(plan) X(plan_dft)(int rank, const int *n, \
137
+ C *in, C *out, int sign, unsigned flags); \
138
+ \
139
+ FFTW_EXTERN X(plan) X(plan_dft_1d)(int n, C *in, C *out, int sign, \
140
+ unsigned flags); \
141
+ FFTW_EXTERN X(plan) X(plan_dft_2d)(int n0, int n1, \
142
+ C *in, C *out, int sign, unsigned flags); \
143
+ FFTW_EXTERN X(plan) X(plan_dft_3d)(int n0, int n1, int n2, \
144
+ C *in, C *out, int sign, unsigned flags); \
145
+ \
146
+ FFTW_EXTERN X(plan) X(plan_many_dft)(int rank, const int *n, \
147
+ int howmany, \
148
+ C *in, const int *inembed, \
149
+ int istride, int idist, \
150
+ C *out, const int *onembed, \
151
+ int ostride, int odist, \
152
+ int sign, unsigned flags); \
153
+ \
154
+ FFTW_EXTERN X(plan) X(plan_guru_dft)(int rank, const X(iodim) *dims, \
155
+ int howmany_rank, \
156
+ const X(iodim) *howmany_dims, \
157
+ C *in, C *out, \
158
+ int sign, unsigned flags); \
159
+ FFTW_EXTERN X(plan) X(plan_guru_split_dft)(int rank, const X(iodim) *dims, \
160
+ int howmany_rank, \
161
+ const X(iodim) *howmany_dims, \
162
+ R *ri, R *ii, R *ro, R *io, \
163
+ unsigned flags); \
164
+ \
165
+ FFTW_EXTERN X(plan) X(plan_guru64_dft)(int rank, \
166
+ const X(iodim64) *dims, \
167
+ int howmany_rank, \
168
+ const X(iodim64) *howmany_dims, \
169
+ C *in, C *out, \
170
+ int sign, unsigned flags); \
171
+ FFTW_EXTERN X(plan) X(plan_guru64_split_dft)(int rank, \
172
+ const X(iodim64) *dims, \
173
+ int howmany_rank, \
174
+ const X(iodim64) *howmany_dims, \
175
+ R *ri, R *ii, R *ro, R *io, \
176
+ unsigned flags); \
177
+ \
178
+ FFTW_EXTERN void X(execute_dft)(const X(plan) p, C *in, C *out); \
179
+ FFTW_EXTERN void X(execute_split_dft)(const X(plan) p, R *ri, R *ii, \
180
+ R *ro, R *io); \
181
+ \
182
+ FFTW_EXTERN X(plan) X(plan_many_dft_r2c)(int rank, const int *n, \
183
+ int howmany, \
184
+ R *in, const int *inembed, \
185
+ int istride, int idist, \
186
+ C *out, const int *onembed, \
187
+ int ostride, int odist, \
188
+ unsigned flags); \
189
+ \
190
+ FFTW_EXTERN X(plan) X(plan_dft_r2c)(int rank, const int *n, \
191
+ R *in, C *out, unsigned flags); \
192
+ \
193
+ FFTW_EXTERN X(plan) X(plan_dft_r2c_1d)(int n,R *in,C *out,unsigned flags); \
194
+ FFTW_EXTERN X(plan) X(plan_dft_r2c_2d)(int n0, int n1, \
195
+ R *in, C *out, unsigned flags); \
196
+ FFTW_EXTERN X(plan) X(plan_dft_r2c_3d)(int n0, int n1, \
197
+ int n2, \
198
+ R *in, C *out, unsigned flags); \
199
+ \
200
+ \
201
+ FFTW_EXTERN X(plan) X(plan_many_dft_c2r)(int rank, const int *n, \
202
+ int howmany, \
203
+ C *in, const int *inembed, \
204
+ int istride, int idist, \
205
+ R *out, const int *onembed, \
206
+ int ostride, int odist, \
207
+ unsigned flags); \
208
+ \
209
+ FFTW_EXTERN X(plan) X(plan_dft_c2r)(int rank, const int *n, \
210
+ C *in, R *out, unsigned flags); \
211
+ \
212
+ FFTW_EXTERN X(plan) X(plan_dft_c2r_1d)(int n,C *in,R *out,unsigned flags); \
213
+ FFTW_EXTERN X(plan) X(plan_dft_c2r_2d)(int n0, int n1, \
214
+ C *in, R *out, unsigned flags); \
215
+ FFTW_EXTERN X(plan) X(plan_dft_c2r_3d)(int n0, int n1, \
216
+ int n2, \
217
+ C *in, R *out, unsigned flags); \
218
+ \
219
+ FFTW_EXTERN X(plan) X(plan_guru_dft_r2c)(int rank, const X(iodim) *dims, \
220
+ int howmany_rank, \
221
+ const X(iodim) *howmany_dims, \
222
+ R *in, C *out, \
223
+ unsigned flags); \
224
+ FFTW_EXTERN X(plan) X(plan_guru_dft_c2r)(int rank, const X(iodim) *dims, \
225
+ int howmany_rank, \
226
+ const X(iodim) *howmany_dims, \
227
+ C *in, R *out, \
228
+ unsigned flags); \
229
+ \
230
+ FFTW_EXTERN X(plan) X(plan_guru_split_dft_r2c)( \
231
+ int rank, const X(iodim) *dims, \
232
+ int howmany_rank, \
233
+ const X(iodim) *howmany_dims, \
234
+ R *in, R *ro, R *io, \
235
+ unsigned flags); \
236
+ FFTW_EXTERN X(plan) X(plan_guru_split_dft_c2r)( \
237
+ int rank, const X(iodim) *dims, \
238
+ int howmany_rank, \
239
+ const X(iodim) *howmany_dims, \
240
+ R *ri, R *ii, R *out, \
241
+ unsigned flags); \
242
+ \
243
+ FFTW_EXTERN X(plan) X(plan_guru64_dft_r2c)(int rank, \
244
+ const X(iodim64) *dims, \
245
+ int howmany_rank, \
246
+ const X(iodim64) *howmany_dims, \
247
+ R *in, C *out, \
248
+ unsigned flags); \
249
+ FFTW_EXTERN X(plan) X(plan_guru64_dft_c2r)(int rank, \
250
+ const X(iodim64) *dims, \
251
+ int howmany_rank, \
252
+ const X(iodim64) *howmany_dims, \
253
+ C *in, R *out, \
254
+ unsigned flags); \
255
+ \
256
+ FFTW_EXTERN X(plan) X(plan_guru64_split_dft_r2c)( \
257
+ int rank, const X(iodim64) *dims, \
258
+ int howmany_rank, \
259
+ const X(iodim64) *howmany_dims, \
260
+ R *in, R *ro, R *io, \
261
+ unsigned flags); \
262
+ FFTW_EXTERN X(plan) X(plan_guru64_split_dft_c2r)( \
263
+ int rank, const X(iodim64) *dims, \
264
+ int howmany_rank, \
265
+ const X(iodim64) *howmany_dims, \
266
+ R *ri, R *ii, R *out, \
267
+ unsigned flags); \
268
+ \
269
+ FFTW_EXTERN void X(execute_dft_r2c)(const X(plan) p, R *in, C *out); \
270
+ FFTW_EXTERN void X(execute_dft_c2r)(const X(plan) p, C *in, R *out); \
271
+ \
272
+ FFTW_EXTERN void X(execute_split_dft_r2c)(const X(plan) p, \
273
+ R *in, R *ro, R *io); \
274
+ FFTW_EXTERN void X(execute_split_dft_c2r)(const X(plan) p, \
275
+ R *ri, R *ii, R *out); \
276
+ \
277
+ FFTW_EXTERN X(plan) X(plan_many_r2r)(int rank, const int *n, \
278
+ int howmany, \
279
+ R *in, const int *inembed, \
280
+ int istride, int idist, \
281
+ R *out, const int *onembed, \
282
+ int ostride, int odist, \
283
+ const X(r2r_kind) *kind, unsigned flags); \
284
+ \
285
+ FFTW_EXTERN X(plan) X(plan_r2r)(int rank, const int *n, R *in, R *out, \
286
+ const X(r2r_kind) *kind, unsigned flags); \
287
+ \
288
+ FFTW_EXTERN X(plan) X(plan_r2r_1d)(int n, R *in, R *out, \
289
+ X(r2r_kind) kind, unsigned flags); \
290
+ FFTW_EXTERN X(plan) X(plan_r2r_2d)(int n0, int n1, R *in, R *out, \
291
+ X(r2r_kind) kind0, X(r2r_kind) kind1, \
292
+ unsigned flags); \
293
+ FFTW_EXTERN X(plan) X(plan_r2r_3d)(int n0, int n1, int n2, \
294
+ R *in, R *out, X(r2r_kind) kind0, \
295
+ X(r2r_kind) kind1, X(r2r_kind) kind2, \
296
+ unsigned flags); \
297
+ \
298
+ FFTW_EXTERN X(plan) X(plan_guru_r2r)(int rank, const X(iodim) *dims, \
299
+ int howmany_rank, \
300
+ const X(iodim) *howmany_dims, \
301
+ R *in, R *out, \
302
+ const X(r2r_kind) *kind, unsigned flags); \
303
+ \
304
+ FFTW_EXTERN X(plan) X(plan_guru64_r2r)(int rank, const X(iodim64) *dims, \
305
+ int howmany_rank, \
306
+ const X(iodim64) *howmany_dims, \
307
+ R *in, R *out, \
308
+ const X(r2r_kind) *kind, unsigned flags); \
309
+ \
310
+ FFTW_EXTERN void X(execute_r2r)(const X(plan) p, R *in, R *out); \
311
+ \
312
+ FFTW_EXTERN void X(destroy_plan)(X(plan) p); \
313
+ FFTW_EXTERN void X(forget_wisdom)(void); \
314
+ FFTW_EXTERN void X(cleanup)(void); \
315
+ \
316
+ FFTW_EXTERN void X(set_timelimit)(double t); \
317
+ \
318
+ FFTW_EXTERN void X(plan_with_nthreads)(int nthreads); \
319
+ FFTW_EXTERN int X(init_threads)(void); \
320
+ FFTW_EXTERN void X(cleanup_threads)(void); \
321
+ FFTW_EXTERN void X(make_planner_thread_safe)(void); \
322
+ \
323
+ FFTW_EXTERN int X(export_wisdom_to_filename)(const char *filename); \
324
+ FFTW_EXTERN void X(export_wisdom_to_file)(FILE *output_file); \
325
+ FFTW_EXTERN char *X(export_wisdom_to_string)(void); \
326
+ FFTW_EXTERN void X(export_wisdom)(X(write_char_func) write_char, \
327
+ void *data); \
328
+ FFTW_EXTERN int X(import_system_wisdom)(void); \
329
+ FFTW_EXTERN int X(import_wisdom_from_filename)(const char *filename); \
330
+ FFTW_EXTERN int X(import_wisdom_from_file)(FILE *input_file); \
331
+ FFTW_EXTERN int X(import_wisdom_from_string)(const char *input_string); \
332
+ FFTW_EXTERN int X(import_wisdom)(X(read_char_func) read_char, void *data); \
333
+ \
334
+ FFTW_EXTERN void X(fprint_plan)(const X(plan) p, FILE *output_file); \
335
+ FFTW_EXTERN void X(print_plan)(const X(plan) p); \
336
+ FFTW_EXTERN char *X(sprint_plan)(const X(plan) p); \
337
+ \
338
+ FFTW_EXTERN void *X(malloc)(size_t n); \
339
+ FFTW_EXTERN R *X(alloc_real)(size_t n); \
340
+ FFTW_EXTERN C *X(alloc_complex)(size_t n); \
341
+ FFTW_EXTERN void X(free)(void *p); \
342
+ \
343
+ FFTW_EXTERN void X(flops)(const X(plan) p, \
344
+ double *add, double *mul, double *fmas); \
345
+ FFTW_EXTERN double X(estimate_cost)(const X(plan) p); \
346
+ FFTW_EXTERN double X(cost)(const X(plan) p); \
347
+ \
348
+ FFTW_EXTERN int X(alignment_of)(R *p); \
349
+ FFTW_EXTERN const char X(version)[]; \
350
+ FFTW_EXTERN const char X(cc)[]; \
351
+ FFTW_EXTERN const char X(codelet_optim)[];
352
+
353
+
354
+ /* end of FFTW_DEFINE_API macro */
355
+
356
+ FFTW_DEFINE_API(FFTW_MANGLE_DOUBLE, double, fftw_complex)
357
+ FFTW_DEFINE_API(FFTW_MANGLE_FLOAT, float, fftwf_complex)
358
+ FFTW_DEFINE_API(FFTW_MANGLE_LONG_DOUBLE, long double, fftwl_complex)
359
+
360
+ /* __float128 (quad precision) is a gcc extension on i386, x86_64, and ia64
361
+ for gcc >= 4.6 (compiled in FFTW with --enable-quad-precision) */
362
+ #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) \
363
+ && !(defined(__ICC) || defined(__INTEL_COMPILER) || defined(__CUDACC__) || defined(__PGI)) \
364
+ && (defined(__i386__) || defined(__x86_64__) || defined(__ia64__))
365
+ # if !defined(FFTW_NO_Complex) && defined(_Complex_I) && defined(complex) && defined(I)
366
+ /* note: __float128 is a typedef, which is not supported with the _Complex
367
+ keyword in gcc, so instead we use this ugly __attribute__ version.
368
+ However, we can't simply pass the __attribute__ version to
369
+ FFTW_DEFINE_API because the __attribute__ confuses gcc in pointer
370
+ types. Hence redefining FFTW_DEFINE_COMPLEX. Ugh. */
371
+ # undef FFTW_DEFINE_COMPLEX
372
+ # define FFTW_DEFINE_COMPLEX(R, C) typedef _Complex float __attribute__((mode(TC))) C
373
+ # endif
374
+ FFTW_DEFINE_API(FFTW_MANGLE_QUAD, __float128, fftwq_complex)
375
+ #endif
376
+
377
+ #define FFTW_FORWARD (-1)
378
+ #define FFTW_BACKWARD (+1)
379
+
380
+ #define FFTW_NO_TIMELIMIT (-1.0)
381
+
382
+ /* documented flags */
383
+ #define FFTW_MEASURE (0U)
384
+ #define FFTW_DESTROY_INPUT (1U << 0)
385
+ #define FFTW_UNALIGNED (1U << 1)
386
+ #define FFTW_CONSERVE_MEMORY (1U << 2)
387
+ #define FFTW_EXHAUSTIVE (1U << 3) /* NO_EXHAUSTIVE is default */
388
+ #define FFTW_PRESERVE_INPUT (1U << 4) /* cancels FFTW_DESTROY_INPUT */
389
+ #define FFTW_PATIENT (1U << 5) /* IMPATIENT is default */
390
+ #define FFTW_ESTIMATE (1U << 6)
391
+ #define FFTW_WISDOM_ONLY (1U << 21)
392
+
393
+ /* undocumented beyond-guru flags */
394
+ #define FFTW_ESTIMATE_PATIENT (1U << 7)
395
+ #define FFTW_BELIEVE_PCOST (1U << 8)
396
+ #define FFTW_NO_DFT_R2HC (1U << 9)
397
+ #define FFTW_NO_NONTHREADED (1U << 10)
398
+ #define FFTW_NO_BUFFERING (1U << 11)
399
+ #define FFTW_NO_INDIRECT_OP (1U << 12)
400
+ #define FFTW_ALLOW_LARGE_GENERIC (1U << 13) /* NO_LARGE_GENERIC is default */
401
+ #define FFTW_NO_RANK_SPLITS (1U << 14)
402
+ #define FFTW_NO_VRANK_SPLITS (1U << 15)
403
+ #define FFTW_NO_VRECURSE (1U << 16)
404
+ #define FFTW_NO_SIMD (1U << 17)
405
+ #define FFTW_NO_SLOW (1U << 18)
406
+ #define FFTW_NO_FIXED_RADIX_LARGE_N (1U << 19)
407
+ #define FFTW_ALLOW_PRUNING (1U << 20)
408
+
409
+ #ifdef __cplusplus
410
+ } /* extern "C" */
411
+ #endif /* __cplusplus */
412
+
413
+ #endif /* FFTW3_H */
@@ -1,10 +1,17 @@
1
+
1
2
  #include "AudioPlayer.h"
3
+ #include "AudioArray.h"
4
+ #include "AudioBus.h"
2
5
  #include "AudioContext.h"
6
+ #include "Constants.h"
3
7
 
4
8
  namespace audioapi {
5
- AudioPlayer::AudioPlayer(const std::function<void(float *, int)> &renderAudio)
9
+
10
+ AudioPlayer::AudioPlayer(
11
+ const std::function<void(AudioBus *, int)> &renderAudio)
6
12
  : renderAudio_(renderAudio) {
7
13
  AudioStreamBuilder builder;
14
+
8
15
  builder.setSharingMode(SharingMode::Exclusive)
9
16
  ->setFormat(AudioFormat::Float)
10
17
  ->setFormatConversionAllowed(true)
@@ -13,12 +20,20 @@ AudioPlayer::AudioPlayer(const std::function<void(float *, int)> &renderAudio)
13
20
  ->setSampleRateConversionQuality(SampleRateConversionQuality::Medium)
14
21
  ->setDataCallback(this)
15
22
  ->openStream(mStream_);
23
+
24
+ mBus_ = std::make_shared<AudioBus>(
25
+ getSampleRate(), getBufferSizeInFrames(), CHANNEL_COUNT);
26
+ isInitialized_ = true;
16
27
  }
17
28
 
18
29
  int AudioPlayer::getSampleRate() const {
19
30
  return mStream_->getSampleRate();
20
31
  }
21
32
 
33
+ int AudioPlayer::getBufferSizeInFrames() const {
34
+ return mStream_->getBufferSizeInFrames();
35
+ }
36
+
22
37
  void AudioPlayer::start() {
23
38
  if (mStream_) {
24
39
  mStream_->requestStart();
@@ -26,6 +41,8 @@ void AudioPlayer::start() {
26
41
  }
27
42
 
28
43
  void AudioPlayer::stop() {
44
+ isInitialized_ = false;
45
+
29
46
  if (mStream_) {
30
47
  mStream_->requestStop();
31
48
  mStream_->close();
@@ -37,9 +54,22 @@ DataCallbackResult AudioPlayer::onAudioReady(
37
54
  AudioStream *oboeStream,
38
55
  void *audioData,
39
56
  int32_t numFrames) {
57
+ if (!isInitialized_) {
58
+ return DataCallbackResult::Continue;
59
+ }
60
+
40
61
  auto buffer = static_cast<float *>(audioData);
41
- renderAudio_(buffer, numFrames);
62
+ renderAudio_(mBus_.get(), numFrames);
63
+
64
+ // TODO: optimize this with SIMD?
65
+ for (int32_t i = 0; i < numFrames; i += 1) {
66
+ for (int channel = 0; channel < CHANNEL_COUNT; channel += 1) {
67
+ buffer[i * CHANNEL_COUNT + channel] =
68
+ mBus_->getChannel(channel)->getData()[i];
69
+ }
70
+ }
42
71
 
43
72
  return DataCallbackResult::Continue;
44
73
  }
74
+
45
75
  } // namespace audioapi
@@ -8,12 +8,14 @@ namespace audioapi {
8
8
  using namespace oboe;
9
9
 
10
10
  class AudioContext;
11
+ class AudioBus;
11
12
 
12
13
  class AudioPlayer : public AudioStreamDataCallback {
13
14
  public:
14
- explicit AudioPlayer(const std::function<void(float *, int)> &renderAudio);
15
+ explicit AudioPlayer(const std::function<void(AudioBus *, int)> &renderAudio);
15
16
 
16
17
  int getSampleRate() const;
18
+ int getBufferSizeInFrames() const;
17
19
  void start();
18
20
  void stop();
19
21
 
@@ -23,8 +25,10 @@ class AudioPlayer : public AudioStreamDataCallback {
23
25
  int32_t numFrames) override;
24
26
 
25
27
  private:
26
- std::function<void(float *, int)> renderAudio_;
28
+ std::function<void(AudioBus *, int)> renderAudio_;
27
29
  std::shared_ptr<AudioStream> mStream_;
30
+ std::shared_ptr<AudioBus> mBus_;
31
+ bool isInitialized_ = false;
28
32
  };
29
33
 
30
34
  } // namespace audioapi
@@ -4,8 +4,10 @@ namespace audioapi {
4
4
  using namespace facebook;
5
5
 
6
6
  AudioAPIInstallerHostObject::AudioAPIInstallerHostObject(
7
- const std::shared_ptr<AudioAPIInstallerWrapper> &wrapper)
8
- : wrapper_(wrapper) {}
7
+ const std::shared_ptr<AudioAPIInstallerWrapper> &wrapper, jsi::Runtime* runtime, const std::shared_ptr<facebook::react::CallInvoker> &jsInvoker)
8
+ : wrapper_(wrapper) {
9
+ promiseVendor_ = std::make_shared<JsiPromise::PromiseVendor>(runtime, jsInvoker);
10
+ }
9
11
 
10
12
  std::vector<jsi::PropNameID> AudioAPIInstallerHostObject::getPropertyNames(
11
13
  jsi::Runtime &runtime) {
@@ -32,7 +34,7 @@ jsi::Value AudioAPIInstallerHostObject::get(
32
34
  size_t count) -> jsi::Value {
33
35
  auto audioContext = wrapper_->createAudioContext();
34
36
  auto audioContextHostObject =
35
- AudioContextHostObject::createFromWrapper(audioContext);
37
+ AudioContextHostObject::createFromWrapper(audioContext, promiseVendor_);
36
38
  return jsi::Object::createFromHostObject(
37
39
  runtime, audioContextHostObject);
38
40
  });