[frogs] patch for issue 708 |
[ Thread Index |
Date Index
| More lilynet.net/frogs Archives
]
- To: lilypond-devel <lilypond-devel@xxxxxxx>, "frogs@xxxxxxxxxxx" <frogs@xxxxxxxxxxx>
- Subject: [frogs] patch for issue 708
- From: Andrew Hawryluk <ahawryluk@xxxxxxxxx>
- Date: Fri, 22 May 2009 21:11:30 -0600
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=Gtl65CkT9xqfFL/NdDLZcyImwhvdWdlQ8MKfier8mL4=; b=n0Dkq66ncULKj+EbQP7e25On1FWMhrGo36a/LBNWAQukbQgSHlKK079+FaAX5qO1yQ QI/NaDgrZA3ChANuPpkwaF7Xn6XGCRCq74GlwIxlqkocwMtvgetZA3iQykPiHVpPtjXB yzZWu2fiwGLfkqiWZe2s0X8FOlahCKJUhkOgU=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=LVM9ifetG/sHmzh0Kw0RYnBzb66lV4hGXNzjnP6iCrsEmThTR+NvtaiTar15SmqOFO FB6jG4MU9kJKZjcog0McnQHKg7rNPEeH5T+lQfktZ+vhtTcZzSn+irt6XQPjZqmilZ9D U9GOVsWoOwBR6EjgGdrU/n0P0HvsuI4Mga3SE=
This patch will allow convert-ly to process this:
\version "2.11.0"
{
c d'4 ees
\set Staff.keySignature = #`(((1 . 4) . 2) ((1 . 3) . 2) ((3 . 3) 2))
f^"some text"
\set Staff.keySignature = #`(((1 . 4) . -2)
((1 . 3) . -4))
}
and output this:
convert-ly (GNU LilyPond) 2.13.1
Processing `test.ly'...
Applying conversion: 2.11.2, 2.11.3, 2.11.5, 2.11.6, 2.11.10, 2.11.11,
2.11.13, 2.11.15, 2.11.23, 2.11.35, 2.11.38, 2.11.46, 2.11.48,
2.11.50, 2.11.51, 2.11.52, 2.11.53, 2.11.55, 2.11.57, 2.11.60,
2.11.61, 2.11.62, 2.11.64, 2.12.0, 2.12.3, 2.13.0,
Not smart enough to convert Staff.keySignature - the alist is no
longer in reversed order.
2.13.1
\version "2.13.1"
{
c d'4 ees
\set Staff.keySignature = #`(((1 . 4) . ,SHARP)
((1 . 3) . ,SHARP)
((3 . 3) . ,SHARP))
f^"some text"
\set Staff.keySignature = #`(((1 . 4) . ,FLAT)
((1 . 3) . ,DOUBLE-FLAT))
}
From d60c53f7d8d6b94acc029f5040c69ee48639df26 Mon Sep 17 00:00:00 2001
From: Andrew Hawryluk <ahawryluk@xxxxxxxxx>
Date: Fri, 22 May 2009 20:57:24 -0600
Subject: [PATCH] Improved keySignature support in convert-ly
Added rules to convert pitch numbers to names, fixed
a bug that prevented the 2.13.0 rule from warning the
user that the keySignature alist order had changed.
---
python/convertrules.py | 64 ++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 56 insertions(+), 8 deletions(-)
diff --git a/python/convertrules.py b/python/convertrules.py
index c9a8394..fb14f3b 100644
--- a/python/convertrules.py
+++ b/python/convertrules.py
@@ -1420,6 +1420,26 @@ def conv (str):
return '(ly:make-pitch %s %s %s)' % (m.group(1), m.group (2),
alt)
+ def fixKS(m):
+ words = { '-2': "DOUBLE-FLAT",
+ '-1': "FLAT",
+ '0': "NATURAL",
+ '1': "SHARP",
+ '2': "DOUBLE-SHARP"}
+ parts = m.group().split("`")
+ if len(parts) != 2:
+ return m.group()
+ numbers = re.findall(r'-?\d+',parts[1])
+ if len(numbers) % 3 != 0:
+ return m.group()
+ newalterations = []
+ for i in range(len(numbers) / 3):
+ newalterations.append('(('+numbers[i*3]+' . '+numbers[i*3+1]+') . ,'+
+ words[numbers[i*3+2]]+')')
+ whitespace = '\n'+' '*(len(parts[0])+2)
+ output = parts[0]+'`('+whitespace.join(newalterations)+')'
+ return output
+
str =re.sub ("\\(ly:make-pitch *([0-9-]+) *([0-9-]+) *([0-9-]+) *\\)",
sub_alteration, str)
@@ -1437,19 +1457,19 @@ Please hand-edit, using
as a substitution text.""") % (m.group (1), m.group (2)) )
raise FatalConversionError ()
- if re.search ("ly:(make-pitch|pitch-alteration)", str) \
- or re.search ("keySignature", str):
+ if re.search ("ly:(make-pitch|pitch-alteration)", str):
stderr_write ('\n')
stderr_write (NOT_SMART % "pitches")
stderr_write ('\n')
stderr_write (
_ ("""The alteration field of Scheme pitches was multiplied by 2
-to support quarter tone accidentals. You must update the following constructs manually:
-
-* calls of ly:make-pitch and ly:pitch-alteration
-* keySignature settings made with \property
+to support quarter tone accidentals. You must update the following construct
+manually: calls of ly:make-pitch and ly:pitch-alteration
"""))
raise FatalConversionError ()
+
+ findKeySig = re.compile(r'\\property\s+\w+\.keySignature .*?\)\s*\)',re.DOTALL)
+ str = findKeySig.sub(fixKS,str)
return str
@@ -2616,6 +2636,34 @@ def conv (str):
## FIXME: standard vs default, alteration-FOO vs FOO-alteration
str = str.replace ('alteration-default-glyph-name-alist',
'standard-alteration-glyph-name-alist')
+
+ def fixKS(m):
+ words = { '-4': "DOUBLE-FLAT",
+ '-3': "THREE-Q-FLAT",
+ '-2': "FLAT",
+ '-1': "SEMI-FLAT",
+ '0': "NATURAL",
+ '1': "SEMI-SHARP",
+ '2': "SHARP",
+ '3': "THREE-Q-SHARP",
+ '4': "DOUBLE-SHARP"}
+ parts = m.group().split("`")
+ if len(parts) != 2:
+ return m.group()
+ numbers = re.findall(r'-?\d+',parts[1])
+ if len(numbers) % 3 != 0:
+ return m.group()
+ newalterations = []
+ for i in range(len(numbers) / 3):
+ newalterations.append('(('+numbers[i*3]+' . '+numbers[i*3+1]+') . ,'+
+ words[numbers[i*3+2]]+')')
+ whitespace = '\n'+' '*(len(parts[0])+2)
+ output = parts[0]+'`('+whitespace.join(newalterations)+')'
+ return output
+
+ findKeySig = re.compile(r'\\set\s+\w+\.keySignature .*?\)\s*\)',re.DOTALL)
+ str = findKeySig.sub(fixKS,str)
+
return str
@@ -2883,9 +2931,9 @@ def conv(str):
@rule ((2, 13, 0), _ ("keySignature property not reversed any more\n\
MIDI 47: orchestral strings -> orchestral harp"))
def conv(str):
- if re.search(r'\set Staff.keySignature', str):
+ if re.search(r'\\set\s+\w+\.keySignature',str):
stderr_write ("\n")
- stderr_write (NOT_SMART % _("The alist for Staff.keySignature is no \
+ stderr_write (NOT_SMART % _("Staff.keySignature - the alist is no \
longer in reversed order.\n"))
str = str.replace('"orchestral strings"', '"orchestral harp"')
return str
--
1.6.0.4