Classes (extension) | UGens > Analysis | UGens > Filters

Gammatone : UGen : AbstractFunction : Object
ExtensionExtension

Single gammatone filter

Description

A bandpass filter, as used in auditory modeling; approximates the frequency selectivity of a haircell site on the basilar membrane in the cochlea.

coded following: V Hohmann Frequency analysis and synthesis using a Gammatone filterbank Acta Acustica vol 88 (2002): 433--442

Class Methods

Gammatone.ar(input, centrefrequency: 440, bandwidth: 200, mul: 1, add: 0)

Arguments:

input

input sound to filter.

centrefrequency

Centre frequency. Default value is 440.0. Cannot be modulated.

bandwidth

Bandwidth of filter. Default value is 200.0. Cannot be modulated.

Inherited class methods

Instance Methods

Inherited instance methods

Examples

// what this example does
{ Gammatone.ar(WhiteNoise.ar) }.play;



//test sweeping frequency of sine input
{ Gammatone.ar(SinOsc.ar(MouseX.kr(100,2000)),1000.0,500.0) }.play;



//create gammatone filterbank with filters centred on 88 piano keys
(
var outereargain, freqs, bandwidths; 

freqs= Array.fill(88, {|i| (21+i).midicps});

//bandwidths in Hz not angular frequency for calculations in Hohmann
bandwidths= 24.7*(freqs*0.00437 +1);

//could reduce these bandwidths, ie 0.125*bandwidths, as test of resonance 

//calculated from ISO2002 100dB phon curve as approximation to sensitivity of outer ear
outereargain = [ 0.080993772688853, 0.089237063418603, 0.097970525722848, 0.10876266808815, 0.12105360022674, 0.13407538922284, 0.14787149408674, 0.16167718172822, 0.17551213214451, 0.19016975152285, 0.20569895830538, 0.22220242493157, 0.2397154127401, 0.2582697769952, 0.27792744116278, 0.29856170337058, 0.32031587344117, 0.34336361377938, 0.36778184407609, 0.39203618886184, 0.41615498938524, 0.44170796842, 0.46878040665827, 0.49446634124901, 0.52001934250193, 0.54709180427952, 0.57577407840633, 0.60165721569576, 0.62782392863276, 0.6555465952902, 0.68491773749099, 0.72411898089945, 0.77354432147194, 0.82590864573464, 0.88138671475204, 0.90157113760596, 0.90157113760596, 0.90157113760596, 0.90157113760596, 0.91510438365248, 0.93321426408541, 0.95240101404735, 0.97272866753273, 0.98926474289463, 1.0053814152966, 1.0224564349105, 1.0405467880267, 1.052760426677, 1.061847894439, 1.071475731154, 1.0816760688321, 1.0839269140212, 1.0839269140212, 1.0839269140212, 1.0839269140212, 1.0817917022137, 1.0789305551391, 1.0758992754061, 1.0726877464002, 1.0605734918597, 1.0429115831426, 1.0241994426808, 1.0043746204451, 0.95672713285027, 0.89882037142901, 0.83747029478932, 0.77247215275345, 0.75895909569467, 0.74934344623004, 0.73915602049396, 0.72836281890006, 0.75972195442662, 0.81665861045357, 0.87698089623035, 0.94089013177825, 1.022563004048, 1.1129841925092, 1.2087821046319, 1.3102764570426, 1.3485952672556, 1.3833144995125, 1.4200982447533, 1.4590692653081, 1.4180204618623, 1.3674299412878, 1.3138311518147, 1.2570452124657, 1.1677392221542 ];

//OK, make filterbank with 88 channels! mixed down for clarity...
{Mix(Gammatone.ar(WhiteNoise.ar,freqs, bandwidths)*outereargain)}.play;

//{Mix(Gammatone.ar(SoundIn.ar,freqs, bandwidths)*outereargain)}.play;


)



//20 channels with ERB scale spacing of centre frequencies. With each filter channel put through Meddis haircell models, may simulate what a cochlear implant 'sounds' like

(
var outereargain, freqs, bandwidths; 
var lowerbs, higherbs; 
var lowfreq, highfreq, numbands;
var prop, erbsnow; 

//create bank spaced equally in ERB scale units from lower frequency to higher
lowfreq = 100.0;
highfreq= 8000.0; //can increase this, maybe up to 16000.0?
numbands= 20; //try increasing this, nice around 50  

lowerbs = log10((lowfreq*0.00437 +1))*21.4; 
higherbs = log10((highfreq*0.00437 +1))*21.4; 

freqs= Array.fill(numbands,{arg i;   

    prop= i.asFloat/(numbands-1);
    
    erbsnow= lowerbs+((prop)*(higherbs-lowerbs)); 

    228.8455*(pow(10, 0.046728972*erbsnow)-1);

});

bandwidths= 24.7*(freqs*0.00437 +1);

//OK, make filterbank with 20 channels, passing each into Meddis model mixed down for clarity...

{Mix(Meddis.ar(Gammatone.ar(SoundIn.ar,freqs, bandwidths)))}.play;

)