Rong Cheng's Blog
ronchen · 2005-12-08
<< DSP定标方法
Remember When >>
MATLAB下的音频AGC实现(原创)
2005-09-07,
by
Rong Cheng
已实现了MATLAB下的音频AGC,效果还可以,做起来才发觉比较简单,关键是要有高效的算法。如果能在实现AGC的同时做到噪音消除和回音消除,则效果更佳。
本人的MATLAB代码如下:
format long;
% [m d] = wavfinfo('in.wav');
[x,fs,nbits]=wavread('in.wav')
figure;
subplot(3,1,1);
plot(x); xlabel('number of sample'); title('Inputput signals');
%legend('Input signals');
[N col]=size(x);
Px=zeros(size(x));
Py=zeros(size(x));
y=zeros(size(x));
g=zeros(size(x));
a=0.2;
mu=0.5;
Pref=0.4;
%Pmin=0.000000001;
%Pmax=0.5;
g(1,1)=1;
y(1,1)=x(1,1);
Py(1,1)=(1-a)*x(1,1)*x(1,1);
Px(1,1)=(1-a)*x(1,1)*x(1,1);
for n=2:N
Px(n,1)=a*Px(n-1,1)+(1-a)*x(n,1)*x(n,1);
g(n,1)=g(n-1,1)*(1+mu*Px(n,1)*(Pref-Py(n-1,1)));
y(n,1)=g(n,1)*x(n,1);
if y(n,1)>2
y(n,1)=2;
end
if y(n,1)<-2
y(n,1)=-2;
end
Py(n,1)=g(n,1)*g(n,1)*Px(n,1);
end
subplot(3,1,2);
plot(y);xlabel('number of sample');
title('Output signals');
%legend('Output signals');
subplot(3,1,3);
plot(g);xlabel('number of sample');title('gain');legend('gain');
figure;plot(y,'r'); hold on;plot(x);
title('Output signals & Input signals ');xlabel('number of sample');
legend('Output signals','Input signals');
以下为处理的结果图:
发布于: 13:17:00 | 分类:
DSP_Algorithms
Matlab
|
引用(0)
|
编辑
2 条评论:
Rong Cheng
,
2005-12-08 22:48:51
你看一下LMS算法吧,其实算法很简单的,在google上搜一下,基本就是基于LMS的,介绍用LMS做 AGC 的英文文章很多的
fan
,
2005-12-08 17:39:39
兄弟,解释一下算法好吗
添加评论
原始快照:web.archive.org