Debian Codegraph @

LPC/LineSpectralFrequencies.cpp

raw symbols SCIP
1 /* LineSpectralFrequencies.cpp
2 *
3 * Copyright (C) 2016-2023 David Weenink
4 *
5 * This program 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 3 of the License, or (at
8 * your option) any later version.
9 *
10 * This program 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. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include "LineSpectralFrequencies.h"cxx . . $ `<file>/LPC/LineSpectralFrequencies.h`/
21 #include "NUM2.h"cxx . . $ `<file>/dwsys/NUM2.h`/
22
23 #include "oo_DESTROY.h"cxx . . $ `<file>/sys/oo_DESTROY.h`/
24 #include "LineSpectralFrequencies_def.h"cxx . . $ `<file>/LPC/LineSpectralFrequencies_def.h`/
25 #include "oo_COPY.h"cxx . . $ `<file>/sys/oo_COPY.h`/
26 #include "LineSpectralFrequencies_def.h"cxx . . $ `<file>/LPC/LineSpectralFrequencies_def.h`/
27 #include "oo_EQUAL.h"cxx . . $ `<file>/sys/oo_EQUAL.h`/
28 #include "LineSpectralFrequencies_def.h"cxx . . $ `<file>/LPC/LineSpectralFrequencies_def.h`/
29 #include "oo_CAN_WRITE_AS_ENCODING.h"cxx . . $ `<file>/sys/oo_CAN_WRITE_AS_ENCODING.h`/
30 #include "LineSpectralFrequencies_def.h"cxx . . $ `<file>/LPC/LineSpectralFrequencies_def.h`/
31 #include "oo_WRITE_TEXT.h"cxx . . $ `<file>/sys/oo_WRITE_TEXT.h`/
32 #include "LineSpectralFrequencies_def.h"cxx . . $ `<file>/LPC/LineSpectralFrequencies_def.h`/
33 #include "oo_WRITE_BINARY.h"cxx . . $ `<file>/sys/oo_WRITE_BINARY.h`/
34 #include "LineSpectralFrequencies_def.h"cxx . . $ `<file>/LPC/LineSpectralFrequencies_def.h`/
35 #include "oo_READ_TEXT.h"cxx . . $ `<file>/sys/oo_READ_TEXT.h`/
36 #include "LineSpectralFrequencies_def.h"cxx . . $ `<file>/LPC/LineSpectralFrequencies_def.h`/
37 #include "oo_READ_BINARY.h"cxx . . $ `<file>/sys/oo_READ_BINARY.h`/
38 #include "LineSpectralFrequencies_def.h"cxx . . $ `<file>/LPC/LineSpectralFrequencies_def.h`/
39 #include "oo_DESCRIPTION.h"cxx . . $ `<file>/sys/oo_DESCRIPTION.h`/
40 #include "LineSpectralFrequencies_def.h"cxx . . $ `<file>/LPC/LineSpectralFrequencies_def.h`/
41
42 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (LineSpectralFrequencies, Sampled, 1);
43
44 void structLineSpectralFrequencies :: v1_info () {
45 structDaatacxx . . $ structDaata# :: v1_infocxx . . $ structThing#v1_info(49f6e7a06ebc5aa8). ();
46 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Time domain: ", xmincxx . . $ structFunction#xmin., U" to ", xmaxcxx . . $ structFunction#xmax., U" (s).");
47 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Number of frequencies: ", maximumNumberOfFrequencies);
48 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Number of frames: ", nxcxx . . $ structSampled#nx.);
49 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"Time step: ", dxcxx . . $ structSampled#dx., U" (s).");
50 MelderInfo_writeLinecxx . . $ MelderInfo_writeLine(3eb398314feba58b). (U"First frame at: ", x1cxx . . $ structSampled#x1., U" (s).");
51 }
52
53 void LineSpectralFrequencies_Frame_initcxx . . $ LineSpectralFrequencies_Frame_init(b16022a24ee3fbdc). (LineSpectralFrequencies_Frame me, integercxx . . $ integer# numberOfFrequencies) {
54 mycxx . . $ `melder/melder.h:44:9`! frequencies =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). zero_VECcxx . . $ zero_VEC(e4395f764b859b1e). (numberOfFrequencies);
55 mycxx . . $ `melder/melder.h:44:9`! numberOfFrequencies = numberOfFrequencies;
56 }
57
58 void LineSpectralFrequencies_initcxx . . $ LineSpectralFrequencies_init(c644db288e7ccf7c). (LineSpectralFrequencies me, double tmin, double tmax, integercxx . . $ integer# nt, double dt, double t1, integercxx . . $ integer# numberOfFrequencies, double maximumFrequency) {
59 mycxx . . $ `melder/melder.h:44:9`! maximumFrequency = maximumFrequency;
60 mycxx . . $ `melder/melder.h:44:9`! maximumNumberOfFrequencies = numberOfFrequencies;
61 Sampled_initcxx . . $ Sampled_init(5b6f70c633f31208). (me, tmin, tmax, nt, dt, t1);
62 mycxx . . $ `melder/melder.h:44:9`! d_frames =cxx . . $ autovector#`operator=`(f4f0443dbfdd1e40). newvectorzerocxx . . $ newvectorzero(d6d5973469733409). <structLineSpectralFrequencies_Frame> (nt);
63 }
64
65 autoLineSpectralFrequencies LineSpectralFrequencies_createcxx . . $ LineSpectralFrequencies_create(e0310cab48391c2c). (double tmin, double tmax, integercxx . . $ integer# nt, double dt, double t1, integercxx . . $ integer# numberOfFrequencies, double maximumFrequency) {
66 try {
67 autoLineSpectralFrequencies me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (LineSpectralFrequencies);
68 LineSpectralFrequencies_initcxx . . $ LineSpectralFrequencies_init(c644db288e7ccf7c). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), tmin, tmax, nt, dt, t1, numberOfFrequencies, maximumFrequency);
69 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
70 } catch (MelderErrorcxx . . $ MelderError#) {
71 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"LineSpectralFrequencies not created.");
72 }
73 }
74
75 void LineSpectralFrequencies_drawFrequenciescxx . . $ LineSpectralFrequencies_drawFrequencies(c884bf9331942823). (LineSpectralFrequencies me, Graphicscxx . . $ Graphics# g, double tmin, double tmax, double fmin, double fmax, bool garnish) {
76 Function_unidirectionalAutowindowcxx . . $ Function_unidirectionalAutowindow(88b7840c59a57eaf). (me, & tmin, & tmax);
77 integercxx . . $ integer# itmin, itmax;
78 if (! Sampled_getWindowSamplescxx . . $ Sampled_getWindowSamples(fe99094ed5bb3f6a). (me, tmin, tmax, & itmin, & itmax))
79 return;
80 if (fmax <= fmin) {
81 const integercxx . . $ integer# numberOfSelected = itmax - itmin + 1;
82 autoVECcxx . . $ autoVEC# f1 = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (numberOfSelected);
83 autoVECcxx . . $ autoVEC# f2 = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (numberOfSelected);
84 for (integercxx . . $ integer# iframe = itmin; iframe <= itmax; iframe ++) {
85 f1 [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe - itmin + 1] = mycxx . . $ `melder/melder.h:44:9`! d_frames [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe]. frequencies [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1];
86 f2 [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe - itmin + 1] = mycxx . . $ `melder/melder.h:44:9`! d_frames [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe]. frequencies [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).mycxx . . $ `melder/melder.h:44:9`! d_frames [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe] . numberOfFrequencies];
87 }
88 double f1max, f2min;
89 NUMextrema_ucxx . . $ NUMextrema_u(9aff78012e48d2eb). (f1cxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), & fmin, & f1max);
90 NUMextrema_ucxx . . $ NUMextrema_u(9aff78012e48d2eb). (f2cxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), & f2min, & fmax);
91 }
92 if (isundefcxx . . $ isundef(f8197d536af80c96). (fmin) || isundefcxx . . $ isundef(f8197d536af80c96). (fmax))
93 return;
94 if (fmax == fmin) {
95 fmin = 0.0;
96 fmax += 0.5;
97 }
98
99 Graphics_setInnercxx . . $ Graphics_setInner(2d838ed765120c5d). (g);
100 Graphics_setWindowcxx . . $ Graphics_setWindow(72bdb7937dbb13da). (g, tmin, tmax, fmin, fmax);
101 for (integercxx . . $ integer# iframe = itmin; iframe <= itmax; iframe ++) {
102 const LineSpectralFrequencies_Frame lsf = & mycxx . . $ `melder/melder.h:44:9`! d_frames [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe];
103 const double x = Sampled_indexToXcxx . . $ Sampled_indexToX(65bcd2c9acbb3dd5). (me, iframe);
104 for (integercxx . . $ integer# ifreq = 1; ifreq <= lsf -> numberOfFrequencies; ifreq ++) {
105 const double y = lsf -> frequencies [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).ifreq];
106 if (y >= fmin && y <= fmax)
107 Graphics_specklecxx . . $ Graphics_speckle(c84ba9158791aef6). (g, x, y);
108 }
109 }
110 Graphics_unsetInnercxx . . $ Graphics_unsetInner(2d838ed765120c5d). (g);
111 if (garnish) {
112 Graphics_drawInnerBoxcxx . . $ Graphics_drawInnerBox(2d838ed765120c5d). (g);
113 Graphics_textBottomcxx . . $ Graphics_textBottom(48cf1f690ec61203). (g, true, U"Time (seconds)");
114 Graphics_textLeftcxx . . $ Graphics_textLeft(48cf1f690ec61203). (g, true, U"Frequency (Hz)");
115 Graphics_marksBottomcxx . . $ Graphics_marksBottom(c3a11a8a55b243ff). (g, 2, true, true, false);
116 Graphics_marksLeftcxx . . $ Graphics_marksLeft(c3a11a8a55b243ff). (g, 2, true, true, false);
117 }
118 }
119
120 autoMatrixcxx . . $ autoMatrix# LineSpectralFrequencies_downto_Matrixcxx . . $ LineSpectralFrequencies_downto_Matrix(26532d3b0576dd26). (LineSpectralFrequencies me) {
121 try {
122 autoMatrixcxx . . $ autoMatrix# thee = Matrix_createcxx . . $ Matrix_create(494a3ae9ff7e3b60). (mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin., mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax., mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx., mycxx . . $ `melder/melder.h:44:9`! dxcxx . . $ structSampled#dx., mycxx . . $ `melder/melder.h:44:9`! x1cxx . . $ structSampled#x1., 0.5, 0.5 + mycxx . . $ `melder/melder.h:44:9`! maximumNumberOfFrequencies, mycxx . . $ `melder/melder.h:44:9`! maximumNumberOfFrequencies, 1.0, 1.0);
123 for (integercxx . . $ integer# j = 1; j <= mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.; j ++) {
124 const LineSpectralFrequencies_Frame lsf = & mycxx . . $ `melder/melder.h:44:9`! d_frames [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).j];
125 thycxx . . $ `melder/melder.h:45:9`! zcxx . . $ structMatrix#z..columncxx . . $ automatrix#column(a8b9553e85c2b1fc). (j).partcxx . . $ vectorview#part(fd45ed87dd839590). (1, lsf -> numberOfFrequencies) <<=cxx . . $ `operator<<=`(adea042513329390). lsfcxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd). -> frequencies.getcxx . . $ autovector#get(e8d1da7fe68a6585).();
126 }
127 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
128 } catch (MelderErrorcxx . . $ MelderError#) {
129 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Matrix with linear prediction coefficients created.");
130 }
131 }
132
133 /* End of file LineSpectralFrequencies.cpp */