+2
-12
@@ -35,16 +35,6 @@ def harmony_spans(document: dict) -> list[HarmonySpan]:
|
||||
span.notes.append(item)
|
||||
return spans
|
||||
|
||||
def written_durations(length: fractions.Fraction):
|
||||
while length:
|
||||
written = generator.model.written_for(length)
|
||||
duration = length
|
||||
if 'ratio' in written and length.denominator & (length.denominator - 1) == 0:
|
||||
duration = next((size for size in generator.model.TYPE_LENGTHS.values() if size < length), length)
|
||||
written = generator.model.written_for(duration)
|
||||
yield duration, written
|
||||
length -= duration
|
||||
|
||||
def measures(document: dict):
|
||||
staff = document['staves'][0]
|
||||
if staff.get('arrangement_part_type') == 'acoustic':
|
||||
@@ -60,7 +50,7 @@ def prepare(document: dict) -> None:
|
||||
end = min(start + generator.model.fraction(n['duration']) for n in notes)
|
||||
end = min(end, groups[index + 1][0] if index + 1 < len(groups) else length)
|
||||
# A duration needing ties becomes one shorter attack followed by silence.
|
||||
duration, written = next(written_durations(end - start))
|
||||
duration, written = next(generator.accompaniment.written_durations(end - start))
|
||||
for note in notes:
|
||||
if generator.model.fraction(note['duration']) != duration:
|
||||
note.update(duration=generator.model.rational(duration), written=written)
|
||||
@@ -89,7 +79,7 @@ def combine(document: dict) -> None:
|
||||
|
||||
def rest(end):
|
||||
nonlocal cursor
|
||||
for duration, written in written_durations(end - cursor):
|
||||
for duration, written in generator.accompaniment.written_durations(end - cursor):
|
||||
notes.append(generator.model.make_event(f'{measure["id"]}-acoustic-{len(notes) + 1}', cursor, duration, 'rest', written=written) | {'voice': 'voice-arranged'})
|
||||
cursor += duration
|
||||
|
||||
|
||||
Reference in New Issue
Block a user