Speaker.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /* Speaker.cpp
  2. *
  3. * Copyright (C) 1992-2005,2007,2011,2012,2015-2018 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 "Speaker.h"
  19. #include "oo_DESTROY.h"
  20. #include "Speaker_def.h"
  21. #include "oo_COPY.h"
  22. #include "Speaker_def.h"
  23. #include "oo_EQUAL.h"
  24. #include "Speaker_def.h"
  25. #include "oo_CAN_WRITE_AS_ENCODING.h"
  26. #include "Speaker_def.h"
  27. #include "oo_WRITE_TEXT.h"
  28. #include "Speaker_def.h"
  29. #include "oo_READ_TEXT.h"
  30. #include "Speaker_def.h"
  31. #include "oo_WRITE_BINARY.h"
  32. #include "Speaker_def.h"
  33. #include "oo_READ_BINARY.h"
  34. #include "Speaker_def.h"
  35. #include "oo_DESCRIPTION.h"
  36. #include "Speaker_def.h"
  37. Thing_implement (Speaker, Daata, 0);
  38. autoSpeaker Speaker_create (conststring32 kindOfSpeaker, int16 numberOfVocalCordMasses) {
  39. autoSpeaker me = Thing_new (Speaker);
  40. /* Supralaryngeal dimensions are taken from P. Mermelstein (1973): */
  41. /* "Articulatory model for the study of speech production", */
  42. /* Journal of the Acoustical Society of America 53,1070 - 1082. */
  43. /* That was a male speaker, so we need scaling for other speakers: */
  44. double scaling;
  45. if (str32equ (kindOfSpeaker, U"Male")) my relativeSize = 1.1;
  46. else if (str32equ (kindOfSpeaker, U"Child")) my relativeSize = 0.7;
  47. else my relativeSize = 1.0;
  48. scaling = my relativeSize;
  49. /* Laryngeal system. Data for male speaker from Ishizaka and Flanagan. */
  50. if (str32equ (kindOfSpeaker, U"Female")) {
  51. my lowerCord.thickness = 1.4e-3; // dx, in metres
  52. my upperCord.thickness = 0.7e-3;
  53. my cord.length = 10e-3;
  54. my lowerCord.mass = 0.02e-3; // kilograms
  55. my upperCord.mass = 0.01e-3;
  56. my lowerCord.k1 = 10; // Newtons per metre
  57. my upperCord.k1 = 4;
  58. } else if (str32equ (kindOfSpeaker, U"Male")) {
  59. my lowerCord.thickness = 2.0e-3; // dx, in metres
  60. my upperCord.thickness = 1.0e-3;
  61. my cord.length = 18e-3;
  62. my lowerCord.mass = 0.1e-3; // kilograms
  63. my upperCord.mass = 0.05e-3;
  64. my lowerCord.k1 = 12; // Newtons per metre
  65. my upperCord.k1 = 4;
  66. } else /* "Child" */ {
  67. my lowerCord.thickness = 0.7e-3; // dx, in metres
  68. my upperCord.thickness = 0.3e-3;
  69. my cord.length = 6e-3;
  70. my lowerCord.mass = 0.003e-3; // kilograms
  71. my upperCord.mass = 0.002e-3;
  72. my lowerCord.k1 = 6; // Newtons per metre
  73. my upperCord.k1 = 2;
  74. }
  75. my cord.numberOfMasses = numberOfVocalCordMasses;
  76. if (numberOfVocalCordMasses == 1) {
  77. my lowerCord.thickness += my upperCord.thickness;
  78. my lowerCord.mass += my upperCord.mass;
  79. my lowerCord.k1 += my upperCord.k1;
  80. }
  81. /* Supralaryngeal system. Data from Mermelstein. */
  82. my velum.x = -0.031 * scaling;
  83. my velum.y = 0.023 * scaling;
  84. my velum.a = atan2 (my velum.y, my velum.x);
  85. my palate.radius = sqrt (my velum.x * my velum.x + my velum.y * my velum.y);
  86. my tip.length = 0.034 * scaling;
  87. my neutralBodyDistance = 0.086 * scaling;
  88. my alveoli.x = 0.024 * scaling;
  89. my alveoli.y = 0.0302 * scaling;
  90. my alveoli.a = atan2 (my alveoli.y, my alveoli.x);
  91. my teethCavity.dx1 = -0.009 * scaling;
  92. my teethCavity.dx2 = -0.004 * scaling;
  93. my teethCavity.dy = -0.011 * scaling;
  94. my lowerTeeth.a = -0.30; // radians
  95. my lowerTeeth.r = 0.113 * scaling; // metres
  96. my upperTeeth.x = 0.036 * scaling;
  97. my upperTeeth.y = 0.026 * scaling;
  98. my lowerLip.dx = 0.010 * scaling;
  99. my lowerLip.dy = -0.004 * scaling;
  100. my upperLip.dx = 0.010 * scaling;
  101. my upperLip.dy = 0.004 * scaling;
  102. my nose.Dx = 0.007 * scaling;
  103. my nose.Dz = 0.014 * scaling;
  104. my nose.weq = VECraw (14);
  105. my nose.weq [1] = 0.018 * scaling;
  106. my nose.weq [2] = 0.016 * scaling;
  107. my nose.weq [3] = 0.014 * scaling;
  108. my nose.weq [4] = 0.020 * scaling;
  109. my nose.weq [5] = 0.023 * scaling;
  110. my nose.weq [6] = 0.020 * scaling;
  111. my nose.weq [7] = 0.035 * scaling;
  112. my nose.weq [8] = 0.035 * scaling;
  113. my nose.weq [9] = 0.030 * scaling;
  114. my nose.weq [10] = 0.022 * scaling;
  115. my nose.weq [11] = 0.016 * scaling;
  116. my nose.weq [12] = 0.010 * scaling;
  117. my nose.weq [13] = 0.012 * scaling;
  118. my nose.weq [14] = 0.013 * scaling;
  119. return me;
  120. }
  121. /* End of file Speaker.cpp */