support for setting carrier separation
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 24 Mar 2013 05:49:45 +0000 (05:49 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 24 Mar 2013 05:49:45 +0000 (05:49 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1225 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/src/codec2_fdmdv.h
codec2-dev/src/fdmdv.c
codec2-dev/src/fdmdv_internal.h

index 1d9db7d211758c890923bb1bc46ae535e00ad8e0..543b4d04ce78023352f6e5947c6b9f1186320ab5 100644 (file)
@@ -94,7 +94,9 @@ struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(int Nc);
 void           CODEC2_WIN32SUPPORT fdmdv_destroy(struct FDMDV *fdmdv_state);
 void           CODEC2_WIN32SUPPORT fdmdv_use_old_qpsk_mapping(struct FDMDV *fdmdv_state);
 int            CODEC2_WIN32SUPPORT fdmdv_bits_per_frame(struct FDMDV *fdmdv_state);
-    
+float          CODEC2_WIN32SUPPORT fdmdv_get_fsep(struct FDMDV *fdmdv_state);
+void           CODEC2_WIN32SUPPORT fdmdv_set_fsep(struct FDMDV *fdmdv_state, float fsep);
+
 void           CODEC2_WIN32SUPPORT fdmdv_mod(struct FDMDV *fdmdv_state, COMP tx_fdm[], int tx_bits[], int *sync_bit);
 void           CODEC2_WIN32SUPPORT fdmdv_demod(struct FDMDV *fdmdv_state, int rx_bits[], int *reliable_sync_bit, COMP rx_fdm[], int *nin);
     
index b1e76fa543c9d82c1ae2b2227ad8f5232ee2343a..880cabb2671a1f1f779baf0e61e7f7a9a77bda1f 100644 (file)
@@ -125,7 +125,6 @@ struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(int Nc)
 {
     struct FDMDV *f;
     int           c, i, k;
-    float         carrier_freq;
 
     assert(NC == FDMDV_NC_MAX);  /* check public and private #defines match */
     assert(Nc <= NC);
@@ -184,22 +183,9 @@ struct FDMDV * CODEC2_WIN32SUPPORT fdmdv_create(int Nc)
            f->rx_baseband_mem_timing[c][k].real = 0.0;
            f->rx_baseband_mem_timing[c][k].imag = 0.0;
        }
-  }
-    
-    /* Set up frequency of each carrier */
-
-    for(c=0; c<Nc/2; c++) {
-       carrier_freq = (-Nc/2 + c)*FSEP + FDMDV_FCENTRE;
-       f->freq[c].real = cos(2.0*PI*carrier_freq/FS);
-       f->freq[c].imag = sin(2.0*PI*carrier_freq/FS);
-    }
-
-    for(c=Nc/2; c<Nc; c++) {
-       carrier_freq = (-Nc/2 + c + 1)*FSEP + FDMDV_FCENTRE;
-       f->freq[c].real = cos(2.0*PI*carrier_freq/FS);
-       f->freq[c].imag = sin(2.0*PI*carrier_freq/FS);
     }
-       
+    
+    fdmdv_set_fsep(f, FSEP);
     f->freq[Nc].real = cos(2.0*PI*FDMDV_FCENTRE/FS);
     f->freq[Nc].imag = sin(2.0*PI*FDMDV_FCENTRE/FS);
 
@@ -305,6 +291,32 @@ void CODEC2_WIN32SUPPORT fdmdv_get_test_bits(struct FDMDV *f, int tx_bits[])
     }
  }
 
+float CODEC2_WIN32SUPPORT fdmdv_get_fsep(struct FDMDV *f)
+{
+    return f->fsep;
+}
+
+void CODEC2_WIN32SUPPORT fdmdv_set_fsep(struct FDMDV *f, float fsep) {
+    int   c;
+    float carrier_freq;
+
+    f->fsep = fsep;
+    /* Set up frequency of each carrier */
+
+    for(c=0; c<f->Nc/2; c++) {
+       carrier_freq = (-f->Nc/2 + c)*f->fsep + FDMDV_FCENTRE;
+       f->freq[c].real = cos(2.0*PI*carrier_freq/FS);
+       f->freq[c].imag = sin(2.0*PI*carrier_freq/FS);
+    }
+
+    for(c=f->Nc/2; c<f->Nc; c++) {
+       carrier_freq = (-f->Nc/2 + c + 1)*f->fsep + FDMDV_FCENTRE;
+       f->freq[c].real = cos(2.0*PI*carrier_freq/FS);
+       f->freq[c].imag = sin(2.0*PI*carrier_freq/FS);
+    }
+}
+
+
 /*---------------------------------------------------------------------------*\
                                                        
   FUNCTION....: bits_to_dqpsk_symbols()             
index 34ff7bde50067fc2c0148b36b70a4ec4cafc79c1..e9b355d47c2f2dfc1f422a6e79fa7eb85b39f6da 100644 (file)
@@ -50,7 +50,7 @@
 #define NSYM                     6  /* number of symbols to filter over                                     */
 #define NFILTER            (NSYM*M) /* size of tx/rx filters at sample rate M                               */
 
-#define FSEP                    75  /* Separation between carriers (Hz)                                     */
+#define FSEP                    75  /* Default separation between carriers (Hz)                             */
 
 #define NT                       5  /* number of symbols we estimate timing over                            */
 #define P                        4  /* oversample factor used for initial rx symbol filtering               */
@@ -77,7 +77,8 @@
 
 struct FDMDV {
 
-    int Nc;           
+    int   Nc;           
+    float fsep;
 
     /* test data (test frame) states */