Skip to content

Instantly share code, notes, and snippets.

@jgillmanjr
Created May 20, 2023 02:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgillmanjr/aaad9647d78dafdf7e460c44bcc58ee9 to your computer and use it in GitHub Desktop.
Save jgillmanjr/aaad9647d78dafdf7e460c44bcc58ee9 to your computer and use it in GitHub Desktop.
Convert old style Midinous patches to new style
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