saebekassebil/teoria — pull request #37 by saebekassebil (2013-06-24 18:57:14+00:00)
Title: Use coords internally to represent notes and intervals

This took a lot of work, but I've finally got around to finishing this up.

This pull request breaks *a lot* of the old API, by replacing many properties (such as `TeoriaNote.octave`) with functions (now `TeoriaNote#octave()`). This is due to the internal representation of a `TeoriaNote` and a `TeoriaInterval`. Both of these objects now have only **one** property: `this.coord`.

The `coord` property is an array with two elements: `coord[octaves, fifths]`. Using octaves and fifths, it is possible to represent all notes (at least in the 12TET), with an arbitrary number of accidentals. All `TeoriaNote`s are now relative to the concert pitch, A4, which is the origo of the coordinate space:

teoria.note('A4').coord -> [0, 0]

This API change has made it possible to remove a lot of tables from the code, which is great, because it leads to less redundancy.

I'd like to thank @gregjopa for his music.js, which I've borrowed the idea of representing notes with coords, from.

If there's no objections to these changes, I'll probably pull this, later this week.

/cc @gregjopa and @quickredfox whom I believe I've discussed this issue of abstracting out the note names with.