def test_make_scale_notes(): p = Pattern([-8, -7, -4, -2, -1, 0, 1, 2, 7], 'test_pattern') scale_notes = make_scale_notes(IONIAN, p, MIDDLE_C) expected = { -8: 47, # ti -7: 48, # do -4: 53, # fa -2: 57, # la -1: 59, # ti 0: 60, # do 1: 62, # re 2: 64, # mi 7: 72, # do } for step in expected: assert expected[step] == scale_notes[step]
def ascending_triads_descending(length: int) -> Pattern: return Pattern( flatten([[s, s + 2, s + 4] for s in range(length, 0, -1)]) + [0], 'Ascending triads descending')
def descending_triads_second_inversion_descending(length: int) -> Pattern: return Pattern( flatten([[s - 3, s, s + 2] for s in range(length, 0, -1)]) + [0], 'Descending triads in second inversion descending')
def descending_triads_first_inversion_descending(length: int) -> Pattern: return Pattern( flatten([[s, s - 3, s - 5] for s in range(length, 0, -1)]) + [0], 'Descending triads in first inversion descending')
def ascending_triads_second_inversion_ascending(length: int) -> Pattern: return Pattern( flatten([[s - 5, s, s + 2] for s in range(length)]) + [length], 'Ascending triads in second inversion ascending')
def ascending_triads_first_inversion_ascending(length: int) -> Pattern: return Pattern( flatten([[s + 2, s + 4, s + 7] for s in range(length)]) + [length], 'Ascending triads in first inversion ascending')
def flatten(l): return [i for sublist in l for i in sublist] TUNE_IN_PATTERN = Pattern([ 0, 2, 4, 2, 0, 3, 2, 1, 0, 4, 5, 6, 7, 0, 2, 4, 7, 0, 2, 4, 6, ], 'Tune-in-1') def ascending(length: int) -> Pattern: return Pattern(list(range(length + 1)), 'Ascending')
def descending(length: int) -> Pattern: return Pattern(list(range(length, -1, -1)), 'Descending')
def descending_thirds_descending(length: int) -> Pattern: return Pattern( flatten([[s, s - 2] for s in range(length, 0, -1)]) + [0], 'Descending thirds descending')
def ascending_thirds_ascending(length: int) -> Pattern: return Pattern( flatten([[s, s + 2] for s in range(length)]) + [length], 'Ascending thirds ascending')
def three_ascending_notes_descending(length: int) -> Pattern: return Pattern( flatten([[s, s + 1, s + 2] for s in range(length, 0, -1)]) + [0], "Three ascending notes descending")
def three_descending_notes_ascending(length: int) -> Pattern: return Pattern( flatten([[s + 2, s + 1, s] for s in range(length)]) + [length], "Three descending notes ascending")
def three_notes_descending(length: int) -> Pattern: return Pattern( flatten([[s, s - 1, s - 2] for s in range(length, 0, -1)]) + [0], 'Three notes descending')
def three_notes_ascending(length: int) -> Pattern: return Pattern( flatten([s, s + 1, s + 2] for s in range(length)) + [length], 'Three notes ascending')
def clb_scale_pattern_ascending() -> Pattern: return Pattern( flatten([[s, s + 1, s + 2, s + 3, s + 4, s + 3, s + 2, s] for s in range(7)]) + [7], 'ChadLB ascending scale exercise')
def clb_scale_pattern_descending() -> Pattern: return Pattern( flatten([[s, s + 1, s + 2, s + 3, s + 2, s + 1, s, s - 2] for s in range(7, 0, -1)]) + [0], 'ChadLB ascending scale exercise')
def ascending(length: int) -> Pattern: return Pattern(list(range(length + 1)), 'Ascending')
def down_to_root(length: int) -> Pattern: return Pattern( flatten([list(range(s, -1, -1)) for s in range(length + 1)]), 'Down to root from every step')
def descending_triads_ascending(length: int) -> Pattern: return Pattern( flatten([[s + 4, s + 2, s] for s in range(length)]) + [length], 'Descending triads ascending')