Edinburgh Speech Tools  2.1-release
EST_WaveFile.cc
Go to the documentation of this file.
1  /*************************************************************************/
2  /* */
3  /* Centre for Speech Technology Research */
4  /* University of Edinburgh, UK */
5  /* Copyright (c) 1995,1996 */
6  /* All Rights Reserved. */
7  /* */
8  /* Permission is hereby granted, free of charge, to use and distribute */
9  /* this software and its documentation without restriction, including */
10  /* without limitation the rights to use, copy, modify, merge, publish, */
11  /* distribute, sublicense, and/or sell copies of this work, and to */
12  /* permit persons to whom this work is furnished to do so, subject to */
13  /* the following conditions: */
14  /* 1. The code must retain the above copyright notice, this list of */
15  /* conditions and the following disclaimer. */
16  /* 2. Any modifications must be clearly marked as such. */
17  /* 3. Original authors' names are not deleted. */
18  /* 4. The authors' names are not used to endorse or promote products */
19  /* derived from this software without specific prior written */
20  /* permission. */
21  /* */
22  /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
23  /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24  /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25  /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
26  /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27  /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28  /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29  /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30  /* THIS SOFTWARE. */
31  /* */
32  /*************************************************************************/
33  /* */
34  /* Author : Richard Caley <rjc@cstr.ed.ac.uk> */
35  /* ------------------------------------------------------------------- */
36  /* Wave file input and output. */
37  /* */
38  /*************************************************************************/
39 #include <cstdlib>
40 #include "EST_Wave.h"
41 #include "EST_WaveFile.h"
42 #include "waveP.h"
43 #include "EST_cutils.h"
44 #include "EST_Option.h"
45 #include "EST_io_aux.h"
46 #include <cstdio>
47 #include <cmath>
48 
49 using namespace std;
50 
51 void extract(EST_Wave &sig, EST_Option &al);
52 
53 typedef
55  short **data, int *nsamp, int *nchan,
56  int *wsize,
57  int *srate,
58  EST_sample_type_t *stype, int *bo,
59  int offset, int length);
60 
61 typedef
63  const short *data,
64  int offset, int nsamp,
65  int nchan, int srate,
66  EST_sample_type_t stype, int bo);
67 
68 typedef
70  int nsamp,
71  int nchan, int srate,
72  EST_sample_type_t stype, int bo);
73 
74 static
76  EST_TokenStream &ts,
77  EST_Wave &wv,
78  int rate,
79  EST_sample_type_t stype, int bo, int nchan,
80  int offset, int length)
81 {
82  short *data;
83  int nsamp;
84  int wsize;
85  int srate = rate;
86 
87  EST_read_status status = (*fn)(ts,
88  &data, &nsamp, &nchan,
89  &wsize,
90  &srate, &stype, &bo,
91  offset, length);
92 
93  if (status == read_ok)
94  {
95  short *data2 = new short[nsamp*nchan];
96  memcpy(data2, data, nsamp*nchan*sizeof(short));
97  wfree(data);
98  wv.values().set_memory(data2, 0, nsamp, nchan, TRUE);
99  wv.set_sample_rate(srate);
100  }
101 
102  return status;
103 }
104 
105 static
107  FILE *fp, const EST_Wave wv,
108  EST_sample_type_t stype, int bo)
109 {
110 EST_write_status status = (*fn)(fp,
111  wv.values().memory(),
112  0, wv.num_samples(), wv.num_channels(),
113  wv.sample_rate(),
114  stype, bo);
115 
116 return status;
117 }
118 
119 static
120 EST_write_status save_header_using(standard_save_header_fn_fp fn,
121  FILE *fp, const EST_Wave wv,
122  EST_sample_type_t stype, int bo)
123 {
124 
125 EST_write_status status = (*fn)(fp,
126  wv.num_samples(), wv.num_channels(),
127  wv.sample_rate(),
128  stype, bo);
129 return status;
130 }
131 
133  EST_Wave &wv,
134  int rate,
135  EST_sample_type_t stype, int bo, int nchan,
136  int offset, int length)
137 {
138  return load_using(load_wave_nist,
139  ts, wv, rate,
140  stype, bo, nchan,
141  offset, length);
142 }
143 
145  const EST_Wave &wv,
146  EST_sample_type_t stype, int bo)
147 {
148  return save_using(save_wave_nist, fp, wv, stype, bo);
149 }
150 
152  const EST_Wave &wv,
153  EST_sample_type_t stype, int bo)
154 {
155  return save_using(save_wave_nist_data, fp, wv, stype, bo);
156 }
157 
159  const EST_Wave &wv,
160  EST_sample_type_t stype, int bo)
161 {
162  return save_header_using(save_wave_nist_header, fp, wv, stype, bo);
163 }
164 
166  EST_Wave &wv,
167  int rate,
168  EST_sample_type_t stype, int bo, int nchan,
169  int offset, int length)
170 {
171  (void) ts;
172  return load_using(load_wave_est,
173  ts, wv, rate,
174  stype, bo, nchan,
175  offset, length);
176 
177 }
178 
180  const EST_Wave &wv,
181  EST_sample_type_t stype, int bo)
182 {
183  return save_using(save_wave_est,
184  fp, wv,
185  stype, bo);
186 }
187 
189  const EST_Wave &wv,
190  EST_sample_type_t stype, int bo)
191 {
192  return save_using(save_wave_est_data,
193  fp, wv,
194  stype, bo);
195 }
196 
198  const EST_Wave &wv,
199  EST_sample_type_t stype, int bo)
200 {
201  return save_header_using(save_wave_est_header,
202  fp, wv,
203  stype, bo);
204 }
205 
207  EST_Wave &wv,
208  int rate,
209  EST_sample_type_t stype, int bo, int nchan,
210  int offset, int length)
211 {
212  return load_using(load_wave_aiff,
213  ts, wv, rate,
214  stype, bo, nchan,
215  offset, length);
216 }
217 
219  const EST_Wave &wv,
220  EST_sample_type_t stype, int bo)
221 {
222  return save_using(save_wave_aiff, fp, wv, stype, bo);
223 }
224 
226  const EST_Wave &wv,
227  EST_sample_type_t stype, int bo)
228 {
229  return save_using(save_wave_aiff_data, fp, wv, stype, bo);
230 }
231 
233  const EST_Wave &wv,
234  EST_sample_type_t stype, int bo)
235 {
236  return save_header_using(save_wave_aiff_header, fp, wv, stype, bo);
237 }
238 
240  EST_Wave &wv,
241  int rate,
242  EST_sample_type_t stype, int bo, int nchan,
243  int offset, int length)
244 {
245  return load_using(load_wave_riff,
246  ts, wv, rate,
247  stype, bo, nchan,
248  offset, length);
249 }
250 
252  const EST_Wave &wv,
253  EST_sample_type_t stype, int bo)
254 {
255  return save_using(save_wave_riff, fp, wv, stype, bo);
256 }
257 
259  const EST_Wave &wv,
260  EST_sample_type_t stype, int bo)
261 {
262  return save_using(save_wave_riff_data, fp, wv, stype, bo);
263 }
264 
266  const EST_Wave &wv,
267  EST_sample_type_t stype, int bo)
268 {
269  return save_header_using(save_wave_riff_header, fp, wv, stype, bo);
270 }
271 
273  EST_Wave &wv,
274  int rate,
275  EST_sample_type_t stype, int bo, int nchan,
276  int offset, int length)
277 {
278  return load_using(load_wave_sd,
279  ts, wv, rate,
280  stype, bo, nchan,
281  offset, length);
282 }
283 
285  const EST_Wave &wv,
286  EST_sample_type_t stype, int bo)
287 {
288  return save_using(save_wave_sd,
289  fp, wv,
290  stype, bo);
291 }
292 
294  const EST_Wave &wv,
295  EST_sample_type_t stype, int bo)
296 {
297  return save_using(save_wave_sd_data,
298  fp, wv,
299  stype, bo);
300 }
301 
303  const EST_Wave &wv,
304  EST_sample_type_t stype, int bo)
305 {
306  return save_header_using(save_wave_sd_header,
307  fp, wv,
308  stype, bo);
309 }
310 
312  EST_Wave &wv,
313  int rate,
314  EST_sample_type_t stype, int bo, int nchan,
315  int offset, int length)
316 {
317  return load_using(load_wave_audlab,
318  ts, wv, rate,
319  stype, bo, nchan,
320  offset, length);
321 }
322 
324  const EST_Wave &wv,
325  EST_sample_type_t stype, int bo)
326 {
327  return save_using(save_wave_audlab, fp, wv, stype, bo);
328 }
329 
331  const EST_Wave &wv,
332  EST_sample_type_t stype, int bo)
333 {
334  return save_using(save_wave_audlab_data, fp, wv, stype, bo);
335 }
336 
338  const EST_Wave &wv,
339  EST_sample_type_t stype, int bo)
340 {
341  return save_header_using(save_wave_audlab_header, fp, wv, stype, bo);
342 }
343 
345  EST_Wave &wv,
346  int rate,
347  EST_sample_type_t stype, int bo, int nchan,
348  int offset, int length)
349 {
350  return load_using(load_wave_snd,
351  ts, wv, rate,
352  stype, bo, nchan,
353  offset, length);
354 }
355 
357  const EST_Wave &wv,
358  EST_sample_type_t stype, int bo)
359 {
360  return save_using(save_wave_snd, fp, wv, stype, bo);
361 }
362 
364  const EST_Wave &wv,
365  EST_sample_type_t stype, int bo)
366 {
367  return save_using(save_wave_snd_data, fp, wv, stype, bo);
368 }
369 
371  const EST_Wave &wv,
372  EST_sample_type_t stype, int bo)
373 {
374  return save_header_using(save_wave_snd_header, fp, wv, stype, bo);
375 }
376 
377 
378 
380  EST_Wave &wv,
381  int rate,
382  EST_sample_type_t stype, int bo, int nchan,
383  int offset, int length)
384 {
385  short *data;
386  int nsamp;
387  int wsize;
388  int srate = rate;
389 
390  EST_read_status status = load_wave_raw(ts,
391  &data, &nsamp, &nchan,
392  &wsize,
393  &srate, &stype, &bo,
394  offset, length,
395  rate, stype, bo, nchan);
396 
397  if (status == read_ok)
398  {
399  wv.values().set_memory(data, 0, nsamp, nchan, TRUE);
400  wv.set_sample_rate(srate);
401  }
402 
403  return status;
404 }
405 
407  const EST_Wave &wv,
408  EST_sample_type_t stype, int bo)
409 {
410 EST_write_status status = save_wave_raw(fp,
411  (short *)wv.values().memory(),
412  0, wv.num_samples(), wv.num_channels(),
413  wv.sample_rate(),
414  stype, bo);
415 return status;
416 }
417 
419  const EST_Wave &wv,
420  EST_sample_type_t stype, int bo)
421 {
422 return save_raw(fp, wv, stype, bo);
423 }
424 
425 
427  const EST_Wave &wv,
428  EST_sample_type_t stype, int bo)
429 {
430  return save_header_using(save_wave_raw_header, fp, wv, stype, bo);
431 }
432 
434  EST_Wave &wv,
435  int rate,
436  EST_sample_type_t stype, int bo, int nchan,
437  int offset, int length)
438 {
439  return load_using(load_wave_ulaw,
440  ts, wv, rate,
441  stype, bo, nchan,
442  offset, length);
443 }
444 
446  const EST_Wave &wv,
447  EST_sample_type_t stype, int bo)
448 {
449  EST_Wave localwv = wv;
450  localwv.resample(8000);
451  return save_using(save_wave_ulaw, fp, localwv, stype, bo);
452 }
453 
455  const EST_Wave &wv,
456  EST_sample_type_t stype, int bo)
457 {
458  EST_Wave localwv = wv;
459  localwv.resample(8000);
460  return save_using(save_wave_ulaw_data, fp, localwv, stype, bo);
461 }
462 
463 
465  const EST_Wave &wv,
466  EST_sample_type_t stype, int bo)
467 {
468  EST_Wave localwv = wv;
469  localwv.resample(8000);
470  return save_header_using(save_wave_ulaw_header, fp, localwv, stype, bo);
471 }
472 
474  EST_Wave &wv,
475  int rate,
476  EST_sample_type_t stype, int bo, int nchan,
477  int offset, int length)
478 {
479  return load_using(load_wave_alaw,
480  ts, wv, rate,
481  stype, bo, nchan,
482  offset, length);
483 }
484 
486  const EST_Wave &wv,
487  EST_sample_type_t stype, int bo)
488 {
489  EST_Wave localwv = wv;
490  localwv.resample(8000);
491  return save_header_using(save_wave_alaw_header, fp, localwv, stype, bo);
492 }
493 
495  const EST_Wave &wv,
496  EST_sample_type_t stype, int bo)
497 {
498  EST_Wave localwv = wv;
499  localwv.resample(8000);
500  return save_using(save_wave_alaw_data, fp, localwv, stype, bo);
501 }
502 
504  const EST_Wave &wv,
505  EST_sample_type_t stype, int bo)
506 {
507  EST_Wave localwv = wv;
508  localwv.resample(8000);
509  return save_using(save_wave_alaw, fp, localwv, stype, bo);
510 }
511 
512 static int parse_esps_r_option(EST_String arg, int &offset, int &length)
513 {
514  EST_String s, e;
515 
516  if (arg.contains("-"))
517  {
518  s = arg.before("-");
519  e = arg.after("-");
520  }
521  else if (arg.contains(":"))
522  {
523  s = arg.before(":");
524  e = arg.after(":");
525  }
526  else
527  {
528  cerr << "Argument to -r is illformed " << arg << endl;
529  return -1;
530  }
531 
532  if (!s.matches(RXint))
533  {
534  cerr << "First argument to -r must be an integer " << arg << endl;
535  return -1;
536  }
537 
538  offset = atoi(s);
539  if (e.contains("+"))
540  {
541  e = e.after("+");
542  length = atoi(e);
543  }
544  else
545  length = atoi(e) - offset;
546 
547  if (length <= 0)
548  {
549  cerr << "length is negative or zero " << arg << endl;
550  return -1;
551  }
552 
553  return 0;
554 }
555 
557  EST_Option &al)
558 {
559  char *sr;
560  EST_String fname, file_type, sample_type;
561  int sample_rate;
562  EST_read_status rval;
563  int num_channels;
564  int offset=0, length=0;
565  int bo;
566 
567  if (in_file == "-")
568  fname = stdin_to_file();
569  else
570  fname = in_file;
571 
572  if (al.present("-n"))
573  num_channels = al.ival("-n", 0);
574  else
575  num_channels = 1;
576 
577  if (al.present("-ulaw"))
578  {
579  al.add_item("-itype","ulaw");
580  al.add_item("-f","8000");
581  }
582  if (al.present("-alaw"))
583  {
584 al.add_item("-itype","alaw");
585 al.add_item("-f","8000");
586  }
587  if (al.present("-iswap"))
588  al.add_item("-ibo","other");
589 
590  if (al.present("-istype"))
591  sample_type = al.val("-istype");
592  else
593  sample_type = sig.sample_type(); // else default type;
594 
595  if (al.present("-itype"))
596  file_type = al.val("-itype"); // else default type;
597  else
598  file_type = "undef";
599 
600 
601  if (al.present("-f"))
602  sample_rate = al.ival("-f", 0);
603  else if ((sr = getenv("NA_PLAY_SAMPLE_RATE")) != NULL)
604  {
605  sample_rate = atoi(sr);
606  cerr << "Warning: no sample rate specified, " <<
607  " using NA_PLAY_SAMPLE_RATE environment variable\n";
608  }
609  else
610  {
611  sample_rate = EST_Wave::default_sample_rate;
612  if (file_type == "raw")
613  cerr << "Warning: no sample rate specified - using default " <<
614  sample_rate << endl;
615  }
616 
617  if (file_type == "ulaw")
618  {
619  sample_rate = 8000;
620  sample_type = "mulaw";
621  }
622 
623  if (al.present("-r")) // only load in part of waveform
624  {
625  if (parse_esps_r_option(al.val("-r"), offset, length) != 0)
626  return read_error;
627  }
628  else
629  offset = length = 0;
630 
631  if (al.present("-iswap"))
632  bo = str_to_bo("swap");
633  else
634  bo = str_to_bo("native");
635  if (al.present("-ibo")) // can override -iswap
636  bo = str_to_bo(al.val("-ibo"));
637 
638  if (file_type == "" ||file_type == "undef")
639  rval = sig.load(fname, offset, length, sample_rate);
640  else
641  rval = sig.load_file(fname,file_type, sample_rate,
642  sample_type, bo, num_channels, offset, length);
643 
644  if ((rval == wrong_format) && (al.present("-basic")))
645  {
646  // For HTML audio/basic, it seems to mean headered or ulaw 8k
647  // so try to load it again as ulaw 8k.
648  rval = sig.load_file(fname, "raw", 8000,
649  "mulaw", bo, 1, offset, length);
650  }
651  if (rval != format_ok)
652  {
653  if (in_file == "-") unlink(fname);
654  cerr << "Cannot recognize file format or cannot access file: \"" << in_file << "\"\n";
655  return read_error;
656  }
657  if (file_type == "alaw")
658  {
659 sample_rate = 8000;
660 sample_type = "alaw";
661  }
662 
663  if (al.present("-start") || al.present("-end")
664  || al.present("-to") || al.present("-from"))
665  extract(sig, al);
666 
667  if (in_file == "-") unlink(fname);
668  return read_ok;
669 }
670 
672  EST_Option &al)
673 {
674  EST_String file_type, sample_type;
675  int bo;
676 
677  if (al.present("-otype"))
678  file_type = al.val("-otype");
679  else
680  file_type = sig.file_type();
681 
682  if (al.present("-ostype"))
683  sample_type = al.val("-ostype");
684  else
685  sample_type = "undef";
686 
687  if (al.present("-oswap"))
688  bo = str_to_bo("swap");
689  else
690  bo = str_to_bo("native");
691 
692  if (al.present("-obo")) // can over ride -oswap
693  bo = str_to_bo(al.val("-obo"));
694 
695  if (sample_type == "undef" || sample_type == "")
696  sample_type = "short";
697 
698  if (sig.save_file(out_file, file_type,
699  sample_type, bo) != write_ok)
700  {
701  cerr << "Cannot write file: \"" << out_file << "\"\n";
702  return write_error;
703  }
704 
705  return write_ok;
706 }
707 
709 {
710  EST_String s("");
711 
712  for(int n=0; n< EST_WaveFile::map.n() ; n++)
713  {
714  const char *nm = EST_WaveFile::map.name(EST_WaveFile::map.token(n));
715 
716  if (s != "")
717  s += ", ";
718 
719  s += nm;
720 
721  }
722  return s;
723 }
724 
726 {
727  EST_String s("Available wave file formats:\n");
728 
729  for(int n=0; n< EST_WaveFile::map.n() ; n++)
730  {
731  const char *nm = EST_WaveFile::map.name(EST_WaveFile::map.token(n));
732  const char *d = EST_WaveFile::map.info(EST_WaveFile::map.token(n)).description;
733 
734  s += EST_String::cat(" ", nm, EST_String(" ")*(12-strlen(nm)), d, "\n");
735  }
736  return s;
737 }
738 
739 typedef struct TInfo {
740  bool recognise;
741  const char *description;
742 } TInfo;
743 
744 // note the order here defines the order in which loads are tried.
745 
746 
747 static
749 {
750  { wff_none, { NULL },
751  { FALSE, NULL, NULL, NULL, NULL, "unknown track file type"} },
752  { wff_nist, { "nist", "timit"},
755  "nist/timit" } },
756  { wff_est, { "est"},
759  "est" } },
760  { wff_esps, { "esps", "sd"},
763  "esps SD waveform" } },
764  { wff_audlab, { "audlab", "vox"},
767  "audlab waveform" } },
768  { wff_snd, { "snd", "au"},
771  "Sun snd file" } },
772  { wff_aiff, { "aiff"},
775  "Apple aiff file" } },
776  { wff_riff, { "riff", "wav"},
779  "Microsoft wav/riff file" } },
780  { wff_raw, { "raw" },
783  "Headerless File" } },
784  { wff_ulaw, { "ulaw", "basic"},
787  "Headerless 8K ulaw File" } },
788  { wff_alaw, { "alaw", "basic"},
791  "Headerless 8K alaw File" } },
792  { wff_none, { NULL }, {FALSE, NULL, NULL,
793  NULL, NULL, NULL} }
794 };
795 
797 
798 #if defined(INSTANTIATE_TEMPLATES)
799 
800 #include "../base_class/EST_TNamedEnum.cc"
802 template class EST_TValuedEnumI<EST_WaveFileType, const char *,
803 EST_WaveFile::Info>;
804 
805 #endif
A class for storing digital waveforms. The waveform is stored as an array of 16 bit shorts...
Definition: EST_Wave.h:64
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)
Definition: EST_wave_io.cc:171
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
Definition: EST_Wave.h:149
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)
const char * description
int contains(const char *s, ssize_t pos=-1) const
Does it contain this substring?
Definition: EST_String.h:365
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)
Definition: EST_wave_io.cc:747
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)
Definition: EST_cutils.c:95
EST_write_status
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)
Definition: EST_wave_io.cc:527
static EST_write_status save_esps(SaveWave_TokenStreamArgs)
int ival(const EST_String &rkey, int m=1) const
Definition: EST_Option.cc:82
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)
Definition: EST_WaveFile.cc:62
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)
Definition: EST_wave_io.cc:398
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
Definition: EST_Wave.h:143
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)
Definition: EST_wave_io.cc:320
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)
Definition: EST_wave_io.cc:792
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)
Definition: EST_WaveFile.cc:54
static EST_read_status load_esps(LoadWave_TokenStreamArgs)
char * getenv()
static EST_write_status save_audlab(SaveWave_TokenStreamArgs)
static EST_write_status save_nist(SaveWave_TokenStreamArgs)
EST_String file_type() const
Definition: EST_Wave.h:166
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
Definition: EST_Wave.h:78
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)
Definition: EST_String.cc:1084
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")
Definition: EST_Wave.cc:398
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)
Definition: EST_Wave.cc:291
static EST_write_status save_audlab_data(SaveWave_TokenStreamArgs)
const char * name(ENUM tok, int n=0) const
const EST_SMatrix & values() const
Definition: EST_Wave.h:177
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)
Definition: EST_wave_io.cc:382
int n(void) const
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)
#define wrong_format
#define FALSE
Definition: EST_bool.h:119
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)
Definition: EST_wave_io.cc:685
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)
NULL
Definition: EST_WFST.cc:55
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)
Definition: EST_wave_io.cc:368
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)
Definition: EST_wave_io.cc:467
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?
Definition: EST_String.cc:651
const V & val(const K &rkey, bool m=0) const
return value according to key (const)
Definition: EST_TKVL.cc:145
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.
Definition: util_io.cc:96
int add_item(const K &rkey, const V &rval, int no_search=0)
add key-val pair to list
Definition: EST_TKVL.cc:248
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)
Definition: EST_wave_io.cc:485
static EST_String options_short(void)
int sample_rate() const
return the sampling rate (frequency)
Definition: EST_Wave.h:147
EST_read_status
static EST_write_status save_ulaw_header(SaveWave_TokenStreamArgs)
const T * memory() const
Definition: EST_TVector.h:238
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)
Definition: EST_wave_io.cc:498
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)
Definition: EST_wave_io.cc:762
void set_memory(T *buffer, ptrdiff_t offset, ssize_t rows, ssize_t columns, int free_when_destroyed=0)
Definition: EST_TMatrix.cc:371
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)
Definition: EST_wave_io.cc:953
#define format_ok
static EST_write_status save_snd_data(SaveWave_TokenStreamArgs)
int present(const K &rkey) const
Returns true if key is present.
Definition: EST_TKVL.cc:222
ssize_t num_channels() const
return the number of channels in the waveform
Definition: EST_Wave.h:145
EST_sample_type_t
Definition: EST_wave_aux.h:105
EST_WaveFileType
Definition: EST_WaveFile.h:50
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.
Definition: EST_String.h:308
static EST_read_status load_nist(LoadWave_TokenStreamArgs)
EST_String before(int pos, int len=0) const
Part before position.
Definition: EST_String.h:276
void resample(int rate)
Resample waveform to rate
Definition: EST_Wave.cc:492
static EST_read_status load_snd(LoadWave_TokenStreamArgs)
LISP fp
Definition: kkcompile.cc:63
EST_String
void wfree(void *p)
Definition: walloc.c:131
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
Definition: EST_Wave.h:163
#define TRUE
Definition: EST_bool.h:118
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)
Definition: EST_WaveFile.cc:69
EST_read_status load(const EST_String filename, int offset=0, ssize_t length=0, int rate=default_sample_rate)
Definition: EST_Wave.cc:180
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
Definition: EST_WaveFile.h:154