function [lpa, a, p] = linearPredictionAnalysis(x, fs, N)

    % frame LP analysis
    % r1 = x(1:N-1)'*x(1:N-1);                              % frame x autocorrelation with zero shift,
                                            % i.e., energy content of frame x
                                            
    % r2 = x(1:N-1)'*x(2:N);                  % frame x autocorrelation with shift of one sample
    
    % mu = abs(r2/r1);                        % pre-emphasis factor (close to 1 for voiced;
                                            % close to zero for unvoiced)
    mu = 0.9;
                                            
                                            % NOTE: mu can also be used as simple threshold
                                            % for voice/unvoiced detection 

%     p = fs/1000 + round(mu*0.5*fs/1000);  % prediction order
    p = fs/1000 + round(mu*0.5*fs/1000);    % prediction order
    
    [a,e] = lpc(x,p);                       % LP analysis of (Hamming-weighted) frame x,
                                            % with prediction order p
                                            
    lpspectrum = freqz(sqrt(N*e), a, N);    % computation of frequency response of LP filter
    
    lpa = 20 * log10(abs(lpspectrum))';
    
%     plot(20*log10(abs(lpspectrum))),  axis tight, grid on  % plot of LP spectral envelope 
%     xlabel('frequency samples')
    
end