@ -2266,7 +2266,19 @@ class KeySignature(Item):
}
def _lilypond ( self , carryLilypondRanges ) :
""" Lilyponds custom key signatures are also the difference to the C Major scale.
The \key X in front does not affect the scale building , it is a seconds step done by lilypond
So , it is actually the same as our system , we just need to build a SCHEME string .
This would be our hollywood - scale :
\key c #`( (0 . ,NATURAL) (1 . ,NATURAL) (2 . ,NATURAL) (3 . ,NATURAL) (4 . ,NATURAL) (5 . ,FLAT) (6 . ,FLAT) )
https : / / lilypond . org / doc / v2 .18 / Documentation / notation / displaying - pitches #key-signature
"""
def build ( step , alteration ) : #generate a Scheme pair for Lilyponds GUILE interpreter
assert 0 < = step < = 6 , step
if alteration == - 10 :
return " ( " + str ( step ) + " . , " + " FLAT) "
elif alteration == 10 :
@ -2275,14 +2287,11 @@ class KeySignature(Item):
return " ( " + str ( step ) + " . , " + " DOUBLE-SHARP) "
elif alteration == - 20 :
return " ( " + str ( step ) + " . , " + " DOUBLE-FLAT) "
elif self . lilypondParameters [ " explicit " ] and alteration == 0 :
return " ( " + str ( step ) + " . , " + " NATURAL) " #explicit is a legacy flag. It is not available to the user. We now (v2.2.0) always export everything explictely to get ly-transposition working
else :
assert alteration == 0 , alteration
return " ( " + str ( step ) + " . , " + " NATURAL) "
#G Major ((3, 10), (0, 0), (4, 0), (1, 0), (5, 0), (2, 0), (6, 0))
#`((0 . ,NATURAL) (1 . ,NATURAL) (2 . ,NATURAL) (3 . ,SHARP) (4 . ,NATURAL) (5 . ,NATURAL) (6 . ,NATURAL))
schemepairs = " " . join ( build ( x [ 0 ] , x [ 1 ] ) for x in self . keysigList )
schemepairs = " " . join ( build ( i , dev ) for i , dev in enumerate ( self . deviationFromMajorScale ) )
schemepairs = " " . join ( schemepairs . split ( ) ) # split and join again to reduce all whitespaces to single ones.
assert schemepairs
#For Transposition in lilypond we need to explicitly export all scheme pairs, not only the one that differ from major.