From 941dd3abc5ae66018aa1999d13e6c9c45f378564 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Sun, 23 Sep 2007 14:08:21 +0200 Subject: [PATCH] MusicXML: Better support for drums -) 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 --- python/musicxml.py | 12 +++++++----- scripts/musicxml2ly.py | 5 +++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/python/musicxml.py b/python/musicxml.py index e9660eb571..80b332bf64 100644 --- a/python/musicxml.py +++ b/python/musicxml.py @@ -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 element): %s\n" % self) + self.message ("Encountered note at %s without %s duration (no 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 (): diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index 857333ca20..48e0900658 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -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: -- 2.39.5