注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Mr.Right

不顾一切的去想,于是我们有了梦想。脚踏实地的去做,于是梦想成了现实。

 
 
 

日志

 
 
关于我

人生一年又一年,只要每年都有所积累,有所成长,都有那么一次自己认为满意的花开时刻就好。即使一时不顺,也要敞开胸怀。生命的荣枯并不是简单的重复,一时的得失不是成败的尺度。花开不是荣耀,而是一个美丽的结束,花谢也不是耻辱,而是一个低调的开始。

网易考拉推荐

matlab经典滤波器音频降噪demo  

2012-09-11 22:28:34|  分类: 学习 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
% NOISYC Adds noise to middle C.

fs = 1e4;
t = 0:1/fs:5;

sw = sin(2*pi*262.62*t); % Middle C
plot(t,sw)
axis([0 0.04 -1.1 1.1])
title('\fontsize{14}{Middle C}')
soundsc(sw,10000)
pause(5)

n = 0.1*randn(size(sw));
swn = sw + n;
figure
plot(t,swn)
axis([0 0.04 -1.1 1.1])
title('\fontsize{14}{Noisy Middle C}')
soundsc(swn,10000)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% PROTOBUTTER Designs an analog prototype of a Butterworth bandpass filter of order 10 with normalized cutoff frequencies Wp = [0.03 0.07].

% Lowpass analog prototype of order 5:
[z,p,k] = buttap(5);

% Frequency transformation:
[A,B,C,D] = zp2ss(z,p,k); 
u1 = 0.03*2*pi;  u2 = 0.07*2*pi;   
Bw = u2-u1; % Bandwidth
Wo = sqrt(u1*u2); % Center frequency
[At,Bt,Ct,Dt] = lp2bp(A,B,C,D,Wo,Bw);

% Plot the analog frequency response:
[b,a] = ss2tf(At,Bt,Ct,Dt);
w = linspace(0.01,1,500)*2*pi;
h = freqs(b,a,w);    
semilogy(w/2/pi,abs(h))
grid on    
xlabel('Normalized Frequency');
ylabel('Analog Response')

% BUTTERC filters the noisy middle C signal from NOISYC with the Butterworth filter built in PROTOBUTTER.
[bz2,az2] = bilinear(b,a,2);
close all


y = filter(bz2,az2,swn);
figure
plot(t,y)
axis([0 0.04 -1.1 1.1])
title('\fontsize{14}{Noisy C Filtered Using Butterworth Filter}')
soundsc(y,1e4)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CHEBYC filters the noisy middle C signal from NOISYC with the Chebyshev Type I filter built in CHEBYBAND.

% CHEBYBAND Designs a Chebtshev Type I bandpass filter with the following specifications:
%
% Order: lowest possible
% Sampling frequency: fs = 1e4 Hz
% Normalized passband cutoff frequencies: Wp = [150 350]/(fs/2) = [0.03 0.07]
% Normalized stopband cutoff frequencies: Ws = [100 400]/(fs/2) = [0.02 0.08]
% Passband ripple: Rp = 0.5 dB
% Stopband attenuation: Rs = 20 dB

Wp = [0.03 0.07];
Ws = [0.02 0.08];
Rp = 0.5;
Rs = 20;

% Compute lowest filter order meeting specifications:
[n,Wn] = cheb1ord(Wp,Ws,Rp,Rs);

% Compute the filter coefficients:
[bc,ac] = cheby1(n,Rp,Wn);

% View response:
fvtool(bc,ac)


y = filter(bc,ac,swn);
figure
plot(t,y)
axis([0 0.04 -1.1 1.1])
title('\fontsize{14}{Noisy C Filtered Using Chebyshev Type I Filter}')
soundsc(y,1e4)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% ELLIPBAND Designs an ellitic bandpass filter.
%
% Specifications:
% Order: lowest possible
% Sampling frequency: fs = 1e4 Hz
% Normalized passband cutoff frequencies: Wp = [150 350]/(fs/2) = [0.03 0.07]
% Normalized stopband cutoff frequencies: Ws = [100 400]/(fs/2) = [0.02 0.08]
% Passband ripple: Rp = 0.5 dB
% Stopband attenuation: Rs = 20 dB

Wp = [0.03 0.07];
Ws = [0.02 0.08];
Rp = 0.5;
Rs = 20;

% Compute lowest filter order meeting specifications:
[n,Wn] = ellipord(Wp,Ws,Rp,Rs);

% Compute the filter coefficients:
[be,ae] = ellip(n,Rp,Rs, Wn);

% View response:
fvtool(be,ae)

% ELLIPC Filters the noisy middle C signal from NOISYC with the elliptic filter built in ELLIPBAND.


y = filter(be,ae,swn);
figure
plot(t,y)
axis([0 0.04 -1.1 1.1])
title('\fontsize{14}{Noisy C Filtered Using Elliptic Filter}')
soundsc(y,1e4)
  评论这张
 
阅读(1286)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2016