LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to make mpg123 shuffle more randomly? large playlist, seeding urandom, cli (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-make-mpg123-shuffle-more-randomly-large-playlist-seeding-urandom-cli-4175450587/)

keithostertag 02-17-2013 08:45 PM

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.

Thanks,
Keith Ostertag

MS3FGX 02-17-2013 08:48 PM

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?

keithostertag 02-17-2013 08:53 PM

Hi-

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?

Thanks,
Keith Ostertag

MS3FGX 02-17-2013 09:45 PM

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.

keithostertag 02-17-2013 09:59 PM

OK, thanks very much for taking the time to look at the code and giving this some thought. I appreciate it.

There's lots of ways to generate playlists, so I think I will put some effort into approaching it from that direction.

Keith

muneshchauhan 10-28-2017 09:53 AM

'-z' option not seen
 
I do not see any '-z' option when '-h' help is pressed.

fatmac 10-30-2017 01:04 PM

Try writing a script to pick tunes at random from you mp3 storage area & send them to mpg123 instead of relying on its internal randomizer. :)


All times are GMT -5. The time now is 02:22 AM.