Skip to content

Commit 5dbf7fd

Browse files
committed
Remove popping in test
1 parent cd64f13 commit 5dbf7fd

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ if (NOT USE_SYSTEM_LIBSOXR)
8888

8989
# Build static libsoxr
9090
option(BUILD_TESTS "" OFF)
91-
option(WITH_OPENMP "" OFF)
91+
option(WITH_OPENMP "" OFF) # OpenMP seems not working (dunno why). Disable it for portability anyway.
9292
option(WITH_LSR_BINDINGS "" OFF)
9393
option(BUILD_SHARED_LIBS "" OFF) # make it shared someday?
9494
option(WITH_VR32 "" OFF)

tests/test_resample.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,38 +127,38 @@ def test_stream_length(in_rate, out_rate, chunk_size, length):
127127

128128

129129
def 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'])
135137
def 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])
152153
def 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

Comments
 (0)