Debian Codegraph @

LPC/Cepstrum.cpp

raw symbols SCIP
1 /* Cepstrum.cpp
2 *
3 * Copyright (C) 1994-2020 David Weenink
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. 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 work. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 /*
20 djmw 20010514
21 djmw 20020812 GPL header
22 djmw 20080122 Version 1: float -> double
23 djmw 20110304 Thing_new
24 */
25
26 #include "Cepstrum.h"cxx . . $ `<file>/LPC/Cepstrum.h`/
27 #include "NUM2.h"cxx . . $ `<file>/dwsys/NUM2.h`/
28 #include "Vector.h"cxx . . $ `<file>/fon/Vector.h`/
29
30 #include "enums_getText.h"cxx . . $ `<file>/melder/enums_getText.h`/
31 #include "Cepstrum_enums.h"cxx . . $ `<file>/LPC/Cepstrum_enums.h`/
32 #include "enums_getValue.h"cxx . . $ `<file>/melder/enums_getValue.h`/
33 #include "Cepstrum_enums.h"cxx . . $ `<file>/LPC/Cepstrum_enums.h`/
34
35 Thing_implementcxx . . $ `sys/Thing.h:65:9`! (Cepstrum, Matrix, 2);
36
37 double structCepstrumcxx . . $ structCepstrum# :: v_getValueAtSamplecxx . . $ structCepstrum#v_getValueAtSample(8bbfc6ce471470c9). (integercxx . . $ integer# isamp, integercxx . . $ integer# which, int units) const {
38 if (which == 1) {
39 if (units == 0)
40 return zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).isamp];
41 else
42 return 20.0 * log10cxx . . $ log10(fee4f1d22bc8e617). (fabscxx . . $ fabs(fee4f1d22bc8e617). (zcxx . . $ structMatrix#z. [cxx . . $ automatrix#`operator[]`(2d545b3cb3f8e666).1] [cxx . . $ vector#`operator[]`(8a4599b8835d1ce1).isamp]) + 1e-30); // dB's
43 }
44 return undefinedcxx . . $ undefined.;
45 }
46
47 autoCepstrumcxx . . $ autoCepstrum# Cepstrum_createcxx . . $ Cepstrum_create(2cbed51e64e74b54). (double qmax, integercxx . . $ integer# nq) {
48 try {
49 autoCepstrumcxx . . $ autoCepstrum# me = Thing_newcxx . . $ `sys/Thing.h:514:9`! (Cepstrum);
50 double dq = qmax / (nq - 1);
51
52 Matrix_initcxx . . $ Matrix_init(9dd6c49f9830a091). (me.getcxx . . $ autoSomeThing#get(34d6acfd341ba7ab).(), 0.0, qmax, nq, dq, 0.0, 1.0, 1.0, 1, 1, 1.0);
53 return mecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
54 } catch (MelderErrorcxx . . $ MelderError#) {
55 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (U"Cepstrum not created.");
56 }
57 }
58
59 void Cepstrum_drawcxx . . $ Cepstrum_draw(9dd6d8709e60e29f). (constCepstrumcxx . . $ constCepstrum# me, Graphicscxx . . $ Graphics# g, double qmin, double qmax, double minimum, double maximum, bool power, bool garnish) {
60 Graphics_setInnercxx . . $ Graphics_setInner(2d838ed765120c5d). (g);
61
62 if (qmax <= qmin) {
63 qmin = mycxx . . $ `melder/melder.h:44:9`! xmincxx . . $ structFunction#xmin.;
64 qmax = mycxx . . $ `melder/melder.h:44:9`! xmaxcxx . . $ structFunction#xmax.;
65 }
66
67 integercxx . . $ integer# imin, imax;
68 integercxx . . $ integer# numberOfSelected = Matrix_getWindowSamplesXcxx . . $ Matrix_getWindowSamplesX(c738979be11bd51a). (me, qmin, qmax, & imin, & imax);
69 if (numberOfSelected == 0)
70 return;
71 autoVECcxx . . $ autoVEC# y = raw_VECcxx . . $ raw_VEC(e4395f764b859b1e). (numberOfSelected);
72 for (integercxx . . $ integer# i = 1; i <= numberOfSelected; i ++)
73 y [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = mycxx . . $ `melder/melder.h:44:9`! v_getValueAtSamplecxx . . $ structCepstrum#v_getValueAtSample(8bbfc6ce471470c9). (imin + i - 1, 1, (power ? 1 : 0));
74
75 if (minimum >= maximum) // autoscaling
76 NUMextrema_ucxx . . $ NUMextrema_u(9aff78012e48d2eb). (ycxx . . $ constvectorview#constvectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), & minimum, & maximum);
77 else
78 VECclip_inplacecxx . . $ VECclip_inplace(c22bf7a6e3d33143). (minimum, ycxx . . $ vectorview#vectorview(eac9d6ec4c4bfecd)..getcxx . . $ autovector#get(e8d1da7fe68a6585).(), maximum);
79 if (isundefcxx . . $ isundef(f8197d536af80c96). (minimum) || isundefcxx . . $ isundef(f8197d536af80c96). (maximum))
80 return;
81 if (maximum == minimum) {
82 maximum += 1.0;
83 minimum -= 1.0;
84 }
85 Graphics_setWindowcxx . . $ Graphics_setWindow(72bdb7937dbb13da). (g, qmin, qmax, minimum, maximum);
86 Graphics_functioncxx . . $ Graphics_function(1c6279e2c8b8beb1). (g, y.asArgumentToFunctionThatExpectsOneBasedArraycxx . . $ autovector#asArgumentToFunctionThatExpectsOneBasedArray(5a2a78a048fb49a8).(), 1, numberOfSelected, Matrix_columnToXcxx . . $ Matrix_columnToX(89d6d8659270b8b7). (me, imin), Matrix_columnToXcxx . . $ Matrix_columnToX(89d6d8659270b8b7). (me, imax));
87
88 Graphics_unsetInnercxx . . $ Graphics_unsetInner(2d838ed765120c5d). (g);
89
90 if (garnish) {
91 Graphics_drawInnerBoxcxx . . $ Graphics_drawInnerBox(2d838ed765120c5d). (g);
92 Graphics_textBottomcxx . . $ Graphics_textBottom(48cf1f690ec61203). (g, true, U"Quefrency (s)");
93 Graphics_marksBottomcxx . . $ Graphics_marksBottom(c3a11a8a55b243ff). (g, 2, true, true, false);
94 Graphics_textLeftcxx . . $ Graphics_textLeft(48cf1f690ec61203). (g, true, power ? U"Amplitude (dB)" : U"Amplitude");
95 Graphics_marksLeftcxx . . $ Graphics_marksLeft(c3a11a8a55b243ff). (g, 2, true, true, false);
96 }
97 }
98
99 void Cepstrum_drawLinearcxx . . $ Cepstrum_drawLinear(35b3d44e8fc06ab8). (constCepstrumcxx . . $ constCepstrum# me, Graphicscxx . . $ Graphics# g, double qmin, double qmax, double minimum, double maximum, bool garnish) {
100 Cepstrum_drawcxx . . $ Cepstrum_draw(9dd6d8709e60e29f). (me, g, qmin, qmax, minimum, maximum, false, garnish);
101 }
102
103 /* End of file Cepstrum.cpp */