使用matlab实现的低通理想滤波器2014a

时间:2014-12-04 15:33:30

标签: matlab signals filtering bandwidth

这里我必须发出声音信号 - 一个是男性语音信号,另一个是噪声信号 - 我将它们加在一起 ​​- 称之为信号"混合" - 现在我要求对其进行过滤,以便消除噪音,剩下的只是男性语音信号。 在分析了男性语音和噪声在时域和频域的图表

时域 1https://www.dropbox.com/s/m5frew6f0qlbae5/filteres%20signal.jpg?dl=0

enter image description here

频域

enter image description here

我发现男性语音的最大频率比最小噪声频率少一点,所以我做了一个低通滤波器 - 使用rect函数 - 并在频域中对其进行滤波。

理想的低通滤波器

enter image description here

我在频域和时域中绘制了结果信号,频域图与频域中的男性语音图相同,但在时域中它并不完全相同

过滤后的信号

enter image description here 当我发出结果信号时,我也发现了变化。 任何帮助请知道为什么过滤后的信号与原始的男性演讲不完全相同?

* P.S:我知道以这种方式过滤是不够的,但目前我们应该在我的课程报告中这样做。

这是我的代码:

[voice,Fs] = audioread ('hamid1.wav');
[noise,Fs] = audioread ('noise.wav');
voice(55126: 131072)=0 % to add both voice and noise signal together their dimensio must agree
mix = voice + noise; % the mixed signal

%vp = audioplayer(voice,Fs);
%play(vp);
%-- data for plotting voice --%
iFs = 1/Fs;
voiceLen = length(voice);
voiceF0 = 1/(iFs*voiceLen);
f_voice = 0:voiceF0: (voiceLen-1)*voiceF0;
t_voice = 0:iFs:(voiceLen-1)*iFs;
mag_voice = abs(fft(voice));

%-- data for plotting noise --%
noiseLen = length(noise);
noiseF0 = 1/(iFs*noiseLen);
f_noise = 0:noiseF0: (noiseLen-1)*noiseF0;
t_noise = 0:iFs:(noiseLen-1)/Fs;
mag_noise = abs(fft(noise));
%--------------------------------------------%

%-- data for plotting mix --%
mixLen = length(mix);
mixF0 = 1/(iFs*mixLen);
f_mix= 0:mixF0: (mixLen-1)*mixF0;
t_mix = 0:iFs:(mixLen-1)/Fs;
mag_mix = abs(fft(mix));

%-- plotting voice speech, noise and mix in frequency domain --%
figure(1);
subplot(3,1,1);
plot(f_voice,mag_voice);
title('voice speech in frequency domain');
xlabel('frequency'); ylabel('Magnitude');
subplot(3,1,2);
plot(f_noise,mag_noise);
title('noise in frequency domain');
xlabel('frequency'); ylabel('Magnitude');
subplot(3,1,3);
plot(f_mix,mag_mix);
title('mix signal in frequency domain');
xlabel('frequency'); ylabel('Magnitude')

%-- plotting voice speech, noise and mix in time domain --%
figure(2);
subplot(3,1,1);
plot(t_voice,voice);
title('voice speech in time domain');
xlabel('time'); ylabel('Amplitude');
subplot(3,1,2);
plot(t_noise,noise);
title('noise in time domain');
xlabel('time'); ylabel('Amplitude');
subplot(3,1,3);
plot(t_mix, mix);
title('mix signal in time domain');
xlabel('time'); ylabel('Amplitude')

%-- design the bandpass filter --
rect = 1*(f_mix>=0 & f_mix <3000);
rect2= rect+0*(f_mix>=3000 & f_mix <5482);
%-- plotting the ideal filter --%
figure(3)
plot(f_mix, rect2,'linewidth',2);
title('bandpass ideal filter');
xlabel('frequency'); ylabel('Magnitude')
axis([0 11000 0 1.5])

%-- Filtering the mix signal to extract voice speech without noise --%
filtered = rect2.*mag_mix'
filteredT = ifft(filtered)

figure(4)
subplot(2,1,1)
plot(f_mix, filtered)
title('Filtered signal in frequency domain')
xlabel('frequency')
ylabel('Magnitude')

subplot(2,1,2)
plot(t_mix, real(filteredT))
title('Filtered signal in time domain')
xlabel('time')
ylabel('Amplitude')
%-------------------------------------------%
filtSig = audioplayer(filteredT,Fs)
play(filtSig)

1 个答案:

答案 0 :(得分:2)

这是一个提示 - 是否可以实现理想的过滤器?什么是理想低通滤波器的逆傅里叶变换?我已经有一段时间看了这些东西,但我认为你没有收到错误。相反,你会看到过于严格的滤波器设计的影响。