~ubuntu-branches/ubuntu/precise/brian/precise

« back to all changes in this revision

Viewing changes to docs_sphinx/examples-hears_approximate_gammatone.txt

  • Committer: Bazaar Package Importer
  • Author(s): Yaroslav Halchenko
  • Date: 2011-02-08 19:28:34 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110208192834-uexkhylennhz4qzp
Tags: 1.2.2~svn2469-1
* Upstream pre-release snapshot
* debian/copyright - fixed Maintainer and Source entries
* debian/rules:
  - set both HOME and MPLCONFIGDIR to point to build/.
    Should resolve issues of building when $HOME is read-only
    (Closes: #612548)
  - assure Agg matplotlib backend to avoid possible complications
    during off-screen operations
  - un-disabled hears unittests (model-fitting remains disabled due
    to absent dependency -- playdoh)
* debian/control:
  - graphviz (for graphs rendering) and texlive-latex-base,
    texlive-latex-extra (for equations rendering) into build-depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.. currentmodule:: brian
 
2
 
 
3
.. index::
 
4
   pair: example usage; erbspace
 
5
   pair: example usage; whitenoise
 
6
   pair: example usage; ApproximateGammatone
 
7
 
 
8
.. _example-hears_approximate_gammatone:
 
9
 
 
10
Example: approximate_gammatone (hears)
 
11
======================================
 
12
 
 
13
Example of the use of the class :class:`~brian.hears.ApproximateGammatone`
 
14
available in the library. It implements a filterbank of approximate gammatone
 
15
filters as  described in Hohmann, V., 2002, "Frequency analysis and synthesis
 
16
using a Gammatone filterbank", Acta Acustica United with Acustica. 
 
17
In this example, a white noise is filtered by a gammatone filterbank and the
 
18
resulting cochleogram is plotted.
 
19
 
 
20
::
 
21
 
 
22
    from brian import *
 
23
    from brian.hears import *
 
24
    
 
25
    level=50*dB # level of the input sound in rms dB SPL
 
26
    sound = whitenoise(100*ms).ramp() # generation of a white noise
 
27
    sound = sound.atlevel(level) # set the sound to a certain dB level
 
28
    
 
29
    nbr_center_frequencies = 50  # number of frequency channels in the filterbank
 
30
    # center frequencies with a spacing following an ERB scale
 
31
    center_frequencies = erbspace(100*Hz, 1000*Hz, nbr_center_frequencies)
 
32
    # bandwidth of the filters (different in each channel) 
 
33
    bw = 10**(0.037+0.785*log10(center_frequencies))
 
34
    
 
35
    gammatone = ApproximateGammatone(sound, center_frequencies, bw, order=3) 
 
36
    
 
37
    gt_mon = gammatone.process()
 
38
    
 
39
    figure()
 
40
    imshow(flipud(gt_mon.T), aspect='auto')    
 
41
    show()
 
42
    
 
43