From 45bb5ad9d7af0643464b5d1e51cff6a0745bfbf4 Mon Sep 17 00:00:00 2001 From: infojunkie Date: Thu, 29 Aug 2024 22:00:16 -0700 Subject: [PATCH] Detect track name mismatches and fix some of them --- build/grooves.json | 370 +++---------------------------------- mma | 2 +- src/js/musicxml-grooves.js | 29 +-- 3 files changed, 39 insertions(+), 362 deletions(-) diff --git a/build/grooves.json b/build/grooves.json index c18f998d..22fdcbe1 100644 --- a/build/grooves.json +++ b/build/grooves.json @@ -268983,18 +268983,6 @@ "1 192t 90 90 90 90 90 90 90 90; 3 192t 90 90 90 90 90 90 90 90" ] }, - { - "track": "DRUM-FLOOR-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "4 1t 90 ; 4.165 1t 90 ; 4.33 1t 90 ; 4.5 1t 90 ; 4.67 1t 90 ; 4.835 1t 90 " - ] - }, { "track": "DRUM-FLOORTOM", "voice": [ @@ -269004,7 +268992,7 @@ 43 ], "sequence": [ - "4 1t 90 ; 4.25 1t 90 ; 4.5 1t 90 ; 4.75 1t 90 " + "4 1t 90 ; 4.165 1t 90 ; 4.33 1t 90 ; 4.5 1t 90 ; 4.67 1t 90 ; 4.835 1t 90 " ] }, { @@ -269019,18 +269007,6 @@ "1 1t 90 ; 2 1t 90 ; 3 1t 90 ; 4 1t 90 " ] }, - { - "track": "DRUM-HI-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "2 1t 90 ; 2.165 1t 90 ; 2.33 1t 90 ; 2.5 1t 90 ; 2.67 1t 90 ; 2.835 1t 90 " - ] - }, { "track": "DRUM-HITOM", "voice": [ @@ -269040,7 +269016,7 @@ 50 ], "sequence": [ - "2 1t 90 ; 2.25 1t 90 ; 2.5 1t 90 ; 2.75 1t 90 " + "2 1t 90 ; 2.165 1t 90 ; 2.33 1t 90 ; 2.5 1t 90 ; 2.67 1t 90 ; 2.835 1t 90 " ] }, { @@ -269055,18 +269031,6 @@ "1 1t 90 ; 2 1t 90 ; 3 1t 90 ; 4 1t 90 " ] }, - { - "track": "DRUM-MEDIUM-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "3 1t 90 ; 3.165 1t 90 ; 3.33 1t 90 ; 3.5 1t 90 ; 3.67 1t 90 ; 3.835 1t 90 " - ] - }, { "track": "DRUM-MEDIUMTOM", "voice": [ @@ -269076,7 +269040,7 @@ 47 ], "sequence": [ - "3 1t 90 ; 3.25 1t 90 ; 3.5 1t 90 ; 3.75 1t 90 " + "3 1t 90 ; 3.165 1t 90 ; 3.33 1t 90 ; 3.5 1t 90 ; 3.67 1t 90 ; 3.835 1t 90 " ] }, { @@ -269656,18 +269620,6 @@ "1 192t 90 90 90 90 90 90 90 90; 3 192t 90 90 90 90 90 90 90 90" ] }, - { - "track": "DRUM-FLOOR-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "1.75 1t 90 ; 2.75 1t 90 ; 3.75 1t 90 ; 4.75 1t 90 " - ] - }, { "track": "DRUM-FLOORTOM", "voice": [ @@ -269677,19 +269629,7 @@ 43 ], "sequence": [ - "4 1t 90 ; 4.25 1t 90 ; 4.5 1t 90 ; 4.75 1t 90 " - ] - }, - { - "track": "DRUM-HI-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "1.25 1t 90 ; 2.25 1t 90 ; 3.25 1t 90 ; 4.25 1t 90 " + "1.75 1t 90 ; 2.75 1t 90 ; 3.75 1t 90 ; 4.75 1t 90 " ] }, { @@ -269701,7 +269641,7 @@ 50 ], "sequence": [ - "2 1t 90 ; 2.25 1t 90 ; 2.5 1t 90 ; 2.75 1t 90 " + "1.25 1t 90 ; 2.25 1t 90 ; 3.25 1t 90 ; 4.25 1t 90 " ] }, { @@ -269716,18 +269656,6 @@ "1 1t 90 ; 2 1t 90 ; 3 1t 90 ; 4 1t 90 " ] }, - { - "track": "DRUM-MEDIUM-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "1.5 1t 90 ; 2.5 1t 90 ; 3.5 1t 90 ; 4.5 1t 90 " - ] - }, { "track": "DRUM-MEDIUMTOM", "voice": [ @@ -269737,7 +269665,7 @@ 47 ], "sequence": [ - "3 1t 90 ; 3.25 1t 90 ; 3.5 1t 90 ; 3.75 1t 90 " + "1.5 1t 90 ; 2.5 1t 90 ; 3.5 1t 90 ; 4.5 1t 90 " ] }, { @@ -270302,18 +270230,6 @@ "1 192t 90 90 90 90 90 90 90 90; 2 192t 90 90 90 90 90 90 90 90; 3 192t 90 90 90 90 90 90 90 90; 4 192t 90 90 90 90 90 90 90 90" ] }, - { - "track": "DRUM-FLOOR-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "2.5 1t 90 ; 4.5 1t 90 " - ] - }, { "track": "DRUM-FLOORTOM", "voice": [ @@ -270323,7 +270239,7 @@ 43 ], "sequence": [ - "4 1t 90 ; 4.5 1t 90 " + "2.5 1t 90 ; 4.5 1t 90 " ] }, { @@ -270338,18 +270254,6 @@ "1 1t 90 ; 2 1t 90 ; 3 1t 90 ; 4 1t 90 " ] }, - { - "track": "DRUM-HI-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "1.5 1t 90 ; 3.5 1t 90 " - ] - }, { "track": "DRUM-HITOM", "voice": [ @@ -270359,7 +270263,7 @@ 50 ], "sequence": [ - "2 1t 90 ; 2.5 1t 90 " + "1.5 1t 90 ; 3.5 1t 90 " ] }, { @@ -270374,18 +270278,6 @@ "1 1t 90 ; 2 1t 90 ; 3 1t 90 ; 4 1t 90 " ] }, - { - "track": "DRUM-MEDIUM-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "2 1t 90 ; 4 1t 90 " - ] - }, { "track": "DRUM-MEDIUMTOM", "voice": [ @@ -270395,7 +270287,7 @@ 47 ], "sequence": [ - "3 1t 90 ; 3.5 1t 90 " + "2 1t 90 ; 4 1t 90 " ] }, { @@ -270960,18 +270852,6 @@ "1 64t 90 90 90 90 90 90 90 90; 1.33333 64t 90 90 90 90 90 90 90 90; 1.66667 64t 90 90 90 90 90 90 90 90; 2 64t 90 90 90 90 90 90 90 90; 2.33333 64t 90 90 90 90 90 90 90 90; 2.66667 64t 90 90 90 90 90 90 90 90; 3 64t 90 90 90 90 90 90 90 90; 3.33333 64t 90 90 90 90 90 90 90 90; 3.66667 64t 90 90 90 90 90 90 90 90; 4 64t 90 90 90 90 90 90 90 90; 4.33333 64t 90 90 90 90 90 90 90 90; 4.66667 64t 90 90 90 90 90 90 90 90" ] }, - { - "track": "DRUM-FLOOR-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "3.33 1t 90 ; 4 1t 90 ; 4.67 1t 90 " - ] - }, { "track": "DRUM-FLOORTOM", "voice": [ @@ -270981,7 +270861,7 @@ 43 ], "sequence": [ - "4 1t 90 ; 4.33 1t 90 ; 4.67 1t 90 " + "3.33 1t 90 ; 4 1t 90 ; 4.67 1t 90 " ] }, { @@ -270996,18 +270876,6 @@ "1 1t 90 ; 2 1t 90 ; 3 1t 90 ; 4 1t 90 " ] }, - { - "track": "DRUM-HI-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "1.33 1t 90 ; 2 1t 90 ; 2.67 1t 90 " - ] - }, { "track": "DRUM-HITOM", "voice": [ @@ -271017,7 +270885,7 @@ 50 ], "sequence": [ - "2 1t 90 ; 2.33 1t 90 ; 2.67 1t 90 " + "1.33 1t 90 ; 2 1t 90 ; 2.67 1t 90 " ] }, { @@ -271032,18 +270900,6 @@ "1 1t 90 ; 2 1t 90 ; 3 1t 90 ; 4 1t 90 " ] }, - { - "track": "DRUM-MEDIUMTOM", - "voice": [ - "MidTom1" - ], - "midi": [ - 47 - ], - "sequence": [ - "3 1t 90 ; 3.33 1t 90 ; 3.67 1t 90 " - ] - }, { "track": "DRUM-SNARE", "voice": [ @@ -271642,18 +271498,6 @@ "1 192t 90 90 90 90 90 90 90 90; 3 192t 90 90 90 90 90 90 90 90" ] }, - { - "track": "DRUM-FLOOR-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "4 1t 90 ; 4.2 1t 90 ; 4.4 1t 90 ; 4.6 1t 90 ; 4.8 1t 90 " - ] - }, { "track": "DRUM-FLOORTOM", "voice": [ @@ -271666,18 +271510,6 @@ "4 1t 90 ; 4.2 1t 90 ; 4.4 1t 90 ; 4.6 1t 90 ; 4.8 1t 90 " ] }, - { - "track": "DRUM-HI-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "2 1t 90 ; 2.2 1t 90 ; 2.4 1t 90 ; 2.6 1t 90 ; 2.8 1t 90 " - ] - }, { "track": "DRUM-HITOM", "voice": [ @@ -271702,18 +271534,6 @@ "1 1t 90 ; 2 1t 90 ; 3 1t 90 ; 4 1t 90 " ] }, - { - "track": "DRUM-MEDIUM-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "3 1t 90 ; 3.2 1t 90 ; 3.4 1t 90 ; 3.6 1t 90 ; 3.8 1t 90 " - ] - }, { "track": "DRUM-MEDIUMTOM", "voice": [ @@ -272288,18 +272108,6 @@ "1 192t 90 90 90 90 90 90 90 90; 2 192t 90 90 90 90 90 90 90 90; 3 192t 90 90 90 90 90 90 90 90; 4 192t 90 90 90 90 90 90 90 90" ] }, - { - "track": "DRUM-FLOOR-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "2.5 1t 90 ; 4.5 1t 90 " - ] - }, { "track": "DRUM-FLOORTOM", "voice": [ @@ -272309,7 +272117,7 @@ 43 ], "sequence": [ - "4 1t 90 ; 4.5 1t 90 " + "2.5 1t 90 ; 4.5 1t 90 " ] }, { @@ -272324,18 +272132,6 @@ "1 1t 90 ; 2 1t 90 ; 3 1t 90 ; 4 1t 90 " ] }, - { - "track": "DRUM-HI-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "1.5 1t 90 ; 3.5 1t 90 " - ] - }, { "track": "DRUM-HITOM", "voice": [ @@ -272345,7 +272141,7 @@ 50 ], "sequence": [ - "2 1t 90 ; 2.5 1t 90 " + "1.5 1t 90 ; 3.5 1t 90 " ] }, { @@ -272360,18 +272156,6 @@ "1 1t 90 ; 2 1t 90 ; 3 1t 90 ; 4 1t 90 " ] }, - { - "track": "DRUM-MEDIUM-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "2 1t 90 ; 4 1t 90 " - ] - }, { "track": "DRUM-MEDIUMTOM", "voice": [ @@ -272381,7 +272165,7 @@ 47 ], "sequence": [ - "3 1t 90 ; 3.5 1t 90 " + "2 1t 90 ; 4 1t 90 " ] }, { @@ -272946,18 +272730,6 @@ "1 192t 90 90 90 90 90 90 90 90; 2 192t 90 90 90 90 90 90 90 90; 3 192t 90 90 90 90 90 90 90 90; 4 192t 90 90 90 90 90 90 90 90" ] }, - { - "track": "DRUM-FLOOR-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "1.75 1t 90 ; 2.75 1t 90 ; 3.75 1t 90 ; 4.75 1t 90 " - ] - }, { "track": "DRUM-FLOORTOM", "voice": [ @@ -272967,7 +272739,7 @@ 43 ], "sequence": [ - "4 1t 90 ; 4.25 1t 90 ; 4.5 1t 90 ; 4.75 1t 90 " + "1.75 1t 90 ; 2.75 1t 90 ; 3.75 1t 90 ; 4.75 1t 90 " ] }, { @@ -272982,18 +272754,6 @@ "1 1t 90 ; 2 1t 90 ; 3 1t 90 ; 4 1t 90 " ] }, - { - "track": "DRUM-HI-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "1.25 1t 90 ; 2.25 1t 90 ; 3.25 1t 90 ; 4.25 1t 90 " - ] - }, { "track": "DRUM-HITOM", "voice": [ @@ -273003,7 +272763,7 @@ 50 ], "sequence": [ - "2 1t 90 ; 2.25 1t 90 ; 2.5 1t 90 ; 2.75 1t 90 " + "1.25 1t 90 ; 2.25 1t 90 ; 3.25 1t 90 ; 4.25 1t 90 " ] }, { @@ -273018,18 +272778,6 @@ "1 1t 90 ; 2 1t 90 ; 3 1t 90 ; 4 1t 90 " ] }, - { - "track": "DRUM-MEDIUM-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "1.5 1t 90 ; 2.5 1t 90 ; 3.5 1t 90 ; 4.5 1t 90 " - ] - }, { "track": "DRUM-MEDIUMTOM", "voice": [ @@ -273039,7 +272787,7 @@ 47 ], "sequence": [ - "3 1t 90 ; 3.25 1t 90 ; 3.5 1t 90 ; 3.75 1t 90 " + "1.5 1t 90 ; 2.5 1t 90 ; 3.5 1t 90 ; 4.5 1t 90 " ] }, { @@ -273604,18 +273352,6 @@ "1 96t 90 90 90 90 90 90 90 90; 1.5 96t 90 90 90 90 90 90 90 90; 2 96t 90 90 90 90 90 90 90 90; 2.5 96t 90 90 90 90 90 90 90 90; 3 96t 90 90 90 90 90 90 90 90; 3.5 96t 90 90 90 90 90 90 90 90; 4 96t 90 90 90 90 90 90 90 90; 4.5 96t 90 90 90 90 90 90 90 90" ] }, - { - "track": "DRUM-FLOOR-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "1.75 1t 90 ; 2.75 1t 90 ; 3.75 1t 90 ; 4.75 1t 90 " - ] - }, { "track": "DRUM-FLOORTOM", "voice": [ @@ -273625,7 +273361,7 @@ 43 ], "sequence": [ - "4 1t 90 ; 4.25 1t 90 ; 4.5 1t 90 ; 4.75 1t 90 " + "1.75 1t 90 ; 2.75 1t 90 ; 3.75 1t 90 ; 4.75 1t 90 " ] }, { @@ -273640,18 +273376,6 @@ "1 1t 90 ; 2 1t 90 ; 3 1t 90 ; 4 1t 90 " ] }, - { - "track": "DRUM-HI-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "1.25 1t 90 ; 2.25 1t 90 ; 3.25 1t 90 ; 4.25 1t 90 " - ] - }, { "track": "DRUM-HITOM", "voice": [ @@ -273661,7 +273385,7 @@ 50 ], "sequence": [ - "2 1t 90 ; 2.25 1t 90 ; 2.5 1t 90 ; 2.75 1t 90 " + "1.25 1t 90 ; 2.25 1t 90 ; 3.25 1t 90 ; 4.25 1t 90 " ] }, { @@ -273676,18 +273400,6 @@ "1 1t 90 ; 2 1t 90 ; 3 1t 90 ; 4 1t 90 " ] }, - { - "track": "DRUM-MEDIUM-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "1.5 1t 90 ; 2.5 1t 90 ; 3.5 1t 90 ; 4.5 1t 90 " - ] - }, { "track": "DRUM-MEDIUMTOM", "voice": [ @@ -273697,7 +273409,7 @@ 47 ], "sequence": [ - "3 1t 90 ; 3.25 1t 90 ; 3.5 1t 90 ; 3.75 1t 90 " + "1.5 1t 90 ; 2.5 1t 90 ; 3.5 1t 90 ; 4.5 1t 90 " ] }, { @@ -274262,18 +273974,6 @@ "1 192t 90 90 90 90 90 90 90 90; 2 192t 90 90 90 90 90 90 90 90; 3 192t 90 90 90 90 90 90 90 90; 4 192t 90 90 90 90 90 90 90 90" ] }, - { - "track": "DRUM-FLOOR-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "1.75 1t 90 ; 2.75 1t 90 ; 3.75 1t 90 ; 4.75 1t 90 " - ] - }, { "track": "DRUM-FLOORTOM", "voice": [ @@ -274283,7 +273983,7 @@ 43 ], "sequence": [ - "4 1t 90 ; 4.25 1t 90 ; 4.5 1t 90 ; 4.75 1t 90 " + "1.75 1t 90 ; 2.75 1t 90 ; 3.75 1t 90 ; 4.75 1t 90 " ] }, { @@ -274298,18 +273998,6 @@ "1 1t 90 ; 2 1t 90 ; 3 1t 90 ; 4 1t 90 " ] }, - { - "track": "DRUM-HI-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "1.25 1t 90 ; 2.25 1t 90 ; 3.25 1t 90 ; 4.25 1t 90 " - ] - }, { "track": "DRUM-HITOM", "voice": [ @@ -274319,7 +274007,7 @@ 50 ], "sequence": [ - "2 1t 90 ; 2.25 1t 90 ; 2.5 1t 90 ; 2.75 1t 90 " + "1.25 1t 90 ; 2.25 1t 90 ; 3.25 1t 90 ; 4.25 1t 90 " ] }, { @@ -274334,18 +274022,6 @@ "1 1t 90 ; 2 1t 90 ; 3 1t 90 ; 4 1t 90 " ] }, - { - "track": "DRUM-MEDIUM-TOM", - "voice": [ - "SnareDrum1" - ], - "midi": [ - 38 - ], - "sequence": [ - "1.5 1t 90 ; 2.5 1t 90 ; 3.5 1t 90 ; 4.5 1t 90 " - ] - }, { "track": "DRUM-MEDIUMTOM", "voice": [ @@ -274355,7 +274031,7 @@ 47 ], "sequence": [ - "3 1t 90 ; 3.25 1t 90 ; 3.5 1t 90 ; 3.75 1t 90 " + "1.5 1t 90 ; 2.5 1t 90 ; 3.5 1t 90 ; 4.5 1t 90 " ] }, { diff --git a/mma b/mma index 9b3fcdce..e511c92b 160000 --- a/mma +++ b/mma @@ -1 +1 @@ -Subproject commit 9b3fcdcec8e85c5f847a1edf2514a578168d1e12 +Subproject commit e511c92b3f916b5a239a46118de88ecb34655d3b diff --git a/src/js/musicxml-grooves.js b/src/js/musicxml-grooves.js index 70222790..6b5b21c5 100755 --- a/src/js/musicxml-grooves.js +++ b/src/js/musicxml-grooves.js @@ -123,6 +123,11 @@ for (const groove of JSON.parse(fs.readFileSync('build/grooves.json'))) { } function createMusicXML(groove) { + groove.tracks = groove.tracks.filter(t => t.track.startsWith('DRUM')).reverse() + if (!groove.tracks.length) { + throw Error('No drum tracks found.') + } + const template = ` element has a number of elements whose @pitch attribute corresponds to the MIDI drum voice. // It can happen that a MIDI drum voice is used by multiple instruments, // so we gather all matching instruments and later select those with the most voices. - const tracks = groove.tracks.filter(t => t.track.startsWith('DRUM')).reverse() - if (!tracks.length) { - throw Error('No drum tracks found.') - } - - const partCandidates = tracks.reduce((partCandidates, track) => { + const partCandidates = groove.tracks.reduce((partCandidates, track) => { track.candidateInstrumentIds = [] const midi = track.midi[0] // In grooves.json, all MIDI notes are the same for each track const trackCandidates = SaxonJS.XPath.evaluate(`//instrument[drum[@midi="${midi}"]]/@id`, instruments, { resultForm: 'array' }) @@ -187,7 +187,7 @@ function createPartList(groove) { // Now select the most used instrument for each drum track. // If there are multiple instruments with the same usage, we pick the one already used by another track. // Otherwise, we pick the instrument with the least pitches. - const parts = tracks.reduce((parts, track) => { + const parts = groove.tracks.reduce((parts, track) => { track.candidateInstrumentIds = track.candidateInstrumentIds.sort((a, b) => { if (partCandidates[b].usage === partCandidates[a].usage) { if (a in parts) return -1 @@ -216,14 +216,15 @@ function createPartList(groove) { function createParts(groove) { const parts = groove.tracks - .filter(t => t.track.startsWith('DRUM')) - .reverse() .reduce((parts, track) => { - const partId = track.partId - if (!(partId in parts)) { - parts[partId] = [] + if (track.partId === undefined) { + console.error(`Found track ${track.track} without a part, which usually indicates a track name mismatch. Ignoring.`) + return parts + } + if (!(track.partId in parts)) { + parts[track.partId] = [] } - parts[partId].push(track) + parts[track.partId].push(track) return parts }, {}) @@ -246,7 +247,7 @@ function createPartListEntry(groove, instrumentId, partId) { const entries = SaxonJS.XPath.evaluate(`//instrument[@id="${instrumentId}"]/drum`, instruments, { resultForm: 'array' }) .reduce((entries, drum) => { const scoreInstrumentId = `P${partId}-I${drum.getAttribute('midi')}` - const track = groove.tracks.find(t => t.midi[0].toString() === drum.getAttribute('midi')) + const track = groove.tracks.find(t => t.midi[0].toString() === drum.getAttribute('midi').toString()) if (track) { track.partId = partId track.scoreInstrumentId = scoreInstrumentId