43 #include "EST_error.h"
112 return fabs(e.
F(
"rise_amp")) + fabs(e.
F(
"fall_amp"));
117 return e.
F(
"rise_dur") + e.
F(
"fall_dur");
122 return (
float)(fabs(e.
F(
"rise_amp")) - fabs(e.
F(
"fall_amp"))) /
123 (float)(fabs(e.
F(
"rise_amp")) + fabs(e.
F(
"fall_amp")));
128 return (
float)(fabs(e.
F(
"rise_dur")) - fabs(e.
F(
"fall_dur"))) /
129 (float)(e.
F(
"rise_dur") + e.
F(
"fall_dur"));
135 t_tilt = (rfc_to_a_tilt(e) + rfc_to_d_tilt(e)) / 2;
143 return e.
F(
"amp") * (1 + e.
F(
"tilt")) / 2.0;
148 return e.
F(
"dur") * (1 + e.
F(
"tilt")) / 2.0;
153 return -e.
F(
"amp") * (1 - e.
F(
"tilt")) / 2.0;
158 return e.
F(
"dur") * (1 - e.
F(
"tilt")) / 2.0;
163 return e->
F(
"ev:start_f0") + tilt_to_rise_amp(e->
A(
"tilt"));
168 return e->
F(
"start") + tilt_to_rise_dur(e->
A(
"tilt"));
174 tilt.
set(
"amp", rfc_to_tilt_amp(rfc));
175 tilt.
set(
"dur", rfc_to_tilt_dur(rfc));
176 tilt.
set(
"tilt", rfc_to_t_tilt(rfc));
184 if (ev.
f(
"intonation_style") !=
"rfc")
185 EST_error(
"Can't create Tilt parameters from intonation style: %s\n",
186 (
const char *)ev.
f.
S(
"intonation_style"));
188 for (e = ev.
head(); e != 0; e = e->next())
192 rfc_to_tilt(e->
A(
"rfc"), e->
A(
"tilt"));
194 ev.
f.
set(
"intonation_style",
"tilt");
199 rfc.
set(
"rise_amp", tilt_to_rise_amp(tilt));
200 rfc.
set(
"rise_dur", tilt_to_rise_dur(tilt));
201 rfc.
set(
"fall_amp", tilt_to_fall_amp(tilt));
202 rfc.
set(
"fall_dur", tilt_to_fall_dur(tilt));
211 if (ev.
f(
"intonation_style") !=
"tilt")
212 EST_error(
"Can't create RFC parameters for intonation_style: %s\n",
213 (
const char *)ev.
f.
S(
"intonation_style"));
215 for (e = ev.
head(); e ; e = e->next())
219 tilt_to_rfc(e->
A(
"tilt"), e->
A(
"rfc"));
222 ev.
f.
set(
"intonation_style",
"rfc");
225 void scale_tilt(
EST_Relation &ev,
float shift,
float scale)
229 for (e = ev.
head(); e; e = e->next())
231 e->
set(
"ev.f0", (e->
F(
"ev.f0") + shift));
233 e->
set(
"tilt.amp", (e->
F(
"tilt.amp") * scale));
241 for (e = ev.
head(); e; e = e->next())
245 if ((e->
F(
"rfc.rise_amp") > 0.0) && (e->
F(
"rfc.fall_amp") < 0.0))
246 e->
set(
"rfc.type",
"RISEFALL");
247 else if (e->
F(
"rfc.rise_amp") > 0.0)
248 e->
set(
"rfc.type",
"RISE");
250 e->
set(
"rfc.type",
"FALL");
253 e->
set(
"rfc.type",
"SIL");
263 if (int_lab.
f(
"timing_style") !=
"segment")
264 EST_error(
"Undefined timing style:%s in relation\n",
265 (
const char *)int_lab.
f.
S(
"timing_style"));
267 for (e = int_lab.
head(); e != 0; e = e->next())
269 e->
set(
"start", start);
273 for (e = int_lab.
head(); e != 0; e = inext)
276 if (event_item(*e) || sil_item(*e))
288 int_lab.
f.
set(
"timing_style",
"unit");
295 e->
set(
"start", e->
F(
"start"));
307 void event_to_segment(
EST_Relation &ev,
float min_length)
313 if (ev.
f.
S(
"timing_style") !=
"event")
316 for (e = ev.
head(); e->next() != 0; e = e->next())
319 if ((n->
F(
"start") - e->
F(
"end")) > min_length)
321 dummy = e->insert_after();
323 dummy->
set(
"end", n->
F(
"start"));
346 ev.
f.
set(
"timing_style",
"segment");
374 float unit_curve(
float amp,
float dur,
float t)
379 x = (t / (dur)) * 2.0;
381 val = pow(x,
float(2.0));
383 val = 2 - pow((
float(2.0) - x),
float(2.0));
393 float fncurve(
float length,
float t,
float curve)
398 x = (t / length) * 2.0;
403 val = 2 - pow((2 - x), curve);
412 return e.
I(
"int_event", 0);
416 return ((e.name() ==
"sil") || (e.name() ==
"SIL"));
420 return ((e.name() ==
"c") || (e.name() ==
"C"));