There are plenty of books about sci-fi music – particularly film scores, or songs with SF-inspired lyrics – and the “science” of music in the sense of acoustics and the physics of sound waves. I’m not trying to compete with books like that. As I said, I’m more interested in three-way overlaps, which narrows the field considerably. The picture above shows some of the research material I’ve been consulting!

In a blog post last year I talked about symmetric musical sets – such as the tritone, the augmented triad, the diminished 7th, the whole-tone scale and the chromatic scale – which divide the octave into 2, 3, 4, 6 and 12 equal parts respectively. For various reasons musicians dislike these groupings, so they’re used very sparingly in classical music and virtually never in pop music. But as someone who’s always been more into maths than music, I’m fascinated by any kind of symmetry.

Traditionally the octave is divided into 12 semitones, so the symmetric sets I just mentioned are the only possible ones. But what if you wanted to divide the octave into 8 equal parts? That seems an obvious choice, because it’s what the word octave implies. But to do it we need to invoke quarter tones. There are 24 of these in an octave, and 24 divided by 8 is 3, so we’re looking for notes 3 quarter tones (or one and a half semitones) apart.

Writing music in quarter tones isn’t easy, because the MIDI format defines pitch as an integer number of semitones. But it does allow something called “pitch bending” (presumably to simulate bending the string of a guitar), and with a bit of patience you can use that feature to raise the necessary notes by a quarter tone.

Here’s a short (1 minute) piece I wrote to see what it would sound like. It’s basically a random composition using the 8 equally spaced notes shown in the diagram above.

When Eric Morecambe mangled Grieg’s Piano Concerto on a TV special in 1971, he insisted he was “playing all the right notes, but not necessarily in the right order”. That’s a valid point, because there aren’t that many different notes on a piano and the only thing that distinguishes one tune from another is the order in which you play them.

To a mathematician or computer programmer the situation is crying out for quantitative analysis. The diagram above shows the “transition matrix” for one specific Beatles tune (using the MIDI standard where middle C is C5). It’s clear there’s a lot of order here. One thing that jumps out is that there’s only one “black” note, G#5, and it’s always followed by A5. In fact A5 is a very popular note, cropping up after no fewer than 8 different pitches. On the other hand, G#5 itself is very rare, only ever coming after D6, and then only 6% of the time.

As well as analysing the original tune, this allows us to write a new tune of our own using the same transition matrix. The result (as the aforementioned mathematicians and computer programmers will recognize) is a first-order Markov chain. Producing an algorithm of this type from scratch would be rather tedious (as indeed the initial analysis would be), but fortunately there’s some free software called OpenMusic which includes built-in Markov functions that make the process much simpler.

Of course, there’s more to a tune than the pitch of the notes – there’s the duration of a note too. But that can be analysed and reproduced by exactly the same method. I experimented with an algorithmic composition of my own, based on the Beatles song analysed above. As a first step, I used the OpenMusic Markov functions to generate a series of tune-fragments for both the “right hand” and “left hand” of the piano. Then, to give the composition some structure, I arranged the fragments in a rough approximation to classical sonata form.

I won’t say what the original song was, because I want to see if anyone can guess it. As a hint, I’ve inserted a brief quotation from the original at the mid-point of the piece. Here it is on YouTube:

I mentioned musical set theory in a previous post, and now that I understand it better I’m getting very enthusiastic about it. It’s a really powerful technique for analysing and composing music. The mathematical connection may give the impression that it “dehumanizes” music by imposing mechanistic constraints and artificial rules – but the exact opposite is true. It’s traditional music theory that forces arbitrary rules and constraints on you – set theory liberates you from them. It’s a framework for organizing your own creativity – with no rules whatsoever.

I’ll explain how it works in a moment, but first a few words about my sources. The bible of the subject is Allen Forte’s The Structure of Atonal Music, which is divided into two roughly equal parts. The first is packed with useful stuff, although the second part was much too advanced for me. But Forte’s book is really about musical analysis, and what I was interested in was composition. On that front, I found a great little book by Stanley Funicelli called Basic Atonal Counterpoint (which is a CreateSpace book, but very professionally done). I also found a lot of practical tips on Frans Absil’s YouTube channel – he also produced the Pitch-Class Set Graphical Toolkit you can see on my iPad in the photograph above.

Musical set theory starts from a few basic observations:

The notes of the chromatic scale can be represented by integer “pitch-classes”: C = 0, C# = 1, D = 2 etc. After B = 11 you get back to C = 0, so additions and subtractions have to be done with mod-12 arithmetic.

Intervals between pitch-classes are much more important than absolute pitches. So C major [0, 4, 7] and E flat major [3, 7, 10] are just different transpositions of the same set (it’s called 3-11).

Inverting an interval (i.e. subtracting it from 12) doesn’t change its basic nature. So interval 7 (perfect fifth) can be grouped with 5 (perfect fourth), interval 8 (minor sixth) with 4 (major third) etc. This leaves us with just six “interval classes”: 1, 2, 3, 4, 5, 6.

The characteristic sound of a set is mainly determined by its interval vector. For example, the major chord 3-11 = [0, 4, 7] has an interval vector 001110 (one minor third, one major third, one perfect fifth and nothing else).

Traditional Western music depends heavily on set 7-35 [0, 2, 4, 5, 7, 9, 11] – the white notes on a piano, aka the major or minor scale (remember you can transpose these notes up by any integer between 1 and 11 to get all the other major and minor scales). Within that 7-element set, there are a number of strongly favoured subsets – most notably the aforementioned 3-11 (the major triad and its inversion, the minor triad).

The purpose of set theory should be obvious now. It gives you access to dozens of other sets, all with their own unique sound. You might think “but they’re going to sound terrible”, and in some cases they do. Set theory helps you to avoid the terrible-sounding ones! But there are some great-sounding sets that simply don’t exist in traditional music theory, such as 4z-29 = [0, 1, 3, 7], with an eyecatching interval vector of 111111.

To teach myself how the system works, I wrote a short “symphony” using the above ideas. It’s my first ever musical composition, and the result sounds a lot more interesting than if I’d struggled with all that traditional stuff about sharps and flats, majors and minors, dominants and subdominants etc. That wouldn’t have told me how to get close to the kind of spooky, spacey, quirky music I wanted to write.

I recently came across the idea of applying set theory to musical analysis (which apparently has been around for some time, although I’d never heard of it before). For most people, who have a stronger intuitive grasp of music than mathematics, this must seem a pointless exercise, but for anyone like me who’s the other way around it’s really very illuminating.

Take symmetry, for example. In most areas of the arts and sciences, symmetry is seen as a good thing – but in music, that’s not the case. All the most popular chords are asymmetric in terms of interval content. You can see that in the left-hand image above, which shows the three notes of the C major chord on the chromatic circle. They’re separated by intervals of 3, 4, and 5 semitones.

In contrast, an augmented C chord, shown on the right, is perfectly symmetric, with all three intervals equal to 4 semitones. The problem (as far as musicians are concerned) is that it’s not very firmly tied to C major. It could equally well be A flat or E major. In the same way, the four-note symmetric chord C – E♭ – F♯ – A can be interpreted in four different ways: as Cdim7, E♭dim7, F♯dim7 or Adim7.

There’s even a completely symmetric two-note interval, in the form of the tritone, consisting of two notes 6 semitones apart (or 3 whole tones, which is how it gets its name). That’s exactly half an octave, for example from C to F sharp. But it’s also the distance from F sharp to C, so you really don’t know which key you’re in. That’s why composers spent centuries trying to avoid it. They called it diabolus in musica, or “the devil in music”.

Being a symmetry-loving scientist rather than a musician, I decided to try writing something that consisted only of symmetric chords. It’s a sort of canon, in the key of everything.

Here’s a link to a YouTube video, with added graphics depicting the various chords on the chromatic circle. Hopefully you’ll enjoy the graphics even if you don’t like the music!