Package gmisclib :: Module erb_scale
[frames] | no frames]

Source Code for Module gmisclib.erb_scale

 1   
 2  """ERB Perceptual frequency scale.""" 
 3   
 4  import math 
 5  import Num 
 6   
 7  __version__ = "$Revision: 1.6 $" 
 8   
9 -def f_to_erb(f):
10 """Frequency to ERB band number. 11 http://ccrma-www.stanford.edu/~jos/bbt/Equivalent_Rectangular_Bandwidth.html 12 """ 13 return Num.log(0.00437*f+1)*(21.4/math.log(10.0))
14
15 -def erb_to_f(e):
16 """ERB number -> frequency 17 """ 18 return (10.0**(e/21.4)-1)/0.00437
19 20
21 -def ebw(e):
22 """Critical bandwidth (in Hz) at frequency e (erbs).""" 23 return 0.108*erb_to_f(e) + 24.7
24 25 26 if __name__ == "__main__": 27 print f_to_erb(51) 28 print f_to_erb(149) 29