from pathlib import Path
import wave,json
def readpcm(path):
 with wave.open(str(path),'rb') as w:
  rate=w.getframerate();n=w.getnframes();width=w.getsampwidth();b=w.readframes(n)
 return rate,[int.from_bytes(b[i:i+width],'little',signed=True)/(2**(width*8-1)-1) for i in range(0,len(b),width)]
r=[]
for n in ['discontinuous.wav','integer-cycles.wav','edge-fade.wav']:
 _,x=readpcm(Path(__file__).parent/n);r.append({'file':n,'frames':len(x),'boundary_jump':x[0]-x[-1]})
assert abs(r[0]['boundary_jump'])>.1 and abs(r[2]['boundary_jump'])==0
print(json.dumps(r,indent=2))
