Sound_to_Pitch.h 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* Sound_to_Pitch.h
  2. *
  3. * Copyright (C) 1992-2011,2015 Paul Boersma
  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.
  13. * See the GNU 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. #include "Sound.h"
  19. #include "Pitch.h"
  20. autoPitch Sound_to_Pitch (Sound me, double timeStep,
  21. double minimumPitch, double maximumPitch);
  22. /* Calls Sound_to_Pitch_ac with default arguments. */
  23. autoPitch Sound_to_Pitch_ac (Sound me, double timeStep, double minimumPitch,
  24. double periodsPerWindow, int maxnCandidates, int accurate,
  25. double silenceThreshold, double voicingThreshold, double octaveCost,
  26. double octaveJumpCost, double voicedUnvoicedCost, double maximumPitch);
  27. /* Calls Sound_to_Pitch_any with AC method. */
  28. autoPitch Sound_to_Pitch_cc (Sound me, double timeStep, double minimumPitch,
  29. double periodsPerWindow, int maxnCandidates, int accurate,
  30. double silenceThreshold, double voicingThreshold, double octaveCost,
  31. double octaveJumpCost, double voicedUnvoicedCost, double maximumPitch);
  32. /* Calls Sound_to_Pitch_any with FCC method. */
  33. autoPitch Sound_to_Pitch_any (Sound me,
  34. double dt, /* time step (seconds); 0.0 = automatic = periodsPerWindow / minimumPitch / 4 */
  35. double minimumPitch, /* (Hz) */
  36. double periodsPerWindow, /* ac3 for pitch analysis, 6 or 4.5 for HNR, 1 for FCC */
  37. int maxnCandidates, /* maximum number of candidates per frame */
  38. int method, /* 0 or 1 = AC, 2 or 3 = FCC, 0 or 2 = fast, 1 or 3 = accurate */
  39. double silenceThreshold, /* relative to purely periodic; default 0.03 */
  40. double voicingThreshold, /* relative to purely periodic; default 0.45 */
  41. double octaveCost, /* favours higher pitches; default 0.01 */
  42. double octaveJumpCost, /* default 0.35 */
  43. double voicedUnvoicedCost, /* default 0.14 */
  44. double maximumPitch); /* (Hz) */
  45. /*
  46. Function:
  47. acoustic periodicity analysis.
  48. Preconditions:
  49. minimumPitch > 0.0;
  50. maxnCandidates >= 2;
  51. Return value:
  52. the resulting pitch contour.
  53. Failures:
  54. Out of memory.
  55. Minimum frequency too low.
  56. Maximum frequency should not be greater than the Sound's Nyquist frequency.
  57. Description for method 0 or 1:
  58. There is a Hanning window (method == 0) or Gaussian window (method == 1)
  59. over the analysis window, in order to avoid phase effects.
  60. Zeroes are appended to the analysis window to avoid edge effects in the FFT.
  61. An FFT is done on the window, giving a complex spectrum.
  62. This complex spectrum is squared, thus giving the power spectrum.
  63. The power spectrum is FFTed back, thus giving the autocorrelation of
  64. the windowed frame. This autocorrelation is expressed relative to the power,
  65. which is the autocorrelation for lag 0. The autocorrelation is divided by
  66. the normalized autocorrelation of the window, in order to bring
  67. all maxima of the autocorrelation of a periodic signal to the same height.
  68. General description:
  69. The maxima are found by sinc interpolation.
  70. The pitch values (frequencies) of the highest 'maxnCandidates' maxima
  71. are saved in 'result', together with their strengths (relative correlations).
  72. A Viterbi algorithm is used to find a smooth path through the candidates,
  73. using the last six arguments of this function.
  74. The 'maximumPitch' argument has no influence on the search for candidates.
  75. It is directly copied into the Pitch object as a hint for considering
  76. pitches above a certain value "voiceless".
  77. */
  78. /* End of file Sound_to_Pitch.h */