Rockbox Development > Feature Ideas
Random track selection
philden:
Works nicely!
I'm still bemused by the concept of more or less random, though!
Thanks very much, Bilgus.
Bilgus:
sorry I updated it once more it stopped working with a single track in one of the updates
anyway the idea is that it has a large range to pick at random and you can lessen that range at the ends or in the middle
selectivity is that range in the middle
2. the degree to which an electronic circuit or instrument can distinguish particular frequencies.
also consider the database file has a long range of positions that still end up with the same string
it is the whole file path of the track previous.
The code iterates to the next track which now has 5-260?
possible values that could match the random number
this is why it is or was prone to repeats and not so much the rand num generator being bad
philden:
This is much more complicated than I expected, I'm impressed by your work, Bilgus. I had naively thought that if the database contains 60,000 songs, you'd just need to generate a random number between 1 and 60,000 and play that track.
My limited understanding of the database is that it doesn't involve such a list. Might the above approach be an option from a playlist file that did contain all of the tracks? I don't know if it would be any easier for the device to handle than just playing or shuffling the list, but it could mean indefinite random play including song repeats.
Bilgus:
philden, thanks It really isn't much more complicated than that and the track file paths are indexed as well but we are kinda going around that whole
process and just reading the database
I wanted to parse the whole thing and index it that was my first try and SLOW
what I have currently works well but its still pretty slow and it's got a bug that garbles the first track from the database
I'll have to get that figured out before I can finish it
Bilgus:
Now I can safely say that was more involved than I anticipated
I think what I have now checks all the boxes and it is much faster too
https://gerrit.rockbox.org/r/c/rockbox/+/4027
I went with building a sparse index with a lua coroutine that walks to the desired string saving everything on the way
these items may be deleted by the garbage collector under memory pressure and later rebuilt
finally this allows rand(0-ndatabaseentries) and should work with massive playlists
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version