108 op.
set(
"start_limit", 0.1);
109 op.
set(
"stop_limit", 0.1);
110 op.
set(
"range", 0.3);
111 op.
set(
"min_event_duration", 0.03);
118 float start_search, end_search;
124 cout <<
"rfc_recognise\n";
132 cout <<
"rfc_recognise\n";
137 for (e = ev.
head(); e != 0; e = n)
143 end_search = e->
F(
"end") + op.
F(
"stop_limit");
144 start_search = e->
F(
"start") - op.
F(
"start_limit");
148 cout <<
"start = " << e->
F(
"start") <<
" End " 149 << e->
F(
"end")<< endl;
150 cout <<
"s start = " << start_search <<
" sEnd " 151 << end_search << endl;
155 if (comp_extract(fz, part, start_search, end_search,
156 op.
F(
"min_event_duration")))
157 rf_match(part, *e, op.
F(
"range"));
166 make_int_item(*tmp,
"sil", fz.
t(0), fz.
t(fz.
num_frames() - 1),
174 convert_to_local(ev);
179 ev.
f.
set(
"intonation_style",
"rfc");
183 cout <<
"After RFC analysis\n";
196 static void convert_to_local(
EST_Item *e)
198 if (e->
S(
"rfc.type",
"0") ==
"RISEFALL")
200 e->
set(
"rfc.rise_amp", (e->
F(
"rfc.peak_f0") - e->
F(
"ev.start_f0")));
201 e->
set(
"rfc.rise_dur", (e->
F(
"rfc.peak_pos") - e->
F(
"start")));
202 e->
set(
"rfc.fall_amp", (e->
F(
"rfc.end_f0") - e->
F(
"rfc.peak_f0")));
203 e->
set(
"rfc.fall_dur", (e->
F(
"end") - e->
F(
"rfc.peak_pos")));
204 e->
set(
"ev.f0", e->
F(
"rfc.peak_f0"));
208 e->
A(
"rfc").
remove(
"peak_pos");
213 else if (e->
S(
"rfc.type",
"0") ==
"RISE")
215 e->
set(
"rfc.rise_amp", (e->
F(
"rfc.end_f0") - e->
F(
"ev.start_f0")));
216 e->
set(
"rfc.rise_dur", (e->
F(
"end") - e->
F(
"start")));
217 e->
set(
"rfc.fall_amp", 0.0);
218 e->
set(
"rfc.fall_dur", 0.0);
219 e->
set(
"ev.f0", e->
F(
"rfc.end_f0"));
223 e->
A(
"rfc").
remove(
"peak_pos");
228 else if (e->
S(
"rfc.type",
"0") ==
"FALL")
230 e->
set(
"rfc.rise_amp", 0.0);
231 e->
set(
"rfc.rise_dur", 0.0);
232 e->
set(
"rfc.fall_amp", (e->
F(
"rfc.end_f0") - e->
F(
"ev.start_f0")));
233 e->
set(
"rfc.fall_dur", (e->
F(
"end") - e->
F(
"start")));
234 e->
set(
"ev.f0", e->
F(
"ev.start_f0"));
237 e->
A(
"rfc").
remove(
"peak_pos");
243 e->
set(
"time", (e->
F(
"end") - e->
F(
"rfc.fall_dur")));
250 for (e = ev.
head(); e; e = e->
next())
263 ev.
f.
set(
"timing_style",
"event");
269 &
end,
float min_length)
302 if ((tr_tmp.
end() - tr_tmp.
start()) < min_length)
304 cout <<
"Contour too small for analysis\n";
324 int longest, s_c, s_l;
325 longest = s_c = s_l = 0;
330 if ((i - s_c) > longest)
332 longest = i - s_c - 1;
340 if ((i - s_c) > longest)
342 longest = i - s_c - 1;
349 extract2(tr_tmp, tr_tmp.
t(s_l), tr_tmp.
t(s_l + longest), part);
362 if ((fz.
a(i) >= 0.0) && (fz.
a(i + 1) < 0.0))
378 ssize_t b_start, b_stop, e_start, e_stop, region;
383 ev.
set(
"start", 0.0);
385 ev.
set(
"rfc", empty);
386 ev.
set(
"ev.start_f0", 0.0);
387 ev.
set(
"rfc.peak_f0", 0.0);
388 ev.
set(
"rfc.peak_pos", 0.0);
396 n = zero_cross(diff);
404 region = (
int)(range *
float(stop - b_start));
406 region = region > 0 ? region : 1;
408 b_stop = b_start + region;
409 e_start = stop - region;
410 e_stop = stop + region;
412 e_start = (e_start < b_stop)? b_stop : e_start;
416 match_rf_point(fz, b_start, b_stop, e_start, e_stop, start, stop);
419 ev.
set(
"ev.start_f0", fz.
a(start));
420 ev.
set(
"start", fz.
t(start));
428 region = (
int)(range *
float(e_stop - b_start));
429 region = region > 0 ? region : 1;
430 e_start = e_stop - region;
435 match_rf_point(fz, b_start, b_stop, e_start, e_stop, start, stop);
441 ev.
set(
"rfc.peak_f0", fz.
a(start));
442 ev.
set(
"rfc.peak_pos", fz.
t(start));
443 ev.
set(
"rfc.end_f0", fz.
a(stop));
445 ev.
set(
"end", fz.
t(stop));
446 ev.
set(
"rfc.type",
"RISEFALL");
466 region = (
int)(range *
float(e_stop - b_start));
467 region = region > 0 ? region : 1;
469 b_stop = b_start + region;
470 e_start = e_stop - region;
475 match_rf_point(fz, b_start, b_stop, e_start, e_stop, start, stop);
477 ev.
set(
"start", fz.
t(start));
478 ev.
set(
"ev.start_f0", fz.
a(start));
479 ev.
set(
"rfc.peak_f0", 0.0);
480 ev.
set(
"rfc.peak_pos", 0.0);
482 ev.
set(
"rfc.end_f0", fz.
a(stop));
483 ev.
set(
"end", fz.
t(stop));
488 ev.
set(
"rfc.type",
"RISE");
490 ev.
set(
"rfc.type",
"FALL");
502 for (e = ev.
head(); e; e = e->
next())
507 e->
set(
"ev.start_f0", fz.
a(i));
509 e->
set(
"ev.end_f0", fz.
a(i));
520 for (e = ev.
head(); e; e = n)
528 s->
set(
"name",
"phrase_end");
529 s->
set(
"ev.f0", e->
F(
"ev.start_f0"));
530 s->
set(
"time", e->
F(
"start"));
535 s->
set(
"name",
"phrase_start");
536 s->
set(
"ev.f0", e->
F(
"ev.end_f0"));
537 s->
set(
"time", e->
F(
"end"));
542 for (e = ev.
head(); e; e = n)
608 static void make_int_item(
EST_Item &tmp,
610 float start_f0,
float peak_pos,
619 tmp.
set(
"ev", dummy);
620 tmp.
set(
"ev.start_f0", start_f0);
622 if ((name !=
"sil") && (name !=
"c"))
624 tmp.
set(
"rfc", dummy);
625 tmp.
set(
"rfc.peak_pos", peak_pos);
626 tmp.
set(
"rfc.peak_f0", peak_f0);
627 tmp.
set(
"rfc.pos", 1);
635 float distance = 0.0;
638 for (i = 0; i < num_points; ++i)
640 diff = fz.
a(i + pos) - new_fz.
a(i);
643 distance += (diff * diff);
663 float s_pos, e_pos, s_freq, e_freq, t;
672 if ((b_start >= b_stop) || (b_start < 0))
674 cerr <<
"Illegal beginning search region in match_rf_point:" <<
675 b_start <<
"-" << b_stop << endl;
678 if ((e_start >= e_stop) || (e_stop > fz.
num_frames()))
680 cerr <<
"Illegal ending search region in match_rf_point:" <<
681 e_start <<
"-" << e_stop << endl;
685 f_shift = fz.
shift();
688 for (i = b_start; i < b_stop; ++i)
689 for (j = e_start; j < e_stop; ++j)
697 duration = e_pos - s_pos;
698 amp = e_freq - s_freq;
701 for (k = 0; k < length + 1; ++k)
703 t = ((float) k) * f_shift;
704 new_fz.
a(k) = (amp *
fncurve(duration, t, 2.0))
708 dist = distance(fz, i, new_fz, length);
709 ndist = dist / (duration * 100.0);
710 ndist *= weight(duration);
712 if (ndist < min_dist)
float fncurve(float length, float t, float curve)
float end(const EST_Item &item)
ssize_t prev_non_break(ssize_t i) const
int sil_item(EST_Item &e)
float end() const
return time of last value in track
void remove_item(EST_Item *item)
void set(const EST_String &name, ssize_t ival)
void int_segment_to_unit(EST_Relation &a, EST_Relation &ev)
void set(const EST_String &name, int ival)
ssize_t index(float t) const
return the frame index nearest time t
int track_break(ssize_t i) const
return true if frame i is a break
void rfc_analysis(EST_Track &fz, EST_Relation &ev, EST_Features &op)
void set_name(const EST_String &name) const
float & t(ssize_t i=0)
return time position of frame i
float & a(ssize_t i, int c=0)
ssize_t next_non_break(ssize_t i) const
float F(const EST_String &name) const
void extract2(EST_Track &orig, float start, float end, EST_Track &ret)
float min(float a, float b)
EST_Item * insert_before(EST_Item *li=0)
void remove(const EST_String &name)
void print_event(EST_Item &ev)
int present(const EST_String &name) const
EST_Item * insert_after(EST_Item *li=0)
ssize_t num_frames() const
return number of frames in track
EST_Features & A(const EST_String &name) const
float start() const
return time of first value in track
float start(const EST_Item &item)
int event_item(EST_Item &e)
float duration(EST_Item *n)
void rm_trailing_breaks()
const EST_String S(const EST_String &name) const
EST_Item * append(EST_Item *si)
void remove_item_feature(const EST_String &name)
EST_Track differentiate(EST_Track &c, float samp_int=0.0)
float F(const EST_String &path) const
void default_rfc_params(EST_Features &op)
int f_present(const EST_String &name) const