Download

Setting up a step sequencer on the audio thread

I’ve set up a project with a synth and a sample player, and I created a step sequencer class that triggers notes. Currently, I’m running the step sequencer on the game thread and accumulating the delta time to trigger notes on the beat. While this works to a degree I have noticed some inconsistencies when using the sample player to play drums. The timing is not sample accurate for obvious reasons, and I would like to move in that direction.

So, I’m going to move the timing to the audio thread and trigger the notes with a short delay (measured in samples). My question is: how can I guarantee that the step sequencer will fire the timing messages before the synth triggers it’s generate audio loop? The audio callback buffer is currently 1024 samples long, and if the step sequencer queues up a note on the synth after the synth generates its audio the note will be triggered on the next loop (1024 samples late).

You might want to look at our new Early Access TimeSynth which is an audio scheduler. You could probably modify it to create drum sequences by feeding it patterns in advance.

Thanks, I’ll check it out.

Ok, I saw the live stream today, and I’ve come to the conclusion that the TimeSynth is not going to work for my use case. I think what I’ll try is just triggering the notes one loop early, and I’ll just add 1024 samples to the delay, that will at least guarantee the step sequencer fires the event before the Synth needs to start generating audio for that note. I’m definitely still looking for a way to trigger the note on the same loop that it needs to start though.