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. More...
#include <include/EST_Wave.h>
Public Member Functions | |
EST_Wave () | |
default constructor More... | |
EST_Wave (const EST_Wave &a) | |
copy constructor More... | |
EST_Wave (ssize_t n, ssize_t c, int sr) | |
EST_Wave (ssize_t samps, ssize_t chans, short *memory, int offset=0, int sample_rate=default_sample_rate, int free_when_destroyed=0) | |
Construct from memory supplied by caller. More... | |
~EST_Wave () | |
const EST_SMatrix & | values () const |
EST_SMatrix & | values () |
EST_Wave & | operator= (const EST_Wave &w) |
Assignment operator. More... | |
EST_Wave & | operator+= (const EST_Wave &a) |
EST_Wave & | operator|= (const EST_Wave &a) |
void | integrity () const |
Access functions for finding amplitudes of samples | |
short & | a (ssize_t i, ssize_t channel=0) |
short | a (ssize_t i, ssize_t channel=0) const |
INLINE short & | a_no_check (ssize_t i, ssize_t channel=0) |
INLINE short | a_no_check (ssize_t i, ssize_t channel=0) const |
INLINE short & | a_no_check_1 (ssize_t i, ssize_t channel=0) |
INLINE short | a_no_check_1 (ssize_t i, ssize_t channel=0) const |
INLINE short | set_a (ssize_t i, ssize_t channel=0, short val=0) |
short | operator() (ssize_t i, ssize_t channel) const |
short | operator() (ssize_t i) const |
short & | a_safe (ssize_t i, ssize_t channel=0) |
float | t (ssize_t i) const |
return the time position in seconds of the ith sample More... | |
Information functions | |
ssize_t | num_samples () const |
return the number of samples in the waveform More... | |
ssize_t | 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... | |
ssize_t | 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... | |
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 | 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, ssize_t channel=EST_ALL) |
void | empty (ssize_t channel=EST_ALL) |
void | sample (EST_TVector< short > &sv, ssize_t n) |
void | channel (EST_TVector< short > &cv, ssize_t n) |
void | copy_channel (ssize_t n, short *buf, int offset=0, ssize_t num=EST_ALL) const |
void | copy_sample (ssize_t n, short *buf, int offset=0, ssize_t num=EST_ALL) const |
void | set_channel (ssize_t n, const short *buf, int offset=0, ssize_t num=EST_ALL) |
void | set_sample (ssize_t n, const short *buf, int offset=0, ssize_t num=EST_ALL) |
void | sub_wave (EST_Wave &sw, int offset=0, ssize_t num=EST_ALL, ssize_t start_c=0, ssize_t nchan=EST_ALL) |
void | sub_wave (EST_Wave &sw, int offset=0, ssize_t num=EST_ALL, ssize_t start_c=0, ssize_t nchan=EST_ALL) const |
File i/o functions | |
EST_read_status | load (const EST_String filename, int offset=0, ssize_t length=0, int rate=default_sample_rate) |
EST_read_status | load (EST_TokenStream &ts, int offset=0, ssize_t length=0, int rate=default_sample_rate) |
EST_read_status | load (const EST_String filename, const EST_String filetype, int offset=0, ssize_t length=0, int rate=default_sample_rate) |
EST_read_status | load (EST_TokenStream &ts, const EST_String filetype, int offset=0, ssize_t 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, ssize_t nc, int offset=0, ssize_t length=0) |
EST_read_status | load_file (EST_TokenStream &ts, const EST_String filetype, int sample_rate, const EST_String sample_type, int bo, ssize_t nc, int offset=0, ssize_t 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) |
Public Member Functions inherited from EST_Featured | |
int | f_Int (const char *name, int def) const |
int | f_Int (const char *name) const |
int | f_I (const char *name, int def) const |
int | f_I (const char *name) const |
void | f_set (const EST_String name, int val) |
void | f_set_path (const EST_String name, int val) |
float | f_Float (const char *name, float def) const |
float | f_Float (const char *name) const |
float | f_F (const char *name, float def) const |
float | f_F (const char *name) const |
void | f_set (const EST_String name, float val) |
void | f_set_path (const EST_String name, float val) |
EST_String | f_String (const char *name, const EST_String &def) const |
EST_String | f_String (const char *name) const |
EST_String | f_S (const char *name, const EST_String &def) const |
EST_String | f_S (const char *name) const |
void | f_set (const EST_String name, const char *val) |
void | f_set_path (const EST_String name, const char *val) |
const EST_Val & | f_Val (const char *name, const EST_Val &def) const |
const EST_Val & | f_Val (const char *name) const |
const EST_Val & | f_V (const char *name, const EST_Val &def) const |
const EST_Val & | f_V (const char *name) const |
void | f_set_val (const EST_String name, EST_Val val) |
void | f_set_path (const EST_String name, EST_Val val) |
void | f_set (const EST_Features &f) |
int | f_present (const EST_String name) const |
void | f_remove (const EST_String name) |
Static Public Attributes | |
static const int | default_sample_rate =16000 |
static const ssize_t | default_num_channels |
Protected Member Functions | |
void | default_vals (ssize_t n=0, ssize_t c=1) |
void | free_wave () |
void | copy_data (const EST_Wave &w) |
void | copy_setup (const EST_Wave &w) |
Protected Member Functions inherited from EST_Featured | |
EST_Featured (void) | |
EST_Featured (const EST_Featured &f) | |
~EST_Featured (void) | |
void | init_features () |
void | copy_features (const EST_Featured &f) |
void | clear_features () |
void | ensure_features (void) |
void | point_to_first (IPointer_feat &ip) const |
void | move_pointer_forwards (IPointer_feat &ip) const |
bool | points_to_something (const IPointer_feat &ip) const |
EST_TKVI< EST_String, EST_Val > & | points_at (const IPointer_feat &ip) |
Protected Attributes | |
EST_SMatrix | p_values |
int | p_sample_rate |
Friends | |
ostream & | operator<< (ostream &p_values, const EST_Wave &sig) |
print waveform More... | |
Additional Inherited Members | |
Public Types inherited from EST_Featured | |
typedef EST_TKVI< EST_String, EST_Val > | FeatEntry |
typedef EST_TStructIterator< EST_Featured, IPointer_feat, FeatEntry > | FeatEntries |
typedef EST_TRwStructIterator< EST_Featured, IPointer_feat, FeatEntry > | RwFeatEntries |
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.
EST_Wave::EST_Wave | ( | ) |
default constructor
Definition at line 63 of file EST_Wave.cc.
EST_Wave::EST_Wave | ( | const EST_Wave & | a | ) |
copy constructor
Definition at line 68 of file EST_Wave.cc.
Definition at line 74 of file EST_Wave.cc.
EST_Wave::EST_Wave | ( | ssize_t | samps, |
ssize_t | 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 | ( | ) |
Definition at line 105 of file EST_Wave.cc.
Definition at line 89 of file EST_Wave.cc.
|
protected |
Definition at line 98 of file EST_Wave.cc.
|
protected |
Definition at line 116 of file EST_Wave.cc.
|
protected |
Definition at line 110 of file EST_Wave.cc.
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.
Definition at line 147 of file EST_Wave.cc.
Definition at line 105 of file EST_Wave.h.
Definition at line 107 of file EST_Wave.h.
Definition at line 109 of file EST_Wave.h.
Definition at line 111 of file EST_Wave.h.
explicit set_a, easier to wrap than assignment
Definition at line 117 of file EST_Wave.h.
return amplitude of sample i
from channel channel
. By default the 0th channel is selected.
Definition at line 123 of file EST_Wave.h.
|
inline |
return amplitude of sample i
from channel 0.
Definition at line 128 of file EST_Wave.h.
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.
|
inline |
return the time position in seconds of the ith sample
Definition at line 137 of file EST_Wave.h.
|
inline |
return the number of samples in the waveform
Definition at line 143 of file EST_Wave.h.
|
inline |
return the number of channels in the waveform
Definition at line 145 of file EST_Wave.h.
|
inline |
return the sampling rate (frequency)
Definition at line 147 of file EST_Wave.h.
|
inline |
Set sampling rate to n
Definition at line 149 of file EST_Wave.h.
|
inline |
return the size of the waveform, i.e. the number of samples.
Definition at line 151 of file EST_Wave.h.
|
inline |
return the time position of the last sample.
Definition at line 153 of file EST_Wave.h.
Can we look N samples to the left?
Definition at line 156 of file EST_Wave.h.
|
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.
|
inline |
Definition at line 164 of file EST_Wave.h.
|
inline |
Definition at line 166 of file EST_Wave.h.
|
inline |
Definition at line 167 of file EST_Wave.h.
|
inline |
A string identifying the waveform, commonly used to store the filename.
Definition at line 170 of file EST_Wave.h.
|
inline |
Sets name.
Definition at line 173 of file EST_Wave.h.
|
inline |
Definition at line 177 of file EST_Wave.h.
|
inline |
Definition at line 178 of file EST_Wave.h.
resize the waveform
Definition at line 184 of file EST_Wave.h.
void EST_Wave::resample | ( | int | rate | ) |
Resample waveform to rate
Definition at line 492 of file EST_Wave.cc.
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 506 of file EST_Wave.cc.
void EST_Wave::rescale | ( | const EST_Track & | factor_contour | ) |
Definition at line 553 of file EST_Wave.cc.
|
inline |
clear waveform and set size to 0.
Definition at line 203 of file EST_Wave.h.
void EST_Wave::copy | ( | const EST_Wave & | from | ) |
Definition at line 121 of file EST_Wave.cc.
Definition at line 166 of file EST_Wave.cc.
Definition at line 209 of file EST_Wave.h.
|
inline |
Definition at line 211 of file EST_Wave.h.
|
inline |
Definition at line 213 of file EST_Wave.h.
|
inline |
Definition at line 216 of file EST_Wave.h.
|
inline |
Definition at line 218 of file EST_Wave.h.
|
inline |
Definition at line 221 of file EST_Wave.h.
|
inline |
Definition at line 223 of file EST_Wave.h.
void EST_Wave::sub_wave | ( | EST_Wave & | sw, |
int | offset = 0 , |
||
ssize_t | num = EST_ALL , |
||
ssize_t | start_c = 0 , |
||
ssize_t | nchan = EST_ALL |
||
) |
Definition at line 342 of file EST_Wave.cc.
|
inline |
Definition at line 231 of file EST_Wave.h.
EST_read_status EST_Wave::load | ( | const EST_String | filename, |
int | offset = 0 , |
||
ssize_t | 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.
EST_read_status EST_Wave::load | ( | EST_TokenStream & | ts, |
int | offset = 0 , |
||
ssize_t | length = 0 , |
||
int | rate = default_sample_rate |
||
) |
Definition at line 198 of file EST_Wave.cc.
EST_read_status EST_Wave::load | ( | const EST_String | filename, |
const EST_String | filetype, | ||
int | offset = 0 , |
||
ssize_t | length = 0 , |
||
int | rate = default_sample_rate |
||
) |
Definition at line 242 of file EST_Wave.cc.
EST_read_status EST_Wave::load | ( | EST_TokenStream & | ts, |
const EST_String | filetype, | ||
int | offset = 0 , |
||
ssize_t | length = 0 , |
||
int | rate = default_sample_rate |
||
) |
Definition at line 263 of file EST_Wave.cc.
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, | ||
ssize_t | nc, | ||
int | offset = 0 , |
||
ssize_t | 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 291 of file EST_Wave.cc.
EST_read_status EST_Wave::load_file | ( | EST_TokenStream & | ts, |
const EST_String | filetype, | ||
int | sample_rate, | ||
const EST_String | sample_type, | ||
int | bo, | ||
ssize_t | nc, | ||
int | offset = 0 , |
||
ssize_t | length = 0 |
||
) |
Definition at line 312 of file EST_Wave.cc.
EST_write_status EST_Wave::save | ( | const EST_String | filename, |
const EST_String | EST_filetype = "" |
||
) |
Save waveform to a file called filename
of file format EST_filetype
.
Definition at line 355 of file EST_Wave.cc.
EST_write_status EST_Wave::save | ( | FILE * | fp, |
const EST_String | EST_filetype = "" |
||
) |
Definition at line 375 of file EST_Wave.cc.
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 398 of file EST_Wave.cc.
EST_write_status EST_Wave::save_file | ( | FILE * | fp, |
EST_String | filetype, | ||
EST_String | sample_type, | ||
int | bo | ||
) |
Definition at line 419 of file EST_Wave.cc.
EST_write_status EST_Wave::save_file_header | ( | FILE * | fp, |
EST_String | ftype, | ||
EST_String | stype, | ||
int | obo | ||
) |
Definition at line 468 of file EST_Wave.cc.
EST_write_status EST_Wave::save_file_data | ( | FILE * | fp, |
EST_String | ftype, | ||
EST_String | stype, | ||
int | obo | ||
) |
Definition at line 443 of file EST_Wave.cc.
Assignment operator.
Definition at line 606 of file EST_Wave.cc.
Add to existing wave in serial. Waveforms must have the same number of channels.
Definition at line 612 of file EST_Wave.cc.
Add wave in parallel, i.e. make wave a
become new channels in existing waveform.
Definition at line 636 of file EST_Wave.cc.
|
inline |
Definition at line 325 of file EST_Wave.h.
|
friend |
print waveform
Definition at line 656 of file EST_Wave.cc.
|
protected |
Definition at line 67 of file EST_Wave.h.
|
protected |
Definition at line 69 of file EST_Wave.h.
|
static |
Definition at line 78 of file EST_Wave.h.
|
static |
Definition at line 79 of file EST_Wave.h.