@@ -127,38 +127,38 @@ def test_stream_length(in_rate, out_rate, chunk_size, length):
127127
128128
129129def make_tone (freq , sr , duration ):
130- return np .sin (2 * np .pi * freq / sr * np .arange (int (sr * duration )))
130+ length = int (sr * duration )
131+ sig = np .sin (2 * np .pi * freq / sr * np .arange (length ))
132+ return sig * np .hanning (length )
131133
132134
133135@pytest .mark .parametrize ('in_rate,out_rate' , [(44100 , 22050 ), (22050 , 32000 )])
134136@pytest .mark .parametrize ('quality' , ['VHQ' , 'HQ' , 'MQ' , 'LQ' , 'QQ' ])
135137def test_quality_sine (in_rate , out_rate , quality ):
136138 FREQ = 32.0
137139 DURATION = 2.0
138- IG = 50 # ignore popping at start/end
139140
140141 x = make_tone (FREQ , in_rate , DURATION )
141142 y = make_tone (FREQ , out_rate , DURATION )
142143
143144 y_pred = soxr .resample (x , in_rate , out_rate , quality = quality )
144145 y_split = soxr .resample (np .asfortranarray (x ), in_rate , out_rate , quality = quality )
145146
146- assert np .allclose (y [ IG : - IG ] , y_pred [ IG : - IG ] , atol = 1e-4 )
147- assert np .allclose (y [ IG : - IG ] , y_split [ IG : - IG ] , atol = 1e-4 )
147+ assert np .allclose (y , y_pred , atol = 1e-4 )
148+ assert np .allclose (y , y_split , atol = 1e-4 )
148149
149150
150151@pytest .mark .parametrize ('in_rate,out_rate' , [(48000 , 24000 ), (32000 , 44100 )])
151152@pytest .mark .parametrize ('dtype' , [np .int32 , np .int16 ])
152153def test_int_sine (in_rate , out_rate , dtype ):
153154 FREQ = 32.0
154155 DURATION = 2.0
155- IG = 50 # ignore popping at start/end
156156
157157 x = (make_tone (FREQ , in_rate , DURATION ) * 16384 ).astype (dtype )
158158 y = (make_tone (FREQ , out_rate , DURATION ) * 16384 ).astype (dtype )
159159
160160 y_pred = soxr .resample (x , in_rate , out_rate )
161161 y_split = soxr .resample (np .asfortranarray (x ), in_rate , out_rate )
162162
163- assert np .allclose (y [ IG : - IG ] , y_pred [ IG : - IG ] , atol = 2 )
164- assert np .allclose (y [ IG : - IG ] , y_split [ IG : - IG ] , atol = 2 )
163+ assert np .allclose (y , y_pred , atol = 2 )
164+ assert np .allclose (y , y_split , atol = 2 )
0 commit comments