From 61baa94db2a7c5f8fe57897da464d717726f2eab Mon Sep 17 00:00:00 2001 From: infojunkie Date: Tue, 27 Aug 2024 23:02:42 -0700 Subject: [PATCH] Fix all validation errors --- src/js/musicxml-grooves.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/js/musicxml-grooves.js b/src/js/musicxml-grooves.js index f7ffc887..81cf6a08 100755 --- a/src/js/musicxml-grooves.js +++ b/src/js/musicxml-grooves.js @@ -348,6 +348,9 @@ function createPartEntry(groove, partId, part) { notes.push(note) if (index === source.length - 1) { const duration = beats + 1 - note.onset + if (duration <= 0) { + console.warn(`Found note with duration 0. Ignoring.`) + } notes.filter(note => note.duration === undefined).forEach(note => { note.duration = Math.min(1, duration) }) if (duration > 1) { notes.push({ @@ -358,7 +361,7 @@ function createPartEntry(groove, partId, part) { } } return notes - }, []).map((note, index, notes) => { + }, []).filter(note => note.duration > 0).map((note, index, notes) => { const drum = note.midi ? SaxonJS.XPath.evaluate(`//instrument[@id="${instrumentId}"]/drum[@midi="${note.midi}"]`, instruments) : undefined const pitch = drum ? ` @@ -366,6 +369,7 @@ function createPartEntry(groove, partId, part) { ${drum.getElementsByTagName('display-octave')[0].textContent} `.trim() : '' + const instrument = drum ? `` : '' const chord = (index > 0 && notes[index - 1].onset === note.onset) ? '' : '' const stem = drum ? `${drum.getElementsByTagName('stem')[0].textContent}` : '' const notehead = drum ? `${drum.getElementsByTagName('notehead')[0].textContent}` : '' @@ -375,7 +379,7 @@ function createPartEntry(groove, partId, part) { ${chord} ${pitch} ${duration} - + ${instrument} ${getNoteTiming(note, index, notes, beatType)} ${stem} ${notehead}