simplified LPC correction to not require any bits and removed HPF as it was breaking...
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 18 Nov 2010 06:52:25 +0000 (06:52 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 18 Nov 2010 06:52:25 +0000 (06:52 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@245 01035d8c-6547-0410-b346-abe4f91aad63

codec2/src/c2sim.c
codec2/src/codec2.c
codec2/src/quantise.c

index 6b99e8133f61ae9d6ea6ee44cbe1f82953a96475..5cece50b302fc7719b18186246c3bcda5b26d77f 100644 (file)
@@ -249,7 +249,7 @@ int main(int argc, char *argv[])
     for(i=0; i<M-N; i++)
       Sn[i] = Sn[i+N];
     for(i=0; i<N; i++)
-       Sn[i+M-N] = hpf((float)buf[i], hpf_states);
+       Sn[i+M-N] = buf[i];
  
     /* Estimate pitch */
 
@@ -311,7 +311,6 @@ int main(int argc, char *argv[])
        int   lsp_indexes[LPC_MAX];
 
        e = speech_to_uq_lsps(lsps, ak, Sn, w, order);
-       lpc_correction = need_lpc_correction(&model, ak, e, order);
 
        if (lsp) {
            encode_lsps(lsp_indexes, lsps, LPC_ORD);
index e67f3fbad53800211ba85d618c2658e4d04f4971..3025a03b59d50c41a12af9e4676e01c112ac38d8 100644 (file)
@@ -352,7 +352,7 @@ void analyse_one_frame(CODEC2 *c2, MODEL *model, short speech[])
     for(i=0; i<M-N; i++)
       c2->Sn[i] = c2->Sn[i+N];
     for(i=0; i<N; i++)
-      c2->Sn[i+M-N] = hpf((float)speech[i], c2->hpf_states);
+      c2->Sn[i+M-N] = speech[i];
 
     dft_speech(Sw, c2->Sn, c2->w);
 
index 4b6e5eafb4743e1c1de38b3e91efd008978a91a9..c8b25296039f771a35956e3f2bebd91a8661ffe2 100644 (file)
@@ -626,69 +626,21 @@ void bw_expand_lsps(float lsp[],
     }
 }
 
-/*---------------------------------------------------------------------------*\
-                                                       
-  FUNCTION....: need_lpc_correction()       
-  AUTHOR......: David Rowe                           
-  DATE CREATED: 22/8/2010 
-
-  Determine if we need LPC correction of first harmonic.
-
-\*---------------------------------------------------------------------------*/
-
-int need_lpc_correction(MODEL *model, float ak[], float E, int order)
-{
-    MODEL  tmp;
-    float  snr,E1;
-
-    /* Find amplitudes so we can check if we need LPC correction.
-       TODO: replace call to aks_to_M2() by a single DFT calculation
-       of E/A(exp(jWo)) to make much more efficient.  We only need
-       A[1].
-    */
-
-    memcpy(&tmp, model, sizeof(MODEL));
-    aks_to_M2(ak, order, &tmp, E, &snr, 0);   
-
-    /* 
-       Attenuate fundamental by 30dB if F0 < 150 Hz and LPC modelling
-       error for A[1] is larger than 6dB.
-
-       LPC modelling often makes big errors on 1st harmonic, for example
-       when the fundamental has been removed by analog high pass
-       filtering before sampling.  However on unfiltered speech from
-       high quality sources we would like to keep the fundamental to
-       maintain the speech quality.  So we check the error in A[1] and
-       attenuate it if the error is large to avoid annoying low
-       frequency energy after LPC modelling.
-
-       This requires a single bit to quantise, on top of the other
-       spectral magnitude bits (i.e. LSP bits + 1 total).
-    */
-
-    E1 = fabs(20.0*log10(model->A[1]) - 20.0*log10(tmp.A[1]));
-    if (E1 > 6.0)
-       return 1;
-    else 
-       return 0;
-}
-
 /*---------------------------------------------------------------------------*\
                                                        
   FUNCTION....: apply_lpc_correction()      
   AUTHOR......: David Rowe                           
   DATE CREATED: 22/8/2010 
 
-  Apply first harmonic LPC correction at decoder.
+  Apply first harmonic LPC correction at decoder.  This helps improve
+  low pitch males after LPC modelling, like hts1a and morig.
 
 \*---------------------------------------------------------------------------*/
 
 void apply_lpc_correction(MODEL *model, int lpc_correction)
 {
-    if (lpc_correction) {
-       if (model->Wo < (PI*150.0/4000)) {
-           model->A[1] *= 0.032;
-       }
+    if (model->Wo < (PI*150.0/4000)) {
+       model->A[1] *= 0.032;
     }
 }