I'm new to Core Audio so I might not see something obvious… My aim is to process previously recorded audio signals. However, those signals should be filtered first. I don't need to play any audio. I only need to record and process it.
My graph looks like that: RemoteIO --> HighPassFilter --> callback (process audio)
And I set it up like this:
LBAudioDetectiveGetDefaultFormat(&detective->streamFormat);
// Create new AUGraph
OSStatus error = NewAUGraph(&detective->graph);
LBErrorCheck(error);
// Initialize AUNodes
AudioComponentDescription rioCD = {0};
rioCD.componentType = kAudioUnitType_Output;
rioCD.componentSubType = kAudioUnitSubType_RemoteIO;
rioCD.componentManufacturer = kAudioUnitManufacturer_Apple;
AUNode rioNode;
error = AUGraphAddNode(detective->graph, &rioCD, &rioNode);
LBErrorCheck(error);
AudioComponentDescription filterCD = {0};
filterCD.componentType = kAudioUnitType_Effect;
filterCD.componentSubType = kAudioUnitSubType_HighPassFilter;
filterCD.componentManufacturer = kAudioUnitManufacturer_Apple;
AUNode filterNode;
error = AUGraphAddNode(detective->graph, &filterCD, &filterNode);
LBErrorCheck(error);
// Open the graph so I can modify the AudioUnits
error = AUGraphOpen(detective->graph);
// Adapt rioUnit
error = AUGraphNodeInfo(detective->graph, rioNode, NULL, &detective->rioUnit);
LBErrorCheck(error);
UInt32 onFlag = 1;
AudioUnitElement bus1 = 1;
UInt32 propertySize = sizeof(UInt32);
error = AudioUnitSetProperty(detective->rioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, bus1, &onFlag, propertySize);
LBErrorCheck(error);
propertySize = sizeof(AudioStreamBasicDescription);
error = AudioUnitSetProperty(detective->rioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, bus1, &detective->streamFormat, propertySize);
LBErrorCheck(error);
// Adapt filterUnit
error = AUGraphNodeInfo(detective->graph, filterNode, NULL, &detective->filterUnit);
LBErrorCheck(error);
AURenderCallbackStruct callback = {0};
callback.inputProc = _LBAudioDetectiveFilterOutput;
callback.inputProcRefCon = detective;
propertySize = sizeof(AURenderCallbackStruct);
error = AudioUnitSetProperty(detective->filterUnit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, 0, &callback, propertySize);
LBErrorCheck(error);
// Connect the two units
AudioUnitElement bus0 = 0;
error = AUGraphConnectNodeInput(detective->graph, rioNode, bus1, filterNode, bus0);
LBErrorCheck(error);
AUGraphInitialize(detective->graph);
My code fails with the error -10879 when I try to set the callback. I'm assuming that the filter audio unit doesn't support this property. How am I supposed to get the recorded sound then? A second generic output unit isn't allowed as far as I know.
Thanks for your help in advance