Check out My Mixtape

Harmit Sampat
VisUMD
Published in
7 min readDec 15, 2019

Visualizing Spotify playlists.

Photo by Fixelgraphy on Unsplash

Music is the most advanced auditory stimulus there is. I strongly believe that music, like any other art form, is 100% subjective. Although there are elements in music that are quantifiable, it is nearly impossible to tell whether or not the individual listener will enjoy it based on those measures. The objective qualities to music such as time signature, tempo, chord progressions, etc. allow people to discuss various musical styles and the technical abilities of musicians, and what makes them interesting but fail to indicate how it is being perceived.

So, yes, there is no way to guarantee that your friends are going to like the playlist you created for your road trip. Nevertheless, I was still interested in finding out whether I could figure out people’s taste in music.

Motivation

One of my go-to topics to use as a conversation starter whenever I’m out meeting new people is asking them about their favorite kinds of songs. Every artist, album and genre have a set of unique characteristics that appeal to the listener and that is what I wanted to explore through data visualization. My goal for this project was to create and present visualizations that uncover these patterns in song qualities.

Visualizing sound and music structures is an idea that has been explored in the past. For instance, Martin Wattenberg’s “The Shape of Song” is a technique to visualize the repeating sections of a song using an arch diagram. There have also been similar projects that visualize the repetitiveness of song lyrics using self-similarity matrices (SongSim). Some of the questions that I wanted to explore through this project were: How do we end up choosing the music that we often listen to, and Can we identify an individual’s music preferences using by visualizing their playlists?

An overview

The dataset I created for this project was fetched entirely from Spotify’s own Web API. Spotify, which is probably the most popular digital music streaming service, also has access to an open developer platform, from which you can read calculated audio features of tracks to learn about its danceability, energy, valence, and more.

Spotify provides numerous high-level as well as low-level audio features and other content for every track in their catalog. I narrowed down my choices to just five of them, using only those features that I thought would help me gather relevant insights. The features, defined according to the Spotify Web API developer guide, were as follows:

  • Acousticness: A confidence measure from 0.0 to 1.0 of whether the track is acoustic.
  • Danceability: Describes how suitable a track is for dancing based on a combination of musical elements including tempo, rhythm stability, beat strength, and overall regularity.
  • Energy: Represents a perceptual measure of intensity and activity. Typically, energetic tracks feel fast, loud, and noisy. For example, death metal has high energy, while a Bach prelude scores low on this scale.
  • Loudness: The overall loudness of a track in decibels (dB). Loudness values are averaged across the entire track and are useful for comparing the relative loudness of tracks.
  • Valence: Describes the musical positiveness conveyed by a track. Tracks with high valence sound more positive (e.g. happy, cheerful, euphoric), while tracks with low valence sound more negative (e.g. sad, depressed, angry).

I chose to stick to these 5 parameters based on the intuition that we make our music choices based on the current mood, the occasion, and the activity we are engaged in at that time. Hence, I believe that these features would be more useful in my exploration of the data.

To understand whether such patterns do exist, I used some popular playlists that can be found on Spotify. Playlists were not chosen according to the genres they represent but based on the situation they are most suitable for. The following playlists were selected:

  1. Beast Mode — a workout playlist
  2. Deep Focus — for long study/work sessions
  3. Chill Hits — a list of mellow sounding tunes
  4. Dance Party — a collection of songs that are often played at parties
  5. Dinner with Friends — a playlist for when you have friends over for dinner
  6. Songs to Sing in the Car — a travel/commute playlist

A few things that I noticed after analyzing the data:

  • ‘Beast mode’ and ‘Dance Party’ score high on energy and loudness, but very low on acousticness which makes perfect sense for their intended use.
  • ‘Deep focus’ has very high acousticness, low energy, and danceability.
  • ‘Chill Hits’ also having low energy and danceability making them ideal for calmer environments.
  • ‘Dinner with friends’ and ‘Songs to Sing in the Car’ are much higher in valence than other playlists, matching the cheerful vibes present in both these situations.

Judging from these results and the information I was able to gather, I concluded that the dataset was fairly capable of providing some revealing patterns within such playlists. ‘Songs to Sing in the Car’ did have many of my favorites in it and, in fact, I do like to sing in the car!

Implementation

All design decisions were made keeping in mind Tamara Munzner’s 8 Rules of Thumb from her book “Visualization Analysis & Design”. Out of those 8 rules, there were 3 that seemed extremely relevant to this visualization:

  1. Overview first, zoom and filter, details on demand;
  2. Get it right in black and white; and
  3. Function first, form next.

The main goal was to ensure that each audio track and its features are clearly distinguishable. Attempts were made to keep lines and other visual elements from overlapping, and less visual clutter, overall. It is extremely tricky to visualize datasets with many dimensions on a 2D plane, even more so when the number of instances is also very large.

After several iterations of sketching concepts and building prototypes, trying to understand the best way to visualize audio features in a playlist, I settled on using a radial bar graph to represent the data. The bars extend radially outwards, showing the top 10 tracks in the playlist for each audio feature. Every bar represents the value of that feature for the individual track and the features are distinguished by color. The darker shade on the bar is the average value for that feature in Spotify’s top 50 charts. This was added for comparing users’ playlists with the current most popular songs.

There were a few pre-processing steps involved: querying and fetching data from the Spotify API, sorting the tracks by audio features, selecting the top tracks and finally combining them back into a new CSV file. The data was prepared using Python.

The interface was built using HTML/CSS can be viewed on any web browser. The visualization was designed using D3.js. Click here to view an interactive version.

Insights

Key insights from the final visualization revealed that:

  • There was fluctuation in acousticness across the different playlists. The dance playlist had very low acousticness scores, which was definitely due to the use of many electronic instruments in their songs.
  • Acousticness and Energy often appeared to be inverse of each other. Where acousticness was high, energy or danceability would be low and vice versa.
  • Valence was generally on the higher side and without much variation.
  • Loudness, although supposed to ranging from 0 to -60 dB, never really went below -6 dB.

The observation on loudness led to another interesting discovery:

image courtesy: https://www.reddit.com/user/cavedave/

It has been observed that in all genres with the exception of jazz and classical music, the loudness value is identical. This is apparently a result of the loudness war (or loudness race), which, at one point in time, was a trend in increasing audio levels in recorded music. This movement was widely criticized because it reduced listener enjoyment. As you can see, it was prevalent in radio-popular genres because of the competition among record companies.

Conclusion

If you want to make sure that your ‘mixtape is fire 🔥’ and will be liked by everyone, you need to make sure that the songs you select match the occasion. A playlist having high valence and acousticness would please most listeners in almost all cases, except for when you need everyone on their feet and dancing. One thing you do not need to worry about is the volume because they’re all pretty loud!

--

--