From e327aeaca933c8642437ed0e0a906763f7695489 Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 6 Mar 2023 20:46:19 +0000 Subject: [PATCH] Add utility script --- render_and_play.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 render_and_play.py diff --git a/render_and_play.py b/render_and_play.py new file mode 100644 index 0000000..eacfd91 --- /dev/null +++ b/render_and_play.py @@ -0,0 +1,25 @@ +import pathlib +import re +import subprocess +import sys + + +win_root = pathlib.Path(r"C:\Users\louis\GitKraken\dottes") +lin_root = pathlib.Path("~/dottes") + +try: + win_abc_file_path = pathlib.Path(sys.argv[1]) +except IndexError: + win_abc_file_path = pathlib.Path(input()) + +if not str(win_abc_file_path).lower().endswith(".abc"): + input("Doesn't look like an abc file.") + exit(1) + +lin_abc_file_path = lin_root / win_abc_file_path.relative_to(win_root) +out_file_name = lin_abc_file_path.name.rsplit(".", 1)[0] + ".mid" +output_path = lin_abc_file_path.parent / out_file_name + +command = f"abc2midi {lin_abc_file_path.as_posix()} -o {output_path.as_posix()}" +print("Command:", command) +r = subprocess.run([r"wsl"], input=command.encode())