Re: Simple code to use an effect
Re: Simple code to use an effect
- Subject: Re: Simple code to use an effect
- From: Laurent de Segur <email@hidden>
- Date: Mon, 18 Feb 2002 18:04:22 -0800
On Monday, February 18, 2002, at 01:02 PM, Jean-Philippe Leblanc wrote:
Now I guess the connection is not linked to the input of the default
output So I am back to the board trying to figure out why
MakeConnection
triggers the filter by way of defaultoutput, then nada on the output.
Any
light on this is sincerely appreciated.
Jean-Philippe,
Here are a code snippet using AUGraph to do what you asked. I basically
plugged a filter (reverb) between the sin gen and the output. It's quite
simple using AUGraph API and I also have a version of this which uses
AudioUnit only, if you are interested. One thing you need to make sure
is that your output rate is directly supported by the device if you
don't attach an audio converter to it.
LdS
//
________________________________________________________________________________
//
// TestAUGraph
//
void TestAUGraph()
{
AUGraph theAUGraph;
AUNode theEffectNode, theOutputNode;
OSStatus err;
verify_noerr(err = NewAUGraph(&theAUGraph));
ComponentDescription desc;
desc.componentType = kAudioUnitComponentType;
desc.componentSubType = kAudioUnitSubType_Output;
desc.componentManufacturer = 0;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
verify_noerr(AUGraphNewNode(theAUGraph, &desc, 0, NULL,
&theOutputNode));
desc.componentType = kAudioUnitComponentType;
desc.componentSubType = kAudioUnitSubType_Effect;
desc.componentManufacturer = kAudioUnitID_MatrixReverb;
verify_noerr(AUGraphNewNode(theAUGraph, &desc, 0, NULL,
&theEffectNode));
verify_noerr(AUGraphOpen(theAUGraph));
verify_noerr(AUGraphConnectNodeInput(theAUGraph, theEffectNode, 0,
theOutputNode, 0));
AudioUnit theEffectUnit;
verify_noerr(AUGraphGetNodeInfo(theAUGraph, theEffectNode, NULL, NULL,
NULL, &theEffectUnit));
// Set up a callback function to generate output to the effect unit
AudioUnitInputCallback theEffectInput;
theEffectInput.inputProc = MyEffectRenderer;
theEffectInput.inputProcRefCon = NULL;
verify_noerr(AudioUnitSetProperty(theEffectUnit,
kAudioUnitProperty_SetInputCallback,
kAudioUnitScope_Global,
0,
&theEffectInput,
sizeof(theEffectInput)));
UInt32 theReverbRoomType = kReverbRoomType_LargeHall;
verify_noerr(AudioUnitSetProperty(theEffectUnit,
kAudioUnitProperty_ReverbRoomType,
kAudioUnitScope_Global,
0,
&theReverbRoomType,
sizeof(UInt32)));
verify_noerr(AUGraphInitialize(theAUGraph));
verify_noerr(AUGraphStart(theAUGraph));
while (1)
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, false);
verify_noerr(AUGraphStop(theAUGraph));
verify_noerr(AUGraphUninitialize(theAUGraph));
verify_noerr(DisposeAUGraph(theAUGraph));
}
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.