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,362 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026 Gravity Compile. MIT License; see LICENSE.
|
|
2
|
+
|
|
3
|
+
#if os(iOS)
|
|
4
|
+
import AVFoundation
|
|
5
|
+
import Foundation
|
|
6
|
+
@_implementationOnly import gxns
|
|
7
|
+
|
|
8
|
+
/// Room music mixed AFTER noise suppression and the voice effect (gravix_rtc
|
|
9
|
+
/// 0.12.0, the default; `postMix: false` keeps the 0.11 input-mixer path).
|
|
10
|
+
///
|
|
11
|
+
/// The 0.11 path played the music into WebRTC's input mixer, before the APM,
|
|
12
|
+
/// so the voice effect had to be bypassed while a song played (a reverb or a
|
|
13
|
+
/// pitch change would have hit the song too) and mic volume / ducking could
|
|
14
|
+
/// not be done. Here, as on Android's POST route:
|
|
15
|
+
///
|
|
16
|
+
/// - a feeder (`queue`) decodes the file with AVAudioFile + AVAudioConverter
|
|
17
|
+
/// to mono float at the capture rate and fills the `gx_music_post` ring;
|
|
18
|
+
/// - `process` (GxAudioDevice capture thread, from GxNoiseProcessor after GxVoiceFx)
|
|
19
|
+
/// adds the music to the processed voice: mic gain, ducking, a delay line
|
|
20
|
+
/// of the NS + effect latency so voice and music stay aligned, fades;
|
|
21
|
+
/// - the host's monitor is mixed by GxAudioDevice into the playout block
|
|
22
|
+
/// (`monitorRead`), reading the same ring (one decoder, no drift), not ducked;
|
|
23
|
+
/// - position = frames the capture thread consumed (what listeners hear),
|
|
24
|
+
/// with the consume time for `positionAgeUs`.
|
|
25
|
+
@available(iOS 13.0, *)
|
|
26
|
+
final class GxMusicPost {
|
|
27
|
+
static let shared = GxMusicPost()
|
|
28
|
+
|
|
29
|
+
/// The C core (2 s at 48 kHz; delays up to 8192 frames).
|
|
30
|
+
let core: OpaquePointer = gxmp_new(96000, 8192)!
|
|
31
|
+
/// The capture rate the last `process` call saw (0 = none yet).
|
|
32
|
+
private let captureRate: OpaquePointer = gxns_flag_new(0)!
|
|
33
|
+
private let queue = DispatchQueue(label: "gravix.music.post", qos: .userInitiated)
|
|
34
|
+
|
|
35
|
+
// ---- session (queue only) ----
|
|
36
|
+
private var file: AVAudioFile?
|
|
37
|
+
private var converter: AVAudioConverter?
|
|
38
|
+
private var outFormat: AVAudioFormat?
|
|
39
|
+
private var inBuffer: AVAudioPCMBuffer?
|
|
40
|
+
private var outBuffer: AVAudioPCMBuffer?
|
|
41
|
+
private var convRate = 0
|
|
42
|
+
/// File frame at the last flush; position = base + consumed (file rate).
|
|
43
|
+
private var baseFrame: AVAudioFramePosition = 0
|
|
44
|
+
private var loop = false
|
|
45
|
+
private var paused = false
|
|
46
|
+
private var eofSet = false
|
|
47
|
+
private var completedFired = false
|
|
48
|
+
private var timer: DispatchSourceTimer?
|
|
49
|
+
private var ticks = 0
|
|
50
|
+
private var generation = 0
|
|
51
|
+
/// Host monitor wanted for this song (read by the output IO thread).
|
|
52
|
+
private let monitorOn: OpaquePointer = gxns_flag_new(0)!
|
|
53
|
+
var monitorWanted: Bool { gxns_flag_get(monitorOn) != 0 }
|
|
54
|
+
|
|
55
|
+
/// Main-thread callbacks set by GravixMusicMixer.
|
|
56
|
+
var onCompleted: (() -> Void)?
|
|
57
|
+
|
|
58
|
+
private static let outChunk: AVAudioFrameCount = 1024
|
|
59
|
+
private static let int16Scale: Float = 32768
|
|
60
|
+
|
|
61
|
+
private init() {}
|
|
62
|
+
|
|
63
|
+
// MARK: - Capture thread
|
|
64
|
+
|
|
65
|
+
/// Capture block from GxAudioDevice, after the voice effect. Never
|
|
66
|
+
/// allocates or locks (gxmp_process is lock-free).
|
|
67
|
+
func process(_ samples: UnsafeMutablePointer<Float>, frames: Int, rate: Int32) {
|
|
68
|
+
guard frames > 0, rate > 0 else { return }
|
|
69
|
+
if gxns_flag_get(captureRate) != rate { gxns_flag_set(captureRate, rate) }
|
|
70
|
+
guard gxmp_active(core) != 0 else { return } // no session: the voice passes untouched
|
|
71
|
+
gxmp_process(core, samples, Int32(frames), rate)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/// The host's monitor, mixed by GxAudioDevice into the playout block
|
|
75
|
+
/// (int16-scale floats, `n` frames at the capture rate). Returns false
|
|
76
|
+
/// (dst untouched) when no song with monitor runs. Output IO thread.
|
|
77
|
+
func monitorRead(_ dst: UnsafeMutablePointer<Float>, frames n: Int) -> Bool {
|
|
78
|
+
guard gxns_flag_get(monitorOn) != 0, gxmp_active(core) != 0, n > 0 else { return false }
|
|
79
|
+
gxmp_monitor_read(core, dst, Int32(n))
|
|
80
|
+
return true
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// MARK: - Control (any thread)
|
|
84
|
+
|
|
85
|
+
var isActive: Bool { queue.sync { file != nil } }
|
|
86
|
+
var rate: Int { Int(gxns_flag_get(captureRate)) }
|
|
87
|
+
|
|
88
|
+
/// Opens [url] and starts mixing. Throws when the file is unreadable.
|
|
89
|
+
func start(url: URL, musicGain: Float, micGain: Float, ducking: Bool, duckLevel: Float, monitor: Bool, loop: Bool) throws -> Int {
|
|
90
|
+
let f = try AVAudioFile(forReading: url)
|
|
91
|
+
guard f.processingFormat.sampleRate > 0, f.processingFormat.channelCount > 0, f.length > 0 else {
|
|
92
|
+
throw NSError(domain: "GxMusicPost", code: 1, userInfo: [NSLocalizedDescriptionKey: "unsupported or empty audio file"])
|
|
93
|
+
}
|
|
94
|
+
return queue.sync {
|
|
95
|
+
stopLocked(fade: false)
|
|
96
|
+
generation += 1
|
|
97
|
+
file = f
|
|
98
|
+
self.loop = loop
|
|
99
|
+
paused = false
|
|
100
|
+
eofSet = false
|
|
101
|
+
completedFired = false
|
|
102
|
+
baseFrame = 0
|
|
103
|
+
convRate = 0
|
|
104
|
+
converter = nil
|
|
105
|
+
gxns_flag_set(monitorOn, monitor ? 1 : 0)
|
|
106
|
+
gxmp_set_music_gain(core, musicGain)
|
|
107
|
+
gxmp_set_mic_gain(core, micGain)
|
|
108
|
+
gxmp_set_ducking(core, ducking ? 1 : 0, duckLevel)
|
|
109
|
+
gxmp_flush(core)
|
|
110
|
+
gxmp_set_running(core, 1)
|
|
111
|
+
gxmp_set_active(core, 1)
|
|
112
|
+
refreshDelayLocked()
|
|
113
|
+
startTimerLocked()
|
|
114
|
+
fillLocked()
|
|
115
|
+
NSLog("[GravixMusic] step=post_start rate=\(rate) loop=\(loop) monitor=\(monitor) file=\(Int(f.processingFormat.sampleRate))Hz/\(f.processingFormat.channelCount)ch")
|
|
116
|
+
return Int(Double(f.length) / f.processingFormat.sampleRate * 1000)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
func stop() { queue.sync { stopLocked(fade: true) } }
|
|
121
|
+
|
|
122
|
+
func pause() {
|
|
123
|
+
queue.sync {
|
|
124
|
+
guard file != nil, !paused else { return }
|
|
125
|
+
paused = true
|
|
126
|
+
gxmp_set_running(core, 0)
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
func resume() {
|
|
131
|
+
queue.sync {
|
|
132
|
+
guard file != nil, paused else { return }
|
|
133
|
+
paused = false
|
|
134
|
+
gxmp_set_running(core, 1)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
func setLoop(_ on: Bool) { queue.sync { loop = on } }
|
|
139
|
+
func setMusicGain(_ g: Float) { gxmp_set_music_gain(core, g) }
|
|
140
|
+
func setMicGain(_ g: Float) { gxmp_set_mic_gain(core, g) }
|
|
141
|
+
func setDucking(_ on: Bool, level: Float) { gxmp_set_ducking(core, on ? 1 : 0, level) }
|
|
142
|
+
|
|
143
|
+
func seek(toMs ms: Int) {
|
|
144
|
+
queue.sync {
|
|
145
|
+
guard let file else { return }
|
|
146
|
+
let target = min(AVAudioFramePosition(Double(max(ms, 0)) / 1000 * file.processingFormat.sampleRate),
|
|
147
|
+
max(file.length - 1, 0))
|
|
148
|
+
reseekLocked(to: target)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
func state() -> [String: Any] {
|
|
153
|
+
queue.sync {
|
|
154
|
+
let r = rate
|
|
155
|
+
guard let file else {
|
|
156
|
+
return ["active": false, "paused": false, "positionMs": 0, "durationMs": -1,
|
|
157
|
+
"captureReady": r > 0, "captureLive": r > 0, "installed": true, "mixRoute": "post"]
|
|
158
|
+
}
|
|
159
|
+
let fileRate = file.processingFormat.sampleRate
|
|
160
|
+
return [
|
|
161
|
+
"active": true,
|
|
162
|
+
"paused": paused,
|
|
163
|
+
"positionMs": Int(Double(positionFramesLocked()) / fileRate * 1000),
|
|
164
|
+
"positionAgeUs": positionAgeUsLocked(),
|
|
165
|
+
"durationMs": Int(Double(file.length) / fileRate * 1000),
|
|
166
|
+
"captureReady": r > 0,
|
|
167
|
+
"captureLive": r > 0,
|
|
168
|
+
"installed": true,
|
|
169
|
+
"mixRoute": "post",
|
|
170
|
+
"delayFrames": Int(lastDelay),
|
|
171
|
+
"duck": Double(gxmp_duck(core)),
|
|
172
|
+
"voiceRms": Double(gxmp_last_voice_rms(core)),
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// MARK: - Feeder (queue)
|
|
178
|
+
|
|
179
|
+
private var lastDelay: Int32 = 0
|
|
180
|
+
|
|
181
|
+
private func startTimerLocked() {
|
|
182
|
+
timer?.cancel()
|
|
183
|
+
let t = DispatchSource.makeTimerSource(queue: queue)
|
|
184
|
+
t.schedule(deadline: .now() + .milliseconds(20), repeating: .milliseconds(20))
|
|
185
|
+
let gen = generation
|
|
186
|
+
t.setEventHandler { [weak self] in
|
|
187
|
+
guard let self, self.generation == gen else { return }
|
|
188
|
+
self.tickLocked()
|
|
189
|
+
}
|
|
190
|
+
timer = t
|
|
191
|
+
t.resume()
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
private func tickLocked() {
|
|
195
|
+
guard file != nil else { return }
|
|
196
|
+
ticks += 1
|
|
197
|
+
if ticks % 25 == 0 { refreshDelayLocked() } // every 500 ms, as Android
|
|
198
|
+
if gxmp_drained(core) != 0, !completedFired {
|
|
199
|
+
completedFired = true
|
|
200
|
+
NSLog("[GravixMusic] step=post_completed")
|
|
201
|
+
stopLocked(fade: false)
|
|
202
|
+
let cb = onCompleted
|
|
203
|
+
DispatchQueue.main.async { cb?() }
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
fillLocked()
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/// Converter at the capture rate; a rate change mid-song (Bluetooth HFP,
|
|
210
|
+
/// a route change) re-seeks to the current position at the new rate.
|
|
211
|
+
private func ensureConverterLocked(rate r: Int) -> Bool {
|
|
212
|
+
guard let file, r > 0 else { return false }
|
|
213
|
+
if converter != nil, convRate == r { return true }
|
|
214
|
+
let wasRunning = convRate != 0
|
|
215
|
+
guard let out = AVAudioFormat(commonFormat: .pcmFormatFloat32, sampleRate: Double(r), channels: 1, interleaved: false),
|
|
216
|
+
let conv = AVAudioConverter(from: file.processingFormat, to: out),
|
|
217
|
+
let inBuf = AVAudioPCMBuffer(pcmFormat: file.processingFormat, frameCapacity: 4096),
|
|
218
|
+
let outBuf = AVAudioPCMBuffer(pcmFormat: out, frameCapacity: Self.outChunk)
|
|
219
|
+
else { return false }
|
|
220
|
+
conv.downmix = true
|
|
221
|
+
let resumeAt = wasRunning ? positionFramesLocked() : baseFrame
|
|
222
|
+
converter = conv
|
|
223
|
+
outFormat = out
|
|
224
|
+
inBuffer = inBuf
|
|
225
|
+
outBuffer = outBuf
|
|
226
|
+
convRate = r
|
|
227
|
+
if wasRunning {
|
|
228
|
+
NSLog("[GravixMusic] step=post_rate_change rate=\(r)")
|
|
229
|
+
reseekLocked(to: resumeAt)
|
|
230
|
+
} else {
|
|
231
|
+
file.framePosition = baseFrame
|
|
232
|
+
}
|
|
233
|
+
return true
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
private func fillLocked() {
|
|
237
|
+
guard let file, !eofSet else { return }
|
|
238
|
+
let r = rate
|
|
239
|
+
guard ensureConverterLocked(rate: r), let converter, let inBuffer, let outBuffer else { return }
|
|
240
|
+
var guardIterations = 0
|
|
241
|
+
while gxmp_space(core) >= Int32(Self.outChunk), guardIterations < 64 {
|
|
242
|
+
guardIterations += 1
|
|
243
|
+
outBuffer.frameLength = 0
|
|
244
|
+
var hitEnd = false
|
|
245
|
+
var error: NSError?
|
|
246
|
+
let status = converter.convert(to: outBuffer, error: &error) { [weak self] _, outStatus in
|
|
247
|
+
guard let self else { outStatus.pointee = .endOfStream; return nil }
|
|
248
|
+
if file.framePosition >= file.length {
|
|
249
|
+
if self.loop {
|
|
250
|
+
file.framePosition = 0
|
|
251
|
+
} else {
|
|
252
|
+
hitEnd = true
|
|
253
|
+
outStatus.pointee = .endOfStream
|
|
254
|
+
return nil
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
inBuffer.frameLength = 0
|
|
258
|
+
do { try file.read(into: inBuffer, frameCount: inBuffer.frameCapacity) } catch {
|
|
259
|
+
hitEnd = true
|
|
260
|
+
outStatus.pointee = .endOfStream
|
|
261
|
+
return nil
|
|
262
|
+
}
|
|
263
|
+
if inBuffer.frameLength == 0 { hitEnd = true; outStatus.pointee = .endOfStream; return nil }
|
|
264
|
+
outStatus.pointee = .haveData
|
|
265
|
+
return inBuffer
|
|
266
|
+
}
|
|
267
|
+
if status == .error {
|
|
268
|
+
NSLog("[GravixMusic] step=post_decode_error \(error?.localizedDescription ?? "")")
|
|
269
|
+
hitEnd = true
|
|
270
|
+
}
|
|
271
|
+
let n = Int(outBuffer.frameLength)
|
|
272
|
+
if n > 0, let p = outBuffer.floatChannelData?[0] {
|
|
273
|
+
for i in 0 ..< n { p[i] *= Self.int16Scale }
|
|
274
|
+
_ = gxmp_write(core, p, Int32(n))
|
|
275
|
+
}
|
|
276
|
+
if hitEnd || status == .endOfStream {
|
|
277
|
+
gxmp_set_eof(core, 1)
|
|
278
|
+
eofSet = true
|
|
279
|
+
return
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
private func reseekLocked(to frame: AVAudioFramePosition) {
|
|
285
|
+
guard let file else { return }
|
|
286
|
+
file.framePosition = frame
|
|
287
|
+
converter?.reset()
|
|
288
|
+
baseFrame = frame
|
|
289
|
+
eofSet = false
|
|
290
|
+
completedFired = false
|
|
291
|
+
gxmp_flush(core)
|
|
292
|
+
fillLocked()
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
private func positionFramesLocked() -> AVAudioFramePosition {
|
|
296
|
+
guard let file else { return 0 }
|
|
297
|
+
let r = rate
|
|
298
|
+
let consumed = gxmp_consumed(core)
|
|
299
|
+
var pos = baseFrame
|
|
300
|
+
if r > 0, consumed > 0 {
|
|
301
|
+
pos += AVAudioFramePosition(Double(consumed) * file.processingFormat.sampleRate / Double(r))
|
|
302
|
+
}
|
|
303
|
+
// the decoder's delay line: what went out is `lastDelay` frames behind
|
|
304
|
+
if r > 0, lastDelay > 0 {
|
|
305
|
+
pos -= AVAudioFramePosition(Double(lastDelay) * file.processingFormat.sampleRate / Double(r))
|
|
306
|
+
if pos < baseFrame { pos = baseFrame }
|
|
307
|
+
}
|
|
308
|
+
if file.length > 0 { pos = loop ? pos % file.length : min(pos, file.length) }
|
|
309
|
+
return pos
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
private func positionAgeUsLocked() -> Int {
|
|
313
|
+
if paused { return 0 }
|
|
314
|
+
let last = gxmp_last_consume_ns(core)
|
|
315
|
+
guard last > 0 else { return 0 }
|
|
316
|
+
let now = gxmp_now_ns()
|
|
317
|
+
guard now > last else { return 0 }
|
|
318
|
+
return min(1_000_000, Int((now - last) / 1000))
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/// The voice's NS + effect delay at the capture rate (status readbacks;
|
|
322
|
+
/// never on the audio thread).
|
|
323
|
+
private func refreshDelayLocked() {
|
|
324
|
+
let r = rate
|
|
325
|
+
guard r > 0 else { return }
|
|
326
|
+
var frames = GxVoiceFx.shared.latencyMs() * r / 1000
|
|
327
|
+
frames += GxNoiseProcessor.shared.latencySamples(atRate: r)
|
|
328
|
+
let d = Int32(min(max(frames, 0), 8192))
|
|
329
|
+
if d != lastDelay {
|
|
330
|
+
lastDelay = d
|
|
331
|
+
gxmp_set_delay(core, d)
|
|
332
|
+
NSLog("[GravixMusic] step=post_delay frames=\(d) rate=\(r)")
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
private func stopLocked(fade: Bool) {
|
|
337
|
+
timer?.cancel()
|
|
338
|
+
timer = nil
|
|
339
|
+
guard file != nil else { return }
|
|
340
|
+
file = nil
|
|
341
|
+
converter = nil
|
|
342
|
+
inBuffer = nil
|
|
343
|
+
outBuffer = nil
|
|
344
|
+
convRate = 0
|
|
345
|
+
gxns_flag_set(monitorOn, 0)
|
|
346
|
+
generation += 1
|
|
347
|
+
if fade {
|
|
348
|
+
// 20 ms fade-out, then off (a new start in between wins)
|
|
349
|
+
gxmp_set_running(core, 0)
|
|
350
|
+
let gen = generation
|
|
351
|
+
queue.asyncAfter(deadline: .now() + .milliseconds(60)) { [weak self] in
|
|
352
|
+
guard let self, self.generation == gen, self.file == nil else { return }
|
|
353
|
+
gxmp_set_active(self.core, 0)
|
|
354
|
+
gxmp_flush(self.core)
|
|
355
|
+
}
|
|
356
|
+
} else {
|
|
357
|
+
gxmp_set_active(core, 0)
|
|
358
|
+
gxmp_flush(core)
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
#endif
|