Skip to content
Wrangling and Visualizing Musical Data
  • AI Chat
  • Code
  • Report
  • Spinner

    1. Introduction

    How do musicians choose the chords they use in their songs? Do guitarists, pianists, and singers gravitate towards different kinds of harmony?

    We can uncover trends in the kinds of chord progressions used by popular artists by analyzing the harmonic data provided in the McGill Billboard Dataset. This dataset includes professionally tagged chords for several hundred pop/rock songs representative of singles that made the Billboard Hot 100 list between 1958 and 1991. Using the data-wrangling tools available in the dplyr package, and the visualization tools available in the ggplot2 package, we can explore the most common chords and chord progressions in these songs, and contrast the harmonies of some guitar-led and piano-led artists to see where the "affordances" of those instruments may affect the chord choices artists make.

    # Loading individual Tidyverse packages
    library(dplyr)
    library(readr)
    library(ggplot2)
    # Reading in the McGill Billboard chord data
    bb <- read_csv("datasets/bb_chords.csv")
    
    # Taking a look at the first rows in bb
    head(bb)

    2. The most common chords

    As seen in the previous task, this is a tidy dataset: each row represents a single observation, and each column a particular variable or attribute of that observation. Note that the metadata for each song (title, artist, year) is repeated for each chord -- like "I Don't Mind" by James Brown, 1961 -- while the unique attributes of each chord (chord symbol, chord quality, and analytical designations like integer and Roman-numeral notation) is included once for each chord change.

    A key element of the style of any popular musical artist is the kind of chords they use in their songs. But not all chords are created equal! In addition to differences in how they sound, some chords are simply easier to play than others. On top of that, some chords are easier to play on one instrument than they are on another. And while master musicians can play a wide variety of chords and progressions with ease, it's not a stretch to think that even the best musicians may choose more "idiomatic" chords and progressions for their instrument.

    To start to explore that, let's look at the most common chords in the McGill Billboard Dataset.

    # Counting the most common chords
    bb_count <- bb %>%
      count(chord, sort = TRUE)
    
    # Displaying the top 20 chords
    bb_count[1:20,]

    3. Visualizing the most common chords

    Of course, it's easier to get a feel for just how common some of these chords are if we graph them and show the percentage of the total chord count represented by each chord. Musicians may notice right away that the most common chords in this corpus are chords that are easy to play on both the guitar and the piano: C, G, A, and D major — and to an extent, F and E major. (They also belong to keys, or scales, that are easy to play on most instruments, so they fit well with melodies and solos, as well.) After that, there is a steep drop off in the frequency with which individual chords appear.

    To illustrate this, here is a short video demonstrating the relative ease (and difficulty) of some of the most common (and not-so-common) chords in the McGill Billboard dataset.

    # Creating a bar plot from bb_count
    bb_count %>%
      slice(1:20) %>%
      mutate(share = n / sum(n),
             chord = reorder(chord, share)) %>%
      ggplot(aes(chord, share, fill = chord)) +
      geom_col() +
      coord_flip() +
      ylab('Share of total chords') +
      xlab('Chord') +
      theme(legend.position="none")

    4. Chord "bigrams"

    Just as some chords are more common and more idiomatic than others, not all chord progressions are created equal. To look for common patterns in the structuring of chord progressions, we can use many of the same modes of analysis used in text-mining to analyze phrases. A chord change is simply a bigram — a two-"word" phrase — composed of a starting chord and a following chord. Here are the most common two-chord "phrases" in the McGill Billboard dataset. To help you get your ear around some of these common progressions, here's a short audio clip containing some of the most common chord bigrams.

    Your browser does not support the audio tag.
    bb_bigram_count <- bb %>%
      mutate(next_chord = lead(chord),
             next_title = lead(title),
             bigram = paste(chord, next_chord)) %>%
      filter(title == next_title) %>%
      count(bigram, sort = TRUE)
    
    # Displaying the first 20 rows of bb_bigram_count
    bb_bigram_count[1:20,]

    5. Visualizing the most common chord progressions

    We can get a better sense of just how popular some of these chord progressions are if we plot them on a bar graph. Note how the most common chord change, G major to D major, occurs more than twice as often than even some of the other top 20 chord bigrams.

    
    bb_count %>%
      slice(1:20) %>%
      mutate(share = n / sum(n),
             chord = reorder(chord, share)) %>%
      ggplot(aes(chord, share, fill = chord)) +
      geom_col() +
      coord_flip() +
      ylab('Share of total chords') +
      xlab('Chord') +
      theme(legend.position="none")

    6. Finding the most common artists

    As noted above, the most common chords (and chord bigrams) are those that are easy to play on both the guitar and the piano. If the degree to which these chords are idiomatic on guitar or piano (or both) determine how common they are, we would expect to find the more idiomatic guitar chords (C, G, D, A, and E major) to be more common in guitar-driven songs, but we would expect the more idiomatic piano chords (C, F, G, D, and B-flat major) to be more common in piano-driven songs. (Note that there is some overlap between these two instruments.)

    The McGill Billboard dataset does not come with songs tagged as "piano-driven" or "guitar-driven," so to test this hypothesis, we'll have to do that manually. Rather than make this determination for every song in the corpus, let's focus on just a few to see if the hypothesis has some validity. If so, then we can think about tagging more artists in the corpus and testing the hypothesis more exhaustively.

    Here are the 30 artists with the most songs in the corpus. From this list, we'll extract a few artists who are obviously heavy on guitar or piano to compare.

    # Finding 30 artists with the most songs in the corpus
    bb_30_artists <- bb %>%
    select(artist,title)%>%unique()%>%
    group_by(artist)%>%count(artist,sort=TRUE)
    # Displaying 30 artists with the most songs in the corpus
    bb_30_artists[1:30,]

    7. Tagging the corpus

    There are relatively few artists in this list whose music is demonstrably "piano-driven," but we can identify a few that generally emphasize keyboards over guitar: Abba, Billy Joel, Elton John, and Stevie Wonder — totaling 17 songs in the corpus. There are many guitar-centered artists in this list, so for our test, we'll focus on three well known, guitar-heavy artists with a similar number of songs in the corpus: The Rolling Stones, The Beatles, and Eric Clapton (18 songs).

    Once we've subset the corpus to only songs by these seven artists and applied the "piano" and "guitar" tags, we can compare the chord content of piano-driven and guitar-driven songs.