outputFormatForBus:0]; [inputNode installTapOnBus:0 bufferSize:1024 format:recordingFormat block:^(AVAudioPCMBuffer [inputNode installTapOnBus:0 bufferSize:1024 format:recordingFormat block:^(AVAudioPCMBuffer * _Nonnull [inputNode removeTapOnBus:0]; [inputNode installTapOnBus:0 bufferSize:1024 format:format block:^(AVAudioPCMBuffer
然后通过AVAudioFormat和音频采样帧数(等于采样率乘以时长)构建AVAudioPCMBuffer,并且通过AVAudioFile.read把音频数据解码到AVAudioPCMBuffer,获取到解码后的 AVAudioPCMBuffer包含了多个声道的数据,多个声道的数据是如何存储的那? 最后基于AVAudioPCMBuffer提供的PCM数据,针对单一声道,计算出分贝值,计算方式与Android平台类似,此处不再赘述。
. */ typedef void (^AVAudioNodeTapBlock)(AVAudioPCMBuffer *buffer, AVAudioTime *when); 我们需要把 buffer 转成 0 bufferSize:4096 format:[_engine.inputNode inputFormatForBus:AVAudioPlayerNodeBufferLoops] block:^(AVAudioPCMBuffer
property (nonatomic, readonly) AVAudioFormat *nativeAudioFormat; //拼接音频流 - (void)appendAudioPCMBuffer:(AVAudioPCMBuffer