Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Let The Music Speak: An Analysis Report on

shuffle algorithm of music players that can enhance


music listening experience

Akshay Syal
Btech Student
VIT Vellore

Bhopal, India
akshaysyal19@gmail.com

Abstract— The shuffling algorithm of most music players or puts all the elements into a hat; it continually determines the
music streaming services although work well and produce next element by randomly drawing an element from the hat
random list of songs but many users complain about the until no elements remain.
shuffling algorithm playing a few songs from the same artist
right after each other. Now there is nothing wrong about the The algorithm effectively puts all the elements into a hat;
current shuffling algorithms like the Fisher-Yates algorithm, it it continually determines the next element by randomly
shuffles well and produce random results but what the users drawing an element from the hat until no elements remain. The
really want is a playlist in which songs of same artist are algorithm produces an unbiased permutation: every
distributed across the whole playlist. The algorithm proposed in permutation is equally likely. The modern version of the
this paper produces an even less random playlist but the output algorithm is efficient: it takes time proportional to the number
playlist will feel “more random” to the users. of items being shuffled and shuffles them in place. Time
Complexity of this algorithm is O(n).
Keywords— Shuffling algorithm, Fisher-Yates Algorithm,
Gambler’s Fallacy -- To shuffle an array a of n elements (indices 0..n-1):
for i from n−1 downto 1 do
I. INTRODUCTION
One of the most common features implemented in a music j ← random integer such that 0 ≤ j ≤ i
player is shuffle. Many users of music player apps or music exchange a[j] and a[i]
streaming services complain about the shuffling algorithm
saying that the player plays a few songs from the same artist III. PROPOSED WORK
right after each other. Fisher-Yates shuffle(a well-known After considering users’ expectations and previous works
shuffling algorithm) is used to generate a perfectly random it was concluded that people don’t like perfect randomness.
shuffling of a playlist. However, perfectly random means that
the following two orders are equally likely to occur (different Shuffle is hard for music players because what people
colours represent different artists). understand as random and what random actually means are
two different things. The difficulty comes in matching user
expectations. Users will say their expectation is songs
randomly selected, but there are many things they don't want
from a random selection. There is nothing really wrong with
your outline for randomly shuffling a playlist, other than it
doesn't really meet users’ expectations of shuffle.

Many people don’t want to listen songs by the same artist • Users don't want to hear the same song multiple times
playing two or three times within a short time period. But if in a row.
they just heard a song from a particular artist, that doesn’t • Users don't want to the same artist/album played
mean that the next song will be more likely from a different consecutively or too close together.
artist in a perfectly random order. Hence people don’t like
perfect randomness. • Users want to hear 1-2 songs from every artist/genre in
their collection before repeats occur.
• Random sequences that match established patterns are
II. EXISTING WORK viewed as not random and disliked. This would be
A. Fisher-Yates shuffle things like playing track 2 from albums A, B, C then
playing track 3 from those albums, or playing track 1
The Fisher–Yates shuffle is an algorithm for generating from A, track 2 from B, track 3 from C. This would
a random permutation of a finite sequence—in plain terms, also be if songs followed a rock, country, rap, pop
the algorithm shuffles the sequence. The algorithm effectively cycle or songs played in alphabetical order.

XXX-X-XXXX-XXXX-X/XX/$XX.00 ©20XX IEEE


• Over playing less liked artists or under playing Adding songs to the playlist
favourite artists creates dissatisfaction.
• Subsets of songs shouldn't be played in the same order
as previous iterations. similarly, the last X songs
shouldn't be in the first X songs in the next iteration.
Users really want something like a curated playlist that
cycles through their collection and plays songs semi-
randomly along an equal distribution.

1. Doubly circular linked list for making songs playlist.


The list stores song name, singer’s name, song’s
positional value and index of the song indexed
according to number of songs of same singer.
2. Singly Linked list for storing singer’s name and
number of his/her songs.
3. Shuffle is implemented by giving each song a
positional value. Then bubble sort will be
implemented.
4. Logic behind positional value:
Let’s say there are singers A, B, C and their songs are a,
aa, aaa, b, bb, c.
• Default spacing is given to songs of the
same singers to distribute them. It will be
equal to k/n where n is number of songs of
the artist and k is from [0, n) i.e. index of
song of that singer.
• Initial offset which is equal to random
number between [0, 1/n]. This gives a
random spacing to songs within the same
category. Adding more songs to playlist to
produce final playlist
• Individual offset which is equal to random
number between [-1/10n, 1/10n]. This gives
random spacings to all songs in the playlist
regardless of their singers.
5. To implement shuffle:
• Traverse through the music playlist.
• Access the singer’s name of the song and
search it in singers list by traversing
through it.
• Access the number of singer’s song (n).
• Update the positional value of the song
according to the logic explained above.
• Implement bubble sort in songs list
according to their positional value in
ascending order.
IV. RESULTS AND OBSERVATION
The shuffled result roughly looks like this:
Shuffled Playlist V. CONCLUSION
The proposed algorithm produces output which is a
shuffled list including all items in the input, which is produced
by the algorithm described above. The randomness
requirements are covered in the algorithm description. The
algorithm doesn’t perform a perfect random shuffle and its
time complexity is O(n^2) but arranges the songs in a semi-
randomly way along an equal distribution.

REFERENCES

[1] Data Structures and Algorithm Analysis in C by Mark Allen Weiss


[2] https://community.spotify.com/t5/iOS-iPhone-iPad/Shuffle-play-is-
not-random/td-p/750619
[3] https://softwareengineering.stackexchange.com/questions/375842/shu
ffle-in-music-players
[4] https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
[5] http://www.empiricalzeal.com/2012/12/21/what-does-randomness-
look-like/
[6] https://www.scientificamerican.com/article/how-randomness-rules-
our-world/
[7] Link to video presentation https://vimeo.com/425563514

You might also like