Can someone tell me how I can amplify the recorded audio in iPhone and then play it simultaneous开发者_如何学JAVAly?
What format do you have the audio in? Usually you can simply loop over the samples and multiply them:
static const float gain = 2;
for (NSUInteger i=0; i<kNumberOfSamplesInBuffer; i++)
buffer[i] *= gain;
And you probably have to take arithmetic overflow into account, making sure the multiplied values don’t exceed the type range:
amplified = MIN(MAX_TYPE_VALUE, MAX(MIN_TYPE_VALUE, sample*gain));
If you still yet have to pick a recording API, I think you can use Audio Queue Services. There’s a plenty of sample code on recording with AQS and you can easily touch the samples there.
set following property to AVAudioSession.
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,
sizeof (audioRouteOverride),&audioRouteOverride);
精彩评论