@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,279 @@
|
|
|
1
|
+
/* Copyright (c) 2009-2010 Xiph.Org Foundation
|
|
2
|
+
Written by Jean-Marc Valin */
|
|
3
|
+
/*
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions
|
|
6
|
+
are met:
|
|
7
|
+
|
|
8
|
+
- Redistributions of source code must retain the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
- Redistributions in binary form must reproduce the above copyright
|
|
12
|
+
notice, this list of conditions and the following disclaimer in the
|
|
13
|
+
documentation and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
16
|
+
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
17
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
18
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
|
19
|
+
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
22
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
#ifdef HAVE_CONFIG_H
|
|
29
|
+
#include "config.h"
|
|
30
|
+
#endif
|
|
31
|
+
|
|
32
|
+
#include "celt_lpc.h"
|
|
33
|
+
#include "arch.h"
|
|
34
|
+
#include "common.h"
|
|
35
|
+
#include "pitch.h"
|
|
36
|
+
|
|
37
|
+
void _celt_lpc(
|
|
38
|
+
opus_val16 *_lpc, /* out: [0...p-1] LPC coefficients */
|
|
39
|
+
const opus_val32 *ac, /* in: [0...p] autocorrelation values */
|
|
40
|
+
int p
|
|
41
|
+
)
|
|
42
|
+
{
|
|
43
|
+
int i, j;
|
|
44
|
+
opus_val32 r;
|
|
45
|
+
opus_val32 error = ac[0];
|
|
46
|
+
#ifdef FIXED_POINT
|
|
47
|
+
opus_val32 lpc[LPC_ORDER];
|
|
48
|
+
#else
|
|
49
|
+
float *lpc = _lpc;
|
|
50
|
+
#endif
|
|
51
|
+
|
|
52
|
+
RNN_CLEAR(lpc, p);
|
|
53
|
+
if (ac[0] != 0)
|
|
54
|
+
{
|
|
55
|
+
for (i = 0; i < p; i++) {
|
|
56
|
+
/* Sum up this iteration's reflection coefficient */
|
|
57
|
+
opus_val32 rr = 0;
|
|
58
|
+
for (j = 0; j < i; j++)
|
|
59
|
+
rr += MULT32_32_Q31(lpc[j],ac[i - j]);
|
|
60
|
+
rr += SHR32(ac[i + 1],3);
|
|
61
|
+
r = -SHL32(rr,3)/error;
|
|
62
|
+
/* Update LPC coefficients and total error */
|
|
63
|
+
lpc[i] = SHR32(r,3);
|
|
64
|
+
for (j = 0; j < (i+1)>>1; j++)
|
|
65
|
+
{
|
|
66
|
+
opus_val32 tmp1, tmp2;
|
|
67
|
+
tmp1 = lpc[j];
|
|
68
|
+
tmp2 = lpc[i-1-j];
|
|
69
|
+
lpc[j] = tmp1 + MULT32_32_Q31(r,tmp2);
|
|
70
|
+
lpc[i-1-j] = tmp2 + MULT32_32_Q31(r,tmp1);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
error = error - MULT32_32_Q31(MULT32_32_Q31(r,r),error);
|
|
74
|
+
/* Bail out once we get 30 dB gain */
|
|
75
|
+
#ifdef FIXED_POINT
|
|
76
|
+
if (error<SHR32(ac[0],10))
|
|
77
|
+
break;
|
|
78
|
+
#else
|
|
79
|
+
if (error<.001f*ac[0])
|
|
80
|
+
break;
|
|
81
|
+
#endif
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
#ifdef FIXED_POINT
|
|
85
|
+
for (i=0;i<p;i++)
|
|
86
|
+
_lpc[i] = ROUND16(lpc[i],16);
|
|
87
|
+
#endif
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
void celt_fir(
|
|
92
|
+
const opus_val16 *x,
|
|
93
|
+
const opus_val16 *num,
|
|
94
|
+
opus_val16 *y,
|
|
95
|
+
int N,
|
|
96
|
+
int ord)
|
|
97
|
+
{
|
|
98
|
+
int i,j;
|
|
99
|
+
opus_val16 rnum[ord];
|
|
100
|
+
for(i=0;i<ord;i++)
|
|
101
|
+
rnum[i] = num[ord-i-1];
|
|
102
|
+
for (i=0;i<N-3;i+=4)
|
|
103
|
+
{
|
|
104
|
+
opus_val32 sum[4];
|
|
105
|
+
sum[0] = SHL32(EXTEND32(x[i ]), SIG_SHIFT);
|
|
106
|
+
sum[1] = SHL32(EXTEND32(x[i+1]), SIG_SHIFT);
|
|
107
|
+
sum[2] = SHL32(EXTEND32(x[i+2]), SIG_SHIFT);
|
|
108
|
+
sum[3] = SHL32(EXTEND32(x[i+3]), SIG_SHIFT);
|
|
109
|
+
xcorr_kernel(rnum, x+i-ord, sum, ord);
|
|
110
|
+
y[i ] = ROUND16(sum[0], SIG_SHIFT);
|
|
111
|
+
y[i+1] = ROUND16(sum[1], SIG_SHIFT);
|
|
112
|
+
y[i+2] = ROUND16(sum[2], SIG_SHIFT);
|
|
113
|
+
y[i+3] = ROUND16(sum[3], SIG_SHIFT);
|
|
114
|
+
}
|
|
115
|
+
for (;i<N;i++)
|
|
116
|
+
{
|
|
117
|
+
opus_val32 sum = SHL32(EXTEND32(x[i]), SIG_SHIFT);
|
|
118
|
+
for (j=0;j<ord;j++)
|
|
119
|
+
sum = MAC16_16(sum,rnum[j],x[i+j-ord]);
|
|
120
|
+
y[i] = ROUND16(sum, SIG_SHIFT);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
void celt_iir(const opus_val32 *_x,
|
|
125
|
+
const opus_val16 *den,
|
|
126
|
+
opus_val32 *_y,
|
|
127
|
+
int N,
|
|
128
|
+
int ord,
|
|
129
|
+
opus_val16 *mem)
|
|
130
|
+
{
|
|
131
|
+
#ifdef SMALL_FOOTPRINT
|
|
132
|
+
int i,j;
|
|
133
|
+
for (i=0;i<N;i++)
|
|
134
|
+
{
|
|
135
|
+
opus_val32 sum = _x[i];
|
|
136
|
+
for (j=0;j<ord;j++)
|
|
137
|
+
{
|
|
138
|
+
sum -= MULT16_16(den[j],mem[j]);
|
|
139
|
+
}
|
|
140
|
+
for (j=ord-1;j>=1;j--)
|
|
141
|
+
{
|
|
142
|
+
mem[j]=mem[j-1];
|
|
143
|
+
}
|
|
144
|
+
mem[0] = SROUND16(sum, SIG_SHIFT);
|
|
145
|
+
_y[i] = sum;
|
|
146
|
+
}
|
|
147
|
+
#else
|
|
148
|
+
int i,j;
|
|
149
|
+
celt_assert((ord&3)==0);
|
|
150
|
+
opus_val16 rden[ord];
|
|
151
|
+
opus_val16 y[N+ord];
|
|
152
|
+
for(i=0;i<ord;i++)
|
|
153
|
+
rden[i] = den[ord-i-1];
|
|
154
|
+
for(i=0;i<ord;i++)
|
|
155
|
+
y[i] = -mem[ord-i-1];
|
|
156
|
+
for(;i<N+ord;i++)
|
|
157
|
+
y[i]=0;
|
|
158
|
+
for (i=0;i<N-3;i+=4)
|
|
159
|
+
{
|
|
160
|
+
/* Unroll by 4 as if it were an FIR filter */
|
|
161
|
+
opus_val32 sum[4];
|
|
162
|
+
sum[0]=_x[i];
|
|
163
|
+
sum[1]=_x[i+1];
|
|
164
|
+
sum[2]=_x[i+2];
|
|
165
|
+
sum[3]=_x[i+3];
|
|
166
|
+
xcorr_kernel(rden, y+i, sum, ord);
|
|
167
|
+
|
|
168
|
+
/* Patch up the result to compensate for the fact that this is an IIR */
|
|
169
|
+
y[i+ord ] = -SROUND16(sum[0],SIG_SHIFT);
|
|
170
|
+
_y[i ] = sum[0];
|
|
171
|
+
sum[1] = MAC16_16(sum[1], y[i+ord ], den[0]);
|
|
172
|
+
y[i+ord+1] = -SROUND16(sum[1],SIG_SHIFT);
|
|
173
|
+
_y[i+1] = sum[1];
|
|
174
|
+
sum[2] = MAC16_16(sum[2], y[i+ord+1], den[0]);
|
|
175
|
+
sum[2] = MAC16_16(sum[2], y[i+ord ], den[1]);
|
|
176
|
+
y[i+ord+2] = -SROUND16(sum[2],SIG_SHIFT);
|
|
177
|
+
_y[i+2] = sum[2];
|
|
178
|
+
|
|
179
|
+
sum[3] = MAC16_16(sum[3], y[i+ord+2], den[0]);
|
|
180
|
+
sum[3] = MAC16_16(sum[3], y[i+ord+1], den[1]);
|
|
181
|
+
sum[3] = MAC16_16(sum[3], y[i+ord ], den[2]);
|
|
182
|
+
y[i+ord+3] = -SROUND16(sum[3],SIG_SHIFT);
|
|
183
|
+
_y[i+3] = sum[3];
|
|
184
|
+
}
|
|
185
|
+
for (;i<N;i++)
|
|
186
|
+
{
|
|
187
|
+
opus_val32 sum = _x[i];
|
|
188
|
+
for (j=0;j<ord;j++)
|
|
189
|
+
sum -= MULT16_16(rden[j],y[i+j]);
|
|
190
|
+
y[i+ord] = SROUND16(sum,SIG_SHIFT);
|
|
191
|
+
_y[i] = sum;
|
|
192
|
+
}
|
|
193
|
+
for(i=0;i<ord;i++)
|
|
194
|
+
mem[i] = _y[N-i-1];
|
|
195
|
+
#endif
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
int _celt_autocorr(
|
|
199
|
+
const opus_val16 *x, /* in: [0...n-1] samples x */
|
|
200
|
+
opus_val32 *ac, /* out: [0...lag-1] ac values */
|
|
201
|
+
const opus_val16 *window,
|
|
202
|
+
int overlap,
|
|
203
|
+
int lag,
|
|
204
|
+
int n)
|
|
205
|
+
{
|
|
206
|
+
opus_val32 d;
|
|
207
|
+
int i, k;
|
|
208
|
+
int fastN=n-lag;
|
|
209
|
+
int shift;
|
|
210
|
+
const opus_val16 *xptr;
|
|
211
|
+
opus_val16 xx[n];
|
|
212
|
+
celt_assert(n>0);
|
|
213
|
+
celt_assert(overlap>=0);
|
|
214
|
+
if (overlap == 0)
|
|
215
|
+
{
|
|
216
|
+
xptr = x;
|
|
217
|
+
} else {
|
|
218
|
+
for (i=0;i<n;i++)
|
|
219
|
+
xx[i] = x[i];
|
|
220
|
+
for (i=0;i<overlap;i++)
|
|
221
|
+
{
|
|
222
|
+
xx[i] = MULT16_16_Q15(x[i],window[i]);
|
|
223
|
+
xx[n-i-1] = MULT16_16_Q15(x[n-i-1],window[i]);
|
|
224
|
+
}
|
|
225
|
+
xptr = xx;
|
|
226
|
+
}
|
|
227
|
+
shift=0;
|
|
228
|
+
#ifdef FIXED_POINT
|
|
229
|
+
{
|
|
230
|
+
opus_val32 ac0;
|
|
231
|
+
ac0 = 1+(n<<7);
|
|
232
|
+
if (n&1) ac0 += SHR32(MULT16_16(xptr[0],xptr[0]),9);
|
|
233
|
+
for(i=(n&1);i<n;i+=2)
|
|
234
|
+
{
|
|
235
|
+
ac0 += SHR32(MULT16_16(xptr[i],xptr[i]),9);
|
|
236
|
+
ac0 += SHR32(MULT16_16(xptr[i+1],xptr[i+1]),9);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
shift = celt_ilog2(ac0)-30+10;
|
|
240
|
+
shift = (shift)/2;
|
|
241
|
+
if (shift>0)
|
|
242
|
+
{
|
|
243
|
+
for(i=0;i<n;i++)
|
|
244
|
+
xx[i] = PSHR32(xptr[i], shift);
|
|
245
|
+
xptr = xx;
|
|
246
|
+
} else
|
|
247
|
+
shift = 0;
|
|
248
|
+
}
|
|
249
|
+
#endif
|
|
250
|
+
celt_pitch_xcorr(xptr, xptr, ac, fastN, lag+1);
|
|
251
|
+
for (k=0;k<=lag;k++)
|
|
252
|
+
{
|
|
253
|
+
for (i = k+fastN, d = 0; i < n; i++)
|
|
254
|
+
d = MAC16_16(d, xptr[i], xptr[i-k]);
|
|
255
|
+
ac[k] += d;
|
|
256
|
+
}
|
|
257
|
+
#ifdef FIXED_POINT
|
|
258
|
+
shift = 2*shift;
|
|
259
|
+
if (shift<=0)
|
|
260
|
+
ac[0] += SHL32((opus_int32)1, -shift);
|
|
261
|
+
if (ac[0] < 268435456)
|
|
262
|
+
{
|
|
263
|
+
int shift2 = 29 - EC_ILOG(ac[0]);
|
|
264
|
+
for (i=0;i<=lag;i++)
|
|
265
|
+
ac[i] = SHL32(ac[i], shift2);
|
|
266
|
+
shift -= shift2;
|
|
267
|
+
} else if (ac[0] >= 536870912)
|
|
268
|
+
{
|
|
269
|
+
int shift2=1;
|
|
270
|
+
if (ac[0] >= 1073741824)
|
|
271
|
+
shift2++;
|
|
272
|
+
for (i=0;i<=lag;i++)
|
|
273
|
+
ac[i] = SHR32(ac[i], shift2);
|
|
274
|
+
shift += shift2;
|
|
275
|
+
}
|
|
276
|
+
#endif
|
|
277
|
+
|
|
278
|
+
return shift;
|
|
279
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/* Copyright (c) 2009-2010 Xiph.Org Foundation
|
|
2
|
+
Written by Jean-Marc Valin */
|
|
3
|
+
/*
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions
|
|
6
|
+
are met:
|
|
7
|
+
|
|
8
|
+
- Redistributions of source code must retain the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
- Redistributions in binary form must reproduce the above copyright
|
|
12
|
+
notice, this list of conditions and the following disclaimer in the
|
|
13
|
+
documentation and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
16
|
+
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
17
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
18
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
|
|
19
|
+
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
22
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
#ifndef PLC_H
|
|
29
|
+
#define PLC_H
|
|
30
|
+
|
|
31
|
+
#include "arch.h"
|
|
32
|
+
#include "common.h"
|
|
33
|
+
|
|
34
|
+
#if defined(OPUS_X86_MAY_HAVE_SSE4_1)
|
|
35
|
+
#include "x86/celt_lpc_sse.h"
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
#define LPC_ORDER 24
|
|
39
|
+
|
|
40
|
+
void _celt_lpc(opus_val16 *_lpc, const opus_val32 *ac, int p);
|
|
41
|
+
|
|
42
|
+
void celt_fir(
|
|
43
|
+
const opus_val16 *x,
|
|
44
|
+
const opus_val16 *num,
|
|
45
|
+
opus_val16 *y,
|
|
46
|
+
int N,
|
|
47
|
+
int ord);
|
|
48
|
+
|
|
49
|
+
void celt_iir(const opus_val32 *x,
|
|
50
|
+
const opus_val16 *den,
|
|
51
|
+
opus_val32 *y,
|
|
52
|
+
int N,
|
|
53
|
+
int ord,
|
|
54
|
+
opus_val16 *mem);
|
|
55
|
+
|
|
56
|
+
int _celt_autocorr(const opus_val16 *x, opus_val32 *ac,
|
|
57
|
+
const opus_val16 *window, int overlap, int lag, int n);
|
|
58
|
+
|
|
59
|
+
#endif /* PLC_H */
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
#ifndef COMMON_H
|
|
4
|
+
#define COMMON_H
|
|
5
|
+
|
|
6
|
+
#include "stdlib.h"
|
|
7
|
+
#include "string.h"
|
|
8
|
+
|
|
9
|
+
#define RNN_INLINE inline
|
|
10
|
+
#define OPUS_INLINE inline
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/** RNNoise wrapper for malloc(). To do your own dynamic allocation, all you need t
|
|
14
|
+
o do is replace this function and rnnoise_free */
|
|
15
|
+
#ifndef OVERRIDE_RNNOISE_ALLOC
|
|
16
|
+
static RNN_INLINE void *rnnoise_alloc (size_t size)
|
|
17
|
+
{
|
|
18
|
+
return malloc(size);
|
|
19
|
+
}
|
|
20
|
+
#endif
|
|
21
|
+
|
|
22
|
+
/** RNNoise wrapper for free(). To do your own dynamic allocation, all you need to do is replace this function and rnnoise_alloc */
|
|
23
|
+
#ifndef OVERRIDE_RNNOISE_FREE
|
|
24
|
+
static RNN_INLINE void rnnoise_free (void *ptr)
|
|
25
|
+
{
|
|
26
|
+
free(ptr);
|
|
27
|
+
}
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
/** Copy n elements from src to dst. The 0* term provides compile-time type checking */
|
|
31
|
+
#ifndef OVERRIDE_RNN_COPY
|
|
32
|
+
#define RNN_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
|
|
33
|
+
#endif
|
|
34
|
+
|
|
35
|
+
/** Copy n elements from src to dst, allowing overlapping regions. The 0* term
|
|
36
|
+
provides compile-time type checking */
|
|
37
|
+
#ifndef OVERRIDE_RNN_MOVE
|
|
38
|
+
#define RNN_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
|
|
39
|
+
#endif
|
|
40
|
+
|
|
41
|
+
/** Set n elements of dst to zero */
|
|
42
|
+
#ifndef OVERRIDE_RNN_CLEAR
|
|
43
|
+
#define RNN_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst))))
|
|
44
|
+
#endif
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
#endif
|