From cb1ad1fffd725280c23d718755e69734d49e1403 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Thu, 17 Sep 2015 12:41:37 +0000 Subject: [PATCH] added ability to read Aw to test synthesising phase in Octave by newamp.m git-svn-id: https://svn.code.sf.net/p/freetel/code@2343 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/src/c2sim.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/codec2-dev/src/c2sim.c b/codec2-dev/src/c2sim.c index 6cfeedc4..3a502376 100644 --- a/codec2-dev/src/c2sim.c +++ b/codec2-dev/src/c2sim.c @@ -144,6 +144,8 @@ int main(int argc, char *argv[]) float lspmelvq_mse = 0.0; int amread; FILE *fam; + int awread; + FILE *faw; char* opt_string = "ho:"; struct option long_options[] = { @@ -179,6 +181,7 @@ int main(int argc, char *argv[]) { "bpf", no_argument, &bpf_en, 1 }, { "bpfb", no_argument, &bpfb_en, 1 }, { "amread", required_argument, &amread, 1 }, + { "awread", required_argument, &awread, 1 }, #ifdef DUMP { "dump", required_argument, &dump, 1 }, #endif @@ -281,6 +284,12 @@ int main(int argc, char *argv[]) optarg, strerror(errno)); exit(1); } + } else if(strcmp(long_options[option_index].name, "awread") == 0) { + if ((faw = fopen(optarg,"rb")) == NULL) { + fprintf(stderr, "Error opening float Aw file: %s: %s.\n", + optarg, strerror(errno)); + exit(1); + } } else if(strcmp(long_options[option_index].name, "dump_pitch_e") == 0) { if ((fjvm = fopen(optarg,"wt")) == NULL) { fprintf(stderr, "Error opening pitch & energy dump file: %s: %s.\n", @@ -799,6 +808,19 @@ int main(int argc, char *argv[]) #endif } + /* optionally rewad in Aw FFT vector, we really only care about the phase + of each entry, used for reading in phases generated by Octave */ + + if (awread) { + int j; + int ret = fread(Aw, sizeof(COMP), FFT_ENC, faw); + //for(j=0; j<10; j++) { + // fprintf(stderr, "%f %f\n", Aw[j].real, Aw[j].imag); + //} + //exit(0); + assert(ret == FFT_ENC); + } + if (phase0) phase_synth_zero_order(fft_fwd_cfg, &model_dec[i], ex_phase, Aw); if (postfilt) -- 2.25.1