Debian Codegraph @

dwtools/DTW.h

raw symbols SCIP
1 #ifndef _DTW_h_
2 #define _DTW_h_
3 /* DTW.h
4 *
5 * Copyright (C) 1993-2017 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 /*
22 djmw 20020813 GPL header
23 djmw 20110306 Latest modification.
24 */
25
26 #include "Spectrogram.h"
27 #include "Polygon_extensions.h"
28 #include "Pitch.h"
29 #include "DurationTier.h"
30 #include "Sound.h"
31
32 #include "DTW_def.h"
33
34 #define DTW_SAKOECHIBA 1
35 #define DTW_SLOPES 2
36
37 #define DTW_UNREACHABLE -1
38 #define DTW_FORBIDDEN -2
39 #define DTW_START 3
40 #define DTW_XANDY 2
41 #define DTW_X 4
42 #define DTW_Y 6
43
44 void DTW_Path_Query_init (DTW_Path_Query me, integer ny, integer nx);
45
46 /* Prototype on y-axis and test on x-axis */
47 autoDTW DTW_create (double tminp, double tmaxp, integer ntp, double dtp, double t1p,
48 double tminc, double tmaxc, integer ntc, double dtc, double t1c);
49
50 void DTW_setWeights (DTW me, double wx, double wy, double wd);
51
52 autoDTW DTW_swapAxes (DTW me);
53
54 void DTW_findPath_bandAndSlope (DTW me, double sakoeChibaBand, int localSlope, autoMatrix *cumulativeDists);
55
56 void DTW_findPath (DTW me, bool matchStart, bool matchEnd, int slope); // deprecated
57 /* Obsolete
58 Function:
59 Calculate the minimum path (through a distance matrix).
60
61 Possible constraints:
62
63 matchStart: path starts at position (1,1) (bottom-left)
64 matchEnd: path ends at (I,J) (top-right)
65 slope: 1 no constraints
66 2 1/3 < slope < 3
67 3 1/2 < slope < 2
68 4 2/3 < slope < 3/2
69
70 For algorithm and DP-equations see the article (& especially table I) in:
71 Sakoe, H. & Chiba, S. (1978), Dynamic Programming Algorithm Optimization
72 for Spoken Word recognition, IEEE Trans. on ASSP, vol 26, 43-49.
73 */
74
75 void DTW_Path_recode (DTW me);
76
77 double DTW_getYTimeFromXTime (DTW me, double tx);
78
79 double DTW_getXTimeFromYTime (DTW me, double ty);
80
81 double DTW_getPathY (DTW me, double tx);
82
83 integer DTW_getMaximumConsecutiveSteps (DTW me, int direction);
84
85 void DTW_paintDistances (DTW me, Graphics g, double xmin, double xmax, double ymin,
86 double ymax, double minimum, double maximum, bool garnish);
87
88 void DTW_drawPath (DTW me, Graphics g, double xmin, double xmax, double ymin,
89 double ymax, bool garnish);
90
91 void DTW_drawWarpX (DTW me, Graphics g, double xmin, double xmax, double ymin, double ymax, double tx, bool garnish);
92 void DTW_drawWarpY (DTW me, Graphics g, double xmin, double xmax, double ymin, double ymax, double ty, bool garnish);
93
94 void DTW_pathRemoveRedundantNodes (DTW me);
95
96 void DTW_pathQueryRecode (DTW me);
97
98 void DTW_drawDistancesAlongPath (DTW me, Graphics g, double xmin, double xmax, double dmin, double dmax, bool garnish);
99
100 void DTW_Sounds_draw (DTW me, Sound yy, Sound xx, Graphics g, double xmin, double xmax,
101 double ymin, double ymax, bool garnish);
102
103 void DTW_Sounds_drawWarpX (DTW me, Sound yy, Sound xx, Graphics g, double xmin, double xmax,
104 double ymin, double ymax, double tx, bool garnish);
105
106 autoPolygon DTW_to_Polygon (DTW me, double band, int slope);
107
108 void DTW_Polygon_findPathInside (DTW me, Polygon thee, int localSlope, autoMatrix *cumulativeDists);
109
110 autoMatrix DTW_to_Matrix_distances (DTW me);
111
112 autoMatrix DTW_to_Matrix_cumulativeDistances (DTW me, double sakoeChibaBand, int slope);
113
114 autoMatrix DTW_Polygon_to_Matrix_cumulativeDistances (DTW me, Polygon thee, int localSlope);
115
116 autoDTW Matrices_to_DTW (Matrix me, Matrix thee, bool matchStart, bool matchEnd, int slope, double metric);
117
118 autoDTW Spectrograms_to_DTW (Spectrogram me, Spectrogram thee, bool matchStart, bool matchEnd, int slope, double metric);
119
120 autoDTW Pitches_to_DTW (Pitch me, Pitch thee, double vuv_costs, double time_weight, bool matchStart, bool matchEnd, int slope);
121
122 autoDurationTier DTW_to_DurationTier (DTW me);
123
124 void DTW_Matrix_replace (DTW me, Matrix thee);
125
126 #endif /* _DTW_h_ */