Skip to content

Commit

Permalink
rnnoise fix
Browse files Browse the repository at this point in the history
  • Loading branch information
martonp96 committed Aug 17, 2023
1 parent 5693da0 commit 5763375
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/CSoundInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(shortSamples[i]) / MaxShortFloatValue;
floatBuffer[i] = static_cast<float>(shortSamples[i]);
}

// Pass the floating-point samples to the RNNoise function
Expand All @@ -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<int16_t>(floatBuffer[i] * MaxShortFloatValue);
shortSamples[i] = static_cast<int16_t>(floatBuffer[i]);
}
}
}
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 5763375

Please sign in to comment.