Callbacks in an AUGraph induced state
Callbacks in an AUGraph induced state
- Subject: Callbacks in an AUGraph induced state
- From: Chilton Webb <email@hidden>
- Date: Sun, 28 Nov 2004 20:19:34 -0600
Hi,
This will probably be an easy one to figure out if you have used
AUGraphs before.
I have an AU based engine that uses AUHAL to read into a buffer, which
is then later retrieved by a filter effect, processed, and sent out the
output AUHAL. It works well enough, but I get horrible noise if I stop
it in-program and restart it (which I have to do fairly often,
unfortunately). So I'm trying these AU Graph things all the kids are
raving about. But my attempts thus far have been unsuccessful. The new
code is below, and is pretty simple.
The second function is from my (working) current code. I'd like to move
to AUGraphs though, so I'm replacing my normal filter effect and output
AUHAL unit with the BuildGraph code below. Any idea why this is not
working?
Thank you,
-Chilton
// code follows.
OSStatus BuildGraph(void)
{
AUNode synthNode, delayNode, outputNode;
ComponentDescription desc;
OSStatus err = noErr;
err = NewAUGraph(&myGraph);
// create nodes
desc.componentType = kAudioUnitComponentType;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
// our filter
desc.componentSubType = kAudioUnitSubType_Effect;
desc.componentManufacturer = kAudioUnitID_Delay;
err = AUGraphNewNode(myGraph, &desc, 0, NULL, &delayNode);
// default output unit
desc.componentSubType = kAudioUnitSubType_Output;
desc.componentManufacturer = kAudioUnitID_DefaultOutput;
err = AUGraphNewNode(myGraph, &desc, 0, NULL, &outputNode);
// connect nodes
err = AUGraphConnectNodeInput( myGraph, delayNode, 0, outputNode, 0 );
err = AUGraphOpen(myGraph);
err = AUGraphInitialize(myGraph);
err = AUGraphGetNodeInfo(myGraph, delayNode, NULL, NULL, NULL,
&FilterUnit);
err = AUGraphGetNodeInfo(myGraph, outputNode, NULL, NULL, NULL,
&OutputUnit);
// here is where we set our callback.
SetRenderProc();
err = AUGraphStart(myGraph);
return err;
}
// Set a render proc on our filter unit, to read from the buffer
OSStatus SetRenderProc(void)
{
OSStatus err = noErr;
AURenderCallbackStruct renderCallback;
renderCallback.inputProc = MyReadFromBufferProc;
renderCallback.inputProcRefCon = 0;
err = AudioUnitSetProperty (FilterUnit,
kAudioUnitProperty_SetRenderCallback,kAudioUnitScope_Input,0,&renderCall
back,sizeof(AURenderCallbackStruct));
return err;
}
_______________________________________________
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