• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Simple code to use an effect
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Re: Simple code to use an effect (From: Bill Stewart <email@hidden>)

  • Prev by Date: Re: Sound Manager & MIDI callbacks, interrupts and threads
  • Next by Date: Re: Questions on data in MIDIPackets
  • Previous by thread: Re: Simple code to use an effect
  • Next by thread: Re: Simple code to use an effect
  • Index(es):
    • Date
    • Thread