fixed occasional wild bit error counts for cohpsk test frames
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 27 Jul 2015 03:47:12 +0000 (03:47 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 27 Jul 2015 03:47:12 +0000 (03:47 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2245 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/src/cohpsk.c
codec2-dev/src/fm.c

index 502969ce16876d2a267b7c3833882fa28efed668..2542573444b470723c3dd97d56f3941d3012f92b 100644 (file)
@@ -1210,6 +1210,9 @@ void cohpsk_put_test_bits(struct COHPSK *coh, int *state, short error_pattern[],
     *bit_errors = 0;
     for(i=0; i<COHPSK_BITS_PER_FRAME; i++) {
         anerror = (rx_bits[i] & 0x1) ^ coh->ptest_bits_coh_rx[i];
+        if ((anerror < 0) || (anerror > 1)) {
+            fprintf(stderr, "i: %d rx_bits: %d ptest_bits_coh_rx: %d\n", i, rx_bits[i], coh->ptest_bits_coh_rx[i]);
+        }
         *bit_errors += anerror;
         error_pattern[i] = anerror;
     }
@@ -1222,6 +1225,9 @@ void cohpsk_put_test_bits(struct COHPSK *coh, int *state, short error_pattern[],
         if (*bit_errors < 4) {
             next_state = 1;
             coh->ptest_bits_coh_rx += COHPSK_BITS_PER_FRAME;
+            if (coh->ptest_bits_coh_rx >= coh->ptest_bits_coh_end) {
+                coh->ptest_bits_coh_rx = (int*)test_bits_coh;
+            }
         }
     }
 
index 18f0a5328a9efb8c7d13c60890f2d7845c1120aa..bdccd8a8b9c91c562dc432777becdb82202e6f96 100644 (file)
@@ -124,7 +124,7 @@ void fm_demod(struct FM *fm_states, float rx_out[], float rx[])
   float  mag;
   int    i,k;
 
-  wc_rect.real = cos(wc); wc_rect.imag = -sin(wc);
+  wc_rect.real = cosf(wc); wc_rect.imag = -sinf(wc);
 
   for(i=0; i<nsam; i++) {
 
@@ -136,10 +136,13 @@ void fm_demod(struct FM *fm_states, float rx_out[], float rx[])
       /* input FIR filter */
 
       rx_bb_filt.real = 0.0; rx_bb_filt.imag = 0.0;
-      for(k=0; k<FILT_MEM; k++) {
-          rx_bb_filt.real += rx_bb[i-k].real * bin[k];
-          rx_bb_filt.imag += rx_bb[i-k].imag * bin[k];
+      
+      for(k=0; k<FILT_MEM/2; k++) {
+          rx_bb_filt.real += rx_bb[i-k].real * bin[k+FILT_MEM/4];
+          rx_bb_filt.imag += rx_bb[i-k].imag * bin[k+FILT_MEM/4];
       }
+      
+      //rx_bb_filt = rx_bb[i];
       //printf("%f %f %f\n", rx[i], wc_rect.real, wc_rect.imag);
       //printf("%f %f %f\n", rx[i], fm_states->lo_phase.real, fm_states->lo_phase.imag);
       //printf("%f %f %f\n", rx[i], rx_bb[i].real, rx_bb[i].imag);
@@ -153,7 +156,7 @@ void fm_demod(struct FM *fm_states, float rx_out[], float rx[])
       rx_bb_diff = cmult(rx_bb_filt, cconj(fm_states->rx_bb_filt_prev));
       fm_states->rx_bb_filt_prev = rx_bb_filt;
   
-      rx_dem = atan2(rx_bb_diff.imag, rx_bb_diff.real);
+      rx_dem = atan2f(rx_bb_diff.imag, rx_bb_diff.real);
 
       /* limit maximum phase jumps, to remove static type noise at low SNRs */
 
@@ -166,10 +169,12 @@ void fm_demod(struct FM *fm_states, float rx_out[], float rx[])
       //printf("%f %f\n", rx_bb_diff.real, rx_bb_diff.imag);
       rx_dem_mem[i] = rx_dem;
       acc = 0;
-      for(k=0; k<FILT_MEM; k++) {
+      /*
+        for(k=0; k<FILT_MEM; k++) {
           acc += rx_dem_mem[i-k] * bout[k];
       }
-      rx_out[i] = acc;
+      */
+      rx_out[i] = rx_dem;
   }
 
   /* update filter memories */