Voidz through Spotifyr

Jasmine Cervantes
4 min readSep 30, 2021

Using Spotifyr + R to get a look at what prison-jazz is really made of.

I’m still figuring out how to harness the complete power of R, so this is a super amateur look into Spotifyr. I used Simran Vatsa’s extremely helpful TayloR analysis as a guide, as well as this depressing Radiohead analysis by Charlie Thompson

library(spotifyr)
library(plyr)
library(tidyverse)
library(ggthemes)
library(knitr)
library(kableExtra)
library(spotifyr)

Loading some packages….

So for Spotify, you’ll use your account to get into the developer site here. You then opt to create a project which leads you to a dashboard where you’ll find your client ID and secret. This is what gets R and Spotify to talk to each other.

Sys.setenv(SPOTIFY_CLIENT_ID = 'your id goes here')
Sys.setenv(SPOTIFY_CLIENT_SECRET = 'secret in here')

After your id + secret are good, you should be able to extract the artist info from the artist of your choosing. I chose The Voidz because they’re super musically diverse, have a smaller catalog, and I know them pretty well enough to spot something wonky in the analysis.

voidz <- get_artist_audio_features('the voidz')

Now I’m filtering out anything that isn’t in the first two albums like any singles or remixes.

voidz <- voidz %>% filter(album_name == "Tyranny" | album_name == "Virtue")

Nice! Now we have an easy, clean data frame!

Valence in music is a rating from 0.0–1.0 of how positive a song is. The Voidz have a song called Human Sadness, an 8-minute ride built from a requiem mass by Mozart. It’s heavy and layered, I was expecting it to have the lowest valence score.

voidz %>% 
select(track_name, album_name, valence) %>%
arrange(valence) %>%
head(10) %>%
kable() %>%
kable_styling(full_width = F, position = "left") %>%
row_spec(row = 1:10, background = "azure", color = "red")

Pointlessness from Virtue came in first though, and with lyrics like “I believe that you’re gonna be forgotten any day now, just like the others told you.” then yeah, alright. Let’s go for first.

Here, we’re taking the artist’s data frame we extracted from spotify, selecting the song, album, and valence scores. We’re then arranging it by valence (you could do -valence if you want the liveliest song). Then, with Kable, we’re customizing the list. I wanted to show 10 tracks (row = 1:10).

Let's try another way to visualize the data:

ggplot(voidz, aes(valence, album_name, colour = track_name)) + 
geom_point(size = 5)

With a plot graph, we can display tracks by valence and sort them by album. Here, we can tell Pointlessness has the lowest valence score on Virtue, All Wordz Are Made Up having the highest.

Lots going on, The Voidz use 16 different keys in their 27 songs. We’ll take on the code we ran for valence and adjust that to show us the top 5 keys.

library(tidyverse)
library(knitr)

voidz %>%
count(key_mode, sort = TRUE) %>%
head(5) %>%
kable() %>%
kable_styling(full_width = F, position = "left") %>%
row_spec(row = 1:5, background = "azure", color = "red")

Energy is another measure given in the Spotify data frame, let’s see what’s up.

voidz %>% 
select(track_name, album_name, energy) %>%
arrange(-energy) %>%
head(10) %>%
kable() %>%
kable_styling(full_width = F, position = "left") %>%
row_spec(row = 1:10, background = "azure", color = "red")

I recognize a lot of these guys from their set lists! I went to setlist.fm to check out their most played songs to compare them to the ones with the highest energy.

Cool! 4 out of the 10 most played are ranked with the highest energy!
Cool! 4 out of the 10 most played are ranked with the highest energy!

To get a little graph going, we’ll load ggplot + ggridges. Then we’ll get our data frame in place, set our x and y’s. The rest your aesthetic choice. Get weird with it!

library(ggplot2)
library(ggridges)

voidz %>% ggplot(aes(x = valence, y = album_name, fill = ..x..)) +
geom_density_ridges_gradient(scale = 0.9) +
scale_fill_gradient(low = "cyan", high = "red") +
theme_fivethirtyeight() +
theme(panel.background = element_rect(fill = "white")) +
theme(plot.background = element_rect(fill = "white")) +
xlim(0,1) +
theme(legend.position = "none") +
labs(title = "The melody is free!",
subtitle = "Based on valence from spotifyr")
## Picking joint bandwidth of 0.0992

and to finish, a visualization of the valence rating through the album. Virtue looks like it builds, then leaves you bottomed out. Tyranny immediately builds to high energy then immediately drops for the second half of the album!

--

--