from pathlib import Path import math,unicodedata p=Path(__file__).parent;dest=Path('C:/Amiga/HD0/Utilities/AmberMod') root=Path('C:/Amiga/WHDLoad/MODS') def display(s):return ''.join(c for c in unicodedata.normalize('NFKD',s) if ord(c)<128 and ord(c)>=32).strip() rows=[] for f in sorted(root.rglob('*'),key=lambda f:str(f).lower()): if not f.is_file() or f.suffix.lower()!='.mod':continue try: with f.open('rb') as h: title=h.read(20).split(b'\0')[0].decode('latin1') title=display(title) filename=display(f.stem) shown=filename if not title or title.lower() in filename.lower() else filename+' / '+title path='WHDLoad:MODS/'+f.relative_to(root).as_posix() rows.append(shown[:94]+'\t'+path) except OSError:pass rows.sort(key=lambda row:row.split('\t',1)[0].casefold()) (dest/'catalog.txt').write_bytes(('\n'.join(rows)+'\n').encode('latin1',errors='replace')) def arr(name,values):return 'static short '+name+'[]={'+','.join(map(str,values))+'};\n' (p/'fft.h').write_text(arr('hann',[round((.5-.5*math.cos(2*math.pi*i/255))*16384) for i in range(256)])+arr('twcos',[round(math.cos(-2*math.pi*i/256)*16384) for i in range(128)])+arr('twsin',[round(math.sin(-2*math.pi*i/256)*16384) for i in range(128)])+arr('bandedge',[round(1*(127**(i/24))) for i in range(25)])+arr('logheight',[round(144*math.log1p(i)/math.log(129)) for i in range(256)])) print(len(rows),'MOD indicizzati')