diff options
author | Mikkel Krautz <mikkel@krautz.dk> | 2013-06-12 23:50:59 +0400 |
---|---|---|
committer | Mikkel Krautz <mikkel@krautz.dk> | 2013-06-12 23:50:59 +0400 |
commit | a58a7313a46d7e869aa8c3c4daaf08d36ce0451b (patch) | |
tree | cbac53504cdae5d51e78e76a09fead50255fca6b | |
parent | 1c6b96e3ff23efc09f8260c418dfe490e41a9c95 (diff) |
MKAudioInput: correctly preprocess resampled frames.
-rw-r--r-- | src/MKAudioInput.m | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/MKAudioInput.m b/src/MKAudioInput.m index fbcdeb5..67f6e41 100644 --- a/src/MKAudioInput.m +++ b/src/MKAudioInput.m @@ -419,17 +419,17 @@ } int isSpeech = 0; + BOOL resampled = micFrequency != sampleRate; + short *frame = resampled ? psOut : psMic; if (_settings.enablePreprocessor) { - isSpeech = speex_preprocess_run(_preprocessorState, psMic); + isSpeech = speex_preprocess_run(_preprocessorState, frame); } else { - BOOL resampled = micFrequency != sampleRate; - short *buf = resampled ? psOut : psMic; int i; for (i = 0; i < frameSize; i++) { - float val = (buf[i] / 32767.0f) * (1.0f + _settings.micBoost); + float val = (frame[i] / 32767.0f) * (1.0f + _settings.micBoost); if (val > 1.0f) val = 1.0f; - buf[i] = val * 32767.0f; + frame[i] = val * 32767.0f; } } |