Skip to content

Commit a4e4d59

Browse files
committed
simplified resample implementation
force pre-release install of resampy on travis force cython install on travis for now removed forced conda install of cython in travis config updated install / test build for resampy 0.1.0
1 parent b25b8f4 commit a4e4d59

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

librosa/core/audio.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
'peak_pick', 'localmax']
2525

2626
# Resampling bandwidths as percentage of Nyquist
27-
# http://www.mega-nerd.com/SRC/api_misc.html#Converters
27+
# http://resampy.readthedocs.org/en/latest/api.html#module-resampy.filters
2828
BW_BEST = 0.9476
2929
BW_FASTEST = 0.85
3030

@@ -34,8 +34,6 @@
3434
import scikits.samplerate as samplerate # pylint: disable=import-error
3535
_HAS_SAMPLERATE = True
3636
except ImportError:
37-
warnings.warn('Could not import scikits.samplerate. '
38-
'Falling back to scipy.signal')
3937
_HAS_SAMPLERATE = False
4038

4139

@@ -263,15 +261,8 @@ def resample(y, orig_sr, target_sr, res_type='kaiser_best', fix=True, scale=Fals
263261
264262
"""
265263

266-
if y.ndim > 1:
267-
return np.vstack([resample(yi, orig_sr, target_sr,
268-
res_type=res_type,
269-
fix=fix,
270-
**kwargs)
271-
for yi in y])
272-
273264
# First, validate the audio buffer
274-
util.valid_audio(y, mono=True)
265+
util.valid_audio(y, mono=False)
275266

276267
if orig_sr == target_sr:
277268
return y
@@ -280,12 +271,10 @@ def resample(y, orig_sr, target_sr, res_type='kaiser_best', fix=True, scale=Fals
280271

281272
n_samples = int(np.ceil(y.shape[-1] * ratio))
282273

283-
scipy_resample = (res_type == 'scipy')
284-
285274
try:
286275
y_hat = resampy.resample(y, orig_sr, target_sr, filter=res_type, axis=-1)
287276
except NotImplementedError:
288-
if _HAS_SAMPLERATE and not scipy_resample:
277+
if _HAS_SAMPLERATE and (res_type != 'scipy'):
289278
y_hat = samplerate.resample(y.T, ratio, res_type).T
290279
else:
291280
y_hat = scipy.signal.resample(y, n_samples, axis=-1)

0 commit comments

Comments
 (0)