Debian Codegraph @

LPC/PowerCepstrum.h

raw
1 #ifndef _PowerCepstrum_h_
2 #define _PowerCepstrum_h_
3 /* PowerCepstrum.h
4 *
5 * Copyright (C) 2012-2025 David Weenink
6 *
7 * This code is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 *
12 * This code is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this work. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "Cepstrum.h"
22 #include "Matrix.h"
23 #include "Vector.h"
24
25 /*
26 The PowerCepstrum is a sequence of real numbers.
27 It is the power spectrum of the power spectrum of a (sound) signal.
28
29 xmin // Lowest quefrency.
30 xmax // Highest quefrency.
31 nx // Number of quefrencies.
32 dx // Quefrency step.
33 x1 // First quefrency.
34
35 ymin = ymax = dy = y1 = 1
36 ny = 1
37 */
38
39 Thing_define (PowerCepstrum, Cepstrum) {
40
41 double v_getValueAtSample (integer isamp, integer which, int units) const
42 override;
43
44 };
45
46 void PowerCepstrum_initWorkspace (PowerCepstrum me, double qminFit, double qmaxFit,
47 kCepstrum_trendType trendLineType, kCepstrum_trendFit method);
48
49
50 autoPowerCepstrum PowerCepstrum_create (double qmax, integer nq);
51 /* Preconditions:
52 nq >= 2;
53 Postconditions:
54 my xmin == 0; my ymin == 1;
55 my xmax == qmax; my ymax == 1;
56 my nx == nq; my ny == 1;
57 my dx == qmax / (nq -1); my dy == 1;
58 my x1 == 0.0; my y1 == 1.0;
59 my z [1..ny] [1..nx] == 0.0;
60 */
61
62 void PowerCepstrum_draw (constPowerCepstrum me, Graphics g, double qmin, double qmax, double dBminimum, double dBmaximum, bool garnish);
63
64 integer PowerCepstrum_getPointRange (PowerCepstrum me, double qmin, double qmax, integer& imin, integer& imax);
65 void PowerCepstrum_getPoints (PowerCepstrum me, integer imin, integer imax, VEC x, VEC y);
66
67
68 void PowerCepstrum_drawTrendLine (PowerCepstrum me, Graphics g, double qmin, double qmax, double dBminimum, double dBmaximum, double qstart, double qend, kCepstrum_trendType lineType, kCepstrum_trendFit method);
69 /*
70 Function:
71 Draw a Cepstrum
72 Preconditions:
73 maximum > minimum;
74 Arguments:
75 [qmin, qmax]: quefrencies; x domain of drawing;
76 Autowindowing: if qmax <= qmin, x domain of drawing is
77 [my xmin, my xmax].
78 [minimum, maximum]: amplitude; y range of drawing.
79 */
80
81 void PowerCepstrum_getMaximumAndQuefrency_pitch (PowerCepstrum me, double pitchFloor, double pitchCeiling, kVector_peakInterpolation peakInterpolationType, double& maximum, double& quefrency); // deprecated, too many options for interpolation type.
82
83 void PowerCepstrum_getMaximumAndQuefrency_q (PowerCepstrum me, double fromQuefrency, double toQuefrency,
84 kCepstrum_peakInterpolation peakInterpolationType, double& peakdB, double& quefrency);
85
86 // The standard of Hillenbrand with fitting options
87 double PowerCepstrum_getPeakProminence_hillenbrand (PowerCepstrum me, double pitchFloor, double pitchCeiling, double& qpeak);
88
89 double PowerCepstrum_getRNR (PowerCepstrum me, double pitchFloor, double pitchCeiling, double f0fractionalWidth);
90
91 autoTable PowerCepstrum_tabulateRhamonics (PowerCepstrum me, double pitchFloor, double pitchCeiling, kVector_peakInterpolation peakInterpolationType);
92 /*
93 column 1: quefrency
94 column 2: power at quefrency
95 */
96
97 double PowerCepstrum_getPeakProminence (PowerCepstrum me, double pitchFloor, double pitchCeiling, kVector_peakInterpolation peakInterpolationType, double qstartFit, double qendFit, kCepstrum_trendType lineType, kCepstrum_trendFit fitMethod, double& qpeak);
98
99 void PowerCepstrum_fitTrendLine (PowerCepstrum me, double qmin, double qmax, double *out_slope, double *out_intercept, kCepstrum_trendType lineType, kCepstrum_trendFit method);
100
101 double PowerCepstrum_getTrendLineValue (PowerCepstrum me, double quefrency, double qstartFit, double qendFit, kCepstrum_trendType lineType, kCepstrum_trendFit fitMethod);
102
103 autoPowerCepstrum PowerCepstrum_subtractTrend (constPowerCepstrum me, double qstartFit, double qendFit, kCepstrum_trendType lineType, kCepstrum_trendFit fitMethod);
104
105 void PowerCepstrum_subtractTrend_inplace (mutablePowerCepstrum me, double qstartFit, double qendFit, kCepstrum_trendType lineType, kCepstrum_trendFit fitMethod);
106
107 void PowerCepstrum_smooth_inplace (mutablePowerCepstrum me, double quefrencyAveragingWindow, integer numberOfIterations);
108
109 autoPowerCepstrum PowerCepstrum_smooth (constPowerCepstrum me, double quefrencyAveragingWindow, integer numberOfIterations);
110
111 autoMatrix PowerCepstrum_to_Matrix (constPowerCepstrum me);
112
113 autoPowerCepstrum Matrix_to_PowerCepstrum (constMatrix me);
114
115 autoPowerCepstrum Matrix_to_PowerCepstrum_row (constMatrix me, integer row);
116
117 autoPowerCepstrum Matrix_to_PowerCepstrum_column (constMatrix me, integer col);
118
119 autoPowerCepstrum Cepstrum_downto_PowerCepstrum (constCepstrum me);
120
121 #endif /* _PowerCepstrum_h_ */