How do we modify the AudioUnitV3Example to create a Generator or MIDI node?

I was able to quickly hack the effect unit to generate a tone, but I'd like to go one step further and make it a MIDI node.


I modified the component descript to be kAudioUnitType_MusicDevice, and re-arranged the audio engine graph so that the node is connected directly to the mixer. However, no sound is produced and the render block does not seem to be called. I also tried the same approach except with a 'Generator' type, no luck.

Answered by Dreamwieber in 10468022

Ok -- figured out my mistake:


My breakpoint was set in the Filter Demo's processWithEvents method. the internalRenderBlock method _was_ being called, but it was erroring out when trying to call pullInput, since the MusicDevice isn't set up to do that (at least by default -- not sure if that's something MusicDevices can do in general).


Setting the type to kAudioUnitType_MusicDevice does indeed return a music device type audio unit. Sending a 'startNote' message to the AVAudioUnitMIDIInstrument in the AVAudioEngine does indeed pass all the way through to the kernel's handleOneEvent method.


Neat!

Accepted Answer

Ok -- figured out my mistake:


My breakpoint was set in the Filter Demo's processWithEvents method. the internalRenderBlock method _was_ being called, but it was erroring out when trying to call pullInput, since the MusicDevice isn't set up to do that (at least by default -- not sure if that's something MusicDevices can do in general).


Setting the type to kAudioUnitType_MusicDevice does indeed return a music device type audio unit. Sending a 'startNote' message to the AVAudioUnitMIDIInstrument in the AVAudioEngine does indeed pass all the way through to the kernel's handleOneEvent method.


Neat!

How do we modify the AudioUnitV3Example to create a Generator or MIDI node?
 
 
Q