From: Reinhold Kainhofer Date: Wed, 27 Feb 2008 14:36:51 +0000 (+0100) Subject: MusicXML: Add support for longa and breve notes, fix error messages X-Git-Tag: release/2.11.42-1~11 X-Git-Url: https://git.donarmstrong.com/lilypond.git?a=commitdiff_plain;h=ae5ed277f33a37a62097dbf850552cbbb122ec9e;p=lilypond.git MusicXML: Add support for longa and breve notes, fix error messages -) Longa and breve notes have a duration_log < 0, so I can't use 1< --- diff --git a/input/regression/musicxml/00c-Basics-Durations.xml b/input/regression/musicxml/00c-Basics-Durations.xml index cbb8dc62ed..4674d04517 100644 --- a/input/regression/musicxml/00c-Basics-Durations.xml +++ b/input/regression/musicxml/00c-Basics-Durations.xml @@ -15,13 +15,13 @@ - 32 + 64 0 major - - - C 5 - 128 - + 512 1 - whole - - - + breve - + C 5 - 128 + 256 1 whole - - - C 5 - 64 + 128 1 half down @@ -89,7 +75,7 @@ C 5 - 32 + 64 1 quarter down @@ -99,7 +85,7 @@ C 5 - 16 + 32 1 eighth down @@ -110,7 +96,7 @@ C 5 - 8 + 16 1 16th down @@ -122,7 +108,7 @@ C 5 - 4 + 8 1 32nd down @@ -135,7 +121,7 @@ C 5 - 2 + 4 1 64th down @@ -149,7 +135,7 @@ C 5 - 1 + 2 1 128th down @@ -164,7 +150,7 @@ C 5 - 1 + 2 1 128th down @@ -176,37 +162,56 @@ + + + + C + 5 + + 1536 + 1 + longa + + + + C 5 - 96 + 768 1 - half + breve - down C 5 - 32 + 384 1 - quarter - down + whole + - - - C 5 - 48 + 192 + 1 + half + + + + + C + 5 + + 96 1 quarter @@ -217,7 +222,7 @@ C 5 - 24 + 48 1 eighth @@ -229,7 +234,7 @@ C 5 - 12 + 24 1 16th @@ -242,7 +247,7 @@ C 5 - 6 + 12 1 32nd @@ -256,11 +261,10 @@ C 5 - 3 + 6 1 64th - down continue continue continue @@ -271,11 +275,10 @@ C 5 - 2 + 3 1 128th - down continue continue continue @@ -287,11 +290,10 @@ C 5 - 2 + 3 1 128th - down end end end diff --git a/python/musicexp.py b/python/musicexp.py index adce691101..862b5d8c4f 100644 --- a/python/musicexp.py +++ b/python/musicexp.py @@ -2,9 +2,9 @@ import inspect import sys import string import re -import lilylib +import lilylib as ly -_ = lilylib._ +_ = ly._ from rational import Rational @@ -155,8 +155,12 @@ class Duration: def ly_expression (self, factor = None): if not factor: factor = self.factor - - str = '%d%s' % (1 << self.duration_log, '.'*self.dots) + + if self.duration_log < 0: + str = {-1: "\\breve", -2: "\\longa"}.get (self.duration_log, "1") + else: + str = '%d' % (1 << self.duration_log) + str += '.'*self.dots if factor <> Rational (1,1): if factor.denominator () <> 1: diff --git a/python/musicxml.py b/python/musicxml.py index e9d1ef8bed..7c398e1e5d 100644 --- a/python/musicxml.py +++ b/python/musicxml.py @@ -5,9 +5,9 @@ from rational import * import re import sys import copy -import lilylib +import lilylib as ly -_ = lilylib._ +_ = ly._ def error (str): ly.stderr_write ((_ ("error: %s") % str) + "\n") @@ -51,7 +51,7 @@ class Xml_node: return ''.join ([c.get_text () for c in self._children]) def message (self, msg): - lilylib.stderr_write (msg+'\n') + ly.stderr_write (msg+'\n') p = self while p: @@ -340,7 +340,7 @@ class Note (Measure_element): 'half': 1, 'whole': 0, 'breve': -1, - 'long': -2}.get (log, 0) + 'longa': -2}.get (log, 0) elif self.get_maybe_exist_named_child (u'grace'): # FIXME: is it ok to default to eight note for grace notes? return 3 @@ -379,7 +379,7 @@ class Part_list (Music_xml_node): if instrument_name: return instrument_name else: - lilylib.stderr_write (_ ("Unable to find find instrument for ID=%s\n") % id) + ly.stderr_write (_ ("Unable to find find instrument for ID=%s\n") % id) return "Grand Piano" class Part_group (Music_xml_node): diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index e594aa7d47..f808a8325b 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -1386,6 +1386,7 @@ class LilyPondVoiceBuilder: else: duration_factor = Rational (diff.numerator ()) else: + # for skips of a whole or more, simply use s1*factor duration_log = 0 duration_factor = diff skip.duration.duration_log = duration_log