blob: 26dd2dc903f383f223489bb0c3f2459da540ce41 (
plain) (
tree)
|
|
# Part of the Fifteen-Thieves Project
# Chris Xiong 2020
# License: Expat (MIT)
import sys
import os
import xv.util
import xv.amap
wavecnt = [0] * 1024
wavenames = []
def process_preset(t, is_rhy=False):
if is_rhy:
for rkey in range(0, 85):
for rtone in range(0, 4):
if t.value(f"sd_root.part[0].rhythm.rtone[{rkey}].rt_wmt[{rtone}].switch"):
try:
wavecnt[t.value(f"sd_root.part[0].rhythm.rtone[{rkey}].rt_wmt[{rtone}].wave_number_l")] += 1
wavecnt[t.value(f"sd_root.part[0].rhythm.rtone[{rkey}].rt_wmt[{rtone}].wave_number_r")] += 1
except IndexError:
pass
else:
for tone in range(0, 4):
if t.value(f"sd_root.part[0].patch.tmt.tmt_block[{tone}].tone_switch"):
try:
wavecnt[t.value(f"sd_root.part[0].patch.tone[{tone}].tn_wave.wave_number_l")] += 1
wavecnt[t.value(f"sd_root.part[0].patch.tone[{tone}].tn_wave.wave_number_r")] += 1
except IndexError:
pass
if __name__ == "__main__":
print("loading address mapping...", flush=True, file=sys.stderr)
m = xv.amap.AddrMapTemplate("amaps/sd-80.amap")
t = xv.amap.create_addr_map_tree(m)
print("loading wave names...", file=sys.stderr)
with open("data/sdwavelist","r") as f:
for l in f:
wavenames += [l.split('\t')[1].strip()]
inst_dir = ["./data/patchparam/classical/", "./data/patchparam/contemporary/", "./data/patchparam/solo/"]
#inst_dir += ["./data/patchparam/enhanced/", "./data/patchparam/special_1/", "./data/patchparam/special_2/"]
rhy_dir = ["./data/rhythmparam/classical/", "./data/rhythmparam/contemporary/", "./data/rhythmparam/solo/"]
#rhy_dir += ["./data/rhythmparam/enhanced/"]
for i in inst_dir:
for fn in os.listdir(i):
mr = xv.util.load_memoryregion(os.path.join(i, fn))
for addr, data in mr:
ra = xv.util.b7belist2int(addr)
t.data[ra:ra + len(data)] = data
process_preset(t)
for i in rhy_dir:
for fn in os.listdir(i):
mr = xv.util.load_memoryregion(os.path.join(i, fn))
for addr, data in mr:
ra = xv.util.b7belist2int(addr)
t.data[ra:ra + len(data)] = data
process_preset(t, True)
for i, w in enumerate(wavenames):
print(f"{w.ljust(16)}{wavecnt[i + 1]}")
|