56 #pragma warning (disable: 4996) 63 #include "fe_warp_affine.h" 73 static float params[N_PARAM] = { 1.0f, 0.0f };
74 static int32 is_neutral = YES;
75 static char p_str[256] =
"";
76 static float nyquist_frequency = 0.0f;
82 return "affine :== < w' = a * x + b >";
88 return FE_WARP_ID_AFFINE;
92 fe_warp_affine_n_param()
98 fe_warp_affine_set_parameters(
char const *param_str,
float sampling_rate)
102 char temp_param_str[256];
105 nyquist_frequency = sampling_rate / 2;
106 if (param_str == NULL) {
111 if (strcmp(param_str, p_str) == 0) {
115 strcpy(temp_param_str, param_str);
116 memset(params, 0, N_PARAM *
sizeof(
float));
117 strcpy(p_str, param_str);
119 tok = strtok(temp_param_str, seps);
120 while (tok != NULL) {
121 params[param_index++] = (float)
atof_c(tok);
122 tok = strtok(NULL, seps);
123 if (param_index >= N_PARAM) {
129 (
"Affine warping takes up to two arguments, %s ignored.\n",
132 if (params[0] == 0) {
135 (
"Affine warping cannot have slope zero, warping not applied.\n");
140 fe_warp_affine_warped_to_unwarped(
float nonlinear)
147 float temp = nonlinear - params[1];
149 if (temp > nyquist_frequency) {
151 (
"Warp factor %g results in frequency (%.1f) higher than Nyquist (%.1f)\n",
152 params[0], temp, nyquist_frequency);
159 fe_warp_affine_unwarped_to_warped(
float linear)
166 float temp = linear * params[0];
173 fe_warp_affine_print(
const char *label)
177 for (i = 0; i < N_PARAM; i++) {
178 printf(
"%s[%04u]: %6.3f ", label, i, params[i]);
Miscellaneous useful string functions.
#define E_INFO(...)
Print logging information to standard error stream.
SPHINXBASE_EXPORT double atof_c(char const *str)
Locale independent version of atof().
Implementation of logging routines.
#define E_WARN(...)
Print warning message to error log.