Luc*_*sen 5 c audio core-audio audiounit ios
所以我试图找出苹果在 iOS 5 中添加的不良记录的 NBandEQ。我能够让它在 16 频段以下的任何东西上都能很好地工作,但我想要更多:) 如果我把它变成一个 15 频段的均衡器会发生什么一切正常,但如果我选择 16 及以上的任何数字kAudioUnitErr_InvalidPropertyValue,我在设置时会收到 -10851 ( ) 错误,kAUNBandEQProperty_NumberOfBands然后前 8 个频段设置良好,其余部分会导致 -10878 ( kAudioUnitErr_InvalidParameter) 错误。所以可以成功完成 15 个乐队,但是当我突然达到 16 个时,只能完成 8 个。有kAUNBandEQProperty_MaxNumberOfBands我可以读到我认为这是当前状态下的设备可以处理的限制。好吧,它会吐出从 12 位数字到 4 位数字的所有不稳定数字。我想我自己是不是不喜欢我给它的极端频率。我排除了这种可能性。然后我意识到频段的带宽可能重叠,它不喜欢那样。所以我将带宽从默认的 0.5 减少到最小。.05 没有帮助有以太。
我确实意识到,在我弄乱了所有愚蠢的设置之后,因为它在我什至没有进入这些设置之前就开始抱怨。它已经给出了频带数量的错误。
我发布这个问题是为了看看是否有更多有经验的程序员可以在我的代码中看到一些让我感到困惑的东西并向我指出。我意识到没有多少人涉足核心音频,更不用说 NBandEQ,但也许我搞砸了一些基本的 C,所以请看一看。我会很感激的。我显然很沮丧。同样在发布此代码时(即使它是丑陋的测试代码),也许我可以帮助落后的其他人。我知道我希望至少有一段代码可以让我看看与 NBandEQ 相关的内容
在此先感谢您的帮助!
//Getting max bands for this device???
UInt32 maxNumOfBands;
UInt32 propSize = sizeof(maxNumOfBands);
AudioUnitGetProperty([_equilizer audioUnit],
kAUNBandEQProperty_MaxNumberOfBands,
kAudioUnitScope_Output,
0,
&maxNumOfBands,
&propSize);
NSLog(@"THIS IS THE MAX NUMBER OF BANDS?---%u",(unsigned int)maxNumOfBands);
UInt32 noBands = [eqFrequencies count];
// Set the number of bands first
NSLog(@"NumberOfBands atempted:%i with result:%ld", (unsigned int)noBands, AudioUnitSetProperty(_equilizer.audioUnit,
kAUNBandEQProperty_NumberOfBands,
kAudioUnitScope_Global,
0,
&noBands,
sizeof(noBands)));
// Set the frequencies
for (NSUInteger i=0; i<noBands; i++) {
NSLog(@"Set Frequency for band:%i with result:%ld", i, AudioUnitSetParameter([_equilizer audioUnit],
kAUNBandEQParam_Frequency+i,
kAudioUnitScope_Global,
0,
(AudioUnitParameterValue)[[eqFrequencies objectAtIndex:i] floatValue],
0));
}
//set bandwidth
for (NSUInteger i=0; i<noBands; i++) {
NSLog(@"Set bandwidth for band:%i with result:%ld", i, AudioUnitSetParameter([_equilizer audioUnit],
kAUNBandEQParam_Bandwidth+i,
kAudioUnitScope_Global,
0,
0.05,//of octive
0));
}
// Set the bypass to off "0"
for (NSUInteger i=0; i<noBands; i++) {
NSLog(@"Set Bypass for band:%i with result:%ld", i, AudioUnitSetParameter([_equilizer audioUnit],
kAUNBandEQParam_BypassBand+i,
kAudioUnitScope_Global,
0,
0,//off
0));
}
Run Code Online (Sandbox Code Playgroud)
}
好吧,我想通了。我用过kAudioUnitScope_Output就kAUNBandEQProperty_MaxNumberOfBands应该可以kAudioUnitScope_Global。
kAUNBandEQProperty_MaxNumberOfBands Sim、iPhone 5 和 Retina Ipad 上的结果为 16。