


BARK2FRQ Convert the BARK frequency scale to Hertz FRQ=(BARK)
Inputs: b matrix of frequencies in Bark
m mode options
'h' use high frequency correction from [1]
'l' use low frequency correction from [1]
'H' do not apply any high frequency correction
'L' do not apply any low frequency correction
'u' unipolar version: do not force b to be an odd function
This has no effect on the default function which is odd anyway
's' use the expression from Schroeder et al. (1979)
'g' plot a graph
Outputs: f frequency values in Hz
c Critical bandwidth: d(freq)/d(bark)

0001 function [f,c] = bark2frq(b,m) 0002 %BARK2FRQ Convert the BARK frequency scale to Hertz FRQ=(BARK) 0003 % 0004 % Inputs: b matrix of frequencies in Bark 0005 % m mode options 0006 % 'h' use high frequency correction from [1] 0007 % 'l' use low frequency correction from [1] 0008 % 'H' do not apply any high frequency correction 0009 % 'L' do not apply any low frequency correction 0010 % 'u' unipolar version: do not force b to be an odd function 0011 % This has no effect on the default function which is odd anyway 0012 % 's' use the expression from Schroeder et al. (1979) 0013 % 'g' plot a graph 0014 % 0015 % Outputs: f frequency values in Hz 0016 % c Critical bandwidth: d(freq)/d(bark) 0017 0018 % The Bark scale is named in honour of Barkhausen, the creator 0019 % of the unit of loudness level [2]. Criitical band k extends 0020 % from bark2frq(k-1) to bark2frq(k). 0021 % 0022 % There are many published formulae approximating the Bark scale. 0023 % The default is the one from [1] but with a correction at high and 0024 % low frequencies to give a better fit to [2] with a continuous derivative 0025 % and ensure that 0 Hz = 0 Bark. 0026 % The h and l mode options apply the corrections from [1] which are 0027 % not as good and do not give a continuous derivative. The H and L 0028 % mode options suppress the correction entirely to give a simple formula. 0029 % The 's' option uses the less accurate formulae from [3] which have been 0030 % widely used in the lterature. 0031 % 0032 % [1] H. Traunmuller, Analytical Expressions for the 0033 % Tonotopic Sensory Scale”, J. Acoust. Soc. Am. 88, 0034 % 1990, pp. 97-100. 0035 % [2] E. Zwicker, Subdivision of the audible frequency range into 0036 % critical bands, J Accoust Soc Am 33, 1961, p248. 0037 % [3] M. R. Schroeder, B. S. Atal, and J. L. Hall. Optimizing digital 0038 % speech coders by exploiting masking properties of the human ear. 0039 % J. Acoust Soc Amer, 66 (6): 1647–1652, 1979. doi: 10.1121/1.383662. 0040 0041 % Copyright (C) Mike Brookes 2006-2010 0042 % Version: $Id: bark2frq.m 713 2011-10-16 14:45:43Z dmb $ 0043 % 0044 % VOICEBOX is a MATLAB toolbox for speech processing. 0045 % Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html 0046 % 0047 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0048 % This program is free software; you can redistribute it and/or modify 0049 % it under the terms of the GNU General Public License as published by 0050 % the Free Software Foundation; either version 2 of the License, or 0051 % (at your option) any later version. 0052 % 0053 % This program is distributed in the hope that it will be useful, 0054 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0055 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0056 % GNU General Public License for more details. 0057 % 0058 % You can obtain a copy of the GNU General Public License from 0059 % http://www.gnu.org/copyleft/gpl.html or by writing to 0060 % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 0061 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0062 persistent A B C E D P Q R S T U V W X Y Z 0063 if isempty(P) 0064 A=26.81; 0065 B=1960; 0066 C=-0.53; 0067 E = A+C; 0068 D=A*B; 0069 P=(0.53/(3.53)^2); 0070 V=3-0.5/P; 0071 W=V^2-9; 0072 Q=0.25; 0073 R=20.4; 0074 xy=2; 0075 S=0.5*Q/xy; 0076 T=R+0.5*xy; 0077 U=T-xy; 0078 X = T*(1+Q)-Q*R; 0079 Y = U-0.5/S; 0080 Z=Y^2-U^2; 0081 end 0082 if nargin<2 0083 m=' '; 0084 end 0085 if any(m=='u') 0086 a=b; 0087 else 0088 a=abs(b); 0089 end 0090 if any(m=='s') 0091 f=650*sinh(a/7); 0092 else 0093 if any(m=='l') 0094 m1=(a<2); 0095 a(m1)=(a(m1)-0.3)/0.85; 0096 elseif ~any(m=='L') 0097 m1=(a<3); 0098 a(m1)=V+sqrt(W+a(m1)/P); 0099 end 0100 if any(m=='h') 0101 m1=(a>20.1); 0102 a(m1)=(a(m1)+4.422)/1.22; 0103 elseif ~any(m=='H') 0104 m2=(a>X); 0105 m1=(a>U) & ~m2; 0106 a(m2)=(a(m2)+Q*R)/(1+Q); 0107 a(m1)=Y+sqrt(Z+a(m1)/S); 0108 end 0109 f=(D*(E-a).^(-1)-B); 0110 end 0111 if ~any(m=='u') 0112 f=f.*sign(b); % force to be odd 0113 end 0114 if nargout>1 0115 [bx,c] = frq2bark(f,m); 0116 end 0117 if ~nargout || any(m=='g') 0118 [bx,c] = frq2bark(f,m); 0119 subplot(212) 0120 semilogy(b,c,'-r'); 0121 ha=gca; 0122 xlabel('Bark'); 0123 ylabel(['Critical BW (' yticksi 'Hz)']); 0124 subplot(211) 0125 plot(b,f,'x-b'); 0126 hb=gca; 0127 xlabel('Bark'); 0128 ylabel(['Frequency (' yticksi 'Hz)']); 0129 linkaxes([ha hb],'x'); 0130 end