作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
应用程序在初始化 AKMicrohone 时崩溃。
- Objective-C
- AudioKit :4.8
-(void)setupFrequencyDetector{
@try {
AKSettings.audioInputEnabled = true;
//self.mic = [[AKMicrophone alloc]initWith:[[AVAudioFormat alloc]initWithCommonFormat:AVAudioPCMFormatFloat32 sampleRate:44100 channels:2 interleaved:true]];
self.mic = [[AKMicrophone alloc]initWith:[[AVAudioFormat alloc]initStandardFormatWithSampleRate:AVAudioPCMFormatFloat32 channels:2]];
self.tracker = [[AKFrequencyTracker alloc]init:self.mic hopSize:4096 peakCount:20];
self.silence = [[AKBooster alloc]init:self.tracker gain:0];
AudioKit.output = self.silence;
} @catch (NSException *exception) {
NSLog(@"Exception :%@",exception.description);
} @finally {}
}
Exception :required condition is false: format.sampleRate == hwFormat.sampleRate AudioKit+StartStop.swift:start():34:No output node has been set yet, no processing will happen.
最佳答案
通过设置音频格式和采样率解决了这个问题。
AVAudioFormat *audioFormat = [AudioKit.engine.inputNode inputFormatForBus:0];
AKSettings.sampleRate = audioFormat.sampleRate;
self.mic = [[AKMicrophone alloc]initWith:audioFormat];
更新函数:
-(void)setupFrequencyDetector{
@try {
AKSettings.audioInputEnabled = true;
AVAudioFormat *audioFormat = [AudioKit.engine.inputNode inputFormatForBus:0];
AKSettings.sampleRate = audioFormat.sampleRate;
self.mic = [[AKMicrophone alloc]initWith:audioFormat];
self.tracker = [[AKFrequencyTracker alloc]init:self.mic hopSize:4096 peakCount:20];
self.silence = [[AKBooster alloc]init:self.tracker gain:0];
AudioKit.output = self.silence;
} @catch (NSException *exception) {
NSLog(@"Exception :%@",exception.description);
} @finally {}}
关于ios - 应用程序在 [[AKMicrophone alloc]initWith :[[AVAudioFormat alloc]initStandardFormatWithSampleRate:AVAudioPCMFormatFloat32 channels:2]] 上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57669462/
我是一名优秀的程序员,十分优秀!