Added modifier

Added modifier and refactored cycles
This commit is contained in:
2023-02-08 22:34:30 +02:00
parent bb928f7c64
commit f51b230099
3 changed files with 15 additions and 13 deletions

View File

@ -101,10 +101,15 @@ class ZiffersTransformer(Transformer):
return {"octave": int(value), "text": items[0].value}
def octave(self, items):
"""Return octave info"""
"""Return octaves ^ and _"""
value = sum(1 if char == "^" else -1 for char in items[0].value)
return {"octave": value, "text": items[0].value}
def modifier(self, items):
"""Return modifiers # and b"""
value = 1 if items[0].value == "#" else -1
return {"modifier": value}
def chord(self, items):
"""Parses chord"""
return Chord(pitch_classes=items, text="".join([val.text for val in items]))