From d2b668c386f3e6cf4f71f62171f87fb1af0ba3e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B6ck?= Date: Thu, 9 Jun 2016 08:53:58 +0200 Subject: [PATCH] re-add **kwargs to MelFilterbank and BarkFilterbank; fixes issue #141 --- CHANGES.rst | 8 ++++++++ madmom/audio/filters.py | 8 ++++---- tests/test_audio_spectrogram.py | 20 +++++++++++++++++++- 3 files changed, 31 insertions(+), 5 deletions(-) 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)