Harmony Inquiry Week 10

I made a new copy of my visualizer code to look at 19-tone equal temperament (shortened 19-TET). The typical way to notate the system is to assign the new notes existing sharp/flat names, splitting the existing sharps/flats into companions and adding a new sharp/flat into the old semi-tone gaps. To see what I mean, have a look at the names for notes:

In 12-TET:

C/B#C#/DbD D#/EbE/FbF/E#F#/GbG G#AbA A#/BbB/Cb
(not to scale)

In 19-TET

C C# Db D D# Eb E E#/FbF F# Gb G G# Ab A A# Bb B B#/Cb
(not to scale)

This results in the names getting spaced out almost the same as usual, but making better approximations to the important whole-number pitch ratios. For example, E in 19-TET is close to E in 12-TET, but a little flatter, closer to the just ratio.

In using the visualizer, I was only able to see one thing, which wasn’t surprising: A# gets close to one of the overtones of a low C. More generally, the note 15/19ths above a root is it somewhat close to its “harmonic seventh,” an interval that 12-TET misses by a lot. Because that harmonic seventh is a feature of blues, I tried an experiment in boogie woogie. Making abundant use of that special interval in place of the typical dominant seventh, I made some formulaic boogie woogie music in Musescore, using a plugin to automatically adjust the pitches into 19-TET tuning.

I’m pleased with the result, though it is pretty harsh. I think the harshness is partly just because of the synthesized piano sound, partly because this tuning is alien to our 12-TET conditioned ears, and partly because I’m leaning on that seventh, which is a dissonant sound.

Boogie Woogie Plus

Harmony Inquiry Week 9

To round out our collection of important chord images, here are those of A minor as compared to the root A1. Making this made me appreciate how effective music theory already is at describing the phenomena we experience listening to music. Something important to notice here is that these chords here use all the same notes as the key of C major. But if a piece of music has implied to us a key of A minor, then hearing a G major chord (the bVII) we experience tension, pulling up up toward A. It’s as if G is interfering with the ghost of A in our heads.

And that same G is the V of C. If we look at our images (ignoring the diminished ii because that’s really harsh to listen to and not commonly used), we see that bVII is the one chord where one of the early overlaps lines up with the middle of an overtone of the base note. The images from the key of C major showed the same thing. In both cases it was a weak overlap, but it’s kind of like those notes are tightly squeezing at the base note. A difference is in the major key that occurs over one of the octaves of that base note, and here it occurs over one of the fifths.

Based on what I’ve seen, it seems like the amount of overlapping that occurs between the chord and the (possibly only implied, rather than physically present) base note prior to the chord’s own first significant internal overlap, correlates with the feeling of harmonic stability, whereas the amount of partial overlapping with the base note correlates with tension. And if an early chord-internal overlap occurs directly over an overtone of the base note, that creates a strong pull, an expectation of a cadence.

Overall, I am doubting the usefulness of the analysis I’ve done over the past few weeks, and the applicability to composition. I think the traditional tools of composition are well refined and didn’t really need the application of math when music is such a subjective and innate experience. That said, I will be keep the experience close at hand in my mind when composing music in the future. And next week I will still try and see what happens when I look at some other tuning system. I’m thinking to look at 19-tone equal temperament, because I heard this amazing song that uses it.

Harmony Inquiry Week 8

This week I updated my code so that it’s easier to use. Now one can refer to a specific note and get its frequency as easy as this:

User types code into a computer terminal, and it produces numbers. This makes it clear that B flat corresponds the same frequencies as C. In detail:

User types C, open parenthesis, 4, close parenthesis. Terminal outputs 261.6

User types B, open parenthesis, 3, close parenthesis. Terminal outputs 246.9

User types B, open parenthesis, sharp, comma, three, close parenthesis. Terminal outputs 261.1

And those numbers can be used as inputs to the visualizer, like this:

image = harmony_vis( nothing, B(flat, 4), D(5), F(5) );
save("B_flat_major.png", image)

image = harmony_vis( B(flat, 2), B(flat, 4), D(5), F(5) );
save("B_flat_major_over_B_flat_base_note.png", image)

That is also an example of how the function can be used to create those images of either three-note or four-note chords. If the first input is nothing (that’s a Julia object that represents nothing or no data, equivalent to Python’s None), then the visualizer will produce a two-rowed picture ( from the next three inputs. Otherwise, the first input will be used as the root note for a four-rowed picture. In either case, the three inputs after the first will be coloured red, green, and blue, respectively.

Here is a link to my Julia code.

Because this system made it clear what notes I was using, I realized some of the images from last week were using notes higher or lower than I had said, and many were labelled wrong in the gallery. I have since fixed those.

As well as four-note chords, I noticed this visualization scheme can be used to look at functional harmony, relating some three-note chord back to a “tonal center.” In the following gallery you can see how the main six diatonic chords in the key of C overlap with the harmonic series of C2. I have used inversions of the chords to keep them within a close pitch-range of one another. Also, I am assuming from prior work that, in a major key, what we hear as the tonal center is the note two octaves below the root of the I (one) chord. Conventionally because of the phenomenon of “octave equivalence,” we would just say that the tonal center is C. However, I am theorizing that the particular note is significant, that higher and lower ‘C’s are harmonically close to the tonal center, but distinct from it.

A nice thing about this collection is it shows all of the close-position inversions of major and minor chords. For next week I will keep looking for patterns in here, and focus on this functional harmony. Questions: Can this show us how a major key works? What about a minor key? What might this say about “borrowed chords?”

Also, I have noticed that this analysis can be easily generalized to notes outside the normal tuning (microtonal notes). So I will like to try using it to find nice-sounding microtonal harmonies, make a composition, and create some audio for that.

Harmony Inquiry Week 7: Clearer Pictures

Full gallery here

C_3 Major

Okay folks, this week the pictures are more colourful, and we can see all of pianospace. The left side is A_0, the bottom of a typical piano, and the right goes past the piano’s range and on to the upper limit of human hearing. Now that the overtone bands are properly smearing out, I should point out that they decrease in volume the higher up they are from the root. So to be totally accurate, we might need to lower the brightness toward the right, but the images are easier to read this way, and anyway, the particular way that a given series fades out depends on the timbre of the instrument producing it.

For these 3-note images, the top half shows all the harmonics while the bottom half shows just the parts that overlap with one another. Here’s another:

C_3 minor

If you want to take a really good look you’ll have to open the image in a new tab. Now, musicians sometimes say that chords built from notes lower down get “muddy.” We’re seeing that just a little bit already, but let’s take a look at lower versions of C major.

C_2 major

Woah! Now the notes are clearly interfering with one another.

C_1 major

It’s a rainbow! Down here the notes are so “muddy” they completely smear together.

I said previously that I wanted to look at 4-note chord. I did find a way to do that.

A minor-7

These pictures are more complicated. Root note’s series is shown in white at the top, the other three notes are given in R, G, and B in the bottom-middle quarter and you can see them mixing there. In between are their overlaps with the root note, such as those first two thin bands of red and blue. And at the bottom are the overlaps of the coloured notes (non-root). Here’s one I especially like the sound of:

A major add 9

And here is a highly dissonant and also commonly used one:

A diminished 7

One more interesting direction to go with this: adding more space between notes. You may remember from near the beginning of this inquiry I talked about a drop-2 minor chord, and that it should have a clear harmonic overlap early on, and that it sounds very consonant. Well here it is:

A minor with the third dropped an octave

It seems at this point that we can state some patterns about these visualizations and how they relate to consonance and dissonance. The thin overlaps don’t seem to matter much; they’re probably not very perceptible. In highly consonant chords, the first significant overlap is a complete one. Whereas in highly dissonant chords, the first significant overlap is muddy. The above is an example where it’s kind of hard to say if those first two are significant, but then there is a very strong complete one. For another example of a clearly muddy one:

I’m excited to see if I can apply this technology to music composition.

Harmony Inquiry Week 6: A Better Waveform

This week I did some reading on Wikipedia, which I probably should have done sooner. I read about critical bandwidth, and also consonance and dissonance. The explanation I’m currently exploring is there, as well as several others including that one about long patterns I gave up on reading (although I am starting to think I didn’t give it enough credit) and the idea that the experience of dissonance is a response to rare or unusual sounds.

I took the formula for critical bandwidth and used it to build a new function for my visualizer. By the way, I have so far neglected to mention how I use Desmos. Many times in my life I have gone to Desmos with some mathematical question, and used it to tinker with functions and get a sense for them. In much the same way. Here is a reenactment of what it looked like to work on a new function:

That function in blue becomes the basis for the new model. What I ended up with was this:

Previously, the frequency bands of the harmonics shrunk down, so they would only have indicated overlap in the cases where it was very close. This time, we are using real frequencies. The y axis represents 440 Hz (standard A4), and the widths of the bands are given by that formula b(x), for which Wikipedia cites Glasberg and Moore. I can already tell that what this produces is going to produce more visually interesting. For example:

Hopefully it is also more useful and accurate in terms of how we hear. This week I hope to make some of those colour-gradient visualizations with this new model, and maybe figure out four-note chords. I imagine that I can continue to use just three colours, by ignoring the chord’s fifth, or using the same colour for it as for the root. Or maybe there is some method of combining four colours in a way that is still visually understandable.

Harmony Inquiry Week 5: Visualizing with Julia

This week I wrote code in Julia to create visualizations of the series of chords I wrote about before. I’ll go into the programming process later this post. First, the mathemusical stuff. Let’s have a look at a minor chord, and then I’ll explain what we’re seeing.

Minor chord

This is all based on an article I referenced before, and the concept of a “critical bandwidth of the human ear,” which is well studied. However, my programming is preliminary and rough, so these images are by no means definitive. I hope to refine and improve them in the future, and using a more complete and accurate theory of critical bands.

The images each show the overlaps in the harmonic series above a three-note chord. The brightness indicates completeness of overlap and the colour indicates which notes’ series are overlapping: red for the root, green for the variable note M, and blue for the fifth. Therefore a magenta stripe indicates an overlap between the root and fifth, yellow is between the root and M, and cyan is between M and the fifth. A white stripe is where all three overlap, and a dim or murky stripe is where overlap is partial. It should be noted that this is based on my programming, and if I had made the underlying function more or less sensitive, it would change what we define as “partial,” and I will have to do so if I want to refine these. As it stands, the direct overlap between notes two semitones apart is very dim, kind of at the threshold of being an overlap. Under their hypothesis, these murky stripes in these pictures are what we hear as dissonance.

Major chord

The major chord shows something interesting, a white stripe near the top. And what is the top? 60 notes up. If you were to play the chord near the middle of a piano, the top end here would be near the end, which is also close-ish to the end of the human audible range.

Here’s a highly dissonant chord:

Chord with M=1, a note one semitone above the root

I have made a collection of these images on their own page. I find them fascinating, but they are less and less meaningful past M=6. I hope to find to way to visualize four-note chords and higher.

Now, for the programming aspect. Julia is a wonderful programming language that should appeal to all mathematicians and computer scientists for being about as easy to write and read as Python, yet compiling code that runs at incredible speed (like C and Fortran). I wrote my code by playing around in the Julia command line and collecting what worked in microsoft notepad, saving the program with file extension “.jl” instead of the usual “.txt” of windows text documents.

using ImageView, Colors, Images

mean(x...) = sum(x)/length(x)
# I couldn't be bothered to find the appropriate library or function

freq(x) = 2^( x/12 )
# This converts from note-space to frequency-space. For our purposes it doesn't really matter where we start, what matters is that going up N semitones corresponds to multiplying the frequency by 2^(N/12)

harmonic_weight(x) = (( cos(2pi*freq(x)) + 1 )/2 )^20
# This function makes a little bump around each harmonic of the root (x=0). We can shift this function to some other note's harmonics by subtracting the relative position of that note from x in the input

# Next is the worker function. We provide it three notes and it makes a colour-coded image of the overlaps in their harmonics
function harmony_vis(note1, note2, note3, resolution=0.025, distance=48, do_filter = true)
	x_space = 0:resolution:distance
	R = harmonic_weight.(x_space.-note1)
	G = harmonic_weight.(x_space.-note2)
	B = harmonic_weight.(x_space.-note3)
	Y = R.*G
	M = R.*B
	C = G.*B
	
	im = do_filter ?
		RGB.([R.*mean.(Y,M), G.*mean.(Y,C), B.*mean.(M,C)]...) :
		RGB.([R,G,B]...)
	imsquared = [im for i in 1:length(im)]
	return vcat(transpose.(imsquared)...)
end

Here is what using that looks like:

Harmony Inquiry Week 4: A Natural Cadence

This week, I discovered a nice little musical idea:

If you’re a musician, you may not find that particularly interesting, although, isn’t it unusually consonant? Let’s see what it is and where it comes from. Last time, we saw that in typical consonant chords, there are patterns in how the overtones of all three notes simultaneously overlap. In the cases of the sus2, sus4, and minor chords, the pattern is itself a harmonic series. This seems to indicate that the sounds of these chords each contain the sound of a related higher note.

ChordPosition of related note relative to the root
Minortwo octaves and a fifth up (31 semitones)
Sus2three octaves and a major second up (38 semitones)
Sus4three octaves and a perfect fifth up (43 semitones)

At my digital piano, I investigated how it sounds to play these chords and the related notes. To me, it does sound like a consonant relationship. I didn’t record any of that but I recommend trying it yourself if you are interested.

More interesting to me was what I saw above a major chord:

There are three almost evenly space tones of increasingly close overlap, at positions 38. 47, and 55. To make that more concrete, let’s choose a key. Above a C major chord, the related notes are D, B and G, which happen to be the notes of a G major chord. In the key of C, we call C major the One chord (I), and G major the Five chord (V). Moving from I to V is a standard way to create tension, and going back from V to I releases that tension, and is called a perfect cadence. But what we’ve found here is a that a Five chord played way high up should sound like it’s an aspect of the One chord. This suggested to me the existence of the smooth-sounding cadence you heard earlier.

Harmony Inquiry Week 3: Some Graphing

I got another useful idea in this article. Different tones within a sound stimulate different regions of the basilar membrane within the inner ear. If two tones stimulate partially overlapping regions, dissonance is perceived, and if they stimulate fully overlapping regions, consonance. The key is that natural sounds are composed of a series of tones, and the interaction between two sounds will have many overlaps.

Inspired, I improved on an interactive graph I’ve been working on in Desmos graphing calculator. Below is an example depicting how the overtones of a note relate to standard tuning. The units of the x-axis represent positions on a standard piano, so 1 to the right is a semitone up and 12 to the right is an octave. The solid black vertical lines represent the a root note and the octaves above it, and the peaks are the root’s overtones.

Overtones of the note at position 0

The more complex version of the graph shows some interactions within a chord. In the video below, we examine a chord with root note at x=0. The dashed vertical line is the chord’s fifth, and the dotted one is a movable note I’ll call M, which can be animated to change the quality of the chord. The different-coloured peaks represent overlaps in overtones: the green ones are from the root and M, the red ones are from M and the fifth, and the blue ones are from the root and the fifth. You’ll notice that the blue peaks are constant, since they come from the two unchanging notes (which, on their own, comprise a power chord). Finally, the black peaks are overlaps of tones shared by all three notes.

The overlap explanation is compelling here, but perhaps is an incomplete story. I notice that the most audibly dissonant chords (M = 1, 6, or 8) have a partial black peak under the first blue one, then a region where M interacts with just one of the power chord’s notes, and then chaos. On the other hand, the most consonant chords have their own series of black peaks. For next time, I’ll make recordings of what these chords sound like and explore some more of what these graphs might be telling us.

Harmony Inquiry Week 2: Online Research

I started my investigation by watching some videos on Youtube. This is how I learned much of what I know about music theory, and I find it can make information quickly and easily understood.

Here is one which does a good job explaining the idea I am investigating. The creator explains how to find the first few overtones of a note on a keyboard, and how to use them to play particularly consonant major chords.

A commenter said that notes of a minor chord share a common overtone. I investigated on my own keyboard and found this is true: two octaves and a perfect fifth above the root is an overtone shared by all three notes. I noticed that by dropping the chord’s third down an octave, we can make this overlap happen an octave lower, and it creates a very nice sound. In an example of how confusingly music theory uses and reuses numbers as names, what I made there is also called a “drop 2 chord,” because it drops the third, which is the second highest note. (It’s also the second note up. It’s called the “third” because it’s the third note of a major scale starting at the root 🙄.)

Next I looked for articles on Google Scholar. I found this one, which is fairly compelling and explains the history of main scientific hypotheses for our experience of consonance and dissonance. I also started reading this one, but didn’t get very far through it before I was distracted by an idea from it. In audacity, I messed around with some sounds to see what pitch I perceived when a sound wave was played containing a periodic gap.

the audio clips played are as follows:
440 sine: a sine wave at 440 Hz
gapped sine:
the same sine wave but with a gap of half a period inserted every four cycles
98 string: a combination five sine waves in decreasing intensity and increasing pitch, meant to roughly resembling the overtones of a string with fundamental frequency 98 Hz. They are 98, 196, 294, 392, and 490 Hz. I made this because I noticed that pattern in the spectrum of the gapped sine wave.
saw 440: a sawtooth wave at 440 Hz
gapped saw: same sawtooth wave, gapped the same way as earlier
saw 391: a sawtooth wave at 391 Hz, which is theoretical frequency of the “long pattern” that comprises the four cycles and a gap. Notice it is also very close to the third harmonic above 98 Hz. If my method of introducing a gap in the sound had been more exact, I expect those numbers would have been identical.

Here is another video I skimmed. I didn’t really like the presentation and knew most of the content already. However, for someone who is new to music theory or its associated math, it could be a good crash course.

Finally, I found a this music stack exchange thread which indeed places the minor chord within a harmonic series. I haven’t quite understood where that fits on a keyboard yet but I expect to at some point.

The beginning of a music and math inquiry

A warning: this first post is not educational. I won’t fully explain the meaning of the things I’m saying. Understanding it all will require knowing a little music theory.

I’m interested in the relationship between the overtone series and common chord types in western music. A major chord actually appears in root position within the overtone series of the note two octaves below the chord’s root, while the minor chord is a little more mysterious.

Questions to investigate:

  • Can a minor chord be related back to a base note the same way?
  • If not, what is it closest to?
  • What overtone patterns are there between chords in common chord progressions?
  • What can these relationships tell us about the nature of harmony and dissonance?
  • Can we use the answers to any of these questions to help us compose music?

In addition to doing research online and asking knowledgeable people for guidance, I would like to investigate the math myself, using technology, and hopefully create some useful educational resources.