Cepstrum.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #ifndef _Cepstrum_h_
  2. #define _Cepstrum_h_
  3. /* Cepstrum.h
  4. *
  5. * Copyright (C) 1994-2013, 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 20010111
  22. djmw 20020812 GPL header
  23. djmw 20121117 Latest modification.
  24. */
  25. /*
  26. The Cepstrum is a sequence of real numbers.
  27. It is the spectrum of the power spectrum of a (sound) signal.
  28. */
  29. #include "Matrix.h"
  30. Thing_define (Cepstrum, Matrix) {
  31. double v_getValueAtSample (integer isamp, integer which, int units)
  32. override;
  33. };
  34. /*
  35. The Cepstrum is a sequence of real numbers.
  36. It is the power spectrum of the power spectrum of a (sound) signal.
  37. */
  38. Thing_define (PowerCepstrum, Cepstrum) {
  39. double v_getValueAtSample (integer isamp, integer which, int units)
  40. override;
  41. };
  42. /*
  43. xmin // Lowest quefrency.
  44. xmax // Highest quefrency.
  45. nx // Number of quefrencies.
  46. dx // Quefrency step.
  47. x1 // First quefrency.
  48. ymin = ymax = dy = y1 = 1
  49. ny = 1
  50. */
  51. autoCepstrum Cepstrum_create (double qmax, integer nq);
  52. autoPowerCepstrum PowerCepstrum_create (double qmax, integer nq);
  53. /* Preconditions:
  54. nq >= 2;
  55. Postconditions:
  56. my xmin = 0; my ymin = 1;
  57. my xmax = qmax; my ymax = 1;
  58. my nx = nq; my ny = 1;
  59. my dx = qmax / (nq -1); my dy = 1;
  60. my x1 = 0; my y1 = 1;
  61. my z [1..ny] [1..nx] = 0.0;
  62. */
  63. void PowerCepstrum_draw (PowerCepstrum me, Graphics g, double qmin, double qmax, double dBminimum, double dBmaximum, int garnish);
  64. void Cepstrum_drawLinear (Cepstrum me, Graphics g, double qmin, double qmax, double minimum, double maximum, int garnish);
  65. void PowerCepstrum_drawTiltLine (PowerCepstrum me, Graphics g, double qmin, double qmax, double dBminimum, double dBmaximum, double qstart, double qend, int lineType, int method);
  66. /*
  67. Function:
  68. Draw a Cepstrum
  69. Preconditions:
  70. maximum > minimum;
  71. Arguments:
  72. [qmin, qmax]: quefrencies; x domain of drawing;
  73. Autowindowing: if qmax <= qmin, x domain of drawing is
  74. [my xmin, my xmax].
  75. [minimum, maximum]: amplitude; y range of drawing.
  76. */
  77. void PowerCepstrum_getMaximumAndQuefrency (PowerCepstrum me, double pitchFloor, double pitchCeiling, int interpolation, double *maximum, double *quefrency);
  78. // The standard of Hillenbrand with fitting options
  79. double PowerCepstrum_getPeakProminence_hillenbrand (PowerCepstrum me, double pitchFloor, double pitchCeiling, double *qpeak);
  80. double PowerCepstrum_getRNR (PowerCepstrum me, double pitchFloor, double pitchCeiling, double f0fractionalWidth);
  81. double PowerCepstrum_getPeakProminence (PowerCepstrum me, double pitchFloor, double pitchCeiling, int interpolation, double qstartFit, double qendFit, int lineType, int fitMethod, double *qpeak);
  82. void PowerCepstrum_fitTiltLine (PowerCepstrum me, double qmin, double qmax, double *slope, double *intercept, int lineType, int method);
  83. autoPowerCepstrum PowerCepstrum_subtractTilt (PowerCepstrum me, double qstartFit, double qendFit, int lineType, int fitMethod);
  84. void PowerCepstrum_subtractTilt_inplace (PowerCepstrum me, double qstartFit, double qendFit, int lineType, int fitMethod);
  85. void PowerCepstrum_smooth_inplace (PowerCepstrum me, double quefrencyAveragingWindow, integer numberOfIterations);
  86. autoPowerCepstrum PowerCepstrum_smooth (PowerCepstrum me, double quefrencyAveragingWindow, integer numberOfIterations);
  87. autoMatrix PowerCepstrum_to_Matrix (PowerCepstrum me);
  88. autoPowerCepstrum Matrix_to_PowerCepstrum (Matrix me);
  89. autoPowerCepstrum Matrix_to_PowerCepstrum_row (Matrix me, integer row);
  90. autoPowerCepstrum Matrix_to_PowerCepstrum_column (Matrix me, integer col);
  91. autoPowerCepstrum Cepstrum_downto_PowerCepstrum (Cepstrum me);
  92. #endif /* _Cepstrum_h_ */