/*---------------------------------------------------------------------------*\
FILE........: dump.c
AUTHOR......: David Rowe
DATE CREATED: 25/8/09
Routines to dump data to text files for Octave analysis.
\*---------------------------------------------------------------------------*/
/*
All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 2.1, as
published by the Free Software Foundation. This program is
distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, see .
*/
#include "defines.h"
#include "comp.h"
#include "dump.h"
#include
#include
#include
#include
#include
#ifdef DUMP
static int dumpon = 0;
static FILE *fsn = NULL;
static FILE *fsw = NULL;
static FILE *few = NULL;
static FILE *fsw_ = NULL;
static FILE *fmodel = NULL;
static FILE *fqmodel = NULL;
static FILE *fpw = NULL;
static FILE *flsp = NULL;
static FILE *fphase = NULL;
static FILE *fphase_ = NULL;
static FILE *ffw = NULL;
static FILE *fe = NULL;
static FILE *fsq = NULL;
static FILE *fdec = NULL;
static FILE *fsnr = NULL;
static FILE *fak = NULL;
static FILE *fbg = NULL;
static FILE *fE = NULL;
static FILE *frk = NULL;
static FILE *fres = NULL;
static char prefix[MAX_STR];
void dump_on(char p[]) {
dumpon = 1;
strcpy(prefix, p);
}
void dump_off(){
if (fsn != NULL)
fclose(fsn);
if (fsw != NULL)
fclose(fsw);
if (fsw_ != NULL)
fclose(fsw_);
if (few != NULL)
fclose(few);
if (fmodel != NULL)
fclose(fmodel);
if (fqmodel != NULL)
fclose(fqmodel);
if (fpw != NULL)
fclose(fpw);
if (flsp != NULL)
fclose(flsp);
if (fphase != NULL)
fclose(fphase);
if (fphase_ != NULL)
fclose(fphase_);
if (ffw != NULL)
fclose(ffw);
if (fe != NULL)
fclose(fe);
if (fsq != NULL)
fclose(fsq);
if (fdec != NULL)
fclose(fdec);
if (fsnr != NULL)
fclose(fsnr);
if (fak != NULL)
fclose(fak);
if (fbg != NULL)
fclose(fbg);
if (fE != NULL)
fclose(fE);
if (frk != NULL)
fclose(frk);
if (fres != NULL)
fclose(fres);
}
void dump_Sn(float Sn[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fsn == NULL) {
sprintf(s,"%s_sn.txt", prefix);
fsn = fopen(s, "wt");
assert(fsn != NULL);
}
/* split across two lines to avoid max line length problems */
/* reconstruct in Octave */
for(i=0; iWo, model->L);
for(l=1; l<=model->L; l++)
fprintf(fmodel,"%f\t",model->A[l]);
for(l=model->L+1; lvoiced);
fprintf(fmodel,"\n");
}
void dump_quantised_model(MODEL *model) {
int l;
char s[MAX_STR];
if (!dumpon) return;
if (fqmodel == NULL) {
sprintf(s,"%s_qmodel.txt", prefix);
fqmodel = fopen(s, "wt");
assert(fqmodel != NULL);
}
fprintf(fqmodel,"%f\t%d\t", model->Wo, model->L);
for(l=1; l<=model->L; l++)
fprintf(fqmodel,"%f\t",model->A[l]);
for(l=model->L+1; l