Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use coords internally to represent notes and intervals #37

Merged
merged 5 commits into from
Jul 8, 2013

Conversation

saebekassebil
Copy link
Owner

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 TeoriaNotes 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.

@gregjopa
Copy link

@saebekassebil great work! I have no objection to these changes. This opens up the door for adding support for different temperaments/microtones.

I'd like the unit tests you have. I think it would be fun to add some audio tests as well using the web audio api and also add some audio to http://saebekassebil.github.io/teoria/.

saebekassebil added a commit that referenced this pull request Jul 8, 2013
Use coords internally to represent notes and intervals
@saebekassebil saebekassebil merged commit 8c029dc into master Jul 8, 2013
@saebekassebil saebekassebil deleted the coords branch July 8, 2013 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants