Modify tokenizer to parse notes

This commit is contained in:
Bartłomiej Pluta
2019-07-05 18:36:12 +02:00
parent ad19e851ec
commit 425d23eb5f
9 changed files with 70 additions and 101 deletions

View File

@@ -1,7 +1,13 @@
from smnp.note.pitch import NotePitch
class Note:
def __init__(self, note, octave = 4, duration = 4, dot = False):
def __init__(self, note, octave, duration, dot = False):
if octave is None:
octave = 4
if duration is None:
duration = 4
if type(note) == str:
self.note = NotePitch.toPitch(note)
else:

0
smnp/note/note.py Normal file
View File

View File

@@ -47,6 +47,7 @@ class NotePitch(Enum):
raise NoteException(f"Note '{string}' does not exist")
stringToPitch = {
'cb': NotePitch.H,
'c': NotePitch.C,
'c#': NotePitch.CIS,
'db': NotePitch.CIS,