forked from CryHavoc/dottes
Compare commits
No commits in common. "0a67785da15e2296060b97c414beb4b616e5544e" and "d57b94a271697972804064aa6aa91fd81ae67f05" have entirely different histories.
0a67785da1
...
d57b94a271
|
@ -12,5 +12,4 @@ Library-.*
|
|||
*.aux
|
||||
*.log
|
||||
*.orig
|
||||
*.mid
|
||||
*~
|
||||
|
|
|
@ -5,6 +5,6 @@ M: C
|
|||
L: 1/4
|
||||
Q: 160
|
||||
K: Gmaj
|
||||
d | "D" d B c d | "G" B>A G d | "G" d B c d | "G" B3 :|
|
||||
B | "D" A F G A | "G" B>A G B | "D" A F G A | "G" B3 B |
|
||||
"D" d | "D" d B c d | "G" B>A G d | "G" d B c d | "G" B3 :|
|
||||
"G" B | "D" A F G A | "G" B>A G B | "D" A F G A | "G" B3 B |
|
||||
"D" A F G A | "G" B>A G d | "D" d B c d | "G" B3 :|
|
||||
|
|
|
@ -7,7 +7,8 @@ M:C
|
|||
L:1/8
|
||||
Q:130
|
||||
K:G
|
||||
"G" GABc "C" A2> G2 | "D" F2D2 D4 | "D" d2A2 d3 c | "G" B2G2 G4 |
|
||||
"G" GABc A2>G2 | "D" F2D2 D4 | "D" d2A2 "G" d3 "D7" c | "G" B2G2 G4 |
|
||||
"Em" GABc "Am" A2>G2 | "D" F2 FG A2D2 | "C" EFG2 "D7" FGAB | "G" G4 G4 :|
|
||||
"D" FGA2 FGA2 | "D" d2 A2 d2 A2 | "C" FG A2 FG A2 | "D" d2 A2 d4 |
|
||||
"G" d2cB "Am" c2dc | "Bm" B2AG "C" A3D | "D" EFG2 "C" FGAB | "G" G4 G4 :|
|
||||
"D" FGA2 FGA2 | "D" d2 "A7" A2 "D" d2 "A7" A2 |\
|
||||
"D" FG "A" A2 "D" FG "A" A2 | "D" d2 "A7" A2 "D" d4 |
|
||||
"G" d2cB "D" c2dc | "G" B2AG "D" A3D | "C" EFG2 "D7" FGAB | "G" G4 G4 :|
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
#!/usr/bin/python3 -u
|
||||
|
||||
import logging
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
win_root = pathlib.Path(r"C:\Users\louis\GitKraken\dottes")
|
||||
lin_root = pathlib.Path("~/dottes")
|
||||
file_update_times = {}
|
||||
|
||||
|
||||
def run_continuous():
|
||||
logging.info("Run continous")
|
||||
|
||||
pwd = pathlib.Path()
|
||||
|
||||
while True:
|
||||
for obj_path in pwd.rglob("*"):
|
||||
obj_path_str = str(obj_path)
|
||||
if not obj_path.is_file():
|
||||
continue
|
||||
if not obj_path_str.lower().endswith(".abc"):
|
||||
continue
|
||||
|
||||
if obj_path_str not in file_update_times:
|
||||
file_update_times[obj_path_str] = obj_path.lstat().st_mtime
|
||||
else:
|
||||
if obj_path.lstat().st_mtime > file_update_times[obj_path_str]:
|
||||
file_update_times[obj_path_str] = obj_path.lstat().st_mtime
|
||||
convert_single(lin_path=obj_path_str)
|
||||
|
||||
|
||||
|
||||
def convert_single(win_path: str = None, lin_path: str = None):
|
||||
if win_path:
|
||||
input_path = win_path
|
||||
win_abc_file_path = pathlib.Path(win_path)
|
||||
lin_abc_file_path = lin_root / win_abc_file_path.relative_to(win_root)
|
||||
elif lin_path:
|
||||
input_path = lin_path
|
||||
lin_abc_file_path = pathlib.Path(lin_path)
|
||||
else:
|
||||
raise Exception("Argument win_path or lin_path must be given")
|
||||
|
||||
|
||||
logging.info(f"Converting {input_path}")
|
||||
|
||||
out_file_name = lin_abc_file_path.name.rsplit(".", 1)[0] + ".mid"
|
||||
output_path = lin_abc_file_path.parent / out_file_name
|
||||
|
||||
if output_path.exists():
|
||||
output_path.unlink()
|
||||
|
||||
r = subprocess.run(
|
||||
[
|
||||
"abc2midi",
|
||||
lin_abc_file_path.as_posix(),
|
||||
"-o", output_path.as_posix()
|
||||
]
|
||||
)
|
||||
|
||||
if r.returncode != 0:
|
||||
logging.error(f"Error whilst convering {lin_abc_file_path}")
|
||||
else:
|
||||
logging.info(f"Converted {input_path} > {output_path}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
if len(sys.argv) > 1:
|
||||
if sys.platform == "win32":
|
||||
convert_single(win_path=sys.argv[1])
|
||||
elif sys.platform == "linux":
|
||||
convert_single(lin_path=sys.argv[1])
|
||||
else:
|
||||
raise Exception(f"Unknown platform '{sys.platform}', don't know how to interpret path")
|
||||
else:
|
||||
run_continuous()
|
|
@ -0,0 +1,30 @@
|
|||
import os
|
||||
import pathlib
|
||||
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"
|
||||
lin_output_path = lin_abc_file_path.parent / out_file_name
|
||||
win_output_path = win_abc_file_path.parent / out_file_name
|
||||
|
||||
if win_output_path.exists():
|
||||
win_output_path.unlink()
|
||||
|
||||
command = f"abc2midi {lin_abc_file_path.as_posix()} -o {lin_output_path.as_posix()}"
|
||||
print("Command:", command)
|
||||
r = subprocess.run([r"wsl"], input=command.encode())
|
||||
os.system(str(win_output_path))
|
Loading…
Reference in New Issue