]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Fix fixed point builds of spandsp, and improve logging of modem performance during...
authorSteve Underwood <steveu@coppice.org>
Sun, 5 Aug 2012 14:20:39 +0000 (22:20 +0800)
committerSteve Underwood <steveu@coppice.org>
Sun, 5 Aug 2012 14:20:39 +0000 (22:20 +0800)
libs/spandsp/src/spandsp/v17rx.h
libs/spandsp/src/spandsp/v22bis.h
libs/spandsp/src/spandsp/v27ter_rx.h
libs/spandsp/src/spandsp/v29rx.h
libs/spandsp/src/v17rx.c
libs/spandsp/tests/modem_monitor.cpp
libs/spandsp/tests/modem_monitor.h
libs/spandsp/tests/v17_tests.c
libs/spandsp/tests/v22bis_tests.c
libs/spandsp/tests/v27ter_tests.c
libs/spandsp/tests/v29_tests.c

index 892217889ac7cd64c98d6358ad4c600b1dc617bb..935d5428533bd2145eb5e2a88f37e3b0369b5590 100644 (file)
@@ -209,6 +209,12 @@ working only on the most optimal lines, and being widely usable across most phon
 TCM absolutely transformed the phone line modem business.
 */
 
+#if defined(SPANDSP_USE_FIXED_POINT)
+#define V17_CONSTELLATION_SCALING_FACTOR        1024.0
+#else
+#define V17_CONSTELLATION_SCALING_FACTOR        1.0
+#endif
+
 /*!
     V.17 modem receive side descriptor. This defines the working state for a
     single instance of a V.17 modem receiver.
index 440118c7cbd7b1a674b96fdb84c2eb762c8e9fb3..6361c058419d1eb81453b35eb63ef1b5e1c292a1 100644 (file)
@@ -48,6 +48,12 @@ or 1200bps if one or both ends to not acknowledge that 2400bps is OK.
 #if !defined(_SPANDSP_V22BIS_H_)
 #define _SPANDSP_V22BIS_H_
 
+#if defined(SPANDSP_USE_FIXED_POINT)
+#define V22BIS_CONSTELLATION_SCALING_FACTOR     1024.0
+#else
+#define V22BIS_CONSTELLATION_SCALING_FACTOR     1.0
+#endif
+
 enum
 {
     V22BIS_GUARD_TONE_NONE,
index 6b464b3d422de8af7597849bb6d85c3eb78a5885..a6055844d6158b61732ae77163be4504692c98f6 100644 (file)
@@ -44,6 +44,12 @@ at the start of transmission, which makes the design of a V.27ter receiver relat
 straightforward.
 */
 
+#if defined(SPANDSP_USE_FIXED_POINT)
+#define V27TER_CONSTELLATION_SCALING_FACTOR     1024.0
+#else
+#define V27TER_CONSTELLATION_SCALING_FACTOR     1.0
+#endif
+
 /*!
     V.27ter modem receive side descriptor. This defines the working state for a
     single instance of a V.27ter modem receiver.
index bdcd23f944719d497e234c02aac2d32656ed4fda..bb52e624dc0b7d5831c1b464960671c20e4bc45e 100644 (file)
@@ -118,6 +118,12 @@ scrambler register) cannot be trusted for the test. The receive modem,
 therefore, only tests that bits starting at bit 24 are really ones. 
 */
 
+#if defined(SPANDSP_USE_FIXED_POINT)
+#define V29_CONSTELLATION_SCALING_FACTOR        4096.0
+#else
+#define V29_CONSTELLATION_SCALING_FACTOR        1.0
+#endif
+
 #if defined(SPANDSP_USE_FIXED_POINT)
 typedef void (*qam_report_handler_t)(void *user_data, const complexi16_t *constel, const complexi16_t *target, int symbol);
 #else
index 27c568c46a35fd6ae9e99009e946702bedf69b71..9d692a154887ff1af00b3fc77aa251f6b44e4003 100644 (file)
@@ -202,10 +202,11 @@ SPAN_DECLARE(int) v17_rx_equalizer_state(v17_rx_state_t *s, complexf_t **coeffs)
 {
 #if defined(SPANDSP_USE_FIXED_POINT)
     *coeffs = NULL;
+    return 0;
 #else
     *coeffs = s->eq_coeff;
-#endif
     return V17_EQUALIZER_LEN;
+#endif
 }
 /*- End of function --------------------------------------------------------*/
 
index a5ba73289f8d417db3e2f71029fee825c618bea8..db8a31a22dcdebe6043a5e27d6976ce3e3ad94c8 100644 (file)
 #define SYMBOL_TRACKER_POINTS   12000
 #define CARRIER_TRACKER_POINTS  12000
 
-#define FP_FACTOR               4096
-
 struct qam_monitor_s
 {
+    float constel_scaling;
+
     Fl_Double_Window *w;
     Fl_Group *c_const;
     Fl_Group *c_right;
@@ -189,14 +189,14 @@ int qam_monitor_update_equalizer(qam_monitor_t *s, const complexf_t *coeffs, int
     for (i = 0;  i < len;  i++)
     {
         s->eq_re_plot[2*i] = (i - len/2)/2.0;
-        s->eq_re_plot[2*i + 1] = coeffs[i].re;
+        s->eq_re_plot[2*i + 1] = coeffs[i].re*s->constel_scaling;
         if (min > coeffs[i].re)
             min = coeffs[i].re;
         if (max < coeffs[i].re)
             max = coeffs[i].re;
 
         s->eq_im_plot[2*i] = (i - len/2)/2.0;
-        s->eq_im_plot[2*i + 1] = coeffs[i].im;
+        s->eq_im_plot[2*i + 1] = coeffs[i].im*s->constel_scaling;
         if (min > coeffs[i].im)
             min = coeffs[i].im;
         if (max < coeffs[i].im)
@@ -235,22 +235,22 @@ int qam_monitor_update_int_equalizer(qam_monitor_t *s, const complexi16_t *coeff
         max = coeffs[i].im;
     for (i = 0;  i < len;  i++)
     {
-        s->eq_re_plot[2*i] = (i - len/2)/2.0f;
-        s->eq_re_plot[2*i + 1] = coeffs[i].re/(float) FP_FACTOR;
         if (min > coeffs[i].re)
             min = coeffs[i].re;
         if (max < coeffs[i].re)
             max = coeffs[i].re;
+        s->eq_re_plot[2*i] = (i - len/2)/2.0f;
+        s->eq_re_plot[2*i + 1] = coeffs[i].re*s->constel_scaling;
 
-        s->eq_im_plot[2*i] = (i - len/2)/2.0f;
-        s->eq_im_plot[2*i + 1] = coeffs[i].im/(float) FP_FACTOR;
         if (min > coeffs[i].im)
             min = coeffs[i].im;
         if (max < coeffs[i].im)
             max = coeffs[i].im;
+        s->eq_im_plot[2*i] = (i - len/2)/2.0f;
+        s->eq_im_plot[2*i + 1] = coeffs[i].im*s->constel_scaling;
     }
-    min /= (float) FP_FACTOR;
-    max /= (float) FP_FACTOR;
+    min *= s->constel_scaling;
+    max *= s->constel_scaling;
 
     s->eq_x->minimum(-len/4.0);
     s->eq_x->maximum(len/4.0);
@@ -286,21 +286,21 @@ int qam_monitor_update_symbol_tracking(qam_monitor_t *s, float total_correction)
     max = s->symbol_tracker[0];
     for (i = s->symbol_track_ptr, j = 0;  i < s->symbol_track_points;  i++, j++)
     {
-        s->symbol_track_plot[2*j] = j;
-        s->symbol_track_plot[2*j + 1] = s->symbol_tracker[i];
         if (min > s->symbol_tracker[i])
             min = s->symbol_tracker[i];
         if (max < s->symbol_tracker[i])
             max = s->symbol_tracker[i];
+        s->symbol_track_plot[2*j] = j;
+        s->symbol_track_plot[2*j + 1] = s->symbol_tracker[i];
     }
     for (i = 0;  i < s->symbol_track_ptr;  i++, j++)
     {
-        s->symbol_track_plot[2*j] = j;
-        s->symbol_track_plot[2*j + 1] = s->symbol_tracker[i];
         if (min > s->symbol_tracker[i])
             min = s->symbol_tracker[i];
         if (max < s->symbol_tracker[i])
             max = s->symbol_tracker[i];
+        s->symbol_track_plot[2*j] = j;
+        s->symbol_track_plot[2*j + 1] = s->symbol_tracker[i];
     }
     s->symbol_track_y->maximum((fabs(max - min) < 0.05)  ?  max + 0.05  :  max);
     s->symbol_track_y->minimum(min);
@@ -379,7 +379,7 @@ int qam_monitor_update_carrier_tracking(qam_monitor_t *s, float carrier_freq)
 }
 /*- End of function --------------------------------------------------------*/
 
-qam_monitor_t *qam_monitor_init(float constel_width, const char *tag)
+qam_monitor_t *qam_monitor_init(float constel_width, float constel_scaling, const char *tag)
 {
     char buf[132 + 1];
     float x;
@@ -391,6 +391,8 @@ qam_monitor_t *qam_monitor_init(float constel_width, const char *tag)
     
     s->w = new Fl_Double_Window(905, 400, (tag)  ?  tag  :  "QAM monitor");
 
+    s->constel_scaling = 1.0/constel_scaling;
+
     s->c_const = new Fl_Group(0, 0, 380, 400);
     s->c_const->box(FL_DOWN_BOX);
     s->c_const->align(FL_ALIGN_TOP | FL_ALIGN_INSIDE);
index b1b79fda06e36af340985bc6a4897f87d6a3221d..3a3f896b8ab135ddab37f7093a3e6d3e1f4affd6 100644 (file)
@@ -50,7 +50,7 @@ extern "C"
 {
 #endif
 
-qam_monitor_t *qam_monitor_init(float constel_width, const char *tag);
+qam_monitor_t *qam_monitor_init(float constel_width, float constel_scaling, const char *tag);
 int qam_monitor_clear_constel(qam_monitor_t *s);
 int qam_monitor_update_constel(qam_monitor_t *s, const complexf_t *pt);
 int qam_monitor_update_equalizer(qam_monitor_t *s, const complexf_t *coeffs, int len);
index a974049a29b40b56c0a332390fd8e0eda54d1f53..39b5a4a3191bb700e8475afacd94cd8c420c86d0 100644 (file)
@@ -133,14 +133,17 @@ static void v17_rx_status(void *user_data, int status)
     switch (status)
     {
     case SIG_STATUS_TRAINING_SUCCEEDED:
-        len = v17_rx_equalizer_state(s, &coeffs);
-        printf("Equalizer:\n");
-        for (i = 0;  i < len;  i++)
+        printf("Training succeeded\n");
+        if ((len = v17_rx_equalizer_state(s, &coeffs)))
+        {
+            printf("Equalizer:\n");
+            for (i = 0;  i < len;  i++)
 #if defined(SPANDSP_USE_FIXED_POINT)
-            printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/4096.0f, coeffs[i].im/4096.0f);
+                printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V17_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V17_CONSTELLATION_SCALING_FACTOR);
 #else
-            printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
+                printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
 #endif
+        }
         break;
     }
 }
@@ -183,10 +186,11 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex
     int len;
 #if defined(SPANDSP_USE_FIXED_POINT)
     complexi16_t *coeffs;
-    complexf_t constel_point;
 #else
     complexf_t *coeffs;
 #endif
+    complexf_t constel_point;
+    complexf_t target_point;
     float fpower;
     v17_rx_state_t *rx;
     static float smooth_power = 0.0f;
@@ -195,67 +199,56 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex
     rx = (v17_rx_state_t *) user_data;
     if (constel)
     {
-        fpower = (constel->re - target->re)*(constel->re - target->re)
-               + (constel->im - target->im)*(constel->im - target->im);
-#if defined(SPANDSP_USE_FIXED_POINT)
-        fpower /= 4096.0*4096.0;
-#endif
+        constel_point.re = constel->re/V17_CONSTELLATION_SCALING_FACTOR;
+        constel_point.im = constel->im/V17_CONSTELLATION_SCALING_FACTOR;
+        target_point.re = target->re/V17_CONSTELLATION_SCALING_FACTOR,
+        target_point.im = target->im/V17_CONSTELLATION_SCALING_FACTOR,
+        fpower = (constel_point.re - target_point.re)*(constel_point.re - target_point.re)
+               + (constel_point.im - target_point.im)*(constel_point.im - target_point.im);
         smooth_power = 0.95f*smooth_power + 0.05f*fpower;
 #if defined(ENABLE_GUI)
         if (use_gui)
         {
-#if defined(SPANDSP_USE_FIXED_POINT)
-            constel_point.re = constel->re/4096.0;
-            constel_point.im = constel->im/4096.0;
             qam_monitor_update_constel(qam_monitor, &constel_point);
-#else
-            qam_monitor_update_constel(qam_monitor, constel);
-#endif
             qam_monitor_update_carrier_tracking(qam_monitor, v17_rx_carrier_frequency(rx));
             qam_monitor_update_symbol_tracking(qam_monitor, v17_rx_symbol_timing_correction(rx));
         }
 #endif
         printf("%8d [%8.4f, %8.4f] [%8.4f, %8.4f] %2x %8.4f %8.4f %9.4f %7.3f %7.4f\n",
                symbol_no,
-#if defined(SPANDSP_USE_FIXED_POINT)
-               constel->re/4096.0,
-               constel->im/4096.0,
-               target->re/4096.0,
-               target->im/4096.0,
-#else
-               constel->re,
-               constel->im,
-               target->re,
-               target->im,
-#endif
+               constel_point.re,
+               constel_point.im,
+               target_point.re,
+               target_point.im,
                symbol,
                fpower,
                smooth_power,
                v17_rx_carrier_frequency(rx),
                v17_rx_signal_power(rx),
                v17_rx_symbol_timing_correction(rx));
-        //printf("Carrier %d %f %f\n", symbol_no, v17_rx_carrier_frequency(rx), v17_rx_symbol_timing_correction(rx));
         symbol_no++;
         if (--update_interval <= 0)
         {
-            len = v17_rx_equalizer_state(rx, &coeffs);
-            printf("Equalizer A:\n");
-            for (i = 0;  i < len;  i++)
+            if ((len = v17_rx_equalizer_state(rx, &coeffs)))
+            {
+                printf("Equalizer A:\n");
+                for (i = 0;  i < len;  i++)
 #if defined(SPANDSP_USE_FIXED_POINT)
-                printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/4096.0f, coeffs[i].im/4096.0f);
+                    printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V17_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V17_CONSTELLATION_SCALING_FACTOR);
 #else
-                printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
+                    printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
 #endif
 #if defined(ENABLE_GUI)
-            if (use_gui)
-            {
+                if (use_gui)
+                {
 #if defined(SPANDSP_USE_FIXED_POINT)
-                qam_monitor_update_int_equalizer(qam_monitor, coeffs, len);
+                    qam_monitor_update_int_equalizer(qam_monitor, coeffs, len);
 #else
-                qam_monitor_update_equalizer(qam_monitor, coeffs, len);
+                    qam_monitor_update_equalizer(qam_monitor, coeffs, len);
 #endif
-            }
+                }
 #endif
+            }
             update_interval = 100;
         }
     }
@@ -481,7 +474,7 @@ int main(int argc, char *argv[])
 #if defined(ENABLE_GUI)
     if (use_gui)
     {
-        qam_monitor = qam_monitor_init(10.0f, NULL);
+        qam_monitor = qam_monitor_init(10.0f, V17_CONSTELLATION_SCALING_FACTOR, NULL);
         if (!decode_test_file)
         {
             start_line_model_monitor(129);
index 23515f40380ba8638aa4d0cd2743de7f9f7a3593..f9604554d094fe43c421e6d54e67b53d37df63fe 100644 (file)
@@ -129,14 +129,16 @@ static void v22bis_rx_status(void *user_data, int status)
     case SIG_STATUS_TRAINING_SUCCEEDED:
         bit_rate = v22bis_get_current_bit_rate(s->v22bis);
         printf("Negotiated bit rate: %d\n", bit_rate);
-        len = v22bis_rx_equalizer_state(s->v22bis, &coeffs);
-        printf("Equalizer:\n");
-        for (i = 0;  i < len;  i++)
+        if ((len = v22bis_rx_equalizer_state(s->v22bis, &coeffs)))
+        {
+            printf("Equalizer:\n");
+            for (i = 0;  i < len;  i++)
 #if defined(SPANDSP_USE_FIXED_POINT)
-            printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/1024.0f, coeffs[i].im/1024.0f);
+                printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V22BIS_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V22BIS_CONSTELLATION_SCALING_FACTOR);
 #else
-            printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
+                printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
 #endif
+        }
         break;
     }
 }
@@ -181,26 +183,25 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex
     int len;
 #if defined(SPANDSP_USE_FIXED_POINT)
     complexi16_t *coeffs;
-    complexf_t constel_point;
 #else
     complexf_t *coeffs;
 #endif
+    complexf_t constel_point;
+    complexf_t target_point;
     float fpower;
     endpoint_t *s;
 
     s = (endpoint_t *) user_data;
     if (constel)
     {
+        constel_point.re = constel->re/V22BIS_CONSTELLATION_SCALING_FACTOR;
+        constel_point.im = constel->im/V22BIS_CONSTELLATION_SCALING_FACTOR;
+        target_point.re = target->re/V22BIS_CONSTELLATION_SCALING_FACTOR;
+        target_point.im = target->im/V22BIS_CONSTELLATION_SCALING_FACTOR;
 #if defined(ENABLE_GUI)
         if (use_gui)
         {
-#if defined(SPANDSP_USE_FIXED_POINT)
-            constel_point.re = constel->re/1024.0;
-            constel_point.im = constel->im/1024.0;
             qam_monitor_update_constel(s->qam_monitor, &constel_point);
-#else
-            qam_monitor_update_constel(s->qam_monitor, constel);
-#endif
             qam_monitor_update_carrier_tracking(s->qam_monitor, v22bis_rx_carrier_frequency(s->v22bis));
             qam_monitor_update_symbol_tracking(s->qam_monitor, v22bis_rx_symbol_timing_correction(s->v22bis));
         }
@@ -211,17 +212,10 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex
 
         printf("%8d [%8.4f, %8.4f] [%8.4f, %8.4f] %2x %8.4f %8.4f %8.4f\n",
                s->symbol_no,
-#if defined(SPANDSP_USE_FIXED_POINT)
-               constel->re/1024.0,
-               constel->im/1024.0,
-               target->re/1024.0,
-               target->im/1024.0,
-#else
-               constel->re,
-               constel->im,
-               target->re,
-               target->im,
-#endif
+               constel_point.re,
+               constel_point.im,
+               target_point.re,
+               target_point.im,
                symbol,
                fpower,
                s->smooth_power,
@@ -231,24 +225,26 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex
     else
     {
         printf("Gardner step %d\n", symbol);
-        len = v22bis_rx_equalizer_state(s->v22bis, &coeffs);
-        printf("Equalizer A:\n");
-        for (i = 0;  i < len;  i++)
+        if ((len = v22bis_rx_equalizer_state(s->v22bis, &coeffs)))
+        {
+            printf("Equalizer A:\n");
+            for (i = 0;  i < len;  i++)
 #if defined(SPANDSP_USE_FIXED_POINT)
-            printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/1024.0f, coeffs[i].im/1024.0f);
+                printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V22BIS_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V22BIS_CONSTELLATION_SCALING_FACTOR);
 #else
-            printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
+                printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
 #endif
 #if defined(ENABLE_GUI)
-        if (use_gui)
-        {
+            if (use_gui)
+            {
 #if defined(SPANDSP_USE_FIXED_POINT)
-            qam_monitor_update_int_equalizer(s->qam_monitor, coeffs, len);
+                qam_monitor_update_int_equalizer(s->qam_monitor, coeffs, len);
 #else
-            qam_monitor_update_equalizer(s->qam_monitor, coeffs, len);
+                qam_monitor_update_equalizer(s->qam_monitor, coeffs, len);
 #endif
-        }
+            }
 #endif
+        }
     }
 }
 /*- End of function --------------------------------------------------------*/
@@ -381,8 +377,8 @@ int main(int argc, char *argv[])
 #if defined(ENABLE_GUI)
     if (use_gui)
     {
-        endpoint[0].qam_monitor = qam_monitor_init(6.0f, "Calling modem");
-        endpoint[1].qam_monitor = qam_monitor_init(6.0f, "Answering modem");
+        endpoint[0].qam_monitor = qam_monitor_init(6.0f, V22BIS_CONSTELLATION_SCALING_FACTOR, "Calling modem");
+        endpoint[1].qam_monitor = qam_monitor_init(6.0f, V22BIS_CONSTELLATION_SCALING_FACTOR, "Answering modem");
     }
 #endif
     if ((model = both_ways_line_model_init(line_model_no,
index 0d63023cc07c274b366c698b6d1a5cb2530d3064..db5a13d29fcc954462fe090e4237aeb14be6e4a6 100644 (file)
@@ -129,14 +129,16 @@ static void v27ter_rx_status(void *user_data, int status)
     switch (status)
     {
     case SIG_STATUS_TRAINING_SUCCEEDED:
-        len = v27ter_rx_equalizer_state(s, &coeffs);
-        printf("Equalizer:\n");
-        for (i = 0;  i < len;  i++)
+        if ((len = v27ter_rx_equalizer_state(s, &coeffs)))
+        {
+            printf("Equalizer:\n");
+            for (i = 0;  i < len;  i++)
 #if defined(SPANDSP_USE_FIXED_POINT)
-            printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/4096.0f, coeffs[i].im/4096.0f);
+                printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V27TER_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V27TER_CONSTELLATION_SCALING_FACTOR);
 #else
-            printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
+                printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
 #endif
+        }
         break;
     }
 }
@@ -179,115 +181,94 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex
     int len;
 #if defined(SPANDSP_USE_FIXED_POINT)
     complexi16_t *coeffs;
-    complexf_t constel_point;
 #else
     complexf_t *coeffs;
 #endif
+    complexf_t constel_point;
+    complexf_t target_point;
     float fpower;
     float error;
     v27ter_rx_state_t *rx;
     static float smooth_power = 0.0f;
-#if defined(ENABLE_GUI)
-    static int reports = 0;
-#endif
+    static int update_interval = 100;
 
     rx = (v27ter_rx_state_t *) user_data;
     if (constel)
     {
-        fpower = (constel->re - target->re)*(constel->re - target->re)
-               + (constel->im - target->im)*(constel->im - target->im);
-#if defined(SPANDSP_USE_FIXED_POINT)
-        fpower /= 1024.0*1024.0;
-#endif
+        constel_point.re = constel->re/V27TER_CONSTELLATION_SCALING_FACTOR;
+        constel_point.im = constel->im/V27TER_CONSTELLATION_SCALING_FACTOR;
+        target_point.re = target->re/V27TER_CONSTELLATION_SCALING_FACTOR;
+        target_point.im = target->im/V27TER_CONSTELLATION_SCALING_FACTOR;
+        fpower = (constel_point.re - target_point.re)*(constel_point.re - target_point.re)
+               + (constel_point.im - target_point.im)*(constel_point.im - target_point.im);
         smooth_power = 0.95f*smooth_power + 0.05f*fpower;
 #if defined(ENABLE_GUI)
         if (use_gui)
         {
-#if defined(SPANDSP_USE_FIXED_POINT)
-            constel_point.re = constel->re/1024.0;
-            constel_point.im = constel->im/1024.0;
             qam_monitor_update_constel(qam_monitor, &constel_point);
-#else
-            qam_monitor_update_constel(qam_monitor, constel);
-#endif
             qam_monitor_update_carrier_tracking(qam_monitor, v27ter_rx_carrier_frequency(rx));
             qam_monitor_update_symbol_tracking(qam_monitor, v27ter_rx_symbol_timing_correction(rx));
         }
 #endif
         error = constel->im*target->re - constel->re*target->im;
-#if defined(SPANDSP_USE_FIXED_POINT)
-        printf("Tracking error %f %f %f %f %f %f\n", error, v27ter_rx_carrier_frequency(rx), constel->re/1024.0, constel->im/1024.0, target->re/1024.0, target->im/1024.0);
-#else
-        printf("Tracking error %f %f %f %f %f %f\n", error, v27ter_rx_carrier_frequency(rx), constel->re, constel->im, target->re, target->im);
-#endif
+        printf("Tracking error %f %f %f %f %f %f\n", error, v27ter_rx_carrier_frequency(rx), constel_point.re, constel_point.im, target_point.re, target_point.im);
         printf("%8d [%8.4f, %8.4f] [%8.4f, %8.4f] %2x %8.4f %8.4f %9.4f %7.3f %7.4f\n",
                symbol_no,
-#if defined(SPANDSP_USE_FIXED_POINT)
-               constel->re/1024.0,
-               constel->im/1024.0,
-               target->re/1024.0,
-               target->im/1024.0,
-#else
-               constel->re,
-               constel->im,
-               target->re,
-               target->im,
-#endif
+               constel_point.re,
+               constel_point.im,
+               target_point.re,
+               target_point.im,
                symbol,
                fpower,
                smooth_power,
                v27ter_rx_carrier_frequency(rx),
                v27ter_rx_signal_power(rx),
                v27ter_rx_symbol_timing_correction(rx));
-        len = v27ter_rx_equalizer_state(rx, &coeffs);
-        printf("Equalizer B:\n");
-        for (i = 0;  i < len;  i++)
-#if defined(SPANDSP_USE_FIXED_POINT)
-            printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/1024.0f, coeffs[i].im/1024.0f);
-#else
-            printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
-#endif
-#if defined(WITH_SPANDSP_INTERNALS)
-        printf("Gardtest %d %f %d\n", symbol_no, v27ter_rx_symbol_timing_correction(rx), rx->gardner_integrate);
-#endif
-        printf("Carcar %d %f\n", symbol_no, v27ter_rx_carrier_frequency(rx));
-#if defined(ENABLE_GUI)
-        if (use_gui)
+        symbol_no++;
+        if (--update_interval <= 0)
         {
-            if (++reports >= 1000)
+            if ((len = v27ter_rx_equalizer_state(rx, &coeffs)))
             {
+                printf("Equalizer B:\n");
+                for (i = 0;  i < len;  i++)
+                    printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V27TER_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V27TER_CONSTELLATION_SCALING_FACTOR);
+#if defined(ENABLE_GUI)
+                if (use_gui)
+                {
 #if defined(SPANDSP_USE_FIXED_POINT)
-                qam_monitor_update_int_equalizer(qam_monitor, coeffs, len);
+                    qam_monitor_update_int_equalizer(qam_monitor, coeffs, len);
 #else
-                qam_monitor_update_equalizer(qam_monitor, coeffs, len);
+                    qam_monitor_update_equalizer(qam_monitor, coeffs, len);
 #endif
-                reports = 0;
+                }
             }
+            update_interval = 100;
         }
 #endif
-        symbol_no++;
     }
     else
     {
         printf("Gardner step %d\n", symbol);
-        len = v27ter_rx_equalizer_state(rx, &coeffs);
-        printf("Equalizer A:\n");
-        for (i = 0;  i < len;  i++)
+        if ((len = v27ter_rx_equalizer_state(rx, &coeffs)))
+        {
+            printf("Equalizer A:\n");
+            for (i = 0;  i < len;  i++)
 #if defined(SPANDSP_USE_FIXED_POINT)
-            printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/1024.0f, coeffs[i].im/1024.0f);
+                printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V27TER_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V27TER_CONSTELLATION_SCALING_FACTOR);
 #else
-            printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
+                printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
 #endif
 #if defined(ENABLE_GUI)
-        if (use_gui)
-        {
+            if (use_gui)
+            {
 #if defined(SPANDSP_USE_FIXED_POINT)
-            qam_monitor_update_int_equalizer(qam_monitor, coeffs, len);
+                qam_monitor_update_int_equalizer(qam_monitor, coeffs, len);
 #else
-            qam_monitor_update_equalizer(qam_monitor, coeffs, len);
+                qam_monitor_update_equalizer(qam_monitor, coeffs, len);
 #endif
-        }
+            }
 #endif
+        }
     }
 }
 /*- End of function --------------------------------------------------------*/
@@ -497,7 +478,7 @@ int main(int argc, char *argv[])
 #if defined(ENABLE_GUI)
     if (use_gui)
     {
-        qam_monitor = qam_monitor_init(2.0f, NULL);
+        qam_monitor = qam_monitor_init(2.0f, V27TER_CONSTELLATION_SCALING_FACTOR, NULL);
         if (!decode_test_file)
         {
             start_line_model_monitor(129);
index 1252a4fc4bb8af0f317e54508248330794ffe1dd..c7335b08ec30b82bb04dfbd7fabf63ab9dd316c3 100644 (file)
@@ -129,14 +129,16 @@ static void v29_rx_status(void *user_data, int status)
     {
     case SIG_STATUS_TRAINING_SUCCEEDED:
         printf("Training succeeded\n");
-        len = v29_rx_equalizer_state(s, &coeffs);
-        printf("Equalizer:\n");
-        for (i = 0;  i < len;  i++)
+        if ((len = v29_rx_equalizer_state(s, &coeffs)))
+        {
+            printf("Equalizer:\n");
+            for (i = 0;  i < len;  i++)
 #if defined(SPANDSP_USE_FIXED_POINT)
-            printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/4096.0f, coeffs[i].im/4096.0f);
+                printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V29_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V29_CONSTELLATION_SCALING_FACTOR);
 #else
-            printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
+                printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
 #endif
+        }
         break;
     }
 }
@@ -179,10 +181,11 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex
     int len;
 #if defined(SPANDSP_USE_FIXED_POINT)
     complexi16_t *coeffs;
-    complexf_t constel_point;
 #else
     complexf_t *coeffs;
 #endif
+    complexf_t constel_point;
+    complexf_t target_point;
     float fpower;
     v29_rx_state_t *rx;
     static float smooth_power = 0.0f;
@@ -191,22 +194,17 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex
     rx = (v29_rx_state_t *) user_data;
     if (constel)
     {
-        fpower = (constel->re - target->re)*(constel->re - target->re)
-               + (constel->im - target->im)*(constel->im - target->im);
-#if defined(SPANDSP_USE_FIXED_POINT)
-        fpower /= 4096.0*4096.0;
-#endif
+        constel_point.re = constel->re/V29_CONSTELLATION_SCALING_FACTOR;
+        constel_point.im = constel->im/V29_CONSTELLATION_SCALING_FACTOR;
+        target_point.re = target->re/V29_CONSTELLATION_SCALING_FACTOR,
+        target_point.im = target->im/V29_CONSTELLATION_SCALING_FACTOR,
+        fpower = (constel_point.re - target_point.re)*(constel_point.re - target_point.re)
+               + (constel_point.im - target_point.im)*(constel_point.im - target_point.im);
         smooth_power = 0.95f*smooth_power + 0.05f*fpower;
 #if defined(ENABLE_GUI)
         if (use_gui)
         {
-#if defined(SPANDSP_USE_FIXED_POINT)
-            constel_point.re = constel->re/4096.0;
-            constel_point.im = constel->im/4096.0;
             qam_monitor_update_constel(qam_monitor, &constel_point);
-#else
-            qam_monitor_update_constel(qam_monitor, constel);
-#endif
             qam_monitor_update_carrier_tracking(qam_monitor, v29_rx_carrier_frequency(rx));
             //qam_monitor_update_carrier_tracking(qam_monitor, (fpower)  ?  fpower  :  0.001f);
             qam_monitor_update_symbol_tracking(qam_monitor, v29_rx_symbol_timing_correction(rx));
@@ -214,17 +212,10 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex
 #endif
         printf("%8d [%8.4f, %8.4f] [%8.4f, %8.4f] %2x %8.4f %8.4f %9.4f %7.3f %7.4f\n",
                symbol_no,
-#if defined(SPANDSP_USE_FIXED_POINT)
-               constel->re/4096.0,
-               constel->im/4096.0,
-               target->re/4096.0,
-               target->im/4096.0,
-#else
-               constel->re,
-               constel->im,
-               target->re,
-               target->im,
-#endif
+               constel_point.re,
+               constel_point.im,
+               target_point.re,
+               target_point.im,
                symbol,
                fpower,
                smooth_power,
@@ -234,24 +225,26 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex
         symbol_no++;
         if (--update_interval <= 0)
         {
-            len = v29_rx_equalizer_state(rx, &coeffs);
-            printf("Equalizer A:\n");
-            for (i = 0;  i < len;  i++)
+            if ((len = v29_rx_equalizer_state(rx, &coeffs)))
+            {
+                printf("Equalizer A:\n");
+                for (i = 0;  i < len;  i++)
 #if defined(SPANDSP_USE_FIXED_POINT)
-                printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/4096.0f, coeffs[i].im/4096.0f);
+                    printf("%3d (%15.5f, %15.5f)\n", i, coeffs[i].re/V29_CONSTELLATION_SCALING_FACTOR, coeffs[i].im/V29_CONSTELLATION_SCALING_FACTOR);
 #else
-                printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
+                    printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i]));
 #endif
 #if defined(ENABLE_GUI)
-            if (use_gui)
-            {
+                if (use_gui)
+                {
 #if defined(SPANDSP_USE_FIXED_POINT)
-                qam_monitor_update_int_equalizer(qam_monitor, coeffs, len);
+                    qam_monitor_update_int_equalizer(qam_monitor, coeffs, len);
 #else
-                qam_monitor_update_equalizer(qam_monitor, coeffs, len);
+                    qam_monitor_update_equalizer(qam_monitor, coeffs, len);
 #endif
-            }
+                }
 #endif
+            }
             update_interval = 100;
         }
     }
@@ -470,7 +463,7 @@ int main(int argc, char *argv[])
 #if defined(ENABLE_GUI)
     if (use_gui)
     {
-        qam_monitor = qam_monitor_init(6.0f, NULL);
+        qam_monitor = qam_monitor_init(6.0f, V29_CONSTELLATION_SCALING_FACTOR, NULL);
         if (!decode_test_file)
         {
             start_line_model_monitor(129);