Home > voicebox > importsii.m

importsii

PURPOSE ^

IMPORTSII calculates the SII importance function per Hz or per Bark Q=(F,M)

SYNOPSIS ^

function q=importsii(f,m)

DESCRIPTION ^

IMPORTSII calculates the SII importance function per Hz or per Bark Q=(F,M)
 Inputs:
        f(n)   Frequencies to which to calculate importance in Hz
               or Bark according to 'b' flag.
        m      Mode string with some of the following flags:
                'b'  Frequencies given in Bark rather than Hz
                'c'  Calculate cumulative importance for f<f(i)
                'd'  Calculate importance of n-1 bands: band i is f(i) to f(i+1)
                'h'  Calculate importance per Hz or per Bark (accoring to 'b' flag)
 Outputs:
        q(n) or q(n-1) gives the importance at each of the f(i) or else,
               if the 'd' flag is specified, in the band from f(i) to f(i+1).

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function q=importsii(f,m)
0002 %IMPORTSII calculates the SII importance function per Hz or per Bark Q=(F,M)
0003 % Inputs:
0004 %        f(n)   Frequencies to which to calculate importance in Hz
0005 %               or Bark according to 'b' flag.
0006 %        m      Mode string with some of the following flags:
0007 %                'b'  Frequencies given in Bark rather than Hz
0008 %                'c'  Calculate cumulative importance for f<f(i)
0009 %                'd'  Calculate importance of n-1 bands: band i is f(i) to f(i+1)
0010 %                'h'  Calculate importance per Hz or per Bark (accoring to 'b' flag)
0011 % Outputs:
0012 %        q(n) or q(n-1) gives the importance at each of the f(i) or else,
0013 %               if the 'd' flag is specified, in the band from f(i) to f(i+1).
0014 
0015 % The importance function is based on the piecewise linear function
0016 % defined in Fig 3 of [2]. This is integrated to give the cumulative
0017 % importance function. It is modified slightly from Fig 3 so that the
0018 % constant portion extends from 4 to 18 Bark (critical bands 5 to 18).
0019 % we then fit a linear portion at either end to force the correct integral
0020 % and ensure continuity of the importance at 4 and 18.
0021 %
0022 % References:
0023 %  [1]  Methods for the calculation of the speech intelligibility index.
0024 %       ANSI Standard S3.5-1997 (R2007), American National Standards Institute, 1997.
0025 %  [2]  C. V. Pavlovic. Derivation of primary parameters and procedures for use in
0026 %       speech intelligibility predictions. J. Acoust Soc Amer, 82: 413–422, 1987.
0027 
0028 %       Copyright (C) Mike Brookes 2006
0029 %      Version: $Id: importsii.m 713 2011-10-16 14:45:43Z dmb $
0030 %
0031 %   VOICEBOX is a MATLAB toolbox for speech processing.
0032 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
0033 %
0034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0035 %   This program is free software; you can redistribute it and/or modify
0036 %   it under the terms of the GNU General Public License as published by
0037 %   the Free Software Foundation; either version 2 of the License, or
0038 %   (at your option) any later version.
0039 %
0040 %   This program is distributed in the hope that it will be useful,
0041 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0042 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0043 %   GNU General Public License for more details.
0044 %
0045 %   You can obtain a copy of the GNU General Public License from
0046 %   http://www.gnu.org/copyleft/gpl.html or by writing to
0047 %   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
0048 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0049 
0050 persistent mi ci ai bi xi0 xi1
0051 if isempty(mi)
0052     % cumulative importance function =  mi*b+c+ai*(b<4)*(b-4)^2-bi*(b>18)*(b-18)^2
0053     % for x in (xi0,xi1)
0054     ci4=0.0783;
0055     ci18=0.8861;
0056     mi=(ci18-ci4)/14;
0057     ci=ci4-4*mi;
0058     ai=mi^2/(4*(4*mi+ci));
0059     bi=mi^2/(4*(1-18*mi-ci));
0060     xi0=4-mi/(2*ai);
0061     xi1=18+mi/(2*bi);
0062 end
0063 if nargin<2
0064     m=' ';
0065 end
0066 if any(m=='b')
0067     b=f;
0068 else
0069     [b,d]=frq2bark(f);
0070 end
0071 if any(m=='c') || any(m=='d')
0072     q=mi*b+ci+ai*(b<4).*(b-4).^2-bi*(b>18).*(b-18).^2;
0073     q(b<xi0)=0;
0074     q(b>xi1)=1;
0075     if any(m=='d')
0076         q=q(2:end)-q(1:end-1);
0077     end
0078 else
0079     q=mi+ai*(b<4).*(b-4)-bi*(b>18).*(b-18);
0080     q(b<xi0)=0;
0081     q(b>xi1)=1;
0082     if ~any(m=='b')
0083         q=q.*d;
0084     end
0085 end
0086 if ~nargout
0087     if any(m=='d')
0088         ix=(1:2*length(q))/2;
0089         plot(f(1+floor(ix)),q(ceil(ix)));
0090     else
0091         plot(f,q);
0092     end
0093     if any(m=='b')
0094         xlabel('Frequency (Bark)');
0095     else
0096         xlabel('Frequency (Hz)');
0097     end
0098     ylabel('Importance');
0099     if any(m=='c')
0100         title('SII Cumulative Importance');
0101     elseif any(m=='d')
0102         title('SII Band Importance');
0103     else
0104         title('SII Importance Function');
0105     end
0106 end
0107

Generated on Thu 02-Feb-2012 09:15:04 by m2html © 2003