EST_Wave.cc (speech_tools-2.4-release) | : | EST_Wave.cc (speech_tools-2.5.0-release) | ||
---|---|---|---|---|
skipping to change at line 56 | skipping to change at line 56 | |||
#include "EST_Wave.h" | #include "EST_Wave.h" | |||
#include "EST_wave_utils.h" | #include "EST_wave_utils.h" | |||
#include "EST_wave_aux.h" | #include "EST_wave_aux.h" | |||
#include "EST_TNamedEnum.h" | #include "EST_TNamedEnum.h" | |||
#include "EST_WaveFile.h" | #include "EST_WaveFile.h" | |||
#include "EST_Track.h" | #include "EST_Track.h" | |||
#include "waveP.h" | #include "waveP.h" | |||
#define sgn(x) (x>0?1:x?-1:0) | ||||
const EST_String DEF_FILE_TYPE = "riff"; | const EST_String DEF_FILE_TYPE = "riff"; | |||
const EST_String DEF_SAMPLE_TYPE = "short"; | const EST_String DEF_SAMPLE_TYPE = "short"; | |||
const int EST_Wave::default_sample_rate=16000; | const int EST_Wave::default_sample_rate=16000; | |||
EST_Wave::EST_Wave() | EST_Wave::EST_Wave() | |||
{ | { | |||
default_vals(); | default_vals(); | |||
} | } | |||
skipping to change at line 453 | skipping to change at line 455 | |||
{ | { | |||
if (p_values.rateconv(p_sample_rate, new_freq) != 0) | if (p_values.rateconv(p_sample_rate, new_freq) != 0) | |||
cerr << "rateconv: failed to convert from " << p_sample_rate << | cerr << "rateconv: failed to convert from " << p_sample_rate << | |||
" to " << new_freq << "\n"; | " to " << new_freq << "\n"; | |||
else | else | |||
set_sample_rate(new_freq); | set_sample_rate(new_freq); | |||
} | } | |||
} | } | |||
void EST_Wave::compress(float mu, float lim) | ||||
{ | ||||
int x; | ||||
for (int i = 0; i < num_samples(); ++i) | ||||
{ | ||||
for (int j = 0; j< num_channels(); ++j) | ||||
{ | ||||
x = a_no_check(i,j); | ||||
a_no_check(i,j) = lim * (sgn(x)*(log(1+(mu/lim)*abs(x))/log(1+mu))); | ||||
} | ||||
} | ||||
} | ||||
void EST_Wave::rescale(float gain, int normalize) | void EST_Wave::rescale(float gain, int normalize) | |||
{ | { | |||
int ns; | int ns; | |||
float factor = gain; | float factor = gain; | |||
float nsf; | float nsf; | |||
if (normalize) | if (normalize) | |||
{ | { | |||
int max = 0; | int max = 0; | |||
for (int i = 0; i < num_samples(); ++i) | for (int i = 0; i < num_samples(); ++i) | |||
End of changes. 2 change blocks. | ||||
0 lines changed or deleted | 16 lines changed or added |