Debian Codegraph @

melder/NUMear.cpp

raw symbols SCIP
1 /* NUMear.cpp
2 *
3 * Copyright (C) 1992-2011,2016-2018,2023 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 "melder.h"cxx . . $ `<file>/melder/melder.h`/
20
21 double NUMhertzToBarkcxx . . $ NUMhertzToBark(447c67c6676f75c3). (double hertz) {
22 const double r = hertz / 650.0;
23 return hertz < 0.0 ? undefinedcxx . . $ undefined. : 7.0 * logcxx . . $ log(fee4f1d22bc8e617). (r + sqrtcxx . . $ sqrt(fee4f1d22bc8e617). (1.0 + r * r));
24 }
25 double NUMbarkToHertzcxx . . $ NUMbarkToHertz(447c67c6676f75c3). (double bark) {
26 return bark < 0.0 ? undefinedcxx . . $ undefined. : 650.0 * sinhcxx . . $ sinh(fee4f1d22bc8e617). (bark / 7.0);
27 }
28
29 double NUMphonToDifferenceLimenscxx . . $ NUMphonToDifferenceLimens(447c67c6676f75c3). (double phon) {
30 return phon < 0.0 ? undefinedcxx . . $ undefined. : 30.0 * (powcxx . . $ pow(b71928d39fde4295). (61.0 / 60.0, phon) - 1.0);
31 }
32 double NUMdifferenceLimensToPhoncxx . . $ NUMdifferenceLimensToPhon(447c67c6676f75c3). (double ndli) {
33 return ndli < 0.0 ? undefinedcxx . . $ undefined. : logcxx . . $ log(fee4f1d22bc8e617). (1.0 + ndli / 30.0) / logcxx . . $ log(fee4f1d22bc8e617). (61.0 / 60.0);
34 }
35
36 double NUMsoundPressureToPhoncxx . . $ NUMsoundPressureToPhon(d8e7e0733fa41c87). (double soundPressure, double bark) {
37 if (soundPressure <= 0.0 || bark < 0.0)
38 return undefinedcxx . . $ undefined.;
39
40 /* dB = 20 * log10 (soundPressure / threshold) */
41 double result = 20.0 * log10cxx . . $ log10(fee4f1d22bc8e617). (soundPressure / 2.0e-5); // first approximation: phon = dB
42
43 /* Phones from dB */
44 if (result < 90.0 && bark < 8.0)
45 result -= sqrcxx . . $ sqr(ada6a8422704cf8a). ((90.0 - result) * (8.0 - bark)) / 2500.0;
46
47 result += 5.0 * expcxx . . $ exp(fee4f1d22bc8e617). (- sqrcxx . . $ sqr(ada6a8422704cf8a). (bark / 3.6 - 5.0));
48 if (bark > 20.0)
49 result -= 0.5 * sqrcxx . . $ sqr(ada6a8422704cf8a). (bark - 20.0);
50 Melder_clipLeftcxx . . $ Melder_clipLeft(6245cd023a7d1552). (0.0, & result);
51 return result;
52 }
53
54 double NUMhertzToMelcxx . . $ NUMhertzToMel(447c67c6676f75c3). (double hertz) {
55 return hertz < 0.0 ? undefinedcxx . . $ undefined. : 550.0 * logcxx . . $ log(fee4f1d22bc8e617). (1.0 + hertz / 550.0);
56 }
57 double NUMmelToHertzcxx . . $ NUMmelToHertz(447c67c6676f75c3). (double mel) {
58 return mel < 0.0 ? undefinedcxx . . $ undefined. : 550.0 * (expcxx . . $ exp(fee4f1d22bc8e617). (mel / 550.0) - 1.0);
59 }
60
61 double NUMhertzToSemitonescxx . . $ NUMhertzToSemitones(447c67c6676f75c3). (double hertz) {
62 return hertz <= 0.0 ? undefinedcxx . . $ undefined. : 12.0 * logcxx . . $ log(fee4f1d22bc8e617). (hertz / 100.0) / NUMln2cxx . . $ NUMln2.;
63 }
64 double NUMsemitonesToHertzcxx . . $ NUMsemitonesToHertz(447c67c6676f75c3). (double semitones) {
65 return isundefcxx . . $ isundef(f8197d536af80c96). (semitones) ? undefinedcxx . . $ undefined. : 100.0 * expcxx . . $ exp(fee4f1d22bc8e617). (semitones * (NUMln2cxx . . $ NUMln2. / 12.0));
66 }
67
68 /* Moore & Glasberg 1983 JASA 74: 750 */
69
70 double NUMerbcxx . . $ NUMerb(447c67c6676f75c3). (double f) {
71 return 6.23e-6 * f * f + 0.09339 * f + 28.52;
72 }
73 double NUMhertzToErbcxx . . $ NUMhertzToErb(447c67c6676f75c3). (double hertz) {
74 return hertz < 0.0 ? undefinedcxx . . $ undefined. : 11.17 * logcxx . . $ log(fee4f1d22bc8e617). ((hertz + 312.0) / (hertz + 14680.0)) + 43.0;
75 }
76 double NUMerbToHertzcxx . . $ NUMerbToHertz(447c67c6676f75c3). (double erb) {
77 double dum = expcxx . . $ exp(fee4f1d22bc8e617). ((erb - 43.0) / 11.17);
78 return erb < 0.0 ? undefinedcxx . . $ undefined. : (14680.0 * dum - 312.0) / (1.0 - dum);
79 }
80
81 /* End of file NUMear.cpp */