From 5763375f8cb1b134f9a9a0ab86980fc30dda114a Mon Sep 17 00:00:00 2001 From: Vektor Date: Thu, 17 Aug 2023 21:02:34 +0200 Subject: [PATCH] rnnoise fix --- src/CSoundInput.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CSoundInput.cpp b/src/CSoundInput.cpp index ea915e9..5bdb9d6 100644 --- a/src/CSoundInput.cpp +++ b/src/CSoundInput.cpp @@ -225,7 +225,7 @@ void CSoundInput::NoiseSuppressionProcess(void* buffer, DWORD length) // Convert the 16-bit integer samples to floating-point samples for (int i = 0; i < FRAME_SIZE_SAMPLES; i++) { - floatBuffer[i] = static_cast(shortSamples[i]) / MaxShortFloatValue; + floatBuffer[i] = static_cast(shortSamples[i]); } // Pass the floating-point samples to the RNNoise function @@ -237,7 +237,7 @@ void CSoundInput::NoiseSuppressionProcess(void* buffer, DWORD length) // Convert the floating-point samples back to 16-bit integer samples for (int i = 0; i < FRAME_SIZE_SAMPLES; i++) { - shortSamples[i] = static_cast(floatBuffer[i] * MaxShortFloatValue); + shortSamples[i] = static_cast(floatBuffer[i]); } } } @@ -285,12 +285,12 @@ void CSoundInput::SoundFrameCaptured(HRECORD handle, const void* buffer, DWORD l // Create new buffer on stack because buffer was marked as const in API memcpy_s(writableBuffer, FRAME_SIZE_SAMPLES * sizeof(short), buffer, length); - // Apply noise suppression - NoiseSuppressionProcess(writableBuffer, FRAME_SIZE_SAMPLES); - // Apply normalization Normalize(writableBuffer, FRAME_SIZE_SAMPLES); + // Apply noise suppression + NoiseSuppressionProcess(writableBuffer, FRAME_SIZE_SAMPLES); + // Get current microphone noise level const DWORD currentMicLevel = BASS_ChannelGetLevel(handle);