Ignore:
Timestamp:
Jul 12, 2012, 1:39:40 AM (12 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
1ebf8770, 913ee14
Parents:
f6cbefe
Message:

test_filterbank.py: splitted and completed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • interfaces/python/test_filterbank.py

    • Property mode changed from 100644 to 100755
    rf6cbefe r5e3ed60  
     1#! /usr/bin/python
     2
    13from numpy.testing import TestCase, run_module_suite
    24from numpy.testing import assert_equal, assert_almost_equal
    3 from numpy import array, shape
     5from numpy import random
    46from aubio import cvec, filterbank
    57
    6 class aubio_filter_test_case(TestCase):
     8class aubio_filterbank_test_case(TestCase):
    79
    8   def test_slaney(self):
     10  def test_members(self):
    911    f = filterbank(40, 512)
    10     f.set_mel_coeffs_slaney(16000)
    11     a = f.get_coeffs()
    12     a.T
    13     assert_equal(shape (a), (40, 512/2 + 1) )
     12    assert_equal ([f.n_filters, f.win_s], [40, 512])
    1413
    15   def test_other_slaney(self):
    16     f = filterbank(40, 512*2)
    17     f.set_mel_coeffs_slaney(44100)
    18     a = f.get_coeffs()
    19     #print "sum is", sum(sum(a))
    20     for win_s in [256, 512, 1024, 2048, 4096]:
    21       f = filterbank(40, win_s)
    22       f.set_mel_coeffs_slaney(320000)
    23       a = f.get_coeffs()
    24       #print "sum is", sum(sum(a))
    25 
    26   def test_triangle_freqs_zeros(self):
    27     f = filterbank(9, 1024)
    28     freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000]
    29     freqs = array(freq_list, dtype = 'float32')
    30     f.set_triangle_bands(freqs, 48000)
    31     f.get_coeffs().T
    32     assert_equal ( f(cvec(1024)), 0)
    33 
    34   def test_triangle_freqs_ones(self):
    35     f = filterbank(9, 1024)
    36     freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000]
    37     freqs = array(freq_list, dtype = 'float32')
    38     f.set_triangle_bands(freqs, 48000)
    39     f.get_coeffs().T
    40     spec = cvec(1024)
    41     spec.norm[:] = 1
    42     assert_almost_equal ( f(spec),
    43             [ 0.02070313,  0.02138672,  0.02127604,  0.02135417,
    44         0.02133301, 0.02133301,  0.02133311,  0.02133334,  0.02133345])
     14  def test_set_coeffs(self):
     15    f = filterbank(40, 512)
     16    r = random.random([40, 512 / 2 + 1]).astype('float32')
     17    f.set_coeffs(r)
     18    assert_equal (r, f.get_coeffs())
    4519
    4620if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.