Skip to content

Commit

Permalink
MKAudioInput: correctly preprocess resampled frames.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrautz committed Jun 12, 2013
1 parent 1c6b96e commit a58a731
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/MKAudioInput.m
Expand Up @@ -419,17 +419,17 @@ - (void) processAndEncodeAudioFrame {
}

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;
}
}

Expand Down

0 comments on commit a58a731

Please sign in to comment.