@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.
- package/README.md +278 -0
- package/android/build.gradle +167 -0
- package/android/lc3Lib/CMakeLists.txt +6 -0
- package/android/lc3Lib/build.gradle +109 -0
- package/android/lc3Lib/proguard-rules.pro +33 -0
- package/android/lc3Lib/src/main/AndroidManifest.xml +2 -0
- package/android/lc3Lib/src/main/cpp/CMakeLists.txt +8 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/CMakeLists.txt +30 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/jni/CMakeLists.txt +7 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/jni/ogg_opus_encoder.cc +96 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/jni/ogg_opus_encoder.h +53 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/Makefile.am +6 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/config_types.h +26 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/config_types.h.in +26 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/ogg.h +209 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libogg/os_types.h +158 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus.h +981 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_custom.h +342 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_defines.h +799 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_multistream.h +660 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_projection.h +568 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/libopus/opus_types.h +166 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/ogg_opus_encoder.cc +268 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/ogg_opus_encoder.h +115 -0
- package/android/lc3Lib/src/main/cpp/google_opus_stuff/opus_tools/opus_header.h +59 -0
- package/android/lc3Lib/src/main/cpp/liblc3/CMakeLists.txt +38 -0
- package/android/lc3Lib/src/main/cpp/liblc3/include/lc3.h +309 -0
- package/android/lc3Lib/src/main/cpp/liblc3/include/lc3_private.h +162 -0
- package/android/lc3Lib/src/main/cpp/liblc3/include/rnnoise.h +114 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/CMakeLists.txt +19 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/attdet.c +92 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/attdet.h +44 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bits.c +375 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bits.h +315 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bwdet.c +129 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/bwdet.h +69 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/common.h +148 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/energy.c +70 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/energy.h +43 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/fastmath.h +158 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/lc3.c +702 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf.c +893 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf.h +111 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf_arm.h +506 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/ltpf_neon.h +281 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/makefile.mk +35 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/mdct.c +452 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/mdct.h +57 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/mdct_neon.h +296 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/meson.build +46 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/plc.c +61 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/plc.h +57 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/sns.c +880 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/sns.h +103 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/spec.c +904 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/spec.h +119 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tables.c +3457 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tables.h +94 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tns.c +457 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3/tns.h +99 -0
- package/android/lc3Lib/src/main/cpp/liblc3/liblc3.cpp +159 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/_kiss_fft_guts.h +182 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/arch.h +261 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/celt_lpc.c +279 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/celt_lpc.h +59 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/common.h +48 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/compile.sh +3 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/denoise.c +646 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/kiss_fft.c +601 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/kiss_fft.h +203 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/opus_types.h +159 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/pitch.c +526 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/pitch.h +149 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn.c +178 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn.h +69 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_data.c +11051 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_data.h +34 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_reader.c +168 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/rnn_train.py +66 -0
- package/android/lc3Lib/src/main/cpp/liblc3/rnnoise/tansig_table.h +45 -0
- package/android/lc3Lib/src/main/java/com/mentra/lc3Lib/Lc3Cpp.java +38 -0
- package/android/lc3Lib/third_party/CMakeLists.txt +23 -0
- package/android/lc3Lib/third_party/CMakeLists_libogg.txt +18 -0
- package/android/lc3Lib/third_party/CMakeLists_libopus.txt +18 -0
- package/android/lc3Lib/third_party/CMakeLists_opus-tools.txt +23 -0
- package/android/lc3Lib/third_party/opus_tools/src/AUTHORS +5 -0
- package/android/lc3Lib/third_party/opus_tools/src/CMakeLists.txt +4 -0
- package/android/lc3Lib/third_party/opus_tools/src/COPYING +371 -0
- package/android/lc3Lib/third_party/opus_tools/src/ChangeLog +3 -0
- package/android/lc3Lib/third_party/opus_tools/src/Makefile.am +42 -0
- package/android/lc3Lib/third_party/opus_tools/src/Makefile.unix +23 -0
- package/android/lc3Lib/third_party/opus_tools/src/NEWS +0 -0
- package/android/lc3Lib/third_party/opus_tools/src/README +0 -0
- package/android/lc3Lib/third_party/opus_tools/src/autogen.sh +115 -0
- package/android/lc3Lib/third_party/opus_tools/src/configure.ac +293 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/arch.h +239 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/audio-in.c +1046 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/diag_range.c +245 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/diag_range.h +28 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/info_opus.c +320 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/info_opus.h +51 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/lpc.c +157 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/lpc.h +27 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/opus_header.c +286 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/opus_header.h +59 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/opusdec.c +884 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/opusenc.c +1021 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/opusenc.h +101 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/opusinfo.c +639 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/opusinfo.h +51 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/os_support.h +167 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/resample.c +1137 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/speex_resampler.h +344 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/stack_alloc.h +115 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/wav_io.c +125 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/wav_io.h +62 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/wave_out.c +223 -0
- package/android/lc3Lib/third_party/opus_tools/src/src/wave_out.h +60 -0
- package/android/settings.gradle +1 -0
- package/android/src/main/AndroidManifest.xml +40 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/BluetoothSdkModule.kt +528 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/Bridge.kt +610 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceManager.kt +1616 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/DeviceStore.kt +314 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothModels.kt +1710 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/MentraBluetoothSdk.kt +554 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/ObservableStore.kt +68 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/controllers/ControllerManager.kt +158 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/controllers/R1.kt +934 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/services/Foreground.kt +175 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/services/PhoneMic.kt +1109 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/G1.java +3974 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/G2.kt +3551 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Mach1.java +1327 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraLive.java +6959 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraNex.kt +1655 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/MentraosBle.java +53675 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/SGCManager.kt +202 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/sgcs/Simulated.kt +224 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/STTTools.kt +340 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/SherpaOnnxTranscriber.kt +465 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/stt/VadGateSpeechPolicy.kt +221 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/AES.java +106 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/AudioSessionMonitor.kt +189 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/BitmapJavaUtils.java +169 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/BlePhotoUploadService.java +179 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/Constants.kt +44 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/G1Text.kt +436 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/IncidentLogBleRelayNaming.java +29 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/IncidentLogBleUploadService.java +76 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/K900ProtocolUtils.java +791 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/MessageChunker.java +186 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/NexSGCUtils.kt +589 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/PhoneAudioMonitor.kt +303 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/SmartGlassesConnectionState.java +9 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/ByteUtilAudioPlayer.java +655 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/Lc3Player.java +441 -0
- package/android/src/main/java/com/mentra/bluetoothsdk/utils/audio/PCMAudioPlayer.java +431 -0
- package/android/src/main/res/values/strings.xml +4 -0
- package/app.plugin.js +1 -0
- package/build/BluetoothSdk.types.d.ts +498 -0
- package/build/BluetoothSdk.types.d.ts.map +1 -0
- package/build/BluetoothSdk.types.js +23 -0
- package/build/BluetoothSdk.types.js.map +1 -0
- package/build/BluetoothSdkModule.d.ts +71 -0
- package/build/BluetoothSdkModule.d.ts.map +1 -0
- package/build/BluetoothSdkModule.js +106 -0
- package/build/BluetoothSdkModule.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +5 -0
- package/build/index.js.map +1 -0
- package/expo-module.config.json +9 -0
- package/ios/BluetoothSdkModule.swift +665 -0
- package/ios/MentraBluetoothSDK.podspec +77 -0
- package/ios/Packages/CoreObjC/CoreObjC.xcodeproj/project.pbxproj +213 -0
- package/ios/Packages/CoreObjC/PcmConverter.h +22 -0
- package/ios/Packages/CoreObjC/PcmConverter.m +266 -0
- package/ios/Packages/CoreObjC/attdet.c +92 -0
- package/ios/Packages/CoreObjC/attdet.h +44 -0
- package/ios/Packages/CoreObjC/bits.c +375 -0
- package/ios/Packages/CoreObjC/bits.h +315 -0
- package/ios/Packages/CoreObjC/bwdet.c +129 -0
- package/ios/Packages/CoreObjC/bwdet.h +69 -0
- package/ios/Packages/CoreObjC/common.h +151 -0
- package/ios/Packages/CoreObjC/energy.c +70 -0
- package/ios/Packages/CoreObjC/energy.h +43 -0
- package/ios/Packages/CoreObjC/fastmath.h +158 -0
- package/ios/Packages/CoreObjC/lc3.c +704 -0
- package/ios/Packages/CoreObjC/lc3.h +313 -0
- package/ios/Packages/CoreObjC/lc3_cpp.h +283 -0
- package/ios/Packages/CoreObjC/lc3_private.h +163 -0
- package/ios/Packages/CoreObjC/ltpf.c +905 -0
- package/ios/Packages/CoreObjC/ltpf.h +111 -0
- package/ios/Packages/CoreObjC/ltpf_arm.h +506 -0
- package/ios/Packages/CoreObjC/ltpf_neon.h +281 -0
- package/ios/Packages/CoreObjC/makefile.mk +35 -0
- package/ios/Packages/CoreObjC/mdct.c +469 -0
- package/ios/Packages/CoreObjC/mdct.h +57 -0
- package/ios/Packages/CoreObjC/mdct_neon.h +296 -0
- package/ios/Packages/CoreObjC/meson.build +61 -0
- package/ios/Packages/CoreObjC/plc.c +61 -0
- package/ios/Packages/CoreObjC/plc.h +57 -0
- package/ios/Packages/CoreObjC/rnnoise.h +114 -0
- package/ios/Packages/CoreObjC/sns.c +880 -0
- package/ios/Packages/CoreObjC/sns.h +103 -0
- package/ios/Packages/CoreObjC/spec.c +907 -0
- package/ios/Packages/CoreObjC/spec.h +119 -0
- package/ios/Packages/CoreObjC/tables.c +3457 -0
- package/ios/Packages/CoreObjC/tables.h +94 -0
- package/ios/Packages/CoreObjC/tns.c +457 -0
- package/ios/Packages/CoreObjC/tns.h +99 -0
- package/ios/Packages/SherpaOnnx/Model/joiner.onnx +0 -0
- package/ios/Packages/SherpaOnnx/Model/tokens.txt +502 -0
- package/ios/Packages/SherpaOnnx/SherpaOnnx.swift +1659 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/Headers/cargs.h +162 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/Headers/sherpa-onnx/c-api/c-api.h +1852 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/Headers/sherpa-onnx/c-api/cxx-api.h +674 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/Info.plist +44 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64/libsherpa-onnx.a +0 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64/sherpa-onnx.a +0 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64_x86_64-simulator/libsherpa-onnx.a +0 -0
- package/ios/Packages/SherpaOnnx/sherpa-onnx.xcframework/ios-arm64_x86_64-simulator/sherpa-onnx.a +0 -0
- package/ios/Packages/VAD/Common/VAD/VADQuality.swift +41 -0
- package/ios/Packages/VAD/Common/VAD/VADState.swift +26 -0
- package/ios/Packages/VAD/Common/VAD/VADStrategy.swift +29 -0
- package/ios/Packages/VAD/Common/VAD/VADType.swift +14 -0
- package/ios/Packages/VAD/Data/Configuration.swift +68 -0
- package/ios/Packages/VAD/Data/FrameSize.swift +39 -0
- package/ios/Packages/VAD/Data/Record.swift +13 -0
- package/ios/Packages/VAD/Data/Result.swift +22 -0
- package/ios/Packages/VAD/Data/SampleRate.swift +48 -0
- package/ios/Packages/VAD/Silero/Model/silero_vad.onnx +0 -0
- package/ios/Packages/VAD/Silero/SileroVAD.swift +284 -0
- package/ios/Packages/VAD/Silero/SileroVADStrategy.swift +64 -0
- package/ios/Packages/libbz2/module.modulemap +5 -0
- package/ios/Packages/libbz2/shim.h +1 -0
- package/ios/Source/Bridge.swift +353 -0
- package/ios/Source/Bridging-Header.h +16 -0
- package/ios/Source/DeviceManager.swift +1478 -0
- package/ios/Source/DeviceStore.swift +295 -0
- package/ios/Source/MentraBluetoothSDK.swift +2439 -0
- package/ios/Source/ObservableStore.swift +88 -0
- package/ios/Source/PrivacyInfo.xcprivacy +23 -0
- package/ios/Source/controllers/ControllerManager.swift +187 -0
- package/ios/Source/controllers/R1.swift +827 -0
- package/ios/Source/services/PhoneMic.swift +662 -0
- package/ios/Source/sgcs/Frame.swift +651 -0
- package/ios/Source/sgcs/G1.swift +2505 -0
- package/ios/Source/sgcs/G2.swift +3730 -0
- package/ios/Source/sgcs/Mach1.swift +543 -0
- package/ios/Source/sgcs/MentraLive.swift +4708 -0
- package/ios/Source/sgcs/MentraNex.swift +2479 -0
- package/ios/Source/sgcs/SGCManager.swift +243 -0
- package/ios/Source/sgcs/Simulated.swift +270 -0
- package/ios/Source/sgcs/mentraos_ble.pb.swift +3811 -0
- package/ios/Source/stt/STTTools.swift +154 -0
- package/ios/Source/stt/SherpaOnnxTranscriber.swift +401 -0
- package/ios/Source/utils/AudioSessionMonitor.swift +283 -0
- package/ios/Source/utils/Constants.swift +74 -0
- package/ios/Source/utils/Enums.swift +95 -0
- package/ios/Source/utils/G1Text.swift +2067 -0
- package/ios/Source/utils/JSCExperiment.swift +241 -0
- package/ios/Source/utils/MemoryMonitor.swift +44 -0
- package/ios/Source/utils/MessageChunker.swift +164 -0
- package/ios/Source/utils/Models.swift +135 -0
- package/ios/Source/utils/PhoneAudioMonitor.swift +226 -0
- package/ios/Source/utils/TarBz2Extractor.swift +206 -0
- package/package.json +78 -0
- package/plugin/build/index.d.ts +6 -0
- package/plugin/build/index.js +12 -0
- package/plugin/build/withAndroid.d.ts +4 -0
- package/plugin/build/withAndroid.js +80 -0
- package/plugin/build/withIos.d.ts +4 -0
- package/plugin/build/withIos.js +64 -0
- package/src/BluetoothSdk.types.ts +581 -0
- package/src/BluetoothSdkModule.ts +259 -0
- package/src/index.ts +4 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
|
|
4
|
+
include_expo_adapter = ENV['MENTRA_BLUETOOTH_SDK_INCLUDE_EXPO_ADAPTER'] == '1'
|
|
5
|
+
|
|
6
|
+
Pod::Spec.new do |s|
|
|
7
|
+
s.name = 'MentraBluetoothSDK'
|
|
8
|
+
s.version = package['version']
|
|
9
|
+
s.summary = package['description']
|
|
10
|
+
s.description = package['description']
|
|
11
|
+
s.license = package['license']
|
|
12
|
+
s.author = package['author']
|
|
13
|
+
s.homepage = package['homepage']
|
|
14
|
+
s.platforms = {
|
|
15
|
+
:ios => '15.1'
|
|
16
|
+
}
|
|
17
|
+
s.swift_version = '5.9'
|
|
18
|
+
s.source = {
|
|
19
|
+
:git => 'https://github.com/Mentra-Community/MentraOS.git',
|
|
20
|
+
:tag => "bluetooth-sdk-v#{s.version}"
|
|
21
|
+
}
|
|
22
|
+
s.static_framework = true
|
|
23
|
+
|
|
24
|
+
# External dependencies required by Bluetooth SDK native code
|
|
25
|
+
s.dependency 'ExpoModulesCore' if include_expo_adapter
|
|
26
|
+
s.dependency 'SWCompression', '~> 4.8.0'
|
|
27
|
+
s.dependency 'SwiftProtobuf', '~> 1.0'
|
|
28
|
+
s.dependency 'onnxruntime-objc', '1.18.0'
|
|
29
|
+
s.dependency 'UltraliteSDK'
|
|
30
|
+
|
|
31
|
+
# Swift/Objective-C compatibility
|
|
32
|
+
s.pod_target_xcconfig = {
|
|
33
|
+
'DEFINES_MODULE' => 'YES',
|
|
34
|
+
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
|
|
35
|
+
'CLANG_CXX_LIBRARY' => 'libc++',
|
|
36
|
+
'SWIFT_INCLUDE_PATHS' => '$(PODS_TARGET_SRCROOT)/Packages/libbz2'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
# iOS frameworks required by Bluetooth SDK
|
|
40
|
+
s.frameworks = 'AVFoundation', 'CoreBluetooth', 'UIKit', 'CoreGraphics'
|
|
41
|
+
|
|
42
|
+
# System libraries required by MentraOS
|
|
43
|
+
s.library = 'bz2'
|
|
44
|
+
|
|
45
|
+
# Vendored frameworks
|
|
46
|
+
s.vendored_frameworks = 'Packages/SherpaOnnx/sherpa-onnx.xcframework'
|
|
47
|
+
|
|
48
|
+
# Resources (model files)
|
|
49
|
+
s.resources = 'Packages/VAD/Silero/Model/*.onnx'
|
|
50
|
+
s.resource_bundles = {
|
|
51
|
+
'BluetoothSDKPrivacy' => ['Source/PrivacyInfo.xcprivacy']
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
native_source_files = [
|
|
55
|
+
"Source/**/*.{h,m,mm,swift,hpp,cpp,c}",
|
|
56
|
+
"Packages/CoreObjC/**/*.{h,m,mm,hpp,cpp,c}",
|
|
57
|
+
"Packages/SherpaOnnx/SherpaOnnx.swift",
|
|
58
|
+
"Packages/SherpaOnnx/sherpa-onnx.xcframework/Headers/**/*.{h,hpp}",
|
|
59
|
+
"Packages/VAD/**/*.swift",
|
|
60
|
+
"Packages/libbz2/shim.h"
|
|
61
|
+
]
|
|
62
|
+
native_source_files << "BluetoothSdkModule.swift" if include_expo_adapter
|
|
63
|
+
s.source_files = native_source_files
|
|
64
|
+
|
|
65
|
+
# Explicitly mark C++ headers and internal headers as private to prevent exposure in public interface
|
|
66
|
+
s.private_header_files = [
|
|
67
|
+
"Packages/CoreObjC/lc3_cpp.h",
|
|
68
|
+
"Packages/CoreObjC/mdct_neon.h",
|
|
69
|
+
"Packages/CoreObjC/ltpf_neon.h",
|
|
70
|
+
"Packages/SherpaOnnx/sherpa-onnx.xcframework/Headers/sherpa-onnx/c-api/cxx-api.h",
|
|
71
|
+
"Packages/libbz2/shim.h",
|
|
72
|
+
"Source/Bridging-Header.h"
|
|
73
|
+
]
|
|
74
|
+
|
|
75
|
+
# Exclude legacy Obj-C bridge files.
|
|
76
|
+
s.exclude_files = ["Source/BridgeModule.{h,m}", "Source/Bridge.m"]
|
|
77
|
+
end
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// !$*UTF8*$!
|
|
2
|
+
{
|
|
3
|
+
archiveVersion = 1;
|
|
4
|
+
classes = {
|
|
5
|
+
};
|
|
6
|
+
objectVersion = 77;
|
|
7
|
+
objects = {
|
|
8
|
+
|
|
9
|
+
/* Begin PBXFileReference section */
|
|
10
|
+
C56BE8092D78E44000407B70 /* attdet.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = attdet.c; sourceTree = "<group>"; };
|
|
11
|
+
C56BE80A2D78E44000407B70 /* makefile.mk */ = {isa = PBXFileReference; lastKnownFileType = text; path = makefile.mk; sourceTree = "<group>"; };
|
|
12
|
+
C56BE80B2D78E44000407B70 /* bwdet.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = bwdet.h; sourceTree = "<group>"; };
|
|
13
|
+
C56BE80C2D78E44000407B70 /* ltpf.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = ltpf.c; sourceTree = "<group>"; };
|
|
14
|
+
C56BE80D2D78E44000407B70 /* tables.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = tables.c; sourceTree = "<group>"; };
|
|
15
|
+
C56BE80E2D78E44000407B70 /* spec.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = spec.c; sourceTree = "<group>"; };
|
|
16
|
+
C56BE80F2D78E44000407B70 /* plc.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = plc.c; sourceTree = "<group>"; };
|
|
17
|
+
C56BE8102D78E44000407B70 /* energy.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = energy.c; sourceTree = "<group>"; };
|
|
18
|
+
C56BE8112D78E44000407B70 /* lc3.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = lc3.h; sourceTree = "<group>"; };
|
|
19
|
+
C56BE8122D78E44000407B70 /* rnnoise.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = rnnoise.h; sourceTree = "<group>"; };
|
|
20
|
+
C56BE8132D78E44000407B70 /* lc3_private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = lc3_private.h; sourceTree = "<group>"; };
|
|
21
|
+
C56BE8142D78E44000407B70 /* sns.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = sns.c; sourceTree = "<group>"; };
|
|
22
|
+
C56BE8152D78E44000407B70 /* mdct.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = mdct.c; sourceTree = "<group>"; };
|
|
23
|
+
C56BE8162D78E44000407B70 /* include */ = {isa = PBXFileReference; lastKnownFileType = folder; path = include; sourceTree = "<group>"; };
|
|
24
|
+
C56BE8172D78E44000407B70 /* tns.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = tns.c; sourceTree = "<group>"; };
|
|
25
|
+
C56BE8182D78E44000407B70 /* bits.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = bits.c; sourceTree = "<group>"; };
|
|
26
|
+
C56BE8192D78E44000407B70 /* PcmConverter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PcmConverter.h; sourceTree = "<group>"; };
|
|
27
|
+
C56BE81A2D78E44000407B70 /* fastmath.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = fastmath.h; sourceTree = "<group>"; };
|
|
28
|
+
C56BE81B2D78E44000407B70 /* meson.build */ = {isa = PBXFileReference; lastKnownFileType = text; path = meson.build; sourceTree = "<group>"; };
|
|
29
|
+
C56BE81C2D78E44000407B70 /* spec.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = spec.h; sourceTree = "<group>"; };
|
|
30
|
+
C56BE81D2D78E44000407B70 /* tables.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tables.h; sourceTree = "<group>"; };
|
|
31
|
+
C56BE81E2D78E44000407B70 /* ltpf.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ltpf.h; sourceTree = "<group>"; };
|
|
32
|
+
C56BE81F2D78E44000407B70 /* bwdet.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = bwdet.c; sourceTree = "<group>"; };
|
|
33
|
+
C56BE8202D78E44000407B70 /* common.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = common.h; sourceTree = "<group>"; };
|
|
34
|
+
C56BE8212D78E44000407B70 /* attdet.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = attdet.h; sourceTree = "<group>"; };
|
|
35
|
+
C56BE8222D78E44000407B70 /* lc3.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = lc3.c; sourceTree = "<group>"; };
|
|
36
|
+
C56BE8232D78E44000407B70 /* ltpf_neon.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ltpf_neon.h; sourceTree = "<group>"; };
|
|
37
|
+
C56BE8242D78E44000407B70 /* energy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = energy.h; sourceTree = "<group>"; };
|
|
38
|
+
C56BE8252D78E44000407B70 /* plc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = plc.h; sourceTree = "<group>"; };
|
|
39
|
+
C56BE8262D78E44000407B70 /* lc3_cpp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = lc3_cpp.h; sourceTree = "<group>"; };
|
|
40
|
+
C56BE8272D78E44000407B70 /* ltpf_arm.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ltpf_arm.h; sourceTree = "<group>"; };
|
|
41
|
+
C56BE8282D78E44000407B70 /* mdct.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mdct.h; sourceTree = "<group>"; };
|
|
42
|
+
C56BE8292D78E44000407B70 /* sns.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = sns.h; sourceTree = "<group>"; };
|
|
43
|
+
C56BE82A2D78E44000407B70 /* mdct_neon.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = mdct_neon.h; sourceTree = "<group>"; };
|
|
44
|
+
C56BE82B2D78E44000407B70 /* PcmConverter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PcmConverter.m; sourceTree = "<group>"; };
|
|
45
|
+
C56BE82C2D78E44000407B70 /* bits.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = bits.h; sourceTree = "<group>"; };
|
|
46
|
+
C56BE82D2D78E44000407B70 /* tns.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tns.h; sourceTree = "<group>"; };
|
|
47
|
+
/* End PBXFileReference section */
|
|
48
|
+
|
|
49
|
+
/* Begin PBXGroup section */
|
|
50
|
+
C56BE8032D78E44000407B70 = {
|
|
51
|
+
isa = PBXGroup;
|
|
52
|
+
children = (
|
|
53
|
+
C56BE8092D78E44000407B70 /* attdet.c */,
|
|
54
|
+
C56BE80A2D78E44000407B70 /* makefile.mk */,
|
|
55
|
+
C56BE80B2D78E44000407B70 /* bwdet.h */,
|
|
56
|
+
C56BE80C2D78E44000407B70 /* ltpf.c */,
|
|
57
|
+
C56BE80D2D78E44000407B70 /* tables.c */,
|
|
58
|
+
C56BE80E2D78E44000407B70 /* spec.c */,
|
|
59
|
+
C56BE80F2D78E44000407B70 /* plc.c */,
|
|
60
|
+
C56BE8102D78E44000407B70 /* energy.c */,
|
|
61
|
+
C56BE8112D78E44000407B70 /* lc3.h */,
|
|
62
|
+
C56BE8122D78E44000407B70 /* rnnoise.h */,
|
|
63
|
+
C56BE8132D78E44000407B70 /* lc3_private.h */,
|
|
64
|
+
C56BE8142D78E44000407B70 /* sns.c */,
|
|
65
|
+
C56BE8152D78E44000407B70 /* mdct.c */,
|
|
66
|
+
C56BE8162D78E44000407B70 /* include */,
|
|
67
|
+
C56BE8172D78E44000407B70 /* tns.c */,
|
|
68
|
+
C56BE8182D78E44000407B70 /* bits.c */,
|
|
69
|
+
C56BE8192D78E44000407B70 /* PcmConverter.h */,
|
|
70
|
+
C56BE81A2D78E44000407B70 /* fastmath.h */,
|
|
71
|
+
C56BE81B2D78E44000407B70 /* meson.build */,
|
|
72
|
+
C56BE81C2D78E44000407B70 /* spec.h */,
|
|
73
|
+
C56BE81D2D78E44000407B70 /* tables.h */,
|
|
74
|
+
C56BE81E2D78E44000407B70 /* ltpf.h */,
|
|
75
|
+
C56BE81F2D78E44000407B70 /* bwdet.c */,
|
|
76
|
+
C56BE8202D78E44000407B70 /* common.h */,
|
|
77
|
+
C56BE8212D78E44000407B70 /* attdet.h */,
|
|
78
|
+
C56BE8222D78E44000407B70 /* lc3.c */,
|
|
79
|
+
C56BE8232D78E44000407B70 /* ltpf_neon.h */,
|
|
80
|
+
C56BE8242D78E44000407B70 /* energy.h */,
|
|
81
|
+
C56BE8252D78E44000407B70 /* plc.h */,
|
|
82
|
+
C56BE8262D78E44000407B70 /* lc3_cpp.h */,
|
|
83
|
+
C56BE8272D78E44000407B70 /* ltpf_arm.h */,
|
|
84
|
+
C56BE8282D78E44000407B70 /* mdct.h */,
|
|
85
|
+
C56BE8292D78E44000407B70 /* sns.h */,
|
|
86
|
+
C56BE82A2D78E44000407B70 /* mdct_neon.h */,
|
|
87
|
+
C56BE82B2D78E44000407B70 /* PcmConverter.m */,
|
|
88
|
+
C56BE82C2D78E44000407B70 /* bits.h */,
|
|
89
|
+
C56BE82D2D78E44000407B70 /* tns.h */,
|
|
90
|
+
);
|
|
91
|
+
sourceTree = "<group>";
|
|
92
|
+
};
|
|
93
|
+
/* End PBXGroup section */
|
|
94
|
+
|
|
95
|
+
/* Begin PBXLegacyTarget section */
|
|
96
|
+
C56BE8082D78E44000407B70 /* CoreObjC */ = {
|
|
97
|
+
isa = PBXLegacyTarget;
|
|
98
|
+
buildArgumentsString = "$(ACTION)";
|
|
99
|
+
buildConfigurationList = C56BE82E2D78E44000407B70 /* Build configuration list for PBXLegacyTarget "CoreObjC" */;
|
|
100
|
+
buildPhases = (
|
|
101
|
+
);
|
|
102
|
+
buildToolPath = /usr/bin/make;
|
|
103
|
+
buildWorkingDirectory = /Users/fosse/dev/AugmentOS/mobile/ios/Packages/CoreObjC;
|
|
104
|
+
dependencies = (
|
|
105
|
+
);
|
|
106
|
+
name = CoreObjC;
|
|
107
|
+
packageProductDependencies = (
|
|
108
|
+
);
|
|
109
|
+
passBuildSettingsInEnvironment = 1;
|
|
110
|
+
productName = CoreObjC;
|
|
111
|
+
};
|
|
112
|
+
/* End PBXLegacyTarget section */
|
|
113
|
+
|
|
114
|
+
/* Begin PBXProject section */
|
|
115
|
+
C56BE8042D78E44000407B70 /* Project object */ = {
|
|
116
|
+
isa = PBXProject;
|
|
117
|
+
attributes = {
|
|
118
|
+
BuildIndependentTargetsInParallel = 1;
|
|
119
|
+
};
|
|
120
|
+
buildConfigurationList = C56BE8072D78E44000407B70 /* Build configuration list for PBXProject "CoreObjC" */;
|
|
121
|
+
developmentRegion = en;
|
|
122
|
+
hasScannedForEncodings = 0;
|
|
123
|
+
knownRegions = (
|
|
124
|
+
en,
|
|
125
|
+
Base,
|
|
126
|
+
);
|
|
127
|
+
mainGroup = C56BE8032D78E44000407B70;
|
|
128
|
+
minimizedProjectReferenceProxies = 1;
|
|
129
|
+
preferredProjectObjectVersion = 77;
|
|
130
|
+
projectDirPath = "";
|
|
131
|
+
projectRoot = "";
|
|
132
|
+
targets = (
|
|
133
|
+
C56BE8082D78E44000407B70 /* CoreObjC */,
|
|
134
|
+
);
|
|
135
|
+
};
|
|
136
|
+
/* End PBXProject section */
|
|
137
|
+
|
|
138
|
+
/* Begin XCBuildConfiguration section */
|
|
139
|
+
C56BE8052D78E44000407B70 /* Debug */ = {
|
|
140
|
+
isa = XCBuildConfiguration;
|
|
141
|
+
buildSettings = {
|
|
142
|
+
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
|
143
|
+
COPY_PHASE_STRIP = NO;
|
|
144
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
|
145
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
146
|
+
ONLY_ACTIVE_ARCH = YES;
|
|
147
|
+
SDKROOT = macosx10.6;
|
|
148
|
+
};
|
|
149
|
+
name = Debug;
|
|
150
|
+
};
|
|
151
|
+
C56BE8062D78E44000407B70 /* Release */ = {
|
|
152
|
+
isa = XCBuildConfiguration;
|
|
153
|
+
buildSettings = {
|
|
154
|
+
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
|
|
155
|
+
COPY_PHASE_STRIP = YES;
|
|
156
|
+
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
|
157
|
+
GCC_WARN_UNUSED_VARIABLE = YES;
|
|
158
|
+
SDKROOT = macosx10.6;
|
|
159
|
+
};
|
|
160
|
+
name = Release;
|
|
161
|
+
};
|
|
162
|
+
C56BE82F2D78E44000407B70 /* Debug */ = {
|
|
163
|
+
isa = XCBuildConfiguration;
|
|
164
|
+
buildSettings = {
|
|
165
|
+
COPY_PHASE_STRIP = NO;
|
|
166
|
+
DEBUGGING_SYMBOLS = YES;
|
|
167
|
+
GCC_DYNAMIC_NO_PIC = NO;
|
|
168
|
+
GCC_ENABLE_FIX_AND_CONTINUE = YES;
|
|
169
|
+
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
|
|
170
|
+
GCC_OPTIMIZATION_LEVEL = 0;
|
|
171
|
+
OTHER_CFLAGS = "";
|
|
172
|
+
OTHER_LDFLAGS = "";
|
|
173
|
+
PRODUCT_NAME = CoreObjC;
|
|
174
|
+
};
|
|
175
|
+
name = Debug;
|
|
176
|
+
};
|
|
177
|
+
C56BE8302D78E44000407B70 /* Release */ = {
|
|
178
|
+
isa = XCBuildConfiguration;
|
|
179
|
+
buildSettings = {
|
|
180
|
+
COPY_PHASE_STRIP = YES;
|
|
181
|
+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
|
182
|
+
GCC_ENABLE_FIX_AND_CONTINUE = NO;
|
|
183
|
+
OTHER_CFLAGS = "";
|
|
184
|
+
OTHER_LDFLAGS = "";
|
|
185
|
+
PRODUCT_NAME = CoreObjC;
|
|
186
|
+
};
|
|
187
|
+
name = Release;
|
|
188
|
+
};
|
|
189
|
+
/* End XCBuildConfiguration section */
|
|
190
|
+
|
|
191
|
+
/* Begin XCConfigurationList section */
|
|
192
|
+
C56BE8072D78E44000407B70 /* Build configuration list for PBXProject "CoreObjC" */ = {
|
|
193
|
+
isa = XCConfigurationList;
|
|
194
|
+
buildConfigurations = (
|
|
195
|
+
C56BE8052D78E44000407B70 /* Debug */,
|
|
196
|
+
C56BE8062D78E44000407B70 /* Release */,
|
|
197
|
+
);
|
|
198
|
+
defaultConfigurationIsVisible = 0;
|
|
199
|
+
defaultConfigurationName = Release;
|
|
200
|
+
};
|
|
201
|
+
C56BE82E2D78E44000407B70 /* Build configuration list for PBXLegacyTarget "CoreObjC" */ = {
|
|
202
|
+
isa = XCConfigurationList;
|
|
203
|
+
buildConfigurations = (
|
|
204
|
+
C56BE82F2D78E44000407B70 /* Debug */,
|
|
205
|
+
C56BE8302D78E44000407B70 /* Release */,
|
|
206
|
+
);
|
|
207
|
+
defaultConfigurationIsVisible = 0;
|
|
208
|
+
defaultConfigurationName = Release;
|
|
209
|
+
};
|
|
210
|
+
/* End XCConfigurationList section */
|
|
211
|
+
};
|
|
212
|
+
rootObject = C56BE8042D78E44000407B70 /* Project object */;
|
|
213
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
// PcmConverter.h
|
|
3
|
+
// Runner
|
|
4
|
+
//
|
|
5
|
+
// Created by Hawk on 2024/3/14.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
|
|
10
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
11
|
+
|
|
12
|
+
@interface PcmConverter : NSObject
|
|
13
|
+
+ (void)setupStaticEncoderAndDecoder;
|
|
14
|
+
-(NSMutableData *)decode: (NSData *)lc3data frameSize:(NSInteger)frameSize;
|
|
15
|
+
-(NSMutableData *)encode: (NSData *)pcmdata frameSize:(NSInteger)frameSize;
|
|
16
|
+
-(void)setOutputFrameSize:(NSInteger)frameSize;
|
|
17
|
+
-(NSInteger)getOutputFrameSize;
|
|
18
|
+
-(void)resetEncoder;
|
|
19
|
+
-(void)resetDecoder;
|
|
20
|
+
@end
|
|
21
|
+
|
|
22
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
//
|
|
2
|
+
// PcmConverter.m
|
|
3
|
+
// Runner
|
|
4
|
+
//
|
|
5
|
+
// Created by Hawk on 2024/3/14.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import "PcmConverter.h"
|
|
9
|
+
#import "lc3.h"
|
|
10
|
+
|
|
11
|
+
@implementation PcmConverter {
|
|
12
|
+
// Instance variables for persistent decoder
|
|
13
|
+
lc3_decoder_t _lc3_decoder;
|
|
14
|
+
void* _decMem;
|
|
15
|
+
unsigned char* _outBuf;
|
|
16
|
+
BOOL _decoderInitialized;
|
|
17
|
+
|
|
18
|
+
// Decoder parameters
|
|
19
|
+
unsigned _decodeSize;
|
|
20
|
+
uint16_t _sampleOfFrames;
|
|
21
|
+
uint16_t _bytesOfFrames;
|
|
22
|
+
|
|
23
|
+
// Instance variables for persistent encoder
|
|
24
|
+
lc3_encoder_t _lc3_encoder;
|
|
25
|
+
void* _encMem;
|
|
26
|
+
unsigned char* _encOutBuf;
|
|
27
|
+
BOOL _encoderInitialized;
|
|
28
|
+
unsigned _encodeSize;
|
|
29
|
+
|
|
30
|
+
// Sample accumulation buffer for encoder
|
|
31
|
+
// LC3 requires exactly 160 samples (320 bytes) per frame at 16kHz/10ms
|
|
32
|
+
// iOS audio callbacks may not align with frame boundaries, so we accumulate samples
|
|
33
|
+
NSMutableData* _encAccumulationBuffer;
|
|
34
|
+
|
|
35
|
+
// Configurable output frame size (determines bitrate)
|
|
36
|
+
// 20 bytes = 16kbps, 40 bytes = 32kbps, 60 bytes = 48kbps
|
|
37
|
+
uint16_t _outputFrameSize;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Frame length 10ms
|
|
41
|
+
static const int dtUs = 10000;
|
|
42
|
+
// Sampling rate 16kHz
|
|
43
|
+
static const int srHz = 16000;
|
|
44
|
+
// Default output bytes after encoding a single frame (can be changed via setOutputFrameSize)
|
|
45
|
+
static const uint16_t defaultOutputByteCount = 20;
|
|
46
|
+
|
|
47
|
+
- (instancetype)init {
|
|
48
|
+
self = [super init];
|
|
49
|
+
if (self) {
|
|
50
|
+
_decoderInitialized = NO;
|
|
51
|
+
_decMem = NULL;
|
|
52
|
+
_outBuf = NULL;
|
|
53
|
+
_encoderInitialized = NO;
|
|
54
|
+
_encMem = NULL;
|
|
55
|
+
_encOutBuf = NULL;
|
|
56
|
+
_encAccumulationBuffer = [[NSMutableData alloc] init];
|
|
57
|
+
_outputFrameSize = defaultOutputByteCount;
|
|
58
|
+
}
|
|
59
|
+
return self;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
- (void)setOutputFrameSize:(NSInteger)frameSize {
|
|
63
|
+
// Validate frame size (20, 40, or 60 bytes)
|
|
64
|
+
if (frameSize != 20 && frameSize != 40 && frameSize != 60) {
|
|
65
|
+
printf("Invalid frame size %ld, must be 20, 40, or 60. Using default.\n", (long)frameSize);
|
|
66
|
+
_outputFrameSize = defaultOutputByteCount;
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// If encoder is already initialized and frame size is changing, we need to reallocate output buffer
|
|
71
|
+
if (_encoderInitialized && _outputFrameSize != frameSize) {
|
|
72
|
+
if (_encOutBuf) {
|
|
73
|
+
free(_encOutBuf);
|
|
74
|
+
}
|
|
75
|
+
_encOutBuf = malloc(frameSize);
|
|
76
|
+
if (_encOutBuf == NULL) {
|
|
77
|
+
printf("Failed to reallocate encoder output buffer for new frame size\n");
|
|
78
|
+
_encoderInitialized = NO;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
_outputFrameSize = (uint16_t)frameSize;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
- (void)setupDecoder {
|
|
87
|
+
if (_decoderInitialized) {
|
|
88
|
+
return; // Already initialized
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
_decodeSize = lc3_decoder_size(dtUs, srHz);
|
|
92
|
+
_sampleOfFrames = lc3_frame_samples(dtUs, srHz);
|
|
93
|
+
_bytesOfFrames = _sampleOfFrames * 2;
|
|
94
|
+
|
|
95
|
+
_decMem = malloc(_decodeSize);
|
|
96
|
+
if (_decMem == NULL) {
|
|
97
|
+
printf("Failed to allocate memory for decoder\n");
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
_lc3_decoder = lc3_setup_decoder(dtUs, srHz, 0, _decMem);
|
|
102
|
+
|
|
103
|
+
_outBuf = malloc(_bytesOfFrames);
|
|
104
|
+
if (_outBuf == NULL) {
|
|
105
|
+
printf("Failed to allocate memory for outBuf\n");
|
|
106
|
+
free(_decMem);
|
|
107
|
+
_decMem = NULL;
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
_decoderInitialized = YES;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
- (NSMutableData *)decode:(NSData *)lc3data frameSize:(NSInteger)frameSize {
|
|
115
|
+
if (lc3data == nil) {
|
|
116
|
+
printf("Failed to decode Base64 data\n");
|
|
117
|
+
return [[NSMutableData alloc] init];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Setup decoder on first use
|
|
121
|
+
[self setupDecoder];
|
|
122
|
+
|
|
123
|
+
if (!_decoderInitialized) {
|
|
124
|
+
printf("Decoder not initialized\n");
|
|
125
|
+
return [[NSMutableData alloc] init];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
int totalBytes = (int)lc3data.length;
|
|
129
|
+
int bytesRead = 0;
|
|
130
|
+
|
|
131
|
+
NSMutableData *pcmData = [[NSMutableData alloc] init];
|
|
132
|
+
|
|
133
|
+
while (bytesRead < totalBytes) {
|
|
134
|
+
int bytesToRead = MIN(frameSize, totalBytes - bytesRead);
|
|
135
|
+
NSRange range = NSMakeRange(bytesRead, bytesToRead);
|
|
136
|
+
NSData *subdata = [lc3data subdataWithRange:range];
|
|
137
|
+
unsigned char *inBuf = (unsigned char *)subdata.bytes;
|
|
138
|
+
|
|
139
|
+
lc3_decode(_lc3_decoder, inBuf, frameSize, LC3_PCM_FORMAT_S16, _outBuf, 1);
|
|
140
|
+
|
|
141
|
+
NSData *data = [NSData dataWithBytes:_outBuf length:_bytesOfFrames];
|
|
142
|
+
[pcmData appendData:data];
|
|
143
|
+
bytesRead += bytesToRead;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return pcmData;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
- (void)resetDecoder {
|
|
150
|
+
// Call this if you need to reset the decoder state
|
|
151
|
+
if (_decoderInitialized && _decMem) {
|
|
152
|
+
_lc3_decoder = lc3_setup_decoder(dtUs, srHz, 0, _decMem);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
- (void)resetEncoder {
|
|
157
|
+
// Call this when starting a new recording session to clear accumulated samples
|
|
158
|
+
// and reset encoder state for clean audio
|
|
159
|
+
[_encAccumulationBuffer setLength:0];
|
|
160
|
+
if (_encoderInitialized && _encMem) {
|
|
161
|
+
_lc3_encoder = lc3_setup_encoder(dtUs, srHz, 0, _encMem);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
- (void)setupEncoder {
|
|
166
|
+
if (_encoderInitialized) {
|
|
167
|
+
return; // Already initialized
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
_encodeSize = lc3_encoder_size(dtUs, srHz);
|
|
171
|
+
|
|
172
|
+
_encMem = malloc(_encodeSize);
|
|
173
|
+
if (_encMem == NULL) {
|
|
174
|
+
printf("Failed to allocate memory for encoder\n");
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
_lc3_encoder = lc3_setup_encoder(dtUs, srHz, 0, _encMem);
|
|
179
|
+
|
|
180
|
+
_encOutBuf = malloc(_outputFrameSize);
|
|
181
|
+
if (_encOutBuf == NULL) {
|
|
182
|
+
printf("Failed to allocate memory for encoder output buffer\n");
|
|
183
|
+
free(_encMem);
|
|
184
|
+
_encMem = NULL;
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
_encoderInitialized = YES;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
- (NSMutableData *)encode:(NSData *)pcmdata frameSize:(NSInteger)frameSize {
|
|
192
|
+
if (pcmdata == nil || pcmdata.length == 0) {
|
|
193
|
+
return [[NSMutableData alloc] init];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// Setup encoder on first use
|
|
197
|
+
[self setupEncoder];
|
|
198
|
+
|
|
199
|
+
if (!_encoderInitialized) {
|
|
200
|
+
printf("Encoder not initialized\n");
|
|
201
|
+
return [[NSMutableData alloc] init];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// if the frame size is not set to the passed in frame size, we need to reallocate the output buffer:
|
|
205
|
+
if (frameSize != _outputFrameSize) {
|
|
206
|
+
[self setOutputFrameSize:frameSize];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// LC3 frame size: 160 samples * 2 bytes = 320 bytes per frame
|
|
210
|
+
uint16_t bytesPerFrame = lc3_frame_samples(dtUs, srHz) * 2;
|
|
211
|
+
|
|
212
|
+
// Append new PCM data to accumulation buffer
|
|
213
|
+
[_encAccumulationBuffer appendData:pcmdata];
|
|
214
|
+
|
|
215
|
+
NSMutableData *lc3Data = [[NSMutableData alloc] init];
|
|
216
|
+
const int16_t *pcmSamples = (const int16_t *)_encAccumulationBuffer.bytes;
|
|
217
|
+
int totalBytes = (int)_encAccumulationBuffer.length;
|
|
218
|
+
int bytesRead = 0;
|
|
219
|
+
|
|
220
|
+
// Encode complete frames from the accumulation buffer
|
|
221
|
+
while (totalBytes - bytesRead >= bytesPerFrame) {
|
|
222
|
+
const int16_t *currentSamples = pcmSamples + (bytesRead / 2);
|
|
223
|
+
int result = lc3_encode(_lc3_encoder, LC3_PCM_FORMAT_S16, currentSamples, 1, _outputFrameSize, _encOutBuf);
|
|
224
|
+
|
|
225
|
+
if (result == 0) {
|
|
226
|
+
[lc3Data appendBytes:_encOutBuf length:_outputFrameSize];
|
|
227
|
+
}
|
|
228
|
+
bytesRead += bytesPerFrame;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Keep leftover samples in the accumulation buffer for next call
|
|
232
|
+
if (bytesRead > 0) {
|
|
233
|
+
NSData *leftover = [_encAccumulationBuffer subdataWithRange:NSMakeRange(bytesRead, totalBytes - bytesRead)];
|
|
234
|
+
[_encAccumulationBuffer setLength:0];
|
|
235
|
+
[_encAccumulationBuffer appendData:leftover];
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return lc3Data;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
- (void)dealloc {
|
|
242
|
+
if (_decMem) {
|
|
243
|
+
free(_decMem);
|
|
244
|
+
_decMem = NULL;
|
|
245
|
+
}
|
|
246
|
+
if (_outBuf) {
|
|
247
|
+
free(_outBuf);
|
|
248
|
+
_outBuf = NULL;
|
|
249
|
+
}
|
|
250
|
+
_decoderInitialized = NO;
|
|
251
|
+
|
|
252
|
+
if (_encMem) {
|
|
253
|
+
free(_encMem);
|
|
254
|
+
_encMem = NULL;
|
|
255
|
+
}
|
|
256
|
+
if (_encOutBuf) {
|
|
257
|
+
free(_encOutBuf);
|
|
258
|
+
_encOutBuf = NULL;
|
|
259
|
+
}
|
|
260
|
+
if (_encAccumulationBuffer) {
|
|
261
|
+
[_encAccumulationBuffer setLength:0];
|
|
262
|
+
_encAccumulationBuffer = nil;
|
|
263
|
+
}
|
|
264
|
+
_encoderInitialized = NO;
|
|
265
|
+
}
|
|
266
|
+
@end
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
#include "attdet.h"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Time domain attack detector
|
|
24
|
+
*/
|
|
25
|
+
bool lc3_attdet_run(enum lc3_dt dt, enum lc3_srate sr,
|
|
26
|
+
int nbytes, struct lc3_attdet_analysis *attdet, const int16_t *x)
|
|
27
|
+
{
|
|
28
|
+
/* --- Check enabling --- */
|
|
29
|
+
|
|
30
|
+
const int nbytes_ranges[LC3_NUM_DT][LC3_NUM_SRATE - LC3_SRATE_32K][2] = {
|
|
31
|
+
[LC3_DT_7M5] = { { 61, 149 }, { 75, 149 } },
|
|
32
|
+
[LC3_DT_10M] = { { 81, INT_MAX }, { 100, INT_MAX } },
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
if (sr < LC3_SRATE_32K ||
|
|
36
|
+
nbytes < nbytes_ranges[dt][sr - LC3_SRATE_32K][0] ||
|
|
37
|
+
nbytes > nbytes_ranges[dt][sr - LC3_SRATE_32K][1] )
|
|
38
|
+
return 0;
|
|
39
|
+
|
|
40
|
+
/* --- Filtering & Energy calculation --- */
|
|
41
|
+
|
|
42
|
+
int nblk = 4 - (dt == LC3_DT_7M5);
|
|
43
|
+
int32_t e[4];
|
|
44
|
+
|
|
45
|
+
for (int i = 0; i < nblk; i++) {
|
|
46
|
+
e[i] = 0;
|
|
47
|
+
|
|
48
|
+
if (sr == LC3_SRATE_32K) {
|
|
49
|
+
int16_t xn2 = (x[-4] + x[-3]) >> 1;
|
|
50
|
+
int16_t xn1 = (x[-2] + x[-1]) >> 1;
|
|
51
|
+
int16_t xn, xf;
|
|
52
|
+
|
|
53
|
+
for (int j = 0; j < 40; j++, x += 2, xn2 = xn1, xn1 = xn) {
|
|
54
|
+
xn = (x[0] + x[1]) >> 1;
|
|
55
|
+
xf = (3 * xn - 4 * xn1 + 1 * xn2) >> 3;
|
|
56
|
+
e[i] += (xf * xf) >> 5;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
else {
|
|
61
|
+
int16_t xn2 = (x[-6] + x[-5] + x[-4]) >> 2;
|
|
62
|
+
int16_t xn1 = (x[-3] + x[-2] + x[-1]) >> 2;
|
|
63
|
+
int16_t xn, xf;
|
|
64
|
+
|
|
65
|
+
for (int j = 0; j < 40; j++, x += 3, xn2 = xn1, xn1 = xn) {
|
|
66
|
+
xn = (x[0] + x[1] + x[2]) >> 2;
|
|
67
|
+
xf = (3 * xn - 4 * xn1 + 1 * xn2) >> 3;
|
|
68
|
+
e[i] += (xf * xf) >> 5;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/* --- Attack detection ---
|
|
74
|
+
* The attack block `p_att` is defined as the normative value + 1,
|
|
75
|
+
* in such way, it will be initialized to 0 */
|
|
76
|
+
|
|
77
|
+
int p_att = 0;
|
|
78
|
+
int32_t a[4];
|
|
79
|
+
|
|
80
|
+
for (int i = 0; i < nblk; i++) {
|
|
81
|
+
a[i] = LC3_MAX(attdet->an1 >> 2, attdet->en1);
|
|
82
|
+
attdet->en1 = e[i], attdet->an1 = a[i];
|
|
83
|
+
|
|
84
|
+
if ((e[i] >> 3) > a[i] + (a[i] >> 4))
|
|
85
|
+
p_att = i + 1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
int att = attdet->p_att >= 1 + (nblk >> 1) || p_att > 0;
|
|
89
|
+
attdet->p_att = p_att;
|
|
90
|
+
|
|
91
|
+
return att;
|
|
92
|
+
}
|