|
FREQTOAUD - Converts frequencies (Hz) to auditory scale units.
Program code:
function aud = freqtoaud(scale,freq);
% AUTHOR: Peter L. Soendergaard
% ------ Checking of input parameters ---------
error(nargchk(2,2,nargin));
if ~isnumeric(freq) || all(freq(:)<0)
error('%s: freq must be a non-negative number.',upper(mfilename));
end;
if ~ischar(scale)
error('%s: the scale must be denoted by a character string.',upper(mfilename))
end;
% ------ Computation --------------------------
switch(lower(scale))
case 'mel'
aud = 1127.01048*log(1+freq/700);
case 'erb'
aud = 9.265*log(1+freq/228.8455);
case 'bark'
% The bark scale seems to have several different approximations available.
% This one was found through http://www.ling.su.se/STAFF/hartmut/bark.htm
aud = (26.81./(1+1960./freq))-0.53;
% The one below was found on Wikipedia.
%aud = 13*atan(0.00076*freq)+3.5*atan((freq/7500).^2);
case 'erb83'
aud = 11.17*log((freq+312)./(freq+14675))+43.0;
otherwise
error(['%s: unknown auditory scale: %s. Please see the help for a list ' ...
'of supported scales.'],upper(mfilename),scale);
end;
|