Edinburgh Speech Tools  2.4-release
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
EST_Track.h
1  /*************************************************************************/
2  /* */
3  /* Centre for Speech Technology Research */
4  /* University of Edinburgh, UK */
5  /* Copyright (c) 1995,1996 */
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  /* Author : Paul Taylor */
35  /* Rewritten : Richard Caley */
36  /* ------------------------------------------------------------------- */
37  /* EST_Track Class header file */
38  /* */
39  /*************************************************************************/
40 
41 class EST_Track;
42 
43 #ifndef __Track_H__
44 #define __Track_H__
45 
46 #include "EST_FMatrix.h"
47 #include "EST_types.h"
48 #include "EST_TrackMap.h"
49 #include "EST_ChannelType.h"
50 #include "EST_Featured.h"
51 
53 
54 class EST_TokenStream;
55 class EST_String;
56 
57 typedef enum EST_TrackFileType {
58  tff_none=0,
59  tff_ascii,
60  tff_esps,
61  tff_htk,
62  tff_htk_fbank,
63  tff_htk_mfcc,
64  tff_htk_mfcc_e,
65  tff_htk_user,
66  tff_htk_discrete,
67  tff_xmg,
68  tff_xgraph,
69  tff_ema,
70  tff_ema_swapped,
71  tff_NIST,
72  tff_est_ascii,
73  tff_est_binary,
74  tff_snns,
75  tff_ssff
76 } EST_TrackFileType;
77 
78 typedef enum EST_InterpType {
79  it_nearest, // nearest time point
80  it_linear, // linerar interpolation
81  it_linear_nz // .. unless one end near zero
82 } EST_InterpType;
83 
84 /** A class for storing time aligned coefficients.
85 
86 some stuff.
87 */
88 
89 class EST_Track : public EST_Featured {
90 
91 protected:
92  EST_FMatrix p_values; // float x array
93  EST_FVector p_times; // float y array
94  EST_CVector p_is_val; // for breaks and non-breaks
95 
96  EST_ValMatrix p_aux; // Auxiliary channels
97  EST_StrVector p_aux_names; // Names of auxiliary channels
98 
99  float p_t_offset; // time shift.
100 
101  EST_TrackMap::P p_map;
102  EST_StrVector p_channel_names; // name of each track
103 
104  bool p_equal_space; // fixed or variable frame rate
105  bool p_single_break; // single break lots between data
106 
107  void default_vals();
108  void default_channel_names();
109  void clear_arrays();
110  void pad_breaks(); // put in extra breaks
111 
112  int interp_value(float x, float f);
113  float interp_amp(float x, int c, float f);
114  float estimate_shift(float x);
115  void copy(const EST_Track& a);
116 
117 public:
118  static const float default_frame_shift;
119  static const int default_sample_rate;
120 
121  /**@name Constructor and Destructor functions
122  */
123 
124  //@{
125 
126  /// Default constructor
127  EST_Track();
128 
129  /// Copy constructor
130  EST_Track(const EST_Track &a);
131 
132  /// resizing constructor
134 
135  /// resizing constructor
136  EST_Track(int num_frames, EST_StrList &map);
137 
138  /// default destructor
139  ~EST_Track();
140  //@}
141 
142  /** @name Configuring Tracks
143  */
144  //@{
145 
146  /** resize the track to have {\tt num_frames} and {\tt num_channels}.
147  if {\tt preserve} is set to 1, any existing values in the track
148  are kept, up to the limits imposed by the new number of frames
149  and channels. If the new track size is bigger, new positions
150  are filled with 0 */
151  void resize(int num_frames, int num_channels, bool preserve = 1);
152 
153  /** resize the track to have {\tt num_frames} and {\tt num_channels}.
154  if {\tt preserve} is set to 1, any existing values in the track
155  are kept, up to the limits imposed by the new number of frames
156  and channels. If the new track size is bigger, new positions
157  are filled with 0 */
158  void resize(int num_frames, EST_StrList &map, bool preserve = 1);
159 
160  /** resize the track's auxiliary channels.
161  */
162  void resize_aux(EST_StrList &map, bool preserve = 1);
163 
164  /** Change the number of channels while keeping the number of
165  frames the same. if {\tt preserve} is set to 1, any existing
166  values in the track are kept, up to the limits imposed by the
167  new number of frames and channels. If the new track size is
168  bigger, new positions are filled with 0 */
169  void set_num_channels(int n, bool preserve = 1)
170  { resize(EST_CURRENT, n, preserve); }
171 
172  /** Change the number of frames while keeping the number of
173  channels the same. if {\tt preserve} is set to 1, any
174  existing values in the track are kept, up to the limits
175  imposed by the new number of frames and channels. If the new
176  track size is bigger, new positions are filled with 0 */
177  void set_num_frames(int n, bool preserve = 1)
178  { resize(n, EST_CURRENT, preserve); }
179 
180  /// set the name of the channel.
181  void set_channel_name(const EST_String &name, int channel);
182 
183  /// set the name of the auxiliary channel.
184  void set_aux_channel_name(const EST_String &name, int channel);
185 
186  /// copy everything but data
187 
188  void copy_setup(const EST_Track& a);
189  //@}
190 
191  /**@name Global track information
192  */
193  //@{
194  /// name of track - redundant use access to features
195  EST_String name() const
196  { return f_String("name");}
197  /// set name of track - redundant use access to features
198  void set_name(const EST_String &n)
199  {f_set("name",n);}
200 
201  //@}
202 
203  /**@name Functions for sub tracks, channels and frames.
204  */
205  //@{
206 
207  /** make {\tt fv} a window to frame {\tt n} in the track.
208  */
209  void frame(EST_FVector &fv, int n, int startf=0, int nf=EST_ALL)
210  { p_values.row(fv, n, startf, nf); }
211 
212  /** make {\tt fv} a window to channel {\tt n} in the track.
213  */
214  void channel(EST_FVector &cv, int n, int startf=0, int nf=EST_ALL)
215  { p_values.column(cv, n, startf, nf); }
216 
217  /** make {\tt fv} a window to the named channel in the track.
218  */
219  void channel(EST_FVector &cv, const char * name, int startf=0,
220  int nf=EST_ALL);
221 
222  /** make {\tt st} refer to a portion of the track. No values
223  are copied - an internal pointer in st is set to the specified
224  portion of the the track. After this, st behaves like a normal
225  track. Its first channel is the same as start_channel and its
226  first frame is the same as start_frame. Any values written into
227  st will changes values in the main track. st cannot be resized.
228 
229  @param start_frame first frame at which sub-track starts
230  @param nframes number of frames to be included in total
231  @param start_channel first channel at which sub-track starts
232  @param nframes number of channels to be included in total
233  */
234  void sub_track(EST_Track &st,
235  int start_frame=0, int nframes=EST_ALL,
236  int start_chan=0, int nchans=EST_ALL);
237 
238  /** make {\tt st} refer to a portion of the track. No values
239  are copied - an internal pointer in st is set to the specified
240  portion of the the track. After this, st behaves like a normal
241  track. Its first channel is the same as start_channel and its
242  first frame is the same as start_frame. Any values written into
243  st will changes values in the main track. st cannot be resized.
244 
245  @param start_frame first frame at which sub-track starts
246  @param nframes number of frames to be included in total
247  @param start_channel_name name of channel at which sub-track starts
248  @param end_channel_name name of channel at which sub-track stops
249  */
250  void sub_track(EST_Track &st,
251  int start_frame, int nframes,
252  const EST_String &start_chan_name,
253  int nchans=EST_ALL);
254 
255  /** make {\tt st} refer to a portion of the track. No values
256  are copied - an internal pointer in st is set to the specified
257  portion of the the track. After this, st behaves like a normal
258  track. Its first channel is the same as start_channel and its
259  first frame is the same as start_frame. Any values written into
260  st will changes values in the main track. st cannot be resized.
261 
262  @param start_frame first frame at which sub-track starts
263  @param nframes number of frames to be included in total
264  @param start_channel_name name of channel at which sub-track starts
265  @param end_channel_name name of channel at which sub-track stops
266  */
267  void sub_track(EST_Track &st,
268  int start_frame, int nframes,
269  const EST_String &start_chan_name,
270  const EST_String &end_chan_name);
271 
272  /** make {\tt st} refer to a portion of the track. (const version)
273  No values
274  are copied - an internal pointer in st is set to the specified
275  portion of the the track. After this, st behaves like a normal
276  track. Its first channel is the same as start_channel and its
277  first frame is the same as start_frame. Any values written into
278  st will changes values in the main track. st cannot be resized.
279 
280  @param start_frame first frame at which sub-track starts
281  @param nframes number of frames to be included in total
282  @param start_channel first channel at which sub-track starts
283  @param nframes number of channels to be included in total
284  */
286  int start_frame=0, int nframes=EST_ALL,
287  int start_chan=0, int nchans=EST_ALL) const
288  { ((EST_Track *)this)->sub_track(st, start_frame, nframes,
289  start_chan, nchans); }
290 
291  /** Copy contiguous portion of track into {\tt st}. Unlike the
292  normal sub_track functions, this makes a completely new track.
293  values written into this will not affect the main track and it
294  can be resized.
295 
296  @param start_frame first frame at which sub-track starts
297  @param nframes number of frames to be included in total
298  @param start_channel first channel at which sub-track starts
299  @param nframes number of channels to be included in total
300  */
301 
302  void copy_sub_track( EST_Track &st,
303  int start_frame=0, int nframes=EST_ALL,
304  int start_chan=0, int nchans=EST_ALL) const;
305 
306  void copy_sub_track_out( EST_Track &st, const EST_FVector& frame_times ) const;
307  void copy_sub_track_out( EST_Track &st, const EST_IVector& frame_indices ) const;
308 
309  /** copy channel {\tt n} into pre-allocated buffer buf */
310  void copy_channel_out(int n, float *buf, int offset=0, int num=EST_ALL)
311  const
312  { p_values.copy_column(n, buf, offset, num); }
313 
314  /** copy channel {\tt n} into EST_FVector */
315  void copy_channel_out(int n, EST_FVector &f, int offset=0, int num=EST_ALL)
316  const
317  { p_values.copy_column(n, f, offset, num); }
318 
319  /** copy frame {\tt n} into pre-allocated buffer buf */
320  void copy_frame_out(int n, float *buf, int offset=0, int num=EST_ALL)
321  const {p_values.copy_row(n, buf, offset, num); }
322 
323  /** copy frame {\tt n} into EST_FVector */
324  void copy_frame_out(int n, EST_FVector &f, int offset=0, int num=EST_ALL)
325  const {p_values.copy_row(n, f, offset, num); }
326 
327  /** copy buf into pre-allocated channel n of track */
328  void copy_channel_in(int n, const float *buf, int offset=0,
329  int num=EST_ALL)
330  { p_values.set_column(n, buf, offset, num); }
331 
332  /** copy f into pre-allocated channel n of track */
333  void copy_channel_in(int n, const EST_FVector &f, int offset=0,
334  int num=EST_ALL)
335  { p_values.set_column(n, f, offset, num); }
336 
337  /** copy channel buf into pre-allocated channel n of track */
338  void copy_channel_in(int c,
339  const EST_Track &from, int from_c, int from_offset=0,
340  int offset=0, int num=EST_ALL)
341  { p_values.set_column(c, from.p_values, from_c,
342  from_offset, offset, num); }
343 
344  /** copy buf into frame n of track */
345  void copy_frame_in(int n, const float *buf, int offset=0,
346  int num=EST_ALL)
347  { p_values.set_row(n, buf, offset, num); }
348 
349  /** copy t into frame n of track */
350  void copy_frame_in(int n, const EST_FVector &t, int offset=0,
351  int num=EST_ALL)
352  { p_values.set_row(n, t, offset, num); }
353 
354  /** copy from into frame n of track */
355  void copy_frame_in(int i,
356  const EST_Track &from, int from_f, int from_offset=0,
357  int offset=0, int num=EST_ALL)
358  { p_values.set_row(i, from.p_values, from_f, from_offset, offset,
359  num); }
360 
361  //@}
362 
363  /**@name Channel information
364  */
365 
366  //@{
367 
368  /** Return the position of channel {\tt name} if it exists,
369  otherwise return -1.
370  */
371  int channel_position(const char *name, int offset=0) const;
372 
373  /** Return the position of channel {\tt name} if it exists,
374  otherwise return -1.
375  */
376  int channel_position(EST_String name, int offset=0) const
377  { return channel_position((const char *)name, offset); }
378 
379 
380  /** Returns true if the track has a channel named {\tt name},
381  otherwise false.
382  */
383 
384  bool has_channel(const char *name) const
385  { return channel_position(name) >=0; }
386 
387  /** Returns true if the track has a channel named {\tt name},
388  otherwise false.
389  */
391  { return has_channel((const char *)name); }
392 
393  //@}
394 
395  /** @name Accessing amplitudes The following functions can be used
396  to access to amplitude of the track at certain points. Most of
397  these functions can be used for reading or writing to this
398  point, thus
399 
400  tr.a(10, 5) = 10.3;
401 
402  can be used to set the 10th frame of the 5th channel and
403 
404  cout << tr.a(10, 5);
405 
406  can be used to print the same information. Most of these functions
407  have a const equivalent for helping the compiler in
408  read only operations.
409  */
410 
411  //@{
412 
413  /** return amplitude of frame i, channel c.*/
414  float &a(int i, int c=0);
415  float a(int i, int c=0) const;
416 
417  /** return amplitude of frame i, channel c with no bounds
418  checking. */
419  float &a_no_check(int i, int c=0) { return p_values.a_no_check(i,c); }
420  float a_no_check(int i, int c=0) const {return p_values.a_no_check(i,c);}
421 
422  /** return amplitude of point i, in the channel named name plus
423  offset. If you have a track with say channels called F0 and
424  voicing, you can access the 45th frame's F0 as t.a(45, "F0");
425  If there are 20 cepstral coefficients for each frame, the 5th can
426  be accessed as t.a(45, "cepstrum", 5);
427  */
428 
429  float &a(int i, const char *name, int offset=0);
430 
431  float a(int i, const char *name, int offset=0) const
432  { return ((EST_Track *)this)->a(i, name, offset); }
433  float &a(int i, EST_String name, int offset=0)
434  { return a(i, (const char *)name, offset); }
435  float a(int i, EST_String name, int offset=0) const
436  { return ((EST_Track *)this)->a(i, (const char *)name, offset); }
437 
438  /** return amplitude of time t, channel c. This can be used for
439  reading or writing to this point. By default the nearest frame
440  to this time is used. If {\tt interp} is set to {\tt
441  it_linear}, linear interpolation is performed between the two
442  amplitudes of the two frames either side of the time point to
443  give an estimation of what the amplitude would have been at
444  time {\tt t}. If {\tt interp} is set to {\tt it_linear_nz},
445  interpolation is as above, unless the time requested is off
446  the end of a portion of track in which case the nearest
447  amplitude is returned.
448  */
449  float &a(float t, int c=0, EST_InterpType interp=it_nearest);
450  float a(float t, int c=0, EST_InterpType interp=it_nearest) const
451  { return ((EST_Track *)this)->a(t, c, interp); }
452 
453 
454  /** return amplitude of frame i, channel c. */
455  float &operator() (int i, int c) { return a(i,c); }
456  /** return amplitude of frame i, channel 0. */
457  float &operator() (int i) { return a(i,0); }
458  float operator() (int i, int c) const { return a(i,c); }
459  float operator() (int i) const { return a(i,0); }
460 
461  /** return amplitude of frame nearest time t, channel c. */
462  float &operator() (float t, int c) {return a(t,c); }
463  /** return amplitude of frame nearest time t, channel 0. */
464  float &operator() (float t) {return a(t,0); }
465  float operator() (float t, int c) const {return a(t,c); }
466  float operator() (float t) const {return a(t,0); }
467 
468  //@}
469 
470  /** @name Timing
471 
472  */
473 
474  //@{
475 
476  /// return time position of frame i
477  float &t(int i=0) { return p_times[i]; }
478  float t(int i=0) const { return p_times(i); }
479 
480  /// return time of frame i in milli-seconds.
481  float ms_t(int i) const { return p_times(i) * 1000.0; }
482 
483  /** set frame times to regular intervals of time {\tt t}.
484  The {\tt start} parameter specifies the integer multiple of {\tt t} at
485  which to start. For example, setting this to 0 will start at time
486  0.0 (The default means the first time value = {\tt t}
487  */
488  void fill_time( float t, int start=1 );
489 
490  /** set frame times to regular intervals of time {\tt t}.
491  The {\tt start} parameter specifies the first time value.
492  */
493  void fill_time( float t, float start );
494 
495  /** fill time channel with times from another track
496  */
497  void fill_time( const EST_Track &t );
498 
499  /** fill all amplitudes with value {\tt v} */
500  void fill(float v) { p_values.fill(v); }
501 
502  /** resample track at this frame shift, specified in seconds.
503  This can be used to change a variable frame spaced track into
504  a fixed frame track, or to change the spacing of an existing
505  evenly spaced track.
506  */
507  void sample(float shift);
508 
509  /// REDO
510  void change_type(float nshift, bool single_break);
511 
512  /** return an estimation of the frame spacing in seconds.
513  This returns -1 if the track is not a fixed shift track */
514  float shift() const;
515  /// return time of first value in track
516  float start() const;
517  /// return time of last value in track
518  float end() const;
519  //@}
520 
521  /** @name Auxiliary channels
522 
523  Auxiliary information is used to store information that goes
524  along with frames, but which are not amplitudes and hence
525  not appropriate for operations such as interpolation,
526  smoothing etc. The aux() array is an array of EST_Vals which
527  allows points to be int, float or a string.
528 
529  The following functions can be used to access to auxiliary
530  track information. Most of these functions can be used for
531  reading or writing to this point, thus
532 
533  tr.aux(10, "voicing") = 1;
534 
535  can be used to set the 10th frame of the "voicing" channel and
536 
537  cout << tr.a(10, "voicing");
538 
539  can be used to print the same information. Most of these functions
540  have a const equivalent for helping the compiler in
541  read only operations.
542 
543  Auxiliary channels are usually accessed by name rather than
544  numerical index. The names are set using the set_aux_channel_names()
545  function.
546  */
547 
548  //@{
549 
550  EST_Val &aux(int i, int c);
551  EST_Val &aux(int i, int c) const;
552 
553  EST_Val &aux(int i, const char *name);
554  EST_Val aux(int i, const char *name) const
555  { return ((EST_Track *)this)->aux(i, name); }
556 
557  EST_Val &aux(int i, EST_String name)
558  { return aux(i, (const char *)name); }
559 
560  EST_Val aux(int i, EST_String name) const
561  { return ((EST_Track *)this)->aux(i, (const char *)name); }
562 
563  //@}
564 
565  /** @name File i/o functions
566  */
567 
568  //@{
569 
570  /** Load a file called {\tt name} into the track.
571  The load function attempts to
572  automatically determine which file type is being loaded from the
573  file's header. If no header is found, the function assumes the
574  file is ascii data, with a fixed frame shift, arranged with rows
575  representing frames and columns channels. In this case, the
576  frame shift must be specified as an argument to this function.
577  For those file formats which don't contain provision for specifying
578  an initial time (e.g. HTK, or ascii...), the {\tt startt} parameter
579  may be specified.
580  */
581  EST_read_status load(const EST_String name, float ishift = 0.0, float startt = 0.0);
582 
583  /** Load character data from an already opened tokenstream {\tt ts}
584  into the track.
585  The load function attempts to
586  automatically determine which file type is being loaded from the
587  file's header. If no header is found, the function assumes the
588  file is ascii data, with a fixed frame shift, arranged with rows
589  representing frames and columns channels. In this case, the
590  frame shift must be specified as an argument to this function
591  For those file formats which don't contain provision for specifying
592  an initial time (e.g. HTK, or ascii...), the {\tt startt} parameter
593  may be specified.
594  */
595  EST_read_status load(EST_TokenStream &ts, float ishift = 0.0, float startt = 0.0);
596 
597  /** Load a file called {\tt name} of format {\tt type}
598  into the track. If no header is found, the function assumes the
599  file is ascii data, with a fixed frame shift, arranged with rows
600  representing frames and columns channels. In this case, the
601  frame shift must be specified as an argument to this function
602  For those file formats which don't contain provision for specifying
603  an initial time (e.g. HTK, or ascii...), the {\tt startt} parameter
604  may be specified.
605  */
606  EST_read_status load(const EST_String name, const EST_String type,
607  float ishift = 0.0, float startt = 0.0 );
608 
609  /** Save the track to a file {\tt name} of format {\tt type}. */
610  EST_write_status save(const EST_String name,
611  const EST_String EST_filetype = "");
612 
613  /** Save the track to a already opened file pointer{\tt FP}
614  and write a file of format {\tt type}. */
615  EST_write_status save(FILE *fp,
616  const EST_String EST_filetype = "");
617 
618  //@}
619 
620  /** @name Utility functions */
621 
622  //@{
623  /// returns true if no values are set in the frame
624  int empty() const;
625 
626  /// set frame i to be a break
627  void set_break(int i);
628  /// set frame i to be a value
629  void set_value(int i);
630  /// return true if frame i is a value
631  int val(int i) const;
632  /// return true if frame i is a break
633  int track_break(int i) const { return (p_is_val(i)); }
634 
635  /** starting at frame i, return the frame index of the first
636  value frame before i. If frame i is a value, return i */
637  int prev_non_break(int i) const;
638 
639  /** starting at frame i, return the frame index of the first
640  value frame after i. If frame i is a value, return i */
641  int next_non_break(int i) const;
642 
643  /// return the frame index nearest time t
644  int index(float t) const;
645 
646  /// return the frame index before time t
647  int index_below(float x) const;
648 
649  /// return number of frames in track
650  int num_frames() const {return p_values.num_rows();}
651 
652  /// return number of frames in track
653  int length() const { return num_frames(); }
654 
655  /// return number of channels in track
656  int num_channels() const {return p_values.num_columns();}
657 
658  /// return number of auxiliary channels in track
659  int num_aux_channels() const {return p_aux.num_columns();}
660 
661  void add_trailing_breaks();
662  void rm_trailing_breaks();
663  /** If the contour has multiple break values between sections
664  containing values, reduce the break sections so that each has
665  a single break only. */
666  void rm_excess_breaks();
667 
668  /// return true if track has equal (i.e. fixed) frame spacing */
669  bool equal_space() const {return p_equal_space;}
670 
671  /**return true if track has only single breaks between value sections */
672  bool single_break() const {return p_single_break;}
673 
674  void set_equal_space(bool t) {p_equal_space = t;}
675  void set_single_break(bool t) {p_single_break = t;}
676 
677 
678  //@}
679 
680 
681  EST_Track& operator = (const EST_Track& a);
682  EST_Track& operator+=(const EST_Track &a); // add to existing track
683  EST_Track& operator|=(const EST_Track &a); // add to existing track in parallel
684  friend ostream& operator << (ostream& s, const EST_Track &tr);
685 
686  // Default constructor
687  EST_Track(int num_frames, EST_TrackMap &map);
688 
689  // assign a known description to a track
690  void assign_map(EST_TrackMap::P map);
691  void assign_map(EST_TrackMap &map) { assign_map(&map); }
692 
693  // create a description for an unknown track
694  void create_map(EST_ChannelNameMap &names);
695  void create_map(void) { create_map(EST_default_channel_names); }
696 
697  EST_TrackMap::P map() const { return p_map; }
698 
699  int channel_position(EST_ChannelType type, int offset=0) const;
700 
701 
702 
703  // return amplitude of point i, channel type c (plus offset)
704  float &a(int i, EST_ChannelType c, int offset=0);
705  float a(int i, EST_ChannelType c, int offset=0) const
706  { return ((EST_Track *)this)->a(i,c, offset); }
707 
708  // return amplitude at time t, channel type c
709  float &a(float t, EST_ChannelType c, EST_InterpType interp=it_nearest);
710  float a(float t, EST_ChannelType c, EST_InterpType interp=it_nearest) const
711  { return ((EST_Track *)this)->a(t, c, interp); }
712 
713  float &operator() (int i, EST_ChannelType c) { return a(i,c); }
714  float operator() (int i, EST_ChannelType c) const { return a(i,c); }
715 
716  float &t_offset() { return p_t_offset; }
717  float t_offset() const { return p_t_offset; }
718 
719 
720  EST_read_status load_channel_names(const EST_String name);
721  EST_write_status save_channel_names(const EST_String name);
722 
723  const EST_String channel_name(int channel, const EST_ChannelNameMap &map, int strings_override=1) const;
724  const EST_String channel_name(int channel, int strings_override=1) const
725  { return channel_name(channel, EST_default_channel_names, strings_override); }
726 
727  const EST_String aux_channel_name(int channel) const
728  { return p_aux_names(channel);}
729 
730  void resize(int num_frames, EST_TrackMap &map);
731 
732  EST_TrackFileType file_type() const {return (EST_TrackFileType)f_Int("file_type",0);}
733 
734 
735  void set_file_type(EST_TrackFileType t) {f_set("file_type", (int)t);}
736 
737 
738  bool has_channel(EST_ChannelType type) const
739  { int cp = channel_position(type);
740  return cp>=0; }
741 
742  // Frame iteration support
743 
744 protected:
745  class IPointer_f {
746  public:
747  EST_Track *frame; int i;
748  IPointer_f();
749  IPointer_f(const IPointer_f &p);
750  ~IPointer_f();
751  };
752 
753  void point_to_first(IPointer_f &ip) const { ip.i = 0; }
754  void move_pointer_forwards(IPointer_f &ip) const { ip.i++; }
755  bool points_to_something(const IPointer_f &ip) const { return ip.i <num_frames(); }
756  EST_Track &points_at(const IPointer_f &ip) { sub_track(*(ip.frame), ip.i, 1);
757  return *(ip.frame); }
758 
759  friend class EST_TIterator< EST_Track, IPointer_f, EST_Track >;
760  friend class EST_TRwIterator< EST_Track, IPointer_f, EST_Track >;
761 
762 public:
763  typedef EST_Track Entry;
766 
767 };
768 
769 // list of tracks in serial
771 
772 
773 #endif /* __Track_H__ */