def make_wav_from_txt():
    #the optoin allows the user to pick a text including notes for a melody
    #if the file does not exist the option will keep asking the user until valid input is given
    #the file also is saved temporarly and is later changed or saved over
    #this is a helper function for choice 3 in the main and is used only there
    while True:
        note_file_name = input("Please choose a note file:")
        if os.path.isfile(note_file_name) == False:
            print("Please choose an existing file within the directory")
            continue
        else:
            break

    data = text_reader(note_file_name)
    temp_name = 'tuner_temp'

    results_from_notes = Tuner(data)
    wave_helper.save_wave(SAMPLE_RATE, results_from_notes, temp_name)

    last_input_note = int(input("Do you want to: 1.Save File or 2.Edit File"))

    if last_input_note == 1:
        new_file = input("Please name your file for saving:")
        os.rename(temp_name, new_file)
        sys.exit()

    if last_input_note == 2:
        user_choice_edit(temp_name)
Example #2
0
def action_flow():
    filename = input('enter file name')
    test_file = wave_helper.load_wave(filename)
    while test_file == -1:
        filename = input('The file is invalid enter file name')
        test_file = wave_helper.load_wave(filename)
    sample_rate, audio_data = wave_helper.load_wave(filename)
    action_chosen = 0
    while action_chosen != OPTION_END_MENU:
        action_chosen = input(USER_MENU)
        if action_chosen == OPTION_REVERSE:
            audio_data = reverse_audio(audio_data)
        if action_chosen == OPTION_NAGATE:
            audio_data = negate_the_audio(audio_data)
        if action_chosen == OPTION_ACC:
            audio_data = speed_acceleration(audio_data)
        if action_chosen == OPTION_DEC:
            audio_data = speed_deceleration(audio_data)
        if action_chosen == OPTION_VOL_INC:
            audio_data = increase_the_volume(audio_data)
        if action_chosen == OPTION_VOL_DEC:
            audio_data = decrease_the_volume(audio_data)
        if action_chosen == OPTION_LOW_PASS:
            audio_data = low_pass_filter(audio_data)
    wave_helper.save_wave(sample_rate, audio_data, filename)
Example #3
0
def save_wav_file(rate, lst):
    """
    this function is saving the file with a new name
    :param rate: the updated rate value
    :param lst: the updated list
    """
    fn = input("Get output file name: ")
    wave_helper.save_wave(rate, lst, fn)
def transition_menu(sample_rate, wave_lst):
    """a menu that is appearing when the user has already done 1 action,
    then it asks him if he want to make another change or to save the
    changes in a file.
    also saves the file if the user wants."""
    user_choice = input(TRANSITIONS_MENU_INPUT)
    if user_choice == ANOTHER_CHANGE:
        changing_a_wav_file_menu(sample_rate, wave_lst)
    elif user_choice == SAVE_FILE:
        output_filename = input(OUTPUT_FILENAME_INPUT)
        wave_helper.save_wave(sample_rate, wave_lst, output_filename)
    else:
        print(BAD_INPUT_NUMBER)
Example #5
0
def save_audio(filename, wav_list):
    """
    """
    valid_file = False
    temp_file = filename
    print(f"File name: {filename}.  Do you want to change the name?")
    while not valid_file:
        temp_file = input("enter valid filename: ")
        if temp_file != "":
            valid_file = True
        #if ".wav" not in temp_file:
        #   temp_file += ".wav"
    wave_helper.save_wave(wav_list[0], wav_list[1], temp_file)
Example #6
0
def save_audio(filename, wav_list):
    """
    the function gets a file name and auido data (lst)
    this function creates wav file from wav_list and saves it as wav file.
    """
    valid_file = False
    temp_file = filename
    print(f"File name: {filename}.  Do you want to change the name?")
    while not valid_file:
        temp_file = input("enter valid filename: ")
        if temp_file != "":
            valid_file = True
        #TODO CHECK IF IT IS OKAY TO THIS SHIT
        #if ".wav" not in temp_file:
         #   temp_file += ".wav"
    wave_helper.save_wave(wav_list[0], wav_list[1], temp_file)
def transit_menu(wave):
    """After every change to the given or created file, this menu will tell
    if the user wants to save, and then go to main menu, or keep changing
    the file."""
    frame_rate = wave[FRAME_IN_WAVE]
    audio_data = wave[AUDIO_IN_WAVE]
    user_input = input(GO_MENU_MSG)
    while user_input not in [SAVE_AUDIO, CHANGE_AUDIO]:
        print(INVALID_INPUT_MSG)
        user_input = input(GO_MENU_MSG)
    if user_input == SAVE_AUDIO:
        filename = input(SAVE_MSG)
        wave_helper.save_wave(frame_rate, audio_data, filename)
        main()
    else:
        change_checked_file([frame_rate, audio_data])
def merge_helper_main():
    #if the user picks this option then they will be asked to input the paths of two wav files
    #that he wishes to combine
    #the option uses helper functions and the merging function
    #before doing so the option checks if the files exist or not by using a helper function
    #after merging the sound data using the merge function the optoin checks for the minimum frame rate
    #to be able to save the file using that framerate
    #THIS IS A HELPER FUNCTION USED IN THE MAIN ONLY for readiablity

    while True:
        file_paths = input("Please input file paths:")
        path1, path2 = file_path_to_two(file_paths)
        if check_file_correct_exists(
                path1) == False or check_file_correct_exists(path2) == False:
            continue
    first_file_read = wave_helper.load_wave(path1)

    second_file_read = wave_helper.load_wave(path2)

    first_file_f_rate = first_file_read[0]
    second_file_f_rate = second_file_read[0]

    new_wave = merging_audios(first_file_read, second_file_read)
    current_frame_rate = min(first_file_f_rate, second_file_f_rate)
    temp_file_name = 'merged wave'

    #the function saves the a temporary file with a temp name to be changed later
    #by orders of the ex6 pdf the option has to save before going to the last menu
    wave_helper.save_wave(current_frame_rate, new_wave, temp_file_name)

    last_input_merged = int(
        input("Do you want to: 1.Save File or 2.Edit File"))

    if last_input_merged == 1:
        new_name = input("Please name your file for saving:")
        #if the user chooses to save then the functoin would just
        #change the temp file name to the user's chosen name
        #and then exit
        os.rename(temp_file_name, new_name)
        sys.exit()

    if last_input_merged == 2:
        #second option takes the user to the editing menu
        user_choice_edit(temp_file_name)
Example #9
0
def save_file(wav_file):
    """
    A function that saves sound to a file, as the user chooses
    :param wav_file: tuple, Represents sound
    """
    new_name = input(NEW_FILE_NAME_MSG)
    result = helper.save_wave(wav_file[0], wav_file[1], new_name)
    if result == 0:
        print(SUCCESSFUL_SAVE_MSG)
    else:
        print(UNSUCCESSFUL_SAVE_MSG)
Example #10
0
def exit_menu(wav_list):
    print("How do you want to save this file? ")
    output_file_name = input()
    check_problem = wave_helper.save_wave(wav_list[0], wav_list[1],
                                          output_file_name + ".wav")
    if check_problem == -1:
        print("There was a problem, action was'nt completed")
    else:
        print(
            "Action completed \n hope you like it! \n --- returning to main menu ---"
        )
    start_menu()
def user_choice_edit(file_name):
    #function to be used in the main,to be able to make it more readable
    #the function takes a filename as a variable and loads it
    #leaving us the sound data and framerate to use
    #the user is given a choice between six different options
    #if the user doesn't pick a correct option the function will inform the user
    #and ask for a valid choice once again
    while True:
        list_of_sounds = wave_helper.load_wave(file_name)[1]
        current_frame_rate = wave_helper.load_wave(file_name)[0]
        printer()
        second_input = input()
        int_second_input = int(second_input)
        if int_second_input == 1:
            list_of_sounds = reverse_sounds(list_of_sounds)
        elif int_second_input == 2:
            list_of_sounds = speed_up(list_of_sounds)
        elif int_second_input == 3:
            list_of_sounds = slow_down(list_of_sounds)
        elif int_second_input == 4:
            list_of_sounds = volume_up(list_of_sounds)
        elif int_second_input == 5:
            list_of_sounds = volume_down(list_of_sounds)
        elif int_second_input == 6:
            list_of_sounds = dimming(list_of_sounds)

        else:
            second_input = input('choose a valid number')
        last_input = input("Do you want to: 1.Save File or 2.Edit File")
        if last_input is 1:
            new_file = input("Please name your file for saving:")
            wave_helper.save_wave(current_frame_rate, list_of_sounds, new_file)
            sys.exit()

        if last_input is 2:
            continue
Example #12
0
def music_menu(music_list):
    valid = True
    while valid:
        x = int(
            input(
                "choose one of the options for editing \n 1. reverse audio \n"
                " 2.accelerate audio \n 3.decelerate audio \n"
                " 4. raise volume\n 5. decrease volume \n 6.dimming \n"
                " 7.exit and save file"))
        if x == 1:
            music_list = reverseaudio(music_list)
            print("the audio has been reversed")
        elif x == 2:
            music_list = accelerate(music_list)
            print("the audio has been accelerated")
        elif x == 3:
            music_list = decelerate(music_list)
            print("the audio has been decelerated")
        elif x == 4:
            music_list = volume_up(music_list)
            print("the volume in the audio has been increased")
        elif x == 5:
            music_list = volume_down(music_list)
            print("the volume in the audio has been decreased")
        elif x == 6:
            music_list = dimming(music_list)
            print("the audio has been dimmed")
        elif x == 7:
            file_name = input("insert a file name for the new file")
            success = wave_helper.save_wave(2000, music_list, file_name)
            if success == (-1):
                print("did'nt save")
            break
        else:
            print("invalid input")
        print(music_list)