PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
703B

  1. % Talkie library
  2. % Copyright 2011 Peter Knight
  3. % This code is released under GPLv2 license.
  4. %
  5. % Calculate LPC reflection coefficients
  6. function [k,g] = levinsonDurbin(r,poles)
  7. k(1)=1;
  8. a=zeros(1,poles+1);
  9. at=zeros(1,poles+1);
  10. e=r(1);
  11. for s=1:poles
  12. k(s+1)=-r(s+1);
  13. for t=1:s-1
  14. at(t+1) = a(t+1);
  15. k(s+1) = k(s+1) - a(t+1) * r(s-t+1);
  16. end
  17. if abs(e)<eps
  18. e=0;
  19. break
  20. end
  21. k(s+1) = k(s+1) / e;
  22. a(s+1) = k(s+1);
  23. for u = 1:s-1
  24. a(u+1) = at(u+1) + k(s+1) * at(s-u+1);
  25. end
  26. e = e * (1-k(s+1)*k(s+1));
  27. end
  28. if e<eps
  29. e=0;
  30. end
  31. g = sqrt(e);