[英]How to amplify the recorded audio in iPhone?
有人可以告诉我如何放大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 . 如果您仍然必须选择录音API,我认为您可以使用Audio Queue Services 。 There's a plenty of sample code on recording with AQS and you can easily touch the samples there. 使用AQS录制时有很多示例代码,您可以轻松触摸那里的示例。
set following property to AVAudioSession. 将以下属性设置为AVAudioSession。
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,
sizeof (audioRouteOverride),&audioRouteOverride);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.