Added note parsing

This commit is contained in:
2023-02-07 22:26:20 +02:00
parent 04d84bcc47
commit 4bcdb2568a
3 changed files with 34 additions and 22 deletions

View File

@ -4,6 +4,7 @@ import itertools
import operator
import random
from .defaults import DEFAULT_OPTIONS
from .scale import note_from_pc
@dataclass
class Meta:
@ -79,6 +80,9 @@ class Pitch(Event):
octave: int = field(default=None)
note: int = field(default=None)
def set_note(self,note: int):
self.note = note
@dataclass
class RandomPitch(Event):
@ -198,7 +202,15 @@ class Ziffers(Sequence):
self.current = next(self.iterator) # Skip item
# Update collected options & default options
self.current.update_new(self.options)
# Resolve note from scale
if set(("key","scale")) <= self.options.keys():
if isinstance(self.current,(Pitch,RandomPitch)):
note = note_from_pc(self.options["key"],self.current.pitch_class,self.options["scale"])
self.current.set_note(note)
self.loop_i += 1
return self.current