diff --git a/tests/test_wave.py b/tests/test_wave.py new file mode 100644 index 0000000..8892c80 --- /dev/null +++ b/tests/test_wave.py @@ -0,0 +1,27 @@ +import numpy as np + +import pytest + +from ovgenpy.wave import Wave + + +prefix = 'tests/wav-formats/' +wave_paths = [ + # 2000 samples, with a full-scale peak at data[1000]. + 'u8-impulse1000.wav', + 's16-impulse1000.wav', + 's32-impulse1000.wav', + 'f32-impulse1000.wav', + 'f64-impulse1000.wav', +] + + +@pytest.mark.parametrize("wave_path", wave_paths) +def test_wave(wave_path): + wave = Wave(None, prefix + wave_path) + data = wave[:] + + # Audacity dithers <=16-bit WAV files upon export, creating a few bits of noise. + # As a result, amin(data) <= 0. + assert -0.01 < np.amin(data) <= 0 + assert 0.99 < np.amax(data) <= 1 diff --git a/tests/wav-formats/f32-impulse1000.wav b/tests/wav-formats/f32-impulse1000.wav new file mode 100644 index 0000000..cf32cd8 Binary files /dev/null and b/tests/wav-formats/f32-impulse1000.wav differ diff --git a/tests/wav-formats/f64-impulse1000.wav b/tests/wav-formats/f64-impulse1000.wav new file mode 100644 index 0000000..edc1c84 Binary files /dev/null and b/tests/wav-formats/f64-impulse1000.wav differ diff --git a/tests/wav-formats/s16-impulse1000.wav b/tests/wav-formats/s16-impulse1000.wav new file mode 100644 index 0000000..dbfc10f Binary files /dev/null and b/tests/wav-formats/s16-impulse1000.wav differ diff --git a/tests/wav-formats/s24-impulse1000.wav b/tests/wav-formats/s24-impulse1000.wav new file mode 100644 index 0000000..7f73960 Binary files /dev/null and b/tests/wav-formats/s24-impulse1000.wav differ diff --git a/tests/wav-formats/s32-impulse1000.wav b/tests/wav-formats/s32-impulse1000.wav new file mode 100644 index 0000000..74feca7 Binary files /dev/null and b/tests/wav-formats/s32-impulse1000.wav differ diff --git a/tests/wav-formats/u8-impulse1000.wav b/tests/wav-formats/u8-impulse1000.wav new file mode 100644 index 0000000..94c0f89 Binary files /dev/null and b/tests/wav-formats/u8-impulse1000.wav differ