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;
}
user7388
  • 1,741
  • 2
  • 19
  • 25
aerlfredith
  • 1,123
  • 4
  • 12
  • 18
  • There could be so many things that can go wrong here. The error code in `result` should give you a clue.. – maroux May 21 '13 at 07:47
  • -10868, I dont really know where I can reliably find these codes or what they mean, when the NSLog prints is just says "The operation could not be completed" if there is more info to be found please share how I can find that info. The code I cant even find online. – aerlfredith May 21 '13 at 08:05
  • 1
    That's kAudioUnitErr_FormatNotSupported. I see there are some questions on this - check them out. – maroux May 21 '13 at 08:31
  • -10868 == kAudioUnitErr_FormatNotSupported. Cool but where do you finds these codes? Or did you just happen to know this specific one? Thanks – aerlfredith May 21 '13 at 08:37
  • 1
    there are several undocumented error codes, but most should be available in the docs: http://developer.apple.com/library/ios/#documentation/AudioUnit/Reference/AUComponentServicesReference/Reference/reference.html – maroux May 21 '13 at 08:41

1 Answers1

-2

This isn't really a direct answer to your question, but you should really use Novocaine. Setting up AudioUnits by hand in iOS is only an exercise in frustration, and you shouldn't directly do this any more unless you are doing very special things with the AU graph. For something as simple as applying a lopass filter to a given signal, this framework is really much more reliable.

Nik Reiman
  • 39,067
  • 29
  • 104
  • 160