ios - 捕获音频时,我的 AVAudioEngine 似乎无法正常工作?
问题描述
我尝试使用 AVAudioEngine 来捕获音频并对其进行实时音频处理。
这是我在 Objective-c 中测试 installTapOnBus 方法的代码:
- (void)installTap:(AVAudioInputNode *)input {
NSLog(@"Installing tap on bus 0.");
AVAudioFormat *format = [input outputFormatForBus: 0];
[input installTapOnBus:0 bufferSize:8192 format:format block:^(AVAudioPCMBuffer *buf, AVAudioTime *when) {
NSLog(@"Get one buf");
}];
}
- (void)setUpEngine {
...
engine = [AVAudioEngine new];
AVAudioInputNode *input = engine.inputNode;
if([input inputFormatForBus:0].channelCount == 0) {
NSLog(@"No enough available inputs!");
return ;
}
[engine connect:input
to:engine.mainMixerNode
format:[input inputFormatForBus:0]];
NSThread *thread = [[NSThread alloc]initWithTarget:self
selector:@selector(installTap:)
object:input];
[thread start];
[engine prepare];
[engine startAndReturnError:&error];
if(error) {
NSLog(@"Engine start error.");
}
}
我认为如果它运行良好,它会在我的控制台上打印“Get one buf”。然后我在我的 iPhone8 上进行了测试,我确定麦克风权限已授予,但我没有在控制台上看到“Get one buf”。
我应该怎么做才能解决这个问题?
解决方案
推荐阅读
- php - 我无法从codeigniter中的数据库中获取最后一个插入ID
- c++ - 为什么这个程序以“未知信号”终止?
- javascript - 我需要一个脚本,每个 ip 只重定向一次给访问者
- python - 如何使用蟒蛇使用蟒蛇?
- ios - 如何使用 ADFS 在 IOS 上实现 SSO 功能
- android - 使用 onClickListener(在自定义适配器中)时,自定义 ListView 中的单选丢失 - android
- dart - 有没有办法检测 SliverAppBar 上的向下滑动动作?
- python-3.x - NetSuite python TBA 身份验证
- node.js - 如何找出在同一函数处理程序中调用的获取和发布请求?
- express - 由于 cors 政策问题,Axios 和 Vue 不会对我的服务器进行 api 调用