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" 153 int main (
int argc,
char *argv[])
164 EST_String(
"[input file] -o [output file] [options]")+
165 "Summary: pitchmark laryngograph (lx) files\n" 166 "use \"-\" to make input and output files stdin/out\n" 167 "-h Options help\n\n"+
168 options_wave_input()+
169 options_track_output()+
170 "-lx_lf <int> lx low frequency cutoff\n\n" 171 "-lx_lo <int> lx low order\n\n" 172 "-lx_hf <int> lx high frequency cutoff\n\n" 173 "-lx_ho <int> lx high order\n\n" 174 "-df_lf <int> df low frequeny cutoff\n\n" 175 "-df_lo <int> df low order\n\n" 176 "-med_o <int> median smoothing order\n\n" 177 "-mean_o <int> mean smoothing order\n\n" 178 "-inv Invert polarity of lx signal. Often the lx signal \n" 179 " is upside down. This option inverts the signal prior to \n" 181 "-fill Insert and remove pitchmarks according to min, max\n" 182 " and def period values. Often it is desirable to place limits\n" 183 " on the values of the pitchmarks. This option enforces a \n" 184 " minimum and maximum pitch period (specified by -man and -max).\n" 185 " If the maximum pitch setting is low enough, this will \n" 186 " esnure that unvoiced regions have evenly spaced pitchmarks \n\n" 187 "-min <float> Minimum allowed pitch period, in seconds\n\n" 188 "-max <float> Maximum allowed pitch period, in seconds\n\n" 189 "-def <float> Default pitch period in seconds, used for a guide\n" 190 " as to what length pitch periods should be in unvoiced \n" 192 "-pm <ifile> Input is raw pitchmark file. This option is \n" 193 " used to perform filling operations on an already existing \n" 194 " set of pitchmarks \n\n" 195 "-f0 <ofile> Calculate F0 from pitchmarks and save to file\n\n" 196 "-end <float> Specify the end time of the last pitchmark, for use \n" 197 " with the -fill option\n\n" 198 "-wave_end Use the end of a waveform to specify when the \n" 199 " last pitchmark position should be. The waveform file is only \n" 200 " read to determine its end, no processing is performed\n\n" 201 "-inter Output intermediate waveforms. This will output the \n" 202 " signal at various stages of processing. Examination of these \n" 203 " waveforms is extremely useful in setting the parameters for \n" 204 " similar waveforms\n\n" 205 "-style <string> \"track\" or \"lab\"\n\n", files, al);
212 if (read_wave(lx, files.
first(), al) != read_ok)
221 pm = pitchmark(lx, op);
225 op.
set(
"pm_end", lx.
end());
239 pm_fill(pm, op.
F(
"pm_end"), op.
F(
"max_period"),
240 op.
F(
"min_period"), op.
F(
"def_period"));
241 pm_fill(pm, op.
F(
"pm_end"), op.
F(
"max_period"),
242 op.
F(
"min_period"), op.
F(
"def_period"));
245 pm_min_check(pm, al.
fval(
"-min"));
253 pm_to_label(pm, lab);
254 if (lab.
save(out_file +
".pm_lab") != write_ok)
259 save_msec(pm, out_file +
".pm");
263 save_ogi_bin(pm, out_file +
".pmv", lx.
sample_rate());
265 else if (pm.
save(out_file, al.
val(
"-otype", 0)) != write_ok)
267 cerr <<
"pitchmark: failed to write output to \"" 268 << out_file <<
"\"" << endl;
281 outf =
new ofstream(filename);
287 outf->setf(ios::fixed, ios::floatfield);
291 *outf << pm.
t(i) * 1000.0 << endl;
305 d[i] =
int(pm.
t(i) * (float) sr);
307 if ((fp = fopen(filename,
"wb")) == NULL)
308 return misc_write_error;
310 if (fwrite(d, pm.
num_frames(),
sizeof(int), fp) != 1)
313 return misc_write_error;
363 op.
set(
"lx_low_frequency", LX_LOW_FREQUENCY);
364 op.
set(
"lx_low_order", LX_LOW_ORDER);
365 op.
set(
"lx_high_frequency", LX_HIGH_FREQUENCY);
366 op.
set(
"lx_high_order", LX_HIGH_ORDER);
367 op.
set(
"df_low_frequency", DF_LOW_FREQUENCY);
368 op.
set(
"df_low_order", DF_LOW_ORDER);
369 op.
set(
"min_period", MIN_PERIOD);
370 op.
set(
"max_period", MAX_PERIOD);
371 op.
set(
"def_period", DEF_PERIOD);
372 op.
set(
"pm_end", PM_END);
375 op.
set(
"lx_low_frequency", al.
ival(
"-lx_lf", 0));
377 op.
set(
"lx_low_order", al.
ival(
"-lx_lo", 0));
379 op.
set(
"lx_high_frequency", al.
ival(
"-lx_hf", 0));
381 op.
set(
"lx_high_order", al.
ival(
"-lx_ho", 0));
383 op.
set(
"median_order", al.
ival(
"-med_o", 0));
385 op.
set(
"mean_order", al.
ival(
"-mean_o", 0));
387 op.
set(
"df_low_frequency", al.
ival(
"-df_lf", 0));
389 op.
set(
"df_low_order", al.
ival(
"-df_lo", 0));
391 op.
set(
"min_period", al.
fval(
"-min", 0));
393 op.
set(
"max_period", al.
fval(
"-max", 0));
395 op.
set(
"def_period", al.
fval(
"-def", 0));
397 op.
set(
"pm_end", al.
fval(
"-end", 0));
399 op.
set(
"pm_debug", 1);
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 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 T & first() const
return const reference to first item in list
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