we were only recovering L/2 Am from LPC, check again
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 11 Aug 2010 07:45:28 +0000 (07:45 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 11 Aug 2010 07:45:28 +0000 (07:45 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@166 01035d8c-6547-0410-b346-abe4f91aad63

codec2/src/dump.c
codec2/src/dump.h
codec2/src/fq20.sh [new file with mode: 0755]
codec2/src/listen.sh
codec2/src/listen1.sh
codec2/src/quantise.c
codec2/src/sinedec.c

index 0f66ae27e2f10f729f4494f0ce49087a59698747..4be59940b8910bcd1e5084aa6863b61948381207 100644 (file)
@@ -48,6 +48,7 @@ static FILE *fdec = NULL;
 static FILE *fsnr = NULL;
 static FILE *fak = NULL;
 static FILE *fbg = NULL;
+static FILE *fE = NULL;
 
 static char  prefix[MAX_STR];
 
@@ -89,6 +90,8 @@ void dump_off(){
        fclose(fak);
     if (fbg != NULL)
        fclose(fbg);
+    if (fE != NULL)
+       fclose(fE);
 }
 
 void dump_Sn(float Sn[]) {
@@ -385,6 +388,16 @@ void dump_bg(float e, float bg_est, float percent_uv) {
     fprintf(fbg,"%f\t%f\t%f\n", e, bg_est, percent_uv);    
 }
 
+void dump_E(float E) {
+    char s[MAX_STR];
 
+    if (!dumpon) return;
 
+    if (fE == NULL) {
+       sprintf(s,"%s_E.txt", prefix);
+       fE = fopen(s, "wt");
+       assert(fE != NULL);
+    }
 
+    fprintf(fE,"%f\n", 10.0*log10(E));
+}
index 74c20dac6f8ce94c23df8eeb8d3d39fd12e4bab1..7e815cce0c548499cee8b5470b33db43a41eec89 100644 (file)
@@ -43,6 +43,7 @@ void dump_quantised_model(MODEL *m);
 void dump_Pw(COMP Pw[]);
 void dump_lsp(float lsp[]);
 void dump_ak(float ak[], int order);
+void dump_E(float E);
 
 /* phase modelling */
 
diff --git a/codec2/src/fq20.sh b/codec2/src/fq20.sh
new file mode 100755 (executable)
index 0000000..b83784b
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+# fq20.shsh
+# David Rowe 27 July 2010
+# 
+# Decode a file with fully quantised codec at 20ms frame rate
+
+../src/sinedec ../raw/$1.raw $1.mdl -o $1_phase0_lsp_20_EWo2.raw --phase 0 --lpc 10 --lsp --postfilter --dec
+
index 816fd8063c7388df101a7250731e0af4db19449c..5cd226ca0a21104276a0f224270241fb29f46090 100755 (executable)
@@ -9,5 +9,5 @@
 
 # compare to other codecs
 
-../script/menu.sh ../raw/$1.raw $1_phase0_lsp.raw ../raw/$1_g729a.raw ../raw/$1_gsm13k.raw ../raw/$1_speex_8k.raw $2 $3
+../script/menu.sh ../raw/$1.raw $1_phase0_lsp.raw $1_phase0_lsp_20.raw $1_phase0_lsp_20_EWo.raw ../raw/$1_g729a.raw ../raw/$1_gsm13k.raw ../raw/$1_speex_8k.raw $2 $3
 
index e3af29ae3acd1324f771421443a509ec0b2e1ad5..a3b72671bc6256fa13b0894bc50c603278fbeca4 100755 (executable)
@@ -4,6 +4,12 @@
 #
 # Run menu with common sample file options, headphone version
 
-../script/menu.sh ../raw/$1.raw $1_uq.raw $1_phase0.raw $1_lpc10.raw $1_lsp.raw $1_phase0_lpc10.raw $1_phase0_lsp.raw ../raw/$1_g729a.raw $2 $3 -d /dev/dsp1
+#../script/menu.sh ../raw/$1.raw $1_uq.raw $1_phase0.raw $1_lpc10.raw $1_lsp.raw $1_phase0_lpc10.raw $1_phase0_lsp.raw ../raw/$1_g729a.raw $2 $3 -d /dev/dsp1
+
+# compare to other codecs
+
+#../script/menu.sh ../raw/$1.raw $1_phase0_lsp.raw $1_phase0_lsp_20.raw ../raw/$1_g729a.raw ../raw/$1_gsm13k.raw ../raw/$1_speex_8k.raw $2 $3 -d /dev/dsp1
+
+../script/menu.sh ../raw/$1.raw $1_uq.raw $1_phase0.raw $1_test.raw ../raw/$1_g729a.raw $2 $3 -d /dev/dsp1
 
 
index 1f1ea0945e7d18d4dad8bda09396fa28127b1a90..7a739069514b757fc1dafbb95d98956e7713e892 100644 (file)
@@ -427,13 +427,23 @@ float lpc_model_amplitudes(
 #endif    
     /* used during development: copy remaining LSPs from orig if we haven't
        quantised all of them */
-    for(j=l; j<order; j++)
+    for(j=l; j<order; j++) 
        lsp_[j] = lsp[j];
 
     lsp_to_lpc(lsp_, &ak[1], order, NULL);
     dump_lsp(lsp);
   }
 
+  dump_E(E);
+  #ifdef SIM_QUANT
+  /* simulated LPC energy quantisation */
+  {
+      float e = 10.0*log10(E);
+      e += 2.0*(1.0 - 2.0*(float)rand()/RAND_MAX);
+      E = pow(10.0,e/10.0);
+  }
+  #endif
+
   aks_to_M2(ak,order,model,E,&snr);   /* {ak} -> {Am} LPC decode */
 
   #ifdef CLICKY
index b9d682eed1ade60b80ac2e21a0be278132a405af..184337262bd323a674f7293bdd72e0203a7ac841 100644 (file)
@@ -88,7 +88,7 @@ int main(int argc, char *argv[])
   int dump;
   
   int phase, phase_model;
-  float ex_phase[1];
+  float ex_phase[MAX_AMP+1];
   int voiced, voiced_1, voiced_2;
 
   int   postfilt;
@@ -107,6 +107,9 @@ int main(int argc, char *argv[])
       model_1.A[i] = 0.0;
       model_1.phi[i] = 0.0;
   }
+  for(i=1; i<=MAX_AMP; i++) {
+      ex_phase[i] = 0.0;
+  }
   model_synth = model_3 = model_2 = model_1;
 
   if (argc < 3) {
@@ -274,8 +277,8 @@ int main(int argc, char *argv[])
 
         //dump_phase_(&model.phi[0]);
     }
-
-    /* optional LPC model amplitudes */
+   /* optional LPC model amplitudes */
 
     if (lpc_model) {
        snr = lpc_model_amplitudes(Sn, &model, order, lsp, ak);
@@ -283,7 +286,6 @@ int main(int argc, char *argv[])
         dump_quantised_model(&model);
     }
 
-
     /* option decimation to 20ms rate, which enables interpolation
        routine to synthesise in between frame */
 
@@ -294,7 +296,6 @@ int main(int argc, char *argv[])
 
            model_synth = model_2;
            transition = 0;
-
        }
        else {
            interp(&model_3, &model_1, &model_synth, &model_a, &model_b, 
@@ -313,6 +314,14 @@ int main(int argc, char *argv[])
        model = model_synth;
     }
 
+    /* 
+       Simulate Wo quantisation noise
+       model.Wo += 2.0*(PI/8000)*(1.0 - 2.0*(float)rand()/RAND_MAX);
+       if (model.Wo > TWO_PI/20.0) model.Wo = TWO_PI/20.0;
+       if (model.Wo < TWO_PI/160.0) model.Wo = TWO_PI/160.0;
+       model.L = floor(PI/model.Wo);   
+    */
+
     /* Synthesise speech */
 
     if (fout != NULL) {