lazy_auditory
Module¶
Peripheral auditory modeling module
Summary of module contents:
Name  Description 

erb  This is a StrategyDict instance object called erb .
Strategies stored: 2. 
gammatone  This is a StrategyDict instance object called
gammatone . Strategies stored: 3. 
gammatone_erb_constants  Constants for using the real bandwidth in the gammatone filter, given its order. Returns a pair \((x, y) = (1/a_n, c_n)\). 
phon2dB  This is a StrategyDict instance object called
phon2dB . Strategies stored: 1. 

gammatone_erb_constants
(n)[source]¶ Constants for using the real bandwidth in the gammatone filter, given its order. Returns a pair \((x, y) = (1/a_n, c_n)\).
Based on equations from:
Holdsworth, J.; Patterson, R.; NimmoSmith, I.; Rice, P. Implementing a GammaTone Filter Bank. In: SVOS Final Report, Annex C, Part A: The Auditory Filter Bank. 1988.
First returned value is a bandwidth compensation for direct use in the gammatone formula:
>>> x, y = gammatone_erb_constants(4) >>> central_frequency = 1000 >>> round(x, 3) 1.019 >>> bandwidth = x * erb["moore_glasberg_83"](central_frequency) >>> round(bandwidth, 2) 130.52
Second returned value helps us find the
3 dB
bandwidth as:>>> x, y = gammatone_erb_constants(4) >>> central_frequency = 1000 >>> bandwidth3dB = x * y * erb["moore_glasberg_83"](central_frequency) >>> round(bandwidth3dB, 2) 113.55
lazy_auditory.erb
StrategyDict¶
This is a StrategyDict instance object called
erb
. Strategies stored: 2.
Strategy erb.gm90 (Default).
Aliases available are erb.glasberg_moore_90
, erb.glasberg_moore
.
Docstring starts with:
Equivalent Rectangular Model (ERB) from Glasberg and Moore (1990).
Strategy erb.mg83.
An alias for it is erb.moore_glasberg_83
.
Docstring starts with:
Equivalent Rectangular Model (ERB) from Moore and Glasberg (1983).
Note
This docstring is selfgenerated, see the StrategyDict class and the strategies docs for more details.

gm90
(freq, Hz=None)¶ Equivalent Rectangular Model (ERB) from Glasberg and Moore (1990).
This is a model for a single filter bandwidth for auditory filter modeling, taken from:
B. R. Glasberg and B. C. J. Moore, "Derivation of auditory filter shapes from notchednoise data". Hearing Research, vol. 47, 1990, pp. 103108.
Parameters:  freq – Frequency, in rad/sample if second parameter is given, in Hz otherwise.
 Hz – Frequency conversion “Hz” from sHz function, i.e.,
sHz(rate)[1]
. If this value is not given, both input and output will be in Hz.
Returns: Frequency range size, in rad/sample if second parameter is given, in Hz otherwise.

mg83
(freq, Hz=None)¶ Equivalent Rectangular Model (ERB) from Moore and Glasberg (1983).
This is a model for a single filter bandwidth for auditory filter modeling, taken from:
B. C. J. Moore and B. R. Glasberg, "Suggested formulae for calculating auditory filter bandwidths and excitation patterns". J. Acoust. Soc. Am., 74, 1983, pp. 750753.
Parameters:  freq – Frequency, in rad/sample if second parameter is given, in Hz otherwise.
 Hz – Frequency conversion “Hz” from sHz function, i.e.,
sHz(rate)[1]
. If this value is not given, both input and output will be in Hz.
Returns: Frequency range size, in rad/sample if second parameter is given, in Hz otherwise.
lazy_auditory.gammatone
StrategyDict¶
This is a StrategyDict instance object called
gammatone
. Strategies stored: 3.
Strategy gammatone.klapuri. Docstring starts with:
Gammatone filter based on Anssi Klapuri’s IIR cascading filter model.
Strategy gammatone.sampled (Default). Docstring starts with:
Gammatone filter based on a sampled impulse response.
Strategy gammatone.slaney. Docstring starts with:
Gammatone filter based on Malcolm Slaney’s IIR cascading filter model.
Note
This docstring is selfgenerated, see the StrategyDict class and the strategies docs for more details.

sampled
(freq, bandwidth, phase=0, eta=4)¶ Gammatone filter based on a sampled impulse response.
Model is described in:
Bellini, D. J. S. "AudioLazy: Processamento digital de sinais expressivo e em tempo real", IMEUSP, Mastership Thesis, 2013.
This implementation have the impulse response (for each sample
n
, keeping the input parameter names):\[n^{eta  1} e^{ bandwidth \cdot n} \cos(freq \cdot n + phase)\]Parameters:  freq – Frequency, in rad/sample.
 bandwidth – Frequency range size, in rad/sample. See
gammatone_erb_constants
for more information about how you can find this.  phase – Phase, in radians. Defaults to zero (cosine).eta : Gammatone filter order. Defaults to 4.
Returns: A CascadeFilter object with ZFilter filters, each of them a poleconjugated IIR filter model. Gain is normalized to have peak with 0 dB (1.0 amplitude). The total number of poles is twice the value of eta (conjugated pairs), one pair for each ZFilter.

klapuri
(freq, bandwidth)¶ Gammatone filter based on Anssi Klapuri’s IIR cascading filter model.
Model is described in:
A. Klapuri, "Multipich Analysis of Polyphonic Music and Speech Signals Using an Auditory Model". IEEE Transactions on Audio, Speech and Language Processing, vol. 16, no. 2, 2008, pp. 255266.
Parameters:  freq – Frequency, in rad/sample.
 bandwidth – Frequency range size, in rad/sample. See
gammatone_erb_constants
for more information about how you can find this.
Returns: A CascadeFilter object with ZFilter filters, each of them a poleconjugated IIR filter model. Gain is normalized to have peak with 0 dB (1.0 amplitude). The total number of poles is twice the value of eta (conjugated pairs), one pair for each ZFilter.

slaney
(freq, bandwidth)¶ Gammatone filter based on Malcolm Slaney’s IIR cascading filter model.
Model is described in:
Slaney, M. "An Efficient Implementation of the PattersonHoldsworth Auditory Filter Bank", Apple Computer Technical Report #35, 1993.
Parameters:  freq – Frequency, in rad/sample.
 bandwidth – Frequency range size, in rad/sample. See
gammatone_erb_constants
for more information about how you can find this.
Returns: A CascadeFilter object with ZFilter filters, each of them a poleconjugated IIR filter model. Gain is normalized to have peak with 0 dB (1.0 amplitude). The total number of poles is twice the value of eta (conjugated pairs), one pair for each ZFilter.
lazy_auditory.phon2dB
StrategyDict¶
This is a StrategyDict instance object called
phon2dB
. Strategies stored: 1.
Strategy phon2dB.iso226 (Default).
Aliases available are phon2dB.iso226_2003
, phon2dB.iso_fdis_226_2003
.
Docstring starts with:
Loudness in phons to Sound Pressure Level (SPL) in dB using the ISO/FDIS 226:2003 model.
Note
This docstring is selfgenerated, see the StrategyDict class and the strategies docs for more details.

iso226
(loudness=None)¶ Loudness in phons to Sound Pressure Level (SPL) in dB using the ISO/FDIS 226:2003 model.
This function needs Scipy, as
scipy.interpolate.UnivariateSpline
objects are used as interpolators.Parameters: loudness – The loudness value in phons to be converted, or None (default) to get the threshold of hearing. Returns: A callable that returns the SPL dB value for each given frequency in hertz. Note
See
phon2dB.iso226.schema
andphon2dB.iso226.table
to know the original frequency used for the result. The result for any other value is an interpolation (spline). Don’t trust on values nor lower nor higher than the frequency limits there (20Hz and 12.5kHz) as they’re not part of ISO226 and no value was collected to estimate them (they’re just a spline interpolation to reach 1000dB at 30Hz and 32kHz). Likewise, the trustful loudness input range is from 20 to 90 phon, as written on ISO226, although other values aren’t found by a spline interpolation but by using the formula on section 4.1 of ISO226.Hint
The
phon2dB.iso226.table
also have other useful information, such as the threshold values in SPL dB.