saebekassebil/teoria — pull request #17 by nick-thompson (2013-01-16 20:38:36+00:00)
Title: teoria.note.fromMidi()

Is there any chance you would consider adding a note.fromMidi method? I would love to use this library in some Web Audio API projects, and the more I play around with the Web Audio API, the more I find the Web MIDI API (http://webaudio.github.com/web-midi-api/) useful. My suggestion is small, but it would make interfacing Teoria with the Web MIDI API much cleaner.

I think it would be a very simple feature. If you check this chart here, http://www.phys.unsw.edu.au/jw/notes.html, there's a simple mapping from key number to MIDI value (+21). A possible solution would be, near here https://github.com/saebekassebil/teoria/blob/master/src/core.js#L303, add the following function:

```javascript
teoria.note.fromMidi = function(note) {
return teoria.note.fromKey(note - 21);
};
```

There is also a well known and simple calculation from MIDI note value to frequency, so the above suggestion could be written equally as simply as:

```javascript
teoria.note.fromMidi = function(note) {
var frequency = 440 * Math.pow(2, ((note - 69) / 12));
return teoria.note.fromFrequency(frequency);
};
```

What do you think? I'd be happy to send a pull request if you approve!

Thanks for the awesome library!