File: examples-hears_approximate_gammatone.txt

package info (click to toggle)
brian 1.4.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, stretch
  • size: 23,436 kB
  • sloc: python: 68,707; cpp: 29,040; ansic: 5,182; sh: 111; makefile: 61
file content (47 lines) | stat: -rw-r--r-- 1,606 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
.. currentmodule:: brian

.. index::
   pair: example usage; figure
   pair: example usage; show
   pair: example usage; flipud
   pair: example usage; imshow
   pair: example usage; erbspace
   pair: example usage; whitenoise
   pair: example usage; ApproximateGammatone

.. _example-hears_approximate_gammatone:

Example: approximate_gammatone (hears)
======================================

Example of the use of the class :class:`~brian.hears.ApproximateGammatone`
available in the library. It implements a filterbank of approximate gammatone
filters as  described in Hohmann, V., 2002, "Frequency analysis and synthesis
using a Gammatone filterbank", Acta Acustica United with Acustica. 
In this example, a white noise is filtered by a gammatone filterbank and the
resulting cochleogram is plotted.

::

    from brian import *
    from brian.hears import *
    
    level=50*dB # level of the input sound in rms dB SPL
    sound = whitenoise(100*ms).ramp() # generation of a white noise
    sound = sound.atlevel(level) # set the sound to a certain dB level
    
    nbr_center_frequencies = 50  # number of frequency channels in the filterbank
    # center frequencies with a spacing following an ERB scale
    center_frequencies = erbspace(100*Hz, 1000*Hz, nbr_center_frequencies)
    # bandwidth of the filters (different in each channel) 
    bw = 10**(0.037+0.785*log10(center_frequencies))
    
    gammatone = ApproximateGammatone(sound, center_frequencies, bw, order=3) 
    
    gt_mon = gammatone.process()
    
    figure()
    imshow(flipud(gt_mon.T), aspect='auto')    
    show()