def test_tab_bars_are_added_every_four_beats(self): positions = [ FretPosition(string=3, fret=1), FretPosition(string=4, fret=2), FretPosition(string=5, fret=3), ] notes = [ Note(order=0, position=positions[0], duration=Beat(2, 4), elapsed_beats=Beat(2, 4)), Note(order=1, position=positions[1], duration=Beat(2, 4), elapsed_beats=Beat(4, 4)), Note(order=2, position=positions[2], duration=Beat(4, 4), elapsed_beats=Beat(2, 1)), ] shapes = [ GuitarShape(name='shape1', positions=positions, category='scale') ] sequence = Sequence(notes=notes, shapes=shapes) vextab = to_vextab(sequence) expected = ('tabstave notation=false\n' 'notes =|: :h 1/3 :h 2/4 | :w 3/5 =:|') self.assertEqual(expected, vextab)
def test_half_notes_have_a_h_duration(self): position = FretPosition(string=6, fret=5) duration = Beat(2, 4) notes = [ Note(order=1, position=position, duration=duration, elapsed_beats=Beat(2, 4)), Note(order=2, position=position, duration=duration, elapsed_beats=Beat(4, 4)), Note(order=3, position=position, duration=duration, elapsed_beats=Beat(6, 4)), Note(order=4, position=position, duration=duration, elapsed_beats=Beat(8, 4)), ] shapes = [ GuitarShape(name='shape1', positions=[position], category='scale') ] sequence = Sequence(notes=notes, shapes=shapes) vextab = to_vextab(sequence) expected = ('tabstave notation=false\n' 'notes =|: :h 5/6 :h 5/6 | :h 5/6 :h 5/6 =:|') self.assertEqual(expected, vextab)
def test_taps_are_added_to_tab(self): position = FretPosition(string=6, fret=5) duration = Beat(1, 8) notes = [ Note(order=0, position=position, duration=duration, elapsed_beats=Beat(1, 4)), Note(order=1, position=position, duration=duration, elapsed_beats=Beat(2, 4), slur=TAP), ] shapes = [ GuitarShape(name='shape1', positions=[position], category='scale') ] sequence = Sequence(notes=notes, shapes=shapes) vextab = to_vextab(sequence) expected = ('tabstave notation=false\n' 'notes =|: :8 5/6 t:8: 5/6 =:|') self.assertEqual(expected, vextab)
def test_palm_mutes_are_added_to_tab_as_text(self): position = FretPosition(string=6, fret=5) duration = Beat(1, 8) notes = [ Note(order=0, position=position, duration=duration, elapsed_beats=Beat(1, 4), annotations=[PALM_MUTE]), Note(order=1, position=position, duration=duration, elapsed_beats=Beat(2, 4), annotations=[PALM_MUTE]), ] shapes = [ GuitarShape(name='shape1', positions=[position], category='scale') ] sequence = Sequence(notes=notes, shapes=shapes) vextab = to_vextab(sequence) expected = ('tabstave notation=false\n' 'notes =|: :8 5/6 $.top.pm$ :8 5/6 $.top.pm$ =:|') self.assertEqual(expected, vextab)
def test_can_palm_mute_and_down_pick_on_tabs(self): duration = Beat(1, 4) notes = [ Note(order=0, position=FretPosition(12, 5), duration=duration, elapsed_beats=Beat(1, 4), annotations=[DOWN_PICK, PALM_MUTE]), Note(order=1, position=FretPosition(14, 5), duration=duration, elapsed_beats=Beat(2, 4), annotations=[DOWN_PICK, PALM_MUTE]), ] shapes = [GuitarShape(name='shape1', positions=[], category='scale')] sequence = Sequence(notes=notes, shapes=shapes) vextab = to_vextab(sequence) expected = ( 'tabstave notation=false\n' 'notes =|: :q 12/5 $.am/top.$ $.top.pm$ :q 14/5 $.am/top.$ $.top.pm$ =:|' ) self.assertEqual(expected, vextab)
def test_rests_are_added_to_the_tab(self): position = FretPosition(string=6, fret=5) duration = Beat(1, 4) rest = Beat(1, 4, rest=True) notes = [ Note(order=0, position=position, duration=duration, elapsed_beats=Beat(1, 4)), Note(order=1, position=position, duration=rest, elapsed_beats=Beat(2, 4)), Note(order=2, position=position, duration=duration, elapsed_beats=Beat(3, 4)), Note(order=3, position=position, duration=rest, elapsed_beats=Beat(4, 4)), ] shapes = [ GuitarShape(name='shape1', positions=[position], category='scale') ] sequence = Sequence(notes=notes, shapes=shapes) vextab = to_vextab(sequence) expected = ('tabstave notation=false\n' 'notes =|: :q 5/6 :q ## :q 5/6 :q ## =:|') self.assertEqual(expected, vextab)
def test_chords_can_have_bends(self): duration = Beat(1, 4) notes = [ Note(order=0, position=FretPosition(12, 5), duration=duration, elapsed_beats=Beat(1, 4)), Note(order=0, position=FretPosition(12, 4), duration=duration, elapsed_beats=Beat(1, 4)), Note(order=1, position=FretPosition(14, 5), duration=duration, elapsed_beats=Beat(2, 4), slur=BEND), Note(order=1, position=FretPosition(14, 4), duration=duration, elapsed_beats=Beat(2, 4), slur=BEND), ] shapes = [GuitarShape(name='shape1', positions=[], category='scale')] sequence = Sequence(notes=notes, shapes=shapes) vextab = to_vextab(sequence) expected = ('tabstave notation=false\n' 'notes =|: :q (12/5.12/4) :q b(14/5.14/4) =:|') self.assertEqual(expected, vextab)
def level_one() -> Sequence: lick = random.choice(basic_pentatonic_licks()) positions = [note.position for note in lick] shape = GuitarShape(positions=positions, name='Pentatonic Lick', category='scale') return Sequence(notes=lick, shapes=[shape])
def test_thirty_second_notes_have_a_32_duration(self): position = FretPosition(string=6, fret=5) duration = Beat(1, 32) notes = [ Note(order=1, position=position, duration=duration, elapsed_beats=Beat(1, 32)), Note(order=2, position=position, duration=duration, elapsed_beats=Beat(2, 32)), Note(order=3, position=position, duration=duration, elapsed_beats=Beat(3, 32)), Note(order=4, position=position, duration=duration, elapsed_beats=Beat(4, 32)), Note(order=5, position=position, duration=duration, elapsed_beats=Beat(5, 32)), Note(order=6, position=position, duration=duration, elapsed_beats=Beat(6, 32)), Note(order=7, position=position, duration=duration, elapsed_beats=Beat(7, 32)), Note(order=8, position=position, duration=duration, elapsed_beats=Beat(8, 32)), ] shapes = [ GuitarShape(name='shape1', positions=[position], category='scale') ] sequence = Sequence(notes=notes, shapes=shapes) vextab = to_vextab(sequence) expected = ( 'tabstave notation=false\n' 'notes =|: :32 5/6 :32 5/6 :32 5/6 :32 5/6 :32 5/6 :32 5/6 :32 5/6 :32 5/6 =:|' ) self.assertEqual(expected, vextab)
def test_chords_are_converted_to_tab(self): position = FretPosition(string=6, fret=0) duration = Beat(1, 4) notes = [ Note(order=0, position=FretPosition(3, 6), duration=duration, elapsed_beats=Beat(1, 4)), Note(order=0, position=FretPosition(5, 5), duration=duration, elapsed_beats=Beat(1, 4)), Note(order=0, position=FretPosition(5, 4), duration=duration, elapsed_beats=Beat(1, 4)), Note(order=1, position=position, duration=duration, elapsed_beats=Beat(2, 4)), Note(order=2, position=FretPosition(5, 6), duration=duration, elapsed_beats=Beat(3, 4)), Note(order=2, position=FretPosition(7, 5), duration=duration, elapsed_beats=Beat(3, 4)), Note(order=2, position=FretPosition(7, 4), duration=duration, elapsed_beats=Beat(3, 4)), Note(order=4, position=position, duration=duration, elapsed_beats=Beat(4, 4)), ] shapes = [ GuitarShape(name='shape1', positions=[position], category='scale') ] sequence = Sequence(notes=notes, shapes=shapes) vextab = to_vextab(sequence) expected = ( 'tabstave notation=false\n' 'notes =|: :q (3/6.5/5.5/4) :q 0/6 :q (5/6.7/5.7/4) :q 0/6 =:|') self.assertEqual(expected, vextab)
def test_thirty_second_note_triplets_are_marked_in_the_tab(self): position = FretPosition(string=6, fret=5) duration = Beat(1, 48) notes = [ Note(order=1, position=position, duration=duration, elapsed_beats=Beat(1, 48)), Note(order=2, position=position, duration=duration, elapsed_beats=Beat(2, 48)), Note(order=3, position=position, duration=duration, elapsed_beats=Beat(3, 48)), Note(order=4, position=position, duration=duration, elapsed_beats=Beat(4, 48)), Note(order=5, position=position, duration=duration, elapsed_beats=Beat(5, 48)), Note(order=6, position=position, duration=duration, elapsed_beats=Beat(6, 48)), ] shapes = [ GuitarShape(name='shape1', positions=[position], category='scale') ] sequence = Sequence(notes=notes, shapes=shapes) vextab = to_vextab(sequence) expected = ( 'tabstave notation=true\n' 'notes =|: :32 5/6 :32 5/6 :32 5/6 ^3^ :32 5/6 :32 5/6 :32 5/6 ^3^ =:|' ) self.assertEqual(expected, vextab)
def test_tabs_are_split_into_mutliple_staves_every_two_bars(self): position = FretPosition(string=3, fret=1) notes = [ Note(order=0, position=position, duration=Beat(1, 1), elapsed_beats=Beat(1, 1)), Note(order=1, position=position, duration=Beat(1, 1), elapsed_beats=Beat(2, 1)), Note(order=2, position=position, duration=Beat(1, 1), elapsed_beats=Beat(3, 1)), Note(order=3, position=position, duration=Beat(1, 1), elapsed_beats=Beat(4, 1)), Note(order=4, position=position, duration=Beat(1, 1), elapsed_beats=Beat(5, 1)), ] shapes = [ GuitarShape(name='shape1', positions=[position], category='scale') ] sequence = Sequence(notes=notes, shapes=shapes) vextab = to_vextab(sequence) expected = ('tabstave notation=false\n' 'notes =|: :w 1/3 | :w 1/3 |\n' '\n' 'tabstave notation=false\n' 'notes :w 1/3 | :w 1/3 |\n' '\n' 'tabstave notation=false\n' 'notes :w 1/3 =:|') self.assertEqual(expected, vextab)
def test_odd_length_quarter_notes_are_split_with_tie(self): position = FretPosition(string=6, fret=5) duration = Beat(3, 4) notes = [ Note(order=0, position=position, duration=duration, elapsed_beats=Beat(3, 4)), ] shapes = [ GuitarShape(name='shape1', positions=[position], category='scale') ] sequence = Sequence(notes=notes, shapes=shapes) vextab = to_vextab(sequence) expected = ('tabstave notation=false\n' 'notes =|: :h 5/6 T:q: 5/6 =:|') self.assertEqual(expected, vextab)
def test_label_annotations_are_added(self): position = FretPosition(string=6, fret=5) duration = Beat(1, 8) notes = [ Note(order=0, position=position, duration=duration, elapsed_beats=Beat(1, 4), annotations=['label:A']), ] shapes = [ GuitarShape(name='shape1', positions=[position], category='scale') ] sequence = Sequence(notes=notes, shapes=shapes) vextab = to_vextab(sequence) expected = ('tabstave notation=false\n' 'notes =|: :8 5/6 $.top.A$ =:|') self.assertEqual(expected, vextab)
def test_odd_length_quarter_note_chords_are_split_with_tie(self): duration = Beat(3, 8) notes = [ Note(order=0, position=FretPosition(12, 5), duration=duration, elapsed_beats=Beat(3, 8)), Note(order=0, position=FretPosition(12, 4), duration=duration, elapsed_beats=Beat(3, 8)), ] shapes = [GuitarShape(name='shape1', positions=[], category='scale')] sequence = Sequence(notes=notes, shapes=shapes) vextab = to_vextab(sequence) expected = ('tabstave notation=false\n' 'notes =|: :q (12/5.12/4) :8 T(12/5.12/4) =:|') self.assertEqual(expected, vextab)
def test_positions_are_converted_to_string(self): positions = [ FretPosition(string=3, fret=1), FretPosition(string=4, fret=2), FretPosition(string=5, fret=3), FretPosition(string=6, fret=4), ] duration = Beat(1) notes = [ Note(order=0, position=positions[0], duration=duration, elapsed_beats=Beat(1)), Note(order=1, position=positions[1], duration=duration, elapsed_beats=Beat(2)), Note(order=2, position=positions[2], duration=duration, elapsed_beats=Beat(3)), Note(order=3, position=positions[3], duration=duration, elapsed_beats=Beat(4)), ] shapes = [ GuitarShape(name='shape1', positions=positions, category='scale') ] sequence = Sequence(notes=notes, shapes=shapes) vextab = to_vextab(sequence) expected = ('tabstave notation=false\n' 'notes =|: :q 1/3 :q 2/4 :q 3/5 :q 4/6 =:|') self.assertEqual(expected, vextab)
def test_up_pick_is_added_to_tabs(self): duration = Beat(1, 4) notes = [ Note(order=0, position=FretPosition(12, 5), duration=duration, elapsed_beats=Beat(1, 4), annotations=[UP_PICK]), Note(order=1, position=FretPosition(14, 5), duration=duration, elapsed_beats=Beat(2, 4), annotations=[UP_PICK]), ] shapes = [GuitarShape(name='shape1', positions=[], category='scale')] sequence = Sequence(notes=notes, shapes=shapes) vextab = to_vextab(sequence) expected = ('tabstave notation=false\n' 'notes =|: :q 12/5 $.a|/top.$ :q 14/5 $.a|/top.$ =:|') self.assertEqual(expected, vextab)