fixed bug when phase0 and LPC combined - important to do phase0 with original {Am}
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 24 Sep 2009 08:41:27 +0000 (08:41 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 24 Sep 2009 08:41:27 +0000 (08:41 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@64 01035d8c-6547-0410-b346-abe4f91aad63

codec2/src/sinedec.c

index 3dab7a594effd6f3be3d11908cd09fd4871ac06a..bf840f21634ca459e78c0efcb94dc06b69024d53 100644 (file)
@@ -197,15 +197,8 @@ int main(int argc, char *argv[])
 
     dump_model(&model);
 
-    /* optional LPC model amplitudes */
-
-    if (lpc_model) {
-       snr = lpc_model_amplitudes(Sn, &model, order, lsp_quantiser, ak);
-       sum_snr += snr;
-        dump_quantised_model(&model);
-    }
-
-    /* optional phase modelling */
+    /* optional phase modelling - make sure this happens before LPC modelling
+       as first order model fit doesn't work well with LPC Modelled {Am} */
 
     if (phase) {
        float Wn[M];                    /* windowed speech samples */
@@ -226,7 +219,7 @@ int main(int argc, char *argv[])
            levinson_durbin(Rk,ak,PHASE_LPC_ORD);
        }
        else
-           assert(order == PHASE_LPC_ORD);
+         assert(order == PHASE_LPC_ORD);
 
        dump_ak(ak, PHASE_LPC_ORD);
        snr = phase_model_first_order(ak, H, &n_min, &min_Am);
@@ -243,11 +236,19 @@ int main(int argc, char *argv[])
            phase_synth_first_order(snr, H, n_min, min_Am);
             dump_phase_(&model.phi[0]);
         }
+
+        if (postfilt)
+           postfilter(&model, snr>2.0, &bg_est);
+
     }
 
-    if (postfilt)
-       postfilter(&model, snr>2.0, &bg_est);
+    /* optional LPC model amplitudes */
 
+    if (lpc_model) {
+       snr = lpc_model_amplitudes(Sn, &model, order, lsp_quantiser, ak);
+       sum_snr += snr;
+        dump_quantised_model(&model);
+    }
 
     /* Synthesise speech */