Code covered by the BSD License  

Highlights from
Cepstrum Aliasing

image thumbnail

Cepstrum Aliasing

by

 

30 Jan 2014 (Updated )

Estimates the level of aliasing when finite size FFTs for the computation are used

[c1,cell_dif,ncount]=cepstral_aliasing_speech(xin,ss,win,fs,L,nffti,cepl)
function [c1,cell_dif,ncount]=cepstral_aliasing_speech(xin,ss,win,fs,L,nffti,cepl)
%
% compute cepstrum of a sequence using both analytical method and fft
% method; compute aliasing error as difference between analytical cepstrum
% and fft cepstrum with varying size of fft
%
% Inputs:
%   xin: speech array
%   ss: starting sample in speech file
%   win: window for creating short-time frame
%   fs: speech sampling rate
%   L: window duration in samples
%   nffti: initial value of fft size for aliasing computation (Note: nffti
%       must be greater than L, the speech frame size)
%   cepl: length of cepstrum that is computed and plotted
%
% Outputs:
%   c1: real cepstrum obtained using polynomial roots
%   cell_dif: cell array with difference between analytical cepstrum and
%   fft cepstrum
%   ncount: number of sizes of nfft used to compute aliasing terms

% create windowed frame of speech
    nfft=nffti;
    b=zeros(1,nfft);
    b(1:L)=xin(ss:ss+L-1).*win;
        
% solve for complex cepstrum based on numerator polynomial roots
    z=roots(b);
    [xhat1]=poly_roots_complex_cep(z,L,cepl,fs);
    
% form real cepstrum
    c1=(xhat1+fliplr(xhat1))/2;
    
% loop for nfft=nffti, 2*nffti, ...,8192
    while (nfft <= 8192)
        
% first wrap b so that the delay is approximately 0
        if (mod(L,2) == 1)
            bw=[b((L+1)/2:L) zeros(1,nfft-L) b(1:(L-1)/2)];
        else
            bw=[b(L/2+1:L) zeros(1,nfft-L) b(1:L/2)];
        end
    
% compute spectrum, phase, unwrapped phase, compute complex cepstrum using
% regular matlab code;
        BN=fft(bw,nfft);
        BNmag=log(abs(BN));
        chat3=ifft(BNmag,nfft);
        c3=[chat3(nfft-cepl+1:nfft) chat3(1:cepl+1)];
        
% zero out cepstral value at 0 quefrency for better plots
    c1(cepl+1)=0;
    c3(cepl+1)=0;
        
% determine the difference between root-based complex cepstrum and aliased
% FFT computation and store differences in cell array
        dif=c1-c3;
        cell_dif{log2(nfft)-log2(nffti)+1}=dif;
        nfft=nfft*2;
    end
    
% count number of alias plots
    ncount=log2(nfft)-log2(nffti);
end

Contact us