Added total_duration and total_beats

This commit is contained in:
2023-03-06 20:40:30 +02:00
parent 745632ce59
commit 7e015a635d
2 changed files with 9 additions and 0 deletions

View File

@ -126,6 +126,14 @@ class Ziffers(Sequence):
if isinstance(val, Event)
]
def total_duration(self) -> float:
"""Return total duration"""
return sum([val.duration for val in self.evaluated_values if isinstance(val, Event)])
def total_beats(self) -> float:
"""Return total beats"""
return sum(self.beats())
def beats(self) -> list[float]:
"""Return list of pitch durations as floats"""
return [

View File

@ -334,6 +334,7 @@ class Subdivision(Sequence):
if isinstance(item, Event):
if duration is not None:
item.duration = new_d
item.beat = new_d*4
yield item