Skip to content

Commit

Permalink
Fix demo for custom MIDI+timemap
Browse files Browse the repository at this point in the history
  • Loading branch information
infojunkie committed Oct 10, 2024
1 parent 4683365 commit c2d36d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 8 additions & 4 deletions demo/demo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ async function createPlayer() {
'vrv': true,
'mma': async () => MusicXMLPlayer.fetish(window.location.href + 'mma/', { method: 'HEAD' }),
'midi': '.mid',
'timemap': '.timemap.json',
'mscore': '.mscore.json',
})) {
const input = document.getElementById(`converter-${k}`);
Expand Down Expand Up @@ -188,9 +187,14 @@ async function createConverter(converter, sheet, groove) {
const base = sheet.startsWith('http') || sheet.startsWith('data/') ? sheet : `data/${sheet}`;
switch (converter) {
case 'midi':
return new MusicXMLPlayer.FetchConverter(base.replace(/\.musicxml$|\.mxl$/, '.mid'));
case 'timemap':
return new MusicXMLPlayer.FetchConverter(base.replace(/\.musicxml$|\.mxl$/, '.mid'), base.replace(/\.musicxml$|\.mxl$/, '.timemap.json'));
try {
const timemap = base.replace(/\.musicxml$|\.mxl$/, '.timemap.json');
await MusicXMLPlayer.fetish(timemap, { method: 'HEAD' });
return new MusicXMLPlayer.FetchConverter(base.replace(/\.musicxml$|\.mxl$/, '.mid'), timemap);
}
catch {
return new MusicXMLPlayer.FetchConverter(base.replace(/\.musicxml$|\.mxl$/, '.mid'));
}
case 'vrv':
return new MusicXMLPlayer.VerovioConverter();
case 'mma':
Expand Down
2 changes: 0 additions & 2 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ <h1>MusicXML Player Demo</h1>
Converter
<input type="radio" id="converter-midi" name="converter" value="midi"/>
<label for="converter-midi">Custom MIDI</label>
<input type="radio" id="converter-timemap" name="converter" value="timemap"/>
<label for="converter-midi">Custom MIDI + Timemap</label>
<input type="radio" id="converter-mma" name="converter" value="mma"/>
<label for="converter-mma">MusicXML MMA</label>
<input type="radio" id="converter-vrv" name="converter" value="vrv"/>
Expand Down

0 comments on commit c2d36d7

Please sign in to comment.