@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user