Skip to content

Tag Archives: music theory

A not inconsiderable divergence from the original theory, but it certainly keeps things simple implementation-wise :)

Lerdahl, part 2

This is a sequel to this post on Lerdahl’s GTTM.

Okay…apologies for the delay…I was busy, but also was uncretain whether I understood the material myself, that stopped me from saying more. Additional disclaimer: I’ve tried my best to pull out all the melody and counterpoint related content of the theory to leave things chordal. I’ve savaged the original theory in the process. Apologies to all affected by my act of gross violence.

Prolongation Trees

Okay, so what is a prolongation tree? They look like this:


Continue reading ›

First part of three.

Lerdahl, part 1

(serialized from this tigsource thread)

I couldn’t find any nice stuff on-line, but I’ve been meaning to properly go through this stuff myself for a while, so I’m happy to have the excuse to learn something about it (Disclaimer: all of what I’m saying is a filtered version of what Lerdahl says in his book, both through my misunderstandings, and my understandings of what might be useful to Muku in his PG music program (This is primarily a response to a request made by him for info on this stuff, but of course I’d love if other people were to chip in and comment)).

Continue reading ›

Tigsource articles, that will appear here anyway, can be found here, if you can't wait for me to copy and paste them on here.

GTTM-based Chord Progression Generator

I’ll be posting some articles about the theory of Lerdahl very very soon. In anticipation of them (and to put something up so I can submit it to the Haskell Activity Report), here’s my implementation of a toy-model based roughly around his theory. It’s restricted to the process of chord generation.

Here‘s a simple playing by me of a chord-sequence that it produced. Here‘s a midi example that it produced by itself when I had it more developed.

There’s still a reasonable amount of work to be done on it, but it’s at a stage where it’s presentable.

Anyway, the current version of the haskell source code is here. Hopefully I’ll have more developed versions up in the future.

And that's also what I was alluding to with the pictures of directed graphs back there a few posts ago.

In which the hero sketches something, for he hath not the strength to venture, unbidden, into more detail. Gerbes? He thinks not.

Hmm. This is going to be harder than I had initially thought now that I think of it. Basically, given three melodies that work in counterpoint they are written on three staves, one above the other. And we have the identity that the interval between the lower and middle voice added to the interval between the middle and upper voice will give the interval between the lower and upper voice. And we have rules that relate how these voices should interact with eachother.

However, one can still apply most of the rules quite well if we make things a little bit abstract and no longer require the above relationship [a,b]+[b,c]=[a,c] to hold, but rather that it hold only up to a certain constant interval I.

And what’s the sense in this? Well with this you still have three melodies, only now instead of all three being contrapuntally amenable, we have that any two of them are. I haven’t seen this expounded elsewhere, and given how practical it seems I thought I’d mention it here.

And why the devil did I want to mix up Fuchs with cohomology? Well, I was trying to figure out an easy example of a Gerbe :) (I failed, as it happened, but it’s quite teasingly close!).

And why this rambley ramble here as opposed to something more deliberate? Because I’ve been meaning to post this since November last year, that’s why. So this means I get to relax about it now. Chill, you know? And if anybody should wish for any explication I would be Only Too Happy to provide it.

Hmm. Pity there isn't any proper measure of consonance, Euler :/

Consonance-preserving maps.

Grrr. Baaad program. But I’m putting it up anyway, because it’s not *that* bad.

Basically, say we had a scale, and a gradus suavitatus on that, a measure of consonance, so that given any two intervals, you can say if one is more consonant than the other. Now given two scales, it might be a worthwhile thing to look for things that preserve relative consonance; that is to say, a function f from one scale to another will have to satisfy the rule a>b => f(a)>f(b).

So, I wrote a program to do it. No interface yet, it’s to be run from within ghci; specific details of how to use it are given (in a very rambling sort of way) at the top of the source code. It seemed like it might be most useful in looking for interesting transformations of melodic motives that have a small number of notes. However, I can’t say I have been able to do anything useful with it, alas.

For an example of the program’s output, see this file:

Harmony-preserving maps example ( ps | pdf ).

For the code itself, here’s the source file:

Harmony Preserving Maps Generator V0.1 ( hs )

So yeah. Out.

I always like when I can bring (structured) graphs and cohomology into the picture. Yeah. : )

A quick tutorial, and a piece

So, I link two things here; firstly a sort-of tutorial for the counterpoint analysis program (more a worked example):

Counterpoint Analysis Program Tutorial/Fugue in Eb ( PS | PDF )

It should make the program make rather a lot more sense. Oh, and for the record, I don’t dislike the piece as much now as I did when I was writing the tutorial.

and, secondly, a rather dull affair:

Waking ( PS | PDF )

Well, that’s it for now. Have another compositional tool I’ve just finished, but want to see if I can do anything with it before putting it up.

It was a pleasant experience, writing this program.

Counterpoint Analysis Program

Counterpoint Analysis Program

V0.1 as of June 01 2007

So, this is a program that, when you input various melodies, will attempt to find contrapuntal relationships between them. I use something like a slightly weakened version of the 1st species counterpoint rules of Fuchs for this. As you may guess from the version number, this program is chiefly for my own use. However, I think it’s usable enough that it’s conceivable that other people might also use it. Oh, disclaimer: it doesn’t always (or even mostly) give great counterpoint examples, but that wasn’t so much the motivation; I wrote it because I’m never sure when writing fugues that I’m not missing some particular combination of themes that sounds especially nice; with this, I get straight away a bunch of combinations to play about with; many which I wouldn’t have seen without it I think (of course, I won’t limit myself to what this program outputs, but it’s a very good starting point I think), this makes it useful as a compositional tool for me.

No, no no, don’t expect any pictures (yet); it’s a console program (so far), so! And please, if you’ve anything to say about it, don’t hesitate to say it, either here or via email – I’m unlikely to do any work on it otherwise (as it fulfils my personal needs rather well in its current form).

Download Zip – Contains windows binaries, basic documentation, and Haskell source (should you wish to recompile it on a different platform).

Worked Example

He had peppers on the mind. Don't...don't we all?

My favourite calculation: Combination tones

Hmm, so in the interest of subscribing to this mathematical carnival what’s doing the rounds now, I’m writing something specifically mathematical in nature, my favourite elementary derivation. I’m trying to make it understandable and brief – if anyone is having trouble following, I can help in the comments.

Okay, so lets say we’re hearing a signal given by f(t); let’s assume it’s periodic. Now, to monitor what we hear, we have to view this as a sum of sine waves

f=a*sin(t)+b*sin(2t)+c*sin(3t)+ …

so a,b,c represent the frequencies we hear of frequency 1,2,3, etc, and the bigger the coefficient the bigger the amplitude.

Lets look at two really simple sounds, pure sine waves of different frequencies sin(at), and sin(bt). SO, they each have exactly one frequency present.

Now, so what if there were some non-linearity of our hearing system. That is what if, when someone plays f=sin(at)+sin(bt), we don’t actually hear this, but rather something more complicated.

So, the simplest way of such a thing being non-trivial is to introduce a quadratic non-linearity (ignoring coefficients…we’re thinking that because “all” functions can be taylor expanded as f(t)+f(t)2/2+f(t)3/3!+…, the next best thing to having just f(t) is to having the first two terms).

So, anyway, now when someone plays a signal f(t), we don’t hear f(t), but rather f(t)+f(t)2

So, what results from this? Well, we have to break down f(t)+f(t)2 to being a sum of sine waves first.

f(t)+f(t)2=sin(at)+sin(bt)+ (sin(at)+sin(bt))2

looking up trig tables and decomposing further we get (ignoring coefficients)


Ah, so look at this. We might be led to deduce from this that, if non-linearities were present, when someone plays two frequencies at the time, we will also perceive sounds playing at double either frequency, their sum, and their difference.

Now, the multiples of a and b can be reasonably expected to be masked by overtones (though it is possible to bring them out), but the difference (and, to a lesser extent, the sum), on the other hand, can be controlled very easily, just by bringing the two source sounds closer together or further apart. And, indeed, we can quite easily hear them.* Which is darnedly neat.

I like this calculation so very, very much because it’s surprisingly fruitful; whenever I feel like I’m loosing my faith in the power of Taylor expansions, I go through this derivation again.

The phenomenon was first noted by Tartini, the derivation was by Helmholtz, and these extra tones are sometimes called Tartini tones or, more commonly combination tones.

What’s also interesting, by the by, is that these effects are actually quadratic: I remember, the first time I heard an example (they can be found on the interweb quite easily, here for instance), I was listening to them with earphones, and the strength of the combination tone totally overwhelmed the two base ones. But, when I played it on speakers, it was much weaker relative to these tones, and if I went too far away, I couldn’t hear it at all.

*okay; this is a lie, actually the third order terms are the easiest to hear, corresponding to things like 2a-b…and there’s an explanation for this (check out Dave Benson’s notes if you want to know more).

Some day I'll reach a point where his program as a whole makes some sense to me, I hope.

Modulations in Music; an analysis of the Mazzola/Muzzulini approach. [unfinished/abandoned]

[I just saw this lying about in my drafts folder. I figure I’d backdate it and stick it up, even though it’s not finished (I have no current intention of finishing it nor desire to do so)].


Schoenberg always envisioned modulation as a four-part process

1) You establish what key you’re going to be leaving.
2) You use only notes common to both, so as to neutralize the old tonality.
3) You enter your new key.
4) You cadence in your new key.

There is a paper by D. Muzzulini [1] which attempts to give a mathematical refinement of this model, claiming still that it agrees with Schoenberg’s original conception in all of the examples in his book [2].

His refinement involves what notes of the new scale you are allowed to use in stage 3. I will define a slightly dumbed-down version of it in the first section, and then try to fit it within a much weaker framework involving iterated transformations which seems to me to be somehow more intrinsically musical, though I do not pretend that the ideas herein are either a) original or b) have any historical justifications. I will finish up by saying in what way a weakened version of Mazzola’s system can be situated within this framework.

Now down to business.

Mazzola’s Model

Two scales, S and T say, that differ by a translation.
A translation/inversion f that maps S bijectively onto T.
A cadential set* c of S

*a cadential set for S is some minimal subset that is in only S and no other scale related to S by translation.

The quantum Q, if any one exists, is defined as being the minimal set with the following requirements:

A) f:QQ bijectively.
B) cQ.
C) QT has no translational/inversional symmetries.
D) Every note of QT is harmonizable with some chord in QT.

The of this is that the notes that we can use in stage 3 are, according to him, give by the set QT.

His evidence for this approach is that, according to him Schoenberg many, many examples of modulations, given in [3], all conform to his approach. Of course, Schoenberg never talks about modulation in this way, doing in mainly be considerations of voice leading – certainly never being too interested in T/I transformations between scale types. And he doesn’t make any efforts to musically justify his axioms, so boo-urns to him for that.

An Iterated Transformation Model

Now, in this model, I’m going to leave the manner of establishing the old and the new key out; the parts of the modulation I’m interested in will look like

1) You’re in your old key
2) You use only notes common to both, so as to neutralize the old tonality.
3) You’re in your new key.

Essentially, all I’m going to do is choose some translation f, and some subset of notes Q of S such that under repeated applications off Q goes through each of the stages above.

Say we have that Q is in S, f(Q) is in ST, and ff(Q) is in T. There are few different ways of using this to modulate. We could just take these to be background scales which we might restrict ourselves to the images of Q, using them as chords or scales to which we are temporarily constrained in moving (Ex. 1) or, more strongly; we could have some melody/pattern played initially in Q, and then apply the transformation to this pattern until we end up in our new key (Ex. 2); or we could just play Q and its transpositions as block chords directly (Ex. 3), or in various inversions (Ex. 4).

General Iterated Transformation Structures

So I can see a few differen other ways that one might be able to do the same sort of stuff. If you can get the first few images of Q to be in the initial key, so that you can emphasize the transposition pattern enough, you might want to skip the transition phase giving a 2-phase transition (Ex. 5), or break out of the two scales entirely (Ex. 6, 7).

I’d call the last situation an extrinsic transport between two tonalities, as opposed to the original idea, in which the transport was somehow intrinsic to the two scales.

More saliently for Muzzulini’s theory, it might make sense, if there aren’t too many notes missing from S or T, to restrict one’s self to working (maybe once one has entered the neutral phase) with the intersection of the images with T (Ex 8).

here I sort of trailed off … here were the things I told myself I would have added had I finished this properly:

3-phase modulation
intrinsic/extrinsic/hybrid modulation

[1] Mazzola G. et al., The Topos of Music, Birkhaueser 2002
[2] Muzzulini D., Musical Modulation by Symmetries. Journal for Music Theory 1995
[3] Schoenberg A., Harmonielehre (1911). Universal Edition, Wien 1966.

Maths & Music Talk

On the 7th April 2005, I gave for the Maths Society a talk with the above title. Below I link to two files, one a rough outline of what I talked about, the other a relatively detailed bibliography describing some good books in a few diverse areas related to music theory.

Outline [ PDF ] [ PS ]

Bibliography [ PDF ] [ PS ]