I'm writing some iPhone sample code, and started with a simple pass through of the input to the output. I usually do this with an AUGraph, and my code for that works as expected:
(BTW, take it as given that I've set up the audio session for the play-and-record category and retrieved the hardwareSampleRate, though it also works to just hard code 44100).
Since I want to insert my own DSP into the arrangement, and can't write a custom unit, I decided to use the kAudioUnitProperty_MakeConnection property to connect bus 1's output scope to bus 0's input scope, effectively replacing
setupErr = AUGraphConnectNodeInput(auGraph, remoteIONode, 1, remoteIONode, 0);
with
AudioUnitConnection connection; connection.sourceAudioUnit = remoteIOUnit; connection.sourceOutputNumber = bus1; connection.destInputNumber = bus0;
setupErr = AudioUnitSetProperty(remoteIOUnit, kAudioUnitProperty_MakeConnection, kAudioUnitScope_Input, bus0, &connection, sizeof (connection));
Full listing of this setup method at:
When I do it this way, I get a weird effect on the audio, which I've captured here:
Thinking it was an SInt16 vs. 8.24-fixed-point issue, I changed my ASBD to kAudioFormatFlagsAudioUnitCanonical, but that didn't make a difference. I considered putting a converter unit in the middle, but it seems like I've already set bus 1 output and bus 0 input to the same ASBD, so it's not clear what would need to convert to what.
I also got the same effect by making the connection with a render proc that simply calls AudioUnitRender() on the I/O unit's bus 1.
Long story short: it seems like AUGraphConnectNodeInput() and setting the kAudioUnitProperty_MakeConnection ought to do the same thing, but don't. So what's the difference? And what else would I need to do in the second case to do a straight mic-to-headphone pass-through?
Thanks!
--Chris
|