Hacker News new | comments | show | ask | jobs | submit login
The art of shuffling music (emphy.de)
39 points by wfunction on Apr 17, 2015 | hide | past | web | favorite | 27 comments



I don't understand why the genre matters. Most of the problems with shuffle play go away if you prune the songs you don't like out of your collection. True randomness is fine if you follow a few basic principles:

1. Don't repeat songs too soon. A record of the last 100 or so songs should be enough and doesn't use much memory. If shuffling a short playlist or album, don't repeat until they've all been played.

2. Don't attempt to group similar sounding songs together. I've never seen an algorithm succeed at this and it serves no aesthetic purpose. If I want to maintain a mood, I'll create a playlist, select songs manually, or just hit skip.

3. Don't ignore new material. If I add, rename, or reorganize music I don't want to do anything special for it to be included in the shuffle.

4. Don't roll your own random algorithm. Ever since shuffle play was introduced as a feature on CD players, there have been algorithms that will play the same N out of X songs in a collection, clearly using some kind of modulo-based function instead of a good quality PRNG. If your algorithm can permanently exclude songs, it's broken.

None of this helps with songs that should remain part of a suite or have a segue that is abruptly clipped, but some of those shouldn't be separate tracks to begin with.


"True randomness" is at complete odds with points 1. and 2. If I flip a coin 10 times and get 10 heads, its still "truly random."

I think iPod's shuffle was originally truly random at first and it was changed - I'm reminded of this thread from a while back - https://news.ycombinator.com/item?id=4301922


This has reminded me of my old MP3 player, I think it was made by Archos, that had two shuffle modes: "shuffle" & "random".

The "random" mode would happily play songs from the playlist multiple times, even directly after one another; "shuffle" on the other hand would never play a song more than once per playlist. When I first got it I was fascinated by this difference – I still wonder why they included both modes.


What I really want in a shuffling music player is for it to remember when I jump to one song after listening to some other song, conclude "hey, I bet that first song makes a good lead-in to that second song", and bias the shuffling to use that transition more often. Is there a player that will do that?


+1

What I want, and will probably never get round to implementing, is Markov chain playlist generation. Collect play order from (high-quality, human-generated) playlists, then use them to build Markov chains of tracks that tend to be played after one another.


And the opposite: if I skip B it probably means it do not go well with A in a sequence.


+1 to that.


iirc foobar2000 (maybe it was a plugin) had some pretty intense shuffle tweaking- album-at-a-time, how far in your linear collection to jump (assuming your genres were together), of course how long between plays of the same song...


I've encountered a similar problem with the shuffle method in Clementine (I love this music player) where it repeats a song not too long after having played it. In the case of Clementine there is no "random playlist" generated, the next song is randomly chosen, despite it having been played 3 songs ago, or even 2 songs ago. So I've noticed shuffling on several software is quite a pain. Interesting read, I wouldn't mind as much the issues in this article since most of my playlists are of the same genre, although I do get the issue of upbeat / lowbeat songs.


That sounds like a pretty basic bug not to catch in a shuffling function. Sounds like it shuffles for ever and never reaches the end then? I haven't heard of clementine before. What does it provide you that other music apps don't?


> I haven't heard of clementine before. > What does it provide you that other music apps don't?

Love. All that sweet Amarok 1.4 UX, untainted by the 2.0 branch shark jumping.

The playlist management just feels right, but the killer feature for me is the indexed library that provides instant searches - perfect for enthusiastically digging into a large collection.

Although it is an entirely different concept, Amarok and later Clementine are what convinced me to jump ship from the file explorer + Winamp-like combo that used to be my sweet spot.


It was inspired by Amarok so that's to no surprise.


I mostly liked it because it was multiplatform, and the ability to control it from a mobile app on my phone via same Wi-Fi local network.

Edit:

I believe it's discontinued now, or something. But also another plus was that it was quite fast at starting up. I got it due to my frustration with how slow iTunes had become. It's hard to find anything close to 'iTunes' as well.


> I believe it's discontinued now, or something.

Something: https://github.com/clementine-player/Clementine/commits/mast...


Seems like their Ubuntu package rarely gets updated, plus their website only lists news as far back as 2013... So I thought it was discontinued...


I like to use the 'dynamic random playlist' mode in Clementine. It maintains a playlist with the previous 5 or so songs and a queue of 20 or so songs which are coming up, which is added to randomly from another playlist (exluding songs which are already in the list). Also (and this is the thing which I rarely find in other players), I can re-arrange this working playlist if I want to follow a theme, add or remove songs coming up, and it will just transition back into a random mode when the added/rearranged songs have played.


Clementine is great. If you look in the library on the left you can right click "Smart playlists" and select "New smart playlist...". Then you can create a playlist of all your music (or with additional filters) that is either randomized every time you open it or built dynamically as you listen.


FWIW I hacked up a program over the years that I use to shuffle my music. It works on unix based boxes with perl and mpv available. It does the following:

* Keeps track of songs already played, so songs heard recently won't be played as much as songs not played recently

* If Control-C is pressed while listening to a song, it will reduce the frequency the song is played

* If the song is listened through in its entirety, the frequency it will be played is increased

* Any new music just added will be given higher priority than old, already played stuff

* Songs from each directory are played more or less equally. So if you have 30 songs from the Beatles and 500 from Black Sabbath, you won't hear Black Sabbath 94% of the time.

* Keeps track of every time a song is played and whether it is liked or not, so if later you want to use this data for something else, you have it available.

You need to pass the songs to it's standard in, eg:

find /disc1/my_music -type f | the_player.pl

To stop listening, you need to hit Control-Z to stop it, and then kill the process.

Here it is: http://pastebin.com/N7vj1pSc


I appreciate the idea of "content-aware" shuffling, but I wish the author had not stated that random shuffling "lacks fairness and uniform distribution." If that is true then the shuffle isn't very random. People have enough trouble with randomness and its characteristics.


> I wish the author had not stated that random shuffling "lacks fairness and uniform distribution." If that is true then the shuffle isn't very random.

I have no idea what you're trying to say here. The lack of uniform distribution that results from random sampling is well known. The author even specifically elaborates on exactly what he's referring to in the text that immediately follows your quote.

Random numbers always clump. What people actually have in mind when they think of "random selection" is almost always a sample that visits every part of the space with roughly equal frequency ("uniform"). See e.g. http://en.wikipedia.org/wiki/Halton_sequence .

Uniform random selection is "fair" and "uniform" before the selection happens. But not afterward. What this guy, and most music listeners, want is selection that visits every song in a "fair" and "uniform" manner after the selection has happened -- they care about what the result is, not whether certain aspects of the result could have been predicted in advance.


'uniform distribution' is a specific term in statistics which means something separate to what uniform colloquially means, and in discussions like this it's important to distinguish carefully between the terms. (i.e. A uniform distribution is unlikely to be perceived as 'uniform', as you say)


The "clumping" the author refers to is within genres. In a perfect random number generator any of the possible output values is as likely to appear next in the sequence as any other. PRNGs are not perfect, but there is nothing either unfair or non-uniform about two blues tunes showing up next to each other, if they happen to be stored in flat list of songs and indexed by ordinal. I think you need to reread the piece.


Another related problem is how to auto generate playlists. I tried it with many acoustic metrics and found nothing working well for my taste. I want something that plays my music the way a good generalist radio would play it. Following a genre is the opposite of what I want: I would be happy to have blues, metal, classic, rap, techno, all shuffled together, as long as there is some cross genre conference between the tracks. Tried it and did not succeed yet.


If you work at Spotify, please read this immediately!



Interesting. I have a very large playlist (1,000+ songs) and there are songs I never hear and songs I hear frequently.


I made a 500 song playlist on Spotify for my drive across the U.S. and discovered that their "shuffle" was actually random. Or if it was a shuffle algorithm, it was a bad one. Whenever I stopped playing (e.g., stopped car for fuel or food), it reshuffled instead of continuing where it left off. As a result, I heard the same 100 songs on that trip.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: