语音信号的滤波处理matlab源码
%%%%%%%%%%% Read the sound file %%%%%%%%%%%
close all;
clear all;
[Y,Fs,NBITS] = wavread('dsp01_noise.wav');
%%%%%%%%%%% Play the sound %%%%%%%%%%%
sound(Y,Fs);
pause(4);
%%%%%%%%%%% Plot the noisy speech signal in time-domain
subplot(321);plot(Y(1:30000));
title('Time-domain plot of the input')
xlabel('Sample number')
%%%%%%%%%%% Plot the noisy speech signal in frequency-domain
XF = fft(Y,Fs);
f = 0:1:Fs-1;
subplot(322);plot(f(1:Fs/2),abs(XF(1:Fs/2)))
axis([0 3000 0 max(abs(XF))]);
title('Frequency components of the input')
xlabel('Frequency "Hz"')
%%%%%%%%%%% BP filter designed by fdatool
load BP_num;
Ybp = filter(Num,1,Y);
% sound(Ybp,Fs);
% pause(4);
%%%%%%%%%%% 1-D Median filter design
NM = 25;
Ynm = medfilt1(Ybp,NM);
sound(2*Ynm,Fs);
pause(4);
%%%%%%%%%%% Save the filtered sound file
wavwrite(Ynm,Fs,'FilteredSig.wav');
%%%%%%%%%%% Plot the filtered speech signal in time-domain
subplot(323);plot(Ynm(1:30000));
title('Time-domain plot of the filtered signal')
xlabel('Sample number')
%%%%%%%%%%% Plot the filtered speech signal in frequency-domain
XF = fft(Ynm,Fs);
f = 0:1:Fs-1;
subplot(324);plot(f(1:Fs/2),abs(XF(1:Fs/2)))
axis([0 3000 0 max(abs(XF))]);
title('Frequency components of the filtered signal')
xlabel('Frequency "Hz"')
%%%%%%%%%%% Load the filtered sound file
[x,Fs]=wavread('FilteredSig.wav');
%%%%%%%%%%% 4 stage Comb filter design
c1=0.6;
c2=0.4;
c3=0.2;
c4=0.1;
% Delay coefficients for the combfilter stage
R1=1000;
R2=1500;
R3=900;
R4=800;
% Combfilter 1
num1=[0,zeros(1,R1-1),1];
den1=[1,zeros(1,R1-1),-c1];
combfilt1=filter(num1,den1,x);
% Combfilter 2
num2=[0,zeros(1,R2-1),1];
den2=[1,zeros(1,R2-1),-c2];
combfilt2=filter(num2,den2,x);
% Combfilter 3
num3=[0,zeros(1,R3-1),1];
den3=[1,zeros(1,R3-1),-c3];
combfilt3=filter(num3,den3,x);
% Combfilter 4
num4=[0,zeros(1,R4-1),1];
den4=[1,zeros(1,R4-1),-c4];
combfilt4=filter(num4,den4,x);
combfilt=combfilt1+combfilt2+combfilt3+combfilt4;
%%%%%%%%%%% 2 stage All Pass filter design
% Determine the order of the All Pass Filters
R5=900;
R6=900;
AN1=0.7; % All Pass Numerator constant Stage 1
AN2=0.6; % All Pass Numerator constant Stage 2
level = 0.7;
AD1=450; % All Pass Denuminator constant Stage 1
AD2=390; % All Pass Denuminator constant Stage 2
% All Pass stage 1
APnum=[AN1,zeros(1,R5-1),1]; %All Pass Numerator
APden=[1,zeros(1,R5-1),AN1]; %All Pass Denumator
AllPass1 = filter(APnum,APden,combfilt);
num=[AN2,zeros(1,R6-1),1];
den=[1,zeros(1,R6-1),AN2];
% All Pass stage 2
AllPass2 = filter(num,den,AllPass1);
% Add the echoes into the original signal and scale down level of echo
REVERB = x + level * 3*AllPass2;
soundsc(REVERB,Fs);
%%%%%%%%%%% Plot the reverb signal in time-domain
subplot(325);plot(REVERB(1:30000));
xlabel('Time Variant'); ylabel('signal level');
title('Filtered Signal + REVERB');
%%%%%%%%%%% Plot the noisy speech signal in frequency-domain
XF = fft(REVERB,Fs);
f = 0:1:Fs-1;
subplot(326);plot(f(1:Fs/2),abs(XF(1:Fs/2)))
axis([0 3000 0 max(abs(XF))]);
title('Frequency components of the reverb')
xlabel('Frequency "Hz"')
相关文章
- Matlab:序列分析法MATLAB代码
- 【风险评估】分布式电源并网对电网的影响及风险评估的研究(Matlab代码实现)
- 【MATLAB】绘制轮廓图
- 【MATLAB】数学建模没有基础怎么办,看过来一篇文章带你入门 matlab
- matlab快速入门(9):对数组进行索引
- 基于Lucas-Kanade算法的三维光流提取matlab仿真
- matlab 动态规划逆序法及应用实例
- 【MATLAB】matlab 文档使用 ( 文档查询 | 文档层次 | 自带搜索工具 | 帮助命令 | 学习导引 )
- matlab入门 蜂窝阵列
- Matlab Newton‘s method
- matlab 基础语法
- MATLAB信号与系统分析(三)——连续信号与系统的复频域分析及MATLAB实现
- MATLAB学习笔记(五)——MATLAB绘图
- 非线性方程组数值求解算法——MATLAB源码
- matlab 男女声识别+源码
- [MATLAB]手把手带你用MATLAB跑经典算法YOLOv5&训练自己的数据集(包含源码)