OffiTracker/utils/beep2offitracker.py
Minki 75f9938727 Added utility for converting midi files to csv
This is a pure monophonic converter but should still help quite a bit with importing existing projects from LMMS or OpenMPT.
2024-01-02 20:02:22 +00:00

31 lines
873 B
Python

import sys
def generate_beep_file(beep_command):
lines = beep_command.split('-n')
output_lines = ["Frequency1,Effect1,Duration"]
for line in lines:
if '-f' in line:
parts = line.split()
frequency = int(parts[parts.index('-f') + 1])
duration = int(parts[parts.index('-l') + 1])
output_lines.append(f"{frequency},50,{duration}")
if '-D' in line:
delay = int(parts[parts.index('-D') + 1])
if delay > 0:
output_lines.append(f"0,0,{delay}")
output_content = '\n'.join(output_lines)
return output_content
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: python script.py 'beep_command'")
else:
beep_command = sys.argv[1]
result = generate_beep_file(beep_command)
print(result)