45 #include "EST_Featured.h" 46 #include "EST_rw_status.h" 47 #include "EST_types.h" 71 void default_vals(
int n=0,
int c=1);
78 static const int default_sample_rate;
79 static const int default_num_channels;
90 short *memory,
int offset=0,
int sample_rate=default_sample_rate,
91 int free_when_destroyed=0);
103 short &
a(
int i,
int channel = 0);
104 short a(
int i,
int channel = 0)
const;
105 INLINE
short &a_no_check(
int i,
int channel = 0)
107 INLINE
short a_no_check(
int i,
int channel = 0)
const 109 INLINE
short &a_no_check_1(
int i,
int channel = 0)
110 {
return p_values.a_no_check_1(i,channel); }
111 INLINE
short a_no_check_1(
int i,
int channel = 0)
const 112 {
return p_values.a_no_check_1(i,channel); }
117 INLINE
short set_a(
int i,
int channel = 0,
short val = 0)
118 {
return a(i,channel) = val; }
124 {
return a(i,channel); }
134 short &
a_safe(
int i,
int channel = 0);
137 float t(
int i)
const {
return (
float)i/(float)p_sample_rate; }
157 {
return p_values.have_rows_before(n); }
164 void set_sample_type(
const EST_String t) { f_set(
"sample_type", t); }
166 EST_String file_type()
const {
return f_String(
"file_type",
"riff"); }
167 void set_file_type(
const EST_String t) { f_set(
"file_type", t); }
177 const EST_SMatrix &values()
const {
return p_values; }
194 void rescale(
float gain,
int normalize=0);
207 void fill(
short v=0,
int channel=EST_ALL);
209 void empty(
int channel=EST_ALL) { fill(0,channel); }
212 { p_values.
row(sv, n); }
214 { p_values.
column(cv, n); }
216 void copy_channel(
int n,
short *buf,
int offset=0,
int num=EST_ALL)
const 218 void copy_sample(
int n,
short *buf,
int offset=0,
int num=EST_ALL)
const 219 { p_values.
copy_row(n, buf, offset, num); }
221 void set_channel(
int n,
const short *buf,
int offset=0,
int num=EST_ALL)
223 void set_sample(
int n,
const short *buf,
int offset=0,
int num=EST_ALL)
224 { p_values.
set_row(n, buf, offset, num); }
228 int offset=0,
int num=EST_ALL,
229 int start_c=0,
int nchan=EST_ALL);
232 int offset=0,
int num=EST_ALL,
233 int start_c=0,
int nchan=EST_ALL)
const 234 { ((
EST_Wave *)
this)->sub_wave(sw, offset, num, start_c, nchan); }
250 int rate = default_sample_rate);
255 int rate = default_sample_rate);
261 int rate = default_sample_rate);
267 int rate = default_sample_rate);
281 int offset = 0,
int length = 0);
285 int offset = 0,
int length = 0);
290 EST_write_status save(
const EST_String filename,
293 EST_write_status save(FILE *fp,
296 EST_write_status save_file(
const EST_String filename,
298 EST_String sample_type,
int bo,
const char *mode =
"wb");
300 EST_write_status save_file(FILE *fp,
304 EST_write_status save_file_header(FILE *fp,
307 EST_write_status save_file_data(FILE *fp,
327 void integrity()
const { p_values.integrity() ; }
short operator()(int i, int channel) const
EST_read_status load(const EST_String filename, int offset=0, int length=0, int rate=default_sample_rate)
EST_Wave & operator+=(const EST_Wave &a)
void set_sample_rate(const int n)
Set sampling rate to n
EST_String sample_type() const
void column(EST_TVector< T > &cv, int c, int start_r=0, int len=-1)
Make the vector { cv} a window onto column { c}.
int num_rows() const
return number of rows
void row(EST_TVector< T > &rv, int r, int start_c=0, int len=-1)
Make the vector { rv} a window onto row { r}.
int length() const
return the size of the waveform, i.e. the number of samples.
short operator()(int i) const
void copy_column(int c, T *buf, int offset=0, int num=-1) const
int num_channels() const
return the number of channels in the waveform
int num_columns() const
return number of columns
void set_name(const EST_String n)
Sets name.
void rescale(float gain, int normalize=0)
int sample_rate() const
return the sampling rate (frequency)
INLINE short set_a(int i, int channel=0, short val=0)
EST_Wave()
default constructor
EST_Wave & operator=(const EST_Wave &w)
Assignment operator.
INLINE const T & a_no_check(int row, int col) const
const access with no bounds check, care recommend
float t(int i) const
return the time position in seconds of the ith sample
short & a(int i, int channel=0)
int num_samples() const
return the number of samples in the waveform
friend ostream & operator<<(ostream &p_values, const EST_Wave &sig)
print waveform
float end()
return the time position of the last sample.
void copy_row(int r, T *buf, int offset=0, int num=-1) const
void resize(int num_samples, int num_channels=EST_ALL, int set=1)
resize the waveform
short & a_safe(int i, int channel=0)
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)
void set_row(int n, const T *buf, int offset=0, int num=-1)
void resize(int rows, int cols, int set=1)
resize matrix
EST_Wave & operator|=(const EST_Wave &a)
void clear()
clear waveform and set size to 0.
void resample(int rate)
Resample waveform to rate
bool have_left_context(unsigned int n) const
Can we look N samples to the left?
EST_String name() const
A string identifying the waveform, commonly used to store the filename.
void set_column(int n, const T *buf, int offset=0, int num=-1)