gravix-rtc-react-native 0.0.0-stage → 0.2.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/CHANGELOG.md +134 -0
- package/LICENSE +20 -0
- package/LICENSES/Apache-2.0.txt +175 -0
- package/NOTICE +68 -0
- package/README.md +313 -2
- package/android/build.gradle +137 -0
- package/android/consumer-rules.pro +29 -0
- package/android/src/main/AndroidManifest.xml +9 -0
- package/android/src/main/cpp/CMakeLists.txt +48 -0
- package/android/src/main/cpp/gx_dfn_engine.c +332 -0
- package/android/src/main/cpp/gx_fx_jni.cpp +34 -0
- package/android/src/main/cpp/gx_ns_jni.c +162 -0
- package/android/src/main/cpp/third_party/onnxruntime/LICENSE +21 -0
- package/android/src/main/cpp/third_party/onnxruntime/include/onnxruntime_c_api.h +9227 -0
- package/android/src/main/cpp/third_party/onnxruntime/include/onnxruntime_ep_c_api.h +3315 -0
- package/android/src/main/cpp/third_party/onnxruntime/include/onnxruntime_error_code.h +98 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixAudioHooks.kt +144 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixAudioModule.kt +105 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixNativeAudio.kt +310 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixRtc.kt +134 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixRtcModule.kt +176 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/GravixRtcPackage.kt +39 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioDeviceKind.java +44 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioManagerUtils.kt +120 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioSwitchManager.java +270 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/audio/AudioType.kt +50 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicCaptureRouter.kt +375 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicDecoder.kt +339 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicInterruptionWatcher.kt +82 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicMicRelease.kt +117 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicMixKernel.kt +191 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/music/MusicMixerEngine.kt +617 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/AudioRoutePolicy.kt +137 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GravixCaptureProcessing.kt +67 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxCaptureDump.kt +143 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxCaptureSwitcher.kt +196 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNoiseProcessor.kt +795 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNsLogic.kt +180 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNsNative.kt +83 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxNsStudio.kt +372 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxRecordStartGuard.kt +76 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxRecorderSeam.kt +434 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxSingerSource.kt +37 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/GxVoiceFx.kt +160 -0
- package/android/src/main/java/com/gravitycompile/gravixrtc/processing/OtherAppAudioPolicy.kt +143 -0
- package/android/src/main/java/org/webrtc/audio/WebRtcAudioTrackHelper.kt +43 -0
- package/docs/ANDROID_NATIVE_HOOKS.md +102 -0
- package/docs/FEATURE_MATRIX.md +192 -0
- package/docs/IOS_NATIVE_HOOKS.md +190 -0
- package/gravix-rtc-react-native.podspec +49 -0
- package/ios/GravixRtc.h +7 -0
- package/ios/GravixRtc.mm +273 -0
- package/ios/GravixRtcSetup.h +29 -0
- package/ios/GravixRtcSetup.m +52 -0
- package/ios/audio/GravixRtcIosAudio.m +157 -0
- package/ios/audio/GxAudioDevice.h +62 -0
- package/ios/audio/GxAudioDevice.m +857 -0
- package/ios/audio/GxAudioSetup.h +34 -0
- package/ios/audio/GxAudioSetup.m +70 -0
- package/ios/audio/GxCompat.swift +53 -0
- package/ios/audio/GxIosAudio.swift +99 -0
- package/ios/audio/GxMusicController.swift +150 -0
- package/ios/audio/GxMusicPost.swift +362 -0
- package/ios/audio/GxNoiseProcessor.swift +718 -0
- package/ios/audio/GxNsDfn3CoreML.swift +195 -0
- package/ios/audio/GxNsStudioEngine.swift +237 -0
- package/ios/audio/GxNsStudioPack.swift +212 -0
- package/ios/audio/GxVoiceFx.swift +161 -0
- package/ios/audio/gx_adm_state.h +153 -0
- package/ios/gxcore/apple/gx_music_post.c +312 -0
- package/ios/gxcore/apple/gx_pcm.c +30 -0
- package/ios/gxcore/apple/gxns_build.h +19 -0
- package/ios/gxcore/apple/gxns_ios.c +17 -0
- package/ios/gxcore/apple/include/gx_fx.h +3 -0
- package/ios/gxcore/apple/include/gx_music_post.h +88 -0
- package/ios/gxcore/apple/include/gx_ns.h +3 -0
- package/ios/gxcore/apple/include/gx_pcm.h +33 -0
- package/ios/gxcore/apple/include/gxns_ios.h +18 -0
- package/ios/gxcore/apple/include/module.modulemap +10 -0
- package/ios/gxcore/apple/shim/rnnoise.h +2 -0
- package/ios/gxcore/apple/shim/speex_resampler.h +2 -0
- package/ios/gxcore/apple/units/gx_fx_forward.cpp +3 -0
- package/ios/gxcore/apple/units/gx_ns.c +7 -0
- package/ios/gxcore/apple/units/gx_ns_timer.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_celt_lpc.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_denoise.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_kiss_fft.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_pitch.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_rnn.c +7 -0
- package/ios/gxcore/apple/units/rnnoise_rnn_data.c +7 -0
- package/ios/gxcore/apple/units/speexdsp_resample.c +7 -0
- package/ios/resources/ns/DFN3-NOTICE.txt +10 -0
- package/ios/resources/ns/DeepFilterNet-LICENSE-APACHE +201 -0
- package/ios/resources/ns/DeepFilterNet-LICENSE-MIT +19 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/analytics/coremldata.bin +0 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/coremldata.bin +0 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/metadata.json +338 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/model.mil +927 -0
- package/ios/resources/ns/gxns_dfn3.mlmodelc/weights/weight.bin +0 -0
- package/lib/module/android/bindings.js +49 -0
- package/lib/module/android/bindings.js.map +1 -0
- package/lib/module/android/index.js +13 -0
- package/lib/module/android/index.js.map +1 -0
- package/lib/module/android/micMute.js +341 -0
- package/lib/module/android/micMute.js.map +1 -0
- package/lib/module/android/nativeAudio.js +47 -0
- package/lib/module/android/nativeAudio.js.map +1 -0
- package/lib/module/android/noiseSuppression.js +170 -0
- package/lib/module/android/noiseSuppression.js.map +1 -0
- package/lib/module/android/roomMusic.js +142 -0
- package/lib/module/android/roomMusic.js.map +1 -0
- package/lib/module/android/singerMode.js +31 -0
- package/lib/module/android/singerMode.js.map +1 -0
- package/lib/module/android/voiceEffects.js +65 -0
- package/lib/module/android/voiceEffects.js.map +1 -0
- package/lib/module/audio/AudioManager.js +79 -0
- package/lib/module/audio/AudioManager.js.map +1 -0
- package/lib/module/audio/AudioSession.js +90 -0
- package/lib/module/audio/AudioSession.js.map +1 -0
- package/lib/module/audio/remoteVolume.js +54 -0
- package/lib/module/audio/remoteVolume.js.map +1 -0
- package/lib/module/components/VideoView.js +109 -0
- package/lib/module/components/VideoView.js.map +1 -0
- package/lib/module/features/audioScenario.js +53 -0
- package/lib/module/features/audioScenario.js.map +1 -0
- package/lib/module/features/beauty.js +828 -0
- package/lib/module/features/beauty.js.map +1 -0
- package/lib/module/features/micRelease.js +89 -0
- package/lib/module/features/micRelease.js.map +1 -0
- package/lib/module/features/noiseSuppression.js +213 -0
- package/lib/module/features/noiseSuppression.js.map +1 -0
- package/lib/module/features/roomMusic.js +90 -0
- package/lib/module/features/roomMusic.js.map +1 -0
- package/lib/module/features/roomMusicAndroid.js +294 -0
- package/lib/module/features/roomMusicAndroid.js.map +1 -0
- package/lib/module/features/roomMusicIos.js +250 -0
- package/lib/module/features/roomMusicIos.js.map +1 -0
- package/lib/module/features/roomMusicTypes.js +53 -0
- package/lib/module/features/roomMusicTypes.js.map +1 -0
- package/lib/module/features/screenShare.js +22 -0
- package/lib/module/features/screenShare.js.map +1 -0
- package/lib/module/features/singerMode.js +73 -0
- package/lib/module/features/singerMode.js.map +1 -0
- package/lib/module/features/voiceEffects.js +148 -0
- package/lib/module/features/voiceEffects.js.map +1 -0
- package/lib/module/hooks/context.js +34 -0
- package/lib/module/hooks/context.js.map +1 -0
- package/lib/module/hooks/hooks.js +145 -0
- package/lib/module/hooks/hooks.js.map +1 -0
- package/lib/module/hooks/types.js +4 -0
- package/lib/module/hooks/types.js.map +1 -0
- package/lib/module/hooks/useRoomEvents.js +30 -0
- package/lib/module/hooks/useRoomEvents.js.map +1 -0
- package/lib/module/index.js +43 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/ios/autoAttach.js +14 -0
- package/lib/module/ios/autoAttach.js.map +1 -0
- package/lib/module/ios/iosAudio.js +149 -0
- package/lib/module/ios/iosAudio.js.map +1 -0
- package/lib/module/join/appStateLifecycle.js +54 -0
- package/lib/module/join/appStateLifecycle.js.map +1 -0
- package/lib/module/micPolicy.js +249 -0
- package/lib/module/micPolicy.js.map +1 -0
- package/lib/module/native/NativeGravixAudio.js +18 -0
- package/lib/module/native/NativeGravixAudio.js.map +1 -0
- package/lib/module/native/NativeGravixRtc.js +13 -0
- package/lib/module/native/NativeGravixRtc.js.map +1 -0
- package/lib/module/native/module.js +23 -0
- package/lib/module/native/module.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/polyfills/DOMException.js +22 -0
- package/lib/module/polyfills/DOMException.js.map +1 -0
- package/lib/module/polyfills/early.js +18 -0
- package/lib/module/polyfills/early.js.map +1 -0
- package/lib/module/polyfills/event.js +71 -0
- package/lib/module/polyfills/event.js.map +1 -0
- package/lib/module/polyfills/sha256.js +92 -0
- package/lib/module/polyfills/sha256.js.map +1 -0
- package/lib/module/polyfills/subtleHmac.js +91 -0
- package/lib/module/polyfills/subtleHmac.js.map +1 -0
- package/lib/module/polyfills/textCoding.js +164 -0
- package/lib/module/polyfills/textCoding.js.map +1 -0
- package/lib/module/registerGlobals.js +135 -0
- package/lib/module/registerGlobals.js.map +1 -0
- package/lib/module/unsupported.js +90 -0
- package/lib/module/unsupported.js.map +1 -0
- package/lib/module/version.js +7 -0
- package/lib/module/version.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/android/bindings.d.ts +14 -0
- package/lib/typescript/src/android/bindings.d.ts.map +1 -0
- package/lib/typescript/src/android/index.d.ts +9 -0
- package/lib/typescript/src/android/index.d.ts.map +1 -0
- package/lib/typescript/src/android/micMute.d.ts +124 -0
- package/lib/typescript/src/android/micMute.d.ts.map +1 -0
- package/lib/typescript/src/android/nativeAudio.d.ts +40 -0
- package/lib/typescript/src/android/nativeAudio.d.ts.map +1 -0
- package/lib/typescript/src/android/noiseSuppression.d.ts +48 -0
- package/lib/typescript/src/android/noiseSuppression.d.ts.map +1 -0
- package/lib/typescript/src/android/roomMusic.d.ts +80 -0
- package/lib/typescript/src/android/roomMusic.d.ts.map +1 -0
- package/lib/typescript/src/android/singerMode.d.ts +27 -0
- package/lib/typescript/src/android/singerMode.d.ts.map +1 -0
- package/lib/typescript/src/android/voiceEffects.d.ts +30 -0
- package/lib/typescript/src/android/voiceEffects.d.ts.map +1 -0
- package/lib/typescript/src/audio/AudioManager.d.ts +32 -0
- package/lib/typescript/src/audio/AudioManager.d.ts.map +1 -0
- package/lib/typescript/src/audio/AudioSession.d.ts +70 -0
- package/lib/typescript/src/audio/AudioSession.d.ts.map +1 -0
- package/lib/typescript/src/audio/remoteVolume.d.ts +8 -0
- package/lib/typescript/src/audio/remoteVolume.d.ts.map +1 -0
- package/lib/typescript/src/components/VideoView.d.ts +44 -0
- package/lib/typescript/src/components/VideoView.d.ts.map +1 -0
- package/lib/typescript/src/features/audioScenario.d.ts +24 -0
- package/lib/typescript/src/features/audioScenario.d.ts.map +1 -0
- package/lib/typescript/src/features/beauty.d.ts +377 -0
- package/lib/typescript/src/features/beauty.d.ts.map +1 -0
- package/lib/typescript/src/features/micRelease.d.ts +28 -0
- package/lib/typescript/src/features/micRelease.d.ts.map +1 -0
- package/lib/typescript/src/features/noiseSuppression.d.ts +64 -0
- package/lib/typescript/src/features/noiseSuppression.d.ts.map +1 -0
- package/lib/typescript/src/features/roomMusic.d.ts +41 -0
- package/lib/typescript/src/features/roomMusic.d.ts.map +1 -0
- package/lib/typescript/src/features/roomMusicAndroid.d.ts +60 -0
- package/lib/typescript/src/features/roomMusicAndroid.d.ts.map +1 -0
- package/lib/typescript/src/features/roomMusicIos.d.ts +56 -0
- package/lib/typescript/src/features/roomMusicIos.d.ts.map +1 -0
- package/lib/typescript/src/features/roomMusicTypes.d.ts +76 -0
- package/lib/typescript/src/features/roomMusicTypes.d.ts.map +1 -0
- package/lib/typescript/src/features/screenShare.d.ts +12 -0
- package/lib/typescript/src/features/screenShare.d.ts.map +1 -0
- package/lib/typescript/src/features/singerMode.d.ts +20 -0
- package/lib/typescript/src/features/singerMode.d.ts.map +1 -0
- package/lib/typescript/src/features/voiceEffects.d.ts +46 -0
- package/lib/typescript/src/features/voiceEffects.d.ts.map +1 -0
- package/lib/typescript/src/hooks/context.d.ts +12 -0
- package/lib/typescript/src/hooks/context.d.ts.map +1 -0
- package/lib/typescript/src/hooks/hooks.d.ts +54 -0
- package/lib/typescript/src/hooks/hooks.d.ts.map +1 -0
- package/lib/typescript/src/hooks/types.d.ts +8 -0
- package/lib/typescript/src/hooks/types.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useRoomEvents.d.ts +13 -0
- package/lib/typescript/src/hooks/useRoomEvents.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +37 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/ios/autoAttach.d.ts +2 -0
- package/lib/typescript/src/ios/autoAttach.d.ts.map +1 -0
- package/lib/typescript/src/ios/iosAudio.d.ts +96 -0
- package/lib/typescript/src/ios/iosAudio.d.ts.map +1 -0
- package/lib/typescript/src/join/appStateLifecycle.d.ts +14 -0
- package/lib/typescript/src/join/appStateLifecycle.d.ts.map +1 -0
- package/lib/typescript/src/micPolicy.d.ts +104 -0
- package/lib/typescript/src/micPolicy.d.ts.map +1 -0
- package/lib/typescript/src/native/NativeGravixAudio.d.ts +21 -0
- package/lib/typescript/src/native/NativeGravixAudio.d.ts.map +1 -0
- package/lib/typescript/src/native/NativeGravixRtc.d.ts +31 -0
- package/lib/typescript/src/native/NativeGravixRtc.d.ts.map +1 -0
- package/lib/typescript/src/native/module.d.ts +7 -0
- package/lib/typescript/src/native/module.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/DOMException.d.ts +3 -0
- package/lib/typescript/src/polyfills/DOMException.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/early.d.ts +2 -0
- package/lib/typescript/src/polyfills/early.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/event.d.ts +2 -0
- package/lib/typescript/src/polyfills/event.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/sha256.d.ts +3 -0
- package/lib/typescript/src/polyfills/sha256.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/subtleHmac.d.ts +37 -0
- package/lib/typescript/src/polyfills/subtleHmac.d.ts.map +1 -0
- package/lib/typescript/src/polyfills/textCoding.d.ts +36 -0
- package/lib/typescript/src/polyfills/textCoding.d.ts.map +1 -0
- package/lib/typescript/src/registerGlobals.d.ts +42 -0
- package/lib/typescript/src/registerGlobals.d.ts.map +1 -0
- package/lib/typescript/src/unsupported.d.ts +42 -0
- package/lib/typescript/src/unsupported.d.ts.map +1 -0
- package/lib/typescript/src/version.d.ts +3 -0
- package/lib/typescript/src/version.d.ts.map +1 -0
- package/metro/index.js +39 -0
- package/metro/noise-stub.js +10 -0
- package/native/gxfx/include/gx_fx.h +82 -0
- package/native/gxfx/src/gx_fx.cpp +527 -0
- package/native/gxfx/third_party/README.md +4 -0
- package/native/gxfx/third_party/signalsmith-linear/LICENSE.txt +21 -0
- package/native/gxfx/third_party/signalsmith-linear/approx.h +191 -0
- package/native/gxfx/third_party/signalsmith-linear/fft.h +1386 -0
- package/native/gxfx/third_party/signalsmith-linear/linear.h +1129 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/approx-cmsisdsp.h +40 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/basic-fill-warnings.h +61 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-accelerate.h +340 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-cmsisdsp.h +307 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-ipp.h +532 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-linear.h +213 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-pffft-double.h +221 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/fft-pffft.h +221 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/linear-accelerate.h +593 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/linear-cmsisdsp.h +713 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/linear-xsimd-dispatch.cpp +6 -0
- package/native/gxfx/third_party/signalsmith-linear/platform/linear-xsimd.h +818 -0
- package/native/gxfx/third_party/signalsmith-linear/stft.h +700 -0
- package/native/gxfx/third_party/signalsmith-stretch-LICENSE.txt +21 -0
- package/native/gxfx/third_party/signalsmith-stretch.h +1060 -0
- package/native/gxns/CMakeLists.txt +67 -0
- package/native/gxns/include/gx_ns.h +285 -0
- package/native/gxns/src/gx_ns.c +1518 -0
- package/native/gxns/src/gx_ns_timer.c +84 -0
- package/native/gxns/src/gx_ns_timer.h +29 -0
- package/native/gxns/third_party/VENDOR.md +43 -0
- package/native/gxns/third_party/rnnoise/AUTHORS +1 -0
- package/native/gxns/third_party/rnnoise/COPYING +31 -0
- package/native/gxns/third_party/rnnoise/include/rnnoise.h +117 -0
- package/native/gxns/third_party/rnnoise/src/_kiss_fft_guts.h +182 -0
- package/native/gxns/third_party/rnnoise/src/arch.h +261 -0
- package/native/gxns/third_party/rnnoise/src/celt_lpc.c +172 -0
- package/native/gxns/third_party/rnnoise/src/celt_lpc.h +45 -0
- package/native/gxns/third_party/rnnoise/src/common.h +48 -0
- package/native/gxns/third_party/rnnoise/src/denoise.c +664 -0
- package/native/gxns/third_party/rnnoise/src/kiss_fft.c +601 -0
- package/native/gxns/third_party/rnnoise/src/kiss_fft.h +203 -0
- package/native/gxns/third_party/rnnoise/src/opus_types.h +159 -0
- package/native/gxns/third_party/rnnoise/src/pitch.c +523 -0
- package/native/gxns/third_party/rnnoise/src/pitch.h +149 -0
- package/native/gxns/third_party/rnnoise/src/rnn.c +178 -0
- package/native/gxns/third_party/rnnoise/src/rnn.h +65 -0
- package/native/gxns/third_party/rnnoise/src/rnn_data.c +11051 -0
- package/native/gxns/third_party/rnnoise/src/rnn_data.h +34 -0
- package/native/gxns/third_party/rnnoise/src/tansig_table.h +45 -0
- package/native/gxns/third_party/speexdsp/AUTHORS +18 -0
- package/native/gxns/third_party/speexdsp/COPYING +35 -0
- package/native/gxns/third_party/speexdsp/arch.h +232 -0
- package/native/gxns/third_party/speexdsp/resample.c +1239 -0
- package/native/gxns/third_party/speexdsp/resample_neon.h +339 -0
- package/native/gxns/third_party/speexdsp/resample_sse.h +128 -0
- package/native/gxns/third_party/speexdsp/speex_resampler.h +343 -0
- package/package.json +186 -4
- package/src/android/bindings.ts +61 -0
- package/src/android/index.ts +10 -0
- package/src/android/micMute.ts +422 -0
- package/src/android/nativeAudio.ts +94 -0
- package/src/android/noiseSuppression.ts +209 -0
- package/src/android/roomMusic.ts +193 -0
- package/src/android/singerMode.ts +53 -0
- package/src/android/voiceEffects.ts +126 -0
- package/src/audio/AudioManager.ts +111 -0
- package/src/audio/AudioSession.ts +190 -0
- package/src/audio/remoteVolume.ts +58 -0
- package/src/components/VideoView.tsx +152 -0
- package/src/features/audioScenario.ts +58 -0
- package/src/features/beauty.ts +1057 -0
- package/src/features/micRelease.ts +108 -0
- package/src/features/noiseSuppression.ts +251 -0
- package/src/features/roomMusic.ts +106 -0
- package/src/features/roomMusicAndroid.ts +310 -0
- package/src/features/roomMusicIos.ts +300 -0
- package/src/features/roomMusicTypes.ts +97 -0
- package/src/features/screenShare.ts +19 -0
- package/src/features/singerMode.ts +70 -0
- package/src/features/voiceEffects.ts +245 -0
- package/src/hooks/context.tsx +38 -0
- package/src/hooks/hooks.ts +247 -0
- package/src/hooks/types.ts +10 -0
- package/src/hooks/useRoomEvents.ts +35 -0
- package/src/index.tsx +134 -0
- package/src/ios/autoAttach.ts +11 -0
- package/src/ios/iosAudio.ts +202 -0
- package/src/join/appStateLifecycle.ts +55 -0
- package/src/micPolicy.ts +312 -0
- package/src/native/NativeGravixAudio.ts +30 -0
- package/src/native/NativeGravixRtc.ts +38 -0
- package/src/native/module.ts +22 -0
- package/src/polyfills/DOMException.ts +20 -0
- package/src/polyfills/early.ts +16 -0
- package/src/polyfills/event.ts +88 -0
- package/src/polyfills/sha256.ts +112 -0
- package/src/polyfills/subtleHmac.ts +124 -0
- package/src/polyfills/textCoding.ts +197 -0
- package/src/registerGlobals.ts +201 -0
- package/src/unsupported.ts +139 -0
- package/src/version.ts +4 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# gx_ns: on-device noise suppression core (RNNoise + speexdsp resampler + gx_ns).
|
|
2
|
+
# Host build + tests:
|
|
3
|
+
# cmake -S native/gxns -B <build> -DGXNS_BUILD_TESTS=ON && cmake --build <build> && ctest --test-dir <build>
|
|
4
|
+
# Android (externalNativeBuild) / iOS (SPM C target) / WASM (emcmake) reuse
|
|
5
|
+
# GXNS_SOURCES + GXNS_DEFINES below; this file only defines a static library.
|
|
6
|
+
cmake_minimum_required(VERSION 3.18)
|
|
7
|
+
project(gxns C)
|
|
8
|
+
|
|
9
|
+
set(CMAKE_C_STANDARD 11)
|
|
10
|
+
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
11
|
+
set(CMAKE_C_EXTENSIONS ON) # gnu11: speexdsp resample_neon.h uses `asm`
|
|
12
|
+
|
|
13
|
+
option(GXNS_BUILD_TESTS "Build host unit tests" OFF)
|
|
14
|
+
|
|
15
|
+
set(GXNS_DIR ${CMAKE_CURRENT_LIST_DIR})
|
|
16
|
+
set(GXNS_SOURCES
|
|
17
|
+
${GXNS_DIR}/src/gx_ns.c
|
|
18
|
+
${GXNS_DIR}/src/gx_ns_timer.c
|
|
19
|
+
${GXNS_DIR}/third_party/rnnoise/src/denoise.c
|
|
20
|
+
${GXNS_DIR}/third_party/rnnoise/src/rnn.c
|
|
21
|
+
${GXNS_DIR}/third_party/rnnoise/src/rnn_data.c
|
|
22
|
+
${GXNS_DIR}/third_party/rnnoise/src/pitch.c
|
|
23
|
+
${GXNS_DIR}/third_party/rnnoise/src/kiss_fft.c
|
|
24
|
+
${GXNS_DIR}/third_party/rnnoise/src/celt_lpc.c
|
|
25
|
+
${GXNS_DIR}/third_party/speexdsp/resample.c)
|
|
26
|
+
set(GXNS_INCLUDES
|
|
27
|
+
${GXNS_DIR}/include
|
|
28
|
+
${GXNS_DIR}/src
|
|
29
|
+
${GXNS_DIR}/third_party/rnnoise/include
|
|
30
|
+
${GXNS_DIR}/third_party/rnnoise/src
|
|
31
|
+
${GXNS_DIR}/third_party/speexdsp)
|
|
32
|
+
set(GXNS_DEFINES OUTSIDE_SPEEX FLOATING_POINT RANDOM_PREFIX=gx EXPORT=)
|
|
33
|
+
|
|
34
|
+
function(gxns_add_library name)
|
|
35
|
+
add_library(${name} STATIC ${GXNS_SOURCES})
|
|
36
|
+
target_include_directories(${name} PUBLIC ${GXNS_INCLUDES})
|
|
37
|
+
target_compile_definitions(${name} PRIVATE ${GXNS_DEFINES} ${ARGN})
|
|
38
|
+
target_compile_definitions(${name} PUBLIC OUTSIDE_SPEEX RANDOM_PREFIX=gx)
|
|
39
|
+
if(NOT MSVC)
|
|
40
|
+
target_compile_options(${name} PRIVATE -O2 -fvisibility=hidden -ffunction-sections -fdata-sections)
|
|
41
|
+
target_link_libraries(${name} PUBLIC m)
|
|
42
|
+
endif()
|
|
43
|
+
endfunction()
|
|
44
|
+
|
|
45
|
+
gxns_add_library(gxns)
|
|
46
|
+
|
|
47
|
+
if(GXNS_BUILD_TESTS)
|
|
48
|
+
enable_testing()
|
|
49
|
+
# Variant with malloc/calloc/realloc/free redirected to a counting trap, for
|
|
50
|
+
# the "no allocation on the hot path" test.
|
|
51
|
+
gxns_add_library(gxns_alloctrap)
|
|
52
|
+
target_compile_options(gxns_alloctrap PRIVATE -include ${GXNS_DIR}/tests/alloc_trap.h)
|
|
53
|
+
|
|
54
|
+
set(GXNS_FIXTURES ${GXNS_DIR}/tests/fixtures)
|
|
55
|
+
foreach(t timer golden rates crossfade agc external pregain dtx_quiet dtx_street room_replay wind sustain music singer_level)
|
|
56
|
+
add_executable(test_${t} ${GXNS_DIR}/tests/test_${t}.c ${GXNS_DIR}/tests/test_util.c)
|
|
57
|
+
target_link_libraries(test_${t} gxns)
|
|
58
|
+
target_compile_definitions(test_${t} PRIVATE GXNS_FIXTURES="${GXNS_FIXTURES}"
|
|
59
|
+
GXNS_SHARED_FIXTURE="${GXNS_DIR}/../../test/fixtures/ns_policy_cases.json")
|
|
60
|
+
add_test(NAME ${t} COMMAND test_${t})
|
|
61
|
+
endforeach()
|
|
62
|
+
add_executable(gxns_replay ${GXNS_DIR}/tools/gxns_replay.c)
|
|
63
|
+
target_link_libraries(gxns_replay gxns)
|
|
64
|
+
add_executable(test_noalloc ${GXNS_DIR}/tests/test_noalloc.c ${GXNS_DIR}/tests/test_util.c ${GXNS_DIR}/tests/alloc_trap.c)
|
|
65
|
+
target_link_libraries(test_noalloc gxns_alloctrap)
|
|
66
|
+
add_test(NAME noalloc COMMAND test_noalloc)
|
|
67
|
+
endif()
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/* Copyright (c) 2024-2026 Gravity Compile. MIT License; see LICENSE. */
|
|
2
|
+
/*
|
|
3
|
+
* gx_ns — platform-independent core of Gravix on-device noise suppression.
|
|
4
|
+
*
|
|
5
|
+
* One instance per capture stream (mono). Feed it the APM capture frames
|
|
6
|
+
* (any size, any of 8/16/24/32/44.1/48 kHz) in INT16 SCALE floats
|
|
7
|
+
* ([-32768, 32767], as WebRTC's capturePostProcessing delivers them); it
|
|
8
|
+
* returns the same number of samples, processed, in place, with a fixed
|
|
9
|
+
* latency (gx_ns_latency_samples()).
|
|
10
|
+
*
|
|
11
|
+
* Inside, everything runs at 48 kHz in 10 ms (480-sample) blocks:
|
|
12
|
+
*
|
|
13
|
+
* in(R) -> [up R->48k] -> FIFO -> block 480 --+-- dry (delay-compensated)
|
|
14
|
+
* +-- RNNoise (int16 scale)
|
|
15
|
+
* +-- external engine (DFN3,
|
|
16
|
+
* [-1,1] scale, optional)
|
|
17
|
+
* (the block first passes the PRE-GAIN: a speech-gated level normaliser to
|
|
18
|
+
* ~-26 dBFS, 0..+30 dB, soft-limited, so every engine sees speech at a
|
|
19
|
+
* sane level; DFN3 erases quiet input, device run 2026-10-21)
|
|
20
|
+
* -> 20 ms complementary crossfade between the sources
|
|
21
|
+
* -> VAD-gated AGC (before or after NS) -> peak limiter
|
|
22
|
+
* -> [down 48k->R] -> FIFO -> out(R)
|
|
23
|
+
*
|
|
24
|
+
* Threads: gx_ns_process() runs on the real-time audio thread and never
|
|
25
|
+
* allocates or locks. Every gx_ns_set_* / gx_ns_request_* call is an atomic
|
|
26
|
+
* store that is safe from any thread; it takes effect at the next 10 ms block.
|
|
27
|
+
* gx_ns_create() / gx_ns_destroy() allocate and must not race with
|
|
28
|
+
* gx_ns_process() on the same instance.
|
|
29
|
+
*/
|
|
30
|
+
#ifndef GX_NS_H
|
|
31
|
+
#define GX_NS_H
|
|
32
|
+
|
|
33
|
+
#include <stdint.h>
|
|
34
|
+
|
|
35
|
+
#ifdef __cplusplus
|
|
36
|
+
extern "C" {
|
|
37
|
+
#endif
|
|
38
|
+
|
|
39
|
+
#if defined(__GNUC__) || defined(__clang__)
|
|
40
|
+
#define GX_NS_API __attribute__((visibility("default")))
|
|
41
|
+
#else
|
|
42
|
+
#define GX_NS_API
|
|
43
|
+
#endif
|
|
44
|
+
|
|
45
|
+
#define GX_NS_ENGINE_RATE 48000
|
|
46
|
+
#define GX_NS_BLOCK 480 /* 10 ms at 48 kHz */
|
|
47
|
+
|
|
48
|
+
/* Engines (what produces the output). */
|
|
49
|
+
typedef enum {
|
|
50
|
+
GX_NS_ENGINE_OFF = 0, /* dry, delay-compensated */
|
|
51
|
+
GX_NS_ENGINE_RNNOISE = 1, /* "standard" */
|
|
52
|
+
GX_NS_ENGINE_DFN3 = 2 /* "studio", via gx_ns_set_external_engine() */
|
|
53
|
+
} gx_ns_engine;
|
|
54
|
+
|
|
55
|
+
/* Where OUR small digital AGC sits. Mapping of the SDK option (Dart/TS agcOrder):
|
|
56
|
+
* ownAfterNs -> agc_enabled=1, GX_NS_AGC_AFTER_NS; WebRTC software NS + AGC off
|
|
57
|
+
* webrtcBeforeNs -> agc_enabled=0 (plan option B: WebRTC's AGC stays on, our NS after it)
|
|
58
|
+
* GX_NS_AGC_BEFORE_NS (our AGC ahead of our NS) exists only for loudness A/B probes. */
|
|
59
|
+
typedef enum {
|
|
60
|
+
GX_NS_AGC_AFTER_NS = 0, /* AEC -> our NS -> our AGC (Agora/ZEGO style, plan option A) */
|
|
61
|
+
GX_NS_AGC_BEFORE_NS = 1 /* our AGC -> our NS (A/B probe only) */
|
|
62
|
+
} gx_ns_agc_order;
|
|
63
|
+
|
|
64
|
+
/* The default order. ONE place to flip it in C; Dart
|
|
65
|
+
* (kGravixNsDefaultAgcOrder) and TS (GRAVIX_NS_DEFAULT_AGC_ORDER) mirror it and
|
|
66
|
+
* test/fixtures/ns_policy_cases.json pins all three to the same value. */
|
|
67
|
+
#define GX_NS_DEFAULT_AGC_ORDER GX_NS_AGC_AFTER_NS
|
|
68
|
+
|
|
69
|
+
/* Studio (DFN3) attenuation limit: the external engine's output is mixed with
|
|
70
|
+
* the delay-aligned dry signal so noise is attenuated by at most this many dB
|
|
71
|
+
* (DeepFilterNet's atten_lim; out = (1-g)*ext + g*dry, g = 10^(-dB/20)).
|
|
72
|
+
* 0 = no limit. 40 dB: the 2026-10-21 sweep (dpdfnet-spike/tune) kept speech
|
|
73
|
+
* level and PESQ unchanged vs no limit while pauses stay >= 20 dB quieter.
|
|
74
|
+
* Mirrored by Dart (kGravixNsDefaultStudioAttenLimitDb) and TS
|
|
75
|
+
* (GRAVIX_NS_DEFAULT_STUDIO_ATTEN_LIMIT_DB); the shared fixture pins all three. */
|
|
76
|
+
#define GX_NS_DEFAULT_ATTEN_LIM_DB 40
|
|
77
|
+
/* Mid-call studio fallback: rolling p95 of the external engine's per-block time
|
|
78
|
+
* over the last ext_p95_window blocks (200 = 2 s); above the budget the core
|
|
79
|
+
* switches to RNNoise (reason GX_NS_REASON_EXT_SLOW) until an engine is
|
|
80
|
+
* (re)attached. Pinned by the shared fixture like the attenuation limit. */
|
|
81
|
+
#define GX_NS_DEFAULT_EXT_P95_BUDGET_US 3000
|
|
82
|
+
#define GX_NS_DEFAULT_EXT_P95_WINDOW 200
|
|
83
|
+
#define GX_NS_EXT_P95_WINDOW_MAX 1000
|
|
84
|
+
/* Pre-gain (before NS, every engine; owner 2026-10-21 "AEC -> pre-gain -> NS ->
|
|
85
|
+
* our AGC"): boost-only speech-level normaliser. Gain = target - speech level,
|
|
86
|
+
* clamped to [0, max]; fast attack / slow release level tracking, updated only
|
|
87
|
+
* on speech blocks (held in pauses: no noise pumping), soft limiter after it.
|
|
88
|
+
* Off while the engine is off or music bypass runs. */
|
|
89
|
+
#define GX_NS_DEFAULT_PREGAIN_TARGET_DBFS (-26)
|
|
90
|
+
#define GX_NS_DEFAULT_PREGAIN_MAX_DB 30
|
|
91
|
+
/* Our AGC after NS: speech target / max gain. -14 dBFS (block RMS of speech)
|
|
92
|
+
* lands the sent level within ~3 dB of WebRTC's own AGC (device run 2026-10-21:
|
|
93
|
+
* WebRTC -10 dB active speech vs ours -31 with the old -18 / 12 dB). */
|
|
94
|
+
#define GX_NS_DEFAULT_AGC_TARGET_DBFS (-14)
|
|
95
|
+
#define GX_NS_DEFAULT_AGC_MAX_GAIN_DB 24
|
|
96
|
+
/* Live studio guard: if the external engine's output speech energy stays this
|
|
97
|
+
* many dB under its input for GX_NS_EXT_SUPPRESS_BLOCKS speech blocks (2 s of
|
|
98
|
+
* speech), the core falls back to RNNoise (reason "studio_suppress") until an
|
|
99
|
+
* engine is re-attached. */
|
|
100
|
+
#define GX_NS_EXT_SUPPRESS_DB 20
|
|
101
|
+
#define GX_NS_EXT_SUPPRESS_BLOCKS 200
|
|
102
|
+
#define GX_NS_MUSIC_FLOOR_DB 6 /* auto music: the NS takes at most this off the input */
|
|
103
|
+
#define GX_NS_MUSIC_MAX_DBFS (-14) /* auto music: boosts never lift the music over this (0.11.4: was -18) */
|
|
104
|
+
#define GX_NS_MAKEUP_MAX_DB 30 /* bypass makeup + singer level ceiling */
|
|
105
|
+
#define GX_NS_SINGER_TARGET_DBFS (-16) /* singer level normaliser defaults (gx_ns_set_singer_level) */
|
|
106
|
+
#define GX_NS_SINGER_MAX_DB 24
|
|
107
|
+
#define GX_NS_SINGER_RISE_DB_S 3
|
|
108
|
+
#define GX_NS_SINGER_PAUSE_MS 500 /* 0.11.5 pause guard: unvoiced this long, the level boost eases out */
|
|
109
|
+
#define GX_NS_SINGER_PAUSE_FALL_DB_S 30 /* at this rate (24 dB in 0.8 s); back in one 10 ms block on the voice */
|
|
110
|
+
#define GX_NS_EXT_VS_RNN_DB 10 /* ... or this far under RNNoise (its shadow) on the same speech blocks */
|
|
111
|
+
|
|
112
|
+
/* Why the active engine differs from the requested one (gx_ns_status.reason). */
|
|
113
|
+
typedef enum {
|
|
114
|
+
GX_NS_REASON_OK = 0,
|
|
115
|
+
GX_NS_REASON_BYPASS = 1, /* music bypass */
|
|
116
|
+
GX_NS_REASON_NO_EXTERNAL = 2, /* DFN3 requested but no engine attached */
|
|
117
|
+
GX_NS_REASON_EXT_ERROR = 3, /* external engine returned an error */
|
|
118
|
+
GX_NS_REASON_DELAY_PENDING = 4, /* waiting for a quiet block to change delay */
|
|
119
|
+
GX_NS_REASON_EXT_SLOW = 5, /* studio rolling p95 over budget -> RNNoise ("studio_slow") */
|
|
120
|
+
GX_NS_REASON_EXT_SUPPRESS = 6 /* studio output speech collapsed vs its input -> RNNoise ("studio_suppress") */
|
|
121
|
+
} gx_ns_reason;
|
|
122
|
+
|
|
123
|
+
/* External (studio) engine, e.g. DFN3. Called on the audio thread with one
|
|
124
|
+
* 480-sample block at 48 kHz in [-1, 1] scale; must not allocate. Returns 0 on
|
|
125
|
+
* success; non-zero makes the core fall back to RNNoise at once
|
|
126
|
+
* (reason GX_NS_REASON_EXT_ERROR). latency_samples = its algorithmic delay at
|
|
127
|
+
* 48 kHz; the core delays the other paths to match (delay compensation). */
|
|
128
|
+
typedef struct {
|
|
129
|
+
int (*process)(void *user, float *out, const float *in, int n);
|
|
130
|
+
void (*reset)(void *user); /* optional: clear state (route change); may be NULL */
|
|
131
|
+
void *user;
|
|
132
|
+
int latency_samples;
|
|
133
|
+
} gx_ns_external_engine;
|
|
134
|
+
|
|
135
|
+
typedef struct {
|
|
136
|
+
int max_frame_samples; /* largest frame per gx_ns_process call (any rate); larger calls are chunked. default 2048 */
|
|
137
|
+
int crossfade_ms; /* default 20 */
|
|
138
|
+
int resampler_quality; /* speex 0..10, default 5 */
|
|
139
|
+
gx_ns_engine initial_engine; /* default RNNOISE; audible from the first block (no crossfade from dry) */
|
|
140
|
+
int agc_enabled; /* default 1 */
|
|
141
|
+
gx_ns_agc_order agc_order; /* default GX_NS_DEFAULT_AGC_ORDER */
|
|
142
|
+
float agc_target_dbfs; /* speech RMS target, default GX_NS_DEFAULT_AGC_TARGET_DBFS */
|
|
143
|
+
float agc_max_gain_db; /* default GX_NS_DEFAULT_AGC_MAX_GAIN_DB */
|
|
144
|
+
float agc_min_gain_db; /* default -10 */
|
|
145
|
+
float limiter_dbfs; /* peak ceiling, default -1 */
|
|
146
|
+
int watchdog_us; /* frame time counted as over budget, default 8000 */
|
|
147
|
+
int max_external_latency;/* largest external latency to support (48 kHz samples), default 960 */
|
|
148
|
+
float ext_atten_lim_db; /* studio attenuation limit, default GX_NS_DEFAULT_ATTEN_LIM_DB; 0 = none */
|
|
149
|
+
int ext_p95_budget_us; /* studio rolling-p95 budget, default GX_NS_DEFAULT_EXT_P95_BUDGET_US; 0 = off */
|
|
150
|
+
int ext_p95_window; /* blocks in the rolling window, default GX_NS_DEFAULT_EXT_P95_WINDOW (2 s), max GX_NS_EXT_P95_WINDOW_MAX */
|
|
151
|
+
int pregain_enabled; /* default 1 */
|
|
152
|
+
float pregain_target_dbfs; /* default GX_NS_DEFAULT_PREGAIN_TARGET_DBFS */
|
|
153
|
+
float pregain_max_db; /* default GX_NS_DEFAULT_PREGAIN_MAX_DB */
|
|
154
|
+
int auto_music; /* music on the mic relaxes the chain (gx_ns_set_auto_music), default 0 */
|
|
155
|
+
} gx_ns_config;
|
|
156
|
+
|
|
157
|
+
typedef struct {
|
|
158
|
+
uint32_t frames; /* gx_ns_process calls timed */
|
|
159
|
+
uint32_t p50_us, p95_us, p99_us, max_us;
|
|
160
|
+
uint32_t over_budget; /* calls longer than watchdog_us */
|
|
161
|
+
uint32_t consecutive_over;/* current run of over-budget calls (watchdog: >= 3 -> fallback) */
|
|
162
|
+
uint32_t underflows; /* output FIFO underflows (should stay 0) */
|
|
163
|
+
uint32_t ext_errors; /* external engine failures */
|
|
164
|
+
uint32_t engine_switches; /* completed crossfades */
|
|
165
|
+
uint32_t ext_p95_us; /* studio engine: rolling p95 per-block time (last full window), 0 = none yet */
|
|
166
|
+
uint32_t ext_slow; /* studio demoted for its rolling p95 (sticky until re-attach) */
|
|
167
|
+
uint32_t ext_suppress; /* studio demoted: output speech collapsed (sticky until re-attach) */
|
|
168
|
+
} gx_ns_stats;
|
|
169
|
+
|
|
170
|
+
typedef struct {
|
|
171
|
+
gx_ns_engine requested;
|
|
172
|
+
gx_ns_engine active; /* source currently audible (target once a fade ends) */
|
|
173
|
+
int crossfading;
|
|
174
|
+
gx_ns_reason reason;
|
|
175
|
+
int rate; /* current I/O rate, 0 before the first frame */
|
|
176
|
+
int latency_samples; /* at `rate` */
|
|
177
|
+
float vad; /* last block voice probability 0..1 */
|
|
178
|
+
float agc_gain_db; /* the AGC's learnt (held) gain */
|
|
179
|
+
float pregain_db; /* the learnt (held) pre-gain (0 = unity) */
|
|
180
|
+
/* What the last block actually got (2026-10-21): out of talk the boosts are
|
|
181
|
+
* held but not applied (pause gate), and the pause expander attenuates. */
|
|
182
|
+
float pregain_applied_db;
|
|
183
|
+
float agc_applied_db;
|
|
184
|
+
float pause_att_db; /* pause expander attenuation (>= 0) */
|
|
185
|
+
int talk; /* the talk detector: this block is talk (or its hangover) */
|
|
186
|
+
int music_detected; /* auto music: the mic carries music, the chain is relaxed (2026-11-20) */
|
|
187
|
+
/* 0.11.4: levels of the last ~1 s window (dBFS, -120 = silence) and the
|
|
188
|
+
* bypass gains (singer mode) */
|
|
189
|
+
float pre_rms_db, pre_peak_db; /* the input, before the pre-gain */
|
|
190
|
+
float post_rms_db, post_peak_db; /* the output, after the limiter */
|
|
191
|
+
float makeup_db; /* bypass gain applied now (fixed makeup + singer level) */
|
|
192
|
+
float singer_gain_db; /* the singer level normaliser's gain (held in pauses) */
|
|
193
|
+
float singer_level_db; /* its sung-level estimate (-120 = none yet) */
|
|
194
|
+
} gx_ns_status;
|
|
195
|
+
|
|
196
|
+
GX_NS_API void gx_ns_default_config(gx_ns_config *cfg);
|
|
197
|
+
|
|
198
|
+
/* Allocates everything (resamplers for every supported rate, FIFOs, RNNoise
|
|
199
|
+
* state + FFT tables warm-up). NULL cfg = defaults. NULL on failure. */
|
|
200
|
+
GX_NS_API struct gx_ns *gx_ns_create(const gx_ns_config *cfg);
|
|
201
|
+
GX_NS_API void gx_ns_destroy(struct gx_ns *st);
|
|
202
|
+
|
|
203
|
+
/* Real-time path. Processes n mono samples in place (int16 scale). A change of
|
|
204
|
+
* sample_rate (8000/16000/24000/32000/44100/48000) resets the stream state
|
|
205
|
+
* without allocating and fades in over the crossfade time. Returns 0, or -1
|
|
206
|
+
* for an unsupported rate (samples left untouched). */
|
|
207
|
+
GX_NS_API int gx_ns_process(struct gx_ns *st, float *samples, int n, int sample_rate);
|
|
208
|
+
|
|
209
|
+
/* Control (any thread, atomic, applied at the next 10 ms block). */
|
|
210
|
+
GX_NS_API void gx_ns_set_engine(struct gx_ns *st, gx_ns_engine engine);
|
|
211
|
+
GX_NS_API void gx_ns_set_bypass(struct gx_ns *st, int bypass); /* music: crossfade to dry, our AGC to unity */
|
|
212
|
+
GX_NS_API void gx_ns_set_agc(struct gx_ns *st, int enabled);
|
|
213
|
+
GX_NS_API void gx_ns_set_agc_order(struct gx_ns *st, gx_ns_agc_order order);
|
|
214
|
+
GX_NS_API void gx_ns_request_reset(struct gx_ns *st); /* route change: fade to dry, reset engine state, fade back (~40 ms) */
|
|
215
|
+
GX_NS_API void gx_ns_set_atten_limit(struct gx_ns *st, float db); /* studio attenuation limit in dB; 0 = none */
|
|
216
|
+
GX_NS_API void gx_ns_set_ext_p95_budget(struct gx_ns *st, int us); /* studio rolling-p95 budget; 0 = off */
|
|
217
|
+
GX_NS_API void gx_ns_reset_stats(struct gx_ns *st);
|
|
218
|
+
GX_NS_API void gx_ns_set_pregain(struct gx_ns *st, int enabled);
|
|
219
|
+
/* Auto music (2026-11-20): music played into the mic (a speaker, another app,
|
|
220
|
+
* an instrument) is detected from the input itself (sustained, tonal, changing
|
|
221
|
+
* notes, no speech pauses: about 3 s to enter, 15 s of non-music to leave;
|
|
222
|
+
* 0.11.4, was 3 s: songs on a gapped input dropped out mid-song).
|
|
223
|
+
* While detected, over ~300 ms: the NS keeps at least half of the input
|
|
224
|
+
* (attenuation <= GX_NS_MUSIC_FLOOR_DB), the pause gate stays open and the
|
|
225
|
+
* pause expander is off, the pre-gain and AGC learn only slowly and only up
|
|
226
|
+
* (<= 1 dB/s, 0.11.4; boosts capped so the music is not lifted over
|
|
227
|
+
* GX_NS_MUSIC_MAX_DBFS). Music
|
|
228
|
+
* bypass and engine off already take the chain out: detection then rests.
|
|
229
|
+
* Off = exactly the chain without it. */
|
|
230
|
+
GX_NS_API void gx_ns_set_auto_music(struct gx_ns *st, int enabled);
|
|
231
|
+
/* Auto music starts over (not detected, not relaxed): call when a capture
|
|
232
|
+
* stream (re)starts. gx_ns_request_reset and a rate change do it too. */
|
|
233
|
+
GX_NS_API void gx_ns_reset_music(struct gx_ns *st);
|
|
234
|
+
/* Makeup gain while the bypass is on (singer mode on a quiet built-in mic,
|
|
235
|
+
* 2026-11-20): applied to the dry signal, ramped over 100 ms, before the peak
|
|
236
|
+
* limiter (GX_NS_DEFAULT config limiter_dbfs, -1 dBFS), so a hot input is
|
|
237
|
+
* limited, never clipped. 0..GX_NS_MAKEUP_MAX_DB; 0 = none (default). */
|
|
238
|
+
GX_NS_API void gx_ns_set_bypass_makeup(struct gx_ns *st, float db);
|
|
239
|
+
/* Singer level normaliser (0.11.4) while the bypass is on: boost-only, toward
|
|
240
|
+
* `target_dbfs` (sung-level estimate: block RMS over the noise floor averaged
|
|
241
|
+
* over ~2 s (10 dB louder for 0.5 s: ~0.2 s); blocks 12 dB under the estimate are not counted, so
|
|
242
|
+
* a quieter far-end echo or room sound does not pull it down), at most
|
|
243
|
+
* `max_db`, rising at most `rise_db_per_s` and only on voiced blocks (held in
|
|
244
|
+
* pauses), falling at once (<= 1 dB per 10 ms) when the singing gets louder.
|
|
245
|
+
* Adds to the fixed makeup; the sum is capped at GX_NS_MAKEUP_MAX_DB, then the
|
|
246
|
+
* -1 dBFS limiter. max_db 0 = off (default; the bypass is then bit-identical).
|
|
247
|
+
* 0.11.5 pause guard: after GX_NS_SINGER_PAUSE_MS with nothing over the noise
|
|
248
|
+
* floor the boost eases out (GX_NS_SINGER_PAUSE_FALL_DB_S), never under the
|
|
249
|
+
* fixed makeup; back at once after 20 ms of singing, gradually on other sound. */
|
|
250
|
+
GX_NS_API void gx_ns_set_singer_level(struct gx_ns *st, float target_dbfs, float max_db, float rise_db_per_s);
|
|
251
|
+
/* Detector features of the last block (tuning, gxns_replay --music):
|
|
252
|
+
* [0] dip share, [1] tonal share, [2] note onsets in the window, [3] stable
|
|
253
|
+
* peaks this block, [4] state (0/1), [5] relax amount 0..1, [6] music level dBFS. */
|
|
254
|
+
GX_NS_API void gx_ns_get_music_debug(struct gx_ns *st, float out[7]);
|
|
255
|
+
|
|
256
|
+
/* The pre-gain the core settles on for speech at `speech_dbfs` (default target
|
|
257
|
+
* and max): what a studio benchmark applies to its input to test the engine at
|
|
258
|
+
* the level it will really see. */
|
|
259
|
+
GX_NS_API float gx_ns_pregain_for_level(float speech_dbfs);
|
|
260
|
+
|
|
261
|
+
/* Delay-compensation hook. Attaching (non-NULL) raises the dry and RNNoise
|
|
262
|
+
* delay to the engine's latency; detaching lowers it again. The delay change is
|
|
263
|
+
* applied at the next quiet block (VAD low) with a 5 ms fade out/in, or after
|
|
264
|
+
* 2 s at the latest. DFN3 becomes audible only after that. To detach safely:
|
|
265
|
+
* gx_ns_set_external_engine(st, NULL), then wait until gx_ns_blocks_processed()
|
|
266
|
+
* has advanced (or the audio thread is stopped) before freeing the engine.
|
|
267
|
+
* The struct is copied. Returns -1 if latency_samples > max_external_latency. */
|
|
268
|
+
GX_NS_API int gx_ns_set_external_engine(struct gx_ns *st, const gx_ns_external_engine *eng);
|
|
269
|
+
|
|
270
|
+
GX_NS_API void gx_ns_get_stats(struct gx_ns *st, gx_ns_stats *out);
|
|
271
|
+
GX_NS_API void gx_ns_get_status(struct gx_ns *st, gx_ns_status *out);
|
|
272
|
+
GX_NS_API int gx_ns_latency_samples(struct gx_ns *st, int sample_rate);
|
|
273
|
+
GX_NS_API uint32_t gx_ns_blocks_processed(struct gx_ns *st);
|
|
274
|
+
|
|
275
|
+
GX_NS_API const char *gx_ns_engine_name(gx_ns_engine e); /* "off" | "rnnoise" | "dfn3" */
|
|
276
|
+
GX_NS_API const char *gx_ns_reason_name(gx_ns_reason r);
|
|
277
|
+
|
|
278
|
+
/* RNNoise's own algorithmic delay at 48 kHz (one frame). */
|
|
279
|
+
#define GX_NS_RNNOISE_LATENCY 480
|
|
280
|
+
|
|
281
|
+
#ifdef __cplusplus
|
|
282
|
+
}
|
|
283
|
+
#endif
|
|
284
|
+
|
|
285
|
+
#endif /* GX_NS_H */
|