You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

293 lines
8.1KB

  1. /***************************************************/
  2. /*! \class Phonemes
  3. \brief STK phonemes table.
  4. This class does nothing other than declare a
  5. set of 32 static phoneme formant parameters
  6. and provide access to those values.
  7. by Perry R. Cook and Gary P. Scavone, 1995--2017.
  8. */
  9. /***************************************************/
  10. #include "Phonemes.h"
  11. #include <iostream>
  12. namespace stk {
  13. const char Phonemes :: phonemeNames[32][4] =
  14. {"eee", "ihh", "ehh", "aaa",
  15. "ahh", "aww", "ohh", "uhh",
  16. "uuu", "ooo", "rrr", "lll",
  17. "mmm", "nnn", "nng", "ngg",
  18. "fff", "sss", "thh", "shh",
  19. "xxx", "hee", "hoo", "hah",
  20. "bbb", "ddd", "jjj", "ggg",
  21. "vvv", "zzz", "thz", "zhh"
  22. };
  23. const StkFloat Phonemes :: phonemeGains[32][2] =
  24. {{1.0, 0.0}, // eee
  25. {1.0, 0.0}, // ihh
  26. {1.0, 0.0}, // ehh
  27. {1.0, 0.0}, // aaa
  28. {1.0, 0.0}, // ahh
  29. {1.0, 0.0}, // aww
  30. {1.0, 0.0}, // ohh
  31. {1.0, 0.0}, // uhh
  32. {1.0, 0.0}, // uuu
  33. {1.0, 0.0}, // ooo
  34. {1.0, 0.0}, // rrr
  35. {1.0, 0.0}, // lll
  36. {1.0, 0.0}, // mmm
  37. {1.0, 0.0}, // nnn
  38. {1.0, 0.0}, // nng
  39. {1.0, 0.0}, // ngg
  40. {0.0, 0.7}, // fff
  41. {0.0, 0.7}, // sss
  42. {0.0, 0.7}, // thh
  43. {0.0, 0.7}, // shh
  44. {0.0, 0.7}, // xxx
  45. {0.0, 0.1}, // hee
  46. {0.0, 0.1}, // hoo
  47. {0.0, 0.1}, // hah
  48. {1.0, 0.1}, // bbb
  49. {1.0, 0.1}, // ddd
  50. {1.0, 0.1}, // jjj
  51. {1.0, 0.1}, // ggg
  52. {1.0, 1.0}, // vvv
  53. {1.0, 1.0}, // zzz
  54. {1.0, 1.0}, // thz
  55. {1.0, 1.0} // zhh
  56. };
  57. const StkFloat Phonemes :: phonemeParameters[32][4][3] =
  58. {{ { 273, 0.996, 10}, // eee (beet)
  59. {2086, 0.945, -16},
  60. {2754, 0.979, -12},
  61. {3270, 0.440, -17}},
  62. { { 385, 0.987, 10}, // ihh (bit)
  63. {2056, 0.930, -20},
  64. {2587, 0.890, -20},
  65. {3150, 0.400, -20}},
  66. { { 515, 0.977, 10}, // ehh (bet)
  67. {1805, 0.810, -10},
  68. {2526, 0.875, -10},
  69. {3103, 0.400, -13}},
  70. { { 773, 0.950, 10}, // aaa (bat)
  71. {1676, 0.830, -6},
  72. {2380, 0.880, -20},
  73. {3027, 0.600, -20}},
  74. { { 770, 0.950, 0}, // ahh (father)
  75. {1153, 0.970, -9},
  76. {2450, 0.780, -29},
  77. {3140, 0.800, -39}},
  78. { { 637, 0.910, 0}, // aww (bought)
  79. { 895, 0.900, -3},
  80. {2556, 0.950, -17},
  81. {3070, 0.910, -20}},
  82. { { 637, 0.910, 0}, // ohh (bone) NOTE:: same as aww (bought)
  83. { 895, 0.900, -3},
  84. {2556, 0.950, -17},
  85. {3070, 0.910, -20}},
  86. { { 561, 0.965, 0}, // uhh (but)
  87. {1084, 0.930, -10},
  88. {2541, 0.930, -15},
  89. {3345, 0.900, -20}},
  90. { { 515, 0.976, 0}, // uuu (foot)
  91. {1031, 0.950, -3},
  92. {2572, 0.960, -11},
  93. {3345, 0.960, -20}},
  94. { { 349, 0.986, -10}, // ooo (boot)
  95. { 918, 0.940, -20},
  96. {2350, 0.960, -27},
  97. {2731, 0.950, -33}},
  98. { { 394, 0.959, -10}, // rrr (bird)
  99. {1297, 0.780, -16},
  100. {1441, 0.980, -16},
  101. {2754, 0.950, -40}},
  102. { { 462, 0.990, +5}, // lll (lull)
  103. {1200, 0.640, -10},
  104. {2500, 0.200, -20},
  105. {3000, 0.100, -30}},
  106. { { 265, 0.987, -10}, // mmm (mom)
  107. {1176, 0.940, -22},
  108. {2352, 0.970, -20},
  109. {3277, 0.940, -31}},
  110. { { 204, 0.980, -10}, // nnn (nun)
  111. {1570, 0.940, -15},
  112. {2481, 0.980, -12},
  113. {3133, 0.800, -30}},
  114. { { 204, 0.980, -10}, // nng (sang) NOTE:: same as nnn
  115. {1570, 0.940, -15},
  116. {2481, 0.980, -12},
  117. {3133, 0.800, -30}},
  118. { { 204, 0.980, -10}, // ngg (bong) NOTE:: same as nnn
  119. {1570, 0.940, -15},
  120. {2481, 0.980, -12},
  121. {3133, 0.800, -30}},
  122. { {1000, 0.300, 0}, // fff
  123. {2800, 0.860, -10},
  124. {7425, 0.740, 0},
  125. {8140, 0.860, 0}},
  126. { {0, 0.000, 0}, // sss
  127. {2000, 0.700, -15},
  128. {5257, 0.750, -3},
  129. {7171, 0.840, 0}},
  130. { { 100, 0.900, 0}, // thh
  131. {4000, 0.500, -20},
  132. {5500, 0.500, -15},
  133. {8000, 0.400, -20}},
  134. { {2693, 0.940, 0}, // shh
  135. {4000, 0.720, -10},
  136. {6123, 0.870, -10},
  137. {7755, 0.750, -18}},
  138. { {1000, 0.300, -10}, // xxx NOTE:: Not Really Done Yet
  139. {2800, 0.860, -10},
  140. {7425, 0.740, 0},
  141. {8140, 0.860, 0}},
  142. { { 273, 0.996, -40}, // hee (beet) (noisy eee)
  143. {2086, 0.945, -16},
  144. {2754, 0.979, -12},
  145. {3270, 0.440, -17}},
  146. { { 349, 0.986, -40}, // hoo (boot) (noisy ooo)
  147. { 918, 0.940, -10},
  148. {2350, 0.960, -17},
  149. {2731, 0.950, -23}},
  150. { { 770, 0.950, -40}, // hah (father) (noisy ahh)
  151. {1153, 0.970, -3},
  152. {2450, 0.780, -20},
  153. {3140, 0.800, -32}},
  154. { {2000, 0.700, -20}, // bbb NOTE:: Not Really Done Yet
  155. {5257, 0.750, -15},
  156. {7171, 0.840, -3},
  157. {9000, 0.900, 0}},
  158. { { 100, 0.900, 0}, // ddd NOTE:: Not Really Done Yet
  159. {4000, 0.500, -20},
  160. {5500, 0.500, -15},
  161. {8000, 0.400, -20}},
  162. { {2693, 0.940, 0}, // jjj NOTE:: Not Really Done Yet
  163. {4000, 0.720, -10},
  164. {6123, 0.870, -10},
  165. {7755, 0.750, -18}},
  166. { {2693, 0.940, 0}, // ggg NOTE:: Not Really Done Yet
  167. {4000, 0.720, -10},
  168. {6123, 0.870, -10},
  169. {7755, 0.750, -18}},
  170. { {2000, 0.700, -20}, // vvv NOTE:: Not Really Done Yet
  171. {5257, 0.750, -15},
  172. {7171, 0.840, -3},
  173. {9000, 0.900, 0}},
  174. { { 100, 0.900, 0}, // zzz NOTE:: Not Really Done Yet
  175. {4000, 0.500, -20},
  176. {5500, 0.500, -15},
  177. {8000, 0.400, -20}},
  178. { {2693, 0.940, 0}, // thz NOTE:: Not Really Done Yet
  179. {4000, 0.720, -10},
  180. {6123, 0.870, -10},
  181. {7755, 0.750, -18}},
  182. { {2693, 0.940, 0}, // zhh NOTE:: Not Really Done Yet
  183. {4000, 0.720, -10},
  184. {6123, 0.870, -10},
  185. {7755, 0.750, -18}}
  186. };
  187. Phonemes :: Phonemes(void)
  188. {
  189. }
  190. Phonemes :: ~Phonemes(void)
  191. {
  192. }
  193. const char *Phonemes :: name( unsigned int index )
  194. {
  195. if ( index > 31 ) {
  196. oStream_ << "Phonemes::name: index is greater than 31!";
  197. handleError( oStream_.str(), StkError::WARNING );
  198. return 0;
  199. }
  200. return phonemeNames[index];
  201. }
  202. StkFloat Phonemes :: voiceGain( unsigned int index )
  203. {
  204. if ( index > 31 ) {
  205. oStream_ << "Phonemes::voiceGain: index is greater than 31!";
  206. handleError( oStream_.str(), StkError::WARNING );
  207. return 0.0;
  208. }
  209. return phonemeGains[index][0];
  210. }
  211. StkFloat Phonemes :: noiseGain( unsigned int index )
  212. {
  213. if ( index > 31 ) {
  214. oStream_ << "Phonemes::noiseGain: index is greater than 31!";
  215. handleError( oStream_.str(), StkError::WARNING );
  216. return 0.0;
  217. }
  218. return phonemeGains[index][1];
  219. }
  220. StkFloat Phonemes :: formantFrequency( unsigned int index, unsigned int partial )
  221. {
  222. if ( index > 31 ) {
  223. oStream_ << "Phonemes::formantFrequency: index is greater than 31!";
  224. handleError( oStream_.str(), StkError::WARNING );
  225. return 0.0;
  226. }
  227. if ( partial > 3 ) {
  228. oStream_ << "Phonemes::formantFrequency: partial is greater than 3!";
  229. handleError( oStream_.str(), StkError::WARNING );
  230. return 0.0;
  231. }
  232. return phonemeParameters[index][partial][0];
  233. }
  234. StkFloat Phonemes :: formantRadius( unsigned int index, unsigned int partial )
  235. {
  236. if ( index > 31 ) {
  237. oStream_ << "Phonemes::formantRadius: index is greater than 31!";
  238. handleError( oStream_.str(), StkError::WARNING );
  239. return 0.0;
  240. }
  241. if ( partial > 3 ) {
  242. oStream_ << "Phonemes::formantRadius: partial is greater than 3!";
  243. handleError( oStream_.str(), StkError::WARNING );
  244. return 0.0;
  245. }
  246. return phonemeParameters[index][partial][1];
  247. }
  248. StkFloat Phonemes :: formantGain( unsigned int index, unsigned int partial )
  249. {
  250. if ( index > 31 ) {
  251. oStream_ << "Phonemes::formantGain: index is greater than 31!";
  252. handleError( oStream_.str(), StkError::WARNING );
  253. return 0.0;
  254. }
  255. if ( partial > 3 ) {
  256. oStream_ << "Phonemes::formantGain: partial is greater than 3!";
  257. handleError( oStream_.str(), StkError::WARNING );
  258. return 0.0;
  259. }
  260. return phonemeParameters[index][partial][2];
  261. }
  262. } // stk namespace