Degree based notation
Added parameter for degree based notation. Using degrees=True integers are interpreted as degrees and 0=Rest.
This commit is contained in:
@ -198,6 +198,7 @@ class Pitch(Event):
|
||||
key: str = field(default=None)
|
||||
scale: str | list = field(default=None)
|
||||
freq: float = field(default=None)
|
||||
degrees: bool = field(default=None)
|
||||
|
||||
def __post_init__(self):
|
||||
super().__post_init__()
|
||||
@ -246,6 +247,7 @@ class Pitch(Event):
|
||||
intervals=self.scale,
|
||||
modifier=self.modifier if self.modifier is not None else 0,
|
||||
octave=self.octave if self.octave is not None else 0,
|
||||
degrees=self.degrees
|
||||
)
|
||||
self.pitch_bend = pitch_bend
|
||||
self.freq = midi_to_freq(note)
|
||||
@ -598,6 +600,8 @@ class Cyclic(Item):
|
||||
"""Get the value for the current cycle"""
|
||||
value = self.values[self.cycle % len(self.values)]
|
||||
self.cycle += 1
|
||||
if options:
|
||||
value.update_options(options)
|
||||
return value
|
||||
|
||||
|
||||
|
||||
@ -124,6 +124,8 @@ def resolve_item(item: Meta, options: dict):
|
||||
update_modifications(item, options)
|
||||
elif isinstance(item, Measure):
|
||||
item.reset_options(options)
|
||||
elif options["degrees"] is True and isinstance(item, Pitch) and item.pitch_class is 0:
|
||||
yield Rest(text="r", kwargs=options)
|
||||
elif isinstance(item, Meta): # Filters whitespace
|
||||
yield update_item(item, options)
|
||||
|
||||
@ -208,6 +210,7 @@ def create_pitch(current: Item, options: dict) -> Pitch:
|
||||
intervals=merged_options["scale"],
|
||||
modifier=c_modifier,
|
||||
octave=c_octave,
|
||||
degrees=merged_options["degrees"]
|
||||
)
|
||||
new_pitch = Pitch(
|
||||
pitch_class=current_value,
|
||||
@ -382,7 +385,7 @@ class ListOperation(Sequence):
|
||||
else:
|
||||
flattened_list.append(_filter_operation(item, options))
|
||||
elif isinstance(item, Cyclic):
|
||||
value = item.get_value()
|
||||
value = item.get_value(options)
|
||||
if isinstance(value, Sequence):
|
||||
flattened_list.extend(_filter_operation(value, options))
|
||||
elif isinstance(value, (Event, RandomInteger, Integer)):
|
||||
|
||||
Reference in New Issue
Block a user