43 #include "EST_cmd_line.h"
44 #include "EST_cmd_line_options.h"
45 #include "EST_sigpr.h"
46 #include "EST_wave_aux.h"
101 int main (
int argc,
char *argv[])
104 EST_String in_file(
"-"), out_file(
"-"), op_file(
""), test;
112 EST_String(
"[input file0] [input file1] ... -o [output file]\n")+
113 "Summary: change/copy/combine waveform files\n"+
114 "use \"-\" to make input and output files stdin/out\n"+
115 "-h Options help\n\n"+
116 options_wave_input()+
117 options_wave_output()+
118 "-scale <float> Scaling factor. Increase or descrease the amplitude\n"
119 " of the whole waveform by the factor given\n\n"
121 "-scaleN <float> Scaling factor with normalization. \n"
122 " The waveform is scaled to its maximum level, after which \n"
123 " it is scaled by the factor given\n\n"
125 "-lpfilter <int> Low pass filter, with cutoff frequency in Hz \n"
126 " Filtering is performed by a FIR filter which is built at run \n"
127 " time. The order of the filter can be given by -forder. The \n"
128 " default value is 199\n\n"
130 "-hpfilter <int> High pass filter, with cutoff frequency in Hz \n"
131 " Filtering is performed by a FIR filter which is \n"
132 " built at run time. The order of the filter can \n"
133 " be given by -forder. The default value is 199.\n\n"
135 "-forder <int> Order of FIR filter used for lpfilter and \n"
136 " hpfilter. This must be ODD. Sensible values range \n"+
137 " from 19 (quick but with a shallow rolloff) to 199 \n"
138 " (slow but with a steep rolloff). The default is 199.\n\n"
140 "-fafter Do filtering after other operations such as \n"
141 " resampling (default : filter before other operations)\n\n"
143 "-info Print information about file and header. \n"
144 " This option gives useful information such as file \n"
145 " length, sampling rate, number of channels etc\n"
146 " No output is produced\n\n"
148 "-add A new single channel waveform is created by adding \n"
149 " the corresponding sample points of each input waveform\n\n"
151 "-pc <string> Combine input waveforms to form a single \n"
152 " multichannel waveform. The argument to this option controls \n"
153 " how long the new waveform should be. If the option \n"
154 " is LONGEST, the output wave if the length of the \n"
155 " longest input wave and shorter waves are padded with \n"
156 " zeros at the end. If the option is FIRST, the length \n"
157 " of the new waveform is the length of the first file \n"
158 " on the command line, and subsequent waves are padded \n"
159 " or cut to this length\n\n"
161 "-key <ifile> Label file designating subsections, for use with \n"
162 " -divide. The KEYLAB file is a label file which specifies \n"
163 " where chunks (such as individual sentences) in \n"
164 " a waveform begin and end. See section of wave extraction.\n\n"
166 "-divide Divide a single input waveform into multiple output \n"
167 " waveforms. Each output waveform is extracted from the \n"
168 " input waveform by using the KEYLAB file, which \n"
169 " specifies the start and stop times for each chunk. \n"
170 " The output files are named according to the filename \n"
171 " in the KEYLAB file, with extension given by -ext. See \n"
172 " section on wave extraction\n\n"
174 "-ext <string> File extension for divided waveforms\n\n"
176 "-extract <string> Used in conjunction with -key to extract a \n"
177 " single section of waveform from the input \n"
178 " waveform. The argument is the name of a file given \n"
179 " in the file column of the KEYLAB file.\n",
186 if (read_wave(sig, files.
first(), al) != format_ok)
192 if (files.length() > 1)
194 for (p= files.head()->next(); p != 0; p=p->next())
196 if (read_wave(sigload, files(p), al) != format_ok)
202 if ((al.
val(
"-pc") ==
"longest") &&
210 add_waves(sig, sigload);
225 FIRlowpass_filter(sig,al.
ival(
"-lpfilter"),al.
ival(
"-forder"));
227 FIRhighpass_filter(sig,al.
ival(
"-hpfilter"),al.
ival(
"-forder"));
235 StringtoStrList(al.
val(
"-c"), s,
" ,");
236 StrListtoIList(s, il);
237 extract_channels(nsig, sig, il);
246 float scale = al.
fval(
"-scale", 0);
249 else if (al.
present(
"-scaleN"))
251 float scale = al.
fval(
"-scaleN", 0);
252 if ((scale < 0) || (scale > 1.0))
254 cerr <<
"ch_wave: -scaleN must be in range 0 to 1" << endl;
267 cerr <<
"Must have key file specified when dividing waveform\n";
270 if (key.
load(al.
val(
"-key")) != format_ok)
273 if (wave_divide(wl, sig, key, al.
val(
"-ext", 0)) == -1)
275 for (p = wl.head(); p; p = p->next())
276 wl(p).save(wl(p).name(), al.
val(
"-otype", 0));
279 else if (al.
present(
"-extract"))
284 cerr <<
"Must have key file specified when dividing waveform\n";
287 if (key.
load(al.
val(
"-key")) != format_ok)
290 if (wave_extract(e, sig, key, al.
val(
"-extract")) == -1)
298 FIRlowpass_filter(sig,al.
ival(
"-lpfilter"),al.
ival(
"-forder"));
300 FIRhighpass_filter(sig,al.
ival(
"-hpfilter"),al.
ival(
"-forder"));
303 write_wave(sig, out_file, al);