Classes

class EST_Wave{}

class EST_Wave(: public EST_Featured

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.

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

Constructors and Destructors

EST_Wave()

EST_Wave()

default constructor

EST_Wave()

EST_Wave(const EST_Wave &a)

copy constructor

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

~EST_Wave()

~EST_Wave()

Destructor

Access functions for finding ampltiudes of samples

a()

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

operator)()

short operator)(int i, int channel) const

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

operator)()

short operator)(int i) const

return amplitude of sample i from channel 0

a_safe()

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

t()

float t(int i) const

return the time position in seconds of the ith sample

Information functions

num_samples()

int num_samples() const

return the number of samples in the waveform

num_channels()

int num_channels() const

return the number of channels in the waveform

sample_rate()

int sample_rate() const

return the sampling rate (frequency)

set_sample_rate()

void set_sample_rate(const int n)

Set sampling rate to n

length()

int length() const

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

end()

float end()

return the time position of the last sample.

have_left_context()

bool have_left_context(unsigned int n) const

Can we look N samples to the left?

sample_type()

EST_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

name()

EST_String name() const

A string indentifying the waveform, commonly used to store the filename

set_name()

void set_name(const EST_String n)

Sets name.

Waveform manipulation functions

resize()

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

resize the waveform

resample()

void resample(int rate)

Resample waveform to rate

rescale()

void 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.

clear()

void clear()

clear waveform and set size to 0.

File i/o functions

load()

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. 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 to the number of required samples after this.

load_file()

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 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 to the number of required samples after this.

save()

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

Save waveform to a file called filename of file format EST_filetype

save()

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

Save waveform to a already openend file with file pointer *FP

Operators

operator = ()

EST_Wave& operator = (const EST_Wave& w)

Assignment operator

operator +=()

EST_Wave& operator +=(const EST_Wave &a)

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

operator |=()

EST_Wave& operator |=(const EST_Wave &a)

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

operator << ()

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

print waveform

class EST_Track{}

class EST_Track(: public EST_Featured

A class for storing time aligned coefficients.

some stuff.

Constructor and Destructor functions

EST_Track()

EST_Track()

Default constructor

EST_Track()

EST_Track(const EST_Track &a)

Copy constructor

EST_Track()

EST_Track(int num_frames, int num_channels)

resizing constructor

EST_Track()

EST_Track(int num_frames, EST_StrList &map)

resizing constructor

~EST_Track()

~EST_Track()

default destructor

Configuring Tracks

resize()

void resize(int num_frames, int num_channels, bool preserve = 1)

resize the track to have {\tt num_frames} and {\tt num_channels}. if {\tt preserve} is set to 1, any existing values in the track are kept, up to the limits imposed by the new number of frames and channels. If the new track size is bigger, new positions are filled with 0

resize()

void resize(int num_frames, EST_StrList &map, bool preserve = 1)

resize the track to have {\tt num_frames} and {\tt num_channels}. if {\tt preserve} is set to 1, any existing values in the track are kept, up to the limits imposed by the new number of frames and channels. If the new track size is bigger, new positions are filled with 0

resize_aux()

void resize_aux(EST_StrList &map, bool preserve = 1)

resize the track's auxiliary channels

set_num_channels()

void set_num_channels(int n, bool preserve = 1)

Change the number of channels while keeping the number of frames the same. if {\tt preserve} is set to 1, any existing values in the track are kept, up to the limits imposed by the new number of frames and channels. If the new track size is bigger, new positions are filled with 0

set_num_frames()

void set_num_frames(int n, bool preserve = 1)

Change the number of frames while keeping the number of channels the same. if {\tt preserve} is set to 1, any existing values in the track are kept, up to the limits imposed by the new number of frames and channels. If the new track size is bigger, new positions are filled with 0

set_channel_name()

void set_channel_name(const EST_String &name, int channel)

set the name of the channel.

set_aux_channel_name()

void set_aux_channel_name(const EST_String &name, int channel)

set the name of the auxiliary channel.

copy_setup()

void copy_setup(const EST_Track& a)

copy everything but data

Global track information

name()

EST_String name() const

name of track - redundant use access to features

set_name()

void set_name(const EST_String &n)

set name of track - redundant use access to features

Functions for sub tracks, channels and frames.

frame()

void frame(EST_FVector &fv, int n, int startf=0, int nf=EST_ALL)

make {\tt fv} a window to frame {\tt n} in the track

channel()

void channel(EST_FVector &cv, int n, int startf=0, int nf=EST_ALL)

make {\tt fv} a window to channel {\tt n} in the track

channel()

void channel(EST_FVector &cv, const char * name, int startf=0, int nf=EST_ALL)

make {\tt fv} a window to the named channel in the track

sub_track()

void sub_track(EST_Track &st, int start_frame=0, int nframes=EST_ALL, int start_chan=0, int nchans=EST_ALL)

make {\tt st} refer to a portion of the track. No values are copied - an internal pointer in st is set to the specified portion of the the track. After this, st behaves like a normal track. Its first channel is the same as start_channel and its first frame is the same as start_frame. Any values written into st will changes values in the main track. st cannot be resized.

Parameters
start_frame

first frame at which sub-track starts

nframes

number of frames to be included in total

start_channel

first channel at which sub-track starts

nframes

number of channels to be included in total

sub_track()

void sub_track(EST_Track &st, int start_frame, int nframes, const EST_String &start_chan_name, int nchans=EST_ALL)

make {\tt st} refer to a portion of the track. No values are copied - an internal pointer in st is set to the specified portion of the the track. After this, st behaves like a normal track. Its first channel is the same as start_channel and its first frame is the same as start_frame. Any values written into st will changes values in the main track. st cannot be resized.

Parameters
start_frame

first frame at which sub-track starts

nframes

number of frames to be included in total

start_channel_name

name of channel at which sub-track starts

end_channel_name

name of channel at which sub-track stops

sub_track()

void sub_track(EST_Track &st, int start_frame, int nframes, const EST_String &start_chan_name, const EST_String &end_chan_name)

make {\tt st} refer to a portion of the track. No values are copied - an internal pointer in st is set to the specified portion of the the track. After this, st behaves like a normal track. Its first channel is the same as start_channel and its first frame is the same as start_frame. Any values written into st will changes values in the main track. st cannot be resized.

Parameters
start_frame

first frame at which sub-track starts

nframes

number of frames to be included in total

start_channel_name

name of channel at which sub-track starts

end_channel_name

name of channel at which sub-track stops

sub_track()

void sub_track(EST_Track &st, int start_frame=0, int nframes=EST_ALL, int start_chan=0, int nchans=EST_ALL) const

make {\tt st} refer to a portion of the track. (const version) No values are copied - an internal pointer in st is set to the specified portion of the the track. After this, st behaves like a normal track. Its first channel is the same as start_channel and its first frame is the same as start_frame. Any values written into st will changes values in the main track. st cannot be resized.

Parameters
start_frame

first frame at which sub-track starts

nframes

number of frames to be included in total

start_channel

first channel at which sub-track starts

nframes

number of channels to be included in total

copy_sub_track()

void copy_sub_track(EST_Track &st, int start_frame=0, int nframes=EST_ALL, int start_chan=0, int nchans=EST_ALL) const

Copy contiguous portion of track into {\tt st}. Unilike the normal sub_track functions, this makes a completely new track. values written into this will not affect the main track and it can be resized.

Parameters
start_frame

first frame at which sub-track starts

nframes

number of frames to be included in total

start_channel

first channel at which sub-track starts

nframes

number of channels to be included in total

copy_channel_out()

void copy_channel_out(int n, float *buf, int offset=0, int num=EST_ALL) const

copy channel {\tt n} into pre-allocated buffer buf

copy_frame_out()

void copy_frame_out(int n, float *buf, int offset=0, int num=EST_ALL) const

copy frame {\tt n} into pre-allocated buffer buf

copy_channel_in()

void copy_channel_in(int n, const float *buf, int offset=0, int num=EST_ALL)

copy buf into pre-allocated channel n of track

copy_channel_in()

void copy_channel_in(int c, const EST_Track &from, int from_c, int from_offset=0, int offset=0, int num=EST_ALL)

copy channel buf into pre-allocated channel n of track

copy_frame_in()

void copy_frame_in(int n, const float *buf, int offset=0, int num=EST_ALL)

copy buf into frame n of track

copy_frame_in()

void copy_frame_in(int n, const EST_FVector &t, int offset=0, int num=EST_ALL)

copy t into frame n of track

copy_frame_in()

void copy_frame_in(int i, const EST_Track &from, int from_f, int from_offset=0, int offset=0, int num=EST_ALL)

copy from into frame n of track

Channel information

channel_position()

int channel_position(const char *name, int offset=0) const

Return the position of channel {\tt name} if it exists, otherwise return -1

channel_position()

int channel_position(EST_String name, int offset=0) const

Return the position of channel {\tt name} if it exists, otherwise return -1

has_channel()

bool has_channel(const char *name) const

Returns true if the track has a channel named {\tt name}, otherwise false

has_channel()

bool has_channel(EST_String name) const

Returns true if the track has a channel named {\tt name}, otherwise false

Accessing amplitudes The following functions can be used

to access to amplitude of the track at certain points. Most of these functions can be used for reading or writing to this point, thus

tr.a(10, 5) = 10.3;

can be used to set the 10th frame of the 5th channel and

cout << tr.a(10, 5);

can be used to print the same information. Most of these functions have a const equivalent for helping the compiler in read only operations.

a()

float& a(int i, int c=0)

return amplitude of frame i, channel c

a_no_check()

float& a_no_check(int i, int c=0)

return amplitude of frame i, channel c with no bounds checking

a()

float& a(int i, const char *name, int offset=0)

return amplitude of point i, in the channel named name plus offset. If you have a track with say channels called F0 and voicing, you can access the 45th frame's F0 as t.a(45, "F0"); If there are 20 cepstral coefficients for each frame, the 5th can be accessed as t.a(45, "cepstrum", 5);

a()

float& a(float t, int c=0, EST_InterpType interp=it_nearest)

return amplitude of time t, channel c. This can be used for reading or writing to this point. By default the nearest frame to this time is used. If {\tt interp} is set to {\tt it_linear}, linear interpolaion is performed between the two amplitudes of the two frames either side of the time point to give an estimation of what the amplitude would have been at time {\tt t}. If {\tt interp} is set to {\tt it_linear_nz}, interpolation is as above, unless the time requested is off the end of a portion of track in which case the nearest amplitude is returned.

operator) ()

float& operator) (int i, int c)

return amplitude of frame i, channel c

operator) ()

float& operator) (int i)

return amplitude of frame i, channel 0

operator) ()

float& operator) (float t, int c)

return amplitude of frame nearest time t, channel c

operator) ()

float& operator) (float t)

return amplitude of frame nearest time t, channel 0

Timing

t()

float& t(int i=0)

return time position of frame i

ms_t()

float ms_t(int i) const

return time of framet i in milli-seconds.

fill_time()

void fill_time(float t, int start =1)

set frame times to regular intervals of time {\tt t}

fill_time()

void fill_time(EST_Track &t)

fill times with times of other track

fill()

void fill(float v)

fill all amplitudes with value {\tt v}

sample()

void sample(float shift)

resample track at this frame shift, specified in seconds. This can be used to change a variable frame spaced track into a fixed frame track, or to change the spacing of an existing evenly spaced track.

change_type()

void change_type(float nshift, bool single_break)

REDO

shift()

float shift() const

return an estimation of the frame spacing in seconds. This returns -1 if the track is not a fixed shift track

start()

float start() const

return time of first value in track

end()

float end() const

return time of last value in track

Auxiliary channels

Auxiliary information is used to store information that goes along with frames, but which are not amplitudes and hence not appropriate for operations such as interpolation, smoothing etc. The aux() array is an array of EST_Vals which allows points to be int, float or a string.

The following functions can be used to access to auxiliary track information. Most of these functions can be used for reading or writing to this point, thus

tr.aux(10, "voicing") = 1;

can be used to set the 10th frame of the "voicing" channel and

cout << tr.a(10, "voicing");

can be used to print the same information. Most of these functions have a const equivalent for helping the compiler in read only operations.

Auxiliary channels are usually accessed by name rather than numerical index. The names are set using the set_aux_channel_names() function.

File i/o functions

load()

EST_read_status load(const EST_String name, float ishift = 0.0)

Load a file called {\tt name} into the track. The load function attempts to automatically determine which file type is being loaded from the file's header. If no header is found, the function assumes the file is ascii data, with a fixed frame shift, arranged with rows representing frames and columns channels. In this case, the frame shift must be specified as an argument to this function

load()

EST_read_status load(EST_TokenStream &ts, float ishift = 0.0)

Load character data from an already opened tokenstream {\tt ts} into the track. The load function attempts to automatically determine which file type is being loaded from the file's header. If no header is found, the function assumes the file is ascii data, with a fixed frame shift, arranged with rows representing frames and columns channels. In this case, the frame shift must be specified as an argument to this function

load()

EST_read_status load(const EST_String name, const EST_String type, float ishift = 0.0)

Load a file called {\tt name} of format {\tt type} into the track. If no header is found, the function assumes the file is ascii data, with a fixed frame shift, arranged with rows representing frames and columns channels. In this case, the frame shift must be specified as an argument to this function

save()

EST_write_status save(const EST_String name, const EST_String EST_filetype = "")

Save the track to a file {\tt name} of format {\tt type}

save()

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

Save the track to a already opened file pointer{\tt FP} and write a file of format {\tt type}

Utility functions

empty()

int empty() const

returns true if no values are set in the frame

set_break()

void set_break(int i)

set frame i to be a break

set_value()

void set_value(int i)

set frame i to be a value

val()

int val(int i) const

return true if frame i is a value

track_break()

int track_break(int i) const

return true if frame i is a break

prev_non_break()

int prev_non_break(int i) const

starting at frame i, return the frame index of the first value frame before i. If frame i is a value, return i

next_non_break()

int next_non_break(int i) const

starting at frame i, return the frame index of the first value frame after i. If frame i is a value, return i

index()

int index(float t) const

return the frame index nearest time t

index_below()

int index_below(float x) const

return the frame index before time t

num_frames()

int num_frames() const

return number of frames in track

length()

int length() const

return number of frames in track

num_channels()

int num_channels() const

return number of channels in track

num_aux_channels()

int num_aux_channels() const

return number of auxiliary channels in track

rm_excess_breaks()

void rm_excess_breaks()

If the contour has multiple break values between sections containing values, reduce the break sections so that each has a single break only

equal_space()

bool equal_space() const

return true if track has equal (i.e. fixed) frame spacing */

single_break()

bool single_break() const

return true if track has only single breaks between value sections