]> git.donarmstrong.com Git - lilypond.git/blobdiff - scripts/musicxml2ly.py
Merge commit 'origin'
[lilypond.git] / scripts / musicxml2ly.py
index d5d421ef9d485396306ef6e40772f63520e96a66..52e697148786be8a306b4a50bd964bacfbd86e10 100644 (file)
@@ -45,37 +45,6 @@ def error_message (str):
 needed_additional_definitions = []
 additional_definitions = {
 
-  "snappizzicato": """#(define-markup-command (snappizzicato layout props) ()
-  (interpret-markup layout props
-    (markup #:stencil
-      (ly:stencil-translate-axis
-        (ly:stencil-add
-          (make-circle-stencil 0.7 0.1 #f)
-          (ly:make-stencil
-            (list 'draw-line 0.1 0 0.1 0 1)
-            '(-0.1 . 0.1) '(0.1 . 1)))
-        0.7 X))))""",
-
-  "eyeglasses": """eyeglassesps = #"0.15 setlinewidth
-      -0.9 0 translate
-      1.1 1.1 scale
-      1.2 0.7 moveto
-      0.7 0.7 0.5 0 361 arc
-      stroke
-      2.20 0.70 0.50 0 361 arc
-      stroke
-      1.45 0.85 0.30 0 180 arc
-      stroke
-      0.20 0.70 moveto
-      0.80 2.00 lineto
-      0.92 2.26 1.30 2.40 1.15 1.70 curveto
-      stroke
-      2.70 0.70 moveto
-      3.30 2.00 lineto
-      3.42 2.26 3.80 2.40 3.65 1.70 curveto
-      stroke"
-eyeglasses =  \markup { \with-dimensions #'(0 . 4.4) #'(0 . 2.5) \postscript #eyeglassesps }""",
-
   "tuplet-note-wrapper": """      % a formatter function, which is simply a wrapper around an existing 
       % tuplet formatter function. It takes the value returned by the given
       % function and appends a note of given length. 
@@ -341,6 +310,10 @@ def extract_score_information (tree):
         if "Dolet 3.4 for Sibelius" in software:
             conversion_settings.ignore_beaming = True
             progress (_ ("Encountered file created by Dolet 3.4 for Sibelius, containing wrong beaming information. All beaming information in the MusicXML file will be ignored"))
+        # ditto for Dolet 3.5
+        if "Dolet 3.5 for Sibelius" in software:
+            conversion_settings.ignore_beaming = True
+            progress (_ ("Encountered file created by Dolet 3.5 for Sibelius, containing wrong beaming information. All beaming information in the MusicXML file will be ignored"))
         if "Noteworthy Composer" in software:
             conversion_settings.ignore_beaming = True
             progress (_ ("Encountered file created by Noteworthy Composer's nwc2xml, containing wrong beaming information. All beaming information in the MusicXML file will be ignored"))
@@ -750,7 +723,7 @@ def musicxml_tuplet_to_lily (tuplet_elt, time_modification):
     actual_type = tuplet_elt.get_actual_type ()
     if actual_type:
         actual_note = musicexp.Duration ()
-        (actual_note.duration_log, actual_note.dots) = normal_type
+        (actual_note.duration_log, actual_note.dots) = actual_type
         tsm.actual_type = actual_note
 
     # Obtain non-default nrs of notes from the tuplet object!
@@ -768,14 +741,8 @@ def musicxml_tuplet_to_lily (tuplet_elt, time_modification):
     display_values = {"none": None, "actual": "actual", "both": "both"}
     if hasattr (tuplet_elt, "show-number"):
         tsm.display_number = display_values.get (getattr (tuplet_elt, "show-number"), "actual")
-    if tsm.display_number == "actual" and tsm.display_denominator:
-        needed_additional_definitions.append ("tuplet-non-default-denominator")
-    elif tsm.display_number == "both" and (tsm.display_numerator or tsm.display_denominator):
-        needed_additional_definitions.append ("tuplet-non-default-fraction")
 
     if hasattr (tuplet_elt, "show-type"):
-        if getattr (tuplet_elt, "show-type") == "actual":
-            needed_additional_definitions.append ("tuplet-note-wrapper")
         tsm.display_type = display_values.get (getattr (tuplet_elt, "show-type"), None)
 
     return tsm
@@ -1140,12 +1107,6 @@ def musicxml_fingering_event (mxl_event):
     ev.type = mxl_event.get_text ()
     return ev
 
-def musicxml_snappizzicato_event (mxl_event):
-    needed_additional_definitions.append ("snappizzicato")
-    ev = musicexp.MarkupEvent ()
-    ev.contents = "\\snappizzicato"
-    return ev
-
 def musicxml_string_event (mxl_event):
     ev = musicexp.NoDirectionArticulationEvent ()
     ev.type = mxl_event.get_text ()
@@ -1207,7 +1168,7 @@ articulations_dict = {
     #"schleifer": "?",
     #"scoop": "?",
     #"shake": "?",
-    "snap-pizzicato": musicxml_snappizzicato_event,
+    "snap-pizzicato": "snappizzicato",
     #"spiccato": "?",
     "staccatissimo": (musicexp.ShortArticulationEvent, "|"), # or "staccatissimo"
     "staccato": (musicexp.ShortArticulationEvent, "."), # or "staccato"
@@ -1450,7 +1411,7 @@ def musicxml_harp_pedals_to_ly (mxl_event):
 
 def musicxml_eyeglasses_to_ly (mxl_event):
     needed_additional_definitions.append ("eyeglasses")
-    return musicexp.MarkEvent ("\\eyeglasses")
+    return musicexp.MarkEvent ("\\markup { \\eyeglasses }")
 
 def next_non_hash_index (lst, pos):
     pos += 1
@@ -1837,8 +1798,9 @@ def musicxml_note_to_lily_main_event (n):
         # treated like an ordinary note pitch
         rest = n.get_maybe_exist_typed_child (musicxml.Rest)
         event = musicexp.RestEvent ()
-        pitch = musicxml_restdisplay_to_lily (rest)
-        event.pitch = pitch
+        if options.convert_rest_positions:
+            pitch = musicxml_restdisplay_to_lily (rest)
+            event.pitch = pitch
 
     elif n.instrument_name:
         event = musicexp.NoteEvent ()
@@ -2313,8 +2275,7 @@ def musicxml_voice_to_lily_voice (voice):
                 if len (endslurs) > 1:
                     endslurs[0].message (_ ('Cannot have two simultaneous (closing) slurs'))
                 # record the slur status for the next note in the loop
-                if not grace:
-                    inside_slur = False
+                inside_slur = False
                 lily_ev = musicxml_spanner_to_lily_event (endslurs[0])
                 ev_chord.append (lily_ev)
 
@@ -2326,8 +2287,7 @@ def musicxml_voice_to_lily_voice (voice):
                 if len (startslurs) > 1:
                     startslurs[0].message (_ ('Cannot have two simultaneous slurs'))
                 # record the slur status for the next note in the loop
-                if not grace:
-                    inside_slur = True
+                inside_slur = True
                 lily_ev = musicxml_spanner_to_lily_event (startslurs[0])
                 ev_chord.append (lily_ev)
 
@@ -2573,7 +2533,7 @@ If the given filename is -, musicxml2ly reads from the command line.
 
     p.version = ('''%prog (LilyPond) @TOPLEVEL_VERSION@\n\n'''
 +
-_ ("""Copyright (c) 2005--2008 by
+_ ("""Copyright (c) 2005--2009 by
     Han-Wen Nienhuys <hanwen@xs4all.nl>,
     Jan Nieuwenhuizen <janneke@gnu.org> and
     Reinhold Kainhofer <reinhold@kainhofer.com>
@@ -2628,6 +2588,12 @@ information.""") % 'lilypond')
                   dest = "convert_directions",
                   help = _ ("do not convert directions (^, _ or -) for articulations, dynamics, etc."))
 
+    p.add_option ('--nrp', '--no-rest-positions', 
+                  action = "store_false",
+                  default = True,
+                  dest = "convert_rest_positions",
+                  help = _ ("do not convert exact vertical positions of rests"))
+
     p.add_option ('--no-beaming', 
                   action = "store_false",
                   default = True,
@@ -2642,9 +2608,10 @@ information.""") % 'lilypond')
                   dest = 'output_name',
                   help = _ ("set output filename to FILE, stdout if -"))
     p.add_option_group ('',
-                        description = (_ ("Report bugs via")
-                                     + ''' http://post.gmane.org/post.php'''
-                                     '''?group=gmane.comp.gnu.lilypond.bugs\n'''))
+                        description = (
+            _ ("Report bugs via %s")
+            % 'http://post.gmane.org/post.php'
+            '?group=gmane.comp.gnu.lilypond.bugs') + '\n')
     return p
 
 def music_xml_voice_name_to_lily_name (part_id, name):