在音频引擎输入节点上安装水龙头时出错 [英] Error when installing a tap on audio engine input node

查看:156
本文介绍了在音频引擎输入节点上安装水龙头时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只要代码到达 inputNode.installTap(onBus: 0, bufferSize: 1024, format: recordingFormat) {[weak self] (buffer:AVAudioPCMBuffer, when:AVAudioTime),应用程序崩溃,出现以下错误

whenever the code reaches inputNode.installTap(onBus: 0, bufferSize: 1024, format: recordingFormat) {[weak self] (buffer:AVAudioPCMBuffer, when:AVAudioTime), app is crashing with following error

由于未捕获的异常'com.apple.coreaudio.avfaudio'而终止应用程序,原因:'所需条件为假:format.sampleRate == hwFormat.sampleRate'

Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: format.sampleRate == hwFormat.sampleRate'

在添加另一个水龙头之前,我厌倦了移除水龙头,并且确保不会添加多个水龙头. 奇怪的是,该应用程序在小于12的iOS上运行良好,并且在所有模拟器上都运行良好.

I tired removing taps before adding another and I'm making sure I'm not adding more than one tap. what is weird is that the app is working fine with iOS less than 12, and working fine on all simulators.

它仅在具有iOS 12的真实设备上崩溃. 我尝试寻找解决方案,但找不到任何东西.

it is crashing only on real devices with iOS 12. I tried searching for a solution but could't find any thing.

推荐答案

这是采样率不匹配.

无法更改输入节点的格式,因此需要对其进行匹配. installTap侦听节点的输出,因此请使用inputNode的输出格式.

The input node's format can't be changed so you need to match it. installTap listens to the output of a node, so use inputNode's output format.

inputNode.installTap(onBus: 0, bufferSize: 1024, format: inputNode.outputFormat(forBus: 0))

另一种选择是将输入连接到混音器,然后使用首选的录制格式点击混音器.混频器在其输入和输出之间执行隐式采样率转换.

Another option is to connect the input to a mixer, then tap the mixer using the preferred recording format. Mixers perform implicit sample rate conversions between their inputs and output.

这篇关于在音频引擎输入节点上安装水龙头时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆