% John Nolting
% 424
% creates impulse response from a test sweep and the cyclic part of a
% measured sweep, and plots a specgram

clear all;

[out fs] = wavread('test_sweep_2nd_half.wav');
[out2 fs2] = wavread('spring_2_rch_7_2nd_half.wav');

c = out(1:end);
c_len = length(c);

r = out2(1:end);
% r = out2(1048575:(1048575+1048574));

r_len = length(r);

ir = real(ifft(fft(r)./fft(c)));

% plot(ir)
win = 256;
overlap = 64;
fft_len = 512;

figure;
% % plot spectrogram sec
M = round(0.04*fs);  % 20 ms window is typical
N = 2^nextpow2(4*M); % zero padding for interpolation
w = kaiser(M,6);
ts = (0:length(ir)-1)/fs;
specgram(ir, 256, fs/1000, 224);
% sg = spectrogram_jos(ir,N,fs,w,-round(M/2),1,80); 
% axis([0 ts(end) 0 fs/2/1000])
colorbar
title('Spectrogram of Spring 2, 3 In/Out, 1 Spring Connected')

