Exemple #1
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
Exemple #2
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
Exemple #3
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
Exemple #4
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
Exemple #5
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
Exemple #6
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)
Exemple #7
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
Exemple #8
0
 def test_D_major_scale(self):
     ''' Test add_run using list of Note names '''
     D_major = ('D4', 'E4', 'F#4', 'G4', 'A4', 'B4', 'C#5', 'D5')
     bar = tab.Bar()
     for note in D_major:
         shape = music.Note(note).get_low_fret()
         bar.add_shape(shape, 1 / 8)
     try:
         self.assertEqual(
             bar, '|--------------------------------|\n'
             '|--------------------0---2---3---|\n'
             '|------------0---2---------------|\n'
             '|0---2---4-----------------------|\n'
             '|--------------------------------|\n'
             '|--------------------------------|\n')
     except AssertionError as e:
         print(f'Static D major, one bar:\n{bar}')
         raise e
Exemple #9
0
 def test_A_major_scale(self):
     ''' Test add_run using Note addition '''
     root = music.Note('A3')
     major = (0, 2, 4, 5, 7, 9, 11, 12)
     bar = tab.Bar()
     for i in major:
         shape = (root + i).get_low_fret()
         bar.add_shape(shape, 1 / 8)
     try:
         self.assertEqual(
             bar, '|--------------------------------|\n'
             '|--------------------------------|\n'
             '|------------------------1---2---|\n'
             '|------------0---2---4-----------|\n'
             '|0---2---4-----------------------|\n'
             '|--------------------------------|\n')
     except AssertionError as e:
         print(f'Static A major, one bar:\n{bar}')
         raise e
Exemple #10
0
 def setUp(self):
     self.bar = tab.Bar(width=32)
     self.staff = tab.Staff()
     self.arr = tab.Arrangement(width=32)
Exemple #11
0
 def test_null_bar(self):
     bar = tab.Bar()
     self.assertEqual(bar, f"|{'-' * tab.MIN_WIDTH}|\n" * 6)
Exemple #12
0
 def test_null_arrangement(self):
     arr = tab.Arrangement()
     self.assertEqual(arr, str(tab.Bar()) + '\n')
Exemple #13
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')
Exemple #14
0
 def test_null_song(self):
     song = music.Song()
     g = player.Guitarist(song)
     self.assertEqual(g.arr, str(tab.Bar()) + '\n')