source: python/demos/demo_filterbank.py @ 1eb8c0e

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5sampler
Last change on this file since 1eb8c0e was 4120fbc, checked in by Paul Brossier <piem@piem.org>, 9 years ago

python/demos: python3 and double precision compatibility

  • Property mode set to 100755
File size: 783 bytes
Line 
1#! /usr/bin/env python
2
3from aubio import filterbank, fvec
4from pylab import loglog, show, 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.