In file ../include/EST_Wave.h:

class EST_Wave

A class for storing digital waveforms.

Inheritance:


Public Methods

[more] EST_Wave ()
default constructor
[more] EST_Wave (const EST_Wave &a)
copy constructor
[more] 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 ampltiudes of samples

[more]short& a (int i, int channel = 0)
return amplitude of sample <tt>i</tt> from channel <tt> channel</tt>.
[more]short operator() (int i, int channel) const
return amplitude of sample <tt>i</tt> from channel <tt> channel</tt>.
[more]short operator() (int i) const
return amplitude of sample <tt>i</tt> from channel 0.
[more]short& a_safe (int i, int channel = 0)
Version of a() that returns zero if index is out of array bounds.
[more]float t (int i) const
return the time position in seconds of the ith sample

[more] Information functions

[more]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 <tt>n</tt>
[more]int length () const
return the size of the waveform, ie.
[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
returns the file format of the file from which the waveform was read.
[more]EST_String name () const
A string indentifying the waveform, commonly used to store the filename
[more]void set_name (const EST_String n)
Sets name

[more] Waveform manipulation functions

[more]void resize (int num_samples, int num_channels = EST_ALL, int set=1)
resize the waveform
[more]void resample (int rate)
Resample waveform to <tt>rate</tt>
[more]void rescale (float gain, int normalize=0)
multiply all samples by a factor <tt>gain</tt>.
[more]void clear ()
clear waveform and set size to 0

[more] File i/o functions

[more]EST_read_status load (const EST_String filename, int offset=0, int length = 0, int rate = default_sample_rate)
Load a file into the waveform.
[more]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)
Load a file of type <tt>filetype</tt> into the waveform.

[more]EST_Wave& operator = (const EST_Wave& w)
Assignment operator
[more]EST_Wave& operator += (const EST_Wave &a)
Add to existing wave in serial.
[more]EST_Wave& operator |= (const EST_Wave &a)
Add wave in parallel, ie.
[more]void integrity () const


Inherited from EST_Featured:


Documentation

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

The waveforms can be of any sample rate, and can be changed to another samping rate using the <tt>resample</tt> function.

o EST_Wave()
default constructor

o EST_Wave(const EST_Wave &a)
copy constructor

o 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

o Access functions for finding ampltiudes of samples

oshort& a(int i, int channel = 0)
return amplitude of sample <tt>i</tt> from channel <tt> channel</tt>. By default the 0th channel is selected. This function can be used for assignment.

oshort operator()(int i, int channel) const
return amplitude of sample <tt>i</tt> from channel <tt> channel</tt>. By default the 0th channel is selected.

oshort operator()(int i) const
return amplitude of sample <tt>i</tt> from channel 0.

oshort& 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.

ofloat t(int i) const
return the time position in seconds of the ith sample

o Information functions

oint num_samples() const
return the number of samples in the waveform

oint num_channels() const
return the number of channels in the waveform

oint sample_rate() const
return the sampling rate (frequency)

ovoid set_sample_rate(const int n)
Set sampling rate to <tt>n</tt>

oint length() const
return the size of the waveform, ie. the number of samples.

ofloat end()
return the time position of the last sample

obool have_left_context(unsigned int n) const
Can we look N samples to the left?

oEST_String sample_type() const
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

oEST_String name() const
A string indentifying the waveform, commonly used to store the filename

ovoid set_name(const EST_String n)
Sets name

o Waveform manipulation functions

ovoid resize(int num_samples, int num_channels = EST_ALL, int set=1)
resize the waveform

ovoid resample(int rate)
Resample waveform to <tt>rate</tt>

ovoid rescale(float gain, int normalize=0)
multiply all samples by a factor <tt>gain</tt>. This checks for overflows and puts them to the maximum positive or negative value as appropriate.

ovoid clear()
clear waveform and set size to 0

o File i/o functions

oEST_read_status 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 <tt> offset</tt> to the sample position from the beginning and <length> to the number of required samples after this.

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

oEST_Wave& operator = (const EST_Wave& w)
Assignment operator

oEST_Wave& operator +=(const EST_Wave &a)
Add to existing wave in serial. Waveforms must have the same number of channels.

oEST_Wave& operator |=(const EST_Wave &a)
Add wave in parallel, ie. make wave <tt>a</tt> become new channels in existing waveform.

ovoid integrity() const


Direct child classes:
EST_SingleChannelWave
Friends:
ostream& operator << (ostream& p_values, const EST_Wave &sig)

Alphabetic index HTML hierarchy of classes or Java


This page is part of the Edinburgh Speech Tools Library documentation
Copyright University of Edinburgh 1997
Contact: speech_tools@cstr.ed.ac.uk