Edinburgh Speech Tools  2.1-release
track_regression.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  /* */
34  /* Author: Richard Caley (rjc@cstr.ed.ac.uk) */
35  /* Date: Fri May 9 1997 */
36  /* ------------------------------------------------------------------- */
37  /* Example of declaration and use of tracks. */
38  /* */
39  /*************************************************************************/
40 
41 
42 #include <iostream>
43 #include <cstdlib>
44 #include "EST_TrackMap.h"
45 #include "EST_Track.h"
46 
47 using namespace std;
48 
49 void dump_track(EST_Track &tr, EST_String comment)
50 {
51  printf("[ Track %s\n", (const char *)comment);
52  for (ssize_t f=0; f<tr.num_frames(); f++)
53  if (tr.val(f))
54  {
55  printf(" %3zd:\t%3.3f", f, tr.t(f));
56  for(ssize_t c=0; c<tr.num_channels(); c++)
57  printf("\t%3.3f", tr.a(f,c));
58  printf("\n");
59  }
60  else
61  printf(" BREAK\n");
62  printf("]\n");
63 }
64 
65 int main(void)
66 
67 {
68  EST_Track tr(20,2);
69  EST_Track pm(20,0);
70 
71  // This is different on different architectures (of course)
72  // cout << "EST_Track size = " << sizeof(EST_Track) << " bytes.\n";
73 
74  for(ssize_t i1=0; i1<tr.num_frames(); i1++)
75  for(ssize_t j1=0; j1<tr.num_channels(); j1++)
76  {
77  tr.a(i1,j1) = i1 + j1/100.0;
78  tr.t(i1) = i1*0.5;
79  pm.t(i1) = i1*1.5;
80  }
81 
82  dump_track(tr, "Original track");
83 
84  tr.rm_trailing_breaks();
85 
86  dump_track(tr, "Breaks Trimmed");
87 
88  for(int b=0; b<3; b++)
89  {
90  tr.set_break(b);
91  tr.set_break(10+b);
92  tr.set_break(tr.num_frames()-b-1);
93  }
94 
95  dump_track(tr, "Breaks");
96 
97  tr.rm_trailing_breaks();
98 
99  dump_track(tr, "Breaks Trimmed");
100 
101  tr.resize(tr.num_frames(), tr.num_channels());
102 
103  dump_track(tr, "resized to same size");
104 
105  EST_Track st, cpy, cpy2;
106 
107  tr.sub_track(st, 3, 7, 0, EST_ALL);
108 
109  dump_track(st, "Sub Track");
110 
111  cpy = st;
112 
113  dump_track(cpy, "Copied");
114 
115  tr.copy_sub_track(cpy2 , 3, 7, 0, EST_ALL);
116 
117  dump_track(cpy2, "Copied Directly");
118 
119  dump_track(pm, "Pitch Marks");
120 
121  pm.resize(10,EST_CURRENT);
122 
123  dump_track(pm, "Resized Pitch Marks");
124 
125  return(0);
126 }
127 
void set_break(ssize_t i)
set frame i to be a break
Definition: EST_Track.cc:124
int num_channels() const
return number of channels in track
Definition: EST_Track.h:657
const int EST_CURRENT
int ssize_t
const int EST_ALL
void resize(ssize_t num_frames, int num_channels, bool preserve=1)
Definition: EST_Track.cc:214
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
int main(void)
float & t(ssize_t i=0)
return time position of frame i
Definition: EST_Track.h:478
float & a(ssize_t i, int c=0)
Definition: EST_Track.cc:1025
void dump_track(EST_Track &tr, EST_String comment)
f
Definition: EST_item_aux.cc:48
ssize_t num_frames() const
return number of frames in track
Definition: EST_Track.h:651
void rm_trailing_breaks()
Definition: EST_Track.cc:847
int val(ssize_t i) const
return true if frame i is a value
Definition: EST_Track.cc:542
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