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,209 @@
|
|
|
1
|
+
// Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
noiseSuppressionOptions,
|
|
5
|
+
nsBenchmarkKey,
|
|
6
|
+
resolveNs,
|
|
7
|
+
type GravixNoiseSuppressionMode,
|
|
8
|
+
type GravixNoiseSuppressionOptions,
|
|
9
|
+
type GravixNsBenchmark,
|
|
10
|
+
type GravixNsDeviceFacts,
|
|
11
|
+
type GravixNsEngine,
|
|
12
|
+
} from 'gravix-rtc';
|
|
13
|
+
import { asMap, requireBridge } from './nativeAudio';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* On-device noise suppression on Android (native gx_ns: RNNoise `standard`,
|
|
17
|
+
* DeepFilterNet3 `studio` on arm64), the levels of the Flutter SDK:
|
|
18
|
+
* `off` | `standard` | `studio` | `auto`. The engine is resolved in JS with
|
|
19
|
+
* the shared resolver of the `gravix-rtc` core (same policy fixture as
|
|
20
|
+
* Flutter / web), then configured natively (Flutter `nsConfigure`).
|
|
21
|
+
*
|
|
22
|
+
* WebRTC's own NS / AGC should be off on the microphone while ours runs: the
|
|
23
|
+
* caller captures the mic with `noiseSuppression: false, autoGainControl:
|
|
24
|
+
* false` (echo cancellation on) when {@link GravixAndroidNsState.engine} is
|
|
25
|
+
* ours, exactly as the web SDK does (`disableWebRtcNs`).
|
|
26
|
+
*/
|
|
27
|
+
export interface GravixAndroidNsState {
|
|
28
|
+
mode: GravixNoiseSuppressionMode;
|
|
29
|
+
/** The engine actually running (`off` = none of ours). */
|
|
30
|
+
engine: GravixNsEngine;
|
|
31
|
+
reason: string;
|
|
32
|
+
/** On WebRTC's capture post-processing slot. */
|
|
33
|
+
installed: boolean;
|
|
34
|
+
route?: string;
|
|
35
|
+
rate?: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Flutter's engine names on the native side. */
|
|
39
|
+
function nativeEngineName(e: GravixNsEngine): string {
|
|
40
|
+
switch (e) {
|
|
41
|
+
case 'rnnoise':
|
|
42
|
+
return 'rnnoise';
|
|
43
|
+
case 'dfn3':
|
|
44
|
+
return 'dfn3';
|
|
45
|
+
default:
|
|
46
|
+
return 'off';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let cachedBenchmark: GravixNsBenchmark | null = null;
|
|
51
|
+
let benchmarkRunning: Promise<void> | null = null;
|
|
52
|
+
|
|
53
|
+
/** Static device facts from the native side (model, soc, abi, RAM, ...). */
|
|
54
|
+
export async function androidNsDeviceFacts(): Promise<
|
|
55
|
+
GravixNsDeviceFacts & { studioAvailable?: boolean }
|
|
56
|
+
> {
|
|
57
|
+
const m =
|
|
58
|
+
asMap(await requireBridge('noiseSuppression').call('nsDeviceFacts')) ?? {};
|
|
59
|
+
return { platform: 'android', ...(m as object) } as GravixNsDeviceFacts & {
|
|
60
|
+
studioAvailable?: boolean;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The `nsConfigure` arguments for [o] resolved to [engine] (Flutter GravixNoiseController). */
|
|
65
|
+
export function androidNsConfigureArgs(
|
|
66
|
+
o: GravixNoiseSuppressionOptions,
|
|
67
|
+
engine: GravixNsEngine,
|
|
68
|
+
reason: string
|
|
69
|
+
): Record<string, unknown> {
|
|
70
|
+
return {
|
|
71
|
+
mode: o.mode,
|
|
72
|
+
engine: nativeEngineName(engine),
|
|
73
|
+
reason,
|
|
74
|
+
agcOrder: o.agcOrder,
|
|
75
|
+
musicBypass: o.musicBypass,
|
|
76
|
+
autoMusic: (o as { autoMusic?: boolean }).autoMusic ?? true,
|
|
77
|
+
hardwareNs: o.hardwareNs,
|
|
78
|
+
headsetNs: o.headsetNs,
|
|
79
|
+
watchdogFrameUs: Math.round(o.watchdogFrameMs * 1000),
|
|
80
|
+
watchdogConsecutive: o.watchdogConsecutive,
|
|
81
|
+
thermalFallback: o.thermalFallback,
|
|
82
|
+
batterySaverFallback: o.batterySaverFallback,
|
|
83
|
+
studioSource: o.studioSource,
|
|
84
|
+
studioDownload: o.studioDownload,
|
|
85
|
+
studioAttenLimitDb: o.studioAttenLimitDb,
|
|
86
|
+
studioP95BudgetUs: o.studioP95BudgetUs,
|
|
87
|
+
studioP95WindowMs: o.studioP95WindowMs,
|
|
88
|
+
studioLowLatency: o.studioLowLatency,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Resolves and applies the noise suppression level. `auto` without a cached
|
|
94
|
+
* benchmark runs RNNoise first and benchmarks studio in the background; once
|
|
95
|
+
* the benchmark is in, call this again (or pass `rerunAfterBenchmark`).
|
|
96
|
+
*/
|
|
97
|
+
export async function configureAndroidNoiseSuppression(
|
|
98
|
+
options?: Partial<GravixNoiseSuppressionOptions> & { autoMusic?: boolean },
|
|
99
|
+
opts: { rerunAfterBenchmark?: boolean } = {}
|
|
100
|
+
): Promise<GravixAndroidNsState> {
|
|
101
|
+
const b = requireBridge('noiseSuppression');
|
|
102
|
+
const o = noiseSuppressionOptions(options);
|
|
103
|
+
const facts =
|
|
104
|
+
o.mode === 'off'
|
|
105
|
+
? ({ platform: 'android' } as GravixNsDeviceFacts)
|
|
106
|
+
: await androidNsDeviceFacts();
|
|
107
|
+
// the resolver reads the typed facts; the studio keys ride along
|
|
108
|
+
const key = androidNsBenchmarkKey(
|
|
109
|
+
facts as unknown as Record<string, unknown>
|
|
110
|
+
);
|
|
111
|
+
const r = resolveNs({
|
|
112
|
+
mode: o.mode,
|
|
113
|
+
facts,
|
|
114
|
+
policy: o.policy ?? null,
|
|
115
|
+
benchmark: cachedBenchmark,
|
|
116
|
+
benchmarkKey: key,
|
|
117
|
+
studioAvailable:
|
|
118
|
+
(facts as { studioAvailable?: boolean }).studioAvailable === true,
|
|
119
|
+
benchmarkP95Us: o.benchmarkP95Us,
|
|
120
|
+
});
|
|
121
|
+
if (r.needsBenchmark && key && !benchmarkRunning) {
|
|
122
|
+
benchmarkRunning = runBenchmark(o.benchmarkP95Us, key).then(() => {
|
|
123
|
+
benchmarkRunning = null;
|
|
124
|
+
if (opts.rerunAfterBenchmark !== false && cachedBenchmark) {
|
|
125
|
+
configureAndroidNoiseSuppression(options, {
|
|
126
|
+
rerunAfterBenchmark: false,
|
|
127
|
+
}).catch(() => {});
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
let reply: Record<string, unknown> | null = null;
|
|
132
|
+
try {
|
|
133
|
+
reply = asMap(
|
|
134
|
+
await b.call('nsConfigure', androidNsConfigureArgs(o, r.engine, r.reason))
|
|
135
|
+
);
|
|
136
|
+
} catch {
|
|
137
|
+
reply = null;
|
|
138
|
+
}
|
|
139
|
+
let engine = r.engine;
|
|
140
|
+
let reason = r.reason;
|
|
141
|
+
const ours = engine === 'rnnoise' || engine === 'dfn3';
|
|
142
|
+
if (ours && (reply == null || reply.ok !== true)) {
|
|
143
|
+
engine = 'off';
|
|
144
|
+
reason =
|
|
145
|
+
typeof reply?.reason === 'string' ? reply.reason : 'native_unavailable';
|
|
146
|
+
} else if (ours && typeof reply?.engine === 'string') {
|
|
147
|
+
// the native side may have downgraded (thermal, saver, watchdog)
|
|
148
|
+
if (
|
|
149
|
+
reply.engine === 'rnnoise' ||
|
|
150
|
+
reply.engine === 'dfn3' ||
|
|
151
|
+
reply.engine === 'off'
|
|
152
|
+
) {
|
|
153
|
+
engine = reply.engine as GravixNsEngine;
|
|
154
|
+
}
|
|
155
|
+
if (typeof reply.reason === 'string') reason = reply.reason;
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
mode: o.mode,
|
|
159
|
+
engine,
|
|
160
|
+
reason,
|
|
161
|
+
installed: reply?.installed === true,
|
|
162
|
+
route: typeof reply?.route === 'string' ? reply.route : undefined,
|
|
163
|
+
rate: typeof reply?.rate === 'number' ? reply.rate : undefined,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** SDK version in the benchmark key: a new native build re-benchmarks. */
|
|
168
|
+
export const GRAVIX_RN_NS_SDK_VERSION = 'rn-android-0.1.0';
|
|
169
|
+
|
|
170
|
+
/** Same key shape as Flutter / web (`nsBenchmarkKey`); null without a studio model. */
|
|
171
|
+
export function androidNsBenchmarkKey(
|
|
172
|
+
facts: Record<string, unknown>
|
|
173
|
+
): string | null {
|
|
174
|
+
const sha = facts.studioSha;
|
|
175
|
+
if (typeof sha !== 'string' || !sha) return null;
|
|
176
|
+
return nsBenchmarkKey({
|
|
177
|
+
sdkVersion: GRAVIX_RN_NS_SDK_VERSION,
|
|
178
|
+
modelSha256: sha,
|
|
179
|
+
runtimeVersion: String(facts.studioRuntime ?? ''),
|
|
180
|
+
osBuild: String(facts.osBuild ?? ''),
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async function runBenchmark(budgetUs: number, key: string): Promise<void> {
|
|
185
|
+
try {
|
|
186
|
+
const m = asMap(
|
|
187
|
+
await requireBridge('noiseSuppression').call('nsBenchmark', { budgetUs })
|
|
188
|
+
);
|
|
189
|
+
if (m && m.ok === true && typeof m.p95Us === 'number') {
|
|
190
|
+
cachedBenchmark = { key, p95Us: m.p95Us, outputOk: m.outputOk === true };
|
|
191
|
+
}
|
|
192
|
+
} catch {
|
|
193
|
+
// no benchmark: auto stays on RNNoise
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/** The native state map (`nsStats`): engine, rate, route, stats. */
|
|
198
|
+
export async function androidNoiseSuppressionStats(): Promise<Record<
|
|
199
|
+
string,
|
|
200
|
+
unknown
|
|
201
|
+
> | null> {
|
|
202
|
+
return asMap(await requireBridge('noiseSuppression').call('nsStats'));
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Test seam. */
|
|
206
|
+
export function __resetAndroidNsForTests(): void {
|
|
207
|
+
cachedBenchmark = null;
|
|
208
|
+
benchmarkRunning = null;
|
|
209
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
asMap,
|
|
5
|
+
requireBridge,
|
|
6
|
+
type GravixAndroidAudioListener,
|
|
7
|
+
} from './nativeAudio';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Karaoke / room music on Android: a local file or content URI decoded
|
|
11
|
+
* natively and mixed INTO the published microphone (one stream, no second
|
|
12
|
+
* track, no server bot), with the host's local monitor, mic volume, ducking,
|
|
13
|
+
* loop and seek. Port of the Flutter SDK's `GravixRoomMusic` native layer
|
|
14
|
+
* (`MusicMixerEngine`, channel `com.gravitycompile.gravix_rtc/music`).
|
|
15
|
+
*
|
|
16
|
+
* Needs a running microphone capture (publish the mic first):
|
|
17
|
+
* `CAPTURE_NOT_READY` otherwise.
|
|
18
|
+
*/
|
|
19
|
+
export interface GravixAndroidMusicOptions {
|
|
20
|
+
/** Music level 0..1 in the mix and the host's monitor (default 1). */
|
|
21
|
+
musicVolume?: number;
|
|
22
|
+
/** Voice level 0..1 in the mix (default 1). */
|
|
23
|
+
micVolume?: number;
|
|
24
|
+
/** Lower the music while the host talks (default false). */
|
|
25
|
+
ducking?: boolean;
|
|
26
|
+
/** Music gain while ducked, 0..1 (default 0.35). */
|
|
27
|
+
duckLevel?: number;
|
|
28
|
+
loop?: boolean;
|
|
29
|
+
/** The host hears the music locally (default true). */
|
|
30
|
+
monitor?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* While music plays a mic mute removes only the voice; the music keeps
|
|
33
|
+
* reaching the room (default true). False: a mute silences both
|
|
34
|
+
* (`holdOnMute` natively).
|
|
35
|
+
*/
|
|
36
|
+
continueWhileMicMuted?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* 0.12.2: with `continueWhileMicMuted`, the mute closes the HARDWARE mic
|
|
39
|
+
* (OS mic indicator off) while the music keeps going (default true). Used
|
|
40
|
+
* by {@link GravixMicMute}; false = the 0.12.1 rollback.
|
|
41
|
+
*/
|
|
42
|
+
continueWhileMicReleased?: boolean;
|
|
43
|
+
/** Pause on a call / audio-focus loss; a transient one resumes (default true). */
|
|
44
|
+
pauseOnInterruption?: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const DEFAULT_ANDROID_MUSIC_OPTIONS: Required<GravixAndroidMusicOptions> =
|
|
48
|
+
{
|
|
49
|
+
musicVolume: 1,
|
|
50
|
+
micVolume: 1,
|
|
51
|
+
ducking: false,
|
|
52
|
+
duckLevel: 0.35,
|
|
53
|
+
loop: false,
|
|
54
|
+
monitor: true,
|
|
55
|
+
continueWhileMicMuted: true,
|
|
56
|
+
continueWhileMicReleased: true,
|
|
57
|
+
pauseOnInterruption: true,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export interface GravixMusicNativeState {
|
|
61
|
+
active: boolean;
|
|
62
|
+
paused: boolean;
|
|
63
|
+
interrupted: string | null;
|
|
64
|
+
positionMs: number;
|
|
65
|
+
durationMs: number;
|
|
66
|
+
captureLive: boolean;
|
|
67
|
+
captureSampleRate: number;
|
|
68
|
+
captureChannels: number;
|
|
69
|
+
installed: boolean;
|
|
70
|
+
mixRoute: string;
|
|
71
|
+
micReleased: boolean;
|
|
72
|
+
[key: string]: unknown;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const clamp01 = (v: number) =>
|
|
76
|
+
Number.isFinite(v) ? Math.min(1, Math.max(0, v)) : 1;
|
|
77
|
+
|
|
78
|
+
/** The `music.start` arguments (Flutter MusicMixerPlugin keys). */
|
|
79
|
+
export function musicStartArgs(
|
|
80
|
+
source: string,
|
|
81
|
+
o: GravixAndroidMusicOptions = {}
|
|
82
|
+
): Record<string, unknown> {
|
|
83
|
+
const m = { ...DEFAULT_ANDROID_MUSIC_OPTIONS, ...o };
|
|
84
|
+
return {
|
|
85
|
+
source,
|
|
86
|
+
contentUri: source.startsWith('content://'),
|
|
87
|
+
loop: m.loop,
|
|
88
|
+
monitor: m.monitor,
|
|
89
|
+
musicVolume: clamp01(m.musicVolume),
|
|
90
|
+
micVolume: clamp01(m.micVolume),
|
|
91
|
+
ducking: m.ducking,
|
|
92
|
+
duckLevel: clamp01(m.duckLevel),
|
|
93
|
+
holdOnMute: !m.continueWhileMicMuted,
|
|
94
|
+
pauseOnInterruption: m.pauseOnInterruption,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** One room-music session at a time (the native mixer is process-wide). */
|
|
99
|
+
export class GravixAndroidRoomMusic {
|
|
100
|
+
private options: Required<GravixAndroidMusicOptions>;
|
|
101
|
+
|
|
102
|
+
constructor(options: GravixAndroidMusicOptions = {}) {
|
|
103
|
+
this.options = { ...DEFAULT_ANDROID_MUSIC_OPTIONS, ...options };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
get currentOptions(): Readonly<Required<GravixAndroidMusicOptions>> {
|
|
107
|
+
return this.options;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private call(
|
|
111
|
+
method: string,
|
|
112
|
+
args?: Record<string, unknown>
|
|
113
|
+
): Promise<unknown> {
|
|
114
|
+
return requireBridge('roomMusic').call(`music.${method}`, args);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** Starts [source] (file path or content:// URI), replacing a running one. Returns the duration (ms, -1 unknown). */
|
|
118
|
+
async start(
|
|
119
|
+
source: string,
|
|
120
|
+
options: GravixAndroidMusicOptions = {}
|
|
121
|
+
): Promise<number> {
|
|
122
|
+
this.options = { ...this.options, ...options };
|
|
123
|
+
const r = asMap(
|
|
124
|
+
await this.call('start', musicStartArgs(source, this.options))
|
|
125
|
+
);
|
|
126
|
+
return typeof r?.durationMs === 'number' ? r.durationMs : -1;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
pause(): Promise<unknown> {
|
|
130
|
+
return this.call('pause');
|
|
131
|
+
}
|
|
132
|
+
resume(): Promise<unknown> {
|
|
133
|
+
return this.call('resume');
|
|
134
|
+
}
|
|
135
|
+
stop(): Promise<unknown> {
|
|
136
|
+
return this.call('stop');
|
|
137
|
+
}
|
|
138
|
+
seek(positionMs: number): Promise<unknown> {
|
|
139
|
+
return this.call('seek', {
|
|
140
|
+
positionMs: Math.max(0, Math.round(positionMs)),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
setMusicVolume(volume: number): Promise<unknown> {
|
|
144
|
+
this.options.musicVolume = clamp01(volume);
|
|
145
|
+
return this.call('setMusicVolume', { volume: this.options.musicVolume });
|
|
146
|
+
}
|
|
147
|
+
setMicVolume(volume: number): Promise<unknown> {
|
|
148
|
+
this.options.micVolume = clamp01(volume);
|
|
149
|
+
return this.call('setMicVolume', { volume: this.options.micVolume });
|
|
150
|
+
}
|
|
151
|
+
setDucking(on: boolean, level?: number): Promise<unknown> {
|
|
152
|
+
this.options.ducking = on;
|
|
153
|
+
if (level !== undefined) this.options.duckLevel = clamp01(level);
|
|
154
|
+
return this.call('setDucking', { on, level: this.options.duckLevel });
|
|
155
|
+
}
|
|
156
|
+
setLoop(on: boolean): Promise<unknown> {
|
|
157
|
+
this.options.loop = on;
|
|
158
|
+
return this.call('setLoop', { on });
|
|
159
|
+
}
|
|
160
|
+
/** continueWhileMicMuted / pauseOnInterruption at runtime. */
|
|
161
|
+
configure(
|
|
162
|
+
o: Pick<
|
|
163
|
+
GravixAndroidMusicOptions,
|
|
164
|
+
| 'continueWhileMicMuted'
|
|
165
|
+
| 'pauseOnInterruption'
|
|
166
|
+
| 'continueWhileMicReleased'
|
|
167
|
+
>
|
|
168
|
+
): Promise<unknown> {
|
|
169
|
+
this.options = { ...this.options, ...o };
|
|
170
|
+
return this.call('configure', {
|
|
171
|
+
holdOnMute: !this.options.continueWhileMicMuted,
|
|
172
|
+
pauseOnInterruption: this.options.pauseOnInterruption,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
async isActive(): Promise<boolean> {
|
|
176
|
+
return (await this.call('isActive')) === true;
|
|
177
|
+
}
|
|
178
|
+
async getState(): Promise<GravixMusicNativeState | null> {
|
|
179
|
+
return asMap(await this.call('getState')) as GravixMusicNativeState | null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
onCompleted(l: () => void): () => void {
|
|
183
|
+
return requireBridge('roomMusic').addListener('music.onCompleted', () =>
|
|
184
|
+
l()
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
onError(l: GravixAndroidAudioListener): () => void {
|
|
188
|
+
return requireBridge('roomMusic').addListener('music.onError', l);
|
|
189
|
+
}
|
|
190
|
+
onInterruption(l: GravixAndroidAudioListener): () => void {
|
|
191
|
+
return requireBridge('roomMusic').addListener('music.onInterruption', l);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
|
|
2
|
+
|
|
3
|
+
import { asMap, requireBridge } from './nativeAudio';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The Android-native half of singer mode (Flutter `nsSetSingerMode`): our
|
|
7
|
+
* NS / AGC / pause expander bypassed (limiter near clip kept), the singer
|
|
8
|
+
* level normaliser, and WebRTC's recorder re-opened with the singer capture
|
|
9
|
+
* source (no audio device module rebuild). The browser-style half (WebRTC
|
|
10
|
+
* processing off, bitrate, DTX) is the gravix-rtc core's `room.setSingerMode`.
|
|
11
|
+
*/
|
|
12
|
+
export type GravixSingerCaptureSource =
|
|
13
|
+
'mic' | 'voiceRecognition' | 'unprocessed' | 'keep';
|
|
14
|
+
|
|
15
|
+
export interface GravixAndroidSingerOptions {
|
|
16
|
+
/** Recorder source while on (default `mic`). */
|
|
17
|
+
source?: GravixSingerCaptureSource;
|
|
18
|
+
levelNormalizer?: boolean;
|
|
19
|
+
levelTargetDbfs?: number;
|
|
20
|
+
levelMaxGainDb?: number;
|
|
21
|
+
levelRiseDbPerSec?: number;
|
|
22
|
+
levelOnWired?: boolean;
|
|
23
|
+
levelOnBluetooth?: boolean;
|
|
24
|
+
builtInMakeupDb?: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface GravixAndroidSingerResult {
|
|
28
|
+
ok: boolean;
|
|
29
|
+
/** MediaRecorder.AudioSource asked for (null = kept). */
|
|
30
|
+
sourceRequested: number | null;
|
|
31
|
+
unprocessedSupported: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function setAndroidSingerMode(
|
|
35
|
+
on: boolean,
|
|
36
|
+
o: GravixAndroidSingerOptions = {}
|
|
37
|
+
): Promise<GravixAndroidSingerResult> {
|
|
38
|
+
const { source = 'mic', ...level } = o;
|
|
39
|
+
const r =
|
|
40
|
+
asMap(
|
|
41
|
+
await requireBridge('singerMode').call('nsSetSingerMode', {
|
|
42
|
+
on,
|
|
43
|
+
source,
|
|
44
|
+
...level,
|
|
45
|
+
})
|
|
46
|
+
) ?? {};
|
|
47
|
+
return {
|
|
48
|
+
ok: r.ok === true,
|
|
49
|
+
sourceRequested:
|
|
50
|
+
typeof r.sourceRequested === 'number' ? r.sourceRequested : null,
|
|
51
|
+
unprocessedSupported: r.unprocessedSupported === true,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// Copyright (c) 2026 Gravity Compile. MIT License; see LICENSE.
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
GravixVoiceEffect,
|
|
5
|
+
GravixVoiceEffectStats,
|
|
6
|
+
} from 'gravix-rtc/noise';
|
|
7
|
+
import { asMap, requireBridge } from './nativeAudio';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Voice effects on the published microphone (Android, native gxfx): the same
|
|
11
|
+
* 35 presets + `none` as the Flutter, Android and web SDKs, in the same order.
|
|
12
|
+
* Runs after noise suppression on WebRTC's capture post-processing slot; room
|
|
13
|
+
* music is mixed after the effect while one is on.
|
|
14
|
+
*/
|
|
15
|
+
export interface GravixVoiceEffectResult {
|
|
16
|
+
ok: boolean;
|
|
17
|
+
/** ok | unknown_effect | library_missing | failed */
|
|
18
|
+
reason: string;
|
|
19
|
+
effect?: GravixVoiceEffect;
|
|
20
|
+
active?: GravixVoiceEffect;
|
|
21
|
+
/** On WebRTC's capture post-processing slot. */
|
|
22
|
+
installed?: boolean;
|
|
23
|
+
latencyMs?: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Same set and order as `GRAVIX_VOICE_EFFECTS` in `gravix-rtc/noise` and
|
|
28
|
+
* `GxVoiceFx.PRESETS` (the index is the engine's preset number). Kept here so
|
|
29
|
+
* the React Native bundle never loads the web WASM / worklet module; a test
|
|
30
|
+
* pins it to both.
|
|
31
|
+
*/
|
|
32
|
+
export const GRAVIX_ANDROID_VOICE_EFFECTS: readonly GravixVoiceEffect[] = [
|
|
33
|
+
'none',
|
|
34
|
+
'studio',
|
|
35
|
+
'hall',
|
|
36
|
+
'robot',
|
|
37
|
+
'girl',
|
|
38
|
+
'transformer',
|
|
39
|
+
'boy',
|
|
40
|
+
'child',
|
|
41
|
+
'woman',
|
|
42
|
+
'man',
|
|
43
|
+
'foreigner',
|
|
44
|
+
'ethereal',
|
|
45
|
+
'magnetic',
|
|
46
|
+
'fresh',
|
|
47
|
+
'energetic',
|
|
48
|
+
'rich',
|
|
49
|
+
'muffled',
|
|
50
|
+
'round',
|
|
51
|
+
'falsetto',
|
|
52
|
+
'full',
|
|
53
|
+
'clear',
|
|
54
|
+
'resonant',
|
|
55
|
+
'loudClear',
|
|
56
|
+
'softRoom',
|
|
57
|
+
'largeRoom',
|
|
58
|
+
'valley',
|
|
59
|
+
'basement',
|
|
60
|
+
'ktv',
|
|
61
|
+
'enhancedKtv',
|
|
62
|
+
'popular',
|
|
63
|
+
'rock',
|
|
64
|
+
'vocalConcert',
|
|
65
|
+
'gramophone',
|
|
66
|
+
'autotuneMajorC',
|
|
67
|
+
'autotuneMinorA',
|
|
68
|
+
'autotuneHarmonicMinor',
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
export function isGravixVoiceEffect(v: unknown): v is GravixVoiceEffect {
|
|
72
|
+
return (
|
|
73
|
+
typeof v === 'string' &&
|
|
74
|
+
(GRAVIX_ANDROID_VOICE_EFFECTS as readonly string[]).includes(v)
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export async function setAndroidVoiceEffect(
|
|
79
|
+
effect: GravixVoiceEffect
|
|
80
|
+
): Promise<GravixVoiceEffectResult> {
|
|
81
|
+
if (!isGravixVoiceEffect(effect))
|
|
82
|
+
return { ok: false, reason: 'unknown_effect' };
|
|
83
|
+
const r =
|
|
84
|
+
asMap(
|
|
85
|
+
await requireBridge('voiceEffects').call('fxConfigure', { effect })
|
|
86
|
+
) ?? {};
|
|
87
|
+
return {
|
|
88
|
+
ok: r.ok === true,
|
|
89
|
+
reason: typeof r.reason === 'string' ? r.reason : 'failed',
|
|
90
|
+
effect: isGravixVoiceEffect(r.effect) ? r.effect : undefined,
|
|
91
|
+
active: isGravixVoiceEffect(r.active) ? r.active : undefined,
|
|
92
|
+
installed: typeof r.installed === 'boolean' ? r.installed : undefined,
|
|
93
|
+
latencyMs: typeof r.latencyMs === 'number' ? r.latencyMs : undefined,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export async function androidVoiceEffectStats(): Promise<GravixVoiceEffectStats | null> {
|
|
98
|
+
const r = asMap(await requireBridge('voiceEffects').call('fxStats'));
|
|
99
|
+
if (!r || !isGravixVoiceEffect(r.effect)) return null;
|
|
100
|
+
return {
|
|
101
|
+
effect: r.effect,
|
|
102
|
+
active: isGravixVoiceEffect(r.active) ? r.active : r.effect,
|
|
103
|
+
rate: Number(r.rate ?? 0),
|
|
104
|
+
musicBypass: r.musicBypass === true,
|
|
105
|
+
watchdog: r.watchdog === true,
|
|
106
|
+
latencyMs: Number(r.latencyMs ?? 0),
|
|
107
|
+
frames: Number(r.frames ?? 0),
|
|
108
|
+
overBudget: Number(r.over ?? 0),
|
|
109
|
+
maxBlockUs: Number(r.maxUs ?? 0),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Runs [effect] on a private chain, off the audio path (device capability check). */
|
|
114
|
+
export async function benchmarkAndroidVoiceEffect(
|
|
115
|
+
effect: GravixVoiceEffect = 'girl',
|
|
116
|
+
rate = 48000,
|
|
117
|
+
seconds = 5
|
|
118
|
+
): Promise<Record<string, unknown> | null> {
|
|
119
|
+
return asMap(
|
|
120
|
+
await requireBridge('voiceEffects').call('fxBenchmark', {
|
|
121
|
+
effect,
|
|
122
|
+
rate,
|
|
123
|
+
seconds,
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
// Copyright 2023-2026 LiveKit, Inc.
|
|
2
|
+
// Modifications Copyright 2026 Gravity Compile.
|
|
3
|
+
// Licensed under the Apache License, Version 2.0; see LICENSES/Apache-2.0.txt.
|
|
4
|
+
|
|
5
|
+
import { Platform } from 'react-native';
|
|
6
|
+
import { nativeModuleOrNull } from '../native/module';
|
|
7
|
+
import type {
|
|
8
|
+
AppleAudioCategoryOption,
|
|
9
|
+
AppleAudioConfiguration,
|
|
10
|
+
} from './AudioSession';
|
|
11
|
+
|
|
12
|
+
/** The audio engine state an iOS session policy is chosen for. */
|
|
13
|
+
export type AudioEngineConfigurationState = {
|
|
14
|
+
isPlayoutEnabled: boolean;
|
|
15
|
+
isRecordingEnabled: boolean;
|
|
16
|
+
isVoiceProcessingEnabled: boolean;
|
|
17
|
+
preferSpeakerOutput: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** Per-engine-state AVAudioSession configuration, applied natively without a JS round trip. */
|
|
21
|
+
export type IOSAudioSessionPolicy = {
|
|
22
|
+
recording: AppleAudioConfiguration;
|
|
23
|
+
recordingWithoutVoiceProcessing?: AppleAudioConfiguration;
|
|
24
|
+
playout: AppleAudioConfiguration;
|
|
25
|
+
/** Deactivate the session when neither playout nor recording runs. Default true. */
|
|
26
|
+
deactivateOnStop?: boolean;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const playAndRecordOptions: AppleAudioCategoryOption[] = [
|
|
30
|
+
'mixWithOthers',
|
|
31
|
+
'allowBluetooth',
|
|
32
|
+
'allowBluetoothA2DP',
|
|
33
|
+
'allowAirPlay',
|
|
34
|
+
];
|
|
35
|
+
const playAndRecordSpeakerOptions: AppleAudioCategoryOption[] = [
|
|
36
|
+
...playAndRecordOptions,
|
|
37
|
+
'defaultToSpeaker',
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
/** The default iOS session for an engine state. */
|
|
41
|
+
export function getDefaultAppleAudioConfigurationForAudioState(
|
|
42
|
+
state: AudioEngineConfigurationState
|
|
43
|
+
): AppleAudioConfiguration {
|
|
44
|
+
if (state.isRecordingEnabled) {
|
|
45
|
+
const audioCategoryOptions = state.preferSpeakerOutput
|
|
46
|
+
? [...playAndRecordSpeakerOptions]
|
|
47
|
+
: [...playAndRecordOptions];
|
|
48
|
+
if (!state.isVoiceProcessingEnabled) {
|
|
49
|
+
// Without Apple voice processing the chat modes play remote audio quieter;
|
|
50
|
+
// the default mode keeps media gain.
|
|
51
|
+
return {
|
|
52
|
+
audioCategory: 'playAndRecord',
|
|
53
|
+
audioCategoryOptions,
|
|
54
|
+
audioMode: 'default',
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
audioCategory: 'playAndRecord',
|
|
59
|
+
audioCategoryOptions,
|
|
60
|
+
audioMode: state.preferSpeakerOutput ? 'videoChat' : 'voiceChat',
|
|
61
|
+
};
|
|
62
|
+
} else if (state.isPlayoutEnabled) {
|
|
63
|
+
return {
|
|
64
|
+
audioCategory: 'playback',
|
|
65
|
+
audioCategoryOptions: ['mixWithOthers'],
|
|
66
|
+
audioMode: 'spokenAudio',
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
audioCategory: 'soloAmbient',
|
|
71
|
+
audioCategoryOptions: [],
|
|
72
|
+
audioMode: 'default',
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let activeSetupToken: object | undefined;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* iOS: the AVAudioSession configuration WebRTC applies itself when its audio
|
|
80
|
+
* unit starts (react-native-webrtc 155's built-in audio device module
|
|
81
|
+
* activates and deactivates the session around playout/recording). Called by
|
|
82
|
+
* `registerGlobals()` unless `autoConfigureAudioSession: false`. Returns a
|
|
83
|
+
* cleanup function. No-op on Android.
|
|
84
|
+
*
|
|
85
|
+
* The policy's `recording` entry is the configuration applied; this WebRTC
|
|
86
|
+
* build has one session configuration for its audio unit, so
|
|
87
|
+
* `recordingWithoutVoiceProcessing`, `playout` and `deactivateOnStop` are not
|
|
88
|
+
* applied separately (kept in the type for compatibility).
|
|
89
|
+
*/
|
|
90
|
+
export function setupIOSAudioManagement(
|
|
91
|
+
preferSpeakerOutput = true,
|
|
92
|
+
policy?: IOSAudioSessionPolicy
|
|
93
|
+
): () => void {
|
|
94
|
+
if (Platform.OS !== 'ios') return () => {};
|
|
95
|
+
const token = {};
|
|
96
|
+
activeSetupToken = token;
|
|
97
|
+
const recording =
|
|
98
|
+
policy?.recording ??
|
|
99
|
+
getDefaultAppleAudioConfigurationForAudioState({
|
|
100
|
+
isPlayoutEnabled: true,
|
|
101
|
+
isRecordingEnabled: true,
|
|
102
|
+
isVoiceProcessingEnabled: true,
|
|
103
|
+
preferSpeakerOutput,
|
|
104
|
+
});
|
|
105
|
+
nativeModuleOrNull()?.setWebRTCAudioConfiguration(recording as object);
|
|
106
|
+
return () => {
|
|
107
|
+
if (activeSetupToken !== token) return;
|
|
108
|
+
activeSetupToken = undefined;
|
|
109
|
+
nativeModuleOrNull()?.setWebRTCAudioConfiguration(null);
|
|
110
|
+
};
|
|
111
|
+
}
|