44 #include "EST_cmd_line.h"
45 #include "EST_cmd_line_options.h"
46 #include "EST_sigpr.h"
47 #include "EST_wave_aux.h"
85 int main (
int argc,
char *argv[])
88 EST_String in_file(
"-"), out_file(
"-"), op_file(
""), test;
95 EST_String(
"[input file0] -o [output file]\n") +
96 "Summary: filter waveform files\n"
97 "use \"-\" to make input and output files stdin/out\n"
99 options_wave_input()+
"\n"+
100 options_wave_output()+
"\n"
101 "-scale <float> Scaling factor. Increase or descrease the amplitude\n"
102 " of the whole waveform by the factor given\n\n"
104 "-scaleN <float> Scaling factor with normalization. \n"
105 " The waveform is scaled to its maximum level, after which \n"
106 " it is scaled by the factor given\n\n"
107 "-double Perform double filtering by applying a forward filter,\n"
108 " then a backward filter, leaving the filtered signla in phase\n"
109 " with the original\n\n"
110 "-lpfilter <int> Low pass filter, with cutoff frequency in Hz \n"
111 " Filtering is performed by a FIR filter which is built at run \n"
112 " time. The order of the filter can be given by -forder. The \n"
113 " default value is 199\n\n"
115 "-hpfilter <int> High pass filter, with cutoff frequency in Hz \n"
116 " Filtering is performed by a FIR filter which is \n"
117 " built at run time. The order of the filter can \n"
118 " be given by -forder. The default value is 199.\n\n"
120 "-forder <int> Order of FIR filter used for lpfilter and \n"
121 " hpfilter. This must be ODD. Sensible values range \n"
122 " from 19 (quick but with a shallow rolloff) to 199 \n"
123 " (slow but with a steep rolloff). The default is 199.\n\n"
124 "-lpcfilter <ifile> Track file containing lpc filter coefficients\n\n"
125 "-firfilter <ifile> File containing a single set of FIR filter\n"
127 "-inv_filter use filter coefficients for inverse filtering\n\n",
132 if (read_wave(sig, files.
first(), al) != format_ok)
137 float scale = al.
fval(
"-s", 0);
140 else if (al.
present(
"-scaleN"))
142 float scale = al.
fval(
"-scaleN", 0);
143 if ((scale < 0) || (scale > 1.0))
145 cerr <<
"ch_wave: -scaleN must be in range 0 to 1" << endl;
156 FIRlowpass_filter(sig, al.
ival(
"-lpfilter"),al.
ival(
"-forder"));
161 FIRhighpass_filter(sig,al.
ival(
"-hpfilter"),al.
ival(
"-forder"));
167 filter.
load(al.
val(
"-lpcfilter"));
169 inv_lpc_filter_ola(sig, filter, fsig);
172 cout <<
"not done yet\n";
177 firfilter.
load(al.
val(
"-firfilter"));
179 FIR_double_filter(sig, fsig, firfilter);
181 FIRfilter(sig, fsig, firfilter);
184 if (write_wave(fsig, out_file, al) != write_ok)
186 cerr <<
"sigfilter: failed to write output to \"" << out_file