--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 1.1 Partwise//EN"\r
+ "http://www.musicxml.org/dtds/partwise.dtd">\r
+<score-partwise version="1.1">\r
+ <identification>\r
+ <miscellaneous>\r
+ <miscellaneous-field name="description">In some cases, a rest might \r
+ not have its type attribute set (this happens, for example, with\r
+ voices in Finale, where you don't manually insert a \r
+ rest).</miscellaneous-field>\r
+ </miscellaneous>\r
+ </identification>\r
+ <part-list>\r
+ <score-part id="P1">\r
+ <part-name>MusicXML Part</part-name>\r
+ </score-part>\r
+ </part-list>\r
+ <!--=========================================================-->\r
+ <part id="P1">\r
+ <measure implicit="yes" number="0">\r
+ <attributes>\r
+ <divisions>1</divisions>\r
+ <key>\r
+ <fifths>0</fifths>\r
+ <mode>major</mode>\r
+ </key>\r
+ <time symbol="common">\r
+ <beats>4</beats>\r
+ <beat-type>4</beat-type>\r
+ </time>\r
+ <staves>2</staves>\r
+ <clef number="1">\r
+ <sign>G</sign>\r
+ <line>2</line>\r
+ </clef>\r
+ <clef number="2">\r
+ <sign>F</sign>\r
+ <line>4</line>\r
+ </clef>\r
+ </attributes>\r
+ <note>\r
+ <pitch>\r
+ <step>C</step>\r
+ <octave>5</octave>\r
+ </pitch>\r
+ <duration>1</duration>\r
+ <voice>1</voice>\r
+ <type>quarter</type>\r
+ <staff>1</staff>\r
+ </note>\r
+ <backup>\r
+ <duration>1</duration>\r
+ </backup>\r
+ <note>\r
+ <rest/>\r
+ <duration>1</duration>\r
+ <voice>2</voice>\r
+ <staff>2</staff>\r
+ </note>\r
+ </measure>\r
+ <!--=======================================================-->\r
+ <measure number="1">\r
+ <note>\r
+ <pitch>\r
+ <step>A</step>\r
+ <octave>4</octave>\r
+ </pitch>\r
+ <duration>4</duration>\r
+ <voice>1</voice>\r
+ <type>whole</type>\r
+ <staff>1</staff>\r
+ </note>\r
+ <backup>\r
+ <duration>4</duration>\r
+ </backup>\r
+ <note>\r
+ <pitch>\r
+ <step>E</step>\r
+ <octave>3</octave>\r
+ </pitch>\r
+ <duration>4</duration>\r
+ <voice>2</voice>\r
+ <type>whole</type>\r
+ </note>\r
+ <barline location="right">\r
+ <bar-style>light-heavy</bar-style>\r
+ </barline>\r
+ </measure>\r
+ </part>\r
+ <!--=========================================================-->\r
+</score-partwise>\r
# FIXME: is it ok to default to eight note for grace notes?
return 3
else:
- self.message (_ ("Encountered note at %s with %s duration (no <type> element):") % (self.start, self.duration) )
- return 0
+ return None
def get_factor (self):
return 1
def musicxml_duration_to_lily (mxl_note):
d = musicexp.Duration ()
- # if the note has no Type child, then that method spits out a warning and
- # returns 0, i.e. a whole note
+ # if the note has no Type child, then that method returns None. In that case,
+ # use the <duration> tag instead. If that doesn't exist, either -> Error
d.duration_log = mxl_note.get_duration_log ()
-
- d.dots = len (mxl_note.get_typed_children (musicxml.Dot))
- # Grace notes by specification have duration 0, so no time modification
- # factor is possible. It even messes up the output with *0/1
- if not mxl_note.get_maybe_exist_typed_child (musicxml.Grace):
- d.factor = mxl_note._duration / d.get_length ()
-
- return d
+ if d.duration_log == None:
+ if mxl_note._duration > 0:
+ return rational_to_lily_duration (mxl_note._duration)
+ else:
+ mxl_note.message (_ ("Encountered note at %s without type and duration (=%s)") % (mxl_note.start, mxl_note._duration) )
+ return None
+ else:
+ d.dots = len (mxl_note.get_typed_children (musicxml.Dot))
+ # Grace notes by specification have duration 0, so no time modification
+ # factor is possible. It even messes up the output with *0/1
+ if not mxl_note.get_maybe_exist_typed_child (musicxml.Grace):
+ d.factor = mxl_note._duration / d.get_length ()
+ return d
def rational_to_lily_duration (rational_len):
d = musicexp.Duration ()