When playing the giveyouup.mid
bundled with the sdk and some other midi files, playback from start to finish works fine. But when using goToStep
to go to a step past a certain point, the sequence instead resets to the start.
Happens on simulator and on device.
Analysis
When analysing the commonalities between songs that are and are not affected, it seems this happens exclusively with high stepCount, which tend to also have high tempo:
- giveyouup, E4M3 and E2M3 have high tempo and stepCounts above 100000 and are affected. reset point is at 97393 exactly. Meaning that goToStep(97392) works and goToStep(97393) resets the sequence to the start
- CGMusic is not affected, has total length of 46021 steps
- countdown_60 is not affected, has total length of 15459 steps
Conclusion: it seems that moveToStep() cannot move past step 97392
Sample project
Relevant code
function ViewModel:movePlayHead(change)
local targetStep = self:getCurrentStep() + floor(change * self.crankSpeed)
targetStep = targetStep % self:getNumSteps()
self.sequence:goToStep(targetStep, true)
end
Reproduction
- Start the project and use the crank to scrobble through the midi file. Some files play correctly from start to end. To start another song, select the song title with
and press
Examples of affected songs are giveyouup.mid and E2M3.mid - notice that when letting the song play past the "reset point" normally without cranking works as expected