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