From: Reinhold Kainhofer Date: Thu, 21 Feb 2008 19:03:04 +0000 (+0100) Subject: MusicXML: Add a way to implement compatibility modes, ignore beams for Sibelius X-Git-Tag: release/2.11.41-1~22^2~2^2~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6b3b6993bbcec6989ba36ba72853ec3c5dd255e1;p=lilypond.git MusicXML: Add a way to implement compatibility modes, ignore beams for Sibelius --- diff --git a/input/regression/musicxml/99a-Sibelius5-IgnoreBeaming.xml b/input/regression/musicxml/99a-Sibelius5-IgnoreBeaming.xml new file mode 100644 index 0000000000..e0a922d0a8 Binary files /dev/null and b/input/regression/musicxml/99a-Sibelius5-IgnoreBeaming.xml differ diff --git a/python/musicexp.py b/python/musicexp.py index b266830d07..1596cd392b 100644 --- a/python/musicexp.py +++ b/python/musicexp.py @@ -835,7 +835,6 @@ class BracketSpannerEvent (SpanEvent): 1:'\\stopGroup'}.get (self.span_direction, '') -# type==-1 means octave up, type==-2 means octave down class OctaveShiftEvent (SpanEvent): def wait_for_note (self): return False diff --git a/python/musicxml.py b/python/musicxml.py index 9d6fa054db..f028cce8a3 100644 --- a/python/musicxml.py +++ b/python/musicxml.py @@ -179,6 +179,16 @@ class Identification (Xml_node): return self.get_encoding_information ('encoder') def get_encoding_description (self): return self.get_encoding_information ('encoding-description') + + def get_encoding_software_list (self): + enc = self.get_named_children ('encoding') + software = [] + for e in enc: + softwares = e.get_named_children ('software') + for s in softwares: + software.append (s.get_text ()) + return software + class Duration (Music_xml_node): diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index 2e22f8e76c..5e791abf44 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -24,6 +24,12 @@ from rational import Rational # Store command-line options in a global variable, so we can access them everythwere options = None +class Conversion_Settings: + def __init__(self): + self.ignore_beaming = False + +conversion_settings = Conversion_Settings () + def progress (str): ly.stderr_write (str + '\n') sys.stderr.flush () @@ -177,6 +183,19 @@ def extract_score_information (tree): set_if_exists ('encoder', ids.get_encoding_person ()) set_if_exists ('encodingdescription', ids.get_encoding_description ()) + # Finally, apply the required compatibility modes + # Some applications created wrong MusicXML files, so we need to + # apply some compatibility mode, e.g. ignoring some features/tags + # in those files + software = ids.get_encoding_software_list () + global conversion_settings + + # Case 1: "Sibelius 5.1" with the "Dolet 3.4 for Sibelius" plugin + # is missing all beam ends => ignore all beaming information + if "Dolet 3.4 for Sibelius" in software: + conversion_settings.ignore_beaming = True + # TODO: Check for other unsupported features + return header class PartGroupInfo: @@ -1675,7 +1694,7 @@ def musicxml_voice_to_lily_voice (voice): mxl_beams = [b for b in n.get_named_children ('beam') if (b.get_type () in ('begin', 'end') and b.is_primary ())] - if mxl_beams: + if mxl_beams and not conversion_settings.ignore_beaming: beam_ev = musicxml_spanner_to_lily_event (mxl_beams[0]) if beam_ev: ev_chord.append (beam_ev)