# v_lpcpf2cc

## PURPOSE

V_LPCPF2CC Convert power spectrum to complex cepstrum CC=(PF,NP)

## SYNOPSIS

function [cc,c0]=v_lpcpf2cc(pf,np,f)

## DESCRIPTION

    V_LPCPF2CC Convert power spectrum to complex cepstrum CC=(PF,NP)

      Inputs: pf(nf,n)    Power spectrum, uniformly spaced DC to Nyquist
              np          Number of cepstral coefficients to calculate [n-1]
              f(1,n)      Frequencies of pf columns [linspace(0,0.5,n)]

     Outputs: cc(nf,np)  Complex spectrum from DC to Nyquist
              c0(nf,1)   The zeroth cepstral coefficient, c(0)

     Note since the log spectrum is not normally bandlimited, this conversion is not exact unless n >> np

## CROSS-REFERENCE INFORMATION

This function calls:

- v_rsfft V_RSFFT fft of a real symmetric spectrum X=(Y,N)

This function is called by:

- v_lpcpf2ff V_LPCPF2FF Convert power spectrum to complex spectrum [FF,FO]=(PF,NP,FI)

## SOURCE CODE

    0001 function [cc,c0]=v_lpcpf2cc(pf,np,f)
    0002 %V_LPCPF2CC Convert power spectrum to complex cepstrum CC=(PF,NP)
    0003 %
    0004 %  Inputs: pf(nf,n)    Power spectrum, uniformly spaced DC to Nyquist
    0005 %          np          Number of cepstral coefficients to calculate [n-1]
    0006 %          f(1,n)      Frequencies of pf columns [linspace(0,0.5,n)]
    0007 %
    0008 % Outputs: cc(nf,np)  Complex spectrum from DC to Nyquist
    0009 %          c0(nf,1)   The zeroth cepstral coefficient, c(0)
    0010 %
    0011 % Note since the log spectrum is not normally bandlimited, this conversion is not exact unless n >> np
    0012
    0013 %      Copyright (C) Mike Brookes 1998-2014
    0014 %      Version: $Id: v_lpcpf2cc.m 10865 2018-09-21 17:22:45Z dmb $
    0015 %
    0016 %   VOICEBOX is a MATLAB toolbox for speech processing.
    0017 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
    0018 %
    0019 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0020 %   This program is free software; you can redistribute it and/or modify
    0021 %   it under the terms of the GNU Lesser General Public License as published by
    0022 %   the Free Software Foundation; either version 3 of the License, or
    0023 %   (at your option) any later version.
    0024 %
    0025 %   This program is distributed in the hope that it will be useful,
    0026 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
    0027 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    0028 %   GNU Lesser General Public License for more details.
    0029 %
    0030 %   You can obtain a copy of the GNU Lesser General Public License from
    0031 %   https://www.gnu.org/licenses/ .
    0032 %
    0033 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0034 [nf,nq]=size(pf);
    0035 if nargin<2 || ~numel(np) np=nq-1; end
    0036 if nargin<3 || ~numel(f)
    0037     cc=v_rsfft(log(pf.')).'/(2*nq-2);
    0038     c0=cc(:,1)*0.5;
    0039     cc(:,nq)=cc(:,nq)*0.5;
    0040     if np>nq-1
    0041         cc=[cc(:,2:nq) zeros(nf,np-nq+1)];
    0042     else
    0043         cc=cc(:,2:np+1);
    0044     end
    0045 else
    0046     cc=0.5*(log(pf)/cos(2*pi*f(:)*(0:min(np,nq-1))));
    0047     c0=cc(:,1);
    0048     cc=cc(:,2:end);
    0049     if np>nq-1
    0050         cc(1,np)=0;
    0051     end
    0052 end
    0053
    0054