LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 02-17-2013, 07:45 PM   #1
keithostertag
Member
 
Registered: Jul 2011
Location: Harrisburg, PA
Posts: 127

Rep: Reputation: Disabled
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
 
Old 02-17-2013, 07:48 PM   #2
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
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?
 
Old 02-17-2013, 07:53 PM   #3
keithostertag
Member
 
Registered: Jul 2011
Location: Harrisburg, PA
Posts: 127

Original Poster
Rep: Reputation: Disabled
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
 
Old 02-17-2013, 08:45 PM   #4
MS3FGX
LQ Guru
 
Registered: Jan 2004
Location: NJ, USA
Distribution: Slackware, Debian
Posts: 5,852

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
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.

Last edited by MS3FGX; 02-17-2013 at 08:48 PM.
 
Old 02-17-2013, 08:59 PM   #5
keithostertag
Member
 
Registered: Jul 2011
Location: Harrisburg, PA
Posts: 127

Original Poster
Rep: Reputation: Disabled
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
 
Old 10-28-2017, 08:53 AM   #6
muneshchauhan
LQ Newbie
 
Registered: Sep 2007
Posts: 1

Rep: Reputation: 0
'-z' option not seen

I do not see any '-z' option when '-h' help is pressed.
 
Old 10-30-2017, 12:04 PM   #7
fatmac
Senior Member
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan with some Tiny Core, Fatdog, Haiku, & BSD thrown in.
Posts: 4,925

Rep: Reputation: Disabled
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How do you make MPlayer with shuffle and loop 0? JackL92 Linux - Software 2 08-28-2012 11:11 PM
Trying unsuccessfully to make launcher for mpg123 holadebeto Linux - Newbie 2 08-10-2011 06:51 AM
VLC loading default playlist or any other playlist from command line r00tb33r Linux - Software 0 12-29-2008 10:24 PM
VLC shuffle playlist broken? cann't play 192 kbps aac songs? aldimeneira Linux - Software 0 10-11-2006 07:02 PM
Run mpg123: system("mpg123"); How to know what PID it gets? And a Emacs highlightin q kornerr Programming 10 08-06-2005 10:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration