close all
clear all
clc
f1 = 1000;
f2 = 2500;
fs = 8000;
n = 0:511;
f = fs*n/512;
x1 = sin(2*pi*f1*n/fs); %信号x1频率为1000Hz
x2 = sin(2*pi*f2*n/fs); %信号x2频率为2500HZ
xadd = x1 + x2; %信号xadd为x1和x2的混频,用该信号代表语音信号
X1 = abs(fft(x1)); %分别对x1,x2,xadd做FFT变换
X2 = abs(fft(x2));
Xadd = abs(fft(xadd));
figure(1) %分别画出x1,x2,xadd的频域图
subplot(3,1,1)
plot(f,X1);
axis([0,4000,0,300])
title('原始信号频域图')
xlabel('X1')
subplot(3,1,2)
plot(f,X2);
axis([0,4000,0,300])
xlabel('X2')
subplot(3,1,3)
plot(f,Xadd);
axis([0,4000,0,300])
xlabel('X1+X2')
xlabel('Hz')
figure(2) %画滤波器
n=24; %采用25阶低通滤波器
window=hamming(50); %汉明窗(Hamming Window)函数
b=fir1(n,0.25)*100; %截止频率为1000Hz,增益40db,得出b的数据
freqz(b,1,8000); %传递函数的幅频响应和相频响应
figure(3)
y1 = filter(b,1,xadd); %对xadd信号进行滤波
subplot(3,1,1) %分别画出xadd滤波前、后的时域波形
plot(xadd);
axis([0,100,-3,3])
xlabel('滤波前时域波形')
subplot(3,1,2)
plot(y1)
axis([0,100,-100,100])
xlabel('滤波后时域波形')
subplot(3,1,3); %画出xadd滤波后的频域波形
plot(f,abs(fft(y1)));
axis([0,4000,0,10000])
xlabel('滤波后频域图')
xout = xadd/max(xadd); %生成dat文件,作为CCS仿真滤波器的输入信号
xto_ccs = round(32767*xout);
myfile = fopen('indata.dat','w');
fprintf(myfile,'1651 1 2d8 1 12c\n');
fprintf(myfile,'%d\n',xto_ccs);
fclose(myfile);
CCS.rar_VOICE filter VHDL_dsp语音滤波_语音_语音 vhdl_语音 滤波
版权申诉
168 浏览量
2022-09-24
02:13:37
上传
评论 1
收藏 326KB RAR 举报
刘良运
- 粉丝: 67
- 资源: 1万+