Edinburgh Speech Tools 2.4-release
EST_ChannelType.h
1 /************************************************************************/
2 /* */
3 /* Centre for Speech Technology Research */
4 /* University of Edinburgh, UK */
5 /* Copyright (c) 1996,1997 */
6 /* All Rights Reserved. */
7 /* */
8 /* Permission is hereby granted, free of charge, to use and distribute */
9 /* this software and its documentation without restriction, including */
10 /* without limitation the rights to use, copy, modify, merge, publish, */
11 /* distribute, sublicense, and/or sell copies of this work, and to */
12 /* permit persons to whom this work is furnished to do so, subject to */
13 /* the following conditions: */
14 /* 1. The code must retain the above copyright notice, this list of */
15 /* conditions and the following disclaimer. */
16 /* 2. Any modifications must be clearly marked as such. */
17 /* 3. Original authors' names are not deleted. */
18 /* 4. The authors' names are not used to endorse or promote products */
19 /* derived from this software without specific prior written */
20 /* permission. */
21 /* */
22 /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23 /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24 /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25 /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26 /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27 /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28 /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29 /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30 /* THIS SOFTWARE. */
31 /* */
32 /************************************************************************/
33
34#ifndef __EST_CHANNELTYPE_H__
35#define __EST_CHANNELTYPE_H__
36
37/**@name Channel Types
38 */
39//@{
40
41/** Symbolic names for coefficient types.
42 *
43 * Used to record what kinds of information are in a track and
44 * anywhere else we need to refer to coefficient types.
45 *
46 * @see EST_ChannelType
47 */
48
49enum EST_CoefficientType
50{
51 /// Linear prediction filter
52 cot_lpc=0,
53 /// guaranteed to be the first known type
54 cot_first=cot_lpc,
55 /// reflection coefficients.
56 cot_reflection,
57 /// Cepstral coefficients
58 cot_cepstrum,
59 /// Mel Scale Cepstrum
60 cot_melcepstrum,
61 /// Mel Scale filter bank
62 cot_fbank,
63 /// Line spectral pairs.
64 cot_lsf,
65 /// Tube areas for filter.
66 cot_tubearea,
67 /// Unknown filter type.
68 cot_filter,
69 /// Free for experimentation
70 cot_user1,
71 /// Free for experimentation
72 cot_user2,
73 /// Guaranteed to be one more than last legal coefficient type
74 cot_free
75};
76
77/**@name Channel Type Numbering Scheme
78 *
79 * Channel types are given numbers containing the following information:
80 * \begin{itemize}
81 * \item A numeric index.
82 * \item A Number of differentiations 0-2
83 * \item 0 for start, 1 for end
84 * \end{itemize}
85 * Things which do not require all these features are packed in according
86 * to the following rules:
87 * \begin{itemize}
88 * \item Single values which can be differentiated are paired as
89 * if they were start and end positions of an unknown type
90 * of coefficient.
91 * \item Single values which can't be differentiated are put in the
92 * positions where the 3rd derivatives would logically be
93 * found.
94 * \end{itemize}
95 */
96//@{
97
98/// extract the coefficient type
99#define EST_ChannelTypeCT(T) ( (T) >> 3 )
100/// extract the number of differentiations
101#define EST_ChannelTypeD(T) ( (T) >> 1 & 3 )
102/// extract the start/end flag.
103#define EST_ChannelTypeSE(T) ( (T) & 1 )
104
105/// get start from end
106#define EST_ChannelTypeStart(T) EST_CoefChannelId(\
107 EST_ChannelTypeCT(T), \
108 EST_ChannelTypeD(T), \
109 0)
110/// get end from start
111#define EST_ChannelTypeEnd(T) EST_CoefChannelId(\
112 EST_ChannelTypeCT(T), \
113 EST_ChannelTypeD(T), \
114 1)
115/// differentiate once
116#define EST_ChannelTypeIncD(T) EST_CoefChannelId(\
117 EST_ChannelTypeCT(T), \
118 EST_ChannelTypeD(T)+1, \
119 EST_ChannelTypeSE(T))
120/// differentiate N times
121#define EST_ChannelTypeDelta(T, N) EST_CoefChannelId(\
122 EST_ChannelTypeCT(T), \
123 EST_ChannelTypeD(T)+(N), \
124 EST_ChannelTypeSE(T))
125/// integrate once
126#define EST_ChannelTypeDecD(T) EST_CoefChannelId(\
127 EST_ChannelTypeCT(T), \
128 EST_ChannelTypeD(T)-1, \
129 EST_ChannelTypeSE(T))
130
131
132/** Build a number representing a channel type for a coefficient type.
133 *
134 * CT = coefficient type
135 * D = Number of levels of differentiation.
136 * SE = Start=0 end=1
137 */
138#define EST_CoefChannelId(CT,D,SE) ( (CT)<<3 | ((D)<<1 & 6) | ((SE)&1) )
139
140/** Build a number representing a channel type for a single value which can
141 * N = count starting from 0
142 * D = Number of levels of differentiation.
143 * be differentiated.
144 */
145
146#define EST_DiffChannelId(N,D) ( EST_CoefChannelId(((N)>>1)+(int)cot_free, D, (N)&1) )
147
148/** Build a number representing a channel type for a simple value
149 * such as length or voicing probability.
150 */
151
152#define EST_ChannelId(N) EST_CoefChannelId((N)>>1, 3, (N)&1)
153//@}
154
155
156/** Symbolic names for track channels.
157 * Used in track maps to label channels so they can be accessed without
158 * knowing exactly where in the track they are.
159 *
160 * @see EST_CoefficientType
161 * @see EST_TrackMap
162 * @see EST_Track
163 * @see EST_TrackMap:example
164 * @author Richard Caley <rjc@cstr.ed.ac.uk>
165 * @version $Id: EST_ChannelType.h,v 1.4 2009/07/03 17:13:56 awb Exp $
166 */
167
168enum EST_ChannelType {
169 /// Value to return for errors, never occurs in TrackMaps
170 channel_unknown = EST_ChannelId(0),
171 /// order of analysis.
172 channel_order = EST_ChannelId(1),
173 /// So we know how many there are
174 first_channel_type=channel_order,
175 /// Peak amplitude.
176 channel_peak = EST_ChannelId(2),
177 /// Duration of section of signal.
178 channel_duration = EST_ChannelId(3),
179 /// Length of section in samples.
180 channel_length = EST_ChannelId(4),
181 /// Offset from frame center to center of window
182 channel_offset = EST_ChannelId(5),
183 /// Voicing decision.
184 channel_voiced = EST_ChannelId(6),
185 /// Number of related frame in another track.
186 channel_frame = EST_ChannelId(7),
187 /// Time in seconds this frame refers to.
188 channel_time = EST_ChannelId(8),
189
190 /// RMS power of section of signal.
191 channel_power = EST_DiffChannelId(0,0),
192 channel_power_d = EST_DiffChannelId(0,1),
193 channel_power_a = EST_DiffChannelId(0,2),
194 /// RMS energy of section of signal.
195 channel_energy = EST_DiffChannelId(1,0),
196 channel_energy_d = EST_DiffChannelId(1,1),
197 channel_energy_a = EST_DiffChannelId(1,2),
198 /// F0 in Hz.
199 channel_f0 = EST_DiffChannelId(2,0),
200 channel_f0_d = EST_DiffChannelId(2,1),
201 channel_f0_a = EST_DiffChannelId(2,2),
202
203 channel_lpc_0 = EST_CoefChannelId(cot_lpc,0,0),
204 channel_lpc_N = EST_CoefChannelId(cot_lpc,0,1),
205 channel_lpc_d_0 = EST_CoefChannelId(cot_lpc,1,0),
206 channel_lpc_d_N = EST_CoefChannelId(cot_lpc,1,1),
207 channel_lpc_a_0 = EST_CoefChannelId(cot_lpc,2,0),
208 channel_lpc_a_N = EST_CoefChannelId(cot_lpc,2,1),
209
210 channel_reflection_0 = EST_CoefChannelId(cot_reflection,0,0),
211 channel_reflection_N = EST_CoefChannelId(cot_reflection,0,1),
212 channel_reflection_d_0 = EST_CoefChannelId(cot_reflection,1,0),
213 channel_reflection_d_N = EST_CoefChannelId(cot_reflection,1,1),
214 channel_reflection_a_0 = EST_CoefChannelId(cot_reflection,2,0),
215 channel_reflection_a_N = EST_CoefChannelId(cot_reflection,2,1),
216
217
218 channel_cepstrum_0 = EST_CoefChannelId(cot_cepstrum,0,0),
219 channel_cepstrum_N = EST_CoefChannelId(cot_cepstrum,0,1),
220 channel_cepstrum_d_0 = EST_CoefChannelId(cot_cepstrum,1,0),
221 channel_cepstrum_d_N = EST_CoefChannelId(cot_cepstrum,1,1),
222 channel_cepstrum_a_0 = EST_CoefChannelId(cot_cepstrum,2,0),
223 channel_cepstrum_a_N = EST_CoefChannelId(cot_cepstrum,2,1),
224
225
226 channel_melcepstrum_0 = EST_CoefChannelId(cot_melcepstrum,0,0),
227 channel_melcepstrum_N = EST_CoefChannelId(cot_melcepstrum,0,1),
228 channel_melcepstrum_d_0 = EST_CoefChannelId(cot_melcepstrum,1,0),
229 channel_melcepstrum_d_N = EST_CoefChannelId(cot_melcepstrum,1,1),
230 channel_melcepstrum_a_0 = EST_CoefChannelId(cot_melcepstrum,2,0),
231 channel_melcepstrum_a_N = EST_CoefChannelId(cot_melcepstrum,2,1),
232
233 channel_fbank_0 = EST_CoefChannelId(cot_fbank,0,0),
234 channel_fbank_N = EST_CoefChannelId(cot_fbank,0,1),
235 channel_fbank_d_0 = EST_CoefChannelId(cot_fbank,1,0),
236 channel_fbank_d_N = EST_CoefChannelId(cot_fbank,1,1),
237 channel_fbank_a_0 = EST_CoefChannelId(cot_fbank,2,0),
238 channel_fbank_a_N = EST_CoefChannelId(cot_fbank,2,1),
239
240
241 channel_lsf_0 = EST_CoefChannelId(cot_lsf,0,0),
242 channel_lsf_N = EST_CoefChannelId(cot_lsf,0,1),
243 channel_lsf_d_0 = EST_CoefChannelId(cot_lsf,1,0),
244 channel_lsf_d_N = EST_CoefChannelId(cot_lsf,1,1),
245 channel_lsf_a_0 = EST_CoefChannelId(cot_lsf,2,0),
246 channel_lsf_a_N = EST_CoefChannelId(cot_lsf,2,1),
247
248
249 channel_tubearea_0 = EST_CoefChannelId(cot_tubearea,0,0),
250 channel_tubearea_N = EST_CoefChannelId(cot_tubearea,0,1),
251 channel_tubearea_d_0 = EST_CoefChannelId(cot_tubearea,1,0),
252 channel_tubearea_d_N = EST_CoefChannelId(cot_tubearea,1,1),
253 channel_tubearea_a_0 = EST_CoefChannelId(cot_tubearea,2,0),
254 channel_tubearea_a_N = EST_CoefChannelId(cot_tubearea,2,1),
255
256
257 channel_filter_0 = EST_CoefChannelId(cot_filter,0,0),
258 channel_filter_N = EST_CoefChannelId(cot_filter,0,1),
259 channel_filter_d_0 = EST_CoefChannelId(cot_filter,1,0),
260 channel_filter_d_N = EST_CoefChannelId(cot_filter,1,1),
261 channel_filter_a_0 = EST_CoefChannelId(cot_filter,2,0),
262 channel_filter_a_N = EST_CoefChannelId(cot_filter,2,1),
263
264
265 channel_user1_0 = EST_CoefChannelId(cot_user1,0,0),
266 channel_user1_N = EST_CoefChannelId(cot_user1,0,1),
267 channel_user1_d_0 = EST_CoefChannelId(cot_user1,1,0),
268 channel_user1_d_N = EST_CoefChannelId(cot_user1,1,1),
269 channel_user1_a_0 = EST_CoefChannelId(cot_user1,2,0),
270 channel_user1_a_N = EST_CoefChannelId(cot_user1,2,1),
271
272
273 channel_user2_0 = EST_CoefChannelId(cot_user2,0,0),
274 channel_user2_N = EST_CoefChannelId(cot_user2,0,1),
275 channel_user2_d_0 = EST_CoefChannelId(cot_user2,1,0),
276 channel_user2_d_N = EST_CoefChannelId(cot_user2,1,1),
277 channel_user2_a_0 = EST_CoefChannelId(cot_user2,2,0),
278 channel_user2_a_N = EST_CoefChannelId(cot_user2,2,1),
279
280
281
282 last_channel_type = channel_f0_a,
283 /// Can be used to size arrays etc.
284 num_channel_types
285};
286//@}
287typedef enum EST_ChannelType EST_ChannelType;
288
289#endif