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"
57{st_unknown, {
"undef"}},
58{st_schar, {
"schar",
"byte"}},
61{st_shorten, {
"shorten"}},
64{st_double, {
"double"}},
76 for (
int i = 0; i <
sig.num_samples() -1; ++i)
78 sig.resize(
sig.num_samples()-1);
96 int c =
multi.num_channels();
97 int num_samples =
multi.num_samples();
99 short *
buf =
new short [num_samples];
106 for (i = 0, p =
ch_list.head(); p; p = p->next(), ++i)
111 EST_error(
"Can't extract channel %d from %d channel waveform\n",
125 int v = wave_extract_channel(
tmp,
multi, channel);
131 int c =
multi.num_channels();
135 cerr <<
"Can't extract channel " << channel <<
" from " <<
136 c <<
" channel waveform\n";
162 wave_combine_channels(
tmp,
m);
166 s.
resize(
m.num_samples(), 1, FALSE);
169 for(
int i=0; i<
m.num_samples(); i++)
172 for(
int j=0;
j<
m.num_channels();
j++)
174 s.
a(i,0) = (int)(sum/
m.num_channels() + 0.5);
185 for (
int i = 0; i <
m.num_samples(); i++)
186 for (
int j = 0;
j <
m.num_channels();
j++)
187 s.
a(i,
j) +=
m.a(i,
j);
199 n = (int)
floor((
float)(
sig.num_samples())/2.0);
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);
205 sig.a_no_check(
sig.num_samples() - 1 -i) = t;
214 if (
al.present(
"-start"))
215 from = (int)(
sig.sample_rate() *
al.fval(
"-start"));
216 else if (
al.present(
"-from"))
217 from =
al.ival(
"-from");
221 if (
al.present(
"-end"))
222 to = (
int)(
sig.sample_rate() *
al.fval(
"-end"));
223 else if (
al.present(
"-to"))
226 to =
sig.num_samples();
228 sig.sub_wave(sub_wave, from, to - from);
236 cout <<
"Duration: " <<
242 cout <<
"Header type: " << w.file_type() <<
endl;
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, alaw, 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, alaw, mulaw, byte or ascii\n\n";
324Declare_TNamedEnum(EST_sample_type_t)
325#if defined(INSTANTIATE_TEMPLATES)
326#include "../base_class/EST_TNamedEnum.cc"
327Instantiate_TNamedEnum(EST_sample_type_t)
void append(const T &item)
add item onto end of list
short & a(int i, int channel=0)
int num_channels() const
return the number of channels in the waveform
int sample_rate() const
return the sampling rate (frequency)
void resize(int num_samples, int num_channels=EST_ALL, int set=1)
resize the waveform
EST_String sample_type() const
int num_samples() const
return the number of samples in the waveform
void set_sample_rate(const int n)
Set sampling rate to n