Sound_and_LPC.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #ifndef _Sound_and_LPC_h_
  2. #define _Sound_and_LPC_h_
  3. /* Sound_and_LPC.h
  4. *
  5. * Copyright (C) 1994-2011, 2015-2016 David Weenink
  6. *
  7. * This code is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * This code is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. /*
  21. djmw 19971103
  22. djmw 20020812 GPL header
  23. djmw 20110307 Latest modification
  24. */
  25. #include "LPC.h"
  26. #include "Sound.h"
  27. autoLPC Sound_to_LPC_auto (Sound me, int predictionOrder, double analysisWidth, double dt, double preEmphasisFrequency);
  28. autoLPC Sound_to_LPC_covar (Sound me, int predictionOrder, double analysisWidth, double dt, double preEmphasisFrequency);
  29. autoLPC Sound_to_LPC_burg (Sound me, int predictionOrder, double analysisWidth, double dt, double preEmphasisFrequency);
  30. autoLPC Sound_to_LPC_marple (Sound me, int predictionOrder, double analysisWidth, double dt, double preEmphasisFrequency, double tol1, double tol2);
  31. /*
  32. * Function:
  33. * Calculate linear prediction coefficients according to following model:
  34. * Minimize E(m) = Sum(n=n0;n=n1; (x[n] + Sum(k=1;k=m; a[k]*x[n-k])))
  35. * Method:
  36. * The minimization is carried out by solving the equations:
  37. * Sum(i=1;i=m; a[i]*c[i][k]) = -c[0][k] for k=1,2,...,m
  38. * where c[i][k] = Sum(n=n0;n=n1;x[n-i]*x[n-k])
  39. * 1. Covariance:
  40. * n0=m; n1 = N-1;
  41. * c[i][k] is symmetric, positive semi-definite matrix
  42. * Markel&Gray, LP of Speech, page 221;
  43. * 2. Autocorrelation
  44. * signal is zero outside the interval;
  45. * n0=-infinity; n1=infinity
  46. * c[i][k] symmetric, positive definite Toeplitz matrix
  47. * Markel&Gray, LP of Speech, page 219;
  48. * Preconditions:
  49. * predictionOrder > 0;
  50. * preEmphasisFrequency >= 0;
  51. *
  52. * Burg method: see Numerical recipes Chapter 13.
  53. *
  54. * Marple method: see Marple, L. (1980), A new autoregressive spectrum analysis
  55. * algorithm, IEEE Trans. on ASSP 28, 441-453.
  56. * tol1 : stop iteration when E(m) / E(0) < tol1
  57. * tol2 : stop iteration when (E(m)-E(m-1)) / E(m-1) < tol2,
  58. */
  59. void LPC_Frame_Sound_filterInverse (LPC_Frame me, Sound thee, integer channel);
  60. autoSound LPC_Sound_filter (LPC me, Sound thee, bool useGain);
  61. /*
  62. E(z) = X(z)A(z),
  63. A(z) = 1 + Sum (k=1, k=m, a(k)z^-k);
  64. filter:
  65. given e & a, determine x;
  66. x(n) = e(n) - Sum (k=1, m, a(k)x(n-k))
  67. useGain determines whether the LPC-gain is used in the synthesis.
  68. */
  69. void LPC_Sound_filterWithFilterAtTime_inplace (LPC me, Sound thee, integer channel, double time);
  70. autoSound LPC_Sound_filterWithFilterAtTime (LPC me, Sound thee, integer channel, double time);
  71. autoSound LPC_Sound_filterInverse (LPC me, Sound thee);
  72. /*
  73. E(z) = X(z)A(z),
  74. A(z) = 1 + Sum (k=1, k=m, a(k)z^-k);
  75. filter inverse:
  76. given x & a, determine e;
  77. e(n) = x(n) + Sum (k=1, m, a(k)x(n-k))
  78. */
  79. autoSound LPC_Sound_filterInverseWithFilterAtTime (LPC me, Sound thee, integer channel, double time);
  80. void LPC_Sound_filterInverseWithFilterAtTime_inplace (LPC me, Sound thee, integer channel, double time);
  81. #endif /* _Sound_and_LPC_h_ */