资源描述:
《过零率(Zero Crossing Rate)是在每个音框中,音讯通过.doc》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、过零率(ZeroCrossingRate)是在每个音框中,音讯通过零点的次数,具有如下特性:1.一般而言,杂讯的过零大于气音的过零率,而气音的过零率又大于有声音的过零率2.通常在断点侦测,估测气音的起始位置和结束位置3.可用来预估信号的基频,但很容易出错,所以必须先进行前处理以下显示如何计算过零率范例1输入:closeallwaveFile='test.wav';frameSize=256;overlap=0;[y,fs,nbits]=wavread(waveFile);framedY=buffer(y,frameSize,overlap);zcr1=sum(framedY(1:end-
2、1,:).*framedY(2:end,:)<=0);zcr2=sum(abs(diff(framedY>0)));time=(1:length(y))/fs;frameNum=size(framedY,2);frameTime=((0:frameNum-1)*(frameSize-overlap)+0.5*frameSize)/fs;subplot(2,1,1);plot(time,y);title(waveFile);set(gca,'xlim',[0,length(y)/fs]);subplot(2,1,2);plot(frameTime,zcr1,'.-',frameTime,z
3、cr2,'.-');legend('zcr1','zcr2');set(gca,'xlim',[0,length(y)/fs]);title('过零率');输出图形:在下面这个范例中可以同时显示音量和过零率范例2输入%显示音量及过零率recordViaMic=0;%若要自行录音,将这个值改为1%获取音频数据ifrecordViaMic,%自行录音fs=16000;%取样频率duration=3;%录音时间waveFile='test.wav';%音频文件名称dataType='uint8';%解析度8bits/samplenbits=8;%录音fprintf('按任意键后开始%g秒录音:
4、',duration);pausefprintf('录音中...');y=wavrecord(duration*fs,dataType);fprintf('录音结束');else%读取音频文件waveFile='test.wav';[y,fs,nbits]=wavread(waveFile);y=uint8(y*(2^nbits)/2+2^nbits/2);%恢复到原先档案所记载的unit8整数值end%绘制音频的时域数据y=double(y);%转成double型文件y=y-mean(y);%零点校正sampleNum=length(y);time=(1:sampleNum)/fs
5、;figure;subplot(4,1,1);plot(time,y);ylabel('Amplitude');title(waveFile);axis([min(time),max(time),-2^nbits/2,2^nbits/2]);%音框设置frameSize=256;overlap=84;frameRate=fs/(frameSize-overlap);framedY=buffer(y,frameSize,overlap);frameNum=size(framedY,2);%计算音量intensity=10*log10(mean(framedY.^2));frameTime=
6、(1:frameNum)*(frameSize-overlap)/fs;subplot(4,1,2);plot(frameTime,intensity);ylabel('Volume(Decibel)');title('音量');set(gca,'xlim',[min(frameTime)max(frameTime)])%计算过零率zcr1=sum(abs(diff(framedY>0)));frameTime=(1:frameNum)*(frameSize-overlap)/fs;subplot(4,1,3);plot(frameTime,zcr1);ylabel('ZCR');tit
7、le('过零率');set(gca,'xlim',[min(frameTime)max(frameTime)])%计算过零率zcr2=sum(framedY(1:end-1,:).*framedY(2:end,:)<=0);frameTime=(1:frameNum)*(frameSize-overlap)/fs;subplot(4,1,4);plot(frameTime,zcr2);xlabel('Time(Seconds)');