diff --git a/CHANGES.rst b/CHANGES.rst index 970037505..b2bc7245b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -22,6 +22,14 @@ Other changes: * added classes for onset/note/beat detection with RNNs to `features.*` (#118) * converted `madmom.modules` into a Python package (#125) + +Version 0.13.2 (release date: 2016-06-09) +----------------------------------------- + +This is a bugfix release. + +* Fix custom filterbank in FilteredSpectrogram (#142) + Version 0.13.1 (release date: 2016-03-14) ----------------------------------------- diff --git a/madmom/audio/filters.py b/madmom/audio/filters.py index fd3fb87d2..07ca301c7 100644 --- a/madmom/audio/filters.py +++ b/madmom/audio/filters.py @@ -1058,13 +1058,13 @@ class MelFilterbank(Filterbank): def __init__(self, bin_frequencies, num_bands=NUM_BANDS, fmin=FMIN, fmax=FMAX, norm_filters=NORM_FILTERS, - unique_filters=UNIQUE_FILTERS): + unique_filters=UNIQUE_FILTERS, **kwargs): # this method is for documentation purposes only pass def __new__(cls, bin_frequencies, num_bands=NUM_BANDS, fmin=FMIN, fmax=FMAX, norm_filters=NORM_FILTERS, - unique_filters=UNIQUE_FILTERS): + unique_filters=UNIQUE_FILTERS, **kwargs): # pylint: disable=arguments-differ # get a list of frequencies aligned on the Mel scale # request 2 more bands, because these are the edge frequencies @@ -1112,13 +1112,13 @@ class BarkFilterbank(Filterbank): def __init__(self, bin_frequencies, num_bands=NUM_BANDS, fmin=FMIN, fmax=FMAX, norm_filters=NORM_FILTERS, - unique_filters=UNIQUE_FILTERS): + unique_filters=UNIQUE_FILTERS, **kwargs): # this method is for documentation purposes only pass def __new__(cls, bin_frequencies, num_bands=NUM_BANDS, fmin=FMIN, fmax=FMAX, norm_filters=NORM_FILTERS, - unique_filters=UNIQUE_FILTERS): + unique_filters=UNIQUE_FILTERS, **kwargs): # pylint: disable=arguments-differ # get a list of frequencies if num_bands == 'normal': diff --git a/tests/test_audio_spectrogram.py b/tests/test_audio_spectrogram.py index 7a9b425f1..0f17c4936 100644 --- a/tests/test_audio_spectrogram.py +++ b/tests/test_audio_spectrogram.py @@ -13,7 +13,8 @@ from .test_audio_filters import FFT_FREQS_1024, LOG_FILTERBANK_CENTER_FREQS from madmom.audio.spectrogram import * -from madmom.audio.filters import Filterbank, LogarithmicFilterbank +from madmom.audio.filters import (Filterbank, LogarithmicFilterbank, + MelFilterbank, BarkFilterbank) from madmom.audio.stft import ShortTimeFourierTransform @@ -224,6 +225,23 @@ def test_values(self): self.assertTrue(result.num_bins == 81) self.assertTrue(result.num_frames == 281) + def test_filterbanks(self): + # with Mel filterbank + result = FilteredSpectrogram(AUDIO_PATH + '/sample.wav', + filterbank=MelFilterbank, num_bands=40) + self.assertTrue(np.allclose(result[0, :6], + [8.42887115, 17.98174477, 19.50165367, + 6.48194313, 2.96991181, 4.06280804])) + self.assertTrue(result.shape == (281, 40)) + # with Bark filterbank + result = FilteredSpectrogram(AUDIO_PATH + '/sample.wav', + filterbank=BarkFilterbank, + num_bands='normal') + self.assertTrue(np.allclose(result[0, :6], + [16.42251968, 17.36715126, 2.81979132, + 4.27050114, 3.08699131, 1.50553513])) + self.assertTrue(result.shape == (281, 23)) + def test_methods(self): result = FilteredSpectrogram(AUDIO_PATH + '/sample.wav') self.assertIsInstance(result.diff(), SpectrogramDifference)