Span
ci / checks (push) Successful in 48m23s

This commit is contained in:
khodowany
2026-10-01 00:15:35 -05:00
parent 7b60182a3d
commit ce695a626a
10 changed files with 128 additions and 59 deletions
+6 -1
View File
@@ -12,6 +12,7 @@ STANDARD_TUNING = ((6, 40), (5, 45), (4, 50), (3, 55), (2, 59), (1, 64))
MIN_FRET = 1
MAX_FRET = 20
MAX_FRET_SPAN = 3
MAX_ANCHOR_FRET = 12
WRITTEN_GUITAR_OCTAVE_OFFSET = 12
class TabPosition(typing.NamedTuple):
@@ -20,8 +21,12 @@ class TabPosition(typing.NamedTuple):
midi: int
def within_fret_span(positions) -> bool:
"""Count occupied fret positions inclusively: frets 1-3 fit, 1-4 do not."""
frets = [position.fret for position in positions]
return not frets or max(frets) - min(frets) <= MAX_FRET_SPAN
return not frets or max(frets) - min(frets) + 1 <= MAX_FRET_SPAN
def has_fret_anchor(positions) -> bool:
return any(MIN_FRET <= position.fret <= MAX_ANCHOR_FRET for position in positions)
def positions_for_pitch(midi: fractions.Fraction) -> tuple[TabPosition, ...]:
if midi.denominator != 1: