I am new to Audiokit. I want to visualize the current position of a running AKSequencer. Are there any callbacks (like in AKMetronome) or listeners or a root clock/main loop running that I can hookup? Or should I use a AKCallbackInstrument that "triggers" the GUI in any way?
Anyone ever did this who wants to share? Thnx!
I do this with the AKCallbackInstrument
. For each sequence track that I write MIDI events to, I have a sister sequencer track sending to AKCallbackInstrument
. When I write a MIDI event for the audio track, I also write a GUI event to the sister callback track.
Because you can only send MIDIStatus, MIDINote, and MIDIVelocity data to the callback instrument, you have to arbitrarily encode information into these formats. For example, a MIDINote of 0 might signify one type of GUI event, MIDINote 1 something else. Creating some enums makes this easy.
Of course the callback functions are called on a background thread, so don't forget to specify that your GUI updates should happen on the main thread.
This approach has worked quite well for me.
edit: I suspect you've already seen this sample code that illustrates something very similar, but this link might be useful for anyone else coming across this question.