Created
May 20, 2023 02:45
-
-
Save jgillmanjr/aaad9647d78dafdf7e460c44bcc58ee9 to your computer and use it in GitHub Desktop.
Convert old style Midinous patches to new style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import json | |
save_path = Path('D:/SteamLibrary/steamapps/common/Midinous/user/save') # Change to the appropriate directory | |
pointfile = 'nouspoint.nous' | |
pathfile = 'nouspath.nous' | |
perffile = 'performance.nous' | |
convert_dirs = [x for x in save_path.glob('*') if x.is_dir()] | |
type_str = """{"type":0,"json":"\\"1.0.5\\""}""" | |
for condir in convert_dirs: | |
outfile = save_path.joinpath(f'{condir.name}.json') | |
# Convert some types. Based off https://discord.com/channels/318522612034830346/892392152913563689/1109243255603859548 | |
nouspoint = [x.replace('Note', 'Primary').replace('Velocity', 'Secondary') for x in condir.joinpath(pointfile).read_text().splitlines()] | |
nouspath = condir.joinpath(pathfile).read_text().splitlines() | |
performance = condir.joinpath(perffile).read_text() | |
with outfile.open('w') as fp: | |
fp.write(type_str + '\n') | |
# Points | |
for l in nouspoint: | |
json_line = { | |
'type': 1, | |
'json': l | |
} | |
js = json.dumps(json_line) | |
fp.write(js + '\n') | |
# Paths | |
for l in nouspath: | |
json_line = { | |
'type': 5, | |
'json': l | |
} | |
js = json.dumps(json_line) | |
fp.write(js + '\n') | |
# Performance | |
json_line = { | |
'type': 6, | |
'json': performance | |
} | |
js = json.dumps(json_line) | |
fp.write(js) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment