test_KlattGrid.praat 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. # test_KlattGrid.praat
  2. # djmw 20151020
  3. printline test_KlattGrid.praat
  4. t = Create Table with column names... t 25 tier min max nf
  5. Set string value... 1 tier pitch
  6. Set string value... 2 tier voicing amplitude
  7. Set string value... 3 tier flutter
  8. Set string value... 4 tier power1
  9. Set string value... 5 tier power2
  10. Set string value... 6 tier open phase
  11. Set string value... 7 tier collision phase
  12. Set string value... 8 tier double pulsing
  13. Set string value... 9 tier spectral tilt
  14. Set string value... 10 tier aspiration amplitude
  15. Set string value... 11 tier breathiness amplitude
  16. Set numeric value... 1 min 80
  17. Set numeric value... 2 min 0
  18. Set numeric value... 3 min 0
  19. Set numeric value... 4 min 1
  20. Set numeric value... 5 min 2
  21. Set numeric value... 6 min 0
  22. Set numeric value... 7 min 0
  23. Set numeric value... 8 min 0
  24. Set numeric value... 9 min 0
  25. Set numeric value... 10 min 0
  26. Set numeric value... 11 min 0
  27. Set numeric value... 1 max 400
  28. Set numeric value... 2 max 93
  29. Set numeric value... 3 max 1
  30. Set numeric value... 4 max 4
  31. Set numeric value... 5 max 5
  32. Set numeric value... 6 max 0.9
  33. Set numeric value... 7 max 0.05
  34. Set numeric value... 8 max 1
  35. Set numeric value... 9 max 40
  36. Set numeric value... 10 max 90
  37. Set numeric value... 11 max 90
  38. Set string value... 12 tier oral formant frequency
  39. Set string value... 13 tier nasal formant frequency
  40. Set string value... 14 tier nasal antiformant frequency
  41. Set string value... 15 tier tracheal formant frequency
  42. Set string value... 16 tier tracheal antiformant frequency
  43. Set string value... 17 tier delta formant frequency
  44. Set string value... 18 tier frication formant frequency
  45. Set numeric value... 12 min 100
  46. Set numeric value... 13 min 100
  47. Set numeric value... 14 min 0
  48. Set numeric value... 15 min 200
  49. Set numeric value... 16 min 100
  50. Set numeric value... 17 min 0
  51. Set numeric value... 18 min 100
  52. Set numeric value... 12 max 6000
  53. Set numeric value... 13 max 6000
  54. Set numeric value... 14 max 6000
  55. Set numeric value... 15 max 2000
  56. Set numeric value... 16 max 1000
  57. Set numeric value... 17 max 1000
  58. Set numeric value... 18 max 8000
  59. Set string value... 19 tier oral formant bandwidth
  60. Set string value... 20 tier nasal formant bandwidth
  61. Set string value... 21 tier nasal antiformant bandwidth
  62. Set string value... 22 tier tracheal formant bandwidth
  63. Set string value... 23 tier tracheal antiformant bandwidth
  64. Set string value... 24 tier delta formant bandwidth
  65. Set string value... 25 tier frication formant bandwidth
  66. nof = 8
  67. nnf = 3
  68. nnaf = 4
  69. ntf = 4
  70. ntaf = 2
  71. ndf = 2
  72. nff = 6
  73. Set numeric value... 12 nf nof
  74. Set numeric value... 13 nf nnf
  75. Set numeric value... 14 nf nnaf
  76. Set numeric value... 15 nf ntf
  77. Set numeric value... 16 nf ntaf
  78. Set numeric value... 17 nf ndf
  79. Set numeric value... 18 nf nff
  80. for i from 19 to 25
  81. bwmin = Object_'t'[i-7, "min"]
  82. bwmax = Object_'t'[i-7, "max"]
  83. nf = Object_'t'[i-7, "nf"]
  84. Set numeric value... i min bwmin/10
  85. Set numeric value... i max bwmax/10
  86. Set numeric value... i nf nf
  87. endfor
  88. nPhonationTiers = 11
  89. tmin = 0
  90. tmax = 1
  91. kg = Create KlattGrid... kg tmin tmax nof nnf nnaf nff ntf ntaf ndf
  92. ntimes = 5
  93. dt = 0.0001
  94. for i to nPhonationTiers
  95. select kg
  96. tier$ = Object_'t'$[i,"tier"]
  97. vmin = Object_'t'[i,"min"]
  98. vmax = Object_'t'[i,"max"]
  99. for itime to ntimes
  100. time[itime] = randomUniform (tmin, tmax)
  101. val[itime] = randomUniform (vmin, vmax)
  102. Add 'tier$' point... time[itime] val[itime]
  103. endfor
  104. for itime to ntimes
  105. val = Get 'tier$' at time... time[itime]
  106. assert val = val[itime]
  107. endfor
  108. Remove 'tier$' points... tmin tmax
  109. tier = Extract 'tier$' tier
  110. Remove
  111. printline 'tab$'... 'tier$'
  112. endfor
  113. for i from nPhonationTiers+1 to 25
  114. select kg
  115. tier$ = Object_'t'$ [i, "tier"]
  116. vmin = Object_'t' [i, "min"]
  117. vmax = Object_'t' [i, "max"]
  118. nf = Object_'t' [i, "nf"]
  119. print 'tab$'... 'tier$'
  120. for ifor from 1 to nf
  121. select kg
  122. for itime to ntimes
  123. time[itime] = randomUniform (tmin, tmax)
  124. val[itime] = randomUniform (vmin, vmax)
  125. Add 'tier$' point... ifor time[itime] val[itime]
  126. endfor
  127. for itime to ntimes
  128. val = Get 'tier$' at time... ifor time[itime]
  129. assert val = val[itime]
  130. endfor
  131. Remove 'tier$' points... ifor tmin tmax
  132. grid$ = replace$ (tier$, " frequency", "", 1)
  133. grid$ = replace$ (grid$, " bandwidth", "", 1)
  134. grid = Extract 'grid$' grid
  135. print 'tab$''ifor'
  136. Remove
  137. endfor
  138. print 'newline$'
  139. endfor
  140. removeObject: kg, t
  141. printline test_KlattGrid.praat OK