In file ../include/EST_Wave.h:

## class EST_Wave

> A class for storing digital waveforms.

## Inheritance:

### Public Methods

  | EST_Wave () default constructor
  | EST_Wave (const EST_Wave &a) copy constructor
  | 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
  | Access functions for finding ampltiudes of samples
  short& | a (int i, int channel = 0) return amplitude of sample <tt>i</tt> from channel <tt> channel</tt>.
  short | operator() (int i, int channel) const return amplitude of sample <tt>i</tt> from channel <tt> channel</tt>.
  short | operator() (int i) const return amplitude of sample <tt>i</tt> from channel 0.
  short& | a_safe (int i, int channel = 0) Version of a() that returns zero if index is out of array bounds.
  float | t (int i) const return the time position in seconds of the ith sample
  | Information functions
  int | num_samples () const return the number of samples in the waveform
  int | num_channels () const return the number of channels in the waveform
  int | sample_rate () const return the sampling rate (frequency)
  void | set_sample_rate (const int n) Set sampling rate to <tt>n</tt>
  int | length () const return the size of the waveform, ie.
  float | end () return the time position of the last sample
  bool | have_left_context (unsigned int n) const Can we look N samples to the left?
  EST_String | sample_type () const returns the file format of the file from which the waveform was read.
  EST_String | name () const A string indentifying the waveform, commonly used to store the filename
  void | set_name (const EST_String n) Sets name
  | Waveform manipulation functions
  void | resize (int num_samples, int num_channels = EST_ALL, int set=1) resize the waveform
  void | resample (int rate) Resample waveform to <tt>rate</tt>
  void | rescale (float gain, int normalize=0) multiply all samples by a factor <tt>gain</tt>.
  void | clear () clear waveform and set size to 0
  | File i/o functions
  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.
  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.
  EST_Wave& | operator = (const EST_Wave& w) Assignment operator
  EST_Wave& | operator += (const EST_Wave &a) Add to existing wave in serial.
  EST_Wave& | operator |= (const EST_Wave &a) Add wave in parallel, ie.
  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.

`EST_Wave()`
  default constructor

`EST_Wave(const EST_Wave &a)`
  copy constructor

`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

`Access functions for finding ampltiudes of samples`

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

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

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

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

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

`Information functions`

`int num_samples() const`
  return the number of samples in the waveform

`int num_channels() const`
  return the number of channels in the waveform

`int sample_rate() const`
  return the sampling rate (frequency)

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

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

`float end()`
  return the time position of the last sample

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

`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

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

`void set_name(const EST_String n)`
  Sets name

`Waveform manipulation functions`

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

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

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

`void clear()`
  clear waveform and set size to 0

`File i/o functions`

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

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

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

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

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

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