V_LPCCC2FF Convert complex cepstrum to complex spectrum FF=(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, a vector of output frequencies in the range 0 to 0.5 nc Number of cepstral coefficients to use [np or, if np is a vector, n] Set nc=-1 to use n coefficients c0(nf,1) Cepstral coefficient c(0) [0] Outputs: ff(nf,np+2) Complex spectrum from DC to Nyquist f(1,np+2) 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+1 to be a power of 2.
0001 function [ff,f]=v_lpccc2ff(cc,np,nc,c0) 0002 %V_LPCCC2FF Convert complex cepstrum to complex spectrum FF=(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, a vector of output frequencies in the range 0 to 0.5 0007 % nc Number of cepstral coefficients to use [np or, if np is a vector, n] 0008 % Set nc=-1 to use n coefficients 0009 % c0(nf,1) Cepstral coefficient c(0) [0] 0010 % 0011 % Outputs: ff(nf,np+2) Complex spectrum from DC to Nyquist 0012 % f(1,np+2) 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+1 to be a power of 2. 0019 0020 % Copyright (C) Mike Brookes 2014 0021 % Version: $Id: v_lpccc2ff.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 General Public License as published by 0029 % the Free Software Foundation; either version 2 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 General Public License for more details. 0036 % 0037 % You can obtain a copy of the GNU General Public License from 0038 % http://www.gnu.org/copyleft/gpl.html or by writing to 0039 % Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. 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 ff=exp([c0 cc]*exp(-2i*pi*(0:mc)'*f)); 0056 else 0057 ff=exp([c0 lpccc2cc(cc,nc)]*exp(-2i*pi*(0:nc)'*f)); 0058 end 0059 else 0060 if nargin<3 || ~numel(nc) nc=np; end 0061 if nc==mc 0062 ff=exp(v_rfft([c0 cc].',2*np).'); 0063 else 0064 ff=exp(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 subplot(2,1,2); 0070 plot(f,unwrap(angle(ff.'))); 0071 xlabel('Normalized frequency f/f_s'); 0072 ylabel('Phase (rad)'); 0073 subplot(2,1,1); 0074 plot(f,db(abs(ff.'))); 0075 xlabel('Normalized frequency f/f_s'); 0076 ylabel('Gain (dB)'); 0077 end 0078