function lowest_three
% This function resynthesizes 'mpgrl_sx419.wav' from three lowest
% frequency poles pairs.  The result is understandable, but odd.
%
%
% Christine Smit Feb-21-2007
%
[d,sr]=wavread('mpgr1_sx419.wav');
d = resample(d,1,2);
sr = sr/2;


[a,g,e] = lpcfit(d,8);

[col row] = size(a);

freqs3 = zeros(col,3);
mags3 = zeros(col,3);

for i=1:col
    poles = roots(a(i,:));
    freqs = angle(poles')*sr/2/pi;
    mags = g(i) ./ (1 - abs(poles'));
    
    indsPos = find(freqs > 0);
    freqsPos = freqs(indsPos);
    magsPos = mags(indsPos);
    
    [freqsSort indsSort] = sort(freqsPos);
    magsSort = magsPos(indsSort);
    
    len = length(freqsSort);
    if len < 3
        % put back in zero poles, I guess ...
        indsZero = find(freqs == 0);
        
        freqsZero = freqs(indsZero);
        magsZero = mags(indsZero);
        
        freqsSort = [freqsZero(1:3-len) freqsSort];
        magsSort = [magsZero(1:3-len) magsSort];
        disp('zero');
    end
    freqs3(i,:) = freqsSort(1:3);
    mags3(i,:) = magsSort(1:3);
end

sws = synthtrax(freqs3', mags3', sr, 128);
soundsc(sws);