From db94643d2daf99bf86b656c36ccc5fa0e96483a9 Mon Sep 17 00:00:00 2001 From: p7mj Date: Fri, 27 Mar 2026 07:05:53 -0400 Subject: [PATCH] Added AtWAV --- AtWAV-A-1-i-Proto.py | 85 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 AtWAV-A-1-i-Proto.py diff --git a/AtWAV-A-1-i-Proto.py b/AtWAV-A-1-i-Proto.py new file mode 100644 index 0000000..009556d --- /dev/null +++ b/AtWAV-A-1-i-Proto.py @@ -0,0 +1,85 @@ +import wave +import sys +import os +from pathlib import Path + +def file_to_wav(input_filepath, output_wavpath): + print("Encrypting...", end = " ") + try: + with open(input_filepath, 'rb') as f: + raw_data = f.read() + + # Parameters: 1 channel (mono), 1 byte per sample (8-bit), 44100Hz + with wave.open(output_wavpath, 'wb') as wav_file: + wav_file.setnchannels(1) + wav_file.setsampwidth(1) # 1 byte per sample + wav_file.setframerate(16000) + wav_file.writeframes(raw_data) + + print("Success.") + delete_original = input("Remove original file? [Y]/[n] ") + if delete_original == "" or delete_original == "Y" or delete_original == "y": + os.remove(input_filepath) + except Exception as e: + print(f"Could not encrypt! {e}") + +def wav_to_file(input_wavpath, output_filepath): + print("Decrypting...") + try: + with wave.open(input_wavpath, 'rb') as wav_file: + # Get all frames (the actual data) + raw_data = wav_file.readframes(wav_file.getnframes()) + + with open(output_filepath, 'wb') as f: + f.write(raw_data) + + print("Success.") + delete_original = input("Remove original file? [Y]/[n] ") + if delete_original == "" or delete_original == "Y" or delete_original == "y": + os.remove(input_wavpath) + except Exception as e: + print(f"Could not decrypt! {e}") + +while True: + print("AtWAV Any to WAV | V-A-1-i Proto | by P7MJ") + choice = input("[1] Encrypt [2] Decrypt [h] Help [x] Exit\n > ") + if choice == "1": + print("") + while True: + unencrypted = input("Name of file w/extension > ") + file_path = Path(unencrypted) + + if file_path.is_file(): + print(f"Success! Found: {file_path.absolute()}") + break + else: + print(f"Error: '{unencrypted}' not found in {Path.cwd()}") + encrypted = input("Name of new WAV > ").replace(".wav", "").replace(".WAV", "") + ".wav" + file_to_wav(unencrypted, encrypted) + print("Disclaimer: Do not play this \"music\" through any speakers, it will probably destroy a couple of friendships. Read the help section for more information.") + + elif choice == "2": + print("") + while True: + pre_decrypt = input("Name of WAV > ").replace(".wav", "").replace(".WAV", "") + ".wav" + if Path(pre_decrypt).is_file(): + break + else: + print("Not an option!") + post_decrypt = input("Unencrypted file name w/extension > ") + wav_to_file(pre_decrypt, post_decrypt) + + elif choice == "h": + print("""HELP SECTION +Not an option: Double check if your filename exists! Add the extension! +When decrypting, make sure your extension is correct. +DO NOT PLAY MUSIC: Do not play the generated WAV! For your own ears and your speaker, please do not! If for any reason you want to, put the volume as low as possible. I actually mean it. + """) + + elif choice == "x": + sys.exit(0) + + else: + print("Not a valid menu choice!") + +