Chord Families
This commit is contained in:
+12
-4
@@ -12,7 +12,8 @@ STANDARD_TUNING = ((6, 40), (5, 45), (4, 50), (3, 55), (2, 59), (1, 64))
|
||||
MIN_FRET = 1
|
||||
MAX_FRET = 20
|
||||
MAX_SINGLE_FRET = 12
|
||||
MAX_FRET_SPAN = 3
|
||||
PREFERRED_FRET_SPAN = 3
|
||||
MAX_FRET_SPAN = 4
|
||||
MAX_ANCHOR_FRET = 12
|
||||
WRITTEN_GUITAR_OCTAVE_OFFSET = 12
|
||||
|
||||
@@ -21,10 +22,17 @@ class TabPosition(typing.NamedTuple):
|
||||
fret: int
|
||||
midi: int
|
||||
|
||||
def within_fret_span(positions) -> bool:
|
||||
"""Count occupied fret positions inclusively: frets 1-3 fit, 1-4 do not."""
|
||||
def fret_span(positions) -> int:
|
||||
"""Inclusive occupied positions: frets 7-9 span three, 7-10 span four."""
|
||||
frets = [position.fret for position in positions]
|
||||
return not frets or max(frets) - min(frets) + 1 <= MAX_FRET_SPAN
|
||||
return max(frets) - min(frets) + 1 if frets else 0
|
||||
|
||||
def span_penalty(positions) -> int:
|
||||
"""Two tiers for legal grips; all one-to-three-fret shapes share tier zero."""
|
||||
return int(fret_span(positions) > PREFERRED_FRET_SPAN)
|
||||
|
||||
def within_fret_span(positions) -> bool:
|
||||
return fret_span(positions) <= MAX_FRET_SPAN
|
||||
|
||||
def has_fret_anchor(positions) -> bool:
|
||||
return any(MIN_FRET <= position.fret <= MAX_ANCHOR_FRET for position in positions)
|
||||
|
||||
Reference in New Issue
Block a user