Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. function [voiced,minAMDF] = bnrDisAMDF(frame,fs,lvlThr,fspan)<br>
  2. <br>
  3. persistent sLength<br>
  4. persistent fLength<br>
  5. persistent amdf<br>
  6.  
  7. % Length of the frame<br>
  8. flength = length(frame);<br>
  9.  
  10. % Pitch period is between 2.5 ms and 19.5 ms for LPC-10 algorithm<br>
  11. % This because this algorithm assumes the frequencyspan is 50 and 400 Hz
  12. pH = ceil((1/min(fspan))*fs);<br>
  13. if(pH > flength)<br>
  14. pH = flength;<br>
  15. end;<br>
  16. <br>
  17. pL = ceil((1/max(fspan))*fs);<br>
  18. if(pL <= 0 || pL >= flength)<br>
  19. pL = 0;<br>
  20. end;<br>
  21. <br>
  22. sLength = pH - pL;<br>
  23. <br>
  24. % Normalize the frame<br>
  25. frame = frame/max(max(abs(frame)));<br>
  26. <br>
  27. % Allocating memory for the calculation of the amdf<br>
  28. %amdf = zeros(1,sLength); %%%%%%%%<br>
  29. amdf = 0;<br>
  30. <br>
  31. % Calculating the AMDF with unbiased normalizing<br>
  32. for k = (pL+1):pH<br>
  33. amdf(k-pL) = sum(abs(frame(1:flength-k+1) - frame(k:flength)))/(flength-k+1);<br>
  34. end;<br>
  35. <br>
  36. % Output of the AMDF<br>
  37. if(min(amdf) < lvlThr)<br>
  38. voiced = 1;<br>
  39. else<br>
  40. voiced = 0;<br>
  41. end;<br>
  42. <br>
  43. % Output of the minimum of the amdf<br>
  44. minAMDF = min(amdf);<br>
  45.  
  46. waveFile='sunday.wav';
  47. [y, fs, nbits]=wavread(waveFile);
  48. index1=9000;
  49. frameSize=512;
  50. index2=index1+frameSize-1;
  51. frame=y(index1:index2);
  52. maxShift=length(frame);
  53. plotOpt=1;
  54. method=2;
  55. frame2amdf(frame, maxShift, method, plotOpt);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement