Edinburgh Speech Tools  2.4-release
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
EST_Event.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 /* Author : Paul Taylor */
34 /* Date : July 1995 */
35 /*-----------------------------------------------------------------------*/
36 /* Event class header file */
37 /* */
38 /*=======================================================================*/
39 
40 // Warning: These event classes can be used as items in the EST_Stream
41 // int he normal way. However, the EventSI class has internal pointers to
42 // adjacent events which it uses to work out various parameters. Thus,
43 // when making a EST_Stream of events, it is important to link the events
44 // pointers as well.
45 
46 #ifndef __Event_H__
47 #define __Event_H__
48 
49 #include <EST_String.h>
50 
51 #ifndef FALSE
52 # define FALSE (0)
53 #endif
54 #ifndef TRUE
55 # define TRUE (1)
56 #endif
57 
58 
59 //class RFCelement{
60 // float amp;
61 // float dur;
62 // float start_amp;
63 // float start_pos;
64 // EST_String type;
65 //};
66 
67 class EventBase{
68  private:
69  public:
70  EST_String type;
71  int save(EST_String filename, EST_String type = "");
72 
73 };
74 
75 class EventRFC: public EventBase{
76 public:
77  void init() {rise_amp = 0.0; rise_dur = 0.0;
78  start_amp =0.0; fall_amp = 0.0; fall_dur = 0.0;
79  start_pos = 0.0; peak_pos = 0.0; type = ""; }
80 
81  float rise_amp;
82  float rise_dur;
83  float fall_amp;
84  float fall_dur;
85  float peak_pos;
86  float start_amp;
87  float start_pos;
88  friend ostream& operator << (ostream& s, EventRFC &e)
89  {
90  s << e.type << " " << e.rise_amp << " " << e.rise_dur
91  << " " << e.fall_amp << " " << e.fall_dur
92  << " " << e.start_amp << " " << e.start_pos
93  << endl;
94  return s;
95  }
96 };
97 
98 class EventSI: public EventBase {
99 private:
100  float s_f0;
101  float s_pos;
102  float p_f0;
103  float p_pos;
104  float e_pos;
105  float e_f0;
106 
107 public:
108  void init();
109 
110  float amp();
111  float dur();
112 
113  float rise_amp();
114  float rise_dur();
115  float fall_amp();
116  float fall_dur();
117 
118  float start_f0();
119  float start_pos();
120  float peak_f0();
121  float peak_pos();
122  float end_f0();
123  float end_pos();
124 
125  void set_start_f0(float a);
126  void set_start_pos(float a);
127  void set_peak_f0(float a);
128  void set_peak_pos(float a);
129  void set_end_f0(float a);
130  void set_end_pos(float a);
131 
132  EventSI *sn;
133  EventSI *sp;
134 
135  friend ostream& operator << (ostream& s, EventSI &e)
136  {
137  s << e.type << " ra:" << e.rise_amp() << " rd:" << e.rise_dur()
138  << "fa: " << e.fall_amp() << " fd:" << e.fall_dur()
139  << " sf0:" << e.start_f0() << " spos:" << e.start_pos()
140  << " pf0:" << e.peak_f0() << " ppos:" << e.peak_pos()
141  << " ef0:" << e.end_f0() << " epos:" << e.end_pos()
142  << endl;
143  return s;
144  }
145 };
146 
147 class EventTilt: public EventBase{
148 private:
149  float samp;
150  float sdur;
151  float stilt;
152  float spos;
153  float s_f0;
154  float s_pos;
155 
156 public:
157  void init();
158 
159  float amp();
160  float dur();
161  float tilt();
162  float pos();
163 
164  void set_amp(float a);
165  void set_dur(float a);
166  void set_tilt(float a);
167  void set_pos(float a);
168 
169  float start_f0();
170  float start_pos();
171  void set_start_f0(float a);
172  void set_start_pos(float a);
173 
174  friend ostream& operator << (ostream& s, EventTilt &e)
175  {
176  s << e.type << " " << e.amp() << " " << e.dur()
177  << " " << e.tilt() << " " << e.pos()
178  << " sf0 " << e.start_f0() << " " << e.start_pos()
179  << endl;
180  return s;
181  }
182 
183 };
184 
185 void gc_eventsi(void *w);
186 void gc_eventtilt(void *w);
187 void gc_eventrfc(void *w);
188 
189 #endif // __Event_H__