mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 16:48:00 +00:00
Time miscalculation fix (#343)
Times being converted to BarsBeatsSixteenths have the potential to miscalculate due to an extended floating point number within the function. Example of error: https://jsfiddle.net/timboie/1vztuhz1/ Fix validation: https://jsfiddle.net/timboie/6e7d31t3/ Any further testing is appreciated Fixes #342
This commit is contained in:
parent
e39e392791
commit
4cd88ab1eb
1 changed files with 1 additions and 0 deletions
|
@ -111,6 +111,7 @@ define(["Tone/core/Tone", "Tone/type/TimeBase", "Tone/type/Frequency"], function
|
|||
Tone.Time.prototype.toBarsBeatsSixteenths = function(){
|
||||
var quarterTime = this._beatsToUnits(1);
|
||||
var quarters = this.valueOf() / quarterTime;
|
||||
quarters = parseFloat(quarters.toFixed(4));
|
||||
var measures = Math.floor(quarters / this._getTimeSignature());
|
||||
var sixteenths = (quarters % 1) * 4;
|
||||
quarters = Math.floor(quarters) % this._getTimeSignature();
|
||||
|
|
Loading…
Reference in a new issue