"""Rebuild the original mono PCM16, 8000 Hz silence controls. Python standard library."""
from pathlib import Path
import math,struct,wave
base=Path(__file__).resolve().parent
tone=[round(.5*min(1,i/40,(15999-i)/40)*math.sin(2*math.pi*261.625565*i/8000)*32767) for i in range(16000)]
for name,offset in [('silence-control.wav',0),('silence-leading.wav',4000)]:
    pcm=[0]*20000;pcm[offset:offset+16000]=tone
    with wave.open(str(base/name),'wb') as f:
        f.setparams((1,2,8000,0,'NONE','not compressed'))
        f.writeframes(struct.pack('<20000h',*pcm))
    print(base/name)
