43 #include "EST_cmd_line_options.h"
44 #include "EST_cmd_line.h"
45 #include "EST_speech_class.h"
46 #include "sigpr/EST_pitchmark.h"
71 int main (
int argc,
char *argv[])
82 EST_String(
"[input file] -o [output file] [options]")+
83 "Summary: pitchmark laryngograph (lx) files\n"
84 "use \"-\" to make input and output files stdin/out\n"
85 "-h Options help\n\n"+
87 options_track_output()+
88 "-lx_lf <int> lx low frequency cutoff\n\n"
89 "-lx_lo <int> lx low order\n\n"
90 "-lx_hf <int> lx high frequency cutoff\n\n"
91 "-lx_ho <int> lx high order\n\n"
92 "-df_lf <int> df low frequeny cutoff\n\n"
93 "-df_lo <int> df low order\n\n"
94 "-med_o <int> median smoothing order\n\n"
95 "-mean_o <int> mean smoothing order\n\n"
96 "-inv Invert polarity of lx signal. Often the lx signal \n"
97 " is upside down. This option inverts the signal prior to \n"
99 "-fill Insert and remove pitchmarks according to min, max\n"
100 " and def period values. Often it is desirable to place limits\n"
101 " on the values of the pitchmarks. This option enforces a \n"
102 " minimum and maximum pitch period (specified by -man and -max).\n"
103 " If the maximum pitch setting is low enough, this will \n"
104 " esnure that unvoiced regions have evenly spaced pitchmarks \n\n"
105 "-min <float> Minimum allowed pitch period, in seconds\n\n"
106 "-max <float> Maximum allowed pitch period, in seconds\n\n"
107 "-def <float> Default pitch period in seconds, used for a guide\n"
108 " as to what length pitch periods should be in unvoiced \n"
110 "-pm <ifile> Input is raw pitchmark file. This option is \n"
111 " used to perform filling operations on an already existing \n"
112 " set of pitchmarks \n\n"
113 "-f0 <ofile> Calculate F0 from pitchmarks and save to file\n\n"
114 "-end <float> Specify the end time of the last pitchmark, for use \n"
115 " with the -fill option\n\n"
116 "-wave_end Use the end of a waveform to specify when the \n"
117 " last pitchmark position should be. The waveform file is only \n"
118 " read to determine its end, no processing is performed\n\n"
119 "-inter Output intermediate waveforms. This will output the \n"
120 " signal at various stages of processing. Examination of these \n"
121 " waveforms is extremely useful in setting the parameters for \n"
122 " similar waveforms\n\n"
123 "-style <string> \"track\" or \"lab\"\n\n", files, al);
130 if (read_wave(lx, files.
first(), al) != read_ok)
143 op.
set(
"pm_end", lx.
end());
157 pm_fill(pm, op.
F(
"pm_end"), op.
F(
"max_period"),
158 op.
F(
"min_period"), op.
F(
"def_period"));
159 pm_fill(pm, op.
F(
"pm_end"), op.
F(
"max_period"),
160 op.
F(
"min_period"), op.
F(
"def_period"));
171 pm_to_label(pm, lab);
172 if (lab.
save(out_file +
".pm_lab") != write_ok)
177 save_msec(pm, out_file +
".pm");
181 save_ogi_bin(pm, out_file +
".pmv", lx.
sample_rate());
183 else if (pm.
save(out_file, al.
val(
"-otype", 0)) != write_ok)
185 cerr <<
"pitchmark: failed to write output to \""
186 << out_file <<
"\"" << endl;
199 outf =
new ofstream(filename);
205 outf->setf(ios::fixed, ios::floatfield);
209 *outf << pm.
t(i) * 1000.0 << endl;
223 d[i] =
int(pm.
t(i) * (float) sr);
225 if ((fp = fopen(filename,
"wb")) == NULL)
226 return misc_write_error;
228 if (fwrite(d, pm.
num_frames(),
sizeof(int), fp) != 1)
231 return misc_write_error;
281 op.
set(
"lx_low_frequency", LX_LOW_FREQUENCY);
282 op.
set(
"lx_low_order", LX_LOW_ORDER);
283 op.
set(
"lx_high_frequency", LX_HIGH_FREQUENCY);
284 op.
set(
"lx_high_order", LX_HIGH_ORDER);
285 op.
set(
"df_low_frequency", DF_LOW_FREQUENCY);
286 op.
set(
"df_low_order", DF_LOW_ORDER);
287 op.
set(
"min_period", MIN_PERIOD);
288 op.
set(
"max_period", MAX_PERIOD);
289 op.
set(
"def_period", DEF_PERIOD);
290 op.
set(
"pm_end", PM_END);
293 op.
set(
"lx_low_frequency", al.
ival(
"-lx_lf", 0));
295 op.
set(
"lx_low_order", al.
ival(
"-lx_lo", 0));
297 op.
set(
"lx_high_frequency", al.
ival(
"-lx_hf", 0));
299 op.
set(
"lx_high_order", al.
ival(
"-lx_ho", 0));
301 op.
set(
"median_order", al.
ival(
"-med_o", 0));
303 op.
set(
"mean_order", al.
ival(
"-mean_o", 0));
305 op.
set(
"df_low_frequency", al.
ival(
"-df_lf", 0));
307 op.
set(
"df_low_order", al.
ival(
"-df_lo", 0));
309 op.
set(
"min_period", al.
fval(
"-min", 0));
311 op.
set(
"max_period", al.
fval(
"-max", 0));
313 op.
set(
"def_period", al.
fval(
"-def", 0));
315 op.
set(
"pm_end", al.
fval(
"-end", 0));
317 op.
set(
"pm_debug", 1);
A class for storing digital waveforms. The waveform is stored as an array of 16 bit shorts...
const T & first() const
return const reference to first item in list
void pm_fill(EST_Track &pm, float new_end, float max, float min, float def)
float & t(int i=0)
return time position of frame i
int override_ival(const EST_String rkey, const int rval)
add to end of list or overwrite. If rval is empty, do nothing
int ival(const EST_String &rkey, int m=1) const
int override_fval(const EST_String rkey, const float rval)
add to end of list or overwrite. If rval is empty, do nothing
float fval(const EST_String &rkey, int m=1) const
void pm_min_check(EST_Track &pm, float min)
void set(const EST_String &name, int ival)
const float F(const EST_String &path) const
EST_read_status load(const EST_String name, float ishift=0.0, float startt=0.0)
EST_write_status save(const EST_String name, const EST_String EST_filetype="")
const int present(const K &rkey) const
Returns true if key is present.
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
float end()
return the time position of the last sample.
int sample_rate() const
return the sampling rate (frequency)
int contains(const char *s, int pos=-1) const
Does it contain this substring?
int num_frames() const
return number of frames in track
EST_write_status save(const EST_String &filename, bool evaluate_ff=false) const
EST_Track pitchmark(EST_Wave &lx, EST_Features &op)