mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 05:02:10 +00:00
i've tested, now you can too
This commit is contained in:
+189
-4
@@ -1,7 +1,7 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
|
||||
FILE........: dump.c
|
||||
AUTHOR......: David Rowe
|
||||
AUTHOR......: David Rowe
|
||||
DATE CREATED: 25/8/09
|
||||
|
||||
Routines to dump data to text files for Octave analysis.
|
||||
@@ -20,11 +20,11 @@
|
||||
License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "defines.h"
|
||||
#include "comp.h"
|
||||
#include "dump.h"
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
@@ -32,15 +32,21 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#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 *fpwb = NULL;
|
||||
static FILE *fpw = NULL;
|
||||
static FILE *frw = NULL;
|
||||
static FILE *flsp = NULL;
|
||||
static FILE *fweights = NULL;
|
||||
static FILE *flsp_ = NULL;
|
||||
static FILE *fphase = NULL;
|
||||
static FILE *fphase_ = NULL;
|
||||
static FILE *ffw = NULL;
|
||||
@@ -48,9 +54,13 @@ static FILE *fe = NULL;
|
||||
static FILE *fsq = NULL;
|
||||
static FILE *fdec = NULL;
|
||||
static FILE *fsnr = NULL;
|
||||
static FILE *flpcsnr = NULL;
|
||||
static FILE *fak = NULL;
|
||||
static FILE *fak_ = NULL;
|
||||
static FILE *fbg = NULL;
|
||||
static FILE *fE = NULL;
|
||||
static FILE *frk = NULL;
|
||||
static FILE *fhephase = NULL;
|
||||
|
||||
static char prefix[MAX_STR];
|
||||
|
||||
@@ -66,14 +76,24 @@ void dump_off(){
|
||||
fclose(fsw);
|
||||
if (fsw_ != NULL)
|
||||
fclose(fsw_);
|
||||
if (few != NULL)
|
||||
fclose(few);
|
||||
if (fmodel != NULL)
|
||||
fclose(fmodel);
|
||||
if (fqmodel != NULL)
|
||||
fclose(fqmodel);
|
||||
if (fpwb != NULL)
|
||||
fclose(fpwb);
|
||||
if (fpw != NULL)
|
||||
fclose(fpw);
|
||||
if (frw != NULL)
|
||||
fclose(frw);
|
||||
if (flsp != NULL)
|
||||
fclose(flsp);
|
||||
if (fweights != NULL)
|
||||
fclose(fweights);
|
||||
if (flsp_ != NULL)
|
||||
fclose(flsp_);
|
||||
if (fphase != NULL)
|
||||
fclose(fphase);
|
||||
if (fphase_ != NULL)
|
||||
@@ -88,12 +108,20 @@ void dump_off(){
|
||||
fclose(fdec);
|
||||
if (fsnr != NULL)
|
||||
fclose(fsnr);
|
||||
if (flpcsnr != NULL)
|
||||
fclose(flpcsnr);
|
||||
if (fak != NULL)
|
||||
fclose(fak);
|
||||
if (fak_ != NULL)
|
||||
fclose(fak_);
|
||||
if (fbg != NULL)
|
||||
fclose(fbg);
|
||||
if (fE != NULL)
|
||||
fclose(fE);
|
||||
if (frk != NULL)
|
||||
fclose(frk);
|
||||
if (fhephase != NULL)
|
||||
fclose(fhephase);
|
||||
}
|
||||
|
||||
void dump_Sn(float Sn[]) {
|
||||
@@ -155,6 +183,24 @@ void dump_Sw_(COMP Sw_[]) {
|
||||
fprintf(fsw_,"\n");
|
||||
}
|
||||
|
||||
void dump_Ew(COMP Ew[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (few == NULL) {
|
||||
sprintf(s,"%s_ew.txt", prefix);
|
||||
few = fopen(s, "wt");
|
||||
assert(few != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<FFT_ENC/2; i++)
|
||||
fprintf(few,"%f\t",
|
||||
10.0*log10(Ew[i].real*Ew[i].real + Ew[i].imag*Ew[i].imag));
|
||||
fprintf(few,"\n");
|
||||
}
|
||||
|
||||
void dump_model(MODEL *model) {
|
||||
int l;
|
||||
char s[MAX_STR];
|
||||
@@ -234,6 +280,25 @@ void dump_phase_(float phase_[], int L) {
|
||||
fprintf(fphase_,"\n");
|
||||
}
|
||||
|
||||
|
||||
void dump_hephase(int ind[], int dim) {
|
||||
int m;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fhephase == NULL) {
|
||||
sprintf(s,"%s_hephase.txt", prefix);
|
||||
fhephase = fopen(s, "wt");
|
||||
assert(fhephase != NULL);
|
||||
}
|
||||
|
||||
for(m=0; m<dim; m++)
|
||||
fprintf(fhephase,"%d\t",ind[m]);
|
||||
fprintf(fhephase,"\n");
|
||||
}
|
||||
|
||||
|
||||
void dump_snr(float snr) {
|
||||
char s[MAX_STR];
|
||||
|
||||
@@ -248,6 +313,39 @@ void dump_snr(float snr) {
|
||||
fprintf(fsnr,"%f\n",snr);
|
||||
}
|
||||
|
||||
void dump_lpc_snr(float snr) {
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (flpcsnr == NULL) {
|
||||
sprintf(s,"%s_lpc_snr.txt", prefix);
|
||||
flpcsnr = fopen(s, "wt");
|
||||
assert(flpcsnr != NULL);
|
||||
}
|
||||
|
||||
fprintf(flpcsnr,"%f\n",snr);
|
||||
}
|
||||
|
||||
/* Pw "before" post filter so we can plot before and after */
|
||||
|
||||
void dump_Pwb(COMP Pwb[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fpwb == NULL) {
|
||||
sprintf(s,"%s_pwb.txt", prefix);
|
||||
fpwb = fopen(s, "wt");
|
||||
assert(fpwb != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<FFT_ENC/2; i++)
|
||||
fprintf(fpwb,"%f\t",Pwb[i].real);
|
||||
fprintf(fpwb,"\n");
|
||||
}
|
||||
|
||||
void dump_Pw(COMP Pw[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
@@ -260,11 +358,45 @@ void dump_Pw(COMP Pw[]) {
|
||||
assert(fpw != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<FFT_DEC/2; i++)
|
||||
for(i=0; i<FFT_ENC/2; i++)
|
||||
fprintf(fpw,"%f\t",Pw[i].real);
|
||||
fprintf(fpw,"\n");
|
||||
}
|
||||
|
||||
void dump_Rw(float Rw[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (frw == NULL) {
|
||||
sprintf(s,"%s_rw.txt", prefix);
|
||||
frw = fopen(s, "wt");
|
||||
assert(frw != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<FFT_ENC/2; i++)
|
||||
fprintf(frw,"%f\t",Rw[i]);
|
||||
fprintf(frw,"\n");
|
||||
}
|
||||
|
||||
void dump_weights(float w[], int order) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fweights == NULL) {
|
||||
sprintf(s,"%s_weights.txt", prefix);
|
||||
fweights = fopen(s, "wt");
|
||||
assert(fweights != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<order; i++)
|
||||
fprintf(fweights,"%f\t", w[i]);
|
||||
fprintf(fweights,"\n");
|
||||
}
|
||||
|
||||
void dump_lsp(float lsp[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
@@ -282,6 +414,23 @@ void dump_lsp(float lsp[]) {
|
||||
fprintf(flsp,"\n");
|
||||
}
|
||||
|
||||
void dump_lsp_(float lsp_[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (flsp_ == NULL) {
|
||||
sprintf(s,"%s_lsp_.txt", prefix);
|
||||
flsp_ = fopen(s, "wt");
|
||||
assert(flsp_ != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<10; i++)
|
||||
fprintf(flsp_,"%f\t",lsp_[i]);
|
||||
fprintf(flsp_,"\n");
|
||||
}
|
||||
|
||||
void dump_ak(float ak[], int order) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
@@ -299,6 +448,23 @@ void dump_ak(float ak[], int order) {
|
||||
fprintf(fak,"\n");
|
||||
}
|
||||
|
||||
void dump_ak_(float ak_[], int order) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (fak_ == NULL) {
|
||||
sprintf(s,"%s_ak_.txt", prefix);
|
||||
fak_ = fopen(s, "wt");
|
||||
assert(fak_ != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<=order; i++)
|
||||
fprintf(fak_,"%f\t",ak_[i]);
|
||||
fprintf(fak_,"\n");
|
||||
}
|
||||
|
||||
void dump_Fw(COMP Fw[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
@@ -400,3 +566,22 @@ void dump_E(float E) {
|
||||
|
||||
fprintf(fE,"%f\n", 10.0*log10(E));
|
||||
}
|
||||
|
||||
void dump_Rk(float Rk[]) {
|
||||
int i;
|
||||
char s[MAX_STR];
|
||||
|
||||
if (!dumpon) return;
|
||||
|
||||
if (frk == NULL) {
|
||||
sprintf(s,"%s_rk.txt", prefix);
|
||||
frk = fopen(s, "wt");
|
||||
assert(frk != NULL);
|
||||
}
|
||||
|
||||
for(i=0; i<P_MAX; i++)
|
||||
fprintf(frk,"%f\t",Rk[i]);
|
||||
fprintf(frk,"\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user