Debian Codegraph @

fon/Intensity.cpp

raw symbols SCIP
1 /* Intensity.cpp
2 *
3 * Copyright (C) 1992-2007,2011,2012,2015-2019,2022,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 "Intensity.h"cxx . . $ `<file>/fon/Intensity.h`/
20
21 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (Intensity, Vector, 2);
22
23 void structIntensitycxx . . $ structIntensity# :: v1_infocxx . . $ structIntensity#v1_info(49f6e7a06ebc5aa8). () {
24 structDaatacxx . . $ structDaata# :: v1_infocxx . . $ structThing#v1_info(49f6e7a06ebc5aa8). ();
25 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Time domain:");
26 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" Start time: ", xmincxx . . $ structFunction#xmin., U" seconds");
27 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" End time: ", xmaxcxx . . $ structFunction#xmax., U" seconds");
28 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" Total duration: ", xmaxcxx . . $ structFunction#xmax. - xmincxx . . $ structFunction#xmin., U" seconds");
29 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Time sampling:");
30 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" Number of frames: ", nxcxx . . $ structSampled#nx.);
31 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" Time step: ", dxcxx . . $ structSampled#dx., U" seconds");
32 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U" First frame centred at: ", x1cxx . . $ structSampled#x1., U" seconds");
33 }
34
35 double structIntensitycxx . . $ structIntensity# :: v_convertStandardToSpecialUnitcxx . . $ structIntensity#v_convertStandardToSpecialUnit(d783654ce2b2ffd0). (double value, integercxx . . $ integer# /* level */, int unit) const {
36 if (unit == 1) {
37 return powcxx . . $ pow(b71928d39fde4295). (10.0, 0.1 * value); // energy
38 } else if (unit == 2) {
39 return powcxx . . $ pow(b71928d39fde4295). (2.0, 0.1 * value); // sones
40 }
41 return value; // default, especially if units == 0 (as in Vector_getMean) or units == 3 (averaging_DB)
42 }
43
44 double structIntensitycxx . . $ structIntensity# :: v_convertSpecialToStandardUnitcxx . . $ structIntensity#v_convertSpecialToStandardUnit(d783654ce2b2ffd0). (double value, integercxx . . $ integer# /* level */, int unit) const {
45 return
46 unit == 1 ?
47 10.0 * log10cxx . . $ log10(fee4f1d22bc8e617). (value) : // value = energy
48 unit == 2 ?
49 10.0 * NUMlog2cxx . . $ NUMlog2(fee4f1d22bc8e617). (value) : // value = sones
50 value; // value = dB
51 }
52
53 void Intensity_initcxx . . $ Intensity_init(44d7851fe1c9bd81). (Intensitycxx . . $ Intensity# me, double tmin, double tmax, integercxx . . $ integer# nt, double dt, double t1) {
54 Matrix_initcxx . . $ Matrix_init(9dd6c49f9830a091). (me, tmin, tmax, nt, dt, t1, 1.0, 1.0, 1, 1.0, 1.0);
55 }
56
57 autoIntensitycxx . . $ autoIntensity# Intensity_createcxx . . $ Intensity_create(83c615748dcd7df). (double tmin, double tmax, integercxx . . $ integer# nt, double dt, double t1) {
58 try {
59 autoIntensitycxx . . $ autoIntensity# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Intensity);
60 Intensity_initcxx . . $ Intensity_init(44d7851fe1c9bd81). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tmin, tmax, nt, dt, t1);
61 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
62 } catch (MelderErrorcxx . . $ MelderError#) {
63 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Intensity not created.");
64 }
65 }
66
67 autoMatrixcxx . . $ autoMatrix# Intensity_to_Matrixcxx . . $ Intensity_to_Matrix(810854a3d14bc6da). (Intensitycxx . . $ Intensity# me) {
68 try {
69 autoMatrixcxx . . $ autoMatrix# thee = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Matrix);
70 mycxx . . $ `melder/melder.h:44:9`! structMatrixcxx . . $ structMatrix# :: v1_copycxx . . $ structMatrix#v1_copy(42659c2335f2eda7). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
71 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
72 } catch (MelderErrorcxx . . $ MelderError#) {
73 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to Matrix.");
74 }
75 }
76
77 autoIntensitycxx . . $ autoIntensity# Matrix_to_Intensitycxx . . $ Matrix_to_Intensity(d8a0db3933b62e36). (Matrixcxx . . $ Matrix# me) {
78 try {
79 autoIntensitycxx . . $ autoIntensity# thee = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Intensity);
80 mycxx . . $ `melder/melder.h:44:9`! structMatrixcxx . . $ structMatrix# :: v1_copycxx . . $ structMatrix#v1_copy(42659c2335f2eda7). (thee.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).());
81 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
82 } catch (MelderErrorcxx . . $ MelderError#) {
83 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": not converted to Intensity.");
84 }
85 }
86
87 void Intensity_drawInsidecxx . . $ Intensity_drawInside(dfe36347cdb6bfdc). (Intensitycxx . . $ Intensity# me, Graphicscxx . . $ Graphics# g, double tmin, double tmax, double minimum, double maximum) {
88 Function_unidirectionalAutowindowcxx . . $ Function_unidirectionalAutowindow(88b7840c59a57eaf). (me, & tmin, & tmax);
89 integercxx . . $ integer# itmin, itmax;
90 Matrix_getWindowSamplesXcxx . . $ Matrix_getWindowSamplesX(c738979be11bd51a). (me, tmin, tmax, & itmin, & itmax);
91 if (maximum <= minimum)
92 Matrix_getWindowExtremacxx . . $ Matrix_getWindowExtrema(d50591dd897af896). (me, itmin, itmax, 1, 1, & minimum, & maximum); // autoscale
93 if (maximum <= minimum) { minimum -= 10; maximum += 10; }
94 Graphics_setWindowcxx . . $ Graphics_setWindow(72bdb7937dbb13da). (g, tmin, tmax, minimum, maximum);
95 Graphics_functioncxx . . $ Graphics_function(1c6279e2c8b8beb1). (g, & mycxx . . $ `melder/melder.h:44:9`! zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).0], itmin, itmax, Matrix_columnToXcxx . . $ Matrix_columnToX(89d6d8659270b8b7). (me, itmin), Matrix_columnToXcxx . . $ Matrix_columnToX(89d6d8659270b8b7). (me, itmax));
96 }
97
98 void Intensity_drawcxx . . $ Intensity_draw(b9a586402ddce4a). (Intensitycxx . . $ Intensity# me, Graphicscxx . . $ Graphics# g, double tmin, double tmax,
99 double minimum, double maximum, bool garnish)
100 {
101 Graphics_setInnercxx . . $ Graphics_setInner(2d838ed765120c5d). (g);
102 Intensity_drawInsidecxx . . $ Intensity_drawInside(dfe36347cdb6bfdc). (me, g, tmin, tmax, minimum, maximum);
103 Graphics_unsetInnercxx . . $ Graphics_unsetInner(2d838ed765120c5d). (g);
104 if (garnish) {
105 Graphics_drawInnerBoxcxx . . $ Graphics_drawInnerBox(2d838ed765120c5d). (g);
106 Graphics_textBottomcxx . . $ Graphics_textBottom(48cf1f690ec61203). (g, true, U"Time (s)");
107 Graphics_marksBottomcxx . . $ Graphics_marksBottom(c3a11a8a55b243ff). (g, 2, true, true, false);
108 Graphics_marksLeftcxx . . $ Graphics_marksLeft(c3a11a8a55b243ff). (g, 2, true, true, false);
109 Graphics_textLeftcxx . . $ Graphics_textLeft(48cf1f690ec61203). (g, true, U"Intensity (dB)");
110 }
111 }
112
113 double Intensity_getQuantilecxx . . $ Intensity_getQuantile(86232bf584732d8f). (Intensitycxx . . $ Intensity# me, double tmin, double tmax, double quantile) {
114 return Sampled_getQuantilecxx . . $ Sampled_getQuantile(c0fbffff6f4b8bff). (me, tmin, tmax, quantile, 0, Intensity_units_DBcxx . . $ `fon/Intensity.h:62:9`!);
115 }
116
117 double Intensity_getAveragecxx . . $ Intensity_getAverage(4a204f48cb78364e). (Intensitycxx . . $ Intensity# me, double tmin, double tmax, int averagingMethod) {
118 return
119 averagingMethod == Intensity_averaging_MEDIANcxx . . $ `fon/Intensity.h:64:9`! ?
120 Intensity_getQuantilecxx . . $ Intensity_getQuantile(86232bf584732d8f). (me, tmin, tmax, 0.50) :
121 Sampled_getMean_standardUnitcxx . . $ Sampled_getMean_standardUnit(2a8b0d40a92e6734). (me, tmin, tmax, 0, averagingMethod, true);
122 }
123
124 /* End of file Intensity.cpp */