I am writing a simple iOS app with Audio Units. I want to add a reverberation effect.
So the graph looks like RemoteIO_Input -> Reverb -> RemoveIO_Output.
But I am getting an error when trying to set up a stream format for the reverb unit - kAudioUnitErr_FormatNotSupported
.
That code works fine without using the reverb unit (single remote IO in graph) so other configuration seems fine and I am not providing their code.
UPD: iOS 6 is used
So questions:
Are there restrictions for the allowed formats?
What format params should I use?
Should set the format in any scope of RemoteIO output element?
Thanks for attention.
CODE: Descriptions:
desc.componentType = kAudioUnitType_Output;
desc.componentSubType = kAudioUnitSubType_RemoteIO;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
descRev.componentType = kAudioUnitType_Effect;
descRev.componentSubType = kAudioUnitSubType_Reverb2;
descRev.componentFlags = 0;
descRev.componentFlagsMask = 0;
descRev.componentManufacturer = kAudioUnitManufacturer_Apple;
Graph set up
NewAUGraph(&graph);
AUNode ioNode;
AUNode rNode;
AUGraphAddNode(graph, &desc, &ioNode);
AUGraphAddNode(graph, &descRev, &rNode);
AUGraphOpen(graph);
AUGraphConnectNodeInput(graph, ioNode, 1, rNode, 0);
AUGraphConnectNodeInput(graph, rNode, 0, ioNode, 0);
Format description and set up
// Describe format
audioFormat.mSampleRate = rate;//44100.00;
audioFormat.mFormatID = kAudioFormatLinearPCM;
audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
audioFormat.mFramesPerPacket = 1;
audioFormat.mChannelsPerFrame = 1;
audioFormat.mBitsPerChannel = 16;
audioFormat.mBytesPerPacket = 2;
audioFormat.mBytesPerFrame = 2;
OSStatus err = AudioUnitSetProperty(unit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output,
kInputBus,
&audioFormat,
sizeof(audioFormat));
if (noErr != err) {
[self showStatus:err];
}
err = AudioUnitSetProperty(unitRev,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input,
0,
&audioFormat,
sizeof(audioFormat));
if (noErr != err) {
[self showStatus:err];
}