예제 #1
0
def test_over_octave_chord_build():
    c = Chord.build_chord(Note.from_note_string('G4'), 'II', 'minor')
    expected = [
        Note.from_note_string('A4'),
        Note.from_note_string('C5'),
        Note.from_note_string('E5b')
    ]

    assert c.notes == expected
예제 #2
0
def test_simple_major_chord_build_non_tonic():
    c = Chord.build_chord(Note.from_note_string('C4'), 'V', 'major')
    expected = [
        Note.from_note_string('G4'),
        Note.from_note_string('B4'),
        Note.from_note_string('D5')
    ]

    assert c.notes == expected
예제 #3
0
def test_simple_minor_chord_build():
    c = Chord.build_chord(Note.from_note_string('C4'), 'I', 'minor')
    expected = [
        Note.from_note_string('C4'),
        Note.from_note_string('E4b'),
        Note.from_note_string('G4')
    ]

    assert c.notes == expected
예제 #4
0
def edit_scale(pad, verbose):
    global config

    rbank = int((pad - 1) / _PADS)
    rsubpad = pad - (_PADS * rbank) - 1

    menu = qprompt.Menu()
    x = 0
    for y in Scale._SCALE_PATTERNS:
        menu.add(str(x), y)
        x = x + 1
    stype = menu.show(hdr="Pad %d (Bank %s-%d):" %
                      (pad, chr(65 + rbank), rsubpad + 1),
                      msg="Scale",
                      returns="desc")

    root = qprompt.ask_int("Note",
                           vld=list(range(0, 128)),
                           dft=config[1][rbank][rsubpad]['note'])

    count = qprompt.ask_int("Count",
                            vld=[0] + list(range(1, _PTOTAL + 2 - pad)),
                            dft=0)

    scale = Scale.build_scale(Note.from_midi_num(root), stype)
    scale_lst = []
    for note in scale:
        scale_lst.append(note.midi_note_number())

    if count:
        while len(scale_lst) < count:
            root = scale_lst.pop()
            scale = Scale.build_scale(Note.from_midi_num(root), stype)
            for note in scale:
                scale_lst.append(note.midi_note_number())
    else:
        count = len(scale_lst)
        if pad + count > _PTOTAL:
            count = _PTOTAL + 1 - pad

    for note in scale_lst[:count]:
        bank = int((pad - 1) / _PADS)
        subpad = pad - (_PADS * bank) - 1

        config[1][bank][subpad]['note'] = note

        if verbose:
            print("Setting Pad %d (Bank %s-%d) to %d (%s)" %
                  (pad, chr(65 + bank), subpad + 1, note,
                   Note.from_midi_num(note)))
        pad = pad + 1
def test_scale_builder_e_maj():
    s = Scale.build_scale(Note('E', 4), 'maj')
    expected = [
        Note('E', 4),
        Note('F', 4, '#'),
        Note('G', 4, '#'),
        Note('A', 4),
        Note('B', 4),
        Note('C', 5, '#'),
        Note('D', 5, '#'),
        Note('E', 5)
    ]
    assert s == expected
def test_scale_builder_f_sharp_min():
    s = Scale.build_scale(Note('F', 4, '#'), 'minor')
    expected = [
        Note('F', 4, '#'),
        Note('G', 4, '#'),
        Note('A', 4),
        Note('B', 4),
        Note('C', 5, '#'),
        Note('D', 5),
        Note('E', 5, '#'),
        Note('F', 5, '#')
    ]
    assert s == expected
def test_scale_builder_c_flat_maj():
    s = Scale.build_scale(Note('C', 5, 'b'), 'maj')
    expected = [
        Note('C', 5, 'b'),
        Note('D', 5, 'b'),
        Note('E', 5, 'b'),
        Note('F', 5, 'b'),
        Note('G', 5, 'b'),
        Note('A', 5, 'b'),
        Note('B', 5, 'b'),
        Note('C', 6, 'b')
    ]
    assert s == expected
def test_scale_builder_b_flat_min():
    s = Scale.build_scale(Note('B', 4, 'b'), 'min')
    expected = [
        Note('B', 4, 'b'),
        Note('C', 5),
        Note('D', 5, 'b'),
        Note('E', 5, 'b'),
        Note('F', 5),
        Note('G', 5, 'b'),
        Note('A', 5),
        Note('B', 5, 'b')
    ]
    assert s == expected
def test_scale_builder_a_nat_min():
    s = Scale.build_scale(Note('A', 4), 'nat min')
    expected = [
        Note('A', 4),
        Note('B', 4),
        Note('C', 5),
        Note('D', 5),
        Note('E', 5),
        Note('F', 5),
        Note('G', 5),
        Note('A', 5)
    ]
    assert s == expected
예제 #10
0
def test_scale_builder_b_nat_min():
    s = Scale.build_scale(Note('B', 4), 'natural minor')
    expected = [
        Note('B', 4),
        Note('C', 5, '#'),
        Note('D', 5),
        Note('E', 5),
        Note('F', 5, '#'),
        Note('G', 5),
        Note('A', 5),
        Note('B', 5)
    ]
    assert s == expected
예제 #11
0
def test_scale_builder_c_flat_nat_min():
    s = Scale.build_scale(Note('C', 5, 'b'), 'natural minor')
    expected = [
        Note('C', 5, 'b'),
        Note('D', 5, 'b'),
        Note('E', 5, 'bb'),
        Note('F', 5, 'b'),
        Note('G', 5, 'b'),
        Note('A', 5, 'bb'),
        Note('B', 5, 'bb'),
        Note('C', 6, 'b')
    ]
    assert s == expected
예제 #12
0
def test_scale_builder_b_sharp_nat_min():
    s = Scale.build_scale(Note('B', 4, '#'), 'nat min')
    expected = [
        Note('B', 4, '#'),
        Note('C', 5, '##'),
        Note('D', 5, '#'),
        Note('E', 5, '#'),
        Note('F', 5, '##'),
        Note('G', 5, '#'),
        Note('A', 5, '#'),
        Note('B', 5, '#')
    ]
    assert s == expected
예제 #13
0
def test_simple_note_add_middle():
    c = Chord(Note.from_note_string('C4'))
    c.add_note(Note.from_note_string('E4'))
    c.add_note(Note.from_note_string('D4'))
    notes = [
        Note.from_note_string('C4'),
        Note.from_note_string('D4'),
        Note.from_note_string('E4')
    ]
    assert c.notes == notes
예제 #14
0
def test_multi_note_add_under():
    c = Chord(Note.from_note_string('D4'))
    c.add_note(Note.from_note_string('C4'))
    c.add_note(Note.from_note_string('B3'))
    notes = [
        Note.from_note_string('B3'),
        Note.from_note_string('C4'),
        Note.from_note_string('D4')
    ]
    assert c.notes == notes
예제 #15
0
def test_double_note_add():
    c = Chord(Note.from_note_string('C4'))
    c.add_note(Note.from_note_string('E4'))
    c.add_note(Note.from_note_string('B4'))
    notes = [
        Note.from_note_string('C4'),
        Note.from_note_string('E4'),
        Note.from_note_string('B4')
    ]
    assert c.notes == notes
예제 #16
0
def test_midi_127_flat():
    n = Note.from_note_string('A9bb')
    mid = n.midi_note_number()
    assert mid == 127
예제 #17
0
def test_midi_num_82():
    n1 = Note.from_midi_num(82)
    n2 = Note.from_note_string('A5#')
    assert n1 == n2
예제 #18
0
def test_midi_num_83():
    n1 = Note.from_midi_num(83)
    n2 = Note.from_note_string('B5')
    assert n1 == n2
예제 #19
0
def edit_scale(pad, verbose):
    global config

    rbank = int((pad - 1) / _PADS)
    rsubpad = pad - (_PADS * rbank) - 1

    menu = qprompt.Menu()
    menu.add("0", "Note")
    menu.add("1", "Midi-CC")
    menu.add("2", "Program")
    ptype = menu.show(msg="Apply Scale to:", returns="desc", dft="0")

    menu = qprompt.Menu()
    x = 0
    for y in Scale._SCALE_PATTERNS:
        menu.add(str(x), y)
        x = x + 1
    stype = menu.show(hdr="Pad %d (Bank %s-%d):" %
                      (pad, chr(65 + rbank), rsubpad + 1),
                      msg="Scale",
                      returns="desc")

    same = None
    if ptype == "Note":
        root = qprompt.ask_int("Note",
                               vld=list(range(0, 128)),
                               dft=config[1][rbank][rsubpad]['note'])

        same = qprompt.ask_yesno(msg="Config all as per Pad %d?" % pad,
                                 dft='N')
    elif ptype == "Midi-CC":
        root = qprompt.ask_int("Midi-CC Value",
                               vld=list(range(0, 128)),
                               dft=config[1][rbank][rsubpad]['midicc'])
    else:
        root = qprompt.ask_int("Program Value",
                               vld=list(range(0, 128)),
                               dft=config[1][rbank][rsubpad]['prog'])

    count = qprompt.ask_int("Count",
                            vld=[0] + list(range(1, _PTOTAL + 2 - pad)),
                            dft=0)

    scale = Scale.build_scale(Note.from_midi_num(root), stype)
    scale_lst = []
    for note in scale:
        scale_lst.append(note.midi_note_number())

    if count:
        while len(scale_lst) < count:
            root = scale_lst.pop()
            scale = Scale.build_scale(Note.from_midi_num(root), stype)
            for note in scale:
                scale_lst.append(note.midi_note_number())
    else:
        count = len(scale_lst)
        if pad + count > _PTOTAL:
            count = _PTOTAL + 1 - pad

    for note in scale_lst[:count]:
        bank = int((pad - 1) / _PADS)
        subpad = pad - (_PADS * bank) - 1

        if same and ptype == "Note":
            config[1][bank][subpad]['trigger'] = config[1][rbank][rsubpad][
                'trigger']

        if ptype == "Note":
            config[1][bank][subpad]['note'] = note
        elif ptype == "Midi-CC":
            config[1][bank][subpad]['midicc'] = note
        else:
            config[1][bank][subpad]['prog'] = note

        if verbose:
            print("Setting Pad %d (Bank %s-%d) to %d (%s)" %
                  (pad, chr(65 + bank), subpad + 1, note,
                   Note.from_midi_num(note)))
        pad = pad + 1
예제 #20
0
def test_midi_11():
    n = Note.from_note_string('B-1')
    mid = n.midi_note_number()
    assert mid == 11
예제 #21
0
def test_midi_16():
    n = Note.from_note_string('E0')
    mid = n.midi_note_number()
    assert mid == 16
예제 #22
0
def edit_scale(pad, verbose):
    global config

    rbank = int((pad - 1) / _PADS)
    rsubpad = pad - (_PADS * rbank) - 1

    ptype = config[1][rbank][rsubpad]['type']
    if ptype == "BANK":
        qprompt.error("Pad %d (Bank %s-%d) is configured as a BANK" %
                      (pad, chr(65 + rbank), rsubpad + 1))
        return

    menu = qprompt.Menu()
    x = 0
    for y in Scale._SCALE_PATTERNS:
        menu.add(str(x), y)
        x = x + 1
    stype = menu.show(hdr="Pad %d (Bank %s-%d):" %
                      (pad, chr(65 + rbank), rsubpad + 1),
                      msg="Scale",
                      returns="desc")

    root = qprompt.ask_int("Note",
                           vld=list(range(0, 128)),
                           dft=config[1][rbank][rsubpad]['note'])

    count = qprompt.ask_int("Count",
                            vld=[0] + list(range(1, _PTOTAL + 2 - pad)),
                            dft=0)

    same = qprompt.ask_yesno(msg="Config all as per Pad %d?" % pad, dft='N')

    scale = Scale.build_scale(Note.from_midi_num(root), stype)
    scale_lst = []
    for note in scale:
        scale_lst.append(note.midi_note_number())

    if count:
        while len(scale_lst) < count:
            root = scale_lst.pop()
            scale = Scale.build_scale(Note.from_midi_num(root), stype)
            for note in scale:
                scale_lst.append(note.midi_note_number())
    else:
        count = len(scale_lst)
        if pad + count > _PTOTAL:
            count = _PTOTAL + 1 - pad

    for note in scale_lst[:count]:
        bank = int((pad - 1) / _PADS)
        subpad = pad - (_PADS * bank) - 1

        if same and ptype == "NOTE":
            config[1][bank][subpad]['type'] = config[1][rbank][rsubpad]['type']
            config[1][bank][subpad]['channel'] = config[1][rbank][rsubpad][
                'channel']
            config[1][bank][subpad]['trigger'] = config[1][rbank][rsubpad][
                'trigger']
            config[1][bank][subpad]['aftertouch'] = config[1][rbank][rsubpad][
                'aftertouch']

        if same and ptype == "PROG":
            config[1][bank][subpad]['type'] = config[1][rbank][rsubpad]['type']
            config[1][bank][subpad]['channel'] = config[1][rbank][rsubpad][
                'channel']

        if ptype == "NOTE":
            config[1][bank][subpad]['note'] = note
        else:
            config[1][bank][subpad]['program'] = note

        if verbose:
            print("Setting Pad %d (Bank %s-%d) to %d (%s)" %
                  (pad, chr(65 + bank), subpad + 1, note,
                   Note.from_midi_num(note)))
        pad = pad + 1
예제 #23
0
def test_midi_10_flat():
    n = Note.from_note_string('B-1b')
    mid = n.midi_note_number()
    assert mid == 10
예제 #24
0
def test_midi_10_sharp():
    n = Note.from_note_string('A-1#')
    mid = n.midi_note_number()
    assert mid == 10
예제 #25
0
def test_midi_9():
    n = Note.from_note_string('A-1')
    mid = n.midi_note_number()
    assert mid == 9
예제 #26
0
def test_midi_22_sharp():
    n = Note.from_note_string('A0#')
    mid = n.midi_note_number()
    assert mid == 22
예제 #27
0
def test_midi_23():
    n = Note.from_note_string('B0')
    mid = n.midi_note_number()
    assert mid == 23
예제 #28
0
def test_midi_22_flat():
    n = Note.from_note_string('B0b')
    mid = n.midi_note_number()
    assert mid == 22
예제 #29
0
def test_midi_127():
    n = Note.from_note_string('G9')
    mid = n.midi_note_number()
    assert mid == 127
예제 #30
0
def test_midi_127_double_sharp():
    n = Note.from_note_string('F9##')
    mid = n.midi_note_number()
    assert mid == 127