From e131f8b27e47a9131d82885a45e8a68427a16d35 Mon Sep 17 00:00:00 2001 From: infojunkie Date: Sun, 15 Sep 2024 17:25:57 -0700 Subject: [PATCH] Remove unneeded tuplet tolerance --- src/js/musicxml-grooves.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/js/musicxml-grooves.js b/src/js/musicxml-grooves.js index a3ad74cc..6baa7cd6 100755 --- a/src/js/musicxml-grooves.js +++ b/src/js/musicxml-grooves.js @@ -19,7 +19,6 @@ const DIVISIONS_256th = DIVISIONS/64 const DIVISIONS_512th = DIVISIONS/128 const DIVISIONS_1024th = DIVISIONS/256 const QUANTIZATION_DEFAULT_GRID = [4, 3] -const TUPLET_TOLERANCE = 0.05 import fs from 'fs' import xmlFormat from 'xml-formatter' @@ -777,8 +776,8 @@ function createNoteTiming(note, index, notes) { const ratio = Math.round(target / tupletCount) if ( tuplet.length === tupletCount && - Math.abs(tupletsDuration(tuplet) - target) <= TUPLET_TOLERANCE * tupletCount && - tuplet.every(n => Math.min(n.quantized.duration % ratio, ratio - (n.quantized.duration % ratio)) <= TUPLET_TOLERANCE) && + Math.abs(tupletsDuration(tuplet) - target) <= Number.EPSILON && + tuplet.every(n => Math.min(n.quantized.duration % ratio, ratio - (n.quantized.duration % ratio)) <= Number.EPSILON) && tuplet.every(n => Math.floor(n.quantized.onset / target) === Math.floor(tuplet[0].quantized.onset / target)) ) { tuplet.forEach((n, i) => { @@ -814,8 +813,8 @@ function createNoteTiming(note, index, notes) { const ratio = Math.round(target / 3) if ( pair.length === 2 && - Math.abs(tupletsDuration(pair) - target) <= TUPLET_TOLERANCE * 2 && - pair.every(n => Math.min(n.quantized.duration % ratio, ratio - (n.quantized.duration % ratio)) <= TUPLET_TOLERANCE) && + Math.abs(tupletsDuration(pair) - target) <= Number.EPSILON && + pair.every(n => Math.min(n.quantized.duration % ratio, ratio - (n.quantized.duration % ratio)) <= Number.EPSILON) && Math.floor(pair[0].quantized.onset / target) === Math.floor(pair[1].quantized.onset / target) ) { pair.forEach((n, i, t) => {