57 int main (
int argc,
char *argv[])
60 EST_String in_file(
"-"), out_file(
"-"), op_file(
""), test;
68 EST_String(
"[input file0] [input file1] ... -o [output file]\n")+
69 "Summary: change/copy/combine waveform files\n"+
70 "use \"-\" to make input and output files stdin/out\n"+
71 "-h Options help\n\n"+
74 "-scale <float> Scaling factor. Increase or descrease the amplitude\n" 75 " of the whole waveform by the factor given\n\n" 77 "-scaleN <float> Scaling factor with normalization. \n" 78 " The waveform is scaled to its maximum level, after which \n" 79 " it is scaled by the factor given\n\n" 81 "-lpfilter <int> Low pass filter, with cutoff frequency in Hz \n" 82 " Filtering is performed by a FIR filter which is built at run \n" 83 " time. The order of the filter can be given by -forder. The \n" 84 " default value is 199\n\n" 86 "-hpfilter <int> High pass filter, with cutoff frequency in Hz \n" 87 " Filtering is performed by a FIR filter which is \n" 88 " built at run time. The order of the filter can \n" 89 " be given by -forder. The default value is 199.\n\n" 91 "-forder <int> Order of FIR filter used for lpfilter and \n" 92 " hpfilter. This must be ODD. Sensible values range \n"+
93 " from 19 (quick but with a shallow rolloff) to 199 \n" 94 " (slow but with a steep rolloff). The default is 199.\n\n" 96 "-fafter Do filtering after other operations such as \n" 97 " resampling (default : filter before other operations)\n\n" 99 "-info Print information about file and header. \n" 100 " This option gives useful information such as file \n" 101 " length, sampling rate, number of channels etc\n" 102 " No output is produced\n\n" 104 "-add A new single channel waveform is created by adding \n" 105 " the corresponding sample points of each input waveform\n\n" 107 "-pc <string> Combine input waveforms to form a single \n" 108 " multichannel waveform. The argument to this option controls \n" 109 " how long the new waveform should be. If the option \n" 110 " is LONGEST, the output wave if the length of the \n" 111 " longest input wave and shorter waves are padded with \n" 112 " zeros at the end. If the option is FIRST, the length \n" 113 " of the new waveform is the length of the first file \n" 114 " on the command line, and subsequent waves are padded \n" 115 " or cut to this length\n\n" 117 "-key <ifile> Label file designating subsections, for use with \n" 118 " -divide. The KEYLAB file is a label file which specifies \n" 119 " where chunks (such as individual sentences) in \n" 120 " a waveform begin and end. See section of wave extraction.\n\n" 122 "-divide Divide a single input waveform into multiple output \n" 123 " waveforms. Each output waveform is extracted from the \n" 124 " input waveform by using the KEYLAB file, which \n" 125 " specifies the start and stop times for each chunk. \n" 126 " The output files are named according to the filename \n" 127 " in the KEYLAB file, with extension given by -ext. See \n" 128 " section on wave extraction\n\n" 130 "-ext <string> File extension for divided waveforms\n\n" 132 "-extract <string> Used in conjunction with -key to extract a \n" 133 " single section of waveform from the input \n" 134 " waveform. The argument is the name of a file given \n" 135 " in the file column of the KEYLAB file.\n",
202 float scale = al.
fval(
"-scale", 0);
205 else if (al.
present(
"-scaleN"))
207 float scale = al.
fval(
"-scaleN", 0);
208 if ((scale < 0) || (scale > 1.0))
210 cerr <<
"ch_wave: -scaleN must be in range 0 to 1" << endl;
223 cerr <<
"Must have key file specified when dividing waveform\n";
231 for (p = wl.
head(); p; p = p->
next())
232 wl(p).save(wl(p).name(), al.
val(
"-otype", 0));
235 else if (al.
present(
"-extract"))
240 cerr <<
"Must have key file specified when dividing waveform\n";
A class for storing digital waveforms. The waveform is stored as an array of 16 bit shorts...
int main(int argc, char *argv[])
int ival(const EST_String &rkey, int m=1) const
int StrListtoIList(EST_StrList &s, EST_IList &il)
Convert a list of strings to a list of integers.
void FIRlowpass_filter(EST_Wave &sigin, int freq, int order=DEFAULT_FILTER_ORDER)
float fval(const EST_String &rkey, int m=1) const
ssize_t num_samples() const
return the number of samples in the waveform
void rescale(float gain, int normalize=0)
int wave_extract(EST_Wave &part, EST_Wave &sig, EST_Relation &keylab, const EST_String &file)
EST_String downcase(const EST_String &s)
void wave_info(EST_Wave &w)
void StringtoStrList(EST_String s, EST_StrList &l, EST_String sep)
Convert a EST_String to a EST_StrList by separating tokens in s delimited by the separator sep...
const T & first() const
return const reference to first item in list
EST_String options_wave_input(void)
void FIRhighpass_filter(EST_Wave &in_sig, int freq, int order)
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
int wave_divide(EST_WaveList &wl, EST_Wave &sig, EST_Relation &keylab, const EST_String &ext)
EST_write_status write_wave(EST_Wave &sig, const EST_String &in_file, EST_Option &al)
void resize(int num_samples, int num_channels=EST_ALL, int set=1)
resize the waveform
void add_waves(EST_Wave &s, const EST_Wave &m)
EST_read_status read_wave(EST_Wave &sig, const EST_String &in_file, EST_Option &al)
EST_String options_wave_output(void)
int present(const K &rkey) const
Returns true if key is present.
EST_read_status load(const EST_String &filename, const EST_String &type="esps")
void resample(int rate)
Resample waveform to rate
int parse_command_line(int argc, char *argv[], const EST_String &usage, EST_StrList &files, EST_Option &al, int make_stdio=1)
void extract_channels(EST_Wave &single, const EST_Wave &multi, EST_IList &ch_list)
void wave_extract_channel(EST_Wave &single, const EST_Wave &multi, EST_IList &ch_list)