source: interfaces/python/test_filterbank.py @ 0536612

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 0536612 was 0536612, checked in by Paul Brossier <piem@piem.org>, 14 years ago

interfaces/python: added more tests

  • Property mode set to 100644
File size: 1.1 KB
Line 
1from numpy.testing import TestCase, run_module_suite
2from numpy.testing import assert_equal, assert_almost_equal
3from numpy import array, shape
4from _aubio import *
5
6class aubio_filter_test_case(TestCase):
7
8  def test_slaney(self):
9    f = filterbank(40, 512)
10    f.set_mel_coeffs_slaney(16000)
11    a = f.get_coeffs()
12    a.T
13
14  def test_other_slaney(self):
15    f = filterbank(40, 512*2)
16    f.set_mel_coeffs_slaney(44100)
17    a = f.get_coeffs()
18    #print "sum is", sum(sum(a))
19    for win_s in [256, 512, 1024, 2048, 4096]:
20      f = filterbank(40, win_s)
21      f.set_mel_coeffs_slaney(320000)
22      a = f.get_coeffs()
23      #print "sum is", sum(sum(a))
24
25  def test_triangle_freqs(self):
26    f = filterbank(9, 1024)
27    freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000]
28    freqs = array(freq_list, dtype = 'float32')
29    f.set_triangle_bands(freqs, 48000)
30    f.get_coeffs().T
31    assert_equal ( f(cvec(1024)), [0] * 9)
32    spec = cvec(1024)
33    spec[0][40:100] = 100
34    #print f(spec)
35
36if __name__ == '__main__':
37  from unittest import main
38  main()
39
Note: See TracBrowser for help on using the repository browser.