Skip navigation

Monthly Archives: July 2012

Unlike the overtone series of the previous post, there is nothing physical or natural about the undertone series, despite its very similar construction.  The overtone series consists of notes at frequencies f, 2f, 3f, 4f, and so on; the undertone series, on the other hand, consists of notes at frequencies f, f/2, f/3, f/4, and so on.  The undertone series is the mirror image of the overtone series.  If you start at one particular note and go up for the overtone series, you’d go down by the same amount for the undertone series.  It’s available in the Offtonic Microtonal Synthesizer as Undertone (C8).

Read More »

I’ve added a new scale to the microtonal synthesizer for your enjoyment.  The preset is called Harmonic (C1), and it’s the first 127 notes of the harmonic scale beginning at C1.  I think it’s pretty cool!

Before they invented valves, trumpets were limited to only playing certain notes.  A trumpet in C could maybe get a low C3 out (it sounds kind of terrible), but it could play its first few harmonics fairly easily.  Middle C (C4), G4, C5, E5 (a bit flat), G5, Bb5 (very flat), C6, D6, E6, Ft6 (that’s F half-sharp), G6, Ab6, A6, Bb6, B6, C7, …  Actually, it’s REALLY not easy to play that high, but you’ll notice the notes are closer together as you go up.  What’s going on?

Read More »

EDIT: It’s now available at the Sibelius website, too!

My first Sibelius plugin has been released!  This deserves an exclamation point because it’s SO COOL!!!!!!!1  Check it out:

Offtonic Plugins for Sibelius

…Didn’t really deserve that exclamation point, did it?  Well, TIL that making plugins for Sibelius is really, really easy.  The ManuScript scripting language that it uses is quite simple (though its differences from, say, Javascript are kind of annoying, like the single equals sign for comparisons).  My one complaint about the process is the horrible and buggy coding environment, but I hear that’s fixed in the new version of Sibelius, which I don’t have.

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 »

I have recently had the misfortune of trying to write an equation programmatically, and in this tutorial, I will allow you to share my misfortune.  I say “misfortune”, but really, I should just have used a text editor and made an image; however, I felt that I should at least figure out how to do it.  The result, unlike the code, was pretty:

Pell-Type Equation, Pretty

The generic Pell-type equation, pretty-printed

The idea here was to use this equation as a header label for my Pell solver (upcoming).  It’s just static text against the default background of an Aqua window, like a Label in Interface Builder, except that the Label object has fixed height and therefore can’t hold this enlarged text with superscripts, so instead, I made a custom NSView subclass to draw it.  (There are probably better options, like multi-line labels.)  By the way, note that I’m using ARC, so if you’re not using it for whatever reason, you’ll have to handle the memory management yourself. The basic code for the subclass:

Read More »

The Microtonal Synthesizer has been updated.  I used it to explain to someone how to listen to beats and realized that I couldn’t set the cents of notes.  Turned out I was forgetting some factors of 100 in one of the functions handling the text fields, and “50” was magically changing to “0.05”.  This is now fixed.  (Update: as I was writing this post, I noticed that changing the frequency of a note wasn’t working.  It should be now.)

So I might as well explain how beats work.  Let’s say you have a note at some constant frequency of f.  This means that you have some sort of wave that repeats at a frequency of f; if f = 440 Hz, then the wave repeats 440 times per second.  It’s not a simple sine wave; the shape of the wave is what gives instruments their characteristic sounds.  A sine wave sounds more like an “ooh”, while a brighter sound like “aah” will be a more complex shape.  For now, though, let’s assume we’re talking about simple sine waves.

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 »

On a housekeeping note, you’re probably seeing the default WordPress theme.  That will change.  Eventually.  Please be patient!

EDIT (7/19/2012): New theme.  It would be nice if the sidebars were actually on the side, but it at least looks nicer…