]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3264: Let lilymidi display key signatures in a readable manner
authorDavid Kastrup <dak@gnu.org>
Tue, 19 Mar 2013 11:51:44 +0000 (12:51 +0100)
committerDavid Kastrup <dak@gnu.org>
Tue, 26 Mar 2013 20:28:59 +0000 (21:28 +0100)
Before this patch, key signatures were just displayed as a binary
string reflecting the Midi message.

scripts/lilymidi.py

index 40047207ad311c2a26827d7628bc439a331eb25e..20d13aa5082d754708d1168f89f749c7b7220d57 100644 (file)
@@ -87,7 +87,10 @@ class time_signature_formatter (formatter):
      return str (val2)   # TODO
 class key_signature_formatter (formatter):
    def format_vals (self, val1, val2):
-     return str (val2)   # TODO
+       key_names = ['F', 'C', 'G', 'D', 'A', 'E', 'B']
+       key = (((ord(val2[0])+128)%256)-128) + ord(val2[1])*3 + 1;
+       return (key_names[key%7] + (key/7) * "is" + (-(key/7)) * "es"
+               + " " + ['major','minor'][ord(val2[1])])
 class channel_formatter (formatter):
    def __init__ (self, txt, ch):
      formatter.__init__ (self, txt)