def test_fret_span_should_count_played_strings(self):
        frets = (2, 2, 3, 3, 5, 5)

        expected_result = 3
        result = fret_span(frets)

        self.assertEquals(result, expected_result)
    def test_fret_span_should_not_count_unplayed_strings(self):
        frets = (None, 2, 3, 4, None, None)

        expected_result = 2
        result = fret_span(frets)

        self.assertEquals(result, expected_result)
    def test_fret_span_should_not_count_open_notes(self):
        frets = (0, 1, 1, 2, 2, 3)

        expected_result = 2
        result = fret_span(frets)

        self.assertEquals(result, expected_result)
    def test_fret_span_should_return_zero_for_all_unplayed_strings(self):
        frets = (None, None, None, None, None, None)

        expected_result = 0
        result = fret_span(frets)

        self.assertEquals(result, expected_result)
    def test_fret_span_should_return_zero_for_only_one_fret(self):
        frets = (1, 1, 1, 1, 1, 1)

        expected_result = 0
        result = fret_span(frets)

        self.assertEquals(result, expected_result)
Esempio n. 6
0
def score_chord(chord, fingers):
    # TODO note for scoring, finger span should be the scoring metric,
    # example: distance between notes: a major would be 2 while a minor would
    # be 3 there may need to be something extra for extra fret spans (5 or 6
    # should be the limit)
    # TODO should certain chords be modified by placement on the neck?

    strings_used = sum(chord_utils.determine_strings_used(chord))
    fret_span = chord_utils.fret_span(chord)
    all_strings_used = len(chord) == strings_used
    fingers_used = chord_utils.fingers_required(chord)
    score = 0.0
    if strings_used > 0:
        score += fingers_used / 2.0
        score += max((fret_span - 1), 0)
        score += 1 if all_strings_used else 2

    return score