# v_lpcar2cc

## PURPOSE

V_LPCAR2CC LPC: Convert AR filter to complex cepstrum [CC,C0]=(AR,NP)

## SYNOPSIS

function [cc,c0]=v_lpcar2cc(ar,np)

## DESCRIPTION

    V_LPCAR2CC LPC: Convert AR filter to complex cepstrum [CC,C0]=(AR,NP)

      Inputs: ar(nf,n+1)   AR coefficients, one frame per row
              np           Number of cepstral coefficients to calculate [n]

     Outputs: cc(nf,np)    Complex cepstral coefficients, excluding c(0)
              c0(nf,1)     Coefficient c(0)

     The "complex cepstral coefficients", cc(n), are the inverse discrete-time Fourier transform
     of the log of the complex-valued spectrum. The cc(n) are real-valued and, for n<0, cc(n)=0.
     The "real cepstral coeffcients", rc(n), are the inverse discrete-time Fourier transform
     of the log of the magnitude spectrum; rc(0)=cc(0) and rc(n)=0.5*cc(n) for n~=0.

## CROSS-REFERENCE INFORMATION

This function calls:

- v_lpccc2pf V_LPCCC2PF Convert complex cepstrum to power spectrum PF=(CC,NP,NC)

This function is called by:

- v_lpccc2cc V_LPCCC2PF Extrapolate complex cepstrum C=(CC)

## SOURCE CODE

    0001 function [cc,c0]=v_lpcar2cc(ar,np)
    0002 %V_LPCAR2CC LPC: Convert AR filter to complex cepstrum [CC,C0]=(AR,NP)
    0003 %
    0004 %  Inputs: ar(nf,n+1)   AR coefficients, one frame per row
    0005 %          np           Number of cepstral coefficients to calculate [n]
    0006 %
    0007 % Outputs: cc(nf,np)    Complex cepstral coefficients, excluding c(0)
    0008 %          c0(nf,1)     Coefficient c(0)
    0009 %
    0010 % The "complex cepstral coefficients", cc(n), are the inverse discrete-time Fourier transform
    0011 % of the log of the complex-valued spectrum. The cc(n) are real-valued and, for n<0, cc(n)=0.
    0012 % The "real cepstral coeffcients", rc(n), are the inverse discrete-time Fourier transform
    0013 % of the log of the magnitude spectrum; rc(0)=cc(0) and rc(n)=0.5*cc(n) for n~=0.
    0014
    0015 %      Copyright (C) Mike Brookes 1998-2014
    0016 %      Version: $Id: v_lpcar2cc.m 10865 2018-09-21 17:22:45Z dmb $
    0017 %
    0018 %   VOICEBOX is a MATLAB toolbox for speech processing.
    0019 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
    0020 %
    0021 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0022 %   This program is free software; you can redistribute it and/or modify
    0023 %   it under the terms of the GNU Lesser General Public License as published by
    0024 %   the Free Software Foundation; either version 3 of the License, or
    0025 %   (at your option) any later version.
    0026 %
    0027 %   This program is distributed in the hope that it will be useful,
    0028 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
    0029 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    0030 %   GNU Lesser General Public License for more details.
    0031 %
    0032 %   You can obtain a copy of the GNU Lesser General Public License from
    0033 %   https://www.gnu.org/licenses/ .
    0034 %
    0035 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0036
    0037 [nf,p1]=size(ar);
    0038 p=p1-1;
    0039 if (nargin<2) np=p; end
    0040 cc=zeros(nf,np);
    0041 if any(ar(:,1)~=1)
    0042     c0=-log(ar(:,1));
    0043     ar=ar./ar(:,ones(1,p1));
    0044 else
    0045     c0=zeros(nf,1);
    0046 end
    0047 cm=(1:np).^(-1);
    0048 if np>p
    0049     xm=-(1:p);
    0050     nz=np-p;
    0051     for k=1:nf
    0052         cc(k,:)=filter(1,ar(k,:),[ar(k,2:p1).*xm zeros(1,nz)]).*cm;
    0053     end
    0054 else
    0055     p1=np+1;
    0056     xm=-(1:np);
    0057     for k=1:nf
    0058         cc(k,:)=filter(1,ar(k,:),ar(k,2:p1).*xm).*cm;
    0059     end
    0060 end
    0061 if ~nargout
    0062     v_lpccc2pf(cc,[],[],c0);
    0063 end