|
|
@ -1652,8 +1652,10 @@ def insertLegatoSlur(): |
|
|
|
|
|
|
|
|
|
|
|
#Key Signatures |
|
|
|
def insertKeySignature(root, scheme): |
|
|
|
def insertKeySignature(root:int, scheme:list, lilypondOverride:str=None): |
|
|
|
keysig = items.KeySignature(pitchmath.plain(root), scheme) |
|
|
|
if lilypondOverride: |
|
|
|
keysig.lilypondParameters["override"] = lilypondOverride |
|
|
|
insertItem(keysig) |
|
|
|
|
|
|
|
def commonKeySignaturesAsList(): |
|
|
@ -1673,7 +1675,7 @@ def commonKeySignaturesAsList(): |
|
|
|
"Hollywood", |
|
|
|
] |
|
|
|
|
|
|
|
def insertCommonKeySignature(root, scheme): |
|
|
|
def insertCommonKeySignature(root:int, scheme:str): |
|
|
|
"""example: |
|
|
|
insertCommonKeySignature(P_C, "Major") |
|
|
|
""" |
|
|
@ -1688,13 +1690,28 @@ def insertCommonKeySignature(root, scheme): |
|
|
|
"Hollywood": [0,0,0,0,0,-10,-10], #The "Hollywood"-Scale. Stargate, Lord of the Rings etc. |
|
|
|
#TODO: MOAR! |
|
|
|
} |
|
|
|
insertKeySignature(root, schemes[scheme]) |
|
|
|
|
|
|
|
def insertCursorCommonKeySignature(scheme): |
|
|
|
#Lilypond knows some standard key signature modes, which produce cleaner output than our default verbose note-for-note one. |
|
|
|
lySupported = ("major", "minor", "dorian", "phrygian", "lydian", "mixolydian", "locrian") |
|
|
|
|
|
|
|
if scheme.lower() in lySupported: |
|
|
|
lyRootNote = pitchmath.pitch2ly[root].strip("'").strip(",").lower() |
|
|
|
lyovrd = f"\\key {lyRootNote} \\{scheme.lower()}" |
|
|
|
else: |
|
|
|
lyovrd = None |
|
|
|
|
|
|
|
insertKeySignature(root, schemes[scheme], lilypondOverride=lyovrd) |
|
|
|
|
|
|
|
def insertCursorCommonKeySignature(scheme:str): |
|
|
|
"""Root note is generated from the cursor pitch position and takes the previous keysig |
|
|
|
into account.""" |
|
|
|
root = pitchmath.plain(session.data.cursor.pitchindex) |
|
|
|
into account. |
|
|
|
|
|
|
|
Scheme is a string as seen in commonKeySignaturesAsList() |
|
|
|
""" |
|
|
|
if not scheme in commonKeySignaturesAsList(): |
|
|
|
raise ValueError("Unknown key signature scheme string: " + scheme) |
|
|
|
|
|
|
|
root = pitchmath.plain(session.data.cursor.pitchindex) |
|
|
|
keysig = session.data.currentTrack().state.keySignature() |
|
|
|
pitchToInsert = pitchmath.toScale(session.data.cursor.pitchindex, keysig) |
|
|
|
|
|
|
|