Edinburgh Speech Tools  2.4-release
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
track_regression.cc
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 void dump_track(EST_Track &tr, EST_String comment)
48 {
49  printf("[ Track %s\n", (const char *)comment);
50  for (int f=0; f<tr.num_frames(); f++)
51  if (tr.val(f))
52  {
53  printf(" %3d:\t%3.3f", f, tr.t(f));
54  for(int c=0; c<tr.num_channels(); c++)
55  printf("\t%3.3f", tr.a(f,c));
56  printf("\n");
57  }
58  else
59  printf(" BREAK\n");
60  printf("]\n");
61 }
62 
63 int main(void)
64 
65 {
66  EST_Track tr(20,2);
67  EST_Track pm(20,0);
68 
69  // This is different on different architectures (of course)
70  // cout << "EST_Track size = " << sizeof(EST_Track) << " bytes.\n";
71 
72  for(int i1=0; i1<tr.num_frames(); i1++)
73  for(int j1=0; j1<tr.num_channels(); j1++)
74  {
75  tr.a(i1,j1) = i1 + j1/100.0;
76  tr.t(i1) = i1*0.5;
77  pm.t(i1) = i1*1.5;
78  }
79 
80  dump_track(tr, "Original track");
81 
82  tr.rm_trailing_breaks();
83 
84  dump_track(tr, "Breaks Trimmed");
85 
86  for(int b=0; b<3; b++)
87  {
88  tr.set_break(b);
89  tr.set_break(10+b);
90  tr.set_break(tr.num_frames()-b-1);
91  }
92 
93  dump_track(tr, "Breaks");
94 
95  tr.rm_trailing_breaks();
96 
97  dump_track(tr, "Breaks Trimmed");
98 
99  tr.resize(tr.num_frames(), tr.num_channels());
100 
101  dump_track(tr, "resized to same size");
102 
103  EST_Track st, cpy, cpy2;
104 
105  tr.sub_track(st, 3, 7, 0, EST_ALL);
106 
107  dump_track(st, "Sub Track");
108 
109  cpy = st;
110 
111  dump_track(cpy, "Copied");
112 
113  tr.copy_sub_track(cpy2 , 3, 7, 0, EST_ALL);
114 
115  dump_track(cpy2, "Copied Directly");
116 
117  dump_track(pm, "Pitch Marks");
118 
119  pm.resize(10,EST_CURRENT);
120 
121  dump_track(pm, "Resized Pitch Marks");
122 
123  return(0);
124 }
125