%
% file:      	guitar_pluck.m, (c) Matthew Roughan, Mon Jul 24 2006
%
file = 'My Song 2.wav';
[x, Fs, bits] = wavread(file);
dt = 1/Fs;

fprintf('file = %s\n', file);
fprintf(' sampled at %d bits at %d Hz\n', bits, Fs);
time = (1:length(x(:,1)))/Fs;

figure(2)
plot(time, x(:,1), 'linewidth', 3);
xlabel('time (seconds)');
set(gca, 'xlim', [0.22, 0.36]);
set(gca, 'linewidth', 3);
set(gca, 'fontsize', 18);
print('-depsc', 'Plots/guitar_A_110.eps');

%%%% choose a segment of the input data
temp = x(:,1);
temp = temp - mean(temp);

y = fft(temp);
K = length(temp);
freq = (1:K/2) / (K*dt);

figure(4)
hold off
semilogy(freq, abs(y(1:K/2)).^2, 'linewidth', 3);
hold on
set(gca, 'xlim', [0 500]);
set(gca, 'ylim', [1 10^10]);
set(gca, 'linewidth', 3);
xlabel('frequency (kHz)');
set(gca, 'fontsize', 18);

print('-depsc', 'Plots/guitar_A_110_fft.eps');
