@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,296 @@
|
|
|
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
|
+
* FFT 5 Points
|
|
29
|
+
* The number of interleaved transform `n` assumed to be even
|
|
30
|
+
*/
|
|
31
|
+
#ifndef fft_5
|
|
32
|
+
|
|
33
|
+
LC3_HOT static inline void neon_fft_5(
|
|
34
|
+
const struct lc3_complex *x, struct lc3_complex *y, int n)
|
|
35
|
+
{
|
|
36
|
+
static const union { float f[2]; uint64_t u64; }
|
|
37
|
+
__cos1 = { { 0.3090169944, 0.3090169944 } },
|
|
38
|
+
__cos2 = { { -0.8090169944, -0.8090169944 } },
|
|
39
|
+
__sin1 = { { 0.9510565163, -0.9510565163 } },
|
|
40
|
+
__sin2 = { { 0.5877852523, -0.5877852523 } };
|
|
41
|
+
|
|
42
|
+
float32x2_t sin1 = vcreate_f32(__sin1.u64);
|
|
43
|
+
float32x2_t sin2 = vcreate_f32(__sin2.u64);
|
|
44
|
+
float32x2_t cos1 = vcreate_f32(__cos1.u64);
|
|
45
|
+
float32x2_t cos2 = vcreate_f32(__cos2.u64);
|
|
46
|
+
|
|
47
|
+
float32x4_t sin1q = vcombine_f32(sin1, sin1);
|
|
48
|
+
float32x4_t sin2q = vcombine_f32(sin2, sin2);
|
|
49
|
+
float32x4_t cos1q = vcombine_f32(cos1, cos1);
|
|
50
|
+
float32x4_t cos2q = vcombine_f32(cos2, cos2);
|
|
51
|
+
|
|
52
|
+
for (int i = 0; i < n; i += 2, x += 2, y += 10) {
|
|
53
|
+
|
|
54
|
+
float32x4_t y0, y1, y2, y3, y4;
|
|
55
|
+
|
|
56
|
+
float32x4_t x0 = vld1q_f32( (float *)(x + 0*n) );
|
|
57
|
+
float32x4_t x1 = vld1q_f32( (float *)(x + 1*n) );
|
|
58
|
+
float32x4_t x2 = vld1q_f32( (float *)(x + 2*n) );
|
|
59
|
+
float32x4_t x3 = vld1q_f32( (float *)(x + 3*n) );
|
|
60
|
+
float32x4_t x4 = vld1q_f32( (float *)(x + 4*n) );
|
|
61
|
+
|
|
62
|
+
float32x4_t s14 = vaddq_f32(x1, x4);
|
|
63
|
+
float32x4_t s23 = vaddq_f32(x2, x3);
|
|
64
|
+
|
|
65
|
+
float32x4_t d14 = vrev64q_f32( vsubq_f32(x1, x4) );
|
|
66
|
+
float32x4_t d23 = vrev64q_f32( vsubq_f32(x2, x3) );
|
|
67
|
+
|
|
68
|
+
y0 = vaddq_f32( x0, vaddq_f32(s14, s23) );
|
|
69
|
+
|
|
70
|
+
y4 = vfmaq_f32( x0, s14, cos1q );
|
|
71
|
+
y4 = vfmaq_f32( y4, s23, cos2q );
|
|
72
|
+
|
|
73
|
+
y1 = vfmaq_f32( y4, d14, sin1q );
|
|
74
|
+
y1 = vfmaq_f32( y1, d23, sin2q );
|
|
75
|
+
|
|
76
|
+
y4 = vfmsq_f32( y4, d14, sin1q );
|
|
77
|
+
y4 = vfmsq_f32( y4, d23, sin2q );
|
|
78
|
+
|
|
79
|
+
y3 = vfmaq_f32( x0, s14, cos2q );
|
|
80
|
+
y3 = vfmaq_f32( y3, s23, cos1q );
|
|
81
|
+
|
|
82
|
+
y2 = vfmaq_f32( y3, d14, sin2q );
|
|
83
|
+
y2 = vfmsq_f32( y2, d23, sin1q );
|
|
84
|
+
|
|
85
|
+
y3 = vfmsq_f32( y3, d14, sin2q );
|
|
86
|
+
y3 = vfmaq_f32( y3, d23, sin1q );
|
|
87
|
+
|
|
88
|
+
vst1_f32( (float *)(y + 0), vget_low_f32(y0) );
|
|
89
|
+
vst1_f32( (float *)(y + 1), vget_low_f32(y1) );
|
|
90
|
+
vst1_f32( (float *)(y + 2), vget_low_f32(y2) );
|
|
91
|
+
vst1_f32( (float *)(y + 3), vget_low_f32(y3) );
|
|
92
|
+
vst1_f32( (float *)(y + 4), vget_low_f32(y4) );
|
|
93
|
+
|
|
94
|
+
vst1_f32( (float *)(y + 5), vget_high_f32(y0) );
|
|
95
|
+
vst1_f32( (float *)(y + 6), vget_high_f32(y1) );
|
|
96
|
+
vst1_f32( (float *)(y + 7), vget_high_f32(y2) );
|
|
97
|
+
vst1_f32( (float *)(y + 8), vget_high_f32(y3) );
|
|
98
|
+
vst1_f32( (float *)(y + 9), vget_high_f32(y4) );
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
#ifndef TEST_NEON
|
|
103
|
+
#define fft_5 neon_fft_5
|
|
104
|
+
#endif
|
|
105
|
+
|
|
106
|
+
#endif /* fft_5 */
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* FFT Butterfly 3 Points
|
|
110
|
+
*/
|
|
111
|
+
#ifndef fft_bf3
|
|
112
|
+
|
|
113
|
+
LC3_HOT static inline void neon_fft_bf3(
|
|
114
|
+
const struct lc3_fft_bf3_twiddles *twiddles,
|
|
115
|
+
const struct lc3_complex *x, struct lc3_complex *y, int n)
|
|
116
|
+
{
|
|
117
|
+
int n3 = twiddles->n3;
|
|
118
|
+
const struct lc3_complex (*w0_ptr)[2] = twiddles->t;
|
|
119
|
+
const struct lc3_complex (*w1_ptr)[2] = w0_ptr + n3;
|
|
120
|
+
const struct lc3_complex (*w2_ptr)[2] = w1_ptr + n3;
|
|
121
|
+
|
|
122
|
+
const struct lc3_complex *x0_ptr = x;
|
|
123
|
+
const struct lc3_complex *x1_ptr = x0_ptr + n*n3;
|
|
124
|
+
const struct lc3_complex *x2_ptr = x1_ptr + n*n3;
|
|
125
|
+
|
|
126
|
+
struct lc3_complex *y0_ptr = y;
|
|
127
|
+
struct lc3_complex *y1_ptr = y0_ptr + n3;
|
|
128
|
+
struct lc3_complex *y2_ptr = y1_ptr + n3;
|
|
129
|
+
|
|
130
|
+
for (int j, i = 0; i < n; i++,
|
|
131
|
+
y0_ptr += 3*n3, y1_ptr += 3*n3, y2_ptr += 3*n3) {
|
|
132
|
+
|
|
133
|
+
/* --- Process by pair --- */
|
|
134
|
+
|
|
135
|
+
for (j = 0; j < (n3 >> 1); j++,
|
|
136
|
+
x0_ptr += 2, x1_ptr += 2, x2_ptr += 2) {
|
|
137
|
+
|
|
138
|
+
float32x4_t x0 = vld1q_f32( (float *)x0_ptr );
|
|
139
|
+
float32x4_t x1 = vld1q_f32( (float *)x1_ptr );
|
|
140
|
+
float32x4_t x2 = vld1q_f32( (float *)x2_ptr );
|
|
141
|
+
|
|
142
|
+
float32x4_t x1r = vtrn1q_f32( vrev64q_f32(vnegq_f32(x1)), x1 );
|
|
143
|
+
float32x4_t x2r = vtrn1q_f32( vrev64q_f32(vnegq_f32(x2)), x2 );
|
|
144
|
+
|
|
145
|
+
float32x4x2_t wn;
|
|
146
|
+
float32x4_t yn;
|
|
147
|
+
|
|
148
|
+
wn = vld2q_f32( (float *)(w0_ptr + 2*j) );
|
|
149
|
+
|
|
150
|
+
yn = vfmaq_f32( x0, x1 , vtrn1q_f32(wn.val[0], wn.val[0]) );
|
|
151
|
+
yn = vfmaq_f32( yn, x1r, vtrn1q_f32(wn.val[1], wn.val[1]) );
|
|
152
|
+
yn = vfmaq_f32( yn, x2 , vtrn2q_f32(wn.val[0], wn.val[0]) );
|
|
153
|
+
yn = vfmaq_f32( yn, x2r, vtrn2q_f32(wn.val[1], wn.val[1]) );
|
|
154
|
+
vst1q_f32( (float *)(y0_ptr + 2*j), yn );
|
|
155
|
+
|
|
156
|
+
wn = vld2q_f32( (float *)(w1_ptr + 2*j) );
|
|
157
|
+
|
|
158
|
+
yn = vfmaq_f32( x0, x1 , vtrn1q_f32(wn.val[0], wn.val[0]) );
|
|
159
|
+
yn = vfmaq_f32( yn, x1r, vtrn1q_f32(wn.val[1], wn.val[1]) );
|
|
160
|
+
yn = vfmaq_f32( yn, x2 , vtrn2q_f32(wn.val[0], wn.val[0]) );
|
|
161
|
+
yn = vfmaq_f32( yn, x2r, vtrn2q_f32(wn.val[1], wn.val[1]) );
|
|
162
|
+
vst1q_f32( (float *)(y1_ptr + 2*j), yn );
|
|
163
|
+
|
|
164
|
+
wn = vld2q_f32( (float *)(w2_ptr + 2*j) );
|
|
165
|
+
|
|
166
|
+
yn = vfmaq_f32( x0, x1 , vtrn1q_f32(wn.val[0], wn.val[0]) );
|
|
167
|
+
yn = vfmaq_f32( yn, x1r, vtrn1q_f32(wn.val[1], wn.val[1]) );
|
|
168
|
+
yn = vfmaq_f32( yn, x2 , vtrn2q_f32(wn.val[0], wn.val[0]) );
|
|
169
|
+
yn = vfmaq_f32( yn, x2r, vtrn2q_f32(wn.val[1], wn.val[1]) );
|
|
170
|
+
vst1q_f32( (float *)(y2_ptr + 2*j), yn );
|
|
171
|
+
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/* --- Last iteration --- */
|
|
175
|
+
|
|
176
|
+
if (n3 & 1) {
|
|
177
|
+
|
|
178
|
+
float32x2x2_t wn;
|
|
179
|
+
float32x2_t yn;
|
|
180
|
+
|
|
181
|
+
float32x2_t x0 = vld1_f32( (float *)(x0_ptr++) );
|
|
182
|
+
float32x2_t x1 = vld1_f32( (float *)(x1_ptr++) );
|
|
183
|
+
float32x2_t x2 = vld1_f32( (float *)(x2_ptr++) );
|
|
184
|
+
|
|
185
|
+
float32x2_t x1r = vtrn1_f32( vrev64_f32(vneg_f32(x1)), x1 );
|
|
186
|
+
float32x2_t x2r = vtrn1_f32( vrev64_f32(vneg_f32(x2)), x2 );
|
|
187
|
+
|
|
188
|
+
wn = vld2_f32( (float *)(w0_ptr + 2*j) );
|
|
189
|
+
|
|
190
|
+
yn = vfma_f32( x0, x1 , vtrn1_f32(wn.val[0], wn.val[0]) );
|
|
191
|
+
yn = vfma_f32( yn, x1r, vtrn1_f32(wn.val[1], wn.val[1]) );
|
|
192
|
+
yn = vfma_f32( yn, x2 , vtrn2_f32(wn.val[0], wn.val[0]) );
|
|
193
|
+
yn = vfma_f32( yn, x2r, vtrn2_f32(wn.val[1], wn.val[1]) );
|
|
194
|
+
vst1_f32( (float *)(y0_ptr + 2*j), yn );
|
|
195
|
+
|
|
196
|
+
wn = vld2_f32( (float *)(w1_ptr + 2*j) );
|
|
197
|
+
|
|
198
|
+
yn = vfma_f32( x0, x1 , vtrn1_f32(wn.val[0], wn.val[0]) );
|
|
199
|
+
yn = vfma_f32( yn, x1r, vtrn1_f32(wn.val[1], wn.val[1]) );
|
|
200
|
+
yn = vfma_f32( yn, x2 , vtrn2_f32(wn.val[0], wn.val[0]) );
|
|
201
|
+
yn = vfma_f32( yn, x2r, vtrn2_f32(wn.val[1], wn.val[1]) );
|
|
202
|
+
vst1_f32( (float *)(y1_ptr + 2*j), yn );
|
|
203
|
+
|
|
204
|
+
wn = vld2_f32( (float *)(w2_ptr + 2*j) );
|
|
205
|
+
|
|
206
|
+
yn = vfma_f32( x0, x1 , vtrn1_f32(wn.val[0], wn.val[0]) );
|
|
207
|
+
yn = vfma_f32( yn, x1r, vtrn1_f32(wn.val[1], wn.val[1]) );
|
|
208
|
+
yn = vfma_f32( yn, x2 , vtrn2_f32(wn.val[0], wn.val[0]) );
|
|
209
|
+
yn = vfma_f32( yn, x2r, vtrn2_f32(wn.val[1], wn.val[1]) );
|
|
210
|
+
vst1_f32( (float *)(y2_ptr + 2*j), yn );
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
#ifndef TEST_NEON
|
|
217
|
+
#define fft_bf3 neon_fft_bf3
|
|
218
|
+
#endif
|
|
219
|
+
|
|
220
|
+
#endif /* fft_bf3 */
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* FFT Butterfly 2 Points
|
|
224
|
+
*/
|
|
225
|
+
#ifndef fft_bf2
|
|
226
|
+
|
|
227
|
+
LC3_HOT static inline void neon_fft_bf2(
|
|
228
|
+
const struct lc3_fft_bf2_twiddles *twiddles,
|
|
229
|
+
const struct lc3_complex *x, struct lc3_complex *y, int n)
|
|
230
|
+
{
|
|
231
|
+
int n2 = twiddles->n2;
|
|
232
|
+
const struct lc3_complex *w_ptr = twiddles->t;
|
|
233
|
+
|
|
234
|
+
const struct lc3_complex *x0_ptr = x;
|
|
235
|
+
const struct lc3_complex *x1_ptr = x0_ptr + n*n2;
|
|
236
|
+
|
|
237
|
+
struct lc3_complex *y0_ptr = y;
|
|
238
|
+
struct lc3_complex *y1_ptr = y0_ptr + n2;
|
|
239
|
+
|
|
240
|
+
for (int j, i = 0; i < n; i++, y0_ptr += 2*n2, y1_ptr += 2*n2) {
|
|
241
|
+
|
|
242
|
+
/* --- Process by pair --- */
|
|
243
|
+
|
|
244
|
+
for (j = 0; j < (n2 >> 1); j++, x0_ptr += 2, x1_ptr += 2) {
|
|
245
|
+
|
|
246
|
+
float32x4_t x0 = vld1q_f32( (float *)x0_ptr );
|
|
247
|
+
float32x4_t x1 = vld1q_f32( (float *)x1_ptr );
|
|
248
|
+
float32x4_t y0, y1;
|
|
249
|
+
|
|
250
|
+
float32x4_t x1r = vtrn1q_f32( vrev64q_f32(vnegq_f32(x1)), x1 );
|
|
251
|
+
|
|
252
|
+
float32x4_t w = vld1q_f32( (float *)(w_ptr + 2*j) );
|
|
253
|
+
float32x4_t w_re = vtrn1q_f32(w, w);
|
|
254
|
+
float32x4_t w_im = vtrn2q_f32(w, w);
|
|
255
|
+
|
|
256
|
+
y0 = vfmaq_f32( x0, x1 , w_re );
|
|
257
|
+
y0 = vfmaq_f32( y0, x1r, w_im );
|
|
258
|
+
vst1q_f32( (float *)(y0_ptr + 2*j), y0 );
|
|
259
|
+
|
|
260
|
+
y1 = vfmsq_f32( x0, x1 , w_re );
|
|
261
|
+
y1 = vfmsq_f32( y1, x1r, w_im );
|
|
262
|
+
vst1q_f32( (float *)(y1_ptr + 2*j), y1 );
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/* --- Last iteration --- */
|
|
266
|
+
|
|
267
|
+
if (n2 & 1) {
|
|
268
|
+
|
|
269
|
+
float32x2_t x0 = vld1_f32( (float *)(x0_ptr++) );
|
|
270
|
+
float32x2_t x1 = vld1_f32( (float *)(x1_ptr++) );
|
|
271
|
+
float32x2_t y0, y1;
|
|
272
|
+
|
|
273
|
+
float32x2_t x1r = vtrn1_f32( vrev64_f32(vneg_f32(x1)), x1 );
|
|
274
|
+
|
|
275
|
+
float32x2_t w = vld1_f32( (float *)(w_ptr + 2*j) );
|
|
276
|
+
float32x2_t w_re = vtrn1_f32(w, w);
|
|
277
|
+
float32x2_t w_im = vtrn2_f32(w, w);
|
|
278
|
+
|
|
279
|
+
y0 = vfma_f32( x0, x1 , w_re );
|
|
280
|
+
y0 = vfma_f32( y0, x1r, w_im );
|
|
281
|
+
vst1_f32( (float *)(y0_ptr + 2*j), y0 );
|
|
282
|
+
|
|
283
|
+
y1 = vfms_f32( x0, x1 , w_re );
|
|
284
|
+
y1 = vfms_f32( y1, x1r, w_im );
|
|
285
|
+
vst1_f32( (float *)(y1_ptr + 2*j), y1 );
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
#ifndef TEST_NEON
|
|
291
|
+
#define fft_bf2 neon_fft_bf2
|
|
292
|
+
#endif
|
|
293
|
+
|
|
294
|
+
#endif /* fft_bf2 */
|
|
295
|
+
|
|
296
|
+
#endif /* __ARM_NEON && __ARM_ARCH_ISA_A64 */
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Copyright © 2022 Intel Corporation
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at:
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
inc = include_directories('../include')
|
|
16
|
+
|
|
17
|
+
lc3_sources = [
|
|
18
|
+
'attdet.c',
|
|
19
|
+
'bits.c',
|
|
20
|
+
'bwdet.c',
|
|
21
|
+
'energy.c',
|
|
22
|
+
'lc3.c',
|
|
23
|
+
'ltpf.c',
|
|
24
|
+
'mdct.c',
|
|
25
|
+
'plc.c',
|
|
26
|
+
'sns.c',
|
|
27
|
+
'spec.c',
|
|
28
|
+
'tables.c',
|
|
29
|
+
'tns.c'
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
lc3lib = library('lc3',
|
|
33
|
+
lc3_sources,
|
|
34
|
+
dependencies: m_dep,
|
|
35
|
+
include_directories: inc,
|
|
36
|
+
soversion: 1,
|
|
37
|
+
install: true)
|
|
38
|
+
|
|
39
|
+
lc3_install_headers = [
|
|
40
|
+
'../include/lc3_private.h',
|
|
41
|
+
'../include/lc3.h',
|
|
42
|
+
'../include/lc3_cpp.h'
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
install_headers(lc3_install_headers)
|
|
46
|
+
|
|
47
|
+
pkg_mod = import('pkgconfig')
|
|
48
|
+
|
|
49
|
+
pkg_mod.generate(libraries : lc3lib,
|
|
50
|
+
name : 'liblc3',
|
|
51
|
+
filebase : 'lc3',
|
|
52
|
+
description : 'LC3 codec library')
|
|
53
|
+
|
|
54
|
+
#Declare dependency
|
|
55
|
+
liblc3_dep = declare_dependency(
|
|
56
|
+
link_with : lc3lib,
|
|
57
|
+
include_directories : inc)
|
|
58
|
+
|
|
59
|
+
if meson.version().version_compare('>= 0.54.0')
|
|
60
|
+
meson.override_dependency('liblc3', liblc3_dep)
|
|
61
|
+
endif
|
|
@@ -0,0 +1,61 @@
|
|
|
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 "plc.h"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Reset Packet Loss Concealment state
|
|
24
|
+
*/
|
|
25
|
+
void lc3_plc_reset(struct lc3_plc_state *plc)
|
|
26
|
+
{
|
|
27
|
+
plc->seed = 24607;
|
|
28
|
+
lc3_plc_suspend(plc);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Suspend PLC execution (Good frame received)
|
|
33
|
+
*/
|
|
34
|
+
void lc3_plc_suspend(struct lc3_plc_state *plc)
|
|
35
|
+
{
|
|
36
|
+
plc->count = 1;
|
|
37
|
+
plc->alpha = 1.0f;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Synthesis of a PLC frame
|
|
42
|
+
*/
|
|
43
|
+
void lc3_plc_synthesize(enum lc3_dt dt, enum lc3_srate sr,
|
|
44
|
+
struct lc3_plc_state *plc, const float *x, float *y)
|
|
45
|
+
{
|
|
46
|
+
uint16_t seed = plc->seed;
|
|
47
|
+
float alpha = plc->alpha;
|
|
48
|
+
int ne = LC3_NE(dt, sr);
|
|
49
|
+
|
|
50
|
+
alpha *= (plc->count < 4 ? 1.0f :
|
|
51
|
+
plc->count < 8 ? 0.9f : 0.85f);
|
|
52
|
+
|
|
53
|
+
for (int i = 0; i < ne; i++) {
|
|
54
|
+
seed = (16831 + seed * 12821) & 0xffff;
|
|
55
|
+
y[i] = alpha * (seed & 0x8000 ? -x[i] : x[i]);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
plc->seed = seed;
|
|
59
|
+
plc->alpha = alpha;
|
|
60
|
+
plc->count++;
|
|
61
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
/**
|
|
20
|
+
* LC3 - Packet Loss Concealment
|
|
21
|
+
*
|
|
22
|
+
* Reference : Low Complexity Communication Codec (LC3)
|
|
23
|
+
* Bluetooth Specification v1.0
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
#ifndef __LC3_PLC_H
|
|
27
|
+
#define __LC3_PLC_H
|
|
28
|
+
|
|
29
|
+
#include "common.h"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Reset PLC state
|
|
34
|
+
* plc PLC State to reset
|
|
35
|
+
*/
|
|
36
|
+
void lc3_plc_reset(lc3_plc_state_t *plc);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Suspend PLC synthesis (Error-free frame decoded)
|
|
40
|
+
* plc PLC State
|
|
41
|
+
*/
|
|
42
|
+
void lc3_plc_suspend(lc3_plc_state_t *plc);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Synthesis of a PLC frame
|
|
46
|
+
* dt, sr Duration and samplerate of the frame
|
|
47
|
+
* plc PLC State
|
|
48
|
+
* x Last good spectral coefficients
|
|
49
|
+
* y Return emulated ones
|
|
50
|
+
*
|
|
51
|
+
* `x` and `y` can be the same buffer
|
|
52
|
+
*/
|
|
53
|
+
void lc3_plc_synthesize(enum lc3_dt dt, enum lc3_srate sr,
|
|
54
|
+
lc3_plc_state_t *plc, const float *x, float *y);
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
#endif /* __LC3_PLC_H */
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/* Copyright (c) 2018 Gregor Richards
|
|
2
|
+
* Copyright (c) 2017 Mozilla */
|
|
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 FOUNDATION OR
|
|
19
|
+
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 RNNOISE_H
|
|
29
|
+
#define RNNOISE_H 1
|
|
30
|
+
|
|
31
|
+
#include <stdio.h>
|
|
32
|
+
|
|
33
|
+
#ifdef __cplusplus
|
|
34
|
+
extern "C" {
|
|
35
|
+
#endif
|
|
36
|
+
|
|
37
|
+
#ifndef RNNOISE_EXPORT
|
|
38
|
+
# if defined(WIN32)
|
|
39
|
+
# if defined(RNNOISE_BUILD) && defined(DLL_EXPORT)
|
|
40
|
+
# define RNNOISE_EXPORT __declspec(dllexport)
|
|
41
|
+
# else
|
|
42
|
+
# define RNNOISE_EXPORT
|
|
43
|
+
# endif
|
|
44
|
+
# elif defined(__GNUC__) && defined(RNNOISE_BUILD)
|
|
45
|
+
# define RNNOISE_EXPORT __attribute__ ((visibility ("default")))
|
|
46
|
+
# else
|
|
47
|
+
# define RNNOISE_EXPORT
|
|
48
|
+
# endif
|
|
49
|
+
#endif
|
|
50
|
+
|
|
51
|
+
typedef struct DenoiseState DenoiseState;
|
|
52
|
+
typedef struct RNNModel RNNModel;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Return the size of DenoiseState
|
|
56
|
+
*/
|
|
57
|
+
RNNOISE_EXPORT int rnnoise_get_size();
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Return the number of samples processed by rnnoise_process_frame at a time
|
|
61
|
+
*/
|
|
62
|
+
RNNOISE_EXPORT int rnnoise_get_frame_size();
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Initializes a pre-allocated DenoiseState
|
|
66
|
+
*
|
|
67
|
+
* If model is NULL the default model is used.
|
|
68
|
+
*
|
|
69
|
+
* See: rnnoise_create() and rnnoise_model_from_file()
|
|
70
|
+
*/
|
|
71
|
+
RNNOISE_EXPORT int rnnoise_init(DenoiseState *st, RNNModel *model);
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Allocate and initialize a DenoiseState
|
|
75
|
+
*
|
|
76
|
+
* If model is NULL the default model is used.
|
|
77
|
+
*
|
|
78
|
+
* The returned pointer MUST be freed with rnnoise_destroy().
|
|
79
|
+
*/
|
|
80
|
+
RNNOISE_EXPORT DenoiseState *rnnoise_create(RNNModel *model);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Free a DenoiseState produced by rnnoise_create.
|
|
84
|
+
*
|
|
85
|
+
* The optional custom model must be freed by rnnoise_model_free() after.
|
|
86
|
+
*/
|
|
87
|
+
RNNOISE_EXPORT void rnnoise_destroy(DenoiseState *st);
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Denoise a frame of samples
|
|
91
|
+
*
|
|
92
|
+
* in and out must be at least rnnoise_get_frame_size() large.
|
|
93
|
+
*/
|
|
94
|
+
RNNOISE_EXPORT float rnnoise_process_frame(DenoiseState *st, float *out, const float *in);
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Load a model from a file
|
|
98
|
+
*
|
|
99
|
+
* It must be deallocated with rnnoise_model_free()
|
|
100
|
+
*/
|
|
101
|
+
RNNOISE_EXPORT RNNModel *rnnoise_model_from_file(FILE *f);
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Free a custom model
|
|
105
|
+
*
|
|
106
|
+
* It must be called after all the DenoiseStates referring to it are freed.
|
|
107
|
+
*/
|
|
108
|
+
RNNOISE_EXPORT void rnnoise_model_free(RNNModel *model);
|
|
109
|
+
|
|
110
|
+
#ifdef __cplusplus
|
|
111
|
+
}
|
|
112
|
+
#endif
|
|
113
|
+
|
|
114
|
+
#endif
|