diff --git a/engine/api.py b/engine/api.py index 67b78d8..4b1fe5f 100644 --- a/engine/api.py +++ b/engine/api.py @@ -1907,7 +1907,6 @@ def insertCommonKeySignature(root:int, scheme:str): "Mixolydian": [0,0,0,0,0,0,-10], "Locrian": [0,-10,-10,0,-10,-10,-10], "Hollywood": [0,0,0,0,0,-10,-10], #The "Hollywood"-Scale. Stargate, Lord of the Rings etc. - #TODO: MOAR! } #Lilypond knows some standard key signature modes, which produce cleaner output than our default verbose note-for-note one. @@ -1915,7 +1914,7 @@ def insertCommonKeySignature(root:int, scheme:str): if scheme.lower() in lySupported: lyRootNote = pitchmath.pitch2ly[root].strip("'").strip(",").lower() - lyovrd = f"\\key {lyRootNote} \\{scheme.lower()}" + lyovrd = f"\n\\key {lyRootNote} \\{scheme.lower()}\n" else: lyovrd = None diff --git a/engine/items.py b/engine/items.py index 8390970..1c0cfa1 100644 --- a/engine/items.py +++ b/engine/items.py @@ -2276,18 +2276,26 @@ class KeySignature(Item): elif alteration == -20: return "(" + str(step) + " . ," + "DOUBLE-FLAT)" elif self.lilypondParameters["explicit"] and alteration == 0: - return "(" + str(step) + " . ," + "NATURAL)" + 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: - return "" + 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(schemepairs.split()) # split and join again to reduce all whitespaces to single ones. - subtextRoot = "\\once \\override Staff.KeySignature #'stencil = #(lambda (grob) (ly:stencil-combine-at-edge (ly:key-signature-interface::print grob) Y DOWN (grob-interpret-markup grob (markup #:small \"" + pitchmath.pitch2ly[self.root].strip(",").title() + "\")) 3)) " #3 is the space between keysig and text - lyKeysignature = subtextRoot + "\\set Staff.keyAlterations = #`( {} )".format(schemepairs) + assert schemepairs + #For Transposition in lilypond we need to explicitly export all scheme pairs, not only the one that differ from major. + + #subtextRoot = "\\once \\override Staff.KeySignature #'stencil = #(lambda (grob) (ly:stencil-combine-at-edge (ly:key-signature-interface::print grob) Y DOWN (grob-interpret-markup grob (markup #:small \"" + pitchmath.pitch2ly[self.root].strip(",").title() + "\")) 3)) " #3 is the space between keysig and text + #lyKeysignature = subtextRoot + "\\set Staff.keyAlterations = #`( {} )".format(schemepairs) + + lyKeysignature = f"\n\\key {pitchmath.pitch2ly[self.root].strip(',')} #`( {schemepairs} )\n" return lyKeysignature + + #!!!!THIS IS DEAD CODE!! + #Alternative schemepairs = " ".join(build(num, alt) for num, alt in enumerate(self.deviationFromMajorScale)) schemepairs = " ".join(schemepairs.split()) # split and join again to reduce all whitespaces to single ones. diff --git a/engine/track.py b/engine/track.py index 922724d..1dfc8f9 100644 --- a/engine/track.py +++ b/engine/track.py @@ -865,8 +865,7 @@ class Track(object): keySignature = "" break else: - keySignature = self.initialKeySignature.lilypond(carryLilypondRanges) + "\n" - + keySignature = self.initialKeySignature.lilypond(carryLilypondRanges) upbeatLy = "\\partial {} ".format(Duration.createByGuessing(self.upbeatInTicks).lilypond(carryLilypondRanges)) if self.upbeatInTicks else ""