private static void AudioManager_InputRecieved(object sender, float[] e) { double decibels = 0f; foreach (var sample in e) { decibels += Math.Abs(sample); } decibels = 20 * Math.Log10(decibels / e.Length); if (decibels < Storage.Settings.NoiseSensitivity) { if (hasSentSpeeking && !stopSpeaking) { StopSpeaking(); } } else { if (!noiseMuted) { stopSpeaking = false; if (!hasSentSpeeking) { VoiceConnection.SendSpeaking(true); hasSentSpeeking = true; } VoiceConnection.SendVoiceData(e); } } }
private static async void StopSpeaking() { stopSpeaking = true; if (!noiseMuted) { await Task.Delay(2000); } lock (syncLock) { if (stopSpeaking) { VoiceConnection.SendSpeaking(false); hasSentSpeeking = false; stopSpeaking = false; } } }