From 7a818c0cd33a505de17822caf92bf659ccc3c274 Mon Sep 17 00:00:00 2001 From: nyanpasu64 Date: Fri, 20 Jul 2018 01:12:28 -0700 Subject: [PATCH] Add unit tests for Wave --- tests/test_wave.py | 27 ++++++++++++++++++++++++++ tests/wav-formats/f32-impulse1000.wav | Bin 0 -> 8080 bytes tests/wav-formats/f64-impulse1000.wav | Bin 0 -> 16080 bytes tests/wav-formats/s16-impulse1000.wav | Bin 0 -> 4044 bytes tests/wav-formats/s24-impulse1000.wav | Bin 0 -> 6044 bytes tests/wav-formats/s32-impulse1000.wav | Bin 0 -> 8044 bytes tests/wav-formats/u8-impulse1000.wav | Bin 0 -> 2044 bytes 7 files changed, 27 insertions(+) create mode 100644 tests/test_wave.py create mode 100644 tests/wav-formats/f32-impulse1000.wav create mode 100644 tests/wav-formats/f64-impulse1000.wav create mode 100644 tests/wav-formats/s16-impulse1000.wav create mode 100644 tests/wav-formats/s24-impulse1000.wav create mode 100644 tests/wav-formats/s32-impulse1000.wav create mode 100644 tests/wav-formats/u8-impulse1000.wav 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 0000000000000000000000000000000000000000..cf32cd8879055968b504385666f3638710d99913 GIT binary patch literal 8080 zcmeIuu?fR45QX8V$dESR0pd+$7dC`6PKu;(C2Z8C(*P=6c%v+lF;ZoQ$Xgiv9~|7l zaXh~JrR(Oi^lTn&c*W`@$;v3b^YA;UP^I9FhE<25=)6uygyR^{e*lck>BcBhEGc;^w9 zrfd52M-d=EfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009Dnz^53JNq_(W0t5&U gAV7cs0RjXF5FkK+009C72oNAZfB*pk1pZOr3kKT}VE_OC literal 0 HcmV?d00001 diff --git a/tests/wav-formats/s16-impulse1000.wav b/tests/wav-formats/s16-impulse1000.wav new file mode 100644 index 0000000000000000000000000000000000000000..dbfc10f19365e44e63696aed42f8f0456dfcfbdc GIT binary patch literal 4044 zcma)Vw=5JlStJB1@~6#|e*2_Qy7WMoK$a1`!A%B8?w5B>M~@q5M&7|T07-PKjU z{;#gtef#G1>tD~tc>nUUM9F`P#Va$vAEN*E)9jznd$!+tX>0xI8mpKc#}hr1y%g!%H6Tg=Y{h}vu)RROi_o*+Hu5`RaW)hX3;njA;9o5}fUGS(TMw7#9Wi6NNO zdJISVYJq>FXALci60}F{RSj!&g`4D-$oY2+Q%5$pd0~-ksERUCoOn;}*R$TPCJ(V? zXY9T3<~+IMmFmd;o4I$K*+jYS$v)A@=3ZUnf!Oe&e`iv5a6EkWT)Nd=N&x)u?$cKXEC%tlRu z`N_XpCK~y5OifVt)&`l%m|Wz!Xx7daF048%66JDo0_MAO->n*Y=`K(iNp9CWTn0BB zQk~9bfAs-59JVvNH(7F0qD1l_Z}251`+NH31(ayX`0lLc_4qw&9z|0f?Ra6#o|3*| z-(Yt?wMtj9Rz#szNb|xLH~II2dJy zirwSQQ_i`T=8-+IuRr~+x~!3>{kL+&ez^jh^<{4`rz0z{CXaNX?qyZ~y^B1VSVx@x zV-62lWhU7WhrEml-^N{i%bJ$W%(Eq`tQ@_gHK&v+^z^10;Mx5kk`qqKdX81GOb1g> zO}O^FtSYIncvTFWC-tQ zKf#+*Zr*kqEP+YXP7x>6;?5*LhNr+W0yy_eQOMzJI}HHdHC;B+?LA4ZljPZr+5 zVAl(u&54~@_~ts@SADxc_d1ewc2bjNu%r0jKZ#L($WQIpe6ch)xj^|~%T9Y3BP%C4 zR^?V%d_A7O=i%5Rirvx5>He)+7OkBi zh9llWk6Q#q*z<0T=(VCd_FDKM1JA7L2YqTXIpvC5Px z3B9Dob3gvPtvUteRMO}j4gmxZKmY**5I_I{1Q0*~0R-v`nAuf-1q%>B009ILKmY** N5I_I{1Q7VQzz4Ve3>yFd literal 0 HcmV?d00001 diff --git a/tests/wav-formats/u8-impulse1000.wav b/tests/wav-formats/u8-impulse1000.wav new file mode 100644 index 0000000000000000000000000000000000000000..94c0f89746173db5938dab0c353327fa98963085 GIT binary patch literal 2044 zcmZ`&IZ^{L5R@Yv@&vv@fU8IeAa)f+M&{i6FFwIz$U)Q7J%<)+K^pZn(%OD`KAnE< z#&~;tefs#kJlu~l4)fW*2L2D@INr~f^Y_$jS3H_FFSr;d2K8ox4pf!x+VBdd5pG8K za(iygO{U&UrZG7fuA|XI6iV0wk0Ls#kH@<68Uftn{;{rI5_$vxr)K6sxX2eL z@-c-jpp;r!y1HQ0g(N)`jMmRKDsqn219jLBtrSV|io_C;1- z11Jv@Y$x#{e6EvBEKGVEM$z6*0N4I20cml#y#$oT?B$&#v|P`2oPh*kq0f`F$y`ek z%GHox)K<+=ybc=>f7np7uc;G}ena%2hZ+gQy{5!*q2V#0ZFD3M3ab*To2g?#Rhv3z z{*;w##W5PzT$CU_dbGR