Browse Source

Fix lilypond keysig regressions. update ly template to v2.22

master
Nils 2 years ago
parent
commit
d90226d67c
  1. 19
      engine/items.py
  2. 2
      engine/lilypond.py
  3. 2
      engine/resources/lilypondTemplates/default.ly

19
engine/items.py

@ -2266,7 +2266,19 @@ class KeySignature(Item):
} }
def _lilypond(self, carryLilypondRanges): 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 def build(step, alteration): #generate a Scheme pair for Lilyponds GUILE interpreter
assert 0 <= step <= 6, step
if alteration == -10: if alteration == -10:
return "(" + str(step) + " . ," + "FLAT)" return "(" + str(step) + " . ," + "FLAT)"
elif alteration == 10: elif alteration == 10:
@ -2275,14 +2287,11 @@ class KeySignature(Item):
return "(" + str(step) + " . ," + "DOUBLE-SHARP)" return "(" + str(step) + " . ," + "DOUBLE-SHARP)"
elif alteration == -20: elif alteration == -20:
return "(" + str(step) + " . ," + "DOUBLE-FLAT)" 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: else:
assert alteration == 0, alteration
return "(" + str(step) + " . ," + "NATURAL)" return "(" + str(step) + " . ," + "NATURAL)"
#G Major ((3, 10), (0, 0), (4, 0), (1, 0), (5, 0), (2, 0), (6, 0)) schemepairs = " ".join(build(i, dev) for i, dev in enumerate(self.deviationFromMajorScale))
#`((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(schemepairs.split()) # split and join again to reduce all whitespaces to single ones. schemepairs = " ".join(schemepairs.split()) # split and join again to reduce all whitespaces to single ones.
assert schemepairs assert schemepairs
#For Transposition in lilypond we need to explicitly export all scheme pairs, not only the one that differ from major. #For Transposition in lilypond we need to explicitly export all scheme pairs, not only the one that differ from major.

2
engine/lilypond.py

@ -180,7 +180,7 @@ def processData(data):
def structure(track, lilypondTrack): def structure(track, lilypondTrack):
""" \new Staff = "tgliHJuGCFAIICICBEHBJABHIJE_Staff" << \\new Voice = "tgliHJuGCFAIICICBEHBJABHIJE" \tgliHJuGCFAIICICBEHBJABHIJE >> %EndTrack """ """ \new Staff = "tgliHJuGCFAIICICBEHBJABHIJE_Staff" << \\new Voice = "tgliHJuGCFAIICICBEHBJABHIJE" \tgliHJuGCFAIICICBEHBJABHIJE >> %EndTrack """
name = stringToCharsOnlyString(track.name) name = stringToCharsOnlyString(track.name)
instruments = '\\with {{ \n instrumentName = #"{}" \n shortInstrumentName = #"{}" }}'.format(lilyfy(track.initialInstrumentName), lilyfy(track.initialShortInstrumentName)) instruments = '\\with {{ \n instrumentName = #"{}" \n shortInstrumentName = #"{}" }}\n'.format(lilyfy(track.initialInstrumentName), lilyfy(track.initialShortInstrumentName))
mergeTempo = "\\new Voice = \"Tempo\" \\tempoStaff" mergeTempo = "\\new Voice = \"Tempo\" \\tempoStaff"
return """\\new Staff = "{}_Staff" {} << {} \\new Voice = "{}" \{} >> %EndTrack""".format(name, instruments, mergeTempo, name, name) return """\\new Staff = "{}_Staff" {} << {} \\new Voice = "{}" \{} >> %EndTrack""".format(name, instruments, mergeTempo, name, name)

2
engine/resources/lilypondTemplates/default.ly

@ -2,7 +2,7 @@
%% Generation Date: %$$DATE$$ %% Generation Date: %$$DATE$$
%% Filename: %$$FILENAME$$ %% Filename: %$$FILENAME$$
\version "2.18" \version "2.22"
#(set-default-paper-size "a4") #(set-default-paper-size "a4")
#(set-global-staff-size 18 ) #(set-global-staff-size 18 )
#(ly:set-option 'point-and-click #f) #(ly:set-option 'point-and-click #f)

Loading…
Cancel
Save