def __init__(self, song=None): self.arr = tab.Arrangement() if song: self.song = song self.path = self.read(song) try: durations = (n.duration for n in self.song.notes) temp = [(a, b) for a, b in zip(self.path, durations)] except TypeError: temp = None self.arr = tab.Arrangement(notes=temp)
def test_four_bars(self): arr = tab.Arrangement() root = music.Note('A3') major = (0, 2, 4, 5, 7, 9, 11, 12) arr.add_run([(root + i).get_low_fret() for i in major], 1 / 2) try: self.assertEqual( arr, '|--------|--------|--------|--------|\n' '|--------|--------|--------|--------|\n' '|--------|--------|--------|1---2---|\n' '|--------|----0---|2---4---|--------|\n' '|0---2---|4-------|--------|--------|\n' '|--------|--------|--------|--------|\n\n') except AssertionError as e: print(f'Static A major, four bars:\n{arr}') raise e
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
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
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
def setUp(self): self.bar = tab.Bar(width=32) self.staff = tab.Staff() self.arr = tab.Arrangement(width=32)
def test_null_arrangement(self): arr = tab.Arrangement() self.assertEqual(arr, str(tab.Bar()) + '\n')