41#include "EST_cmd_line_options.h"
43#define DEFAULT_TIME_SCALE 0.001
48EST_write_status save_snns_pat(
const EST_String filename,
110 EST_String(
"[input file] -o [output file] [options]\n")+
111 "Summary: change/copy track files\n"
112 "use \"-\" to make input and output files stdin/out\n"
114 options_track_input()+
"\n"+
115 options_track_output()+
"\n"
116 "-info Print information about file and header. \n"
117 " This option gives useful information such as file \n"
118 " length, file type, channel names. No output is produced\n\n"
119 "-track_names <string> \n"
120 " File containing new names for output channels\n\n"
121 "-diff Differentiate contour. This performs simple \n"
122 " numerical differentiation on the contour by \n"
123 " subtracting the amplitude of the current frame \n"
124 " from the amplitude of the next. Although quick, \n"
125 " this technique is crude and not recommende as the \n"
126 " estimation of the derivate is done on only one point\n\n"
127 "-delta <int> Make delta coefficients (better form of differentiate).\n"
128 " The argument to this option is the regression length of \n"
129 " of the delta calculation and can be between 2 and 4 \n\n"
130 "-sm <float> Length of smoothing window in seconds. Various types of \n"
131 " smoothing are available for tracks. This options specifies \n"
132 " length of the smooting window which effects the degree of \n"
133 " smoothing, i.e. a longer value means more smoothing \n\n"
134 "-smtype <string> Smooth type, median or mean\n"
135 "-style <string> Convert track to other form. Currently only one form \n"
136 " \"label\" is supported. This uses a specified cut off to \n"
137 " make a label file, with two labels, one for above the \n"
138 " cut off (-pos) and one for below (-neg)\n\n"
139 "-t <float> threshold for track to label conversion \n"
140 "-neg <string> Name of negative label in track to label conversion \n"
141 "-pos <string> Name of positive label in track to label conversion \n"
142 "-pc <string> Combine given tracks in parallel. If option \n"
143 " is longest, pad shorter tracks to longest, else if \n"
144 " first pad/cut to match first input track \n" +
145 options_track_filetypes_long(),
168 if (
files.length() == 0)
170 cerr <<
argv[0] <<
": no input files specified\n";
174 if (
al.present(
"-info"))
176 for (p =
trlist.head(); p; p = p->next())
181 if (
al.present(
"-pc"))
184 else if (
al.val(
"-otype", 0) ==
"snns")
194 tr.resize(0,
tr.num_channels());
196 for (p =
trlist.head(); p; p = p->next())
200 if (
al.present(
"-S"))
201 tr.sample(
al.fval(
"-S"));
202 if (
al.present(
"-sm"))
204 track_smooth(
tr,
al.fval(
"-sm"),
al.val(
"-smtype"));
207 if (
al.present(
"-diff") &&
al.present(
"-delta"))
209 cerr <<
"Using -diff and -delta together makes no sense !\n";
212 if (
al.present(
"-diff"))
214 tr = differentiate(
tr);
216 if (
al.present(
"-delta"))
219 delta(
tr,
ntr,
al.ival(
"-delta"));
223 if (
al.present(
"-c"))
228 StringtoStrList(
al.val(
"-c"), s,
" ,");
229 StrListtoIList(s,
il);
234 if (
al.present(
"-start") ||
al.present(
"-end")
235 ||
al.present(
"-to") ||
al.present(
"-from"))
244 if (
al.present(
"-track_names"))
247 if(load_StrList(
al.val(
"-track_names"),
new_names) != format_ok)
249 cerr <<
"Failed to load new track names file." <<
endl;
291 if (
al.val(
"-style",0) ==
"label")
294 if (
al.present(
"-t"))
295 track_to_label(
tr,
lab,
al.fval(
"-t"));
297 track_to_label(
tr,
lab);
298 if (
al.present(
"-pos"))
299 change_label(
lab,
"pos",
al.val(
"-pos"));
300 if (
al.present(
"-neg"))
301 change_label(
lab,
"neg",
al.val(
"-neg"));
302 if (
lab.save(out_file) != write_ok)
324 if (
tr.save(out_file,
al.val(
"-otype")) != write_ok)
333 a_list.override_val(
"ishift",
al.val(
"-s", 0));
334 a_list.override_val(
"color",
al.val(
"-color", 0));
335 a_list.override_val(
"in_track_file_type",
al.val(
"-itype", 0));
336 a_list.override_val(
"out_track_file_type",
al.val(
"-otype", 0));
337 a_list.override_val(
"tr_to_label_thresh",
al.val(
"-t", 0));
338 a_list.override_fval(
"time_scale", DEFAULT_TIME_SCALE);
340 if (
al.val(
"-style", 0) ==
"label")
341 a_list.override_val(
"lab_file_type",
al.val(
"-otype", 0));
342 if (
al.present(
"-time_scale"))
343 a_list.override_fval(
"time_scale",
al.fval(
"-time_scale", 1));
344 if (
al.present(
"-time_channel"))
345 a_list.override_val(
"time_channel",
al.sval(
"-time_channel", 1));