56 int *v,
float fsize,
float rate,
int num_points)
64 if ((fd=fopen(filename,
"wb")) ==
NULL)
66 fprintf(stderr,
"ESPS file: cannot open file \"%s\" for writing\n",
73 if (
streq(style,
"F0"))
80 add_fea_d(hdr,
"record_freq",0,(
double)rate);
81 add_fea_d(hdr,
"frame_duration",0,(
double)fsize);
84 "EDST F0 written as ESPS FEA_SD.\n");
87 for (i = 0; i < num_points; i++)
101 add_fea_d(hdr,
"window_duration",0,(
double)0.049);
102 add_fea_d(hdr,
"frame_duration",0,(
double)fsize);
103 add_fea_d(hdr,
"record_freq",0,(
double)rate);
106 "EDST Track written as ESPS FEA_SD.\n");
109 for (i = 0; i < num_points; i++)
126 float **a,
float fsize,
float rate,
127 int order,
int num_points,
short fixed)
134 if ((fd = fopen(filename,
"wb")) ==
NULL)
136 fprintf(stderr,
"ESPS file: cannot open file \"%s\" for writing\n",
143 for (i = 0; i < order; ++i)
146 if (!
streq(f_names[0],
"F0"))
148 add_fea_s(hdr,
"lpccep_order",0,(
short)order);
150 add_fea_d(hdr,
"window_duration",0,(
double)0.049);
152 add_fea_f(hdr,
"warping_param",0,(
float)0.0);
155 add_fea_d(hdr,
"record_freq",0,(
double)rate);
156 add_fea_d(hdr,
"frame_duration",0,(
double)fsize);
157 add_fea_d(hdr,
"start_time",0,(
double)0.0);
159 add_fea_s(hdr,
"est_variable_frame", 0, (
short)1);
164 for (i = 0; i < num_points; ++i)
166 for (j = 0; j < order; ++j)
180 float **t,
float **a,
int **v,
float *fsize,
int *num_points)
185 int ff0, fprob_voice, i;
192 if ((fd = fopen(filename,
"rb")) ==
NULL)
194 fprintf(stderr,
"Can't open esps file %s for reading\n", filename);
204 ta =
walloc(
float,hdr->num_records);
205 tv =
walloc(
int,hdr->num_records);
207 for (ff0=fprob_voice=-1,i=0; i < hdr->num_fields; i++)
208 if (
streq(
"F0",hdr->field_name[i]))
210 else if (
streq(
"prob_voice",hdr->field_name[i]))
214 for (i=0; i < hdr->num_records; i++)
218 fprintf(stderr,
"ESPS file: unexpected end of file when reading record %d\n", i);
230 switch(rec->field[0]->type)
237 fprintf(stderr,
"ESPS file: doesn't seem to be F0 file\n");
246 if (fprob_voice == -1)
249 tv[i] = ((
get_field_d(rec,fprob_voice,0) < 0.5) ? 0 : 1);
252 *num_points = hdr->num_records;
262 strcpy(style,
"track");
273 float ***a,
float *fsize,
274 int *num_points,
int *num_fields,
280 int i, j, order, num_recs, jj;
286 if ((fd = fopen(filename,
"rb")) ==
NULL)
298 num_recs = hdr->num_records;
299 order = hdr->num_fields;
301 ta =
walloc(
float *,num_recs);
302 tf =
walloc(
char *,order);
303 for (j = 0; j < num_recs; ++j)
304 ta[j] =
walloc(
float,order);
311 *fixed =
fea_value_s(
"est_variable_frame", 0, hdr, &v) != 0;
314 for (j = 0; j < hdr->num_records; j++)
318 fprintf(stderr,
"ESPS file: unexpected end of file when reading record %d\n", j);
323 for (jj = 0; jj < num_recs; ++jj)
330 for (i = 0; i < order; ++i)
331 switch (rec->field[i]->type)
346 fprintf(stderr,
"ESPS file: unsupported type in record %d\n",
347 rec->field[i]->type);
357 for (j = 0; j < order; ++j)
358 tf[j] =
wstrdup(hdr->field_name[j]);
362 *num_points = num_recs;
esps_rec new_esps_rec(const esps_hdr hdr)
char * wstrdup(const char *s)
enum EST_write_status put_track_esps(const char *filename, char **f_names, float **a, float fsize, float rate, int order, int num_points, short fixed)
#define walloc(TYPE, SIZE)
float get_field_f(esps_rec r, int field, int pos)
double get_field_d(esps_rec r, int field, int pos)
void add_fea_d(esps_hdr hdr, const char *name, int pos, double d)
int read_esps_rec(esps_rec r, esps_hdr hdr, FILE *fd)
void add_fea_i(esps_hdr hdr, const char *name, int pos, int d)
esps_hdr make_esps_hdr(void)
void add_fea_f(esps_hdr hdr, const char *name, int pos, float d)
enum EST_read_status get_track_esps(const char *filename, char ***fields, float ***a, float *fsize, int *num_points, int *num_fields, short *fixed)
enum EST_read_status read_esps_hdr(esps_hdr *uhdr, FILE *fd)
int get_field_i(esps_rec r, int field, int pos)
The file was written successfully.
void set_field_d(esps_rec r, int field, int pos, double d)
void delete_esps_rec(esps_rec r)
enum EST_write_status write_esps_hdr(esps_hdr hdr, FILE *fd)
short get_field_s(esps_rec r, int field, int pos)
enum EST_write_status put_esps(const char *filename, const char *style, float *t, float *a, int *v, float fsize, float rate, int num_points)
enum EST_read_status get_esps(const char *filename, char *style, float **t, float **a, int **v, float *fsize, int *num_points)
int fea_value_s(const char *name, int pos, esps_hdr hdr, short *d)
char get_field_c(esps_rec r, int field, int pos)
void add_fea_special(esps_hdr hdr, int type, const char *name)
int fea_value_d(const char *name, int pos, esps_hdr hdr, double *d)
void delete_esps_hdr(esps_hdr h)
void add_field(esps_hdr hdr, const char *name, int type, int dimension)
void add_fea_s(esps_hdr hdr, const char *name, int pos, short d)
int write_esps_rec(esps_rec r, esps_hdr h, FILE *fd)