]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Better support for drums
authorReinhold Kainhofer <reinhold@kainhofer.com>
Sun, 23 Sep 2007 12:08:21 +0000 (14:08 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Wed, 3 Oct 2007 16:40:35 +0000 (18:40 +0200)
-) Add the bass drum instrument
-) Ignore notes with the attribute print-object="no". These are
   typically notes that indicate midi output for tremolos and should
   not be printed.
-) Use the Musix_xml_node.message method to print out the warning about
   missing note types. This also prints out where the problem occurs.

Signed-off-by: Reinhold Kainhofer <reinhold@kainhofer.com>
python/musicxml.py
scripts/musicxml2ly.py

index e9660eb571ae13ccfd9512fc609bce19149e9a96..80b332bf6487cda846aada5e7e986e483ff89839 100644 (file)
@@ -278,7 +278,7 @@ class Note (Measure_element):
         self.instrument_name = ''
         
     def get_duration_log (self):
-        ch = self.get_maybe_exist_typed_child (get_class (u'type'))
+        ch = self.get_maybe_exist_named_child (u'type')
 
         if ch:
             log = ch.get_text ().strip()
@@ -294,7 +294,7 @@ class Note (Measure_element):
                     'breve': -1,
                     'long': -2}.get (log, 0)
         else:
-            sys.stderr.write ("Encountered note without duration (no <type> element): %s\n" % self)
+            self.message ("Encountered note at %s without %s duration (no <type> element):" % (self.start, self.duration) )
             return 0
 
     def get_factor (self):
@@ -572,8 +572,6 @@ class Part (Music_xml_node):
        for n in elements:
            voice_id = n.get_maybe_exist_typed_child (get_class ('voice'))
 
-            # TODO: If the first element of a voice is a dynamics entry,
-            #       then voice_id is not yet set! Thus it will currently be ignored
            if not (voice_id or isinstance (n, Attributes) or isinstance (n, Direction) ):
                continue
 
@@ -602,7 +600,11 @@ class Part (Music_xml_node):
                 continue
 
            id = voice_id.get_text ()
-           voices[id].add_element (n)
+            if hasattr (n, 'print-object') and getattr (n, 'print-object') == "no":
+                #Skip this note. 
+                pass
+            else:
+                voices[id].add_element (n)
 
        if start_attr:
             for (s, vids) in staff_to_voice_dict.items ():
index 857333ca2025e2f856c8d08f999a0e24f0dc937e..48e090065819ffcf73e4e1856e8d548fc764f2ad 100644 (file)
@@ -465,7 +465,8 @@ instrument_drumtype_dict = {
     'Side Stick': 'sidestick',
     'Open Triangle': 'opentriangle',
     'Mute Triangle': 'mutetriangle',
-    'Tambourine': 'tambourine'
+    'Tambourine': 'tambourine',
+    'Bass Drum': 'bassdrum',
 }
 
 def musicxml_note_to_lily_main_event (n):
@@ -497,7 +498,7 @@ def musicxml_note_to_lily_main_event (n):
         if drum_type:
             event.drum_type = drum_type
         else:
-            n.message ("drum %s type unknow, please add to instrument_drumtype_dict" % n.instrument_name)
+            n.message ("drum %s type unknown, please add to instrument_drumtype_dict" % n.instrument_name)
             event.drum_type = 'acousticsnare'
     
     if not event: