How to visualize current AKSequencer position with Audiokit?
Asked Answered
S

1

6

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!

Sabina answered 2/3, 2018 at 21:11 Comment(1)
I have a feeling I could reach my goal using an AKCallbackInstrument in the sequencer to tgrigger custom functions.Sabina
F
4

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.

Faber answered 3/3, 2018 at 0:26 Comment(1)
Yes, seen this code snippet. Thats how I figured it out. Thnx!Sabina

© 2022 - 2024 — McMap. All rights reserved.