setLoop method
Enables looping.
Implementation
void setLoop(double loopStartBeat, double loopEndBeat) {
// If the sequence is over, ensure globalState is updated so the sequence
// doesn't start playing
checkIsOver();
// Update engine start frame to remove excess loops
final loopsElapsed = loopState == LoopState.BeforeLoopEnd
? getLoopsElapsed(_getFramesRendered())
: 0;
engineStartFrame += loopsElapsed * getLoopLengthFrames();
// Update loop state and bounds
final loopEndFrame = beatToFrames(loopEndBeat);
final currentFrame = _getFrame(false);
if (currentFrame <= loopEndFrame) {
loopState = LoopState.BeforeLoopEnd;
} else {
loopState = LoopState.AfterLoopEnd;
}
this.loopStartBeat = loopStartBeat;
this.loopEndBeat = loopEndBeat;
getTracks().forEach((track) => track.syncBuffer());
}