source: python/demos/demo_filterbank.py @ 735a739

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

python/demos/demo_filterbank.py: added simple filterbank demo

  • Property mode set to 100755
File size: 787 bytes
Line 
1#! /usr/bin/python
2
3from aubio import filterbank, fvec
4from pylab import loglog, show, subplot, xlim, ylim, xlabel, ylabel, title
5from numpy import vstack, arange
6
7win_s = 2048
8samplerate = 48000
9
10freq_list = [60, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 24000]
11n_filters = len(freq_list) - 2
12
13f = filterbank(n_filters, win_s)
14freqs = fvec(freq_list)
15f.set_triangle_bands(freqs, samplerate)
16
17coeffs = f.get_coeffs()
18coeffs[4] *= 5.
19
20f.set_coeffs(coeffs)
21
22times = vstack([arange(win_s / 2 + 1) * samplerate / win_s] * n_filters)
23title('Bank of filters built using a simple list of boundaries\nThe middle band has been amplified by 2.')
24loglog(times.T, f.get_coeffs().T, '.-')
25xlim([50, samplerate/2])
26ylim([1.0e-6, 2.0e-2])
27xlabel('log frequency (Hz)')
28ylabel('log amplitude')
29
30show()
Note: See TracBrowser for help on using the repository browser.