Re: Assigning a callback and enabling playthru on remoteIO node
Re: Assigning a callback and enabling playthru on remoteIO node
- Subject: Re: Assigning a callback and enabling playthru on remoteIO node
- From: William Stewart <email@hidden>
- Date: Wed, 3 Feb 2010 18:52:24 -0800
An even more efficient way for playing silence is to just return an
error from the render callback (you don't have to memset the buffers
then). By just returning silence like this a whole range of processing
(particularly sample rate conversion) can be getting done on your
zeroes...
However, if you DO memset the buffers, you should also set the
ioRenderActionFlags with the audio is silent bit set. That way some
AUs that look at this would know they can ignore your buffer
Bill
On Jan 31, 2010, at 10:26 PM, Alex Wiltschko wrote:
Answering my own question, I've figured it out;
I've opted out of using AUGraphs, and instead have a single remoteIO
audio unit.
The trick is to attach your callback to the output bus and output
scope, where the audio would normally be sent to the mic.
OSStatus err = AudioUnitSetProperty(outputAudioUnit,
kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Output,
0,
&playbackCallbackStruct,
sizeof(playbackCallbackStruct));
Within your callback, render audio on Bus 1
AudioUnitRender(outputAudioUnit, ioActionFlags, inTimeStamp, 1,
inNumberFrames, ioData);
If you want to play audio through, you don't have to do anything.
The audio rendered into ioData will be played through the mic.
But, if you want to silence the playthru, just zero-out the buffers
in ioData:
if (!playThroughEnabled) {
for (int i=0; i < ioData->mNumberBuffers; ++i) {
memset(ioData->mBuffers[i].mData, 0, ioData->mBuffers
[i].mDataByteSize);
}
}
Alex
On Jan 29, 2010, at 2:17 AM, Alex Wiltschko wrote:
Hello,
I'd like to both collect incoming audio data from a remoteIO node
as well as play that audio through to the speaker.
The use case is plugging in an audio source into the headphone
jack, and then using the iPhone as both a speaker and a visualizer.
In an AUGraph, it is very easy to enable playthru:
err = AUGraphConnectNodeInput(graph, ioNode, 1, ioNode, 0);
NSAssert(err == noErr, @"Connecting the input of RemoteIO node to
its output failed");
However, if this connection is enabled, I'm unable to assign a
callback to the ioNode
err = AUGraphSetNodeInputCallback (graph,
ioNode,
0,
&playbackCallbackStruct);
results in error -10861.
I assume this means that AUGraphConnectNodeInput has created a
callback and is passing audio directly from bus 1 to bus 0, and a
user-defined callback would interfere with this connection.
Given that there is no splitter unit on the iPhone, will I have to
implement my own renderCallback and feed audio manually into the
remoteIO bus 0?
Thanks,
Alex
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden