Playing a sequence of notes with AVAudioSourceNode

Steve Mills

Is it possible to set up an AVAudioEngine and friends so I could feed it a sequence of MIDI notes and have it play that sequence, using an AVAudioSourceNode as the sound source? The AVAudioSourceNode is just using a render block to produce a sine wave of a given pitch. Apple doesn't seem to have any sample code for AVFoundation that I could find, and all the examples I see online are too simplified (load a midi file and sound bank file, play it).

I've gotten as far as loading a short midi file as a test, but get an error that there's no AU connected to the track, and I can't figure out how to make that happen. But ideally, I'd like to generate the midi on the fly and feed the notes into an AVAudioSequencer (I think).

Steve Mills
Drummer, Mac geek

Join to automatically receive all group messages.