Ejemplo n.º 1
0
def mov_six():
    """blank movement"""
    return info.Movement(num=6)
Ejemplo n.º 2
0
def mov_four():
    """fourth movement"""
    return info.Movement(num=4, tempo='Adagio', key=('d', 'major'))
Ejemplo n.º 3
0
def mov_five():
    """blank movement"""
    return info.Movement(num=5)
Ejemplo n.º 4
0
def mov_three():
    """Third movement"""
    return info.Movement(num=3, tempo='Vivace', key=('a', 'major'), time='2/4')
Ejemplo n.º 5
0
def mov_two():
    """Two movement."""
    return info.Movement(num=2, tempo='Largo', key=('a', 'minor'), time='3/4')
Ejemplo n.º 6
0
def mov_one_empty():
    """Empty first movement."""
    return info.Movement(num=1)
Ejemplo n.º 7
0
def mov_one_all():
    """Populated first movement."""
    return info.Movement(num=1,
                         tempo='Allegro',
                         time='4/4',
                         key=('a', 'major'))
Ejemplo n.º 8
0
def movement_prompt(curr_movements):
    if curr_movements:
        print("Movements in piece: ")
        print_movements(curr_movements)
    prompt_help = ("Options:\n"
                   f"{BOLD}print{END} movements\n"
                   f"{BOLD}create{END} a new movement\n"
                   f"{BOLD}edit{END} a movement\n"
                   f"{BOLD}delete{END} a movement\n"
                   f"{BOLD}help{END} to view this message\n"
                   f"{BOLD}done{END} to save and return to main prompt")
    print(prompt_help)
    command_completer = WordCompleter(
        ['create', 'delete', 'print', 'edit', 'help', 'done'])
    tempo_completer = InsensitiveCompleter(get_tempo_words())
    mode_completer = WordCompleter(info.get_allowed_modes())
    while True:
        command = prompt("Movements> ", completer=command_completer)
        if len(command) == 0:
            continue
        elif command.lower()[0] == 'h':
            print(prompt_help)
        elif command.lower()[0] == 'p':
            print_movements(curr_movements)
        elif command.lower()[0] == 'c':
            new_mov_num = len(curr_movements) + 1
            new_mov_tempo = prompt("Enter tempo (optional): ",
                                   completer=tempo_completer)
            new_mov_time = prompt("Enter time signature (optional): ")
            new_mov_key_note = prompt("Enter key note: ",
                                      validator=NoteValidator())
            new_mov_key_mode = prompt("Enter key mode: ",
                                      completer=mode_completer,
                                      validator=ModeValidator())
            new_mov_key = info.KeySignature(note=new_mov_key_note,
                                            mode=new_mov_key_mode)
            curr_movements.append(
                info.Movement(num=new_mov_num,
                              tempo=new_mov_tempo,
                              time=new_mov_time,
                              key=new_mov_key))
        elif command.lower()[0] == 'e':
            print_movements(curr_movements)
            mov_num = int(
                prompt("Enter movement number to edit: ",
                       validator=IndexValidator(len(curr_movements),
                                                allow_empty=False)))
            working_mov = curr_movements[mov_num - 1]
            curr_movements[mov_num - 1].tempo = prompt(
                "Enter tempo (optional): ",
                completer=tempo_completer,
                default=working_mov.tempo)
            curr_movements[mov_num - 1].time = prompt(
                "Enter time signature (optional): ", default=working_mov.time)
            new_key_note = prompt("Enter key note: ",
                                  validator=NoteValidator(),
                                  default=working_mov.key.note)
            new_key_mode = prompt("Enter key mode: ",
                                  completer=mode_completer,
                                  validator=ModeValidator(),
                                  default=working_mov.key.mode)
            new_key = info.KeySignature(note=new_key_note, mode=new_key_mode)
            curr_movements[mov_num - 1].key = new_key
        elif command.lower()[0:2] == 'de':
            print_movements(curr_movements)
            mov_num = int(
                prompt("Enter movement number to delete: ",
                       validator=IndexValidator(len(curr_movements),
                                                allow_empty=False)))
            delete_index = mov_num - 1
            curr_movements.pop(delete_index)
            for i in range(delete_index, len(curr_movements)):
                curr_movements[i].num = curr_movements[i].num - 1
        elif command.lower()[0:2] == 'do':
            return curr_movements
        else:
            print(INVALID)