标签:
clear
clc
close all
&&&&&&&&&&&&&&&&&
上面的几句话意思是清屏,清内存。
&&&&&&&&&&&&&&&&&
%[Original,fs,bits]=wavread(‘E:\Curriculum\The Fifth Term\数字信号处理\课程设计\DSP Voice Cuter\Love Story.wav‘);%修改文件路径可以滤除不同歌曲
[Original,fs,bits]=wavread(‘E:\matlab workspace\视觉机器学习20讲配套仿真代码Code\22 VoiceFilterB1\齐晨 - 咱们结婚吧.wav‘);%修改文件路径可以滤除不同歌曲
%size(Original)
&&&&&&&&&&&&&&&&&&&&&&&
y是自己随意定义的一个输出函数,fs 是采样频率 bits 表示每个样点的位数
[Y,FS,NBITS,OPTS]=wavread(...) returns a structure OPTS of additional
information contained in the WAV file. The content of this
structure differs from file to file. Typical structure fields
include ‘.fmt‘ (audio format information) and ‘.info‘ (text
which may describe title, author, etc.)
Output Scaling
The range of values in Y depends on the data format FMT specified.
Some examples of output scaling based on typical bit-widths found
in a WAV file are given below for both ‘double‘ and ‘native‘ formats.
FMT=‘native‘
#Bits MATLAB data type Data range
----- ------------------------- -------------------
8 uint8 (unsigned integer) 0 <= Y <= 255
16 int16 (signed integer) -32768 <= Y <= +32767
24 int32 (signed integer) -2^23 <= Y <= 2^23-1
32 single (floating point) -1.0 <= Y <= +1.0
FMT=‘double‘
#Bits MATLAB data type Data range
----- ------------------------- -------------------
N<32 double -1.0 <= Y < +1.0
N=32 double -1.0 <= Y <= +1.0
Note: Values in y might exceed -1.0 or +1.0 for the case of
N=32 bit data samples stored in the WAV file.
Supports multi-channel data, with up to 32 bits per sample.
Supports Microsoft PCM data format only.
&&&&&&&&&&&&&&&&&&&&&&&&&
ts=1/fs;
N=length(Original)-1;
t=0:1/fs:N/fs;
Nfft=N;
df=fs/Nfft;
fk=(-Nfft/2:Nfft/2-1)*df;
a1=1,a2=-1,b1=1,b2=-1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
SoundLeft=Original(:,1);
SoundRight=Original(:,2);
SoundLeft_f=ts*fftshift(fft(SoundLeft,N));
SoundRight_f=ts*fftshift(fft(SoundRight,N));
figure(1)
subplot(411)
plot(t,SoundLeft);
subplot(412)
plot(t,SoundRight);
subplot(413)
f_range=[-3000,3000,0,0.06];
plot(fk,SoundLeft_f);
axis(f_range);
subplot(414)
plot(fk,SoundRight_f);
axis(f_range);
% Sound=SoundLeft-SoundRight;
NewLeft=a1*SoundLeft+a2*SoundRight;
NewRight=b1*SoundLeft+b2*SoundRight;
Sound(:,1)=NewLeft;
Sound(:,2)=NewRight;
Sound_Left_f=ts*fftshift(fft(NewLeft,N));
Sound_Right_f=ts*fftshift(fft(NewRight,N));
figure(2)
subplot(411)
plot(t,NewLeft);
subplot(412)
plot(t,NewRight);
f_range=[-3000,3000,0,0.06];
subplot(413)
plot(fk,Sound_Left_f);
axis(f_range);
subplot(414)
plot(fk,Sound_Right_f);
axis(f_range);
BP=fir1(300,[500,2000]/(fs/2)); % 考虑300阶
CutDown=filter(BP,1,Sound); %Pass BPF
Sound_Final=Sound-0.6*abs(CutDown);
Sound_Final_f=ts*fftshift(fft(Sound_Final,N));
figure(3)
subplot(211)
plot(t,Sound_Final);
subplot(212)
f_range=[-3000,3000,0,0.06];
plot(fk,Sound_Final_f);
axis(f_range);
sound(Sound_Final,fs,bits);
标签:
原文地址:http://blog.csdn.net/zouyu409709312/article/details/51330909