[5080e1]: auditory / audtofreq.m Maximize Restore History

Download this file

audtofreq.m    57 lines (42 with data), 1.3 kB

 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
48
49
50
51
52
53
54
55
function freq = audtofreq(aud,varargin);
%AUDTOFREQ Converts auditory units to frequency (Hz)
% Usage: freq = audtofreq(aud);
%
% `audtofreq(aud,scale)` converts values on the selected auditory scale to
% frequencies measured in Hz.
%
% See the help on |freqtoaud|_ to get a list of the supported values of
% the *scale* parameter. If no scale is given, the erb-scale will be
% selected by default.
%
% See also: freqtoaud, audspace, audfiltbw
% AUTHOR: Peter L. Søndergaard
%% ------ Checking of input parameters ---------
if nargin<1
error('%s: Too few input parameters.',upper(mfilename));
end;
if ~isnumeric(aud)
error('%s: aud must be a number.',upper(mfilename));
end;
definput.import={'freqtoaud'};
[flags,kv]=ltfatarghelper({},definput,varargin);
%% ------ Computation --------------------------
if flags.do_mel
freq = 700*sign(aud).*(exp(abs(aud)*log(17/7)/1000)-1);
end;
if flags.do_mel1000
freq = 1000*sign(aud).*(exp(abs(aud)*log(2)/1000)-1);
end;
if flags.do_erb
freq = (1/0.00437)*sign(aud).*(exp(abs(aud)/9.2645)-1);
end;
if flags.do_bark
% This one was found through http://www.ling.su.se/STAFF/hartmut/bark.htm
freq = sign(aud).*1960./(26.81./(abs(aud)+0.53)-1);
end;
if flags.do_erb83
freq = 14363./(1-exp(aud-43.0)/11.7)-14675;
end;
if flags.do_freq
freq=aud;
end;