Tweak the shuffle behavior
Hi tim, I was looking for a terminal music player for my newly installed EndeavourOS when I ran into tap — it's light, fast, beautiful, and everything just works. I've really enjoyed using it these days. Thank you for creating such a piece of art in my terminal!
I have one small issue about shuffle though. With shuffle enabled, I noticed that some tracks repeat more often while others rarely play. For example, with a 4-track album I might get something like [1, 3, 4, 3, 4, 1, 3, 1, 2, ...], where 2 waited long before playing. After reading the code, it seems shuffle simply picks a random track different from the current one.
Would you consider changing shuffle to generate a random permutation of the current playlist and play through that order? This would ensure all tracks are played more evenly. I've tweaked shuffle this way in my fork and would be happy to open a PR if you think this approach makes sense.
The tweaked shuffle that I implemented:
- When toggles on, continues to play through current track, then start a shuffled cycle. eg. for a 4-track album
[1(shuffle-on), 3, 2, 1, 4]where the first shuffled cycle started at3. - After a complete shuffle cycle, if nothing happens, starts a new cycle in the same album, additionally, the new cycle would not start with the same track as the previous cycle ended. eg.
[1(shuffle-on), 3, 2, 1, 4, 3(2nd cycle), 1, 4, 2], the 2nd cycle could also start with1or2, but not4. - When jumping to a searched / random album with
shuffleon, a shuffle cycle on the new album would start immediately(the first track played could be any track). - When toggles off, forgets about the cycle, so when toggles on next time, start a new cycle.
Please let me know if you're interested in this idea. Thanks again for your work on tap!