v_lpcar2fm

PURPOSE ^

V_LPCAR2RF Convert autoregressive coefficients to formant freq+amp+bw [N,F,A,B]=(AR,T)

SYNOPSIS ^

function [n,f,a,b]=v_lpcar2fm(ar,t)

DESCRIPTION ^

V_LPCAR2RF Convert autoregressive coefficients to formant freq+amp+bw [N,F,A,B]=(AR,T)

 Input:   ar(:,p+1)  Autoregressive coefficients
          t          Threshold (see below)
 Output:  n          Number of formants found
          f          Formant frequencies in normalized Hz (in increasing order)
          a          Formant amplitudes
          b          Formant bandwidths in normalized Hz

 The number of columns in the output arrays f, a and b is max(n); surplus positions
 in any given row have f=b=0.

 In determining formants, poles are ignored if any of the following hold:
        (a) they are on the real axis
        (b) they have bandwidth > t*frequency (if t>0)
        (c) they have bandwidth > -t (if t<=0)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [n,f,a,b]=v_lpcar2fm(ar,t)
0002 %V_LPCAR2RF Convert autoregressive coefficients to formant freq+amp+bw [N,F,A,B]=(AR,T)
0003 %
0004 % Input:   ar(:,p+1)  Autoregressive coefficients
0005 %          t          Threshold (see below)
0006 % Output:  n          Number of formants found
0007 %          f          Formant frequencies in normalized Hz (in increasing order)
0008 %          a          Formant amplitudes
0009 %          b          Formant bandwidths in normalized Hz
0010 %
0011 % The number of columns in the output arrays f, a and b is max(n); surplus positions
0012 % in any given row have f=b=0.
0013 %
0014 % In determining formants, poles are ignored if any of the following hold:
0015 %        (a) they are on the real axis
0016 %        (b) they have bandwidth > t*frequency (if t>0)
0017 %        (c) they have bandwidth > -t (if t<=0)
0018 
0019 %      Copyright (C) Mike Brookes 1997
0020 %      Version: $Id: v_lpcar2fm.m 10865 2018-09-21 17:22:45Z dmb $
0021 %
0022 %   VOICEBOX is a MATLAB toolbox for speech processing.
0023 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
0024 %
0025 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0026 %   This program is free software; you can redistribute it and/or modify
0027 %   it under the terms of the GNU General Public License as published by
0028 %   the Free Software Foundation; either version 2 of the License, or
0029 %   (at your option) any later version.
0030 %
0031 %   This program is distributed in the hope that it will be useful,
0032 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
0033 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0034 %   GNU General Public License for more details.
0035 %
0036 %   You can obtain a copy of the GNU General Public License from
0037 %   http://www.gnu.org/copyleft/gpl.html or by writing to
0038 %   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
0039 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0040 
0041 [nf,p1]=size(ar);
0042 p=p1-1;
0043 d=(1:nf)';
0044 zz=v_lpcar2zz(ar);
0045 ig=imag(zz)<=0;
0046 n=p1-1-sum(ig,2);
0047 mn=max(n);
0048 
0049 % remove redundant columns
0050 
0051 if mn<p
0052    [ig,ix]=sort(ig,2);
0053    zz=reshape(zz(d(:,ones(1,mn))+nf*(ix(:,1:mn)-1)),nf,mn);
0054    ig(:,mn+1:end)=[];
0055 end
0056 
0057 zz(ig)=1;      % to prevent infinities
0058 f=angle(zz)*0.5/pi;
0059 b=-log(abs(zz))/pi;
0060 if nargin > 1
0061    if t>0
0062       ig=ig | b>t*f;
0063    else
0064       ig=ig | b+t>0;
0065    end
0066 end
0067 f(ig)=0;
0068 b(ig)=0;
0069 n=mn-sum(ig,2);
0070 m=max(n);
0071 
0072 % remove redundant columns
0073 
0074 [igf,ix]=sort(ig+f,2);
0075 dd=d(:,ones(1,m))+nf*(ix(:,1:m)-1);
0076 zz=reshape(zz(dd),nf,m);
0077 f=reshape(f(dd),nf,m);
0078 b=reshape(b(dd),nf,m);
0079 ig=reshape(ig(dd),nf,m);
0080 
0081 % now calculate gain
0082 ap=permute(ar,[1 3 2]);
0083 pw=permute(-2*pi*1i*(0:p),[1 3 2]);
0084 a=abs(sum(ap(:,ones(1,m),:).*exp(pw(ones(1,nf),ones(1,m),:).*f(:,:,ones(1,p1))),3)).^(-1);

Generated by m2html © 2003