#!/usr/bin/env python3
"""Rebuild Midilot's exact 20 October 2026 amplitude WAV fixtures."""
from pathlib import Path
import math,struct,wave,hashlib
out=Path(__file__).resolve().parent.parent/'samples';out.mkdir(exist_ok=True)
frames=16000;rate=8000
for name,amplitude in [('amplitude-reference.wav',0.5),('amplitude-quiet.wav',0.0002)]:
 values=[round(amplitude*min(1,i/40,(frames-1-i)/40)*math.sin(2*math.pi*261.625565*i/rate)*32767) for i in range(frames)]
 with wave.open(str(out/name),'wb') as w:w.setnchannels(1);w.setsampwidth(2);w.setframerate(rate);w.writeframes(struct.pack('<'+'h'*frames,*values))
with wave.open(str(out/'amplitude-quiet.wav'),'rb') as w:quiet=struct.unpack('<'+'h'*frames,w.readframes(frames))
boosted=[value*2500 for value in quiet];assert max(map(abs,boosted))<32768
with wave.open(str(out/'amplitude-boosted.wav'),'wb') as w:w.setnchannels(1);w.setsampwidth(2);w.setframerate(rate);w.writeframes(struct.pack('<'+'h'*frames,*boosted))
for name in ['amplitude-reference.wav','amplitude-quiet.wav','amplitude-boosted.wav']:print(name,hashlib.sha256((out/name).read_bytes()).hexdigest())
