How to make mpg123 shuffle more randomly? large playlist, seeding urandom, cli
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to make mpg123 shuffle more randomly? large playlist, seeding urandom, cli
I have been using mpg123 to shuffle through a large playlist- > 13,000 mp3's. I feel it does not shuffle randomly enough- I often seem to hear the same files/artists repeatedly, and many never. I listen to it almost 12 hours/day. I am running it with:
Code:
mpg123 -cCz --list playlist
I have tried seeding the urandom generator with the script off the man random page in several init scripts:
Code:
echo "Initializing random number generator..."
random_seed=/var/run/random-seed
# Carry a random seed from start-up to start-up
# Load and then save the whole entropy pool
if [ -f $random_seed ]; then
cat $random_seed >/dev/urandom
else
touch $random_seed
fi
chmod 600 $random_seed
poolfile=/proc/sys/kernel/random/poolsize
[ -r $poolfile ] && bytes=`cat $poolfile` || bytes=512
dd if=/dev/urandom of=$random_seed count=1 bs=$bytes
but doesn't seem to help.
Is my playlist simply too large for mpg123? Or is there something else I can do to increase the randomness? I have read that one can re-seed urandom with processor cpu clock tics, or similar, but I don't know how to do that or if it would help.
I'm using Debian on an old (very slow) laptop, CLI mainly.
I don't know that it's really an issue with the system's random number generator; more likely I would think there is some deficiency in mpg123's handling of "random" shuffle. Have you looked at the source to see how it determines the next song?
Thanks for responding. I haven't considered looking at the source, since I know very little about programming. I have wondered about mpg123's shuffle routine... maybe I could bypass it using some kind of scripts? I'm not very familiar with script writing, though. Ideas?
Alright, I have looked at the latest version of mpg123, and pulled out the code it uses to pick the next song. I put that together with a simple test program to evaluate how it picks the next song, and can't really find anything obviously broken.
Consider that you say you're listening to music for 12 hours. If we assume an average song length of 3 minutes, that is only 240 plays. If I load my test program with a simulated 13,000 track playlist and 240 track changes, it's relatively rare that a track gets played more than twice (less than 1% chance), but the vast majority of tracks never get played simply because there wasn't enough track changes to get to them.
You aren't playing music long enough to hear all of the tracks, and conversely, some tracks will repeat occasionally.
So unless you are seeing something very odd, like the same song playing 10+ times a day, or one song playing back to back; I think it just comes down to chance.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.