开发者

How to amplify the recorded audio in iPhone?

开发者 https://www.devze.com 2023-01-24 07:12 出处:网络
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 a

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消