fixed rounding error when converting frequency to midi

This commit is contained in:
Yotam Mann 2017-08-26 15:36:06 -04:00
parent 5bea2666c0
commit 6937466554

View file

@ -279,7 +279,7 @@ define(["Tone/core/Tone", "Tone/type/TimeBase"], function (Tone) {
* tone.midiToFrequency(440); // returns 69 * tone.midiToFrequency(440); // returns 69
*/ */
Tone.Frequency.prototype.frequencyToMidi = function(frequency){ Tone.Frequency.prototype.frequencyToMidi = function(frequency){
return 69 + 12 * Math.log(frequency / Tone.Frequency.A4) / Math.LN2; return 69 + Math.round(12 * Math.log(frequency / Tone.Frequency.A4) / Math.LN2);
}; };
return Tone.Frequency; return Tone.Frequency;