From 7ddc7bbaf5ddb31f99abee418932757f74a8ccc6 Mon Sep 17 00:00:00 2001 From: Kevin Kipp Date: Fri, 6 Sep 2024 14:00:23 -0500 Subject: [PATCH] Remove noise suppression from muted track --- app/hooks/useUserMedia.ts | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/app/hooks/useUserMedia.ts b/app/hooks/useUserMedia.ts index 38348650..6813c691 100644 --- a/app/hooks/useUserMedia.ts +++ b/app/hooks/useUserMedia.ts @@ -111,33 +111,27 @@ export default function useUserMedia(mode: Mode) { ) }, [suppressNoiseEnabled$]) const mutedAudioTrack$ = useMemo(() => { - return combineLatest([ - getUserMediaTrack$('audioinput').pipe( - tap({ - next: (track) => { - track.enabled = false - }, - error: (e) => { - invariant(e instanceof Error) - setAudioUnavailableReason( - e.name in errorMessageMap - ? (e.name as UserMediaError) - : 'UnknownError' - ) - }, - }) - ), - suppressNoiseEnabled$, - ]).pipe( - switchMap(([track, suppressNoise]) => - of(suppressNoise && track ? noiseSuppression(track) : track) - ), + return getUserMediaTrack$('audioinput').pipe( + tap({ + next: (track) => { + track.enabled = false + }, + error: (e) => { + invariant(e instanceof Error) + setAudioUnavailableReason( + e.name in errorMessageMap + ? (e.name as UserMediaError) + : 'UnknownError' + ) + }, + }), shareReplay({ refCount: true, bufferSize: 1, }) ) - }, [suppressNoiseEnabled$]) + }, []) + const alwaysOnAudioStreamTrack = useSubscribedState(audioTrack$) const audioDeviceId = alwaysOnAudioStreamTrack?.getSettings().deviceId const audioEnabled$ = useStateObservable(audioEnabled)