Skip navigation

Category Archives: Math

To be fair, the new plugin is the same as the old one but with different numbers.  I’m planning on making a Sibelius plugin factory at some point, to allow custom plugins.  For now, though, enjoy the ability to write in 17-tone equal temperament!

Though “temperament” is a bit of a misnomer, because while 17-TET certainly sounds like it has quite a temper, it doesn’t actually temper out anything useful.  Here are the names of the 17 notes of 17-TET:

C Db C# D Eb D# E F Gb F# G Ab G# A Bb A# B (C)

If you’ve read my previous post on the mathematics of diatonic tunings (and actually understood my ramblings), you might remember (or not) that our diatonic 12-tone system depends on two kinds of half steps, the chromatic, from C to C# where the note name doesn’t change, and the diatonic, from C to Db where the note name does change.  The chromatic half step is seven fifths forward in the circle of fifths, and the diatonic half step is five fifths backward in the circle of fifths.  In 12-TET, there are only 12 notes, so those two half steps meet at the same notes, and they’re enharmonic.  C# is the same as Db, just spelled differently.  In other diatonic tunings, though, the chromatic and diatonic half steps have different sizes!  In n-TET, the circle of fifths has n notes.  Each diatonic half step steps backwards 5 fifths, and each chromatic one steps forward 7 fifths, so if your chromatic and diatonic half steps meet after c chromatic ones and d diatonic ones, there are n = 7c + 5d notes in the circle of fifths.  Heh, like that derivation?  Anyway, one of the values of n is 17, where equivalence is reached in 1 chromatic and two diatonic half steps because c = 1 and d = 2.  1 chromatic half step from B is B#; 1 diatonic half step is C and two is Db.  In 17-TET, B# = Db.  Kinda weird, isn’t it?  c and d are also the sizes of the intervals in 17-TET steps.  The chromatic half step is 1 17-TET step and the diatonic is two.  This explains the weird order evident in the note names.  I excluded double flats and double sharps (as well as Cb, E#, Fb, B#), but it’s easy to see where they go.

Problem number 1 with 17-TET: the major triad.  Let’s look at the cent values: the major third is 423.5 cents and the fifth is 705.9 cents.  12-TET has 400 and 700, and JI has 386.3 and 702.0.  The fifth is a little sharp — not much sharper than the 12-TET fifth is flat.  You barely notice it if at all.  But the third is 23.5 cents sharper than 12-TET and a ridiculous 37 cents sharper than JI!  It resembles a major third but it’s REALLY out of tune.  19-TET has a pretty close fifth as well, but its major third is 378.9 cents, closer to JI than 12-TET.  When you hear a major chord in 19-TET, it’s very consonant; in 17-TET, it’s an elementary school class of violinists.

So, you have to wonder: how would the second movement of Beethoven’s Sonata No. 8 “Pathetique” sound in 17-TET?  Well, it’s fairly odd that you were wondering that, but that’s OK because it’s right here:

Sonata No. 8 – II (12-TET)

Sonata No. 8 – II (17-TET)

Sonata No. 8 – II (19-TET)

These recordings were made in Sibelius; the 17-TET and 19-TET recordings using my plugins for the respective purposes.  It’s really easy to retune: select all, apply the plugin, done.  (So long as you wrote the music with one note in a staff at a time, anyway; I also had to transcribe the E major section as being in Fb major to keep spellings correct.)  Hopefully they give a good sense of how 17-TET works.

And that is that it doesn’t.

17-TET is AWFUL for tonal music.  Most of the piece is beautiful major chords, and if there’s one thing that sounds awful in 17-TET, it’s major chords.  Minor chords aren’t as bad.  17-TET does have a neutral third that sounds good, the D# (which is the same as Ed, E half-flat).  However, 12-TET does not have a neutral third, so Beethoven wasn’t gonna use it!

Note that 19-TET sounds considerably better.  The intervals that most diverge from their 12-TET counterparts are the half steps, both diatonic and chromatic (12-TET: 100 cents, 19-TET diatonic: 126 cents, 19-TET chromatic: 63 cents, 17-TET diatonic: 71 cents, 17-TET chromatic: 141 cents).  The sonata movement has a few chromatic passages, and it’s really obvious.  17-TET deals pretty well with leading tones, actually, which 19-TET doesn’t, but 17-TET makes up for it by totally destroying the major triad.  19-TET has better major triads than 12-TET!

Of course, you can write great music in 17-TET.  You can; I haven’t yet.  I will post when (and if) I do.  One thing that is painfully obvious upon hearing retunings of 12-TET music is that music conceived in 12-TET probably sounds better in 12-TET, and other ideas need to be worked out for other tuning systems.  With the Offtonic 17-TET plugin for Sibelius, you can play as you will!

A while ago (a long while ago, I guess — hey, I have a job, so I’m busy), I posted about how 19-tone equal temperament is a diatonic tuning.  But is it the only one?  Other than 12-TET, that is?

Obviously not.  Let’s take a look at how it works!

Under our harmonic system, we base everything on the fifth.  A perfect fifth is a frequency ratio of exactly 1.5, which translates to about 701.955 cents.  Our 12-TET scale only uses multiples of 100 cents, so it approximates the perfect fifth quite well at 700 cents.  This is far from the only possible value, however!  There’s a small range where we can arbitrarily choose our fifth, and that’s what we’re about to explore.

Read More »

I have just recently written a Sibelius plugin that allows playback in 19-tone equal temperament, Offtonic 19-TET.  The 19-tone scale has also been available on the Offtonic Microtonal Synthesizer since its creation.  So what is it?  What is it about?  What is the deal with 19-tone equal temperament, or 19-TET?

To begin with, there are many ways to generate an EDO, an Equal Division of the Octave.  The most obvious way is to simply divide the octave into n equal parts, and voilà, n-TET.  You can think of this as starting from note 0 and adding 1 each time, and when you get to n, that’s really the same as note 0.  For example, in 12-TET, I can start at C:

Read More »

Offtonic Pell Solver has been released!

Tired of the endless waiting?  No?  Well, if you had been, you could have stopped waiting now, provided you have OS X 10.7 (Lion).  This initial release solves a general Pell-type equation by finding all solutions when there are finitely many, and when there aren’t, it finds all of the fundamental solutions and generates an arbitrary number of new solutions from those.

Currently it only works for parameters up to 2^31 (and this is not changing anytime soon due to the difficulty in factoring such large numbers), and the solutions can go up to 2^63.  This latter limit will change to arbitrary size once I implement a large numbers library and rewrite my Pell solver to use it.  That’s the next version.

Read More »

My Pell solver is only supposed to solve Diophantine equations, which are equations with integers. I have some text fields for the parameters, and NSString deals with this just fine: to get the integer value from a text field, simply do:

int n = [[nField stringValue] intValue];

This assumes that you have an IBOutlet NSTextField *nField to read from. This works pretty well; the parser stops when it encounters something it doesn’t like, so if you type in “foo”, n will just be 0. You won’t get errors. However, it doesn’t look so good for the user when this happens. You can use a number formatter to make sure the user can only type in valid integers. Here is a complete implementation of an integer formatter:

Read More »

Offtonic Pell Solver has been released!

(Part 1)

We’re solving x^2 – Dy^2 = N.  We’ve gotten the very easy cases out of the way: N = 0, D = 0.  We’ve gotten the easy cases out of the way: D < 0, D = d^2.  This leaves only the situation where D is a non-square positive integer and N is nonzero.  As we will see, this one is legitimately complicated.  A Pell equation is one where N = 1.  Such an equation always has a solution.  Now let’s suppose (x,y) is a solution to x^2 – Dy^2 = N and (r,s) is a solution to x^2 – Dy^2 = 1.  If u + v sqrt(D) = (r + s sqrt(D))(x + y sqrt(D)), (u,v) will also be a solution to x^2 – Dy^2 = N.  In other words, you can combine a solution of the original equation with a solution to the N = 1 equation to create a new solution of the original equation.  And you can do this forever: if a solution exists, there is an infinite number of them.  Luckily, it turns out that those infinite solutions are organized: there is a finite number of fundamental solutions, and each of those can generate an infinity of solutions by combining with the N = 1 solution.  Our task, then, is to (a) find the N = 1 solution (the N = -1 solution is important as well, if it exists), (b) find the fundamental solutions, and (c) combine them.  We can do (c) very easily using the formula above; the challenges are (a) and (b).  But first, there’s an algorithm called the PQa algorithm, and there are various equivalent formulations of it.  The one I will show is the one from John P. Robertson’s paper:

Read More »

Offtonic Pell Solver has been released!

(Part 2)

For my inaugural instructional post, I want to tackle a mathematical problem: solving Pell-type equations (with a computer, not by hand).  What do I mean?  I mean equations that look like this:

x^2 – Dy^2 = N

where D and N are integers and x and y are nonnegative integers.  This makes it a quadratic Diophantine equation, and as it turns out, they’re not so easy to solve.  I came across some of these critters in a Project Euler problem a while ago (no, I won’t tell you which one), and I looked up how to solve them.  Well, maybe my Google-fu is not strong, but I didn’t find anything easy to understand.  There were a few incomplete references, a few references that didn’t explain much, and some papers with quite a bit of theory.  I eventually found this paper (Solving the generalized Pell equation x^2 − Dy^2 = N, John P. Robertson, 2004) that made sense, and I distilled it into an algorithm.  This method is mostly based on Robertson’s.

Read More »