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; 频分辩率 步长
%计算频率间隔(Hz/s)
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)); 可计算某些频率点上的频谱。
%%%http://wenku.baidu.com/link?url=_9ehkwkZXvfNExDAQvvIjQszVJYtYPv64xl9cBn2DN2m0nRWpjRVnhwJdkiA-zBb0MlzUCShSnOXtC7W6NnvbNwqyH7xzzGFL1yd0NQbGca
fftshift的作用正是让正半轴部分和负半轴部分的图像分别关于各自的中心对称。因为直接用fft得出的数据与频率不是对应的,fftshift可以纠正过来
fftshift是这针对频域信号的,将fft的