Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

This is a problem that has bugged me for the last 5 years, across multiple devices, operating systems and installs of iTunes and iPods.

I have found that the iTunes shuffle feature does not randomly shuffle songs. In fact, I can accurately predict the exact sequence of songs that iTunes will play. This frustrates me to no end because I like to listen to my music randomly, but I have a few favourite songs that I always start out with.

For example, if I select the song 'Somebody That I Used To Know' by Gotye, it will always follow with this exact sequence of songs:

  1. Blame It On The Tetons by Modest Mouse
  2. Girl You Have No Faith In Medicine by The White Stripes
  3. Mombassa by Hans Zimmer, from the Inception Soundtrack
  4. Break of Dawn by Michael Jackson
  5. Missing Words by Mark Ronson and the Business International

The method I use to start the songs does not matter. I have tried selecting the song in iTunes, searching for it and playing it with Coversutra, or searching for it from within iTunes, playing the song and then clearing the search. All three methods will play the exact same sequence of songs.

I thought this might be due to the same seed being used, but I get the same sequence after restarting iTunes or even my computer. The sequence is the same across different days as well. Waiting for the song to finish or hitting next does not change anything either.

I have had this problem (but with different sequences) for as long as I can remember on my Windows PC, MacBook and my iMac. All different versions of iTunes and operating systems, spanning 5 years.

Why does iTunes fail so hard and something that is so easy? Is there any way I can fix this?

share|improve this question
    
Have you tried using iTunes DJ instead? I have found it works better. –  daviesgeek Aug 26 '11 at 16:27
4  
What happens when you turn off shuffle mode and on again? That always works for me like shuffling the deck of cards another time. Are you in a normal playlist or something with "smarts" like DJ or an smart playlist? –  bmike Aug 26 '11 at 17:11
add comment

7 Answers 7

up vote 175 down vote accepted

The Summary Version

It is random, but the order is only shuffled once, when you turn random play on. If you want to re-shuffle the order, turn random play off and then on again.

The Detailed Version

I don't think this is a bug, it's a feature. Though I can understand how it might seem broken.

iTunes doesn't shuffle the order of the tracks every time you hit play (or any other control button). Another way of saying this is: it uses the same seed for your playlist every time until you tell it to use another seed.

This may seem contrary to the idea of shuffle but it actually serves a purpose: it lets the skip back and skip forward buttons work in a manner that makes sense. I can move back 5 songs while it's on shuffle to hear the song I heard 5 songs ago, and then iTunes plays through all the songs I just heard to get me back to the spot I was at before going back 5 songs.

I do believe the ordering is truly random the first time it's generated. The problem is it's never obvious how to re-generate the ordering after that so your brain, which is really good at recognizing patterns as that's a handy survival skill when you're hunting and gathering, starts to learn the order over time. It starts to find patterns.

You can see this is the case with this little experiment. Set iTunes to shuffle your entire library. Pick a track. Play 5 tracks and write them down. Now pick any other track and let iTunes play one or two songs after that. Now go back to your first track and play from there again. It'll play that track and the same five after it that you wrote down. Changing tracks didn't reseed the random number generator.

The traversal through your tracks is truly random, but that random order isn't refreshed often enough so it starts to feel non-random.

So how do you get iTunes to generate a new shuffle order?

You uncheck and recheck the shuffle button. Doing this causes iTunes to recreate the random traversal path through your playlist (or entire library). It re-seeds the random number generator.

You can convince yourself this is true with a little experiment. Take an album that has track numbers in the meta data and select tracks 1 through 5 then select File -> New Playlist from Selection... from the menu. You'll now have a playlist with 5 songs in it.

Select that playlist and make sure that the shuffle button is unlit and that the track numbers are showing in the window. iTunes will show you the tracks in order: 1, 2, 3, 4, 5.

Now hit the shuffle button.

iTunes will show you the tracks out of order. I get: 4, 2, 1, 3, 5.

Now hit the shuffle button to turn it off. And turn it on again.

I now get: 5, 2, 3, 4, 1.

Repeat as many times and needed to convince yourself that iTunes is actually regenerating a random traversal sequence through the tracks in your playlist.

It's the same thing for traversing your entire library: if you never uncheck and recheck the shuffle button the order never gets regenerated so things will start to seem non-random. After I unchecked and rechecked shuffle and began playing my entire library from my original starting track from my second paragraph above I got 5 different songs after it this time. So the order was changed, it's just less obvious when you're looking at your entire library instead of a playlist.

There's a caveat to all of this: iTunes DJ (aka Party Shuffle) works differently. With Party Shuffle you can influence the selection so that there's weighting given to more popular songs in your library. This obviously isn't random playback. So if you want truly random playback you want to shuffle your entire library from the Music view in the sidebar, not the iTunes DJ view. And you want to uncheck and re-check that shuffle button before each listening session to keep it truly unpredictable.

share|improve this answer
12  
Finally a useful answer to this question! I don't know how many times it's been dismissed off-hand. –  Bryan Matthews Aug 26 '11 at 20:00
2  
Your answer explains why I've never experienced this. During the day, I listen to albums I select, listening to the tracks in sequence. When there's an hour left in my work day, I switch to shuffle across my whole library. –  Cleggy Aug 26 '11 at 20:09
3  
This is true. I implemented Shuffle logic in an iPhone App called "Ambiance" and had to do it this way for the same reasons: back and forward navigation. –  coneybeare Aug 26 '11 at 20:10
2  
I loved the moment where you said "It starts to find patterns" and it kind of sounded like "It's not iTunes' problem, it's your brain that's at fault here!" –  badp Aug 27 '11 at 8:08
2  
@Bombe iTunes generates a completely random ordering of your entire list, not just a single number. This allows the forward and back buttons to function in a sensible way even though it's in shuffle mode. The experiment with the playlist illustrates this. –  Ian C. Aug 27 '11 at 13:17
show 6 more comments

Another reason why iTunes does only generate the randomness once is that this way it can ensure that you get every track played once with no duplicates.

If you have 1000 tracks in shuffle mode, after 1000 plays you will have listened to all of them. That would never work if it would randomly choose a track every time you hit play or the previous track ended, you would get duplicates at some point.

share|improve this answer
    
Plus, you wouldn't be able to use the skip/reverse buttons properly. –  timothymh May 31 '13 at 12:47
add comment

I remember reading somewhere that apple originally used true randomness in shuffle but people complained that the same song would play two or three times in a row (which you would expect as an almost certainty considering the number of users). They quickly changed it and Steve Jobs spun it (rather well) into "iPods are now less random in order to seem random" when he released the feature.

So shuffle was changed to randomising the track list every time you selected it rather than randomising the next song - to remove the risk of double, triple, quadruple etc. plays.

I just feel sorry for the guy who copped the same song 5 times in a row despite having 1000s of songs in his iPod. Surely there was at least one...

share|improve this answer
add comment

@Bombe and @IanC - there are reversible pseudorandom number generators, so you do only need one number, not the whole sequence. Think about it, the time taken to generate the sequence does not depend on the size of your music collection. Encryption algorithms offer one approach, since any encryption algorithm that does not change the length of the input (eg the Enigma Machine, Caesar Ciphers) will give you random-ish values that you can treat as a number, and you can decrypt any string to reverse through the sequence.

However, it's far simpler just to use a simple linear congruential generator, of the form:

enter image description here

If the constants are chosen such that every value less than m will be generated, it turns out there are a different set of constants a', c' that reverse the sequence. You (or Apple) only need to calculate the second set of constants once. One pair of generators that are inverses of each other are:

enter image description here

See here for the derivation. You then pick a starting value using your system clock, and hey presto - a reversible random sequence.

All that's then needed is a way to map numbers in the range [0, 232-1] to songs in your collection, which is pretty simple.

If shuffle really works by playing the songs in the same order every time though, (as the questioner describes) then Apple are not maintaining a random number independent of the current song - since multiple numbers in the range 0..232-1 would map to the same song with different subsequent songs. Instead, they must be using the song's position in your collection as xn, and then mapping from xn+1 back to a song position. This would mean you'd get exactly the effect described in the question. The only variation would be the starting point, which would be a mapping from the clock to xn, then calculating xn+1 and mapping that back to a song position.

share|improve this answer
    
With iTunes at least, the application is obligated to show the entire random sequence of numbers generated for a playlist or library, so using something less than simple seems un-advantageous. It has to output the full N tracks worth of values in any case. And yes, they are using the songs index in your collection (or a play list) as the number for the song when creating a vector to walk through a collection. Though what you describe in the final paragraph is incorrect. You do get a different vector every shuffle. Not just a different starting point. –  Ian C. Jul 28 '12 at 2:35
add comment

Of course it is not truly random. Many years ago Steve Jobs was doing the Keynote for one of the major iPod product announcements. He stated that the truly random shuffle could line up the same song two or more times in a row. So they reworked the shuffle to make it less random. For one thing it tracked the songs so that a single song would not be played more than once in a shuffled play list. So it is a feature not a bug. Introduced by none other than Jobs himself.

share|improve this answer
add comment

If you notice, when you enter a playlist for the first time and select the shuffle icon, it instantly shuffles your playlist, then plays through in that order sequentially.

If you manually sort the playlist differently, for example by artist, then select the shuffle icon, your playlist won't shift visually, and if you start listening to a particular song it will jump to random next track when the song is ended, rather than sequentially going through your playlist.

If you close iTunes, or listen to a different playlist for a while, then come back to the original one, and select the very same first song, the next song it plays will be different than the last time (unless for some reason the random selection is the same, but this will happen with decreasing frequency as your playlists get larger).

share|improve this answer
add comment

CNet did a study a while back that proved that iTunes Shuffle plays songs by specific studios, studios who had partnerships with Apple, more often.

So if you're wondering why you hear ###### pop songs more often when you use shuffle in iTunes, now you know why.

share|improve this answer
    
That page doesn't say whether their results are statistically significant or not. It's not obvious to me that their results would be unlikely given a perfectly random distribution. –  Tanner Swett Mar 19 '13 at 19:17
add comment

protected by Community Sep 12 '12 at 9:02

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.