mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 08:38:00 +00:00
fixed rounding error when converting frequency to midi
This commit is contained in:
parent
5bea2666c0
commit
6937466554
1 changed files with 12 additions and 12 deletions
|
@ -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;
|
||||||
|
|
Loading…
Reference in a new issue