有人可以告诉我如何放大iPhone中录制的音频,然后同时播放吗?
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.