Open Daniel63656 opened 1 year ago
With 9.1.0
, I get this output for score.show('text')
, which seems to be correct.
The display in MuseScore 4 looks identical too.
music21
automatically adds rests to gaps in voices, so the addition of new rests is expected behaviour (that should be better documented).
I agree that this might not always be the right thing to do and should probably be configurable.
If this is not what you see on your machine, you could try upgrading to version 9.1.0
to see if that fixes your problem.
{0.0} <music21.metadata.Metadata object at 0x...>
{0.0} <music21.stream.PartStaff P1-Staff1>
{0.0} <music21.instrument.Piano 'P1: Piano: Piano'>
{0.0} <music21.stream.Measure 1 offset=0.0>
{0.0} <music21.expressions.TextExpression 'Largo'>
{0.0} <music21.layout.SystemLayout>
{0.0} <music21.clef.BassClef>
{0.0} <music21.tempo.MetronomeMark Quarter=30 (playback only)>
{0.0} <music21.key.KeySignature of 3 flats>
{0.0} <music21.meter.TimeSignature 4/4>
{0.0} <music21.stream.Voice 1>
{0.0} <music21.chord.Chord G3 C4 E-4 G4>
{0.0} <music21.note.Rest half>
{1.0} <music21.chord.Chord A-3 C4 E-4 A-4>
{2.0} <music21.chord.Chord E-4 G4>
{2.75} <music21.chord.Chord D4 F4>
{3.0} <music21.chord.Chord E-3 G3 C4 E-4>
{0.0} <music21.stream.Voice 2>
{0.0} <music21.note.Rest half>
{2.0} <music21.chord.Chord G3 B3>
{3.0} <music21.note.Rest quarter>
{0.0} <music21.dynamics.Dynamic ff>
{0.0} <music21.spanner.Slur <music21.chord.Chord G3 C4 E-4 G4><music21.chord.Chord E-3 G3 C4 E-4>>
{0.0} <music21.stream.PartStaff P1-Staff2>
{0.0} <music21.instrument.Piano 'P1: Piano: Piano'>
{0.0} <music21.stream.Measure 1 offset=0.0>
{0.0} <music21.layout.SystemLayout>
{0.0} <music21.layout.StaffLayout distance 73.55, staffNumber 2, staffSize None, staffLines None>
{0.0} <music21.clef.BassClef>
{0.0} <music21.key.KeySignature of 3 flats>
{0.0} <music21.meter.TimeSignature 4/4>
{0.0} <music21.stream.Voice 1>
{0.0} <music21.note.Rest half>
{0.0} <music21.stream.Voice 2>
{0.0} <music21.note.Rest half>
{3.0} <music21.note.Rest quarter>
{0.0} <music21.stream.Voice 5>
{0.0} <music21.chord.Chord C2 C3>
{1.0} <music21.chord.Chord F1 F2>
{2.0} <music21.chord.Chord G1 G2>
{3.0} <music21.chord.Chord C2 G2 C3>
{0.0} <music21.layout.StaffGroup <music21.stream.PartStaff P1-Staff1><music21.stream.PartStaff P1-Staff2>>
Yes, I have the same, but this is not correct. The half rest in voice1 is wrong in particular. This becomes also apparent if you render the score with show(), where this erroneous half rest causes chaos. In the original, the bar spans a whole note and in the music21 read score, the additional rest causes voice1 to extend the bar.
and correct one (in MuseScore 4):
I see your problem now!
I think Music21 doesn't parse forward
tags correctly if they immediately follow a backup
tag.
There are two options for you to fix this:
you can replace
<backup>
<duration>16</duration>
</backup>
<forward>
<duration>8</duration>
</forward>
with
<backup>
<duration>8</duration>
</backup>
or you can change xmlForward
in music21/musicxml/xmlToM21.py
to:
def xmlForward(self, mxObj: ET.Element):
'''
Parse a forward tag by changing :attr:`offsetMeasureNote`.
'''
mxDuration = mxObj.find('duration')
if durationText := strippedText(mxDuration):
change = opFrac(float(durationText) / self.divisions)
# Allow overfilled measures for now -- TODO(someday): warn?
self.offsetMeasureNote = opFrac(self.offsetMeasureNote + change)
self.endedWithForwardTag = None
this is just a quick fix that may break other scores though (#991 ) I created a PR to completely fix this issue, but it may take a while for it get accepted.
Is there any progress on that matter? I need to decide whether I use music21 or my own interpreter (which works in these cases but is in Java)
music21 version
8.3.0
Problem summary When dealing with voices that don't span a whole bar, music21 wrongly interprets notes and voices. It adds rests that don't exist and causes simultaneous notes to be not on the same beat.
Steps to reproduce consider the voices in the treble. I attached the xml file (one bar) to reproduce this.
corresponding file