1
/*************************************************************************/
3
/* Centre for Speech Technology Research */
4
/* (University of Edinburgh, UK) and */
6
/* Copyright (c) 2003 */
7
/* All Rights Reserved. */
9
/* Permission is hereby granted, free of charge, to use and distribute */
10
/* this software and its documentation without restriction, including */
11
/* without limitation the rights to use, copy, modify, merge, publish, */
12
/* distribute, sublicense, and/or sell copies of this work, and to */
13
/* permit persons to whom this work is furnished to do so, subject to */
14
/* the following conditions: */
16
/* 1. The code must retain the above copyright notice, this list of */
17
/* conditions and the following disclaimer. */
18
/* 2. Any modifications must be clearly marked as such. */
19
/* 3. Original authors' names are not deleted. */
20
/* 4. The authors' names are not used to endorse or promote products */
21
/* derived from this software without specific prior written */
24
/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
25
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
26
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT */
27
/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
28
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
29
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
30
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
31
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
34
/*************************************************************************/
35
/* Author : Korin Richmond */
36
/* Date : 02 June 2003 */
37
/* ------------------------------------------------------------------- */
38
/* EST_Wave Class interface file */
40
/*************************************************************************/
46
#include "EST_wave_aux.h"
47
#include "EST_audio.h"
48
#include "EST_Option.h"
51
%include "EST_rw_status.i"
52
%include "EST_typemaps.i"
61
void default_vals(int n=0, int c=1);
63
void copy_data(const EST_Wave &w);
64
void copy_setup(const EST_Wave &w);
68
// these are static in the EST_Wave class, but there's some
69
// problem with segmentation fault...
70
const int default_sample_rate;
71
//const int default_num_channels;
74
EST_Wave(const EST_Wave &a);
75
EST_Wave(int n, int c, int sr);
78
short a(int i, int channel = 0) const;
79
short &a_safe(int i, int channel = 0);
82
short set_a(int i, int channel = 0, short val = 0);
84
// return the time position in seconds of the ith sample
87
int num_samples() const;
88
int num_channels() const;
89
int sample_rate() const;
90
void set_sample_rate(const int n);
93
// return the time position of the last sample.
96
// Can we look N samples to the left?
97
bool have_left_context(unsigned int n) const;
99
EST_String sample_type() const;
100
void set_sample_type(const EST_String t);
102
EST_String file_type() const;
103
void set_file_type(const EST_String t);
105
EST_String name() const;
106
void set_name(const EST_String n);
108
void resize(int num_samples, int num_channels = EST_ALL, int set=1);
109
void resample(int rate);
111
// multiply all samples by factor "gain".
112
void rescale( float gain,int normalize=0 );
113
void rescale( const EST_Track &factor_contour );
115
// clear waveform and set size to 0.
118
void copy(const EST_Wave &from);
119
void fill(short v=0, int channel=EST_ALL);
121
void empty(int channel=EST_ALL);
123
EST_read_status load(const EST_String filename,
126
int rate = default_sample_rate);
128
EST_read_status load_file(const EST_String filename,
129
const EST_String filetype, int sample_rate,
130
const EST_String sample_type, int bo, int nc,
131
int offset = 0, int length = 0);
133
EST_write_status save(const EST_String filename,
134
const EST_String EST_filetype = "");
136
EST_write_status save_file(const EST_String filename,
138
EST_String sample_type, int bo);
140
void integrity() const;
153
play_wave( *self, empty );
159
int wave_extract_channel(EST_Wave &single, const EST_Wave &multi, int channel);
161
void wave_combine_channels(EST_Wave &combined, const EST_Wave &multi);
163
int wave_subwave(EST_Wave &subsig,EST_Wave &sig,int offset,int length);
165
int wave_divide(EST_WaveList &wl, EST_Wave &sig, EST_Relation &keylab,
166
const EST_String &ext);
168
int wave_extract(EST_Wave &part, EST_Wave &sig, EST_Relation &keylab,
169
const EST_String &file);
171
void add_waves(EST_Wave &s, const EST_Wave &m);
173
EST_Wave difference(EST_Wave &a, EST_Wave &b);
174
float rms_error(EST_Wave &a, EST_Wave &b, int channel);
175
float abs_error(EST_Wave &a, EST_Wave &b, int channel);
176
float correlation(EST_Wave &a, EST_Wave &b, int channel);
178
EST_FVector rms_error(EST_Wave &a, EST_Wave &b);
179
EST_FVector abs_error(EST_Wave &a, EST_Wave &b);
180
EST_FVector correlation(EST_Wave &a, EST_Wave &b);
182
EST_Wave error(EST_Wave &ref, EST_Wave &test, int relax);
184
void absolute(EST_Wave &a);
186
void wave_info(EST_Wave &w);
187
void invert(EST_Wave &sig);
189
void differentiate(EST_Wave &sig);
190
void reverse(EST_Wave &sig);