43 #include "EST_cutils.h"
44 #include "EST_string_aux.h"
46 #include "EST_wave_utils.h"
47 #include "EST_wave_aux.h"
48 #include "EST_io_aux.h"
49 #include "EST_error.h"
57 {st_unknown, {
"undef"}},
58 {st_schar, {
"schar",
"byte"}},
59 {st_uchar, {
"uchar"}},
60 {st_short, {
"short"}},
61 {st_shorten, {
"shorten"}},
63 {st_float, {
"float"}},
64 {st_double, {
"double"}},
65 {st_mulaw, {
"mulaw"}},
66 {st_adpcm, {
"adpcm"}},
68 {st_ascii, {
"ascii"}},
77 sig.
a(i) = sig.
a(i + 1) - sig.
a(i);
86 if (&single == &multi)
90 extract_channels(tmp, multi, ch_list);
99 short *buf =
new short [num_samples];
102 single.
resize(num_samples, ch_list.length());
104 single.set_file_type(multi.file_type());
106 for (i = 0, p = ch_list.head(); p; p = p->next(), ++i)
108 channel = ch_list(p);
110 if (channel < 0 || channel >= c)
111 EST_error(
"Can't extract channel %d from %d channel waveform\n",
114 multi.copy_channel(channel, buf);
115 single.set_channel(i, buf);
119 int wave_extract_channel(
EST_Wave &single,
const EST_Wave &multi,
int channel)
121 if (&single == &multi)
125 int v = wave_extract_channel(tmp, multi, channel);
133 if (channel < 0 || channel >= c)
135 cerr <<
"Can't extract channel " << channel <<
" from " <<
136 c <<
" channel waveform\n";
142 multi.sub_wave(subwave, 0, EST_ALL, channel, 1);
144 single.copy(subwave);
153 extract_channels(single, multi, a);
162 wave_combine_channels(tmp,m);
183 s.
resize(new_samples, new_channels, 1);
187 s.
a(i, j) += m.
a(i, j);
201 for (i = 0; i < n; ++i)
203 t = sig.a_no_check(i);
204 sig.a_no_check(i) = sig.a_no_check(sig.
num_samples() - 1 -i);
217 from = al.
ival(
"-from");
228 sig.sub_wave(sub_wave, from, to - from);
236 cout <<
"Duration: " <<
239 cout <<
"Sample rate: " << w.
sample_rate() << endl;
240 cout <<
"Number of samples: " << w.
num_samples() << endl;
241 cout <<
"Number of channels: " << w.
num_channels() << endl;
242 cout <<
"Header type: " << w.file_type() << endl;
246 static EST_String options_wave_filetypes(
void)
252 return "nist, est, esps, snd, riff, aiff, audlab, raw, ascii";
259 "-start <float> Extract sub-wave starting at this time, specified in \n"
261 "-end <float> Extract sub-wave ending at this time, specified in \n"
263 "-from <int> Extract sub-wave starting at this sample point\n\n"
264 "-to <int> Extract sub-wave ending at this sample point\n\n";
271 "-itype <string> Input file type (optional). If set to raw, this \n"
272 " indicates that the input file does not have a header. While \n"
273 " this can be used to specify file types other than raw, this is \n"
274 " rarely used for other purposes\n"
275 " as the file type of all the existing supported \n"
276 " types can be determined automatically from the \n"
277 " file's header. If the input file is unheadered, \n"
278 " files are assumed to be shorts (16bit). \n"
279 " Supported types are \n"
280 " "+options_wave_filetypes()+
"\n\n"
281 "-n <int> Number of channels in an unheadered input file \n\n"
282 "-f <int> Sample rate in Hertz for an unheadered input file \n\n"
283 "-ibo <string> Input byte order in an unheadered input file: \n"
284 " possibliities are: MSB , LSB, native or nonnative. \n"
285 " Suns, HP, SGI Mips, M68000 are MSB (big endian) \n"
286 " Intel, Alpha, DEC Mips, Vax are LSB (little \n"
288 "-iswap Swap bytes. (For use on an unheadered input file)\n\n"
289 "-istype <string> Sample type in an unheadered input file:\n"
290 " short, mulaw, byte, ascii\n\n"
291 "-c <string> Select a single channel (starts from 0). \n"
292 " Waveforms can have multiple channels. This option \n"
293 " extracts a single channel for progcessing and \n"
294 " discards the rest. \n\n"+
308 "-o <ofile> Output filename. If not specified output is\n"
310 "-otype <string> Output file type, (optional). If no type is\n"
311 " Specified the type of the input file is assumed.\n"
312 " Supported types are: \n"
313 " "+options_wave_filetypes()+
"\n\n"
314 "-F <int> Output sample rate in Hz. If this is different \n"
315 " from the input sample rate, resampling will occur \n\n"
316 "-obo <string> Output byte order: MSB, LSB, native, or nonnative. \n"
317 " Suns, HP, SGI Mips, M68000 are MSB (big endian) \n"
318 " Intel, Alpha, DEC Mips, Vax are LSB \n"
319 " (little endian)\n\n"
320 "-oswap Swap bytes when saving to output\n\n"+
321 "-ostype <string> Output sample type: short, mulaw, byte or ascii\n\n";
324 Declare_TNamedEnum(EST_sample_type_t)
325 #if defined(INSTANTIATE_TEMPLATES)
326 #include "../base_class/EST_TNamedEnum.cc"
327 Instantiate_TNamedEnum(EST_sample_type_t)