pitch.praat 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. # pitch.praat
  2. # Paul Boersma, December 10, 2007
  3. # Tests "Sound: To Pitch..."
  4. echo Pitch test
  5. method$ = "cc"
  6. for freq from 76.1 to 106
  7. call sineTest freq 0.1
  8. endfor
  9. for freq from 106.1 to 226
  10. call sineTest freq 0.01
  11. endfor
  12. for i from 2 to 20
  13. call sineTest i*100+77 0.02
  14. endfor
  15. for i from 21 to 29
  16. call sineTest i*100+77 0.1
  17. endfor
  18. for i from 30 to 35
  19. call sineTest i*100+77 1.0
  20. endfor
  21. for i from 36 to 60
  22. call sineTest i*100+77 5.0
  23. endfor
  24. for i from 61 to 107
  25. call sineTest i*100+77 10.0
  26. endfor
  27. for i from 1080 to 1095
  28. call sineTest i*10-0.1 10.0
  29. endfor
  30. for freq from 76.1 to 136
  31. call pulseTest freq 0.1
  32. endfor
  33. for freq from 136.1 to 226
  34. call pulseTest freq 0.2
  35. endfor
  36. for i from 2 to 13
  37. call pulseTest i*100+77 1
  38. endfor
  39. for i from 14 to 20
  40. call pulseTest i*100+77 2
  41. endfor
  42. for i from 210 to 219
  43. call pulseTest i*10+77 10
  44. endfor
  45. for i from 22 to 30
  46. call pulseTest i*100+77 2
  47. endfor
  48. for i from 31 to 53
  49. call pulseTest i*100+77 5
  50. endfor
  51. call pulseTest 219 1
  52. call pulseTest 220 1
  53. method$ = "ac"
  54. for freq from 75.1 to 106
  55. call sineTest freq 0.1
  56. endfor
  57. for freq from 106.1 to 226
  58. call sineTest freq 0.01
  59. endfor
  60. for i from 2 to 105
  61. call sineTest i*100+77 0.02
  62. endfor
  63. for i from 106 to 107
  64. call sineTest i*100+77 0.1
  65. endfor
  66. for i from 1080 to 1095
  67. call sineTest i*10-0.1 0.3
  68. endfor
  69. for freq from 75.1 to 226
  70. call pulseTest freq 0.03
  71. endfor
  72. for i from 2 to 20
  73. call pulseTest i*100+77 1
  74. endfor
  75. for i from 210 to 219
  76. call pulseTest i*10+77 4
  77. endfor
  78. for i from 22 to 53
  79. call pulseTest i*100+77 1
  80. endfor
  81. call pulseTest 219 1
  82. call pulseTest 220 1
  83. # Tests above 5512.5 Hz are superfluous,
  84. # since pulses are no different from since waves then.
  85. printline Pitch test finished OK
  86. procedure sineTest pitch precision
  87. Create Sound... sound 0 1 22050 sin (2 * pi * pitch * x)
  88. call analyse precision
  89. endproc
  90. procedure pulseTest pitch precision
  91. Create PitchTier... sound 0 1
  92. Add point... 0.5 pitch
  93. To Sound (pulse train)... 22050 1 1e-9 2000 no
  94. call analyse precision
  95. select PitchTier sound
  96. Remove
  97. endproc
  98. procedure analyse precision
  99. ;To Pitch... 0.09457464735 75 11025
  100. noprogress To Pitch ('method$')... 0.09457464735 75 15 no 0.03 0.45 0.03 0.35 0.14 11025
  101. minPitch = Get minimum... 0 0 Hertz None
  102. maxPitch = Get maximum... 0 0 Hertz None
  103. diff1 = minPitch - pitch
  104. diff2 = maxPitch - pitch
  105. absDiff = max (abs (diff1), abs (diff2))
  106. relDiff = absDiff / pitch
  107. printline 'pitch' 'diff1:6' 'diff2:6' 'relDiff:3%'
  108. assert absDiff < precision ; 'pitch' 'minPitch' 'maxPitch'
  109. plus Sound sound
  110. Remove
  111. endproc