Debian Codegraph @

LPC/PowerCepstrumWorkspace.h

raw
1 #ifndef _PowerCepstrumWorkspace_h_
2 #define _PowerCepstrumWorkspace_h_
3 /* PowerCepstrumWorkspace_def.h
4 *
5 * Copyright (C) 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 3 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 "PowerCepstrum.h"
22 #include "SlopeSelector.h"
23
24 Thing_define (PowerCepstrumWorkspace, Thing) {
25
26 /*
27 To do some of the calculations efficiently we use a Workspace that maintains state.
28 */
29 constPowerCepstrum powerCepstrum;
30 integer numberOfPoints = 0;
31 integer imin, imax; // [imin,imax] the slope calculation interval
32 autoVEC x, y; // numberOfPoints (in dB's)
33 autoMatrix asdBs; // for peak detection
34 autoSlopeSelector slopeSelector;
35 bool slopeKnown = false, peakKnown = false, trendSubtracted = false;
36 kSlopeSelector_method method;
37 kCepstrum_trendType trendLineType;
38 kVector_peakInterpolation peakInterpolationType = kVector_peakInterpolation :: PARABOLIC;
39 double qminPeakSearch, qmaxPeakSearch; // peak in [pitchFloor, pitchCeiling]
40 double slope, intercept;
41 double cpp; // = peakdB - trenddB
42 double trenddB, peakdB;
43 double peakQuefrency;
44 integer maximumNumberOfRhamonics, numberOfRhamonics;
45 autoMAT rhamonics; // maximumNumberOfRhamonics x 5: power, q1, q, q2, amplitude
46
47 void initWorkspace (constPowerCepstrum me, double qminFit, double qmaxFit, kCepstrum_trendType trendLineType, kCepstrum_trendFit method);
48
49 void initPeakSearchPart (double qminPeakSearch, double qmaxPeakSearch, kVector_peakInterpolation peakInterpolationType);
50
51 void newData (constPowerCepstrum thee);
52
53 void getSlopeAndIntercept ();
54
55 void getPeakAndPosition ();
56
57 void subtractTrend ();
58
59 double getTrend (double quefrency);
60
61 void getCPP ();
62
63 void todBs ();
64
65 void fromdBs ();
66
67 void setMaximumNumberOfRhamonics (integer maximumNumberOfRhamonics);
68
69 void getNumberOfRhamonics (double qmin, double qmax);
70
71 void getRhamonicPeaks (double qmin, double qmax);
72
73 void getRhamonicsPower (double qmin, double qmax, double f0fractionalWidth);
74
75 double getRNR (double qmin, double qmax, double f0fractionalWidth);
76
77 };
78
79 autoPowerCepstrumWorkspace PowerCepstrumWorkspace_create (constPowerCepstrum thee, double qminFit, double qmaxFit,
80 kCepstrum_trendType trendLineType, kCepstrum_trendFit method);
81
82 /*void PowerCepstrum_initWorkspace (PowerCepstrum me, double qminFit, double qmaxFit,
83 kCepstrum_trendType trendLineType, kCepstrum_trendFit method);
84
85
86 void PowerCepstrumWorkspace_init (mutablePowerCepstrumWorkspace me, constPowerCepstrum thee, double qminFit, double qmaxFit,
87 kCepstrum_trendType trendLineType, kCepstrum_trendFit method);
88
89 autoPowerCepstrumWorkspace PowerCepstrumWorkspace_create (constPowerCepstrum thee, double qminFit, double qmaxFit,
90 kCepstrum_trendType trendLineType, kCepstrum_trendFit method);
91
92 void PowerCepstrumWorkspace_initPeakSearchPart (mutablePowerCepstrumWorkspace me, double qminPeakSearch,
93 double qmaxPeakSearch, kVector_peakInterpolation peakInterpolationType);
94 */
95
96 #endif /* PowerCepstrumWorkspace_h_ */