Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [voiced,minAMDF] = bnrDisAMDF(frame,fs,lvlThr,fspan)<br>
- <br>
- persistent sLength<br>
- persistent fLength<br>
- persistent amdf<br>
- % Length of the frame<br>
- flength = length(frame);<br>
- % Pitch period is between 2.5 ms and 19.5 ms for LPC-10 algorithm<br>
- % This because this algorithm assumes the frequencyspan is 50 and 400 Hz
- pH = ceil((1/min(fspan))*fs);<br>
- if(pH > flength)<br>
- pH = flength;<br>
- end;<br>
- <br>
- pL = ceil((1/max(fspan))*fs);<br>
- if(pL <= 0 || pL >= flength)<br>
- pL = 0;<br>
- end;<br>
- <br>
- sLength = pH - pL;<br>
- <br>
- % Normalize the frame<br>
- frame = frame/max(max(abs(frame)));<br>
- <br>
- % Allocating memory for the calculation of the amdf<br>
- %amdf = zeros(1,sLength); %%%%%%%%<br>
- amdf = 0;<br>
- <br>
- % Calculating the AMDF with unbiased normalizing<br>
- for k = (pL+1):pH<br>
- amdf(k-pL) = sum(abs(frame(1:flength-k+1) - frame(k:flength)))/(flength-k+1);<br>
- end;<br>
- <br>
- % Output of the AMDF<br>
- if(min(amdf) < lvlThr)<br>
- voiced = 1;<br>
- else<br>
- voiced = 0;<br>
- end;<br>
- <br>
- % Output of the minimum of the amdf<br>
- minAMDF = min(amdf);<br>
- waveFile='sunday.wav';
- [y, fs, nbits]=wavread(waveFile);
- index1=9000;
- frameSize=512;
- index2=index1+frameSize-1;
- frame=y(index1:index2);
- maxShift=length(frame);
- plotOpt=1;
- method=2;
- frame2amdf(frame, maxShift, method, plotOpt);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement