midi-freq
A tiny (188 bytes) function to get the frequency of a midi note number:
var freq = 440 // => 440
It uses an equal tempered scale. Basically it's just: Math.pow(2, (midi - 69) / 12) * tuning
with a couple of goodies.
API
freq(tuning, midi)
Get the frequency of a midi note with the custom tuning. If not specified, is 440Hz by default.
Basic usage
Get the frequency:
// 69 is note A4var freq = // => 440 // => 440 /// => 444// 57 is note A3 // => 220 // => 222
Set default tuning
Normally you use the same tuning for all your app. You can partially applied the function:
var freq = 444// the freq function uses 444 as custom tuning // => 222
License
MIT License