Problem 1

Contents

Record Audio

r = audiorecorder(16000,16,1);
recordblocking(r,2)
recspeech = getaudiodata(r,'double');

%figure(1)
%plot(recspeech)
  

Parts a, b, and c

[speech Fs] = wavread('PatOKeefe');


t = 0:1/Fs:length(speech)/Fs-1/Fs;

figure(1)
subplot(311)
plot(t,speech)

narrow_N = round(.02*Fs);
narrow_OL = round(0.97*narrow_N);

wideband_N = round(narrow_N/4);
wideband_OL = round(0.9*wideband_N);

subplot(312)
spectrogram(speech,narrow_N,narrow_OL,0:100:8000,Fs,'yaxis');
title('Narrowband');

subplot(313)
spectrogram(speech,wideband_N,wideband_OL,0:100:8000,Fs,'yaxis');
title('Wideband');

Part d

length_30ms = round(.03*Fs);

% find appropriate sample start positions
vowelOneStartSample = round(0.29*Fs);
vowelTwoStartSample =round(1.14*Fs);

% isolate 30ms of interest for both vowels
wave1 = speech(vowelOneStartSample:vowelOneStartSample+length_30ms);
wave2 = speech(vowelTwoStartSample:vowelTwoStartSample+length_30ms);

waveOne = wave1*hamming(length(wave1))';
waveTwo = wave2*hamming(length(wave2))';

% find the transform of the two segments
WAVEONE = fft(waveOne,2^nextpow2(waveOne));
WAVETWO = fft(waveTwo,2^nextpow2(waveTwo));

W1_Mag = 20*log10(abs(WAVEONE));
W2_Mag = 20*log10(abs(WAVETWO));
W1_Phase = unwrap(angle(WAVEONE));
W2_Phase = unwrap(angle(WAVETWO));

figure(1)
subplot(311)
plot(linspace(vowelOneStartSample/Fs,vowelOneStartSample/Fs+.03,length(wave1)),wave1);
axis tight,grid on
title('Waveform for /@/'),xlabel('Time (sec)'),ylabel('Amplitude');

subplot(312)
plot(linspace(0,Fs/2,length(W1_Mag)/2),W1_Mag(1:length(W1_Mag)/2));
axis tight,grid on
title('Magnitude Spectrum'),xlabel('Frequency (Hz)'),ylabel('Magnitude (dB)');

subplot(313)
plot(linspace(0,Fs/2,length(W1_Phase)/2),W1_Phase(1:length(W1_Phase)/2))
axis tight,grid on
title('Phase Spectrum'),xlabel('Frequency (Hz)'),ylabel('Radius');


figure(2)
subplot(311)
plot(linspace(vowelTwoStartSample/Fs,vowelTwoStartSample/Fs+.03,length(wave2)),wave2);
axis tight,grid on
title('Waveform for /o/'),xlabel('Time (sec)'),ylabel('Amplitude');

subplot(312)
plot(linspace(0,Fs/2,length(W2_Mag)/2),W2_Mag(1:length(W2_Mag)/2));
axis tight,grid on
title('Magnitude Spectrum'),xlabel('Frequency (Hz)'),ylabel('Magnitude (dB)');

subplot(313)
plot(linspace(0,Fs/2,length(W2_Phase)/2),W2_Phase(1:length(W2_Phase)/2))
axis tight,grid on
title('Phase Spectrum'),xlabel('Frequency (Hz)'),ylabel('Radius');