%Katelyn Nye, EEN 502 - Fall 2007: Acoustics Project 3 %1. % Original Signal [x,Fs,bits] = wavread('Speech'); t=[0:.5/26623:.5]; figure(1) plot(t,x) title('Time Waveform of Speech') xlabel('Time (s)') ylabel('Amplitude') % Spectrogram plot of input signal obtained by Hann window & % converted to spectral representation via DFT. [x,Fs,bits] = wavread('Speech'); N=2048; HannWindow=hanning(N); figure(2) [s,F,t]=SPECTROGRAM(x,HannWindow,(N/2),N,Fs); SPECTROGRAM(x,HannWindow,(N/2),N,Fs) title('Spectrogram Plot of Speech') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 2. % 25 critical band Bark spectrogram FbandL = [0, 100, 200, 300, 400, 510, 630, 770, 920, 1080, 1270, 1480, 1720, 2000, 2320, 2700, 3150, 3700, 4400, 5300, 6400, 7700, 9500, 12000, 15500]; FbandL = transpose(FbandL); FbandC = [50, 150, 250, 350, 450, 570, 700, 840, 1000, 1170, 1370, 1600, 1850, 2150, 2500, 2900, 3400, 4000, 4800, 5800, 7000, 8500, 10500, 13500, 19500]; FbandC=transpose(FbandC); FbandR = [100, 200, 300, 400, 510, 630, 770, 920, 1080, 1270, 1480, 1720, 2000, 2320, 2700, 3150, 3700, 4400, 5300, 6400, 7700, 9500, 12000, 15500, 23500]; FbandR=transpose(FbandR); window=zeros(24,1); bark1=zeros(25,1); bark2=zeros(25,1); barkfreq1=zeros(1025,1); barkfreq2=zeros(1025,1); for j=1:24 window(j,:)=FbandR(j,:)-FbandL(j,:); end figure(3) [b,Fb,t]=SPECTROGRAM(x,HannWindow,(N/2),FbandC,Fs); b=real(b); %size: 25 by 13 SPECTROGRAM(x,HannWindow,(N/2),FbandC,Fs) title('Bark Spectrogram Plot of Speech') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 4. % Power Spectrum for i=1:13 P(:,i)=real(s(:,i)).^2+imag(s(:,i)).^2; end Pdb=10*log10(P); maxpow=0; for i=1:1025 for j=1:13 maximum=Pdb(i,j); if maximum>maxpow maxpow=maximum; f1=i; t1=j; end end end onefourthmaxpow=10; for i=1:1025 for j=1:13 if Pdb(i,j)>0 && Pdb(i,j)FbandL(j) && F(i)FbandL(j) && F(i)FbandL(j) && F(i)FbandL(j) && F(i)FbandL(j) && F(i)FbandL(j) && F(i)FbandL(j) && F(i)FbandL(j) && F(i)FbandL(j) && F(i)FbandL(j) && F(i)FbandL(j) && F(i)FbandL(j) && F(i)barkoffset_thres(i) abs_max1(i) = Ti_1(i); else abs_max1(i) = barkoffset_thres(i); end end abs_max1=abs_max1-20; figure(8) hold on plot(F,abs_max1,'m') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Final Threshold of 1/4th Signal Power for i=1:1025 if Ti_2(i)>barkoffset_thres(i) abs_max2(i) = Ti_2(i); else abs_max2(i) = barkoffset_thres(i); end end abs_max2=abs_max2-20; figure(9) hold on plot(F,abs_max2,'m') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Remaining Power Spectrum of Maximum Signal Power g1=0; for i=1:1025 if Pdb(i,t1)>=abs_max1(i) absolute1(i)=Pdb(i,t1); remaining1(i)=Pdb(i,t1); g1=g1+1; else absolute1(i)=nan; remaining1(i)=Pdb(i,t1)-300; end end percent_remain1=(g1/1025)*100 figure(8) hold on plot(F,absolute1,'c') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Remaining Power Spectrum of 1/4th Signal Power g2=0; for i=1:1025 if Pdb(i,t2)>=abs_max2(i) absolute2(i)=Pdb(i,t2); g2=g2+1; else absolute2(i)=nan; end end percent_remain2=(g2/1025)*100 figure(9) hold on plot(F,absolute2,'c') %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Spectrogram of Remaining Power Spectrum of Maximum Signal Power absolute1_ifft=ifft(remaining1,N); WAVWRITE(absolute1_ifft,Fs,16,'SpeechCompressed') [Q,Fs,bits] = wavread('SpeechCompressed'); t=[0:.5/2047:.5]; figure(10) plot(t,Q) title('Time Waveform of Compressed Speech') xlabel('Time (s)') ylabel('Amplitude') figure(11) SPECTROGRAM(Q) title('Spectrogram Plot of Remaining Power Spectrum of Signal Speech') %%%%%%%%%%%%% %Speech: percent_remain1 = 8.9756, percent_remain2 = 25.8537 %Classical : percent_remain1 = 17.8537, percent_remain2 = 12.3902 %Rock: percent_remain1 = 61.3659, percent_remain2 = 58.3415