Edinburgh Speech Tools  2.1-release
EST_TrackMap.cc
Go to the documentation of this file.
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  /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */
34  /* Date: Fri May 9 1997 */
35  /************************************************************************/
36  /* */
37  /* Track maps provide a mapping from symbolic track names to the */
38  /* actual position of the information within a track frame. */
39  /* */
40  /* Channel name maps map textual names for track channels to symbolic */
41  /* names, they are just a special case of named enums. */
42  /* */
43  /************************************************************************/
44 
45 #include "EST_TrackMap.h"
46 
48 {
49  for(int i=0; i<num_channel_types; i++)
50  p_map[i]=NO_SUCH_CHANNEL;
51 }
52 
54 {
55  for(int i=0; i<num_channel_types; i++)
56  p_map[i]=from.p_map[i];
57 }
58 
59 
61 {
62 clear();
63 p_parent=NULL;
64 p_offset=0;
65 }
66 
68 {
69  init();
70 }
71 
72 
74 {
75  init();
76  if (refcount)
78 }
79 
81 {
82  init();
83  p_parent = (EST_TrackMap *)parent;
84  p_offset=offset;
85  if (refcount)
87 }
88 
90 {
91  init();
92  copy(from);
93  if (refcount)
95 }
96 
98 {
99  init();
100 
101  int i;
102  for(i=0; map[i].type != channel_unknown; i++)
103  set(map[i].type, map[i].channel);
104 }
105 
107 {
108 }
109 
111 {
112  short c= NO_SUCH_CHANNEL;
113  if (p_parent!=0)
114  {
115  c = p_parent->get(type);
116  if (c != NO_SUCH_CHANNEL)
117  c -= p_offset;
118  }
119  return c;
120 }
121 
122 EST_ChannelType EST_TrackMap::channel_type(unsigned short channel) const
123 {
124  unsigned short i;
125 
126  for(i=0; i<num_channel_types;i++)
127  if (p_map[i] == channel)
128  return (EST_ChannelType)i;
129 
130  if (p_parent!=0)
131  return p_parent->channel_type(channel+p_offset);
132 
133  return channel_unknown;
134 }
135 
136 short EST_TrackMap::last_channel(void) const
137 {
138  short last = -1;
139  for(short i=0; i<num_channel_types;i++)
140  if (p_map[i]> last)
141  last = p_map[i];
142  return last;
143 }
144 
145 
147  { channel_unknown, { "Unknown" },0},
148  { channel_order, { "Order" },0},
149  { channel_power, { "power", "Power", "raw_power"},0},
150  { channel_power_d, { "power_d", "Power_d", "raw_power_d"},0},
151  { channel_power_a, { "power_a", "Power_a", "raw_power_a"},0},
152  { channel_energy, { "energy", "Energy"},0},
153  { channel_energy_d, { "energy_d", "Energy_d"},0},
154  { channel_energy_a, { "energy_a", "Energy_a"},0},
155  { channel_peak, { "Peak", "ac_peak" },0},
156  { channel_duration, { "Duration" },0},
157  { channel_length, { "Length", "frame_len"},0},
158  { channel_offset, { "Offset", "frame_offset"},0},
159  { channel_f0, { "f0", "F0" },0},
160  { channel_f0_d, { "f0_d", "F0_d" },0},
161  { channel_f0_a, { "f0_a", "F0_a" },0},
162  { channel_voiced, { "Voiced", "prob_voice"},0},
163  { channel_frame, { "Frame"},0},
164  { channel_time, { "Time"},0},
165  { channel_lpc_0, { "lpc_0", "Lpc_0"},0},
166  { channel_lpc_N, { "lpc_N", "Lpc_N"},0},
167  { channel_lpc_d_0, { "lpc_d_0"},0},
168  { channel_lpc_d_N, { "lpc_d_N"},0},
169  { channel_lpc_a_0, { "lpc_a_0"},0},
170  { channel_lpc_a_N, { "lpc_a_N"},0},
171  { channel_cepstrum_0, { "cep_0"},0},
172  { channel_cepstrum_N, { "cep_N"},0},
173  { channel_cepstrum_d_0, { "cep_d_0"},0},
174  { channel_cepstrum_d_N, { "cep_d_N"},0},
175  { channel_cepstrum_a_0, { "cep_a_0"},0},
176  { channel_cepstrum_a_N, { "cep_a_N"},0},
177  { channel_melcepstrum_0, { "melcep_0"},0},
178  { channel_melcepstrum_N, { "melcep_N"},0},
179  { channel_melcepstrum_d_0, { "melcep_d_0"},0},
180  { channel_melcepstrum_d_N, { "melcep_d_N"},0},
181  { channel_melcepstrum_a_0, { "melcep_a_0"},0},
182  { channel_melcepstrum_a_N, { "melcep_a_N"},0},
183  { channel_lsf_0, { "lsf_0"},0},
184  { channel_lsf_N, { "lsf_N"},0},
185  { channel_lsf_d_0, { "lsf_d_0"},0},
186  { channel_lsf_d_N, { "lsf_d_N"},0},
187  { channel_lsf_a_0, { "lsf_a_0"},0},
188  { channel_lsf_a_N, { "lsf_a_N"},0},
189  { channel_fbank_0, { "fbank_0"},0},
190  { channel_fbank_N, { "fbank_N"},0},
191  { channel_fbank_d_0, { "fbank_d_0"},0},
192  { channel_fbank_d_N, { "fbank_d_N"},0},
193  { channel_fbank_a_0, { "fbank_a_0"},0},
194  { channel_fbank_a_N, { "fbank_a_N"},0},
195  { channel_filter_0, { "filter_0"},0},
196  { channel_filter_N, { "filter_N"},0},
197  { channel_filter_d_0, { "filter_d_0"},0},
198  { channel_filter_d_N, { "filter_d_N"},0},
199  { channel_filter_a_0, { "filter_a_0"},0},
200  { channel_filter_a_N, { "filter_a_N"},0},
201  { channel_reflection_0, { "reflection_0"},0},
202  { channel_reflection_N, { "reflection_N"},0},
203  { channel_reflection_d_0, { "reflection_d_0"},0},
204  { channel_reflection_d_N, { "reflection_d_N"},0},
205  { channel_reflection_a_0, { "reflection_a_0"},0},
206  { channel_reflection_a_N, { "reflection_a_N"},0},
207  { channel_unknown, { NULL },0}
208 };
209 
211 
213  { channel_unknown, { "Unknown" },0},
214  { channel_order, { "Order" },0},
215  { channel_power, { "raw_power", "rms" },0},
216  { channel_peak, { "ac_peak" },0},
217  { channel_duration, { "Duration" },0},
218  { channel_length, { "frame_len"},0},
219  { channel_f0, { "F0" },0},
220  { channel_voiced, { "prob_voice"},0},
221  { channel_lpc_0, { "lpc_0", "spec_param" },0},
222  { channel_lpc_N, { "lpc_N"},0},
223  // { channel_coef0, { "spec_param" },0},
224  { channel_unknown, { NULL },0}
225 };
226 
227 EST_ChannelNameMap esps_channel_names(esps_channel_name_tbl);
228 
229 #if defined(INSTANTIATE_TEMPLATES)
230 
231 #include "../base_class/EST_TNamedEnum.cc"
232 
233 template class EST_TNamedEnum<EST_ChannelType>;
237 
239 
240 #endif
short get_parent(EST_ChannelType type) const
short get(EST_ChannelType type) const
Get the position of a channel.
Definition: EST_TrackMap.h:136
short last_channel(void) const
Returns the index of the last known channel.
RMS power of section of signal.
Time in seconds this frame refers to.
EST_ChannelType
Duration of section of signal.
Can be used to size arrays etc.
Voicing decision.
EST_TrackMap(void)
Default constructor.
Definition: EST_TrackMap.cc:67
EST_ChannelType channel_type(unsigned short channel) const
Returns the type of the channel at the given position.
Peak amplitude.
void copy(EST_TrackMap &from)
copy an exiting map.
Definition: EST_TrackMap.cc:53
int refcount(void) const
Number of related frame in another track.
void init(void)
Initialise the map.
Definition: EST_TrackMap.cc:60
structure for the table.
Definition: EST_TrackMap.h:73
NULL
Definition: EST_WFST.cc:55
Length of section in samples.
RMS energy of section of signal.
EST_ChannelNameMap esps_channel_names(esps_channel_name_tbl)
Definition of the names ESPS programs use for channels.
Offset from frame center to center of window.
void start_refcounting(int initial=0)
order of analysis.
void clear(void)
Empty the map.
Definition: EST_TrackMap.cc:47
EST_Item * parent(const EST_Item *n)
return parent of n
F0 in Hz.
EST_ChannelNameMap EST_default_channel_names(channel_name_tbl)
Definition of standard names we use for channels.
#define NO_SUCH_CHANNEL
Returned if we ask for a channel not in the map.
Definition: EST_TrackMap.h:86
Value to return for errors, never occurs in TrackMaps.