Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/parsing/musicxml/measure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ export class Measure {
fragments.push(Fragment.create(config, log, signature, buffer, partIds));
}

// Ensure every measure has at least one fragment so the Part structure is preserved
// for empty measures (e.g. when <attributes> and notes are missing).
if (fragments.length === 0) {
fragments.push(Fragment.create(config, log, signature, [], partIds));
}

return fragments;
}

Expand Down
25 changes: 25 additions & 0 deletions tests/__data__/vexml/empty_first_measure.musicxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 1.0 Partwise//EN"
"http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise>
<movement-title>Pitches and accidentals</movement-title>
<identification>
<miscellaneous>
<miscellaneous-field name="description">All pitches from G to c'''' in
ascending steps; First without accidentals, then with a sharp and then
with a flat accidental. Double alterations and cautionary accidentals
are tested at the end.</miscellaneous-field>
</miscellaneous>
</identification>
<part-list>
<score-part id="P1">
<part-name>MusicXML Part</part-name>
</score-part>
</part-list>
<!--=========================================================-->
<part id="P1">
<measure number="1">
</measure>
</part>
<!--=========================================================-->
</score-partwise>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tests/integration/vexml.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('vexml', () => {
{ filename: 'tabs_vibrato.musicxml', width: 900 },
{ filename: 'tabs_bends.musicxml', width: 900 },
{ filename: 'chord_symbols.musicxml', width: 900 },
{ filename: 'empty_first_measure.musicxml', width: 900 },
])(`$filename ($width px)`, async (t) => {
const { document, vexmlDiv, screenshotElementSelector } = setup();

Expand Down
Loading