Fix bugs in tofdm.c add shift back to .m
authorokcsampson <okcsampson@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 12 Jul 2017 03:29:01 +0000 (03:29 +0000)
committerokcsampson <okcsampson@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 12 Jul 2017 03:29:01 +0000 (03:29 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@3296 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/tofdm.m
codec2-dev/unittest/tofdm.c

index d5ca59e60962159b24d680ee6ff8a93b06e25ce7..6a650c6445ee32f581cb10a8d69dc738aab324f3 100644 (file)
@@ -34,6 +34,7 @@ end
 % Channel simulation ----------------------------------------------
 
 rx_log = sample_clock_offset(tx_log, sample_clock_offset_ppm);
+rx_log = freq_shift(rx_log, .01, Fs);
 
 % Rx ---------------------------------------------------------------
 
index b339998ec70dd18176dd54de328efc31301d3c7e..496552a004597d824b941f485625efe99653a981 100644 (file)
   DATE CREATED: May 2015
 
   Simulates small Fs offset between mod and demod.
+  (Note: Won't work with float, works OK with double)
 
 \*---------------------------------------------------------------------------*/
 
 static int fs_offset(COMP out[], COMP in[], int n, float sample_rate_ppm) {
-    float f;
-    int   t1, t2;
+    double f;
+    int t1, t2;
 
-    float tin = 0.0f;
+    double tin = 0.0;
     int tout = 0;
 
-    while (tin < n) {
-      t1 = floorf(tin);
-      t2 = ceilf(tin);
-      f = tin - t1;
+    while (tin < (double) n) {
+      t1 = (int) floor(tin);
+      t2 = (int) ceil(tin);
 
-      out[tout].real = (1.0f - f) * in[t1].real + f * in[t2].real;
-      out[tout].imag = (1.0f - f) * in[t1].imag + f * in[t2].imag;
+      f = (tin - (double) t1);
+
+      out[tout].real = (1.0 - f) * in[t1].real + f * in[t2].real;
+      out[tout].imag = (1.0 - f) * in[t1].imag + f * in[t2].imag;
 
       tout += 1;
-      tin  += 1.0f + sample_rate_ppm / 1E6f;
+      tin  += 1.0 + sample_rate_ppm / 1E6;
     }
 
     return tout;
@@ -174,7 +176,6 @@ int main(int argc, char *argv[])
 
     freq_shift(rx_log, rx_log, foff, &foff_phase_rect, samples_per_frame * NFRAMES);
 
-
     /* --------------------------------------------------------*\
                                Demod
     \*---------------------------------------------------------*/