function project_03_part01d()
close all;

[signal,fs,nbits] = wavread('eliot_peng.wav');

segment_length = .03*fs;                    %30 ms
window_size = 2^nextpow2(segment_length);   %# of points in Fourier transform should be power of 2
f = (fs/2)*linspace(0,1,window_size/2);

vowel1_start = 0.3*fs;                      %start of 'i' in El[i]ot
vowel1 = signal(vowel1_start - window_size/2:vowel1_start + window_size/2 - 1);
vowel1 = vowel1.*hamming(window_size);
subplot(311), plot(vowel1), grid on, axis tight;
title('vowel "i" in El[i]ot'), xlabel('time (samples)'), ylabel('amplitude');

magnitude_vowel1 = fft(vowel1);
magnitude_vowel1 = abs(magnitude_vowel1(1:window_size/2));
magnitude_vowel1 = 20*log10(magnitude_vowel1);
subplot(312), plot(f,magnitude_vowel1), grid on, axis tight;
xlabel('frequency (Hz)'), ylabel('magnitude (dB)');

phase_vowel1 = fft(vowel1);
phase_vowel1 = unwrap(angle(phase_vowel1(1:window_size/2)));
subplot(313), plot(f,phase_vowel1), grid on, axis tight;
xlabel('frequency (Hz)'), ylabel('phase (rad)');

%soundsc(vowel1,fs);
%print project_03_part01d_vowel1 -dpng -r100;

vowel2_start = 1.14*fs;                      %start of 'e' in P[e]ng
vowel2 = signal(vowel2_start - window_size/2:vowel2_start + window_size/2 - 1);
vowel2 = vowel2.*hamming(window_size);
figure;
subplot(311), plot(vowel2), grid on, axis tight;
title('vowel "e" in P[e]ng'), xlabel('time (samples)'), ylabel('amplitude');

magnitude_vowel2 = fft(vowel2);
magnitude_vowel2 = abs(magnitude_vowel2(1:window_size/2));
magnitude_vowel2 = 20*log10(magnitude_vowel2);
subplot(312), plot(f,magnitude_vowel2), grid on, axis tight;
xlabel('frequency (Hz)'), ylabel('magnitude (dB)');

phase_vowel2 = fft(vowel2);
phase_vowel2 = unwrap(angle(phase_vowel2(1:window_size/2)));
subplot(313), plot(f,phase_vowel2), grid on, axis tight;
xlabel('frequency (Hz)'), ylabel('phase (rad)');

%soundsc(vowel2,fs);
%print project_03_part01d_vowel2 -dpng -r100;