@@ -26,8 +26,14 @@ def place(notes: tuple[generator.solo.types.Note, ...], tempo: fractions.Fractio
|
||||
following = []
|
||||
for position in positions(note.pitch.number()):
|
||||
current = dataclasses.replace(note, position=position)
|
||||
candidates = [(cost + travel(path[-1] if path else previous, current, tempo), (*path, current)) for cost, path in states]
|
||||
following.append(min(candidates, key=lambda item: (item[0], tuple(n.position for n in item[1]))))
|
||||
candidates = []
|
||||
for cost, path in states:
|
||||
prior = path[-1] if path else previous
|
||||
if note.continuation and (prior is None or prior.pitch != note.pitch or prior.position != position or prior.end != note.start):
|
||||
continue
|
||||
candidates.append((cost + (0 if note.continuation else travel(prior, current, tempo)), (*path, current)))
|
||||
if candidates:
|
||||
following.append(min(candidates, key=lambda item: (item[0], tuple(n.position for n in item[1]))))
|
||||
if not following:
|
||||
return None
|
||||
states = following
|
||||
|
||||
Reference in New Issue
Block a user