setBeat method
Immediately changes the position of the sequence to the given beat.
Implementation
void setBeat(double beat) {
if (!globalState.isEngineReady) return;
_tracks.values.forEach((track) {
NativeBridge.resetTrack(track.id);
});
final leadFrames =
getIsPlaying() ? min(_getFramesRendered(), LEAD_FRAMES) : 0;
final frame = beatToFrames(beat) - leadFrames;
engineStartFrame = NativeBridge.getPosition() - frame;
pauseBeat = beat;
getTracks().forEach((track) {
track.syncBuffer(engineStartFrame);
});
if (loopState != LoopState.Off) {
final loopEndFrame = beatToFrames(loopEndBeat);
loopState = frame < loopEndFrame
? LoopState.BeforeLoopEnd
: LoopState.AfterLoopEnd;
}
}