This commit is contained in:
khodowany
2026-10-03 12:44:53 -05:00
parent 59afd78205
commit 04c6ea2e00
25 changed files with 673 additions and 185 deletions
+9 -7
View File
@@ -6,6 +6,7 @@ import functools
import generator.fretboard
import generator.solo.types
from generator.solo.profiles import UNRESTRICTED
def travel(previous: generator.solo.types.Note | None, current: generator.solo.types.Note, tempo: fractions.Fraction) -> int:
if previous is None:
@@ -33,12 +34,12 @@ def stable_path(path):
@functools.lru_cache(maxsize=4096)
def alternatives(notes, tempo, previous=None, limit=2):
def alternatives(notes, tempo, previous=None, limit=2, profile=UNRESTRICTED):
"""Phrase paths with a four-fret hand region and distinct endpoint choices."""
states = [(0, (), h) for h in hand_positions(previous.position)] if previous and previous.position else [(0, (), None)]
for note in notes:
following = {}
for position in positions(note.pitch.number()):
for position in positions(note.pitch.number(), profile):
current = dataclasses.replace(note, position=position)
for hand in hand_positions(position):
best = None
@@ -73,10 +74,11 @@ def alternatives(notes, tempo, previous=None, limit=2):
@functools.lru_cache(maxsize=4096)
def place(notes, tempo, previous=None):
result = alternatives(notes,tempo,previous,1)
def place(notes, tempo, previous=None, profile=UNRESTRICTED):
result = alternatives(notes,tempo,previous,1,profile)
return result[0] if result else None
@functools.lru_cache(maxsize=128)
def positions(number: int):
return generator.fretboard.single_positions_for_pitch(fractions.Fraction(number))
@functools.lru_cache(maxsize=2048)
def positions(number: int, profile=UNRESTRICTED):
profile = profile or UNRESTRICTED
return tuple(p for p in generator.fretboard.single_positions_for_pitch(fractions.Fraction(number)) if p.string_number in profile.strings)