2

I am trying to implement a low pass filter in core audio on IOS but when I use the code below an error is generated stating "The operation could not be completed", which is very undescriptive of the problem. And I can see what about this operation would be illegal.

Can anyone help me with this? Or refer me to a place with decent documentation about core audio because apples documentation is very unhelpful indeed.

result = AUGraphNodeInfo(processingGraph, lowpassNode, NULL, &lowpassUnit);
if(result != noErr)
{
    [self printErrorMessage: @"AUGraphNodeInfo" withStatus: result];
    return;
}

int byteSize = sizeof(AudioUnitSampleType);
AudioStreamBasicDescription streamFormat;
streamFormat.mFormatID          = kAudioFormatLinearPCM;
streamFormat.mFormatFlags       = kAudioFormatFlagsAudioUnitCanonical;
streamFormat.mBytesPerPacket    = byteSize;
streamFormat.mFramesPerPacket   = 1;
streamFormat.mBytesPerFrame     = byteSize;
streamFormat.mChannelsPerFrame  = 1;
streamFormat.mBitsPerChannel    = 8 * byteSize;
streamFormat.mSampleRate        = graphSampleRate;

NSLog (@"Setting stream format for lowpass unit input bus");
result = AudioUnitSetProperty(lowpassUnit,
                              kAudioUnitProperty_StreamFormat,
                              kAudioUnitScope_Input,
                              0,
                              &streamFormat,
                              sizeof (AudioStreamBasicDescription));
if (noErr != result)
{
    NSLog(@"%@", [NSError errorWithDomain:NSOSStatusErrorDomain code:result userInfo:nil]);
    return;
}
4

1 回答 1

-2

这并不是您问题的直接答案,但您应该真正使用Novocaine。在 iOS 中手动设置 AudioUnits 只是一种挫败感,除非你对 AU 图表做非常特殊的事情,否则你不应该再直接这样做了。对于像对给定信号应用低通滤波器这样简单的事情,这个框架确实更可靠。

于 2013-11-06T14:32:14.797 回答