Edinburgh Speech Tools 2.4-release
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
42Auxiliary 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
58int wave_extract_channel(EST_Wave &single, const EST_Wave &multi, int channel);
59
60void wave_combine_channels(EST_Wave &combined, const EST_Wave &multi);
61
62int wave_subwave(EST_Wave &subsig,EST_Wave &sig,int offset,int length);
63
64int wave_divide(EST_WaveList &wl, EST_Wave &sig, EST_Relation &keylab,
65 const EST_String &ext);
66
67int wave_extract(EST_Wave &part, EST_Wave &sig, EST_Relation &keylab,
68 const EST_String &file);
69
70void add_waves(EST_Wave &s, const EST_Wave &m);
71
72EST_Wave difference(EST_Wave &a, EST_Wave &b);
73float rms_error(EST_Wave &a, EST_Wave &b, int channel);
74float abs_error(EST_Wave &a, EST_Wave &b, int channel);
75float correlation(EST_Wave &a, EST_Wave &b, int channel);
76
77EST_FVector rms_error(EST_Wave &a, EST_Wave &b);
78EST_FVector abs_error(EST_Wave &a, EST_Wave &b);
79EST_FVector correlation(EST_Wave &a, EST_Wave &b);
80
81EST_Wave error(EST_Wave &ref, EST_Wave &test, int relax);
82
83void absolute(EST_Wave &a);
84
85EST_read_status read_wave(EST_Wave &sig, const EST_String &in_file,
86 EST_Option &al);
87EST_write_status write_wave(EST_Wave &sig, const EST_String &in_file, EST_Option &al);
88void wave_info(EST_Wave &w);
89void invert(EST_Wave &sig);
90
91
92void differentiate(EST_Wave &sig);
93void reverse(EST_Wave &sig);
94
95void ulaw_to_short(const unsigned char *ulaw,short *data,int length);
96void alaw_to_short(const unsigned char *alaw,short *data,int length);
97void uchar_to_short(const unsigned char *chars,short *data,int length);
98void short_to_char(const short *data,unsigned char *chars,int length);
99void short_to_ulaw(const short *data,unsigned char *ulaw,int length);
100void short_to_alaw(const short *data,unsigned char *alaw,int length);
101
102// Used when setting Waves in Features
103VAL_REGISTER_CLASS_DCLS(wave,EST_Wave)
104
105enum EST_sample_type_t {
106 st_unknown,
107 st_schar,
108 st_uchar,
109 st_short,
110 st_shorten,
111 st_int,
112 st_float,
113 st_double,
114 st_mulaw,
115 st_adpcm,
116 st_alaw,
117 st_ascii};
118
119
120enum EST_write_status wave_io_save_header(FILE *fp,
121 const int num_samples, const int num_channels,
122 const int sample_rate,
123 const EST_String& stype, const int bo,
124 const EST_String& ftype);
125
126extern EST_TNamedEnum<EST_sample_type_t> EST_sample_type_map;
127
128#endif /* __EST_WAVE_AUX_H__ */
129
130//@}