Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Audio Effect in CoreAudio Audio Graph - Render Callback

I'm building a MIDI synth using CoreAudio. Currently, I have the following audio graph:

    Sampler -> Reverb -> IO

I need to add a chorus effect to the graph as well as the reverb. The problem is that there isn't a chorus effect on the iPhone. To get around this I'm planning to implement my own chorus effect. To do this I need access to the audio stream.

The question is: what's the best way to get access to the audio stream in the middle of the audio graph.

    Sampler -> Reverb -> [Custom processing] -> IOUnit

Is there a way I can alter the audio stream using something like the AudioUnitAddRenderNotify callback? or do I have to break the audio graph like this:

    Sampler -> Reverb -> [AudioUnitAddRenderNotify callback] -> buffer -> [RenderCallback] -> IOUnit

Any advice would be appreciated.

like image 697
James Andrews Avatar asked Nov 03 '22 13:11

James Andrews


1 Answers

The easiest way is to add a render notify callback (AudioUnitAddRenderNotify) to your Reverb node's AU and process the audio in the kAudioUnitRenderAction_PostRender call. I did an experiment and got this to work as long as the callback was added after the AUGraph was open, and no processing was done in the prerender call.

like image 171
sbooth Avatar answered Nov 08 '22 09:11

sbooth