Edinburgh Speech Tools  2.1-release
EST_Track.cc
Go to the documentation of this file.
1 /*************************************************************************/
2 /* */
3 /* Centre for Speech Technology Research */
4 /* University of Edinburgh, UK */
5 /* Copyright (c) 1994,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 /* Date : April 1994 */
36 /* ------------------------------------------------------------------- */
37 /* EST_Track Class source file */
38 /* */
39 /*************************************************************************/
40 
41 #include <fstream>
42 #include <iostream>
43 #include <cmath>
44 #include "EST_unix.h"
45 #include "EST_Track.h"
46 #include "EST_string_aux.h"
47 #include "EST_TrackFile.h"
48 #include "EST_error.h"
49 
50 using namespace std;
51 
52 const int EST_Track::default_sample_rate=16000; // occasionally needed for xmg files
53 const float EST_Track::default_frame_shift=0.005; // default frame spacing.
54 
55 const EST_String DEF_FILE_TYPE = "est";
56 
58 {
59  default_vals();
60 }
61 
63 {
64  default_vals();
65  copy(a);
66 }
67 
68 EST_Track::EST_Track(ssize_t n_frames, int n_channels)
69 {
70  default_vals();
71  p_values.resize(n_frames, n_channels);
72  p_times.resize(n_frames);
73  p_is_val.resize(n_frames);
74  p_channel_names.resize(n_channels);
75 
76  p_aux.resize(n_frames, 1);
78 
79  char d = 0;
80  p_is_val.fill(d);
81 }
82 
84 {
85  int n_channels = map.last_channel()+1;
86 
87  default_vals();
88  p_values.resize(n_frames, n_channels);
89  p_times.resize(n_frames);
90  p_is_val.resize(n_frames);
91  p_channel_names.resize(n_channels);
92  char d = 0;
93  p_is_val.fill(d);
94  assign_map(map);
95 }
96 
98 {
99  // clear_features();
100 }
101 
103 {
104  for (int i = 0; i < num_channels(); ++i)
105  set_channel_name("track" + itoString(i), i);
106 }
107 
109 {
112  p_values.resize(0, 0);
113  p_times.resize(0);
114  p_is_val.resize(0);
115  p_aux.resize(0, 0);
116  p_aux_names.resize(0);
118  p_map = NULL;
119  p_t_offset=0;
120 
121  init_features();
122 }
123 
124 void EST_Track::set_break(ssize_t i) // make location i hold a break
125 {
126  if (i >= num_frames())
127  cerr << "Requested setting of break value of the end of the array\n";
128 
129  p_is_val[i] = 1;
130 }
131 
132 
133 void EST_Track::set_value(ssize_t i) // make location i hold a value
134 {
135  p_is_val[i] = 0;
136 }
137 
138 const EST_String EST_Track::channel_name(int i, const EST_ChannelNameMap &map, int strings_override) const
139 {
140  (void)map;
141  (void)strings_override;
142  return p_channel_names(i);
143 }
144 
145 /* OLD ENUM VERSION
146 
147 const EST_String EST_Track::channel_name(int i, const EST_ChannelNameMap &map, int strings_override) const
148 {
149  EST_ChannelType type = channel_unknown;
150 
151  if (strings_override && p_channel_names(i) != "")
152  return p_channel_names(i);
153  else if (p_map!=NULL && ((type = p_map->channel_type(i)) != channel_unknown))
154  {
155  const char *name = map.name(type);
156  if (!name)
157  name = EST_default_channel_names.name(type);
158  if (name != NULL)
159  return EST_String(name);
160  return "unnamed_channel" + itoString(type);
161  }
162  else if (!strings_override && p_channel_names(i) != "")
163  return p_channel_names(i);
164  else
165  return "track" + itoString(i);
166 }
167 */
169 {
170  p_channel_names[i] = fn;
171 }
172 
174 {
175  p_aux_names[i] = fn;
176 }
177 
178 ostream& operator << (ostream& s, const EST_Track &tr)
179 {
180  ssize_t i;
181  int j;
182  for (i = 0; i < tr.num_frames(); ++i)
183  {
184  s << tr.t(i);
185  for (j = 0; j < tr.num_channels(); ++j)
186  s << "\t" << tr(i, j);
187  for (j = 0; j < tr.num_aux_channels(); ++j)
188  s << "\t" << tr.aux(i, j);
189  s << "\t" << !tr.track_break(i) << endl;
190  }
191  return s;
192 }
193 
195 {
196  copy_setup(a);
197  p_values = a.p_values;
198  p_times = a.p_times;
199  p_is_val = a.p_is_val;
201  p_aux = a.p_aux;
203 }
204 
206 {
210  p_map = a.p_map;
211  copy_features(a);
212 }
213 
214 void EST_Track::resize(ssize_t new_num_frames, int new_num_channels, bool set)
215 {
216  ssize_t old_num_frames = num_frames();
217 
218  if (new_num_frames<0)
219  new_num_frames = num_frames();
220 
221  if (new_num_channels<0)
222  new_num_channels = num_channels();
223 
224  p_channel_names.resize(new_num_channels);
225 
226  // this ensures the new channels have a default name
227  if (new_num_channels > num_channels())
228  for (int i = num_channels(); i < new_num_channels; ++i)
229  set_channel_name("track_" + itoString(i), i);
230 
231  p_values.resize(new_num_frames, new_num_channels, set);
232  p_times.resize(new_num_frames, set);
233  p_is_val.resize(new_num_frames, set);
234 
235  p_aux.resize(new_num_frames, num_aux_channels(), set);
236 
237  // Its important that any new vals get set to 0
238  for (ssize_t i = old_num_frames; i < num_frames(); ++i)
239  p_is_val.a_no_check(i) = 0;
240 
241 }
242 
243 static void map_to_channels(EST_StrList &channel_map,
244  EST_StrList &channel_names)
245 {
246  EST_Litem *p;
247  EST_String b, type, first, last;
248  ssize_t n_f, n_l;
249 
250  for (p = channel_map.head(); p; p = p->next())
251  {
252  b = channel_map(p);
253  if (b.matches("$", 0))
254  {
255  // do this backwards as types may have "_" in them
256  b = b.after("$");
257  if (!b.contains("-"))
258  {
259  cerr<<"Ill formed coefficient range in map: " << b << "\n";
260  return;
261  }
262  type = b.before("-");
263  first = b.after("-");
264 
265  if (!first.contains("+"))
266  {
267  cerr<<"Ill formed coefficient range in map: "<<first<<"\n";
268  return;
269  }
270 
271  last = first.after("+");
272  first = first.before("+");
273 
274  n_f = Stringtoi(first);
275  n_l = Stringtoi(last);
276 
277  for (ssize_t i = n_f; i < n_l; ++i)
278  channel_names.append(type + "_" + itoString(i));
279  channel_names.append(type + "_N");
280  }
281  else
282  channel_names.append(b);
283  }
284 }
285 
286 void EST_Track::resize(ssize_t new_num_frames, EST_StrList &new_channels, bool set)
287 {
288  EST_StrList x;
289  map_to_channels(new_channels, x);
290  ssize_t i;
291  EST_Litem *p;
292 
293  int new_num_channels;
294  new_num_channels = x.length();
295 
296  if (new_num_frames<0)
297  new_num_frames = num_frames();
298 
299 
300  p_channel_names.resize(new_num_channels);
301  // this ensures the new channels have a default name
302 
303  for (i = 0, p = x.head(); p ; p = p->next(), ++i)
304  set_channel_name(x(p), i);
305 
306  p_values.resize(new_num_frames, new_num_channels, set);
307  p_times.resize(new_num_frames, set);
308  p_is_val.resize(new_num_frames, set);
309 
310 // for (int i = 0; i < new_num_frames; ++i)
311 // p_is_val.a_no_check(i) = 1;
312 }
313 
314 void EST_Track::resize_aux(EST_StrList &new_aux_channels, bool set)
315 {
316  int i;
317  EST_Litem *p;
318 
319  int new_num_channels;
320  new_num_channels = new_aux_channels.length();
321 
322  p_aux_names.resize(new_num_channels);
323 
324  // this ensures the new channels have a default name
325  for (i = 0, p = new_aux_channels.head(); p ; p = p->next(), ++i)
326  set_aux_channel_name(new_aux_channels(p), i);
327 
328  p_aux.resize(num_frames(), new_num_channels, set);
329 }
330 
331 EST_Track& EST_Track::operator+=(const EST_Track &a) // add to existing track
332 {
333  ssize_t i, j, k;
334 
335  if (num_frames() == 0) // i.e. no existing EST_Track to add to
336  {
337  *this = a;
338  return *this;
339  }
340 
341  if (a.num_channels() != num_channels())
342  {
343  cerr << "Error: Tried to add " << a.num_channels() <<
344  " channel EST_Track to "<<num_channels() << " channel EST_Track\n";
345  return *this;
346  }
347 
348  ssize_t old_num = num_frames();
349  float old_end = end();
350  this->resize(a.num_frames()+ this->num_frames(), this->num_channels());
351  for (i = 0, j = old_num; i < a.num_frames(); ++i, ++j)
352  {
353  for (k = 0; k < num_channels(); ++k)
354  p_values.a_no_check(j, k) = a(i, k);
355  p_times[j] = old_end + a.t(i);
356  p_is_val[j] = a.p_is_val(i);
357  }
358 
359  return *this;
360 }
361 
363 { // add to existing track in parallel
364  ssize_t i, j, k;
365 
366  if (num_channels() == 0) // i.e. no existing EST_Track to add to
367  {
368  *this = a;
369  return *this;
370  }
371 
372  if (a.num_frames() != num_frames())
373  {
374  cerr << "Error: Tried to add " << a.num_frames() <<
375  " channel EST_Track to "<<num_frames()<< " channel EST_Track\n";
376  return *this;
377  }
378 
379  ssize_t old_num = num_channels();
380  this->resize(a.num_frames(), this->num_channels() + a.num_channels());
381  for (i = 0, j = old_num; i < a.num_channels(); ++i, ++j)
382  for (k = 0; k < num_frames(); ++k)
383  p_values.a_no_check(k, j) = a(k, i);
384 
385  return *this;
386 }
387 
389 {
390  copy(a);
391  return *this;
392 }
393 
394 
395 int EST_Track::channel_position(const char *name, int offset) const
396 {
397  int c;
398 
399  for (c=0; c<num_channels(); c++)
400  if (channel_name(c) == name)
401  return c+offset;
402 
403  return -1;
404 }
405 
406 float &EST_Track::a(ssize_t i, const char *name, int offset)
407 {
408  int c;
409 
410  for (c=0; c<num_channels(); c++)
411  if (channel_name(c) == name)
412  return p_values.a_no_check(i, c+offset);
413 
414  cerr << "no channel '" << name << "'\n";
415  return *(p_values.error_return);
416 }
417 
419 {
420  for (int c = 0; c < num_aux_channels(); c++)
421  if (aux_channel_name(c) == name)
422  return p_aux.a_no_check(i, c);
423 
424  cerr << "no auxiliary channel '" << name << "' found\n";
425  return *(p_aux.error_return);
426 }
427 
429 {
430  return p_aux(i, c);
431 }
432 
434 {
435  return ((EST_Track *)this)->aux(i,c);
436 }
437 
438 #define EPSILON (0.0001)
439 
440 float &EST_Track::a(float t, int c, EST_InterpType interp)
441 {
442  static float ia = 0.0;
443 
444  if (interp == it_nearest)
445  return p_values.a_no_check(index(t), c);
446  else if (interp == it_linear)
447  {
448  ssize_t i = index_below(t);
449  if (i < 0)
450  return a(static_cast<ssize_t>(0),c);
451 
452  float n = a(i,c), n1 = a(i+1,c);
453  float tn = p_times(i), tn1 = p_times(i+1);
454  ia = n + (n1-n)*(t-tn)/(tn1-tn);
455  return ia;
456  }
457  else if (interp == it_linear_nz)
458  {
459  ssize_t i = index_below(t);
460  if (i < 0)
461  return a(static_cast<ssize_t>(0),c);
462 
463  float n = a(i,c), n1 = a(i+1,c);
464  if (fabs(n) < EPSILON || fabs(n1) < EPSILON)
465  return p_values.a_no_check(index(t), c);
466  float tn = p_times(i), tn1 = p_times(i+1);
467  ia = n + (n1-n)*(t-tn)/(tn1-tn);
468  return ia;
469  }
470  return ia;
471 }
472 
473 ssize_t EST_Track::index(float x) const
474 {
475  if (equal_space())
476  {
477  float s = shift();
478  ssize_t f = (ssize_t)( (x-t(0))/s+0.5 ); //don't assume track starts at t=0.0
479  if (f<0)
480  f=0;
481  else if (f>= num_frames())
482  f=num_frames()-1;
483  return f;
484  }
485  else if (num_frames() > 1) //if single frame, return that index (0)
486  {
487  ssize_t bst, bmid, bend;
488  bst = 1;
489  bend = num_frames();
490  if (x < p_times.a_no_check(bst))
491  bmid=bst;
492  if (x >= p_times.a_no_check(bend-1))
493  bmid=bend-1;
494  else
495  {
496  while (1)
497  {
498  bmid = bst + (bend-bst)/2;
499  if (bst == bmid)
500  break;
501  else if (x < p_times.a_no_check(bmid))
502  {
503  if (x >= p_times.a_no_check(bmid-1))
504  break;
505  bend = bmid;
506  }
507  else
508  bst = bmid;
509  }
510  }
511  if (fabs(x - p_times.a_no_check(bmid)) <
512  fabs(x - p_times.a_no_check(bmid-1)))
513  return bmid;
514  else
515  return bmid - 1;
516  }
517 
518  return num_frames() -1;
519 }
520 
522 {
523  if (equal_space())
524  {
525  float s = shift();
526  ssize_t f = (int)(x/s);
527  if (f<0)
528  f=0;
529  else if (f>= num_frames())
530  f=num_frames()-1;
531  return f;
532  }
533  else
534  {
535  for (ssize_t i = 1; i < num_frames(); ++i)
536  if (x <= p_times.a_no_check(i))
537  return i - 1;
538  return num_frames()-1;
539  }
540 }
541 
543 {
544  return !p_is_val(i);
545 }
546 /*
547  "p_equal_space" indicates whether the x-axis values are evenly spaced
548  (FIXED) or spaced arbitrarily (VARI).
549 
550  "p_single_break" describes the break format. F0 contours are seldom
551  continuous - often breaks occur due to unvoicing etc. These are a
552  marked in the data arrays by break values, "i_break" for ints
553  and "f_break" for floats. The "p_single_break" channel specifies whether
554  a break is represented by a single break value, or as a break
555  value for every frame. eg
556  (SINGLE)
557  800 100
558  810 105
559  BREAK BREAK
560  850 130
561  860 135
562  or
563  (MANY)
564  800 100
565  810 105
566  820 BREAK
567  830 BREAK
568  840 BREAK
569  850 130
570  860 135
571 
572  In the MANY case, only the y value is specified as a break, in the
573  SINGLE case the x value may or may not be specified as a break. For
574  this reason, when checking for breaks, it is useful to only rely
575  on the y value being set to the i_break value. Not that if the single_break
576  is MANY and the equal_space is FIXED, you dont really need x-axis
577  values.
578 
579  Different functions naturally work better on different representations
580  and that is why all these different types are supported. A
581  general function mod_cont() is supplied to change from one
582  type to another. Not all conversions are currently
583  supported however.
584 
585  */
586 
587 float EST_Track::end() const
588 {
589  if (num_frames() == 0)
590  return 0.0;
591  else
592  return (p_times(prev_non_break(num_frames())));
593 }
594 float EST_Track::start() const
595 {
596  if (num_frames() == 0)
597  return 0.0;
598  else
599  return (track_break(0) ? p_times(next_non_break(0)) : p_times(0));
600 }
601 
602 float EST_Track::shift() const
603 {
604  int j1 = 0;
605  int j2 = 0;
606 
607  if (!p_equal_space)
608  EST_error("Tried to take shift from non-fixed contour\n");
609 
610  do
611  {
612  j1 = next_non_break(++j1);
613  j2 = next_non_break(j1);
614  // cout << "j1:" << j1 << " j2:" << j2 << endl;
615  }
616  while ((j2 != 0) && (j2 != (j1 +1)));
617 
618  if (j2 == 0)
619  {
620  if (num_frames() > 1)
621  return p_times(1) - p_times(0);
622  else
623  EST_error("Couldn't determine shift size\n");
624 
625  }
626  return (p_times(j2) - p_times(j1));
627 }
628 
629 /* tries to find the next value that isnt a break. Dont really
630  know what to do on a fail, so just return 0 */
631 
633 {
634  ssize_t i = j;
635  for (++i; i < num_frames(); ++i)
636  {
637  // cout << "i: " << i << " " << value[i] << endl;
638  if (!track_break(i))
639  return i;
640  }
641 
642  return 0;
643 }
644 
645 /* give the current point, returns the previous non-break */
646 
648 {
649  ssize_t i = j;
650  for (--i; i >= 0 ; --i)
651  if (!track_break(i))
652  return i;
653  return 0;
654 }
655 
656 void EST_Track::change_type(float nshift, bool single_break)
657 {
658  if (nshift != 0.0)
659  {
660  if (!p_equal_space || nshift != shift())
661  sample(nshift);
663  }
664 
665  if (single_break != p_single_break)
666  {
667  if (!p_single_break)
668  pad_breaks();
669  else
671  }
672 }
673 
674 void EST_Track::sample(float f_interval)
675 {
676  EST_FVector new_times;
677  EST_FMatrix new_values;
678  EST_CVector new_is_break;
679  int i, j, n;
680 
681  n = (int) rint(((end())/ f_interval));
682 
683  new_times.resize(n);
684  new_values.resize(n, num_channels());
685  new_is_break.resize(n);
686 
687  // REORG - can this be replaced with fill_time()?
688  for (i = 0; i < n; ++i)
689  new_times[i] = (float) ((i + 1) * f_interval);
690 
691  for (i = 0; i < n; ++i)
692  {
693  new_is_break[i] = !interp_value(new_times(i), f_interval);
694  for (j = 0; j < num_channels(); ++j)
695  new_values(i, j) = !new_is_break(i) ? interp_amp(new_times(i), j, f_interval): 0.0;
696  }
697 
698  p_times = new_times;
699  p_values = new_values;
700  p_is_val = new_is_break;
703 }
704 
705 float EST_Track::interp_amp(float x, int c, float fl)
706 {
707  ssize_t i;
708  float x1, x2, y1, y2, m;
709 
710  for (i = 0; i < num_frames(); ++i)
711  if ((p_times(i) + (fl / 2.0))> x)
712  break;
713 
714  if (i == num_frames())
715  return p_values.a_no_check(i - 1,c);
716  if (i == 0)
717  return p_values.a_no_check(0, c);
718 
719  if (track_break(i) && track_break(i - 1))
720  return 0.0;
721 
722  if (track_break(i))
723  return p_values.a_no_check(i - 1, c);
724 
725  else if (track_break(i - 1))
726  return p_values.a_no_check(i, c);
727 
728  x1 = p_times(i - 1);
729  y1 = p_values.a_no_check(i - 1, c);
730  x2 = p_times(i);
731  y2 = p_values.a_no_check(i, c);
732 
733  m = (y2 - y1) / (x2 -x1);
734  return ((x - x1) * m) + y1;
735 }
736 
737 int EST_Track::interp_value(float x, float fl)
738 {
739  int i;
740  int p, n;
741  float cf;
742 
743  if (p_equal_space)
744  cf = shift();
745  else
746  cf = estimate_shift(x);
747 
748  for (i = 0; i < num_frames(); ++i)
749  if ((p_times(i) + (fl / 2.0))> x)
750  break;
751  // This was:
752  // for (i = 0; i < num_frames(); ++i)
753  // if (p_times[i] > x)
754  // break;
755 
756  if (i == 0) // must be a break for the first value. (can't have i -1).
757  return FALSE;
758 
759  if ((!track_break(i)) && (!track_break(i -1)))
760  return TRUE;
761 
762  p = prev_non_break(i);
763  n = next_non_break(i);
764 
765  if ((x < p_times(p) + (cf / 2.0)) || (x > p_times(n) - (cf / 2.0)))
766  return TRUE; // rounding at edges
767 
768  return FALSE;
769 }
770 
772 {
773  ssize_t i, j;
774  for (j = 0; j < num_frames(); ++j)
775  if (p_times(j) > x)
776  break;
777 
778  for (i = j; i > 0; --i)
779  if ((!track_break(i)) && (!track_break(i - 1)))
780  return p_times(i) - p_times(i - 1);
781 
782  for (i = j; i < num_frames() - 1; ++i)
783  if ((!track_break(i)) && (!track_break(i + 1)))
784  return p_times(i + 1) - p_times(i);
785 
786  return 5.0; // default value
787 }
788 
789 void EST_Track::fill_time( float t, int start )
790 {
791  ssize_t nframes = num_frames();
792 
793  for( ssize_t i=0; i<nframes; ++i )
794  p_times.a_no_check(i) = t * (float) (i + start);
795 }
796 
797 void EST_Track::fill_time( float t, float startt )
798 {
799  ssize_t nframes = num_frames();
800 
801  for( ssize_t i=0; i<nframes; ++i )
802  p_times.a_no_check(i) = startt + (t * (float)i);
803 }
804 
806 {
807  ssize_t nframes = num_frames();
808 
809  for( ssize_t i=0; i<nframes; ++i )
810  p_times.a_no_check(i) = t.t(i);
811 }
812 
814 {
815  ssize_t i, j, k;
816  EST_FVector new_times;
817  EST_CVector new_is_break;
818  EST_FMatrix new_values;
819 
820  new_values.resize(num_channels(), num_frames());
821  new_times.resize(num_frames());
822  new_is_break.resize(num_frames());
823 
824  for (i = 0; track_break(i); ++i); //rm leading breaks
825 
826  for (j = 0; i < num_frames(); ++i, ++j)
827  {
828  for (k = 0; k < num_channels(); ++k)
829  new_values(j, k) = p_values.a_no_check(i, k);
830  new_times[j] = p_times(i);
831  new_is_break[j] = p_is_val(i);
832  while ((!new_is_break(j)) && (!val(i + 1)))
833  ++i;
834  }
835  p_times = new_times;
836  p_values = new_values;
837  p_is_val = new_is_break;
838  for (--j; track_break(j); --j) // "rm" trailing breaks
839  ;
843 
845 }
846 
848 {
849  if (num_frames() <=0 )
850  return;
851  ssize_t start, end;
852 
853  for (start = 0; start < num_frames(); ++start)
854  if (!track_break(start))
855  break;
856 
857  for(end=num_frames(); end>0; end--)
858  if (!track_break(end-1))
859  break;
860 
861  if (start==0 && end==num_frames())
862  return;
863 
864  for (ssize_t i=start, j = 0; i < end; ++i, ++j)
865  {
866  p_times[j] = p_times(i);
867  for (ssize_t k = 0; k < num_channels(); k++)
868  a_no_check(j, k) = a_no_check(i, k);
869  p_is_val[j] = p_is_val(i);
870  }
871 
872  p_values.resize(end-start, EST_CURRENT, 1);
873 
876 }
877 
879 {
880  ssize_t i, j, k;
881  EST_FVector new_times;
882  EST_FMatrix new_values;
883  int new_num = num_frames();
884 
885  if (!track_break(0))
886  new_num++;
887  if (!track_break(num_frames() - 1))
888  new_num++;
889 
890  if (new_num == num_frames()) /*ie trailing breaks already there */
891  return;
892 
893  new_times.resize(new_num);
894  new_values.resize(num_channels(), new_num);
895 
896  j = 0;
897  if (!track_break(j))
898  set_break(j);
899 
900  for (i = 0; i < num_frames(); ++i, ++j)
901  {
902  new_times[j] = p_times(i);
903  for (k = 0; k < num_channels(); ++k)
904  new_values(j, k) = p_values.a_no_check(i, k);
905  }
906 
907  if (!track_break(num_frames() - 1))
908  set_break(j);
909 
910  p_times = new_times;
911  p_values = new_values;
914 }
915 
917 {
918  if (!p_single_break)
919  return;
920 
921  if (!p_equal_space)
922  EST_error("pad_breaks: Can only operate on fixed data\n");
923 
924  EST_FVector new_times;
925  EST_FMatrix new_values;
926  EST_CVector new_is_break;
927  ssize_t i, j, k, n;
928 
929  n = (int)(((end())/ shift()) + 1.0);
930  int s = int(start()/ shift());
931 
932  for (i = 0; i < n; ++i)
933  {
934  new_times[i] = (float) (i * shift());
935  for (k = 0; k < num_channels(); ++k)
936  new_values(k, i) = 0.0;
937  new_is_break[i] = 0;
938  }
939 
940  for (i = 0, j = s; j < n; ++i, ++j)
941  {
942  if (track_break(i))
943  {
944  for (; new_times(j) < p_times(i + 1); ++j);
945  --j;
946  }
947  else
948  {
949  new_is_break[j] = 1;
950  for (k = 0; k < num_channels(); ++k)
951  new_values(j, k) = p_values.a_no_check(i, k);
952  }
953  }
954  new_is_break[j] = 1;
955  for (k = 0; k < num_channels(); ++k)
956  new_values(j, k) = p_values.a_no_check(i, k);
957 
958  p_times = new_times;
959  p_values = new_values;
960  p_is_val = new_is_break;
961 
965 
967 }
968 
969 static bool bounds_check(const EST_Track &t, int f, int c, int set)
970 {
971  const char *what = set? "set" : "access";
972 
973  if (f<0 || f >= t.num_frames())
974  {
975  cerr << "Attempt to " << what << " frame " << f << " of " << t.num_frames() << " frame track\n";
976  return FALSE;
977  }
978  if (c<0 || c >= t.num_channels())
979  {
980  cerr << "Attempt to " << what << " channel " << c << " of " << t.num_channels() << " channel track\n";
981  return FALSE;
982  }
983 
984 return TRUE;
985 }
986 
987 static bool bounds_check(const EST_Track &t,
988  ssize_t f, ssize_t nf,
989  int c, ssize_t nc,
990  int set)
991 {
992  const char *what = set? "set" : "access";
993 
994  if (nf>0)
995  {
996  if (f >= t.num_frames())
997  {
998  cerr << "Attempt to " << what << " frame " << f << " of " << t.num_frames() << " frame track\n";
999  return FALSE;
1000  }
1001  if (f+nf-1 >= t.num_frames())
1002  {
1003  cerr << "Attempt to " << what << " frame " << f+nf-1 << " of " << t.num_frames() << " frame track\n";
1004  return FALSE;
1005  }
1006  }
1007 
1008  if (nc>0)
1009  {
1010  if (c >= t.num_channels())
1011  {
1012  cerr << "Attempt to " << what << " channel " << c << " of " << t.num_channels() << " channel track\n";
1013  return FALSE;
1014  }
1015  if (c+nc-1 >= t.num_channels())
1016  {
1017  cerr << "Attempt to " << what << " channel " << c+nc-1 << " of " << t.num_channels() << " channel track\n";
1018  return FALSE;
1019  }
1020  }
1021 
1022 return TRUE;
1023 }
1024 
1025 float &EST_Track::a(ssize_t i, int c)
1026 {
1027  if (!bounds_check(*this, i,c,0))
1028  return *(p_values.error_return);
1029 
1030  return p_values.a_no_check(i,c);
1031 }
1032 
1033 float EST_Track::a(ssize_t i, int c) const
1034 {
1035  return ((EST_Track *)this)->a(i,c);
1036 }
1037 
1038 int EST_Track::empty() const
1039 {
1040  ssize_t i, num;
1041 
1042  for (i = num = 0; i < num_frames(); ++i)
1043  if (val(i))
1044  return 0; // i.e. false
1045 
1046  return 1; // i.e. true
1047 }
1048 
1049 void EST_Track::channel(EST_FVector &cv, const char * name, int startf, int nf)
1050 {
1051  ssize_t n;
1052  if ((n = channel_position(name)) == -1)
1053  {
1054  cerr << "No such channel " << name << endl;
1055  return;
1056  }
1057  channel(cv, n, startf, nf);
1058 }
1059 
1061  int start_frame, int nframes,
1062  const EST_String &start_chan_name, int nchans)
1063 {
1064  int start_chan;
1065  if (start_chan_name == "")
1066  start_chan = 0;
1067 
1068  if ((start_chan = channel_position(start_chan_name)) == -1)
1069  EST_error("sub_track: No such channel %s\n",
1070  (const char *)start_chan_name);
1071 
1072  sub_track(st, start_frame, nframes, start_chan, nchans);
1073 }
1074 
1076  int start_frame, int nframes,
1077  const EST_String &start_chan_name,
1078  const EST_String &end_chan_name)
1079 {
1080  int start_chan, end_chan, nchans=0;
1081 
1082  if ((start_chan = channel_position(start_chan_name)) == -1)
1083  EST_error("sub_track: No such channel %s\n",
1084  (const char *)start_chan_name);
1085 
1086  if (end_chan_name == "")
1087  nchans = EST_ALL;
1088  else
1089  {
1090  if ((end_chan = channel_position(end_chan_name)) == -1)
1091  EST_error("sub_track: No such channel %s\n",
1092  (const char*)end_chan_name);
1093  else
1094  nchans = end_chan - start_chan + 1;
1095  }
1096 
1097  sub_track(st, start_frame, nframes, start_chan, nchans);
1098 }
1099 
1101  int start_frame, int nframes,
1102  int start_chan, int nchans)
1103 {
1104  if (nframes <0)
1105  nframes = num_frames() - start_frame;
1106  if (nchans <0)
1107  nchans = num_channels() - start_chan;
1108 
1109  if (!bounds_check(*this, start_frame, nframes, start_chan, nchans, 0))
1110  return;
1111 
1112  p_values.sub_matrix(st.p_values, start_frame, nframes, start_chan, nchans);
1113 
1114  p_times.sub_vector(st.p_times, start_frame, nframes);
1115 
1116  p_is_val.sub_vector(st.p_is_val, start_frame, nframes);
1117 
1118  p_channel_names.sub_vector(st.p_channel_names, start_chan, nchans);
1119 
1120  // All auxiliary information is included. These are effectively
1121  // pointer statements
1122 
1123  p_aux.sub_matrix(st.p_aux, start_frame, nframes, 0, EST_ALL);
1125 
1126  st.p_t_offset = p_t_offset;
1127 
1130  st.copy_features(*this);
1131 
1132  if (p_map!=0)
1133  st.p_map = new EST_TrackMap(p_map, start_chan, EST_TM_REFCOUNTED);
1134  else
1135  st.p_map = NULL;
1136 }
1137 
1138 
1140  int start_frame, int nframes,
1141  int start_chan, int nchans) const
1142 {
1143  if (nframes <0)
1144  nframes = num_frames() - start_frame;
1145  if (nchans <0)
1146  nchans = num_channels() - start_chan;
1147 
1148  if (!bounds_check(*this, start_frame, nframes, start_chan, nchans, 0))
1149  return;
1150 
1151  st.resize(nframes, nchans);
1152 
1153  for (int ff=0; ff<nframes; ff++)
1154  {
1155  st.p_times.a(ff) = p_times.a(ff+start_frame);
1156  st.p_is_val.a(ff) = p_is_val.a(ff+start_frame);
1157  for (int c=0; c<nchans; c++)
1158  st.p_values.a(ff,c) = p_values.a(ff+start_frame,c+start_chan);
1159  }
1160 
1161  for (int c=0; c<nchans; c++)
1162  st.p_channel_names.a(c) = p_channel_names.a(c+start_chan);
1163 
1164  st.p_aux = p_aux;
1165  st.p_aux_names = p_aux_names;
1166 
1169 
1170  st.copy_features(*this);
1171 
1172  if (p_map!=0)
1173  st.p_map = new EST_TrackMap(p_map, start_chan, EST_TM_REFCOUNTED);
1174  else
1175  st.p_map = NULL;
1176 }
1177 
1178 void EST_Track::copy_sub_track_out( EST_Track &st, const EST_FVector& frame_times ) const
1179 {
1180  int f_len = frame_times.length();
1181  int nchans = num_channels();
1182  st.resize( f_len, nchans );
1183 
1184  for( int i=0; i<f_len; ++i ){
1185 
1186  int source_index = index(frame_times(i));
1187 
1188  st.p_times.a(i) = p_times.a( source_index );
1189  st.p_is_val.a(i) = p_is_val.a( source_index );
1190 
1191  for( int c=0; c<nchans; c++ )
1192  st.p_values.a(i,c) = p_values.a(source_index,c);
1193  }
1194 
1195  st.copy_setup( *this );
1196  st.set_equal_space( false ); //might not be true, but it's a better default
1197 
1198  // st.p_aux = p_aux;
1199  // st.p_aux_names = p_aux_names;
1200 }
1201 
1202 void EST_Track::copy_sub_track_out( EST_Track &st, const EST_IVector& frame_indices ) const
1203 {
1204  int f_len = frame_indices.length();
1205  int nchans = num_channels();
1206  st.resize( f_len, nchans );
1207 
1208  int last_index = num_frames()-1;
1209 
1210  for( int i=0; i<f_len; ++i ){
1211 
1212  int source_index = frame_indices(i);
1213 
1214  if( source_index <= last_index ){
1215 
1216  st.p_times.a(i) = p_times.a( source_index );
1217  st.p_is_val.a(i) = p_is_val.a( source_index );
1218 
1219  for( int c=0; c<nchans; c++ )
1220  st.p_values.a(i,c) = p_values.a(source_index,c);
1221  }
1222  }
1223 
1224  st.copy_setup( *this );
1225  st.set_equal_space( false ); //might not be true, but it's a better default
1226 
1227  // st.p_aux = p_aux;
1228  // st.p_aux_names = p_aux_names;
1229 }
1230 
1231 
1232 
1234  const EST_String type)
1235 {
1236  EST_String save_type = (type == "") ? DEF_FILE_TYPE : type;
1237 
1239 
1240  if (t == tff_none)
1241  {
1242  cerr << "Unknown Track file type " << save_type << endl;
1243  return write_fail;
1244  }
1245 
1247 
1248  if (s_fun == NULL)
1249  {
1250  cerr << "Can't save tracks to files type " << save_type << endl;
1251  return write_fail;
1252  }
1253 
1254  return (*s_fun)(filename, *this);
1255 }
1256 
1258 {
1260 
1261  if (t == tff_none)
1262  {
1263  cerr << "Unknown Track file type " << type << endl;
1264  return write_fail;
1265  }
1266 
1269 
1270  if (s_fun == NULL)
1271  {
1272  cerr << "Can't save tracks to files type " << type << endl;
1273  return write_fail;
1274  }
1275  return (*s_fun)(fp, *this);
1276 }
1277 
1278 EST_read_status EST_Track::load(EST_TokenStream &ts, float ishift, float startt)
1279 {
1280  EST_read_status stat = read_error;
1281 
1282  for (int n = 0; n < EST_TrackFile::ts_map.n(); n++)
1283  {
1285 
1286  if (t == tff_none)
1287  continue;
1288 
1289  EST_TrackFile::TS_Info *info = &(EST_TrackFile::ts_map.info(t));
1290 
1291  if (! info->recognise)
1292  continue;
1293 
1294  EST_TrackFile::Load_TokenStream * l_fun =info->load;
1295 
1296  if (l_fun == NULL)
1297  continue;
1298 
1299  stat = (*l_fun)(ts, *this, ishift, startt);
1300 
1301  if (stat != read_format_error)
1302  {
1303  if (stat == read_ok)
1304  set_file_type(t);
1305  break;
1306  }
1307  }
1308 
1309  return stat;
1310 }
1311 
1312 EST_read_status EST_Track::load(const EST_String filename, float ishift, float startt)
1313 {
1314  EST_read_status stat = read_error;
1315 
1316  for(int n=0; n< EST_TrackFile::map.n() ; n++)
1317  {
1319 
1320  if (t == tff_none)
1321  continue;
1322 
1323 
1324  EST_TrackFile::Info *info = &(EST_TrackFile::map.info(t));
1325 
1326  if (! info->recognise)
1327  continue;
1328 
1329  EST_TrackFile::Load_File * l_fun =info->load;
1330 
1331  if (l_fun == NULL)
1332  continue;
1333 
1334  stat = (*l_fun)(filename, *this, ishift, startt);
1335 
1336  if (stat == read_ok)
1337  {
1338  set_file_type(t);
1339  break;
1340  }
1341  else if (stat == read_error)
1342  break;
1343  }
1344 
1345  return stat;
1346 }
1347 
1348 EST_read_status EST_Track::load(const EST_String filename, const EST_String type, float ishift, float startt)
1349 {
1351 
1352  if (t == tff_none)
1353  {
1354  cerr << "Unknown Track file type " << type << endl;
1355  return read_error;
1356  }
1357 
1359 
1360  if (l_fun == NULL)
1361  {
1362  cerr << "Can't load tracks from file type" << type << endl;
1363  return read_error;
1364  }
1365 
1366  set_file_type(t);
1367  return (*l_fun)(filename, *this, ishift, startt);
1368 }
1369 
1371 {
1372  FILE *file;
1373 
1374  if ((file=fopen(filename, "wb"))==NULL)
1375  return write_fail;
1376 
1377  for(int c=0; c<num_channels(); c++)
1378  fprintf(file, "%s\n", (const char *)channel_name(c));
1379 
1380  fclose(file);
1381 
1382  return write_ok;
1383 }
1384 
1386 {
1387  FILE *file;
1388  static const int buffer_length = 100;
1389  char buffer[buffer_length];
1390 
1391  if ((file=fopen(filename, "rb"))==NULL)
1392  return misc_read_error;
1393 
1394  for(int c=0; c<num_channels(); c++)
1395  {
1396  if (!fgets(buffer, buffer_length, file))
1397  break;
1398 
1399  buffer[strlen(buffer)-1] = '\0';
1400  set_channel_name(buffer, c);
1401  }
1402 
1403 
1404  fclose(file);
1405 
1406  return format_ok;
1407 }
1408 
1409 /* code from here down should be deleted once tracp mapping is modified */
1410 
1411 
1412 float &EST_Track::a(float t, EST_ChannelType type, EST_InterpType interp)
1413 {
1414  short c = NO_SUCH_CHANNEL;
1415 
1416  if (p_map!=0 && (c = p_map->get(type)) != NO_SUCH_CHANNEL)
1417  return a(t, c, interp);
1418  else
1419  {
1420  cerr << "no channel '" << EST_default_channel_names.name(type) << "' = " << (int)type << "\n";
1421  }
1422  return *(p_values.error_return);
1423 }
1424 
1425 
1427 {
1428  p_map = map;
1429 }
1430 
1432 {
1434 
1435  for (int i = 0; i < num_channels(); i++)
1436  {
1437  EST_ChannelType type = names.token(p_channel_names(i));
1438 
1439  if (type != channel_unknown)
1440  map->set(type, i);
1441  }
1442 
1443  assign_map(map);
1444 }
1445 
1446 
1448 {
1449  resize(new_num_frames, map.last_channel()+1);
1450  assign_map(map);
1451 }
1452 
1453 
1454 
1456 {
1457  if (p_map!=0)
1458  {
1459  ssize_t p = (*p_map)(type);
1460  return (p!= NO_SUCH_CHANNEL)?(p+offset): NO_SUCH_CHANNEL;
1461  }
1462  return channel_position(EST_default_channel_names.name(type), offset);
1463 }
1464 
1465 float &EST_Track::a(ssize_t i, EST_ChannelType type, int offset)
1466 {
1467  short c = NO_SUCH_CHANNEL;
1468 
1469  if (p_map!=0 && ((c = p_map->get(type)) != NO_SUCH_CHANNEL))
1470  return p_values.a_no_check(i, c+offset);
1471  else
1472  {
1473  cerr << "no channel '" << EST_default_channel_names.name(type) << "' = " << (int)type << "\n";
1474  }
1475 
1476  return *(p_values.error_return);
1477 }
1478 
1480 {
1481  frame = new EST_Track();
1482  i = 0;
1483 }
1484 
1486 {
1487  i = 0;
1488  frame=new EST_Track(*(p.frame));
1489 }
1490 
1492 {
1493  if (frame != NULL)
1494  {
1495  delete frame;
1496  frame=NULL;
1497  }
1498 }
1499 
1500 
1501 #if defined(INSTANTIATE_TEMPLATES)
1502 
1504 
1505 #endif
void default_channel_names()
Definition: EST_Track.cc:102
bool single_break() const
Definition: EST_Track.h:673
EST_TrackMap::P p_map
Definition: EST_Track.h:102
void pad_breaks()
Definition: EST_Track.cc:916
short get(EST_ChannelType type) const
Get the position of a channel.
Definition: EST_TrackMap.h:136
int num_aux_channels() const
return number of auxiliary channels in track
Definition: EST_Track.h:660
short last_channel(void) const
Returns the index of the last known channel.
#define EPSILON
Definition: EST_Track.cc:438
bool p_equal_space
Definition: EST_Track.h:105
int contains(const char *s, ssize_t pos=-1) const
Does it contain this substring?
Definition: EST_String.h:365
Load_TokenStream * load
EST_Track & operator+=(const EST_Track &a)
Definition: EST_Track.cc:331
ssize_t prev_non_break(ssize_t i) const
Definition: EST_Track.cc:647
static EST_TNamedEnumI< EST_TrackFileType, TS_Info > ts_map
EST_ChannelType
EST_write_status
float end() const
return time of last value in track
Definition: EST_Track.cc:587
The file was read in successfully.
void create_map(void)
Definition: EST_Track.h:696
A vector class for floating point numbers. EST_FVector x should be used instead of float *x wherever ...
Definition: EST_FMatrix.h:119
void set_value(ssize_t i)
set frame i to be a value
Definition: EST_Track.cc:133
void set_channel_name(const EST_String &name, int channel)
set the name of the channel.
Definition: EST_Track.cc:168
EST_Track & operator=(const EST_Track &a)
Definition: EST_Track.cc:388
void set_break(ssize_t i)
set frame i to be a break
Definition: EST_Track.cc:124
EST_String name() const
name of track - redundant use access to features
Definition: EST_Track.h:196
int num_channels() const
return number of channels in track
Definition: EST_Track.h:657
void fill(const T &v)
Fill entire array will value v.
Definition: EST_TVector.cc:105
#define EST_TM_REFCOUNTED
Pass to creation function to turn on refcounting.
Definition: EST_TrackMap.h:103
INLINE const T & a_no_check(ssize_t n) const
read-only const access operator: without bounds checking
Definition: EST_TVector.h:254
EST_read_status Load_File(LoadTrackFileArgs)
Definition: EST_TrackFile.h:70
ssize_t index_below(float x) const
return the frame index before time t
Definition: EST_Track.cc:521
EST_String itoString(int n)
Make a EST_String object from an integer.
Definition: util_io.cc:141
const int EST_CURRENT
int ssize_t
const int EST_ALL
const T & a(ssize_t row, ssize_t col) const
Definition: EST_TMatrix.h:196
void resize(ssize_t num_frames, int num_channels, bool preserve=1)
Definition: EST_Track.cc:214
float & a_no_check(ssize_t i, int c=0)
Definition: EST_Track.h:420
const T & a(ssize_t n) const
Definition: EST_TVector.h:269
ssize_t index(float t) const
return the frame index nearest time t
Definition: EST_Track.cc:473
EST_UItem * next()
Definition: EST_UList.h:55
float & a(float t, int c=0, EST_InterpType interp=it_nearest)
Definition: EST_Track.cc:440
EST_write_status Save_TokenStream(SaveTrac_TokenStreamArgs)
Definition: EST_TrackFile.h:75
static const float default_frame_shift
Definition: EST_Track.h:119
ENUM token(VAL value) const
EST_TrackFileType
Definition: EST_Track.h:58
const EST_String DEF_FILE_TYPE
Definition: EST_Track.cc:55
void sub_track(EST_Track &st, int start_frame=0, int nframes=EST_ALL, int start_chan=0, int nchans=EST_ALL)
Definition: EST_Track.cc:1100
EST_read_status load_channel_names(const EST_String name)
Definition: EST_Track.cc:1385
float interp_amp(float x, int c, float f)
Definition: EST_Track.cc:705
An error occurred while reading.
void copy(const EST_Track &a)
Definition: EST_Track.cc:194
int track_break(ssize_t i) const
return true if frame i is a break
Definition: EST_Track.h:634
int channel_position(const char *name, int offset=0) const
Definition: EST_Track.cc:395
void assign_map(EST_TrackMap::P map)
Definition: EST_Track.cc:1426
Save_TokenStream * save
Definition: EST_TrackFile.h:87
EST_read_status load(const EST_String name, float ishift=0.0, float startt=0.0)
Definition: EST_Track.cc:1312
bool equal_space() const
return true if track has equal (i.e. fixed) frame spacing */
Definition: EST_Track.h:670
void resize(ssize_t n, int set=1)
Definition: EST_TVector.cc:196
float & t(ssize_t i=0)
return time position of frame i
Definition: EST_Track.h:478
void set(EST_ChannelType type, short pos)
Record the position of a channel.
Definition: EST_TrackMap.h:132
float & a(ssize_t i, int c=0)
Definition: EST_Track.cc:1025
const char * name(ENUM tok, int n=0) const
INLINE ssize_t length() const
number of items in vector.
Definition: EST_TVector.h:249
EST_InterpType
Definition: EST_Track.h:79
void copy_setup(const EST_Track &a)
copy everything but data
Definition: EST_Track.cc:205
int Stringtoi(EST_String s)
Make an int from a EST_String. EST_String equivalent of atoi()
Definition: util_io.cc:131
ssize_t next_non_break(ssize_t i) const
Definition: EST_Track.cc:632
~EST_Track()
default destructor
Definition: EST_Track.cc:97
EST_FVector p_times
Definition: EST_Track.h:94
static const int default_sample_rate
Definition: EST_Track.h:120
void default_vals()
Definition: EST_Track.cc:108
void set_file_type(EST_TrackFileType t)
Definition: EST_Track.h:736
int n(void) const
The file was written successfully.
friend std::ostream & operator<<(std::ostream &s, const EST_Track &tr)
EST_write_status save(const EST_String name, const EST_String EST_filetype="")
Definition: EST_Track.cc:1233
EST_ValMatrix p_aux
Definition: EST_Track.h:97
bool p_single_break
Definition: EST_Track.h:106
void change_type(float nshift, bool single_break)
REDO.
Definition: EST_Track.cc:656
#define FALSE
Definition: EST_bool.h:119
void sub_matrix(EST_TMatrix< T > &sm, ssize_t r=0, ptrdiff_t numr=EST_ALL, ssize_t c=0, ptrdiff_t numc=EST_ALL)
Make the matrix sm a window into this matrix.
Definition: EST_TMatrix.cc:578
void resize_aux(EST_StrList &map, bool preserve=1)
Definition: EST_Track.cc:314
#define misc_read_error
The file exists but is not in the format specified.
NULL
Definition: EST_WFST.cc:55
void channel(EST_FVector &cv, ssize_t n, int startf=0, int nf=EST_ALL)
Definition: EST_Track.h:215
#define EST_error
Definition: EST_error.h:104
f
Definition: EST_item_aux.cc:48
#define Instantiate_TIterator_T(CONTAINER, IP, ENTRY, TAG)
void rm_excess_breaks()
Definition: EST_Track.cc:813
static EST_TNamedEnumI< EST_TrackFileType, Info > map
void sample(float shift)
Definition: EST_Track.cc:674
ssize_t num_frames() const
return number of frames in track
Definition: EST_Track.h:651
EST_Track * frame
Definition: EST_Track.h:748
float p_t_offset
Definition: EST_Track.h:100
int matches(const char *e, ssize_t pos=0) const
Exactly match this string?
Definition: EST_String.cc:651
getString int
Definition: EST_item_aux.cc:50
The file was not written successfully.
Save_TokenStream * save
EST_Track()
Default constructor.
Definition: EST_Track.cc:57
float start() const
return time of first value in track
Definition: EST_Track.cc:594
EST_read_status Load_TokenStream(LoadTrack_TokenStreamArgs)
Definition: EST_TrackFile.h:73
void append(const T &item)
add item onto end of list
Definition: EST_TList.h:196
void sub_vector(EST_TVector< T > &sv, int start_c=0, int len=-1)
Create a sub vector.
Definition: EST_TVector.cc:298
EST_FMatrix p_values
Definition: EST_Track.h:93
void add_trailing_breaks()
Definition: EST_Track.cc:878
EST_CVector p_is_val
Definition: EST_Track.h:95
int length() const
Definition: EST_UList.cc:57
const EST_String channel_name(int channel, const EST_ChannelNameMap &map, int strings_override=1) const
Definition: EST_Track.cc:138
float estimate_shift(float x)
Definition: EST_Track.cc:771
EST_ChannelNameMap EST_default_channel_names
Definition of standard names we use for channels.
static T * error_return
Definition: EST_TVector.h:227
EST_read_status
INFO & info(ENUM token) const
EST_write_status save_channel_names(const EST_String name)
Definition: EST_Track.cc:1370
EST_write_status Save_File(SaveTrackFileArgs)
Definition: EST_TrackFile.h:71
void set_aux_channel_name(const EST_String &name, int channel)
set the name of the auxiliary channel.
Definition: EST_Track.cc:173
#define format_ok
void copy_sub_track_out(EST_Track &st, const EST_FVector &frame_times) const
Definition: EST_Track.cc:1178
EST_Val & aux(ssize_t i, int c)
Definition: EST_Track.cc:428
EST_StrVector p_aux_names
Definition: EST_Track.h:98
int interp_value(float x, float f)
Definition: EST_Track.cc:737
void rm_trailing_breaks()
Definition: EST_Track.cc:847
EST_UItem * head() const
Definition: EST_UList.h:97
int val(ssize_t i) const
return true if frame i is a value
Definition: EST_Track.cc:542
float shift() const
Definition: EST_Track.cc:602
void resize(ssize_t rows, ssize_t cols, ssize_t set=1)
Definition: EST_TMatrix.cc:250
INLINE const T & a_no_check(ssize_t row, ssize_t col) const
const access with no bounds check, care recommend
Definition: EST_TMatrix.h:182
void resize(int rows, int cols, int set=1)
resize matrix
EST_String after(int pos, int len=1) const
Part after pos+len.
Definition: EST_String.h:308
EST_String before(int pos, int len=0) const
Part before position.
Definition: EST_String.h:276
int empty() const
returns true if no values are set in the frame
Definition: EST_Track.cc:1038
LISP fp
Definition: kkcompile.cc:63
#define TRUE
Definition: EST_bool.h:118
void frame(EST_FVector &fv, int n, int startf=0, int nf=EST_ALL)
Definition: EST_Track.h:210
void set_equal_space(bool t)
Definition: EST_Track.h:675
EST_Track & operator|=(const EST_Track &a)
Definition: EST_Track.cc:362
EST_StrVector p_channel_names
Definition: EST_Track.h:103
void fill_time(float t, int start=1)
Definition: EST_Track.cc:789
void copy_sub_track(EST_Track &st, int start_frame=0, int nframes=EST_ALL, int start_chan=0, int nchans=EST_ALL) const
Definition: EST_Track.cc:1139
void resize(int n, int set=1)
resize vector
const EST_String aux_channel_name(int channel) const
Definition: EST_Track.h:728
#define NO_SUCH_CHANNEL
Returned if we ask for a channel not in the map.
Definition: EST_TrackMap.h:86
EST_TrackMap::P map() const
Definition: EST_Track.h:698
Value to return for errors, never occurs in TrackMaps.
Utility EST_String Functions header file.