@mentra/bluetooth-sdk 0.1.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.
Files changed (278) hide show
  1. package/README.md +278 -0
  2. package/android/build.gradle +167 -0
  3. package/android/lc3Lib/CMakeLists.txt +6 -0
  4. package/android/lc3Lib/build.gradle +109 -0
  5. package/android/lc3Lib/proguard-rules.pro +33 -0
  6. package/android/lc3Lib/src/main/AndroidManifest.xml +2 -0
  7. package/android/lc3Lib/src/main/cpp/CMakeLists.txt +8 -0
  8. package/android/lc3Lib/src/main/cpp/google_opus_stuff/CMakeLists.txt +30 -0
  9. package/android/lc3Lib/src/main/cpp/google_opus_stuff/jni/CMakeLists.txt +7 -0
  10. package/android/lc3Lib/src/main/cpp/google_opus_stuff/jni/ogg_opus_encoder.cc +96 -0
  11. package/android/lc3Lib/src/main/cpp/google_opus_stuff/jni/ogg_opus_encoder.h +53 -0
  12. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/Makefile.am +6 -0
  13. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/config_types.h +26 -0
  14. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/config_types.h.in +26 -0
  15. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/ogg.h +209 -0
  16. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/os_types.h +158 -0
  17. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus.h +981 -0
  18. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_custom.h +342 -0
  19. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_defines.h +799 -0
  20. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_multistream.h +660 -0
  21. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_projection.h +568 -0
  22. package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_types.h +166 -0
  23. package/android/lc3Lib/src/main/cpp/google_opus_stuff/ogg_opus_encoder.cc +268 -0
  24. package/android/lc3Lib/src/main/cpp/google_opus_stuff/ogg_opus_encoder.h +115 -0
  25. package/android/lc3Lib/src/main/cpp/google_opus_stuff/opus_tools/opus_header.h +59 -0
  26. package/android/lc3Lib/src/main/cpp/liblc3/CMakeLists.txt +38 -0
  27. package/android/lc3Lib/src/main/cpp/liblc3/include/lc3.h +309 -0
  28. package/android/lc3Lib/src/main/cpp/liblc3/include/lc3_private.h +162 -0
  29. package/android/lc3Lib/src/main/cpp/liblc3/include/rnnoise.h +114 -0
  30. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/CMakeLists.txt +19 -0
  31. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/attdet.c +92 -0
  32. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/attdet.h +44 -0
  33. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bits.c +375 -0
  34. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bits.h +315 -0
  35. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bwdet.c +129 -0
  36. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bwdet.h +69 -0
  37. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/common.h +148 -0
  38. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/energy.c +70 -0
  39. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/energy.h +43 -0
  40. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/fastmath.h +158 -0
  41. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/lc3.c +702 -0
  42. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf.c +893 -0
  43. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf.h +111 -0
  44. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf_arm.h +506 -0
  45. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf_neon.h +281 -0
  46. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/makefile.mk +35 -0
  47. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/mdct.c +452 -0
  48. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/mdct.h +57 -0
  49. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/mdct_neon.h +296 -0
  50. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/meson.build +46 -0
  51. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/plc.c +61 -0
  52. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/plc.h +57 -0
  53. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/sns.c +880 -0
  54. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/sns.h +103 -0
  55. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/spec.c +904 -0
  56. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/spec.h +119 -0
  57. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tables.c +3457 -0
  58. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tables.h +94 -0
  59. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tns.c +457 -0
  60. package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tns.h +99 -0
  61. package/android/lc3Lib/src/main/cpp/liblc3/liblc3.cpp +159 -0
  62. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/_kiss_fft_guts.h +182 -0
  63. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/arch.h +261 -0
  64. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/celt_lpc.c +279 -0
  65. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/celt_lpc.h +59 -0
  66. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/common.h +48 -0
  67. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/compile.sh +3 -0
  68. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/denoise.c +646 -0
  69. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/kiss_fft.c +601 -0
  70. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/kiss_fft.h +203 -0
  71. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/opus_types.h +159 -0
  72. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/pitch.c +526 -0
  73. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/pitch.h +149 -0
  74. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn.c +178 -0
  75. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn.h +69 -0
  76. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_data.c +11051 -0
  77. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_data.h +34 -0
  78. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_reader.c +168 -0
  79. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_train.py +66 -0
  80. package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/tansig_table.h +45 -0
  81. package/android/lc3Lib/src/main/java/com/mentra/lc3Lib/Lc3Cpp.java +38 -0
  82. package/android/lc3Lib/third_party/CMakeLists.txt +23 -0
  83. package/android/lc3Lib/third_party/CMakeLists_libogg.txt +18 -0
  84. package/android/lc3Lib/third_party/CMakeLists_libopus.txt +18 -0
  85. package/android/lc3Lib/third_party/CMakeLists_opus-tools.txt +23 -0
  86. package/android/lc3Lib/third_party/opus_tools/src/AUTHORS +5 -0
  87. package/android/lc3Lib/third_party/opus_tools/src/CMakeLists.txt +4 -0
  88. package/android/lc3Lib/third_party/opus_tools/src/COPYING +371 -0
  89. package/android/lc3Lib/third_party/opus_tools/src/ChangeLog +3 -0
  90. package/android/lc3Lib/third_party/opus_tools/src/Makefile.am +42 -0
  91. package/android/lc3Lib/third_party/opus_tools/src/Makefile.unix +23 -0
  92. package/android/lc3Lib/third_party/opus_tools/src/NEWS +0 -0
  93. package/android/lc3Lib/third_party/opus_tools/src/README +0 -0
  94. package/android/lc3Lib/third_party/opus_tools/src/autogen.sh +115 -0
  95. package/android/lc3Lib/third_party/opus_tools/src/configure.ac +293 -0
  96. package/android/lc3Lib/third_party/opus_tools/src/src/arch.h +239 -0
  97. package/android/lc3Lib/third_party/opus_tools/src/src/audio-in.c +1046 -0
  98. package/android/lc3Lib/third_party/opus_tools/src/src/diag_range.c +245 -0
  99. package/android/lc3Lib/third_party/opus_tools/src/src/diag_range.h +28 -0
  100. package/android/lc3Lib/third_party/opus_tools/src/src/info_opus.c +320 -0
  101. package/android/lc3Lib/third_party/opus_tools/src/src/info_opus.h +51 -0
  102. package/android/lc3Lib/third_party/opus_tools/src/src/lpc.c +157 -0
  103. package/android/lc3Lib/third_party/opus_tools/src/src/lpc.h +27 -0
  104. package/android/lc3Lib/third_party/opus_tools/src/src/opus_header.c +286 -0
  105. package/android/lc3Lib/third_party/opus_tools/src/src/opus_header.h +59 -0
  106. package/android/lc3Lib/third_party/opus_tools/src/src/opusdec.c +884 -0
  107. package/android/lc3Lib/third_party/opus_tools/src/src/opusenc.c +1021 -0
  108. package/android/lc3Lib/third_party/opus_tools/src/src/opusenc.h +101 -0
  109. package/android/lc3Lib/third_party/opus_tools/src/src/opusinfo.c +639 -0
  110. package/android/lc3Lib/third_party/opus_tools/src/src/opusinfo.h +51 -0
  111. package/android/lc3Lib/third_party/opus_tools/src/src/os_support.h +167 -0
  112. package/android/lc3Lib/third_party/opus_tools/src/src/resample.c +1137 -0
  113. package/android/lc3Lib/third_party/opus_tools/src/src/speex_resampler.h +344 -0
  114. package/android/lc3Lib/third_party/opus_tools/src/src/stack_alloc.h +115 -0
  115. package/android/lc3Lib/third_party/opus_tools/src/src/wav_io.c +125 -0
  116. package/android/lc3Lib/third_party/opus_tools/src/src/wav_io.h +62 -0
  117. package/android/lc3Lib/third_party/opus_tools/src/src/wave_out.c +223 -0
  118. package/android/lc3Lib/third_party/opus_tools/src/src/wave_out.h +60 -0
  119. package/android/settings.gradle +1 -0
  120. package/android/src/main/AndroidManifest.xml +40 -0
  121. package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +528 -0
  122. package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +610 -0
  123. package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +1616 -0
  124. package/android/src/main/java/com/mentra/bluetoothsdk/DeviceStore.kt +314 -0
  125. package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothModels.kt +1710 -0
  126. package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +554 -0
  127. package/android/src/main/java/com/mentra/bluetoothsdk/ObservableStore.kt +68 -0
  128. package/android/src/main/java/com/mentra/bluetoothsdk/controllers/ControllerManager.kt +158 -0
  129. package/android/src/main/java/com/mentra/bluetoothsdk/controllers/R1.kt +934 -0
  130. package/android/src/main/java/com/mentra/bluetoothsdk/services/Foreground.kt +175 -0
  131. package/android/src/main/java/com/mentra/bluetoothsdk/services/PhoneMic.kt +1109 -0
  132. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/G1.java +3974 -0
  133. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/G2.kt +3551 -0
  134. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Mach1.java +1327 -0
  135. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.java +6959 -0
  136. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraNex.kt +1655 -0
  137. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraosBle.java +53675 -0
  138. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/SGCManager.kt +202 -0
  139. package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Simulated.kt +224 -0
  140. package/android/src/main/java/com/mentra/bluetoothsdk/stt/STTTools.kt +340 -0
  141. package/android/src/main/java/com/mentra/bluetoothsdk/stt/SherpaOnnxTranscriber.kt +465 -0
  142. package/android/src/main/java/com/mentra/bluetoothsdk/stt/VadGateSpeechPolicy.kt +221 -0
  143. package/android/src/main/java/com/mentra/bluetoothsdk/utils/AES.java +106 -0
  144. package/android/src/main/java/com/mentra/bluetoothsdk/utils/AudioSessionMonitor.kt +189 -0
  145. package/android/src/main/java/com/mentra/bluetoothsdk/utils/BitmapJavaUtils.java +169 -0
  146. package/android/src/main/java/com/mentra/bluetoothsdk/utils/BlePhotoUploadService.java +179 -0
  147. package/android/src/main/java/com/mentra/bluetoothsdk/utils/Constants.kt +44 -0
  148. package/android/src/main/java/com/mentra/bluetoothsdk/utils/G1Text.kt +436 -0
  149. package/android/src/main/java/com/mentra/bluetoothsdk/utils/IncidentLogBleRelayNaming.java +29 -0
  150. package/android/src/main/java/com/mentra/bluetoothsdk/utils/IncidentLogBleUploadService.java +76 -0
  151. package/android/src/main/java/com/mentra/bluetoothsdk/utils/K900ProtocolUtils.java +791 -0
  152. package/android/src/main/java/com/mentra/bluetoothsdk/utils/MessageChunker.java +186 -0
  153. package/android/src/main/java/com/mentra/bluetoothsdk/utils/NexSGCUtils.kt +589 -0
  154. package/android/src/main/java/com/mentra/bluetoothsdk/utils/PhoneAudioMonitor.kt +303 -0
  155. package/android/src/main/java/com/mentra/bluetoothsdk/utils/SmartGlassesConnectionState.java +9 -0
  156. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/ByteUtilAudioPlayer.java +655 -0
  157. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/Lc3Player.java +441 -0
  158. package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PCMAudioPlayer.java +431 -0
  159. package/android/src/main/res/values/strings.xml +4 -0
  160. package/app.plugin.js +1 -0
  161. package/build/BluetoothSdk.types.d.ts +498 -0
  162. package/build/BluetoothSdk.types.d.ts.map +1 -0
  163. package/build/BluetoothSdk.types.js +23 -0
  164. package/build/BluetoothSdk.types.js.map +1 -0
  165. package/build/BluetoothSdkModule.d.ts +71 -0
  166. package/build/BluetoothSdkModule.d.ts.map +1 -0
  167. package/build/BluetoothSdkModule.js +106 -0
  168. package/build/BluetoothSdkModule.js.map +1 -0
  169. package/build/index.d.ts +3 -0
  170. package/build/index.d.ts.map +1 -0
  171. package/build/index.js +5 -0
  172. package/build/index.js.map +1 -0
  173. package/expo-module.config.json +9 -0
  174. package/ios/BluetoothSdkModule.swift +665 -0
  175. package/ios/MentraBluetoothSDK.podspec +77 -0
  176. package/ios/Packages/CoreObjC/CoreObjC.xcodeproj/project.pbxproj +213 -0
  177. package/ios/Packages/CoreObjC/PcmConverter.h +22 -0
  178. package/ios/Packages/CoreObjC/PcmConverter.m +266 -0
  179. package/ios/Packages/CoreObjC/attdet.c +92 -0
  180. package/ios/Packages/CoreObjC/attdet.h +44 -0
  181. package/ios/Packages/CoreObjC/bits.c +375 -0
  182. package/ios/Packages/CoreObjC/bits.h +315 -0
  183. package/ios/Packages/CoreObjC/bwdet.c +129 -0
  184. package/ios/Packages/CoreObjC/bwdet.h +69 -0
  185. package/ios/Packages/CoreObjC/common.h +151 -0
  186. package/ios/Packages/CoreObjC/energy.c +70 -0
  187. package/ios/Packages/CoreObjC/energy.h +43 -0
  188. package/ios/Packages/CoreObjC/fastmath.h +158 -0
  189. package/ios/Packages/CoreObjC/lc3.c +704 -0
  190. package/ios/Packages/CoreObjC/lc3.h +313 -0
  191. package/ios/Packages/CoreObjC/lc3_cpp.h +283 -0
  192. package/ios/Packages/CoreObjC/lc3_private.h +163 -0
  193. package/ios/Packages/CoreObjC/ltpf.c +905 -0
  194. package/ios/Packages/CoreObjC/ltpf.h +111 -0
  195. package/ios/Packages/CoreObjC/ltpf_arm.h +506 -0
  196. package/ios/Packages/CoreObjC/ltpf_neon.h +281 -0
  197. package/ios/Packages/CoreObjC/makefile.mk +35 -0
  198. package/ios/Packages/CoreObjC/mdct.c +469 -0
  199. package/ios/Packages/CoreObjC/mdct.h +57 -0
  200. package/ios/Packages/CoreObjC/mdct_neon.h +296 -0
  201. package/ios/Packages/CoreObjC/meson.build +61 -0
  202. package/ios/Packages/CoreObjC/plc.c +61 -0
  203. package/ios/Packages/CoreObjC/plc.h +57 -0
  204. package/ios/Packages/CoreObjC/rnnoise.h +114 -0
  205. package/ios/Packages/CoreObjC/sns.c +880 -0
  206. package/ios/Packages/CoreObjC/sns.h +103 -0
  207. package/ios/Packages/CoreObjC/spec.c +907 -0
  208. package/ios/Packages/CoreObjC/spec.h +119 -0
  209. package/ios/Packages/CoreObjC/tables.c +3457 -0
  210. package/ios/Packages/CoreObjC/tables.h +94 -0
  211. package/ios/Packages/CoreObjC/tns.c +457 -0
  212. package/ios/Packages/CoreObjC/tns.h +99 -0
  213. package/ios/Packages/SherpaOnnx/Model/joiner.onnx +0 -0
  214. package/ios/Packages/SherpaOnnx/Model/tokens.txt +502 -0
  215. package/ios/Packages/SherpaOnnx/SherpaOnnx.swift +1659 -0
  216. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/Headers/cargs.h +162 -0
  217. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/Headers/sherpa-onnx/c-api/c-api.h +1852 -0
  218. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/Headers/sherpa-onnx/c-api/cxx-api.h +674 -0
  219. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/Info.plist +44 -0
  220. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64/libsherpa-onnx.a +0 -0
  221. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64/sherpa-onnx.a +0 -0
  222. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64_x86_64-simulator/libsherpa-onnx.a +0 -0
  223. package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64_x86_64-simulator/sherpa-onnx.a +0 -0
  224. package/ios/Packages/VAD/Common/VAD/VADQuality.swift +41 -0
  225. package/ios/Packages/VAD/Common/VAD/VADState.swift +26 -0
  226. package/ios/Packages/VAD/Common/VAD/VADStrategy.swift +29 -0
  227. package/ios/Packages/VAD/Common/VAD/VADType.swift +14 -0
  228. package/ios/Packages/VAD/Data/Configuration.swift +68 -0
  229. package/ios/Packages/VAD/Data/FrameSize.swift +39 -0
  230. package/ios/Packages/VAD/Data/Record.swift +13 -0
  231. package/ios/Packages/VAD/Data/Result.swift +22 -0
  232. package/ios/Packages/VAD/Data/SampleRate.swift +48 -0
  233. package/ios/Packages/VAD/Silero/Model/silero_vad.onnx +0 -0
  234. package/ios/Packages/VAD/Silero/SileroVAD.swift +284 -0
  235. package/ios/Packages/VAD/Silero/SileroVADStrategy.swift +64 -0
  236. package/ios/Packages/libbz2/module.modulemap +5 -0
  237. package/ios/Packages/libbz2/shim.h +1 -0
  238. package/ios/Source/Bridge.swift +353 -0
  239. package/ios/Source/Bridging-Header.h +16 -0
  240. package/ios/Source/DeviceManager.swift +1478 -0
  241. package/ios/Source/DeviceStore.swift +295 -0
  242. package/ios/Source/MentraBluetoothSDK.swift +2439 -0
  243. package/ios/Source/ObservableStore.swift +88 -0
  244. package/ios/Source/PrivacyInfo.xcprivacy +23 -0
  245. package/ios/Source/controllers/ControllerManager.swift +187 -0
  246. package/ios/Source/controllers/R1.swift +827 -0
  247. package/ios/Source/services/PhoneMic.swift +662 -0
  248. package/ios/Source/sgcs/Frame.swift +651 -0
  249. package/ios/Source/sgcs/G1.swift +2505 -0
  250. package/ios/Source/sgcs/G2.swift +3730 -0
  251. package/ios/Source/sgcs/Mach1.swift +543 -0
  252. package/ios/Source/sgcs/MentraLive.swift +4708 -0
  253. package/ios/Source/sgcs/MentraNex.swift +2479 -0
  254. package/ios/Source/sgcs/SGCManager.swift +243 -0
  255. package/ios/Source/sgcs/Simulated.swift +270 -0
  256. package/ios/Source/sgcs/mentraos_ble.pb.swift +3811 -0
  257. package/ios/Source/stt/STTTools.swift +154 -0
  258. package/ios/Source/stt/SherpaOnnxTranscriber.swift +401 -0
  259. package/ios/Source/utils/AudioSessionMonitor.swift +283 -0
  260. package/ios/Source/utils/Constants.swift +74 -0
  261. package/ios/Source/utils/Enums.swift +95 -0
  262. package/ios/Source/utils/G1Text.swift +2067 -0
  263. package/ios/Source/utils/JSCExperiment.swift +241 -0
  264. package/ios/Source/utils/MemoryMonitor.swift +44 -0
  265. package/ios/Source/utils/MessageChunker.swift +164 -0
  266. package/ios/Source/utils/Models.swift +135 -0
  267. package/ios/Source/utils/PhoneAudioMonitor.swift +226 -0
  268. package/ios/Source/utils/TarBz2Extractor.swift +206 -0
  269. package/package.json +78 -0
  270. package/plugin/build/index.d.ts +6 -0
  271. package/plugin/build/index.js +12 -0
  272. package/plugin/build/withAndroid.d.ts +4 -0
  273. package/plugin/build/withAndroid.js +80 -0
  274. package/plugin/build/withIos.d.ts +4 -0
  275. package/plugin/build/withIos.js +64 -0
  276. package/src/BluetoothSdk.types.ts +581 -0
  277. package/src/BluetoothSdkModule.ts +259 -0
  278. package/src/index.ts +4 -0
@@ -0,0 +1,281 @@
1
+ /******************************************************************************
2
+ *
3
+ * Copyright 2022 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at:
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ *
17
+ ******************************************************************************/
18
+
19
+ #if __ARM_NEON && __ARM_ARCH_ISA_A64 && \
20
+ !defined(TEST_ARM) || defined(TEST_NEON)
21
+
22
+ #ifndef TEST_NEON
23
+ #include <arm_neon.h>
24
+ #endif /* TEST_NEON */
25
+
26
+
27
+ /**
28
+ * Import
29
+ */
30
+
31
+ static inline int32_t filter_hp50(struct lc3_ltpf_hp50_state *, int32_t);
32
+
33
+
34
+ /**
35
+ * Resample from 16 Khz to 12.8 KHz
36
+ */
37
+ #ifndef resample_16k_12k8
38
+
39
+ LC3_HOT static void neon_resample_16k_12k8(
40
+ struct lc3_ltpf_hp50_state *hp50, const int16_t *x, int16_t *y, int n)
41
+ {
42
+ static const int16_t h[4][20] = {
43
+
44
+ { -61, 214, -398, 417, 0, -1052, 2686, -4529, 5997, 26233,
45
+ 5997, -4529, 2686, -1052, 0, 417, -398, 214, -61, 0 },
46
+
47
+ { -79, 180, -213, 0, 598, -1522, 2389, -2427, 0, 24506,
48
+ 13068, -5289, 1873, 0, -752, 763, -457, 156, 0, -28 },
49
+
50
+ { -61, 92, 0, -323, 861, -1361, 1317, 0, -3885, 19741,
51
+ 19741, -3885, 0, 1317, -1361, 861, -323, 0, 92, -61 },
52
+
53
+ { -28, 0, 156, -457, 763, -752, 0, 1873, -5289, 13068,
54
+ 24506, 0, -2427, 2389, -1522, 598, 0, -213, 180, -79 },
55
+
56
+ };
57
+
58
+ x -= 20 - 1;
59
+
60
+ for (int i = 0; i < 5*n; i += 5) {
61
+ const int16_t *hn = h[i & 3];
62
+ const int16_t *xn = x + (i >> 2);
63
+ int32x4_t un;
64
+
65
+ un = vmull_s16( vld1_s16(xn), vld1_s16(hn)), xn += 4, hn += 4;
66
+ un = vmlal_s16(un, vld1_s16(xn), vld1_s16(hn)), xn += 4, hn += 4;
67
+ un = vmlal_s16(un, vld1_s16(xn), vld1_s16(hn)), xn += 4, hn += 4;
68
+ un = vmlal_s16(un, vld1_s16(xn), vld1_s16(hn)), xn += 4, hn += 4;
69
+ un = vmlal_s16(un, vld1_s16(xn), vld1_s16(hn)), xn += 4, hn += 4;
70
+
71
+ int32_t yn = filter_hp50(hp50, vaddvq_s32(un));
72
+ *(y++) = (yn + (1 << 15)) >> 16;
73
+ }
74
+ }
75
+
76
+ #ifndef TEST_NEON
77
+ #define resample_16k_12k8 neon_resample_16k_12k8
78
+ #endif
79
+
80
+ #endif /* resample_16k_12k8 */
81
+
82
+ /**
83
+ * Resample from 32 Khz to 12.8 KHz
84
+ */
85
+ #ifndef resample_32k_12k8
86
+
87
+ LC3_HOT static void neon_resample_32k_12k8(
88
+ struct lc3_ltpf_hp50_state *hp50, const int16_t *x, int16_t *y, int n)
89
+ {
90
+ x -= 40 - 1;
91
+
92
+ static const int16_t h[2][40] = {
93
+
94
+ { -30, -31, 46, 107, 0, -199, -162, 209, 430, 0,
95
+ -681, -526, 658, 1343, 0, -2264, -1943, 2999, 9871, 13116,
96
+ 9871, 2999, -1943, -2264, 0, 1343, 658, -526, -681, 0,
97
+ 430, 209, -162, -199, 0, 107, 46, -31, -30, 0 },
98
+
99
+ { -14, -39, 0, 90, 78, -106, -229, 0, 382, 299,
100
+ -376, -761, 0, 1194, 937, -1214, -2644, 0, 6534, 12253,
101
+ 12253, 6534, 0, -2644, -1214, 937, 1194, 0, -761, -376,
102
+ 299, 382, 0, -229, -106, 78, 90, 0, -39, -14 },
103
+
104
+ };
105
+
106
+ for (int i = 0; i < 5*n; i += 5) {
107
+ const int16_t *hn = h[i & 1];
108
+ const int16_t *xn = x + (i >> 1);
109
+
110
+ int32x4_t un = vmull_s16(vld1_s16(xn), vld1_s16(hn));
111
+ xn += 4, hn += 4;
112
+
113
+ for (int i = 1; i < 10; i++)
114
+ un = vmlal_s16(un, vld1_s16(xn), vld1_s16(hn)), xn += 4, hn += 4;
115
+
116
+ int32_t yn = filter_hp50(hp50, vaddvq_s32(un));
117
+ *(y++) = (yn + (1 << 15)) >> 16;
118
+ }
119
+ }
120
+
121
+ #ifndef TEST_NEON
122
+ #define resample_32k_12k8 neon_resample_32k_12k8
123
+ #endif
124
+
125
+ #endif /* resample_32k_12k8 */
126
+
127
+ /**
128
+ * Resample from 48 Khz to 12.8 KHz
129
+ */
130
+ #ifndef resample_48k_12k8
131
+
132
+ LC3_HOT static void neon_resample_48k_12k8(
133
+ struct lc3_ltpf_hp50_state *hp50, const int16_t *x, int16_t *y, int n)
134
+ {
135
+ static const int16_t alignas(16) h[4][64] = {
136
+
137
+ { -13, -25, -20, 10, 51, 71, 38, -47, -133, -145,
138
+ -42, 139, 277, 242, 0, -329, -511, -351, 144, 698,
139
+ 895, 450, -535, -1510, -1697, -521, 1999, 5138, 7737, 8744,
140
+ 7737, 5138, 1999, -521, -1697, -1510, -535, 450, 895, 698,
141
+ 144, -351, -511, -329, 0, 242, 277, 139, -42, -145,
142
+ -133, -47, 38, 71, 51, 10, -20, -25, -13, 0 },
143
+
144
+ { -9, -23, -24, 0, 41, 71, 52, -23, -115, -152,
145
+ -78, 92, 254, 272, 76, -251, -493, -427, 0, 576,
146
+ 900, 624, -262, -1309, -1763, -954, 1272, 4356, 7203, 8679,
147
+ 8169, 5886, 2767, 0, -1542, -1660, -809, 240, 848, 796,
148
+ 292, -252, -507, -398, -82, 199, 288, 183, 0, -130,
149
+ -145, -71, 20, 69, 60, 20, -15, -26, -17, -3 },
150
+
151
+ { -6, -20, -26, -8, 31, 67, 62, 0, -94, -152,
152
+ -108, 45, 223, 287, 143, -167, -454, -480, -134, 439,
153
+ 866, 758, 0, -1071, -1748, -1295, 601, 3559, 6580, 8485,
154
+ 8485, 6580, 3559, 601, -1295, -1748, -1071, 0, 758, 866,
155
+ 439, -134, -480, -454, -167, 143, 287, 223, 45, -108,
156
+ -152, -94, 0, 62, 67, 31, -8, -26, -20, -6 },
157
+
158
+ { -3, -17, -26, -15, 20, 60, 69, 20, -71, -145,
159
+ -130, 0, 183, 288, 199, -82, -398, -507, -252, 292,
160
+ 796, 848, 240, -809, -1660, -1542, 0, 2767, 5886, 8169,
161
+ 8679, 7203, 4356, 1272, -954, -1763, -1309, -262, 624, 900,
162
+ 576, 0, -427, -493, -251, 76, 272, 254, 92, -78,
163
+ -152, -115, -23, 52, 71, 41, 0, -24, -23, -9 },
164
+
165
+ };
166
+
167
+ x -= 60 - 1;
168
+
169
+ for (int i = 0; i < 15*n; i += 15) {
170
+ const int16_t *hn = h[i & 3];
171
+ const int16_t *xn = x + (i >> 2);
172
+
173
+ int32x4_t un = vmull_s16(vld1_s16(xn), vld1_s16(hn));
174
+ xn += 4, hn += 4;
175
+
176
+ for (int i = 1; i < 15; i++)
177
+ un = vmlal_s16(un, vld1_s16(xn), vld1_s16(hn)), xn += 4, hn += 4;
178
+
179
+ int32_t yn = filter_hp50(hp50, vaddvq_s32(un));
180
+ *(y++) = (yn + (1 << 15)) >> 16;
181
+ }
182
+ }
183
+
184
+ #ifndef TEST_NEON
185
+ #define resample_48k_12k8 neon_resample_48k_12k8
186
+ #endif
187
+
188
+ #endif /* resample_48k_12k8 */
189
+
190
+ /**
191
+ * Return dot product of 2 vectors
192
+ */
193
+ #ifndef dot
194
+
195
+ LC3_HOT static inline float neon_dot(const int16_t *a, const int16_t *b, int n)
196
+ {
197
+ int64x2_t v = vmovq_n_s64(0);
198
+
199
+ for (int i = 0; i < (n >> 4); i++) {
200
+ int32x4_t u;
201
+
202
+ u = vmull_s16( vld1_s16(a), vld1_s16(b)), a += 4, b += 4;
203
+ u = vmlal_s16(u, vld1_s16(a), vld1_s16(b)), a += 4, b += 4;
204
+ v = vpadalq_s32(v, u);
205
+
206
+ u = vmull_s16( vld1_s16(a), vld1_s16(b)), a += 4, b += 4;
207
+ u = vmlal_s16(u, vld1_s16(a), vld1_s16(b)), a += 4, b += 4;
208
+ v = vpadalq_s32(v, u);
209
+ }
210
+
211
+ int32_t v32 = (vaddvq_s64(v) + (1 << 5)) >> 6;
212
+ return (float)v32;
213
+ }
214
+
215
+ #ifndef TEST_NEON
216
+ #define dot neon_dot
217
+ #endif
218
+
219
+ #endif /* dot */
220
+
221
+ /**
222
+ * Return vector of correlations
223
+ */
224
+ #ifndef correlate
225
+
226
+ LC3_HOT static void neon_correlate(
227
+ const int16_t *a, const int16_t *b, int n, float *y, int nc)
228
+ {
229
+ for ( ; nc >= 4; nc -= 4, b -= 4) {
230
+ const int16_t *an = (const int16_t *)a;
231
+ const int16_t *bn = (const int16_t *)b;
232
+
233
+ int64x2_t v0 = vmovq_n_s64(0), v1 = v0, v2 = v0, v3 = v0;
234
+ int16x4_t ax, b0, b1;
235
+
236
+ b0 = vld1_s16(bn-4);
237
+
238
+ for (int i=0; i < (n >> 4); i++ )
239
+ for (int j = 0; j < 2; j++) {
240
+ int32x4_t u0, u1, u2, u3;
241
+
242
+ b1 = b0;
243
+ b0 = vld1_s16(bn), bn += 4;
244
+ ax = vld1_s16(an), an += 4;
245
+
246
+ u0 = vmull_s16(ax, b0);
247
+ u1 = vmull_s16(ax, vext_s16(b1, b0, 3));
248
+ u2 = vmull_s16(ax, vext_s16(b1, b0, 2));
249
+ u3 = vmull_s16(ax, vext_s16(b1, b0, 1));
250
+
251
+ b1 = b0;
252
+ b0 = vld1_s16(bn), bn += 4;
253
+ ax = vld1_s16(an), an += 4;
254
+
255
+ u0 = vmlal_s16(u0, ax, b0);
256
+ u1 = vmlal_s16(u1, ax, vext_s16(b1, b0, 3));
257
+ u2 = vmlal_s16(u2, ax, vext_s16(b1, b0, 2));
258
+ u3 = vmlal_s16(u3, ax, vext_s16(b1, b0, 1));
259
+
260
+ v0 = vpadalq_s32(v0, u0);
261
+ v1 = vpadalq_s32(v1, u1);
262
+ v2 = vpadalq_s32(v2, u2);
263
+ v3 = vpadalq_s32(v3, u3);
264
+ }
265
+
266
+ *(y++) = (float)((int32_t)((vaddvq_s64(v0) + (1 << 5)) >> 6));
267
+ *(y++) = (float)((int32_t)((vaddvq_s64(v1) + (1 << 5)) >> 6));
268
+ *(y++) = (float)((int32_t)((vaddvq_s64(v2) + (1 << 5)) >> 6));
269
+ *(y++) = (float)((int32_t)((vaddvq_s64(v3) + (1 << 5)) >> 6));
270
+ }
271
+
272
+ for ( ; nc > 0; nc--)
273
+ *(y++) = neon_dot(a, b--, n);
274
+ }
275
+ #endif /* correlate */
276
+
277
+ #ifndef TEST_NEON
278
+ #define correlate neon_correlate
279
+ #endif
280
+
281
+ #endif /* __ARM_NEON && __ARM_ARCH_ISA_A64 */
@@ -0,0 +1,35 @@
1
+ #
2
+ # Copyright 2022 Google LLC
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at:
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ liblc3_src += \
18
+ $(SRC_DIR)/attdet.c \
19
+ $(SRC_DIR)/bits.c \
20
+ $(SRC_DIR)/bwdet.c \
21
+ $(SRC_DIR)/energy.c \
22
+ $(SRC_DIR)/lc3.c \
23
+ $(SRC_DIR)/ltpf.c \
24
+ $(SRC_DIR)/mdct.c \
25
+ $(SRC_DIR)/plc.c \
26
+ $(SRC_DIR)/sns.c \
27
+ $(SRC_DIR)/spec.c \
28
+ $(SRC_DIR)/tables.c \
29
+ $(SRC_DIR)/tns.c
30
+
31
+ liblc3_cflags += -ffast-math
32
+
33
+ $(eval $(call add-lib,liblc3))
34
+
35
+ default: liblc3