Dissonance

A Journey Through Musical Possibility Space

From Spectrum to Scale

In this page, we'll derive musical systems for real and imagined instruments. Starting from any sound, we'll attempt to work out the musical scales and chords that sound the most consonant (or at the least dissonant) for this particular sound. In other words, we're discovering musical scales & chords by analyzing the spectrum of a sound. Although the page has a built-in default sound, I'll show you how you can change this sound to whatever you like, and everything on this page will then refer to your sound.

To hear the sound, press the button below.



This sound has {{spectrum.freq.length}} harmonics, or frequency components, that are in the ratio {{spectrum.freq.map(myRound)}}. Each frequency component, or partial, to use the music term for it, decreases in loudness. The amplitudes for the partials of this sound are {{spectrum.amp.map(myRound)}}.

Before we go further, let's inspect this sound in code. Open up your browser's console, and type in app.spectrum.freq and press enter. This will give you the frequency components of this sound. You can also type in app.spectrum.amp to get the amplitudes.

But here's where it gets interesting: you can change these numbers! So, for example, if you wanted a sound with only the odd partials present, you could set app.spectrum.freq = [1, 3, 5, 7, 9, 11] and everything in this document will be updated for your new sound. Try it out if you like, and then press the play button above to hear your new sound. When you're done, you can set the sound back to the default by entering app.spectrum.freq = [1, 2, 3, 4, 5, 6] or just refreshing the page.

Your sound can have as many frequency components as you like, but you have to make sure that app.spectrum.freq & app.spectrum.amp both have the same number of entries (i.e. every partial in your sound needs to have a frequency and corresponding amplitude). You can also change the pitch of the sound, by setting app.refFreq = 440 or any number you like (this is the fundamental frequency in Hz, so don't go much above 1000, or the sound will be very high pitched!)

Consonant Intervals

An interval is two notes that are played together. Imagine you made two copies of the sound from above. If you fixed the pitch of one sound, and then slowly varied the pitch of the second sound, what would you hear? For some musical intervals, the combination would sound dissonant. At certain special intervals, the sound becomes more consonant.

Below is a graph of this dissonance. When both sounds have the same frequency, they sound perfectly in sync (in unison), and so there is no perceived dissonance. So the y axis (which measures the dissonance) is zero at the beginning of the graph, when the ratio of pitches is 1.

Try it out. Click on any point on the graph to hear what that musical interval (combination of tones) sounds like. Do the dips sound any different from the peaks?

You might notice that when you play the sounds together at the special musical intervals that are given by the dips in the graph (shown in orange above), they sound more consonant than when you play them at other intervals. Taken together, these dips make up a musical scale. The table below lists the intervals in this scale. How do they sound when played together?


If the original sound has a harmonic spectrum, the intervals end up being located at the well known "Just Intonation" ratios. In other words, 'Just Intonation' is the musical scale that minimizes dissonance for a pure harmonic sound.

Consonant Triads

Next, let's think about what happens when we play three notes together. So instead of intervals, we'll now consider triads, which are musical chords consisting of 3 notes played together. We have one sound that's fixed, and two more identical sounds whose pitch we will vary. Now, instead of generating a dissonance graph like before, we get a dissonance surface. The x and y axes represent how far in pitch the two sounds are with respect to the fixed reference.

Take a look, and click and drag around.

This is the dissonance surface for our sound. Every point on this surface is a triad, i.e. a combination of three notes (there are infinitely many possibilities, because frequency varies continuously). The bottom of the valleys (shown in blue) correspond to more consonant musical chords, while the hills and mountain peaks (shown in red) correspond to more dissonant chords. You can drag the graph to rotate it and look under it, and click on any point to hear the corresponding triad.

What we're after here are the valleys –– these are the least dissonant musical triads, and together, these make up a list of musical chords. However, it's a little hard to identify these valleys from the surface above. So instead, let's take a look at a heatmap of this surface. The dark blue areas have lower dissonance than the yellow and light green areas.

Click on different points on this heatmap to discover different chords. The sharp blue valleys have automatically been identified in orange. Do they sound different from other points? What makes these points special?

The table below provides more information on these chords, marked in orange above.

References

The algorithm used in this article is developed by William Sethares and explained in detail in his excellent book Tuning, Timbre, Spectrum, Scale. I pulled some values of parameters from this Python port of Sethares' work. The code for this page is available on Github.