Exemplo n.º 1
0
def display_fretboard(curr_string, curr_note):
    open_strings = ['e', 'b', 'g', 'd', 'a', 'e']
    open_string_positions = [24, 19, 15, 10, 5, 0]

    output = '0 1 2 3 4 5 6 7 8 9 10 11 12 \n';

    str_i = 1
    for open_string in open_strings:
        output += open_string + ' '
        is_curr_note_open = False

        for note_index in range(
                first_fret_position(open_string_positions, str_i),
                twelfth_fret_position(open_string_positions, str_i)):

            if get_index(curr_string, curr_note) == open_string_positions[str_i - 1]:
                is_curr_note_open = True

            if str_i == curr_string and is_curr_note_open and note_index == open_string_positions[str_i - 1] + 12:
                output += curr_note + ' '
                is_curr_note_open = False
            elif str_i == curr_string and get_index(curr_string, curr_note) == note_index :
                output += curr_note + ' '
            else:
                output += '| '
        output += '\n'
        str_i += 1

    return output
Exemplo n.º 2
0
    def test_get_index(self):

        self.assertEqual(get_index(0, 0), -1)

        # Open E
        self.assertEqual(get_index(6, 'E'), 12)

        self.assertEqual(get_index(6, 'F'), 1)
        self.assertEqual(get_index(6, 'D#/Eb'), 11)

        # Open A
        self.assertEqual(get_index(5, 'A'), 17)

        self.assertEqual(get_index(5, 'F'), 13)
        self.assertEqual(get_index(5, 'F#/Gb'), 14)
        self.assertEqual(get_index(5, 'G'), 15)
        self.assertEqual(get_index(5, 'G#/Ab'), 16)
        self.assertEqual(get_index(5, 'A'), 17)

        # Open D
        self.assertEqual(get_index(4, 'D'), 22)

        self.assertEqual(get_index(4, 'D#/Eb'), 11)
        self.assertEqual(get_index(4, 'E'), 12)

        self.assertEqual(get_index(4, 'F'), 13)
        self.assertEqual(get_index(4, 'F#/Gb'), 14)
        self.assertEqual(get_index(4, 'G'), 15)
        self.assertEqual(get_index(4, 'G#/Ab'), 16)
        self.assertEqual(get_index(4, 'A'), 17)
        self.assertEqual(get_index(4, 'A#/Bb'), 18)
        self.assertEqual(get_index(4, 'B'), 19)
        self.assertEqual(get_index(4, 'C'), 20)
        self.assertEqual(get_index(4, 'C#/Db'), 21)

        # Open G
        self.assertEqual(get_index(3, 'G'), 27)

        self.assertEqual(get_index(3, 'G#/Ab'), 16)
        self.assertEqual(get_index(3, 'A'), 17)
        self.assertEqual(get_index(3, 'A#/Bb'), 18)
        self.assertEqual(get_index(3, 'B'), 19)
        self.assertEqual(get_index(3, 'C'), 20)
        self.assertEqual(get_index(3, 'C#/Db'), 21)
        self.assertEqual(get_index(3, 'D'), 22)
        self.assertEqual(get_index(3, 'D#/Eb'), 23)
        self.assertEqual(get_index(3, 'E'), 24)
        self.assertEqual(get_index(3, 'F'), 25)
        self.assertEqual(get_index(3, 'F#/Gb'), 26)

        # Open B
        self.assertEqual(get_index(2, 'B'), 31)

        self.assertEqual(get_index(2, 'C'), 20)
        self.assertEqual(get_index(2, 'C#/Db'), 21)
        self.assertEqual(get_index(2, 'D'), 22)
        self.assertEqual(get_index(2, 'D#/Eb'), 23)
        self.assertEqual(get_index(2, 'E'), 24)
        self.assertEqual(get_index(2, 'F'), 25)
        self.assertEqual(get_index(2, 'F#/Gb'), 26)
        self.assertEqual(get_index(2, 'G'), 27)
        self.assertEqual(get_index(2, 'G#/Ab'), 28)
        self.assertEqual(get_index(2, 'A'), 29)
        self.assertEqual(get_index(2, 'A#/Bb'), 30)

        # Open E
        self.assertEqual(get_index(1, 'E'), 36)
        self.assertEqual(get_index(1, 'F'), 25)
        self.assertEqual(get_index(1, 'F#/Gb'), 26)
        self.assertEqual(get_index(1, 'G'), 27)
        self.assertEqual(get_index(1, 'G#/Ab'), 28)
        self.assertEqual(get_index(1, 'A'), 29)
        self.assertEqual(get_index(1, 'A#/Bb'), 30)
        self.assertEqual(get_index(1, 'B'), 31)
        self.assertEqual(get_index(1, 'C'), 32)
        self.assertEqual(get_index(1, 'C#/Db'), 33)
        self.assertEqual(get_index(1, 'D'), 34)
        self.assertEqual(get_index(1, 'D#/Eb'), 35)
Exemplo n.º 3
0
 def get_file(self, current_string, note):
     return self.files[get_index(
         self.zero_based_string_to_string_number(current_string), note)]
Exemplo n.º 4
0
 def get_file(self, current_string, note):
     return self.files[get_index(
         self.zero_based_string_to_string_number(current_string), note)]