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;
}