A list,
Ii. Source code
clc;
clear;
fs=wavread('C:\Users\lenovo\Desktop\93317443speech-denoising\Ring01.wav');
y=fs(40000:120000);
N=length(y);
figure(1);
subplot(111);
plot(y);
ylabel(A ' 'amplitude);
title('Raw signal');
s=awgn(y,20.'measured'); % Add Gaussian white noise figure(2);
plot(s);
ylabel(A ' 'amplitude);
title('Add noise signal');
wname='db3'; % select DB3 wavelet base Lev =5; %5[c] l = wavedec layer decomposition (s, Lev, wname); a5=appcoef(c,l,wname,lev); d5=detcoef(c,l,5);
d4=detcoef(c,l,4);
d3=detcoef(c,l,3);
d2=detcoef(c,l,2);
d1=detcoef(c,l,1);
cD=[d1,d2,d3,d4,d5];
a=8500; b=13;
sigma=median(abs(cD))/3.647
thr1=(sigma*sqrt(2* (log10(N))))/(log10(2));
cD1=wthresh(d1,'s',thr1);
thr2=(sigma*sqrt(2* (log10(N))))/(log10(3));
cD2=wthresh(d2,'s',thr2);
thr3=(sigma*sqrt(2* (log10(N))))/(log10(4));
cD3=wthresh(d3,'s',thr3);
thr4=(sigma*sqrt(2* (log10(N))))/(log10(5));
cD4=wthresh(d4,'s',thr4);
thr5=(sigma*sqrt(2* (log10(N))))/(log10(6));
cD5=wthresh(d5,'s',thr5);
cd=[a5,cD5,cD4,cD3,cD2,cD1];
c=cd;
ys=waverec(c,l,wname);
figure(3);
plot(ys);
title('Soft threshold processing');
thr1=(sigma*sqrt(2* (log10(N))))/(log10(2));
cD1=wthresh(d1,'h',thr1);
thr2=(sigma*sqrt(2* (log10(N))))/(log10(3));
cD2=wthresh(d2,'h',thr2);
thr3=(sigma*sqrt(2* (log10(N))))/(log10(4));
cD3=wthresh(d3,'h',thr3);
thr4=(sigma*sqrt(2* (log10(N))))/(log10(5));
cD4=wthresh(d4,'h',thr4);
thr5=(sigma*sqrt(2* (log10(N))))/(log10(6));
cD5=wthresh(d5,'h',thr5);
cd=[a5,cD5,cD4,cD3,cD2,cD1];
c=cd;
yh=waverec(c,l,wname);
figure(4);
plot(yh);
title('Hard threshold handling');
thr1=(sigma*sqrt(2* (log10(length(d1)))))/(log10(1+1));
for i=1:length(d1)
if(abs(d1(i))>=thr1)
cD1(i)=sign(d1(i))*(abs(d1(i))-b*thr1/(a^(abs(abs(d1(i))-thr1))+b- 1)); % estimate the first layer wavelet coefficientselse
cD1(i)=0;
end
end
thr2=(sigma*sqrt(2* (log10(length(d2)))))/(log10(2+1));
for i=1:length(d2)
if(abs(d2(i))>=thr2)
cD2(i)=sign(d2(i))*(abs(d2(i))-b*thr2/(a^(abs(abs(d2(i))-thr2))+b- 1)); % estimate the second wavelet coefficientselse
cD2(i)=0;
end
end
thr3=(sigma*sqrt(2* (log10(length(d3)))))/(log10(3+1));
for i=1:length(d3)
if(abs(d3(i))>=thr3)
cD3(i)=sign(d3(i))*(abs(d3(i))-b*thr3/(a^(abs(abs(d3(i))-thr3))+b- 1)); % to estimate the third layer wavelet coefficientselse
cD3(i)=0;
end
end
thr4=(sigma*sqrt(2* (log10(length(d4)))))/(log10(4+1));
for i=1:length(d4)
if(abs(d4(i))>=thr4)
cD4(i)=sign(d4(i))*(abs(d4(i))-b*thr4/(a^(abs(abs(d4(i))-thr4))+b- 1)); % to estimate the fourth layer wavelet coefficientselse
cD4(i)=0;
end
end
thr5=(sigma*sqrt(2* (log10(length(d5)))))/(log10(5+1));
for i=1:length(d5)
if(abs(d5(i))>=thr5)
cD5(i)=sign(d5(i))*(abs(d5(i))-b*thr5/(a^(abs(abs(d5(i))-thr5))+b- 1)); % to estimate the fifth layer wavelet coefficientselse
cD5(i)=0; CD =[a5,cD5,cD4,cD3,cD2,cD1]; c=cd; yhs=waverec(cd,l,wname); figure(5);
plot(ys,'LineWidth'.1);
ylabel(A ' 'amplitude)
Copy the code
3. Operation results
Fourth, note
Version: 2014 a