added ability to read Aw to test synthesising phase in Octave by newamp.m
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 17 Sep 2015 12:41:37 +0000 (12:41 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 17 Sep 2015 12:41:37 +0000 (12:41 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2343 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/src/c2sim.c

index 6cfeedc4c67ac9226fc1636e63bc255d7cfa3a5a..3a502376bee561e260f679dca88638d811f01cf7 100644 (file)
@@ -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)