示例#1
0
 def test_single_notes(self):
     for string, fret in it.product(range(5), range(19)):
         with self.subTest(i=(string, fret)):
             s = tab.Shape([(string, fret)])
             self.assertEqual(s.list_tuples(), [(string, fret)])
             temp = [fret if string == i else None for i in range(6)]
             self.assertEqual(s.list_frets(), temp)
示例#2
0
 def test_whole_note(self):
     bar = tab.Bar()
     bar.add_shape(tab.Shape((0, 0)), 1)
     try:
         self.assertEqual(len(bar), 8 + 2)
     except AssertionError as e:
         print(f'Dynamic whole notes:\n{bar}')
         raise e
示例#3
0
 def test_sixteenth_note(self):
     bar = tab.Bar()
     for i in range(16):
         bar.add_shape(tab.Shape((0, 0)), 1 / 16)
     try:
         self.assertEqual(len(bar), 64 + 2)
     except AssertionError as e:
         print(f'Dynamic sixteenth notes:\n{bar}')
         raise e
示例#4
0
 def test_half_note(self):
     bar = tab.Bar()
     for i in range(2):
         bar.add_shape(tab.Shape((0, 0)), 1 / 2)
     try:
         self.assertEqual(len(bar), 8 + 2)
     except AssertionError as e:
         print(f'Dynamic half notes:\n{bar}')
         raise e
示例#5
0
 def test_quarter_note(self):
     bar = tab.Bar()
     for i in range(4):
         bar.add_shape(tab.Shape((0, 0)), 1 / 4)
     try:
         self.assertEqual(len(bar), 16 + 2)
     except AssertionError as e:
         print(f'Dynamic quarter notes:\n{bar}')
         raise e
示例#6
0
 def test_eighth_note(self):
     bar = tab.Bar()
     for i in range(8):
         bar.add_shape(tab.Shape((0, 0)), 1 / 8)
     try:
         self.assertEqual(len(bar), 32 + 2)
     except AssertionError as e:
         print(f'Dynamic eighth notes:\n{bar}')
         raise e
示例#7
0
    def test_length_limit(self):
        ''' Ensure notes added beyond 1 bars-length are ignored'''
        bar_0 = tab.Bar(width=32)
        bar_0.add_shape(tab.Shape((0, 0)), 1)
        for line in bar_0.lines:
            self.assertEqual(len(line), 34)

        bar_1 = tab.Bar(width=32)
        bar_1.add_shape(tab.Shape((0, 0)), 1)
        bar_1.add_shape(tab.Shape((0, 0)), 1)
        for line in bar_1.lines:
            self.assertEqual(len(line), 34)

        bar_4 = tab.Bar(width=32)
        for i in range(5):
            bar_4.add_shape(tab.Shape((0, 0)), 1 / 4)
        for line in bar_4.lines:
            self.assertEqual(len(line), 34)

        bar_16 = tab.Bar(width=32)
        for i in range(17):
            bar_16.add_shape(tab.Shape((0, 0)), 1 / 16)
        for line in bar_16.lines:
            self.assertEqual(len(line), 66)
示例#8
0
    def test_single_notes(self):
        arr = tab.Arrangement()
        for note in [(0, 0), (0, 2), (0, 4), (1, 0), (1, 2), (1, 4), (2, 1),
                     (2, 2)]:
            arr.add_shape(tab.Shape(note), 1 / 8)
#        tabs = arr.transcribe()
        expected = ('|--------------------------------|\n'
                    '|--------------------------------|\n'
                    '|--------------------------------|\n'
                    '|------------------------1---2---|\n'
                    '|------------0---2---4-----------|\n'
                    '|0---2---4-----------------------|\n\n')
        try:
            self.assertEqual(arr, expected)
        except AssertionError as e:
            print(f'E major scale, one bar:\n{arr}')
            raise e
示例#9
0
 def test_E_major_scale(self):
     ''' Add eighth Notes manually, one by one '''
     bar = tab.Bar()
     for note in ((0, 0), (0, 2), (0, 4), (1, 0), (1, 2), (1, 4), (2, 1),
                  (2, 2)):
         bar.add_shape(tab.Shape(note), 1 / 8)
     try:
         self.assertEqual(
             bar, '|--------------------------------|\n'
             '|--------------------------------|\n'
             '|--------------------------------|\n'
             '|------------------------1---2---|\n'
             '|------------0---2---4-----------|\n'
             '|0---2---4-----------------------|\n')
     except AssertionError as e:
         print(f'Static E major, one bar:\n{bar}')
         raise e
示例#10
0
    def test_chords(self):
        arr = tab.Arrangement()
        sotw = [([(0, 0), (1, 2), (2, 2)], 1 / 4),
                ([(0, 3), (1, 5), (2, 5)], 1 / 4),
                ([(0, 5), (1, 7), (2, 7)], 3 / 8),
                ([(0, 0), (1, 2), (2, 2)], 1 / 4),
                ([(0, 3), (1, 5), (2, 5)], 1 / 4),
                ([(0, 7), (1, 9), (2, 9)], 1 / 8),
                ([(0, 5), (1, 7), (2, 7)], 1 / 2)]
        for note in sotw:
            frets, duration = note
            arr.add_shape(tab.Shape(frets), duration)
#        tabs = arr.transcribe()
        try:
            self.assertEqual(arr, smoke_on_the_water)
        except AssertionError as e:
            print(f'Smoke on the Water, two bars, manual:\n{arr}')
            raise e
示例#11
0
    def test_mixed_notes(self):
        ''' Sixth notes? Tab() will need to handle 3/4 time as well '''
        arr = tab.Arrangement()
        bb1 = [([(0, 3), (4, 0)], 1 / 6), ([(3, 0)], 1 / 6),
               ([(1, 0), (4, 1)], 1 / 6), ([(3, 0)], 1 / 6),
               ([(1, 2), (4, 3)], 1 / 6), ([(3, 0)], 1 / 6)]
        bb2 = [([(1, 10), (4, 12)], 1 / 4), ([(3, 0)], 1 / 8),
               ([(4, 12)], 1 / 8), ([(1, 10)], 1 / 8), ([(4, 12)], 1 / 8),
               ([(3, 0)], 1 / 4)]
        for note in bb1 + bb2:
            frets, duration = note
            arr.add_shape(tab.Shape(frets), duration)


#        tabs = arr.transcribe()
        try:
            self.assertEqual(arr, blackbird)
        except AssertionError as e:
            print(f'Blackbird, two bars, manual:\n{arr}')
            raise e
示例#12
0
 def test_open_d_shape(self):
     lst = [None, 0, 0, 2, 3, 2]
     self.assertEqual(tab.Shape(open_d).list_frets(), lst)
     self.assertEqual(tab.Shape(lst).list_tuples(), open_d)
示例#13
0
 def test_all_open(self):
     s = tab.Shape()
     for i in range(6):
         s += tab.Shape((i, 0))
     self.assertEqual(s, tab.Shape([0, 0, 0, 0, 0, 0]))
示例#14
0
 def test_null_shape(self):
     self.assertEqual(tab.Shape() + tab.Shape(), tab.Shape())
示例#15
0
 def test_barre_f_shape(self):
     lst = [1, 3, 3, 2, 1, 1]
     self.assertEqual(tab.Shape(barre_f).list_frets(), lst)
     self.assertEqual(tab.Shape(lst).list_tuples(), barre_f)
示例#16
0
 def test_null_shape(self):
     s = tab.Shape()
     self.assertEqual(s.list_frets(), [None] * 6)
     self.assertEqual(s.list_tuples(), [])
示例#17
0
 def test_open_e_shape(self):
     lst = [0, 2, 2, 1, 0, 0]
     self.assertEqual(tab.Shape(open_e).list_frets(), lst)
     self.assertEqual(tab.Shape(lst).list_tuples(), open_e)
示例#18
0
 def test_open_g_shape(self):
     lst = [3, 2, 0, 0, 0, 3]
     self.assertEqual(tab.Shape(open_g).list_frets(), lst)
     self.assertEqual(tab.Shape(lst).list_tuples(), open_g)
示例#19
0
 def test_barre_b_shape(self):
     lst = [2, 2, 4, 4, 4, 2]
     self.assertEqual(tab.Shape(barre_b).list_frets(), lst)
     self.assertEqual(tab.Shape(lst).list_tuples(), barre_b)
示例#20
0
 def test_low_E(self):
     song = music.Song()
     song.add('E3')
     g = player.Guitarist(song)
     expected = tab.Bar(notes=[(tab.Shape((0, 0)), 1 / 4)])
     self.assertEqual(g.arr, str(expected) + '\n')