Skip to content
Permalink
Browse files

Merge PR #3453: AudioInput: calculate audio statistics after RNNoise …

…processing
  • Loading branch information...
davidebeatrici committed Jul 8, 2018
2 parents 91f5e1c + ec11400 commit 1781697159e0bf408db5e0f605a73a37030d1f2e
Showing with 18 additions and 17 deletions.
  1. +18 −17 src/mumble/AudioInput.cpp
@@ -165,8 +165,9 @@ AudioInput::~AudioInput() {
#endif

#ifdef USE_RNNOISE
if (denoiseState)
if (denoiseState) {
rnnoise_destroy(denoiseState);
}
#endif

if (ceEncoder) {
@@ -811,6 +812,22 @@ void AudioInput::encodeAudioFrame() {
QMutexLocker l(&qmSpeex);
resetAudioProcessor();

#ifdef USE_RNNOISE
// At the time of writing this code, RNNoise only supports a sample rate of 48000 Hz.
if (g.s.bDenoise && denoiseState && (iFrameSize == 480)) {
float denoiseFrames[480];
for (int i = 0; i < 480; i++) {
denoiseFrames[i] = psMic[i];
}

rnnoise_process_frame(denoiseState, denoiseFrames, denoiseFrames);

for (int i = 0; i < 480; i++) {
psMic[i] = denoiseFrames[i];
}
}
#endif

speex_preprocess_ctl(sppPreprocess, SPEEX_PREPROCESS_GET_AGC_GAIN, &iArg);
float gainValue = static_cast<float>(iArg);
iArg = g.s.iNoiseSuppress - iArg;
@@ -825,22 +842,6 @@ void AudioInput::encodeAudioFrame() {
psSource = psMic;
}

#ifdef USE_RNNOISE
// At the time of writing this code, RNNoise only supports a sample rate of 48000 Hz.
if (g.s.bDenoise && (iFrameSize == 480)) {
float denoiseFrames[480];
for (int i = 0; i < 480; i++) {
denoiseFrames[i] = psSource[i];
}

rnnoise_process_frame(denoiseState, denoiseFrames, denoiseFrames);

for (int i = 0; i < 480; i++) {
psSource[i] = denoiseFrames[i];
}
}
#endif

sum=1.0f;
for (i=0;i<iFrameSize;i++)
sum += static_cast<float>(psSource[i] * psSource[i]);

0 comments on commit 1781697

Please sign in to comment.
You can’t perform that action at this time.