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"
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);
211 if (!
al.present(
"-pm") || (
al.present(
"-pm") &&
al.present(
"-wave_end")))
212 if (read_wave(
lx,
files.first(),
al) != read_ok)
215 if (
al.present(
"-pm"))
216 pm.load(
al.val(
"-pm"));
219 if (
al.present(
"-inv"))
221 pm = pitchmark(
lx, op);
225 op.
set(
"pm_end",
lx.end());
227 if (
al.present(
"-f0"))
231 f0.save(
al.val(
"-f0"));
237 if (
al.present(
"-fill"))
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"));
244 else if (
al.present(
"-min"))
245 pm_min_check(
pm,
al.fval(
"-min"));
247 if (
al.present(
"-style"))
250 if (
al.val(
"-style").contains(
"lab"))
253 pm_to_label(
pm,
lab);
254 if (
lab.save(out_file +
".pm_lab") != write_ok)
258 if (
al.val(
"-style").contains(
"msec"))
259 save_msec(
pm, out_file +
".pm");
262 if (
al.val(
"-style").contains(
"ogi_bin"))
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;
287 outf->setf(ios::fixed, ios::floatfield);
290 for (
int i = 0; i <
pm.num_frames(); ++i)
302 d =
new int[
pm.num_frames()];
304 for (i = 0; i <
pm.num_frames(); ++i)
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;
333 if (
al.present(
"-lx_lf"))
335 if (
al.present(
"-lx_lo"))
337 if (
al.present(
"-lx_hf"))
339 if (
al.present(
"-lx_ho"))
341 if (
al.present(
"-med_o"))
343 if (
al.present(
"-mean_o"))
345 if (
al.present(
"-df_lf"))
347 if (
al.present(
"-df_lo"))
349 if (
al.present(
"-min"))
351 if (
al.present(
"-max"))
353 if (
al.present(
"-def"))
355 if (
al.present(
"-end"))
357 if (
al.present(
"-inter"))
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);
374 if (
al.present(
"-lx_lf"))
375 op.
set(
"lx_low_frequency",
al.ival(
"-lx_lf", 0));
376 if (
al.present(
"-lx_lo"))
377 op.
set(
"lx_low_order",
al.ival(
"-lx_lo", 0));
378 if (
al.present(
"-lx_hf"))
379 op.
set(
"lx_high_frequency",
al.ival(
"-lx_hf", 0));
380 if (
al.present(
"-lx_ho"))
381 op.
set(
"lx_high_order",
al.ival(
"-lx_ho", 0));
382 if (
al.present(
"-med_o"))
383 op.
set(
"median_order",
al.ival(
"-med_o", 0));
384 if (
al.present(
"-mean_o"))
385 op.
set(
"mean_order",
al.ival(
"-mean_o", 0));
386 if (
al.present(
"-df_lf"))
387 op.
set(
"df_low_frequency",
al.ival(
"-df_lf", 0));
388 if (
al.present(
"-df_lo"))
389 op.
set(
"df_low_order",
al.ival(
"-df_lo", 0));
390 if (
al.present(
"-min"))
391 op.
set(
"min_period",
al.fval(
"-min", 0));
392 if (
al.present(
"-max"))
393 op.
set(
"max_period",
al.fval(
"-max", 0));
394 if (
al.present(
"-def"))
395 op.
set(
"def_period",
al.fval(
"-def", 0));
396 if (
al.present(
"-end"))
397 op.
set(
"pm_end",
al.fval(
"-end", 0));
398 if (
al.present(
"-inter"))
399 op.
set(
"pm_debug", 1);
void set(const EST_String &name, int ival)
const float F(const EST_String &path) const
int override_ival(const EST_String rkey, const int rval)
add to end of list or overwrite. If rval is empty, do nothing
int override_fval(const EST_String rkey, const float rval)
add to end of list or overwrite. If rval is empty, do nothing