Debian Codegraph @

LPC/LPC_and_Cepstrumc.cpp

raw symbols SCIP
1 /* LPC_and_Cepstrumc.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 20020812 GPL header
21 djmw 20080122 float -> double
22 */
23
24 #include "LPC_and_Cepstrumc.h"cxx . . $ `<file>/LPC/LPC_and_Cepstrumc.h`/
25
26 void LPC_Frame_into_Cepstrumc_Framecxx . . $ LPC_Frame_into_Cepstrumc_Frame(c4d3ad67d86fd65e). (LPC_Framecxx . . $ LPC_Frame# me, Cepstrumc_Framecxx . . $ Cepstrumc_Frame# thee) {
27 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! nCoefficients == mycxx . . $ `melder/melder.h:44:9`! a.size); // check invariant
28 thycxx . . $ `melder/melder.h:45:9`! ccxx . . $ structCepstrumc_Frame#c..resizecxx . . $ autovector#resize(d91e89fbd57cd1). (mycxx . . $ `melder/melder.h:44:9`! nCoefficientscxx . . $ structLPC_Frame#nCoefficients.);
29 thycxx . . $ `melder/melder.h:45:9`! nCoefficientscxx . . $ structCepstrumc_Frame#nCoefficients. = thycxx . . $ `melder/melder.h:45:9`! ccxx . . $ structCepstrumc_Frame#c..sizecxx . . $ autovector#size.; // maintain invariant
30 thycxx . . $ `melder/melder.h:45:9`! c0cxx . . $ structCepstrumc_Frame#c0. = 0.5 * logcxx . . $ log(fee4f1d22bc8e617). (mycxx . . $ `melder/melder.h:44:9`! gaincxx . . $ structLPC_Frame#gain.);
31 if (mycxx . . $ `melder/melder.h:44:9`! nCoefficientscxx . . $ structLPC_Frame#nCoefficients. == 0)
32 return;
33 thycxx . . $ `melder/melder.h:45:9`! ccxx . . $ structCepstrumc_Frame#c. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1] = - mycxx . . $ `melder/melder.h:44:9`! acxx . . $ structLPC_Frame#a. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1];
34 for (integercxx . . $ integer# i = 2; i <= mycxx . . $ `melder/melder.h:44:9`! nCoefficientscxx . . $ structLPC_Frame#nCoefficients.; i ++) {
35 thycxx . . $ `melder/melder.h:45:9`! ccxx . . $ structCepstrumc_Frame#c. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = 0.0;
36 for (integercxx . . $ integer# k = 1; k < i; k ++)
37 thycxx . . $ `melder/melder.h:45:9`! ccxx . . $ structCepstrumc_Frame#c. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] += mycxx . . $ `melder/melder.h:44:9`! acxx . . $ structLPC_Frame#a. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i - k] * thycxx . . $ `melder/melder.h:45:9`! ccxx . . $ structCepstrumc_Frame#c. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).k] * k;
38 thycxx . . $ `melder/melder.h:45:9`! ccxx . . $ structCepstrumc_Frame#c. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = - mycxx . . $ `melder/melder.h:44:9`! acxx . . $ structLPC_Frame#a. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] - thycxx . . $ `melder/melder.h:45:9`! ccxx . . $ structCepstrumc_Frame#c. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] / i;
39 }
40 }
41
42 void Cepstrumc_Frame_into_LPC_Framecxx . . $ Cepstrumc_Frame_into_LPC_Frame(90bbd1976fcd57fa). (Cepstrumc_Framecxx . . $ Cepstrumc_Frame# me, LPC_Framecxx . . $ LPC_Frame# thee) {
43 Melder_assertcxx . . $ `melder/melder_assert.h:39:10`! (mycxx . . $ `melder/melder.h:44:9`! nCoefficients == mycxx . . $ `melder/melder.h:44:9`! c.size); // Check invariant
44 thycxx . . $ `melder/melder.h:45:9`! acxx . . $ structLPC_Frame#a..resizecxx . . $ autovector#resize(d91e89fbd57cd1). (mycxx . . $ `melder/melder.h:44:9`! nCoefficientscxx . . $ structCepstrumc_Frame#nCoefficients.);
45 thycxx . . $ `melder/melder.h:45:9`! nCoefficientscxx . . $ structLPC_Frame#nCoefficients. = thycxx . . $ `melder/melder.h:45:9`! acxx . . $ structLPC_Frame#a..sizecxx . . $ autovector#size.; // maintain invariant
46 thycxx . . $ `melder/melder.h:45:9`! gaincxx . . $ structLPC_Frame#gain. = expcxx . . $ exp(fee4f1d22bc8e617). (2.0 * mycxx . . $ `melder/melder.h:44:9`! c0cxx . . $ structCepstrumc_Frame#c0.);
47 if (thycxx . . $ `melder/melder.h:45:9`! nCoefficientscxx . . $ structLPC_Frame#nCoefficients. == 0)
48 return;
49 thycxx . . $ `melder/melder.h:45:9`! acxx . . $ structLPC_Frame#a. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1] = - mycxx . . $ `melder/melder.h:44:9`! ccxx . . $ structCepstrumc_Frame#c. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).1];
50 for (integercxx . . $ integer# i = 2; i <= thycxx . . $ `melder/melder.h:45:9`! nCoefficientscxx . . $ structLPC_Frame#nCoefficients.; i ++)
51 mycxx . . $ `melder/melder.h:44:9`! ccxx . . $ structCepstrumc_Frame#c. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] *= i;
52 for (integercxx . . $ integer# i = 2; i <= thycxx . . $ `melder/melder.h:45:9`! nCoefficientscxx . . $ structLPC_Frame#nCoefficients.; i ++) {
53 thycxx . . $ `melder/melder.h:45:9`! acxx . . $ structLPC_Frame#a. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] = mycxx . . $ `melder/melder.h:44:9`! ccxx . . $ structCepstrumc_Frame#c. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i];
54 for (integercxx . . $ integer# j = 1 ; j < i; j ++)
55 thycxx . . $ `melder/melder.h:45:9`! acxx . . $ structLPC_Frame#a. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] += thycxx . . $ `melder/melder.h:45:9`! acxx . . $ structLPC_Frame#a. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).j] * mycxx . . $ `melder/melder.h:44:9`! ccxx . . $ structCepstrumc_Frame#c. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i - j];
56 thycxx . . $ `melder/melder.h:45:9`! acxx . . $ structLPC_Frame#a. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] /= -i;
57 }
58 /*
59 Undo the modification of the c array
60 */
61 for (integercxx . . $ integer# i = 2; i <= thycxx . . $ `melder/melder.h:45:9`! nCoefficientscxx . . $ structLPC_Frame#nCoefficients.; i ++)
62 mycxx . . $ `melder/melder.h:44:9`! ccxx . . $ structCepstrumc_Frame#c. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i] /= i;
63 }
64
65 autoCepstrumccxx . . $ autoCepstrumc# LPC_to_Cepstrumccxx . . $ LPC_to_Cepstrumc(da5fdc37e9ffcb76). (LPCcxx . . $ LPC# me) {
66 try {
67 autoCepstrumccxx . . $ autoCepstrumc# thee = Cepstrumc_createcxx . . $ Cepstrumc_create(3ada163742ca27ec). (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., mycxx . . $ `melder/melder.h:44:9`! maxnCoefficientscxx . . $ structLPC#maxnCoefficients., 1.0 / mycxx . . $ `melder/melder.h:44:9`! samplingPeriodcxx . . $ structLPC#samplingPeriod.);
68 for (integercxx . . $ integer# iframe = 1; iframe <= mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.; iframe ++) {
69 Cepstrumc_Frame_initcxx . . $ Cepstrumc_Frame_init(b4d5f83352c0fd7d). (& thycxx . . $ `melder/melder.h:45:9`! framecxx . . $ structCepstrumc#frame. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe], mycxx . . $ `melder/melder.h:44:9`! d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe]. nCoefficientscxx . . $ structLPC_Frame#nCoefficients.);
70 LPC_Frame_into_Cepstrumc_Framecxx . . $ LPC_Frame_into_Cepstrumc_Frame(c4d3ad67d86fd65e). (& mycxx . . $ `melder/melder.h:44:9`! d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe], & thycxx . . $ `melder/melder.h:45:9`! framecxx . . $ structCepstrumc#frame. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).iframe]);
71 }
72 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
73 } catch (MelderErrorcxx . . $ MelderError#) {
74 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U": no Cepstrum created.");
75 }
76 }
77
78 autoLPCcxx . . $ autoLPC# Cepstrumc_to_LPCcxx . . $ Cepstrumc_to_LPC(2575c8b306c6d22). (Cepstrumccxx . . $ Cepstrumc# me) {
79 try {
80 autoLPCcxx . . $ autoLPC# thee = LPC_createcxx . . $ LPC_create(dee197ba90f07c69). (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., mycxx . . $ `melder/melder.h:44:9`! maxnCoefficientscxx . . $ structCepstrumc#maxnCoefficients., 1.0 / mycxx . . $ `melder/melder.h:44:9`! samplingFrequencycxx . . $ structCepstrumc#samplingFrequency.);
81 for (integercxx . . $ integer# i = 1; i <= mycxx . . $ `melder/melder.h:44:9`! nxcxx . . $ structSampled#nx.; i ++) {
82 LPC_Frame_initcxx . . $ LPC_Frame_init(36b24d3ac8bf631d). (& thycxx . . $ `melder/melder.h:45:9`! d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i], mycxx . . $ `melder/melder.h:44:9`! framecxx . . $ structCepstrumc#frame. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i].nCoefficientscxx . . $ structCepstrumc_Frame#nCoefficients.);
83 Cepstrumc_Frame_into_LPC_Framecxx . . $ Cepstrumc_Frame_into_LPC_Frame(90bbd1976fcd57fa). (& mycxx . . $ `melder/melder.h:44:9`! framecxx . . $ structCepstrumc#frame. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i], & thycxx . . $ `melder/melder.h:45:9`! d_framescxx . . $ structLPC#d_frames. [cxx . . $ autovector#`operator[]`(8a4599b8835d1ce1).i]);
84 }
85 return theecxx . . $ autoSomeThing#autoSomeThing(b79141a71f7bc86f).;
86 } catch (MelderErrorcxx . . $ MelderError#) {
87 Melder_throwcxx . . $ `melder/melder_error.h:77:9`! (me, U":no LPC created.");
88 }
89 }
90
91 /* End of file LPC_and_Cepstrumc.cpp */