coefficient.m
上传用户:luvkyhj
上传日期:2013-06-25
资源大小:3k
文件大小:1k
- %clear all;%计算共振峰参数的仿真
- function [f2,f3,q2,q3]=coefficient(x)
- x=double(x);
- x=x/max(abs(x));
- x=filter([1 -0.9375],1,x);
- w=1/6+sin(pi*[1:12]./12);
- w=w/max(w);
- w=w*0.375;
- [x1,x2]=vad(x);
- y=enframe(x,160,80);
- x2=floor(x2);
- f=zeros(1,500);
- q=1;
- for m=x1:x2
- xs=y(m,:);
- a=lpc(xs,12);
- a=real(a(2:13));
- lpcc=lpc2lpcc(a);
- lpcc=lpcc'.*w;
- formant=fft(lpcc,64);
- for p=2:33
- if ((abs(formant(p-1))<abs(formant(p)))&&(abs(formant(p))>abs(formant(p+1))))
- f(q)=8000*(p-1)/64;
- q=q+1;
- else
- continue;
- end
- end
- end
- q2=1;
- q3=1;
- %f2=zeros(1,q);
- %f3=zeros(1,q);
- for q1=1:q
- if (800<f(q1))&&(f(q1)<1300)
- f2(q2)=f(q1);
- q2=q2+1;
- elseif (1300<f(q1))&&(f(q1)<2650)
- f3(q3)=f(q1);
- q3=q3+1;
- else
- continue;
- end
- end
- q2=length(f2);
- q3=length(f3);
- temp=f2(1);
- %去除毛刺
- for i=2:q2-1
- temp1=(temp+f2(i)+f2(i+1))/3;
- temp=f2(i);
- f2(i)=temp1;
- end
- temp=f3(1);
- for i=2:q3-1
- temp1=(temp+f3(i)+f3(i+1))/3;
- temp=f3(i);
- f3(i)=temp1;
- end
- %subplot(2,1,1),plot(f2),axis([1 q2 800 1300]),title('第二共振峰轨迹');
- %subplot(2,1,2),plot(f3),axis([1 q3 1300 2650]),title('第三共振峰轨迹');