# v_lpcpf2ff

## PURPOSE

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

## SYNOPSIS

function [ff,fo]=v_lpcpf2ff(pf,np,fi)

## DESCRIPTION

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

      Inputs: pf(nf,n)     Power spectrum at n discrete frequencies, one frame per row
              np           Number of complex cepstral coefficients to use (excluding c0) [n-1]
                              should be greater than the sum of the numerator
                              and denominator filter orders but less than n
              fi(1,n)      Vector of frequencies [linspace(0,0.5,n)]
                             including this argument slows down the routine

     Outputs: ff(nf,n)     Complex spectrum (pf = abs(ff).^2
              fo(1,n)      Vector of frequencies

     This routine converts a power spectrum into the corresponding complex
     spectrum. It determines the phase spectrum under the assumption that it
     is minimum phase. The routine works by converting first to the compex
     cepstrum.

## CROSS-REFERENCE INFORMATION

This function calls:

- v_lpccc2ff V_LPCCC2FF Convert complex cepstrum to complex spectrum FF=(CC,NP,NC)
- v_lpcpf2cc V_LPCPF2CC Convert power spectrum to complex cepstrum CC=(PF,NP)

This function is called by:

## SOURCE CODE

    0001 function [ff,fo]=v_lpcpf2ff(pf,np,fi)
    0002 %V_LPCPF2FF Convert power spectrum to complex spectrum [FF,FO]=(PF,NP,FI)
    0003 %
    0004 %  Inputs: pf(nf,n)     Power spectrum at n discrete frequencies, one frame per row
    0005 %          np           Number of complex cepstral coefficients to use (excluding c0) [n-1]
    0006 %                          should be greater than the sum of the numerator
    0007 %                          and denominator filter orders but less than n
    0008 %          fi(1,n)      Vector of frequencies [linspace(0,0.5,n)]
    0009 %                         including this argument slows down the routine
    0010 %
    0011 % Outputs: ff(nf,n)     Complex spectrum (pf = abs(ff).^2
    0012 %          fo(1,n)      Vector of frequencies
    0013 %
    0014 % This routine converts a power spectrum into the corresponding complex
    0015 % spectrum. It determines the phase spectrum under the assumption that it
    0016 % is minimum phase. The routine works by converting first to the compex
    0017 % cepstrum.
    0018
    0019 %      Copyright (C) Mike Brookes 2014
    0020 %      Version: $Id: v_lpcpf2ff.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 Lesser General Public License as published by
    0028 %   the Free Software Foundation; either version 3 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 Lesser General Public License for more details.
    0035 %
    0036 %   You can obtain a copy of the GNU Lesser General Public License from
    0037 %   https://www.gnu.org/licenses/ .
    0038 %
    0039 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    0040 [nf,nq]=size(pf);
    0041 if nargin<3 fi=[];
    0042     if nargin<2
    0043         np=nq-1; % number of cepstal coefficients (excl c(0))
    0044     end
    0045 end
    0046 [cc,c0]=v_lpcpf2cc(pf,np,fi);
    0047 if ~numel(fi)
    0048     fi=nq-1;
    0049 end
    0050 [fx,fo]=v_lpccc2ff(cc,fi,-1,c0);
    0051 ff=sqrt(pf).*exp(1i*angle(fx));
    0052 if ~nargout
    0053     subplot(2,1,2);
    0054     plot(fo,unwrap(angle(ff.')));
    0055     xlabel('Normalized frequency f/f_s');
    0056     ylabel('Phase (rad)');
    0057     subplot(2,1,1);
    0058     plot(fo,db(abs(ff.')),'-b',fo,db(pf.')/2,':k');
    0059     xlabel('Normalized frequency f/f_s');
    0060     ylabel('Gain (dB)');
    0061 end
    0062
    0063