# v_lpccc2pf

## PURPOSE

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

## SYNOPSIS

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

## DESCRIPTION

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

      Inputs: cc(nf,n)     Complex ceptral coefficients excluding c(0), one frame per row
              np           Size of output spectrum is np+1 [n]
                           Alternatively, np can be a vector of output frequencies in the range 0 to 0.5
              nc           Highest cepstral coefficient to use [np or, if np is a vector, n]
                           Set nc=-1 to use n coefficients
              c0(nf,1)     Cepstral coefficient cc(0) [0]

     Outputs: pf(nf,np+1)  Power spectrum from DC to Nyquist
              f(1,np+1)    Normalized frequencies (0 to 0.5)

     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.
     For highest speed, choose np to be a power of 2.

## CROSS-REFERENCE INFORMATION

This function calls:

- v_lpccc2cc V_LPCCC2PF Extrapolate complex cepstrum C=(CC)
- v_rfft V_RFFT Calculate the DFT of real data Y=(X,N,D)

This function is called by:

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

## SOURCE CODE

    0001 function [pf,f]=v_lpccc2pf(cc,np,nc,c0)
    0002 %V_LPCCC2PF Convert complex cepstrum to power spectrum PF=(CC,NP,NC)
    0003 %
    0004 %  Inputs: cc(nf,n)     Complex ceptral coefficients excluding c(0), one frame per row
    0005 %          np           Size of output spectrum is np+1 [n]
    0006 %                       Alternatively, np can be a vector of output frequencies in the range 0 to 0.5
    0007 %          nc           Highest cepstral coefficient to use [np or, if np is a vector, n]
    0008 %                       Set nc=-1 to use n coefficients
    0009 %          c0(nf,1)     Cepstral coefficient cc(0) [0]
    0010 %
    0011 % Outputs: pf(nf,np+1)  Power spectrum from DC to Nyquist
    0012 %          f(1,np+1)    Normalized frequencies (0 to 0.5)
    0013 %
    0014 % The "complex cepstral coefficients", cc(n), are the inverse discrete-time Fourier transform
    0015 % of the log of the complex-valued spectrum. The cc(n) are real-valued and, for n<0, cc(n)=0.
    0016 % The "real cepstral coeffcients", rc(n), are the inverse discrete-time Fourier transform
    0017 % of the log of the magnitude spectrum; rc(0)=cc(0) and rc(n)=0.5*cc(n) for n~=0.
    0018 % For highest speed, choose np to be a power of 2.
    0019
    0020 %      Copyright (C) Mike Brookes 1998-2014
    0021 %      Version: $Id: v_lpccc2pf.m 10865 2018-09-21 17:22:45Z dmb $
    0022 %
    0023 %   VOICEBOX is a MATLAB toolbox for speech processing.
    0024 %   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
    0025 %
    0026 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0027 %   This program is free software; you can redistribute it and/or modify
    0028 %   it under the terms of the GNU Lesser General Public License as published by
    0029 %   the Free Software Foundation; either version 3 of the License, or
    0030 %   (at your option) any later version.
    0031 %
    0032 %   This program is distributed in the hope that it will be useful,
    0033 %   but WITHOUT ANY WARRANTY; without even the implied warranty of
    0034 %   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    0035 %   GNU Lesser General Public License for more details.
    0036 %
    0037 %   You can obtain a copy of the GNU Lesser General Public License from
    0038 %   https://www.gnu.org/licenses/ .
    0039 %
    0040 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0041 [nf,mc]=size(cc);
    0042 if nargin<2 || ~numel(np)
    0043     if nargout
    0044         np=mc;
    0045     else
    0046         np=128;
    0047     end
    0048 end
    0049 if nargin>=3 && numel(nc)==1 && nc==-1 nc=mc; end
    0050 if nargin<4 || ~numel(c0) c0=zeros(nf,1); end
    0051 if numel(np)>1 || np(1)<1
    0052     if nargin<3 || ~numel(nc) nc=mc; end
    0053     f=np(:)';
    0054     if nc==mc
    0055         pf=exp(2*[c0 cc]*cos(2*pi*(0:mc)'*f));
    0056     else
    0057         pf=exp(2*[c0 lpccc2cc(cc,nc)]*cos(2*pi*(0:nc)'*f));
    0058     end
    0059 else
    0060     if nargin<3 || ~numel(nc) nc=np; end
    0061     if nc==mc
    0062         pf=exp(2*real(v_rfft([c0 cc].',2*np).'));
    0063     else
    0064         pf=exp(2*real(v_rfft([c0 v_lpccc2cc(cc,nc)].',2*np).'));
    0065     end
    0066     f=linspace(0,0.5,np+1);
    0067 end
    0068 if ~nargout
    0069     plot(f,db(pf.')/2);
    0070     xlabel('Normalized frequency f/f_s');
    0071     ylabel('Gain (dB)');
    0072 end
    0073
    0074
    0075
    0076
    0077