function [Y,A] = whiten(X,P)
% y = whiten(X,P)
%  Fit a P'th order LPC to the whole of X, and inverse-filter by
%  it.  Y is the whitened version.
%  A returns the actual whitening FIR coefficients.
% 2010-11-27 Dan Ellis dpwe@ee.columbia.edu

if nargin < 2;  P = 40; end

A = lpc(X,P);
Y = filter(A,1,X);
