55 short **data,
int *nsamp,
int *nchan,
59 int offset,
int length);
64 int offset,
int nsamp,
80 int offset,
int length)
88 &data, &nsamp, &nchan,
95 short *data2 =
new short[nsamp*nchan];
96 memcpy(data2, data, nsamp*nchan*
sizeof(
short));
136 int offset,
int length)
169 int offset,
int length)
210 int offset,
int length)
243 int offset,
int length)
276 int offset,
int length)
315 int offset,
int length)
348 int offset,
int length)
383 int offset,
int length)
391 &data, &nsamp, &nchan,
395 rate, stype, bo, nchan);
422 return save_raw(fp, wv, stype, bo);
437 int offset,
int length)
477 int offset,
int length)
512 static int parse_esps_r_option(
EST_String arg,
int &offset,
int &length)
528 cerr <<
"Argument to -r is illformed " << arg << endl;
534 cerr <<
"First argument to -r must be an integer " << arg << endl;
545 length = atoi(e) - offset;
549 cerr <<
"length is negative or zero " << arg << endl;
564 int offset=0, length=0;
573 num_channels = al.
ival(
"-n", 0);
591 sample_type = al.
val(
"-istype");
596 file_type = al.
val(
"-itype");
602 sample_rate = al.
ival(
"-f", 0);
603 else if ((sr =
getenv(
"NA_PLAY_SAMPLE_RATE")) !=
NULL)
605 sample_rate = atoi(sr);
606 cerr <<
"Warning: no sample rate specified, " <<
607 " using NA_PLAY_SAMPLE_RATE environment variable\n";
612 if (file_type ==
"raw")
613 cerr <<
"Warning: no sample rate specified - using default " <<
617 if (file_type ==
"ulaw")
620 sample_type =
"mulaw";
625 if (parse_esps_r_option(al.
val(
"-r"), offset, length) != 0)
638 if (file_type ==
"" ||file_type ==
"undef")
639 rval = sig.
load(fname, offset, length, sample_rate);
641 rval = sig.
load_file(fname,file_type, sample_rate,
642 sample_type, bo, num_channels, offset, length);
649 "mulaw", bo, 1, offset, length);
653 if (in_file ==
"-") unlink(fname);
654 cerr <<
"Cannot recognize file format or cannot access file: \"" << in_file <<
"\"\n";
657 if (file_type ==
"alaw")
660 sample_type =
"alaw";
667 if (in_file ==
"-") unlink(fname);
678 file_type = al.
val(
"-otype");
683 sample_type = al.
val(
"-ostype");
685 sample_type =
"undef";
695 if (sample_type ==
"undef" || sample_type ==
"")
696 sample_type =
"short";
701 cerr <<
"Cannot write file: \"" << out_file <<
"\"\n";
727 EST_String s(
"Available wave file formats:\n");
739 typedef struct TInfo {
741 const char *description;
763 "esps SD waveform" } },
767 "audlab waveform" } },
775 "Apple aiff file" } },
779 "Microsoft wav/riff file" } },
783 "Headerless File" } },
787 "Headerless 8K ulaw File" } },
791 "Headerless 8K alaw File" } },
798 #if defined(INSTANTIATE_TEMPLATES) 800 #include "../base_class/EST_TNamedEnum.cc" A class for storing digital waveforms. The waveform is stored as an array of 16 bit shorts...
enum EST_write_status save_wave_aiff_data(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
enum EST_read_status load_wave_audlab(EST_TokenStream &ts, short **data, int *num_samples, int *num_channels, int *word_size, int *sample_rate, enum EST_sample_type_t *sample_type, int *bo, int offset, int length)
static EST_write_status save_raw_header(SaveWave_TokenStreamArgs)
static EST_write_status save_nist_data(SaveWave_TokenStreamArgs)
enum EST_read_status load_wave_nist(EST_TokenStream &ts, short **data, int *num_samples, int *num_channels, int *word_size, int *sample_rate, enum EST_sample_type_t *sample_type, int *bo, int offset, int length)
enum EST_write_status save_wave_sd_header(FILE *fp, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
void set_sample_rate(const int n)
Set sampling rate to n
static EST_write_status save_snd(SaveWave_TokenStreamArgs)
EST_read_status read_wave(EST_Wave &sig, const EST_String &in_file, EST_Option &al)
static EST_read_status load_riff(LoadWave_TokenStreamArgs)
int contains(const char *s, ssize_t pos=-1) const
Does it contain this substring?
enum EST_write_status save_wave_alaw_data(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
static EST_write_status save_raw_data(SaveWave_TokenStreamArgs)
static EST_write_status save_alaw_data(SaveWave_TokenStreamArgs)
Utility IO Function header file.
enum EST_write_status save_wave_alaw(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
static EST_read_status load_ulaw(LoadWave_TokenStreamArgs)
enum EST_write_status save_wave_riff_data(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
void extract(EST_Wave &sig, EST_Option &al)
enum EST_write_status save_wave_aiff(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
enum EST_bo_t str_to_bo(const char *boname)
The file was read in successfully.
enum EST_write_status save_wave_snd(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
static EST_write_status save_alaw(SaveWave_TokenStreamArgs)
static EST_String options_supported(void)
static EST_write_status save_ulaw_data(SaveWave_TokenStreamArgs)
enum EST_read_status load_wave_riff(EST_TokenStream &ts, short **data, int *num_samples, int *num_channels, int *word_size, int *sample_rate, enum EST_sample_type_t *sample_type, int *bo, int offset, int length)
static EST_write_status save_esps(SaveWave_TokenStreamArgs)
int ival(const EST_String &rkey, int m=1) const
enum EST_write_status save_wave_sd_data(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
EST_write_status(* standard_save_fn_fp)(FILE *fp, const short *data, int offset, int nsamp, int nchan, int srate, EST_sample_type_t stype, int bo)
static EST_write_status save_snd_header(SaveWave_TokenStreamArgs)
static EST_write_status save_audlab_header(SaveWave_TokenStreamArgs)
static EST_write_status save_riff_header(SaveWave_TokenStreamArgs)
static EST_write_status save_aiff(SaveWave_TokenStreamArgs)
enum EST_read_status load_wave_est(EST_TokenStream &ts, short **data, int *num_samples, int *num_channels, int *word_size, int *sample_rate, enum EST_sample_type_t *sample_type, int *bo, int offset, int length)
static EST_write_status save_riff(SaveWave_TokenStreamArgs)
enum EST_write_status save_wave_ulaw_header(FILE *fp, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
ssize_t num_samples() const
return the number of samples in the waveform
static EST_read_status load_audlab(LoadWave_TokenStreamArgs)
enum EST_write_status save_wave_nist_header(FILE *fp, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
enum EST_read_status load_wave_aiff(EST_TokenStream &ts, short **data, int *num_samples, int *num_channels, int *word_size, int *sample_rate, enum EST_sample_type_t *sample_type, int *bo, int offset, int length)
EST_read_status(* standard_load_fn_fp)(EST_TokenStream &ts, short **data, int *nsamp, int *nchan, int *wsize, int *srate, EST_sample_type_t *stype, int *bo, int offset, int length)
static EST_read_status load_esps(LoadWave_TokenStreamArgs)
static EST_write_status save_audlab(SaveWave_TokenStreamArgs)
static EST_write_status save_nist(SaveWave_TokenStreamArgs)
EST_String file_type() const
enum EST_write_status save_wave_raw_header(FILE *fp, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
static EST_write_status save_est_data(SaveWave_TokenStreamArgs)
static const int default_sample_rate
static EST_write_status save_est_header(SaveWave_TokenStreamArgs)
static EST_String cat(const EST_String s1, const EST_String s2=Empty, const EST_String s3=Empty, const EST_String s4=Empty, const EST_String s5=Empty, const EST_String s6=Empty, const EST_String s7=Empty, const EST_String s8=Empty, const EST_String s9=Empty)
static EST_write_status save_aiff_header(SaveWave_TokenStreamArgs)
EST_Regex RXint("-?[0-9]+")
Integer.
An error occurred while reading.
EST_write_status save_file(const EST_String filename, EST_String filetype, EST_String sample_type, int bo, const char *mode="wb")
static EST_write_status save_esps_data(SaveWave_TokenStreamArgs)
static EST_read_status load_raw(LoadWave_TokenStreamArgs)
enum EST_read_status load_wave_alaw(EST_TokenStream &ts, short **data, int *num_samples, int *num_channels, int *word_size, int *sample_rate, enum EST_sample_type_t *sample_type, int *bo, int offset, int length)
The file was not written successfully.
enum EST_read_status load_wave_snd(EST_TokenStream &ts, short **data, int *num_samples, int *num_channels, int *word_size, int *sample_rate, enum EST_sample_type_t *sample_type, int *bo, int offset, int length)
EST_read_status load_file(const EST_String filename, const EST_String filetype, int sample_rate, const EST_String sample_type, int bo, ssize_t nc, int offset=0, ssize_t length=0)
static EST_write_status save_audlab_data(SaveWave_TokenStreamArgs)
const char * name(ENUM tok, int n=0) const
const EST_SMatrix & values() const
static EST_write_status save_ulaw(SaveWave_TokenStreamArgs)
enum EST_write_status save_wave_snd_header(FILE *fp, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
enum EST_write_status save_wave_nist(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
The file was written successfully.
enum EST_read_status load_wave_raw(EST_TokenStream &ts, short **data, int *num_samples, int *num_channels, int *word_size, int *sample_rate, enum EST_sample_type_t *sample_type, int *bo, int offset, int length, int isample_rate, enum EST_sample_type_t isample_type, int ibo, int inc)
enum EST_write_status save_wave_riff_header(FILE *fp, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
enum EST_write_status save_wave_audlab(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
enum EST_write_status save_wave_alaw_header(FILE *fp, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
static EST_write_status save_aiff_data(SaveWave_TokenStreamArgs)
static EST_write_status save_alaw_header(SaveWave_TokenStreamArgs)
enum EST_write_status save_wave_nist_data(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
enum EST_write_status save_wave_est_header(FILE *fp, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
static EST_write_status save_riff_data(SaveWave_TokenStreamArgs)
enum EST_read_status load_wave_sd(EST_TokenStream &ts, short **data, int *num_samples, int *num_channels, int *word_size, int *sample_rate, enum EST_sample_type_t *sample_type, int *bo, int offset, int length)
int matches(const char *e, ssize_t pos=0) const
Exactly match this string?
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
static EST_read_status load_est(LoadWave_TokenStreamArgs)
enum EST_write_status save_wave_raw(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
static EST_read_status load_alaw(LoadWave_TokenStreamArgs)
EST_String stdin_to_file()
Copy stdin to a file and return the name of that tmpfile.
int add_item(const K &rkey, const V &rval, int no_search=0)
add key-val pair to list
enum EST_write_status save_wave_est_data(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
static EST_String options_short(void)
int sample_rate() const
return the sampling rate (frequency)
static EST_write_status save_ulaw_header(SaveWave_TokenStreamArgs)
INFO & info(ENUM token) const
enum EST_write_status save_wave_audlab_data(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
enum EST_write_status save_wave_sd(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
static EST_write_status save_raw(SaveWave_TokenStreamArgs)
enum EST_write_status save_wave_est(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
enum EST_write_status save_wave_riff(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
void set_memory(T *buffer, ptrdiff_t offset, ssize_t rows, ssize_t columns, int free_when_destroyed=0)
static EST_read_status load_aiff(LoadWave_TokenStreamArgs)
enum EST_write_status save_wave_snd_data(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
enum EST_write_status save_wave_aiff_header(FILE *fp, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
static EST_write_status save_snd_data(SaveWave_TokenStreamArgs)
int present(const K &rkey) const
Returns true if key is present.
ssize_t num_channels() const
return the number of channels in the waveform
static EST_write_status save_nist_header(SaveWave_TokenStreamArgs)
static EST_write_status save_esps_header(SaveWave_TokenStreamArgs)
EST_String after(int pos, int len=1) const
Part after pos+len.
static EST_read_status load_nist(LoadWave_TokenStreamArgs)
EST_String before(int pos, int len=0) const
Part before position.
void resample(int rate)
Resample waveform to rate
static EST_read_status load_snd(LoadWave_TokenStreamArgs)
enum EST_write_status save_wave_audlab_header(FILE *fp, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
EST_String sample_type() const
enum EST_write_status save_wave_ulaw(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
static EST_write_status save_est(SaveWave_TokenStreamArgs)
EST_write_status write_wave(EST_Wave &sig, const EST_String &out_file, EST_Option &al)
enum EST_write_status save_wave_ulaw_data(FILE *fp, const short *data, int offset, int num_samples, int num_channels, int sample_rate, enum EST_sample_type_t sample_type, int bo)
EST_write_status(* standard_save_header_fn_fp)(FILE *fp, int nsamp, int nchan, int srate, EST_sample_type_t stype, int bo)
EST_read_status load(const EST_String filename, int offset=0, ssize_t length=0, int rate=default_sample_rate)
enum EST_read_status load_wave_ulaw(EST_TokenStream &ts, short **data, int *num_samples, int *num_channels, int *word_size, int *sample_rate, enum EST_sample_type_t *sample_type, int *bo, int offset, int length)
static EST_TNamedEnumI< EST_WaveFileType, Info > map