Randoloot/tests/audio/surface_assets_test.py
2026-10-18 16:22:39 +02:00

21 lines
886 B
Python

from pathlib import Path
import wave
import numpy as np
ROOT = Path(__file__).resolve().parents[2]
files = list((ROOT/"assets/sounds/surface").glob("*.wav"))
assert len(files) == 13
seams = []
for path in files:
with wave.open(str(path)) as stream:
assert stream.getnchannels() == 2 and stream.getsampwidth() == 2 and stream.getframerate() == 48000
signal = np.frombuffer(stream.readframes(stream.getnframes()),dtype="<i2").reshape(-1,2)/32768.0
assert np.isfinite(signal).all()
assert np.max(np.abs(signal)) < .9
assert np.max(np.abs(signal.mean(axis=0))) < .01
if path.stem.endswith("loop"):
difference = float(np.max(np.abs(signal[0]-signal[-1])))
assert difference < .05
seams.append((path.name,round(difference,6)))
print("SURFACE ASSET QA PASS: 13 stereo PCM16 WAVs at 48 kHz, no clipping/DC, loop seam deltas:",seams)