LPC_and_Polynomial.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* LPC_and_Polynomial.cpp
  2. *
  3. * Copyright (C) 1994-2018 David Weenink
  4. *
  5. * This code is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This code is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /*
  19. djmw 20020812 GPL header
  20. */
  21. #include "LPC_and_Polynomial.h"
  22. autoPolynomial LPC_Frame_to_Polynomial (LPC_Frame me) {
  23. integer degree = (integer) my nCoefficients;
  24. autoPolynomial thee = Polynomial_create (-1, 1, degree);
  25. for (integer i = 1; i <= degree; i ++) {
  26. thy coefficients [i] = my a [degree - i + 1];
  27. }
  28. thy coefficients[degree + 1] = 1.0;
  29. return thee;
  30. }
  31. autoPolynomial LPC_to_Polynomial (LPC me, double time) {
  32. try {
  33. integer iFrame = Sampled_xToIndex (me, time);
  34. if (iFrame < 1) {
  35. iFrame = 1;
  36. }
  37. if (iFrame > my nx) {
  38. iFrame = my nx;
  39. }
  40. autoPolynomial thee = LPC_Frame_to_Polynomial (& my d_frames [iFrame]);
  41. return thee;
  42. } catch (MelderError) {
  43. Melder_throw (me, U": no Polynomial created.");
  44. }
  45. }
  46. /* End of file LPC_and_Polynomial.cpp */