70 lines
2.6 KiB
Python
70 lines
2.6 KiB
Python
|
# The following is how these files were generated from memory dumps
|
||
|
|
||
|
import numpy as np
|
||
|
unk1_lut = np.fromfile('unk1_values.bin', dtype=np.int32)
|
||
|
unk2_lut = np.fromfile('unk2_values.bin', dtype=np.int32)
|
||
|
unk1_rlut = {v: i for i, v in enumerate(unk1_values)}
|
||
|
unk2_rlut = {v: i for i, v in enumerate(unk2_values)}
|
||
|
notetype_lut = ['e', 't', 'h', 'b', 's', 'x']
|
||
|
|
||
|
def make_rgtx(filename, data):
|
||
|
# Near-lossless (float rounding) representation of the memory dumps.
|
||
|
# Once the meaning of unk1 and unk2 are determined, it should be possible to interpret a chart 100% correctly from this.
|
||
|
out_filename = filename.partition('.')[0] + '.rgtx'
|
||
|
lines = []
|
||
|
if len(data.shape) != 2:
|
||
|
data = data.reshape([-1,20])
|
||
|
times = data[:,:2].view(dtype=np.float32).sum(1)
|
||
|
durations = data[:,2].view(dtype=np.float32)
|
||
|
cols = data[:,3]
|
||
|
ntypes = [notetype_lut[t] for t in data[:,4]]
|
||
|
sids = data[:,5]
|
||
|
stypes = data[:,6]
|
||
|
unk1s = [unk1_rlut[i] for i in data[:,7]]
|
||
|
unk2s = [unk2_rlut[i] for i in data[:,8]]
|
||
|
for i in range(len(times)):
|
||
|
timestr = f'{times[i]:.7g}'
|
||
|
notestr = f':{cols[i]}{ntypes[i]}{durations[i]:.7g},{sids[i]},{stypes[i]:x},{unk1s[i]:x},{unk2s[i]:x}'
|
||
|
if i==0 or times[i]!=times[i-1]:
|
||
|
lines.append(timestr + notestr)
|
||
|
else:
|
||
|
lines[-1] = lines[-1] + notestr
|
||
|
with open(out_filename, 'w') as f:
|
||
|
f.write('\n'.join(lines))
|
||
|
|
||
|
|
||
|
def make_rgts(filename, data):
|
||
|
# Simplified format that excludes durations for non-holds and slideIDs for non-slides
|
||
|
# Also excludes the unk1 and unk2 values for now which may discard important information
|
||
|
out_filename = filename.partition('.')[0] + '.rgts'
|
||
|
lines = []
|
||
|
if len(data.shape) != 2:
|
||
|
data = data.reshape([-1,20])
|
||
|
times = data[:,:2].view(dtype=np.float32).sum(1)
|
||
|
durations = data[:,2].view(dtype=np.float32)
|
||
|
cols = data[:,3]
|
||
|
ntypes = [notetype_lut[t] for t in data[:,4]]
|
||
|
sids = data[:,5]
|
||
|
stypes = data[:,6]
|
||
|
for i in range(len(times)):
|
||
|
timestr = f'{times[i]:.7g}'
|
||
|
notestr = f':{cols[i]}{ntypes[i]}'
|
||
|
if ntypes[i]=='h':
|
||
|
notestr += f'{durations[i]:.7g}'
|
||
|
elif ntypes[i] in ('s', 'e'):
|
||
|
notestr += f'{stypes[i]:x}{sids[i]}' # No comma, stype is exactly one character
|
||
|
if i==0 or times[i]!=times[i-1]:
|
||
|
lines.append(timestr + notestr)
|
||
|
else:
|
||
|
lines[-1] = lines[-1] + notestr
|
||
|
with open(out_filename, 'w') as f:
|
||
|
f.write('\n'.join(lines))
|
||
|
|
||
|
|
||
|
def make_files_from_dump(filename):
|
||
|
data = np.fromfile(filename, dtype=np.int32)
|
||
|
make_rgtx(filename, data)
|
||
|
make_rgts(filename, data)
|
||
|
|
||
|
# If you load this file in interactive mode (python -i example.py) you should be able to run the above function to convert any new memory dumps of the MMF format
|