From: Reinhold Kainhofer Date: Fri, 21 Nov 2008 21:25:58 +0000 (+0100) Subject: MusicXML: extract note duration log and nr of dots in one function X-Git-Tag: release/2.11.65-1~25 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=223b21d80d457138192a81232e53541af9ba94bd;p=lilypond.git MusicXML: extract note duration log and nr of dots in one function --- diff --git a/python/musicxml.py b/python/musicxml.py index f796bf5892..f3487d4a8e 100644 --- a/python/musicxml.py +++ b/python/musicxml.py @@ -401,6 +401,14 @@ class Note (Measure_element): return 3 else: return None + + def get_duration_info (self): + log = self.get_duration_log () + if log != None: + dots = len (self.get_typed_children (Dot)) + return (log, dots) + else: + return None def get_factor (self): return 1 diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index b124e99ebe..529de96020 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -461,24 +461,27 @@ def extract_score_structure (part_list, staffinfo): def musicxml_duration_to_lily (mxl_note): - d = musicexp.Duration () # if the note has no Type child, then that method returns None. In that case, # use the tag instead. If that doesn't exist, either -> Error - d.duration_log = mxl_note.get_duration_log () - 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)) + dur = mxl_note.get_duration_info () + if dur: + d = musicexp.Duration () + d.duration_log = dur[0] + d.dots = dur[1] # 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 + else: + 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 + + def rational_to_lily_duration (rational_len): d = musicexp.Duration ()