Can sequence:play(onFinishcallback) be frame-accurate?

Hi.

I’ve built a drum machine using “sound.sequencer” feature.(playdate.sound.sequence:play([finishCallback]))

Problem is, while the “infinite loop sequence” replays the sequence frame-tight, playdate.sound.sequence:setLoops(startStep, endStep, [loopCount]) where loopcount is 0, the finite-loop callback does not seem to be frame-accurate.

That’s how the SDK example was set up, making the loop infinite and doesn’t utilize the “finishCallback” function attachment.

The callback function fires quite randomly even if the function call was consistently made in the same step, giving noticible delays on playback.

I’ve used a hacky solution to set the infinite loop up and then made 2 sequencers go back and forth to implement the “pattern transition”, but it’s clean-cut of an implementation and the sounds inevitably bleed through the other sequencers.

If it’s not big of a fix, I would really love the frame-accurate “finishCallback”. Thanks.

1 Like

having the same issue with longer image sequences synced to audio.

I change the image “reels” on audio callback end and there is very inconsistent flickers on the changes which is not expected at how low memory and cpu load im at, as well as the flickering being different even with the same transition (which i wouldn’t expect if the problem was something like microsecond differences between end sample length etc)

Two things working against you here: One, we have to forward the event to the main run loop on the game task where your code runs, and two there's a fair bit of overhead calling a Lua function. If you use the C API, though, the callback is called on the audio task and will be frame accurate. (..I'm pretty sure, anyway)