How Shuffle Works in Rockbox
When we designed and created the Rockbox shuffle concept, we had a few goals:
- true shuffle that won't repeat a single song until all songs in the list/dir have been played
- resumable - when the box has been switched off and is later turned on, we should resume the same song at the same index in the shuffled playlist/dir
- support limitless back - at any time, even after resuming, you can always go back to the previously played song(s)
All song playing in Rockbox works on a list of songs. When you play a dir, it builds a list of song internally and plays that. If you play a playlist, it loads that list and plays it. (Playlists are stored internally as a long list of indexes into a file on disk where the actual song name is stored.)
Rockbox generates a random seed and re-orders the internal list with the random function (Mersenne Twister). When storing resume info, the random seed is stored and thus later re-used again when the same random order is wanted.
Copyright © by the contributing authors.