4

I have an app with an elaborated render callback that I doubt could do with AVAudioEngine.

Anyway to use my AUGraph render callback ( with multiple buses ) with AVAudioEngine ?

Any sample code ?

Fischer
  • 1,513
  • 4
  • 17
  • 38

2 Answers2

8

The Audio Unit API is not deprecated, only AUGraph which is presumably built on top of it.

Make connections using AudioUnitSetProperty with kAudioUnitProperty_MakeConnection with an AudioUnitConnection struct.

Start and stop your output unit with AudioOutputUnitStart and AudioOutputUnitStop.

Set a render callback using AudioUnitSetProperty and kAudioUnitProperty_SetRenderCallback with an AURenderCallbackStruct

There's really not all that much that AUGraph gives you other than a little bookkeeping and a simpler connection syntax.

dave234
  • 4,793
  • 1
  • 14
  • 29
  • Thanks dave234. I was seeting the mixerUnit with AUGraphNodeInfo ... like AUGraphNodeInfo(processingGraph,mixerNode,NULL,&mixerUnit); – Fischer Jun 28 '19 at 16:56
  • how to set the mixerUnit without AUGraphNodeInfo ? – Fischer Jun 28 '19 at 16:58
  • I don't understand the question. – dave234 Jun 28 '19 at 17:02
  • My doubt is ... There is another updated way to setup the mixerUnit ( kAudioUnitSubType_MultiChannelMixer ) than AUGraphNodeInfo ? I guess AUGraphNodeInfo could be also deprecated – Fischer Jun 28 '19 at 17:11
  • 1
    Yeah, you wouldn't use nodes at all, just the AudioUnits directly. You have to call [AudioUnitInitialize](https://developer.apple.com/documentation/audiotoolbox/1439851-audiounitinitialize?language=objc) on each unit before starting the output unit. – dave234 Jun 28 '19 at 18:15
3

A (non-deprecated) V3 AUAudioUnit subclass can still return an AUInternalRenderBlock which supports audio render callbacks. The AVAudioEngine API can then connect these Audio Units (for instance, to mixer nodes). Audio Unit V3 render functions still seem to allow short (buffers with less than 500 samples) for near-real-time audio synthesis and analysis on iOS.

See my V3 AU example app on GitHub (mixed Swift and Objective C): https://github.com/hotpaw2/auv3test5

hotpaw2
  • 70,107
  • 14
  • 90
  • 153