1 Introduction

The Top Spotify Tracks of 2018 dataset contains 100 of the most popular songs. In this notebook, we will analyze the data structure and try to identify what are the secret ingredients(Tempo, Keys, Name) for popular songs.
I normally listen to Chinese pop music or Classical music, thanks to this dataset, I listened to 20+ Western Hit Songs in 2 days. My personal favorite is Happier by Marshmello.

Note: I used majority of my code for Spotify Song Analysis 2017, meanwhile I have added some personal opinions to the popular songs/artists for the 2018 analysis.

1.1 Data preparation

We will rescale some variables, such as Danceability, Energy , Speechiness, Liveness, Valence, and Accoustiness for visualization purposes. In addition, We will combine some variables (Key and Mode) and categorize tempo for them to make sense musically.

1.1.1 Data Rescaling

We will rescale Danceability, Energy , Speechiness, Liveness, Valence, and Accoustiness by multiply 100.

  • Danceability: describes how suitable a track is for dancing,0.0 is least danceable and 1.0 is most danceable.

  • Energy: is a measure from 0.0 to 1.0 and represents a perceptual measure of intensity and activity.

  • Speechiness: detects the presence of spoken words in a track. Values above 0.66 describe tracks that are probably made entirely of spoken words.

  • Acousticness: A confidence measure from 0.0 to 1.0 of whether the track is acoustic

  • Liveness: Higher liveness values represent an increased probability that the track was performed live.

  • Valence: A measure from 0.0 to 1.0 describing the musical positiveness conveyed by a track. Tracks with high valence sound more positive (e.g.ย happy, cheerful, euphoric),

1.1.2 Data Preparation for Key Signatures and Tempo

We will categorize the tempo by classical music standard. We will show the tonality of each song by combining the variables key and mode, and then group the tonality of the songs by the key signatures.

  • Key :The key the track is integers map to pitches using standard Pitch Class notation. E.g. 0 = C, 1 = C sharp/D flat, 2 = D, and so on.
  • Mode : Major is represented by 1 and minor is 0.

Key Characterstics and Mood

  • C Major :Innocently Happy
  • C minor :Innocently Sad, Love-Sick
  • C sharp minor : Despair, Wailing, Weeping
  • C sharp Major: fullness, sonorousness, euphony
  • D Major: Triumphant, Victorious War-Cries
  • D minor: Serious, Pious, Ruminating
  • D sharp minor: Deep Distress, Existential Angst
  • D sharp Major: Cruel, Hard, Yet Full of Devotion
  • E Major: Quarrelsome, Boisterous, Incomplete Pleasure
  • E minor: Effeminate, Amorous, Restless
  • F Major: Complaisance and calm
  • E sharp minor: Obscure, Plaintive, Funereal
  • F sharp Major : Conquering Difficulties, Sighs of Relief
  • F sharp minor: Gloomy, Passionate Resentment
  • G Major: Serious, Magnificent, Fantasy
  • G minor: Discontent, Uneasiness
  • G sharp Major : Death, Eternity, Judgement
  • G sharp minor : Grumbling, Moaning, Wailing
  • A Major : Joyful, Pastoral, Declaration of Love
  • A minor : Tender, Plaintive, Pious
  • A sharp major: Joyful, Quaint, Cheerful
  • B flat minor : Terrible, the Night, Mocking
  • B Major: Harsh, Strong, Wild, Rage
  • B minor: Solitary, Melancholic, Patience
music$tone <- ifelse(music$mode==0, "minor", "major")

music$scale <-ifelse (music$key==0, "C",
                      ifelse(music$key==1, "C#",
                             ifelse(music$key==2, "D",
                               ifelse(music$key==3,"D#" ,
                                      ifelse(music$key==4, "E",
                                             ifelse(music$key==5, "E#",
                                                    ifelse(music$key==6,"F",
                                                           ifelse(music$key==7, "F#",
                                                                  ifelse(music$key==8, "G",
                                                                         ifelse(music$key==9,"G#",
                                                                                ifelse(music$key==10,"A",
                                                                                       "A#"))))))))))) 


music$keys <- paste(music$scale, music$tone, sep= " ")

music$keysign <- ifelse (music$keys %in% c("C major","A minor" ), "Original",
                         ifelse(music$keys %in% c("G major","E minor","D# minor" ), "F sharp",
                          ifelse(music$keys %in% c("D major","B minor" ), "F,C Sharp",
                            ifelse(music$keys %in% c("A major","F# minor" ), "F,C,G Sharp",    
                            ifelse(music$keys %in% c("E major","C# minor" ), "F,A,G,D Sharp",
                            ifelse(music$keys %in% c("B major","G# minor" ), "F,C,G,D,A Sharp",
                            ifelse(music$keys %in% c("F# major","G# minor" ), "F,A,C,G,D,A,E Sharp",
                             ifelse(music$keys %in% c("C# major","A# minor" ), "F,A,C,G,D,A,E,B Sharp",
                             ifelse(music$keys %in% c("F major","D minor","E# major" ), "B Flat",
                              ifelse(music$keys %in% c("G minor", "A# major" ), "B,E Flat",
                               ifelse(music$keys %in% c("C minor","D# major"), "B,E, A Flat",
                               ifelse(music$keys %in% c("F minor","G# major","E# minor" ), "B,A,D,E Flat",
                              "Unknown"))))))))))))


music$keylabel <- ifelse(music$keys== "C major",  "C major :Innocently Happy", 
                  ifelse (music$keys=="C minor", "C minor :Innocently Sad, Love-Sick",
                  ifelse(music$keys=="C# minor" , "C sharp minor : Despair, Wailing, Weeping", 
                   ifelse(music$keys=="C# major","C sharp major: Fullness, Sonorousness, Euphony",
                  ifelse(music$keys=="D major", "D major: Triumphant, Victorious War-Cries",
                  ifelse(music$keys=="D minor", "D minor: Serious, Pious, Ruminating",
                   ifelse(music$keys=="D# minor", "D sharp minor: Deep Distress, Existential Angst",
                   ifelse(music$keys=="D# major", "Cruel, Hard, Yet Full of Devotion",
                   ifelse(music$keys=="E major", "E major: Quarrelsome, Boisterous, Incomplete Pleasure",
                    ifelse(music$keys=="E minor", "E minor: Effeminate, Amorous, Restless",
                    ifelse(music$keys %in% c("E# major" ,"F major"), "F major: Complaisance and calm",
                    ifelse(music$keys %in% c("F minor", "E# minor"),  "F minor: Obscure, Plaintive, Funereal",
                    ifelse(music$keys=="F# major", "F sharp major : Conquering Difficulties, Sighs of Relief",
                    ifelse(music$keys=="F# minor", "F sharp minor: Gloomy, Passionate Resentment",
                    ifelse(music$keys=="G major", "G major: Serious, Magnificent, Fantasy",
                    ifelse(music$keys=="G minor", "G minor: Discontent, Uneasiness",
                    ifelse(music$keys=="G# major", "G sharp major : Death, Eternity, Judgement",
                    ifelse(music$keys=="G# minor", "G sharp minor: Grumbling, Moaning, Wailing",
                    ifelse(music$keys=="A major", "A major : Joyful, Pastoral, Declaration of Love",
                    ifelse(music$keys=="A minor", "A minor : Tender, Plaintive, Pious",
                    ifelse (music$keys=="A# major", "A sharp major: Joyful, Quaint, Cheerful",
                    ifelse(music$keys=="A# minor", "A sharp minor: Terrible, the Night, Mocking",
                           "Unknown")  )))))))      )))       )))))))))))

# tempo classification
music$tempoc[music$tempo >= 66 & music$tempo <76] <- "Adagio" 
music$tempoc[music$tempo >=  76 & music$tempo <108] <- "Andante" 
music$tempoc[music$tempo >= 108 & music$tempo <120] <- "Moderato" 
music$tempoc[music$tempo >= 120 & music$tempo <156 ] <- "Allegro" 
music$tempoc[music$tempo >= 156 & music$tempo <176] <- "Vivace" 
music$tempoc[music$tempo >= 176 ] <- "Presto" 


music$tlabel[music$tempo >= 66 & music$tempo <76] <-" 66- 76"
music$tlabel[music$tempo >=  76 & music$tempo <108] <- "76-108" 
music$tlabel[music$tempo >= 108 & music$tempo <120] <- "108- 120" 
music$tlabel[music$tempo >= 120 & music$tempo <156 ] <- "120 -156" 
music$tlabel[music$tempo >= 156 & music$tempo <176] <- "156-176" 
music$tlabel[music$tempo >= 176 ] <- "> 176" 

2 Spotify 2018 Top 100 Song Tracks Analysis

2.2 Individual Player analysis

We will see the radarchart of the most popular artists.

2.2.3 Post Malone

In my point of view, Post Maloneโ€™s songs have relatively connected melody lines compare to other rappers. His music flows more and the lyrics are not too dense. His voice

Starbucks?

3 Music Theory 101

In order for our work to make sense musically, we need to go over 2 basic components of music very quick: Key and Rhythm.

3.1 Tonality VS Key signature

Starbucks?

Beer?

Key signature refers to what notes are sharp and flat. I understand tonality as the color of a music piece, two pieces of music can have same key signature, but totally different tonality. For example, First chapter of Mozart G major violin is happy and bubbly whereas First Chapter Mendelssohn E minor violin concerto shares a color of myseterious and sorrowness. But their key signature are both in F Sharp.

3.2 Tempo Classifation

Tempo

  • Adagio โ€“ slowly with great expression[10] (66โ€“76 bpm)
  • Andante โ€“ at a walking pace (76โ€“108 bpm)
  • Moderato โ€“ at a moderate speed (108โ€“120 bpm)
  • Allegro โ€“ fast, quickly, and bright (120โ€“156 bpm)
  • Vivace โ€“ lively and fast (156โ€“176 bpm)
  • Presto โ€“ very, very fast (168โ€“200 bpm)

4 Basic Music Theory Analysis

We will take a look at what tone the top 100 songs use most frequently, and what is the most often used key signituares. and temp

4.1 Tonality of Top 100 songs

In general , Major chords revoke a happy feeling, whereas Minor chords represent sadness. I m very surprised Csharp major is used so often. In addition, Top 3 categories all share a grief, sad emotions.

5 Key signature analysis

6 Rythme analysis

6.1 Tempo Classification

Now we tak a look at what is the most popular Tempo type amont the top 100 songs, We will use the categorized tempo type to do the analysis. We can see about half of the songs has tempo between 76 to 108. So Andante is the most used tempo. Adagio is the least used tempo. I guess slow songs is not that popular then.

## Warning: Removed 1 rows containing missing values (geom_text).

7 Categorical analysis on Key and Tempo

7.3 Heatmap Energy respect to Key and Tempo

we can see Vivace and A# major demonstrated high energy. I think higher speed will represent higher energy. However, we notice with Vivace and C# major, the energy is quite low. I think thatโ€™s because C# has grief depressive feeling

8 Mosaic Plot Keys vs Rythmn

Now we want to inverstigate if the key has relationship with rythmn . From the mosaic graph, there is no evidence to show Minor Key or Major Key has association with the Rythmn.

PostCredit Scene- My Favorite Song in 2018

I came across a song, ็ปฏ Fei by Mubo and Roi 2 weeks ago, i really like it. It is so easy to dance to! I forgot what song I liked the most in 2018, but this song is from 2018, so I decided to list it here.

Starbucks?

MuBo <3

9 References

[1] Tempo Classification, https://en.wikipedia.org/wiki/Tempo

[2] Key Signature Chart,https://www.piano-keyboard-guide.com/key-signatures.html