Skip to content

Commit

Permalink
backport #142 to v0.13.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Böck committed Jun 9, 2016
1 parent 74cb58f commit b1c485a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Release Notes
=============

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)
-----------------------------------------

Expand Down
8 changes: 4 additions & 4 deletions madmom/audio/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,13 +1015,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
Expand Down Expand Up @@ -1069,13 +1069,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':
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import numpy as np

# define version
version = '0.13.1'
version = '0.13.2'

# define which extensions need to be compiled
extensions = [Extension('madmom.ml.rnn',
Expand Down
20 changes: 19 additions & 1 deletion tests/test_audio_spectrogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -173,6 +174,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)
Expand Down

0 comments on commit b1c485a

Please sign in to comment.