MCPcopy Create free account
hub / github.com/bspaans/python-mingus / find_frets

Method find_frets

mingus/extra/tunings.py:69–96  ·  view source on GitHub ↗

Return a list with for each string the fret on which the note is played or None if it can't be played on that particular string. The maxfret parameter is the highest fret that can be played; note should either be a string or a Note object. Example: >>> t = S

(self, note, maxfret=24)

Source from the content-addressed store, hash-verified

67 return float(c) / len(self.tuning)
68
69 def find_frets(self, note, maxfret=24):
70 """Return a list with for each string the fret on which the note is
71 played or None if it can't be played on that particular string.
72
73 The maxfret parameter is the highest fret that can be played; note
74 should either be a string or a Note object.
75
76 Example:
77 >>> t = StringTuning('test', 'test', ['A-3', 'E-4'])
78 >>> t.find_frets(Note('C-4')
79 [3, None]
80 >>> t.find_frets(Note('A-4')
81 [12, 5]
82 """
83 result = []
84 if isinstance(note, six.string_types):
85 note = Note(note)
86 for x in self.tuning:
87 if isinstance(x, list):
88 base = x[0]
89 else:
90 base = x
91 diff = base.measure(note)
92 if 0 <= diff <= maxfret:
93 result.append(diff)
94 else:
95 result.append(None)
96 return result
97
98 def find_fingering(self, notes, max_distance=4, not_strings=None):
99 """Return a list [(string, fret)] of possible fingerings for

Callers 3

find_fingeringMethod · 0.95
from_NoteFunction · 0.80
test_find_fretsMethod · 0.80

Calls 2

NoteClass · 0.90
measureMethod · 0.80

Tested by 1

test_find_fretsMethod · 0.64