Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra rest inserted when parsing MusicXML with backup/forward tags #1715

Open
werneta opened this issue Jun 9, 2024 · 0 comments
Open

Extra rest inserted when parsing MusicXML with backup/forward tags #1715

werneta opened this issue Jun 9, 2024 · 0 comments

Comments

@werneta
Copy link

werneta commented Jun 9, 2024

music21 version

9.1.0

Problem summary
I'm working in MuseScore 4 and have a 4/4 measure with a double-dotted half note, followed by a clef change, followed by an eighth note:
image

When I convert this to MusicXML and import it with music21, there is an extra rest inserted after the clef change. It looks like it's related to <backup> and <forward> tags that are MuseScore adds around the clef change.

Steps to reproduce
Use this file (remove the .txt) from the file name:
clef_change_backup.musicxml.txt

import music21
fname = 'clef_change_backup.musicxml'
x = music21.converter.parseFile(fname)
list(x[1][1])

Expected vs. actual behavior

[<music21.clef.TrebleClef>,
 <music21.key.KeySignature of no sharps or flats>,
 <music21.meter.TimeSignature 4/4>,
 <music21.note.Note C>,
 <music21.clef.BassClef>,
 <music21.note.Rest dotted-quarter>, # Not expected
 <music21.note.Note C>,
 <music21.bar.Barline type=final>]

More information

I tried removing the <backup> and <forward> tags in the XML:

      <note>
        <pitch>
          <step>C</step>
          <octave>5</octave>
          </pitch>
        <duration>7</duration>
        <voice>1</voice>
        <type>half</type>
        <dot/>
        <dot/>
        <stem>down</stem>
        </note>
      <backup> <!-- Removed this element -->
        <duration>3</duration>
        </backup>
      <attributes>
        <clef>
          <sign>F</sign>
          <line>4</line>
          </clef>
        </attributes>
      <forward> <!-- Removed this element -->
        <duration>3</duration>
        </forward>
      <note>
        <pitch>
          <step>C</step>
          <octave>3</octave>
          </pitch>
        <duration>1</duration>
        <voice>1</voice>
        <type>eighth</type>
        <stem>up</stem>
        </note>

and saved it as this file: clef_change_nobackup.musicxml.txt

Rerunning the previous steps generates the expected output:

[<music21.clef.TrebleClef>,
 <music21.key.KeySignature of no sharps or flats>,
 <music21.meter.TimeSignature 4/4>,
 <music21.note.Note C>,
 <music21.clef.BassClef>,
 <music21.note.Note C>,
 <music21.bar.Barline type=final>]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant