diff options
author | Mikkel Krautz <mikkel@krautz.dk> | 2013-06-13 01:06:49 +0400 |
---|---|---|
committer | Mikkel Krautz <mikkel@krautz.dk> | 2013-06-13 01:06:49 +0400 |
commit | e0df6e1529b0db4ddf43935f74583c22a42279d1 (patch) | |
tree | 2ac08b2ab04823499d96d09e518e877ca3272f42 | |
parent | e3282ad5ea7cd58f57cfc1afc5a0f8a45d4027ac (diff) |
MKAudioInput: limit sidetone processing to 48KHz mic sampling rates.
-rw-r--r-- | src/MKAudioInput.m | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/MKAudioInput.m b/src/MKAudioInput.m index 3a24237..bfcf6ce 100644 --- a/src/MKAudioInput.m +++ b/src/MKAudioInput.m @@ -264,10 +264,20 @@ } - (void) processSidetone { - BOOL resampled = _micResampler != NULL; - NSData *data = [[NSData alloc] initWithBytes:(resampled ? psOut : psMic) length:frameSize*sizeof(short)]; - [[[MKAudio sharedAudio] sidetoneOutput] addFrame:data]; - [data release]; + // Limit sidetone processing to when we have a 48KHz mic sampling rate. + // For newer iOS versions, we're always given 48KHz, but for OS X, we can't + // be certain. So this most certainly mutes the sidetone on OS X for many audio + // devices. + // + // When resampling from the internal 48KHz sampling rate to 32KHz for Speex UWB, this + // sidetone code path will be adding non-preprocessed frames to the sidetone output. + // This is a deliberate choice for now, because it allows us to avoid resampling a + // perhaps already resampled signal. + if (micFrequency == 48000) { + NSData *data = [[NSData alloc] initWithBytes:psMic length:micLength*sizeof(short)]; + [[[MKAudio sharedAudio] sidetoneOutput] addFrame:data]; + [data release]; + } } - (void) resetPreprocessor { |