Edinburgh Speech Tools 2.4-release
EST_Wave Class Reference

#include <include/EST_Wave.h>

Inheritance diagram for EST_Wave:
Collaboration diagram for EST_Wave:

Public Member Functions

 EST_Wave ()
 default constructor More...
 
 EST_Wave (const EST_Wave &a)
 copy constructor More...
 
 EST_Wave (int n, int c, int sr)
 
 EST_Wave (int samps, int chans, short *memory, int offset=0, int sample_rate=default_sample_rate, int free_when_destroyed=0)
 Construct from memory supplied by caller. More...
 
Access functions for finding amplitudes of samples
short & a (int i, int channel=0)
 
short a (int i, int channel=0) const
 
INLINE short & a_no_check (int i, int channel=0)
 
INLINE short a_no_check (int i, int channel=0) const
 
INLINE short & a_no_check_1 (int i, int channel=0)
 
INLINE short a_no_check_1 (int i, int channel=0) const
 
INLINE short set_a (int i, int channel=0, short val=0)
 
short operator() (int i, int channel) const
 
short operator() (int i) const
 
short & a_safe (int i, int channel=0)
 
float t (int i) const
 return the time position in seconds of the ith sample More...
 
Information functions
int num_samples () const
 return the number of samples in the waveform More...
 
int num_channels () const
 return the number of channels in the waveform More...
 
int sample_rate () const
 return the sampling rate (frequency) More...
 
void set_sample_rate (const int n)
 Set sampling rate to n More...
 
int length () const
 return the size of the waveform, i.e. the number of samples. More...
 
float end ()
 return the time position of the last sample. More...
 
bool have_left_context (unsigned int n) const
 Can we look N samples to the left? More...
 
EST_String sample_type () const
 
void set_sample_type (const EST_String t)
 
EST_String file_type () const
 
void set_file_type (const EST_String t)
 
EST_String name () const
 A string identifying the waveform, commonly used to store the filename. More...
 
void set_name (const EST_String n)
 Sets name. More...
 
const EST_SMatrixvalues () const
 
EST_SMatrixvalues ()
 
Waveform manipulation functions
void resize (int num_samples, int num_channels=EST_ALL, int set=1)
 resize the waveform More...
 
void resample (int rate)
 Resample waveform to rate More...
 
void compress (float mu, float limit)
 Dynamic Range Compression - SaiKrishna May 2017. More...
 
void rescale (float gain, int normalize=0)
 
void rescale (const EST_Track &factor_contour)
 
void clear ()
 clear waveform and set size to 0. More...
 
void copy (const EST_Wave &from)
 
void fill (short v=0, int channel=EST_ALL)
 
void empty (int channel=EST_ALL)
 
void sample (EST_TVector< short > &sv, int n)
 
void channel (EST_TVector< short > &cv, int n)
 
void copy_channel (int n, short *buf, int offset=0, int num=EST_ALL) const
 
void copy_sample (int n, short *buf, int offset=0, int num=EST_ALL) const
 
void set_channel (int n, const short *buf, int offset=0, int num=EST_ALL)
 
void set_sample (int n, const short *buf, int offset=0, int num=EST_ALL)
 
void sub_wave (EST_Wave &sw, int offset=0, int num=EST_ALL, int start_c=0, int nchan=EST_ALL)
 
void sub_wave (EST_Wave &sw, int offset=0, int num=EST_ALL, int start_c=0, int nchan=EST_ALL) const
 

Static Public Attributes

static const int default_sample_rate =16000
 
static const int default_num_channels
 

Protected Member Functions

void default_vals (int n=0, int c=1)
 
void free_wave ()
 
void copy_data (const EST_Wave &w)
 
void copy_setup (const EST_Wave &w)
 

Protected Attributes

EST_SMatrix p_values
 
int p_sample_rate
 

File i/o functions

EST_read_status load (const EST_String filename, int offset=0, int length=0, int rate=default_sample_rate)
 
EST_read_status load (EST_TokenStream &ts, int offset=0, int length=0, int rate=default_sample_rate)
 
EST_read_status load (const EST_String filename, const EST_String filetype, int offset=0, int length=0, int rate=default_sample_rate)
 
EST_read_status load (EST_TokenStream &ts, const EST_String filetype, int offset=0, int length=0, int rate=default_sample_rate)
 
EST_read_status load_file (const EST_String filename, const EST_String filetype, int sample_rate, const EST_String sample_type, int bo, int nc, int offset=0, int length=0)
 
EST_read_status load_file (EST_TokenStream &ts, const EST_String filetype, int sample_rate, const EST_String sample_type, int bo, int nc, int offset=0, int length=0)
 
EST_write_status save (const EST_String filename, const EST_String EST_filetype="")
 
EST_write_status save (FILE *fp, const EST_String EST_filetype="")
 
EST_write_status save_file (const EST_String filename, EST_String filetype, EST_String sample_type, int bo, const char *mode="wb")
 
EST_write_status save_file (FILE *fp, EST_String filetype, EST_String sample_type, int bo)
 
EST_write_status save_file_header (FILE *fp, EST_String ftype, EST_String stype, int obo)
 
EST_write_status save_file_data (FILE *fp, EST_String ftype, EST_String stype, int obo)
 
EST_Waveoperator= (const EST_Wave &w)
 Assignment operator. More...
 
EST_Waveoperator+= (const EST_Wave &a)
 
EST_Waveoperator|= (const EST_Wave &a)
 
void integrity () const
 
ostream & operator<< (ostream &p_values, const EST_Wave &sig)
 print waveform More...
 

Additional Inherited Members

Detailed Description

A class for storing digital waveforms. The waveform is stored as an array of 16 bit shorts. Multiple channels are supported, but if no channel information is given the 0th channel is accessed.

The waveforms can be of any sample rate, and can be changed to another sampling rate using the resample function.

Definition at line 64 of file EST_Wave.h.

Constructor & Destructor Documentation

◆ EST_Wave() [1/4]

EST_Wave::EST_Wave ( )

default constructor

Definition at line 63 of file EST_Wave.cc.

◆ EST_Wave() [2/4]

EST_Wave::EST_Wave ( const EST_Wave a)

copy constructor

Definition at line 68 of file EST_Wave.cc.

◆ EST_Wave() [3/4]

EST_Wave::EST_Wave ( int  n,
int  c,
int  sr 
)

Definition at line 74 of file EST_Wave.cc.

◆ EST_Wave() [4/4]

EST_Wave::EST_Wave ( int  samps,
int  chans,
short *  memory,
int  offset = 0,
int  sample_rate = default_sample_rate,
int  free_when_destroyed = 0 
)

Construct from memory supplied by caller.

Definition at line 80 of file EST_Wave.cc.

◆ ~EST_Wave()

EST_Wave::~EST_Wave ( )

Definition at line 105 of file EST_Wave.cc.

Member Function Documentation

◆ default_vals()

void EST_Wave::default_vals ( int  n = 0,
int  c = 1 
)
protected

Definition at line 89 of file EST_Wave.cc.

◆ free_wave()

void EST_Wave::free_wave ( )
protected

Definition at line 98 of file EST_Wave.cc.

◆ copy_data()

void EST_Wave::copy_data ( const EST_Wave w)
protected

Definition at line 116 of file EST_Wave.cc.

◆ copy_setup()

void EST_Wave::copy_setup ( const EST_Wave w)
protected

Definition at line 110 of file EST_Wave.cc.

◆ a() [1/2]

short & EST_Wave::a ( int  i,
int  channel = 0 
)

return amplitude of sample i from channel channel. By default the 0th channel is selected. This function can be used for assignment.

Definition at line 128 of file EST_Wave.cc.

◆ a() [2/2]

short EST_Wave::a ( int  i,
int  channel = 0 
) const

Definition at line 147 of file EST_Wave.cc.

◆ a_no_check() [1/2]

INLINE short & EST_Wave::a_no_check ( int  i,
int  channel = 0 
)
inline

Definition at line 105 of file EST_Wave.h.

◆ a_no_check() [2/2]

INLINE short EST_Wave::a_no_check ( int  i,
int  channel = 0 
) const
inline

Definition at line 107 of file EST_Wave.h.

◆ a_no_check_1() [1/2]

INLINE short & EST_Wave::a_no_check_1 ( int  i,
int  channel = 0 
)
inline

Definition at line 109 of file EST_Wave.h.

◆ a_no_check_1() [2/2]

INLINE short EST_Wave::a_no_check_1 ( int  i,
int  channel = 0 
) const
inline

Definition at line 111 of file EST_Wave.h.

◆ set_a()

INLINE short EST_Wave::set_a ( int  i,
int  channel = 0,
short  val = 0 
)
inline

explicit set_a, easier to wrap than assignment

Definition at line 117 of file EST_Wave.h.

◆ operator()() [1/2]

short EST_Wave::operator() ( int  i,
int  channel 
) const
inline

return amplitude of sample i from channel channel. By default the 0th channel is selected.

Definition at line 123 of file EST_Wave.h.

◆ operator()() [2/2]

short EST_Wave::operator() ( int  i) const
inline

return amplitude of sample i from channel 0.

Definition at line 128 of file EST_Wave.h.

◆ a_safe()

short & EST_Wave::a_safe ( int  i,
int  channel = 0 
)

Version of a() that returns zero if index is out of array bounds. This is particularly useful in signal processing when you want to have windows going off the end of the waveform.

Definition at line 152 of file EST_Wave.cc.

◆ t()

float EST_Wave::t ( int  i) const
inline

return the time position in seconds of the ith sample

Definition at line 137 of file EST_Wave.h.

◆ num_samples()

int EST_Wave::num_samples ( ) const
inline

return the number of samples in the waveform

Definition at line 143 of file EST_Wave.h.

◆ num_channels()

int EST_Wave::num_channels ( ) const
inline

return the number of channels in the waveform

Definition at line 145 of file EST_Wave.h.

◆ sample_rate()

int EST_Wave::sample_rate ( ) const
inline

return the sampling rate (frequency)

Definition at line 147 of file EST_Wave.h.

◆ set_sample_rate()

void EST_Wave::set_sample_rate ( const int  n)
inline

Set sampling rate to n

Definition at line 149 of file EST_Wave.h.

◆ length()

int EST_Wave::length ( void  ) const
inline

return the size of the waveform, i.e. the number of samples.

Definition at line 151 of file EST_Wave.h.

◆ end()

float EST_Wave::end ( )
inline

return the time position of the last sample.

Definition at line 153 of file EST_Wave.h.

◆ have_left_context()

bool EST_Wave::have_left_context ( unsigned int  n) const
inline

Can we look N samples to the left?

Definition at line 156 of file EST_Wave.h.

◆ sample_type()

EST_String EST_Wave::sample_type ( ) const
inline

returns the file format of the file from which the waveform was read. If the waveform has not been read from a file, this is set to the default type

Definition at line 163 of file EST_Wave.h.

◆ set_sample_type()

void EST_Wave::set_sample_type ( const EST_String  t)
inline

Definition at line 164 of file EST_Wave.h.

◆ file_type()

EST_String EST_Wave::file_type ( ) const
inline

Definition at line 166 of file EST_Wave.h.

◆ set_file_type()

void EST_Wave::set_file_type ( const EST_String  t)
inline

Definition at line 167 of file EST_Wave.h.

◆ name()

EST_String EST_Wave::name ( void  ) const
inline

A string identifying the waveform, commonly used to store the filename.

Definition at line 170 of file EST_Wave.h.

◆ set_name()

void EST_Wave::set_name ( const EST_String  n)
inline

Sets name.

Definition at line 173 of file EST_Wave.h.

◆ values() [1/2]

const EST_SMatrix & EST_Wave::values ( ) const
inline

Definition at line 177 of file EST_Wave.h.

◆ values() [2/2]

EST_SMatrix & EST_Wave::values ( )
inline

Definition at line 178 of file EST_Wave.h.

◆ resize()

void EST_Wave::resize ( int  num_samples,
int  num_channels = EST_ALL,
int  set = 1 
)
inline

resize the waveform

Definition at line 184 of file EST_Wave.h.

◆ resample()

void EST_Wave::resample ( int  rate)

Resample waveform to rate

Definition at line 489 of file EST_Wave.cc.

◆ compress()

void EST_Wave::compress ( float  mu,
float  limit 
)

Dynamic Range Compression - SaiKrishna May 2017.

Definition at line 503 of file EST_Wave.cc.

◆ rescale() [1/2]

void EST_Wave::rescale ( float  gain,
int  normalize = 0 
)

multiply all samples by a factor gain. This checks for overflows and puts them to the maximum positive or negative value as appropriate.

Definition at line 517 of file EST_Wave.cc.

◆ rescale() [2/2]

void EST_Wave::rescale ( const EST_Track factor_contour)

Definition at line 560 of file EST_Wave.cc.

◆ clear()

void EST_Wave::clear ( void  )
inline

clear waveform and set size to 0.

Definition at line 206 of file EST_Wave.h.

◆ copy()

void EST_Wave::copy ( const EST_Wave from)

Definition at line 121 of file EST_Wave.cc.

◆ fill()

void EST_Wave::fill ( short  v = 0,
int  channel = EST_ALL 
)

Definition at line 166 of file EST_Wave.cc.

◆ empty()

void EST_Wave::empty ( int  channel = EST_ALL)
inline

Definition at line 212 of file EST_Wave.h.

◆ sample()

void EST_Wave::sample ( EST_TVector< short > &  sv,
int  n 
)
inline

Definition at line 214 of file EST_Wave.h.

◆ channel()

void EST_Wave::channel ( EST_TVector< short > &  cv,
int  n 
)
inline

Definition at line 216 of file EST_Wave.h.

◆ copy_channel()

void EST_Wave::copy_channel ( int  n,
short *  buf,
int  offset = 0,
int  num = EST_ALL 
) const
inline

Definition at line 219 of file EST_Wave.h.

◆ copy_sample()

void EST_Wave::copy_sample ( int  n,
short *  buf,
int  offset = 0,
int  num = EST_ALL 
) const
inline

Definition at line 221 of file EST_Wave.h.

◆ set_channel()

void EST_Wave::set_channel ( int  n,
const short *  buf,
int  offset = 0,
int  num = EST_ALL 
)
inline

Definition at line 224 of file EST_Wave.h.

◆ set_sample()

void EST_Wave::set_sample ( int  n,
const short *  buf,
int  offset = 0,
int  num = EST_ALL 
)
inline

Definition at line 226 of file EST_Wave.h.

◆ sub_wave() [1/2]

void EST_Wave::sub_wave ( EST_Wave sw,
int  offset = 0,
int  num = EST_ALL,
int  start_c = 0,
int  nchan = EST_ALL 
)

Definition at line 339 of file EST_Wave.cc.

◆ sub_wave() [2/2]

void EST_Wave::sub_wave ( EST_Wave sw,
int  offset = 0,
int  num = EST_ALL,
int  start_c = 0,
int  nchan = EST_ALL 
) const
inline

Definition at line 234 of file EST_Wave.h.

◆ load() [1/4]

EST_read_status EST_Wave::load ( const EST_String  filename,
int  offset = 0,
int  length = 0,
int  rate = default_sample_rate 
)

Load a file into the waveform. The load routine attempts to automatically determine which file type is being loaded. A portion of the waveform can be loaded by setting offset to the sample position from the beginning and <length> to the number of required samples after this.

Definition at line 180 of file EST_Wave.cc.

◆ load() [2/4]

EST_read_status EST_Wave::load ( EST_TokenStream ts,
int  offset = 0,
int  length = 0,
int  rate = default_sample_rate 
)

Definition at line 198 of file EST_Wave.cc.

◆ load() [3/4]

EST_read_status EST_Wave::load ( const EST_String  filename,
const EST_String  filetype,
int  offset = 0,
int  length = 0,
int  rate = default_sample_rate 
)

Definition at line 239 of file EST_Wave.cc.

◆ load() [4/4]

EST_read_status EST_Wave::load ( EST_TokenStream ts,
const EST_String  filetype,
int  offset = 0,
int  length = 0,
int  rate = default_sample_rate 
)

Definition at line 260 of file EST_Wave.cc.

◆ load_file() [1/2]

EST_read_status EST_Wave::load_file ( const EST_String  filename,
const EST_String  filetype,
int  sample_rate,
const EST_String  sample_type,
int  bo,
int  nc,
int  offset = 0,
int  length = 0 
)

Load a file of type filetype into the waveform. This can be used to load unheadered files, in which case the fields sample_rate, sample_type, bo and nc are used to specify the sample rate, type, byte order and number of channels. A portion of the waveform can be loaded by setting offset to the sample position from the beginning and <length> to the number of required samples after this.

Definition at line 288 of file EST_Wave.cc.

◆ load_file() [2/2]

EST_read_status EST_Wave::load_file ( EST_TokenStream ts,
const EST_String  filetype,
int  sample_rate,
const EST_String  sample_type,
int  bo,
int  nc,
int  offset = 0,
int  length = 0 
)

Definition at line 309 of file EST_Wave.cc.

◆ save() [1/2]

EST_write_status EST_Wave::save ( const EST_String  filename,
const EST_String  EST_filetype = "" 
)

Definition at line 352 of file EST_Wave.cc.

◆ save() [2/2]

EST_write_status EST_Wave::save ( FILE *  fp,
const EST_String  EST_filetype = "" 
)

Definition at line 372 of file EST_Wave.cc.

◆ save_file() [1/2]

EST_write_status EST_Wave::save_file ( const EST_String  filename,
EST_String  filetype,
EST_String  sample_type,
int  bo,
const char *  mode = "wb" 
)

Definition at line 395 of file EST_Wave.cc.

◆ save_file() [2/2]

EST_write_status EST_Wave::save_file ( FILE *  fp,
EST_String  filetype,
EST_String  sample_type,
int  bo 
)

Definition at line 416 of file EST_Wave.cc.

◆ save_file_header()

EST_write_status EST_Wave::save_file_header ( FILE *  fp,
EST_String  ftype,
EST_String  stype,
int  obo 
)

Definition at line 465 of file EST_Wave.cc.

◆ save_file_data()

EST_write_status EST_Wave::save_file_data ( FILE *  fp,
EST_String  ftype,
EST_String  stype,
int  obo 
)

Definition at line 440 of file EST_Wave.cc.

◆ operator=()

EST_Wave & EST_Wave::operator= ( const EST_Wave w)

Assignment operator.

Definition at line 612 of file EST_Wave.cc.

◆ operator+=()

EST_Wave & EST_Wave::operator+= ( const EST_Wave a)

Add to existing wave in serial. Waveforms must have the same number of channels.

Definition at line 618 of file EST_Wave.cc.

◆ operator|=()

EST_Wave & EST_Wave::operator|= ( const EST_Wave a)

Add wave in parallel, i.e. make wave a become new channels in existing waveform.

Definition at line 642 of file EST_Wave.cc.

◆ integrity()

void EST_Wave::integrity ( ) const
inline

Definition at line 330 of file EST_Wave.h.

Friends And Related Function Documentation

◆ operator<<

ostream & operator<< ( ostream &  p_values,
const EST_Wave sig 
)
friend

print waveform

Definition at line 662 of file EST_Wave.cc.

Member Data Documentation

◆ p_values

EST_SMatrix EST_Wave::p_values
protected

Definition at line 67 of file EST_Wave.h.

◆ p_sample_rate

int EST_Wave::p_sample_rate
protected

Definition at line 69 of file EST_Wave.h.

◆ default_sample_rate

const int EST_Wave::default_sample_rate =16000
static

Definition at line 78 of file EST_Wave.h.

◆ default_num_channels

const int EST_Wave::default_num_channels
static

Definition at line 79 of file EST_Wave.h.


The documentation for this class was generated from the following files: