normalised digital osc phase as they were drifting over time leading to a X shaped...
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 1 Nov 2012 06:13:58 +0000 (06:13 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 1 Nov 2012 06:13:58 +0000 (06:13 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@914 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/src/fdmdv.c
codec2-dev/src/fdmdv.h
codec2-dev/src/fdmdv_demod.c
codec2-dev/src/fdmdv_mod.c

index 26c2a7f7cd7cf2c694bd3c292b17578731f56c2e..9f1b20cd2623676739ef5fbf20c4ba7b615a81cd 100644 (file)
@@ -448,6 +448,12 @@ void fdm_upconvert(COMP tx_fdm[], COMP tx_baseband[NC+1][M], COMP phase_tx[], CO
     for (i=0; i<M; i++) 
        tx_fdm[i] = cmult(two, tx_fdm[i]);
 
+    /* normalise digital oscilators as the magnitude can drfift over time */
+
+    for (c=0; c<NC+1; c++) {
+       phase_tx[c].real /= cabsolute(phase_tx[c]);     
+       phase_tx[c].imag /= cabsolute(phase_tx[c]);     
+    }
 }
 
 /*---------------------------------------------------------------------------*\
@@ -706,7 +712,7 @@ float rx_est_freq_offset(struct FDMDV *f, float rx_fdm[], int nin)
 
 void freq_shift(COMP rx_fdm_fcorr[], float rx_fdm[], float foff, COMP *foff_rect, COMP *foff_phase_rect, int nin)
 {
-    int i;
+    int   i;
 
     foff_rect->real = cos(2.0*PI*foff/FS);
     foff_rect->imag = sin(2.0*PI*foff/FS);
@@ -714,7 +720,11 @@ void freq_shift(COMP rx_fdm_fcorr[], float rx_fdm[], float foff, COMP *foff_rect
        *foff_phase_rect = cmult(*foff_phase_rect, cconj(*foff_rect));
        rx_fdm_fcorr[i] = fcmult(rx_fdm[i], *foff_phase_rect);
     }
-  
+
+    /* normalise digital oscilator as the magnitude can drfift over time */
+
+    foff_phase_rect->real /= cabsolute(*foff_phase_rect);       
+    foff_phase_rect->imag /= cabsolute(*foff_phase_rect);       
 }
 
 /*---------------------------------------------------------------------------*\
@@ -759,6 +769,12 @@ void fdm_downconvert(COMP rx_baseband[NC+1][M+M/P], COMP rx_fdm[], COMP phase_rx
        rx_baseband[c][i] = cmult(rx_fdm[i], cconj(phase_rx[c]));
     }
 
+    /* normalise digital oscilators as the magnitude can drfift over time */
+
+    for (c=0; c<NC+1; c++) {
+       phase_rx[c].real /= cabsolute(phase_rx[c]);       
+       phase_rx[c].imag /= cabsolute(phase_rx[c]);       
+    }
 }
 
 /*---------------------------------------------------------------------------*\
@@ -1440,3 +1456,26 @@ void CODEC2_WIN32SUPPORT fdmdv_get_rx_spectrum(struct FDMDV *f, float mag_spec_d
     }
 }
 
+/*---------------------------------------------------------------------------*\
+                                                       
+  Function used during development to test if magnitude of digital
+  oscillators was drifting.  It was!
+
+\*---------------------------------------------------------------------------*/
+
+void CODEC2_WIN32SUPPORT fdmdv_dump_osc_mags(struct FDMDV *f) 
+{
+    int   i;
+
+    fprintf(stderr, "phase_tx[]:\n");
+    for(i=0; i<=NC; i++)
+       fprintf(stderr,"  %1.3f", cabsolute(f->phase_tx[i]));
+    fprintf(stderr,"\nfreq[]:\n");
+    for(i=0; i<=NC; i++)
+       fprintf(stderr,"  %1.3f", cabsolute(f->freq[i]));
+    fprintf(stderr,"\nfoff_rect %1.3f  foff_phase_rect: %1.3f", cabsolute(f->foff_rect), cabsolute(f->foff_phase_rect));
+    fprintf(stderr,"\nphase_rx[]:\n");
+    for(i=0; i<=NC; i++)
+       fprintf(stderr,"  %1.3f", cabsolute(f->phase_rx[i]));
+    fprintf(stderr, "\n\n");
+}
index b165247f2eb14bb5a4c1c1e603453173940383a0..58fdecc86dd908671562e59228172b0ca37a5269 100644 (file)
@@ -98,6 +98,8 @@ void           CODEC2_WIN32SUPPORT fdmdv_get_rx_spectrum(struct FDMDV *fdmdv_sta
 void           CODEC2_WIN32SUPPORT fdmdv_8_to_48(float out48k[], float in8k[], int n);
 void           CODEC2_WIN32SUPPORT fdmdv_48_to_8(float out8k[], float in48k[], int n);
 
+void CODEC2_WIN32SUPPORT fdmdv_dump_osc_mags(struct FDMDV *f);
 #ifdef __cplusplus
 }
 #endif
index e69253aa1974374c74100804add0871e9cb5c381..7929ca6894c9d126afca2d0e74699ef3856d06c2 100644 (file)
@@ -219,6 +219,8 @@ int main(int argc, char *argv[])
        }
     }
 
+    //fdmdv_dump_osc_mags(fdmdv);
+
     fclose(fin);
     fclose(fout);
     free(rx_fdm_log);
index 604282bd3781aebb8bd83520012da7bdf91d05a1..b85f8d1fa4a33a31dfb517ba07202492ca7a7f1f 100644 (file)
@@ -114,6 +114,8 @@ int main(int argc, char *argv[])
         if (fin == stdin) fflush(stdin);         
     }
 
+    //fdmdv_dump_osc_mags(fdmdv);
+
     fclose(fin);
     fclose(fout);
     fdmdv_destroy(fdmdv);