Edinburgh Speech Tools  2.4-release
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
EST_wave_aux.h
1 /*************************************************************************/
2 /* */
3 /* Centre for Speech Technology Research */
4 /* University of Edinburgh, UK */
5 /* Copyright (c) 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 /* Author : Paul Taylor and Alan Black */
34 /* Date : May 1996 */
35 /*-----------------------------------------------------------------------*/
36 /* EST_Wave class auxiliary functions */
37 /* */
38 /*=======================================================================*/
39 
40 
41 /**@name EST_wave_aux
42 Auxiliary functions for processing waveforms.
43  */
44 
45 //@{
46 
47 #ifndef __EST_WAVE_AUX_H__
48 #define __EST_WAVE_AUX_H__
49 
50 #include "EST_String.h"
51 #include "EST_Wave.h"
52 #include "ling_class/EST_Relation.h"
53 #include "EST_Option.h"
54 #include "EST_FMatrix.h"
55 #include "EST_TNamedEnum.h"
56 
57 
58 int wave_extract_channel(EST_Wave &single, const EST_Wave &multi, int channel);
59 
60 void wave_combine_channels(EST_Wave &combined, const EST_Wave &multi);
61 
62 int wave_subwave(EST_Wave &subsig,EST_Wave &sig,int offset,int length);
63 
64 int wave_divide(EST_WaveList &wl, EST_Wave &sig, EST_Relation &keylab,
65  const EST_String &ext);
66 
67 int wave_extract(EST_Wave &part, EST_Wave &sig, EST_Relation &keylab,
68  const EST_String &file);
69 
70 void add_waves(EST_Wave &s, const EST_Wave &m);
71 
72 EST_Wave difference(EST_Wave &a, EST_Wave &b);
73 float rms_error(EST_Wave &a, EST_Wave &b, int channel);
74 float abs_error(EST_Wave &a, EST_Wave &b, int channel);
75 float correlation(EST_Wave &a, EST_Wave &b, int channel);
76 
77 EST_FVector rms_error(EST_Wave &a, EST_Wave &b);
78 EST_FVector abs_error(EST_Wave &a, EST_Wave &b);
79 EST_FVector correlation(EST_Wave &a, EST_Wave &b);
80 
81 EST_Wave error(EST_Wave &ref, EST_Wave &test, int relax);
82 
83 void absolute(EST_Wave &a);
84 
85 EST_read_status read_wave(EST_Wave &sig, const EST_String &in_file,
86  EST_Option &al);
87 EST_write_status write_wave(EST_Wave &sig, const EST_String &in_file, EST_Option &al);
88 void wave_info(EST_Wave &w);
89 void invert(EST_Wave &sig);
90 
91 
92 void differentiate(EST_Wave &sig);
93 void reverse(EST_Wave &sig);
94 
95 void ulaw_to_short(const unsigned char *ulaw,short *data,int length);
96 void alaw_to_short(const unsigned char *alaw,short *data,int length);
97 void uchar_to_short(const unsigned char *chars,short *data,int length);
98 void short_to_char(const short *data,unsigned char *chars,int length);
99 void short_to_ulaw(const short *data,unsigned char *ulaw,int length);
100 
101 // Used when setting Waves in Features
102 VAL_REGISTER_CLASS_DCLS(wave,EST_Wave)
103 
104 enum EST_sample_type_t {
105  st_unknown,
106  st_schar,
107  st_uchar,
108  st_short,
109  st_shorten,
110  st_int,
111  st_float,
112  st_double,
113  st_mulaw,
114  st_adpcm,
115  st_alaw,
116  st_ascii};
117 
118 extern EST_TNamedEnum<EST_sample_type_t> EST_sample_type_map;
119 
120 #endif /* __EST_WAVE_AUX_H__ */
121 
122 //@}