Fix fixed point builds of spandsp, and improve logging of modem performance during tests

This commit is contained in:
Steve Underwood 2012-08-05 22:20:39 +08:00
parent 72566f6a3f
commit 04e93f4c0b
11 changed files with 197 additions and 207 deletions

View 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. 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 V.17 modem receive side descriptor. This defines the working state for a
single instance of a V.17 modem receiver. single instance of a V.17 modem receiver.

View File

@ -48,6 +48,12 @@ or 1200bps if one or both ends to not acknowledge that 2400bps is OK.
#if !defined(_SPANDSP_V22BIS_H_) #if !defined(_SPANDSP_V22BIS_H_)
#define _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 enum
{ {
V22BIS_GUARD_TONE_NONE, V22BIS_GUARD_TONE_NONE,

View File

@ -44,6 +44,12 @@ at the start of transmission, which makes the design of a V.27ter receiver relat
straightforward. 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 V.27ter modem receive side descriptor. This defines the working state for a
single instance of a V.27ter modem receiver. single instance of a V.27ter modem receiver.

View 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. 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) #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); typedef void (*qam_report_handler_t)(void *user_data, const complexi16_t *constel, const complexi16_t *target, int symbol);
#else #else

View 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) #if defined(SPANDSP_USE_FIXED_POINT)
*coeffs = NULL; *coeffs = NULL;
return 0;
#else #else
*coeffs = s->eq_coeff; *coeffs = s->eq_coeff;
#endif
return V17_EQUALIZER_LEN; return V17_EQUALIZER_LEN;
#endif
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/

View File

@ -52,10 +52,10 @@
#define SYMBOL_TRACKER_POINTS 12000 #define SYMBOL_TRACKER_POINTS 12000
#define CARRIER_TRACKER_POINTS 12000 #define CARRIER_TRACKER_POINTS 12000
#define FP_FACTOR 4096
struct qam_monitor_s struct qam_monitor_s
{ {
float constel_scaling;
Fl_Double_Window *w; Fl_Double_Window *w;
Fl_Group *c_const; Fl_Group *c_const;
Fl_Group *c_right; 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++) for (i = 0; i < len; i++)
{ {
s->eq_re_plot[2*i] = (i - len/2)/2.0; 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) if (min > coeffs[i].re)
min = coeffs[i].re; min = coeffs[i].re;
if (max < coeffs[i].re) if (max < coeffs[i].re)
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] = (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) if (min > coeffs[i].im)
min = coeffs[i].im; min = coeffs[i].im;
if (max < 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; max = coeffs[i].im;
for (i = 0; i < len; i++) 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) if (min > coeffs[i].re)
min = coeffs[i].re; min = coeffs[i].re;
if (max < coeffs[i].re) if (max < coeffs[i].re)
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) if (min > coeffs[i].im)
min = coeffs[i].im; min = coeffs[i].im;
if (max < coeffs[i].im) if (max < coeffs[i].im)
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; min *= s->constel_scaling;
max /= (float) FP_FACTOR; max *= s->constel_scaling;
s->eq_x->minimum(-len/4.0); s->eq_x->minimum(-len/4.0);
s->eq_x->maximum(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]; max = s->symbol_tracker[0];
for (i = s->symbol_track_ptr, j = 0; i < s->symbol_track_points; i++, j++) 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]) if (min > s->symbol_tracker[i])
min = s->symbol_tracker[i]; min = s->symbol_tracker[i];
if (max < s->symbol_tracker[i]) if (max < s->symbol_tracker[i])
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++) 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]) if (min > s->symbol_tracker[i])
min = s->symbol_tracker[i]; min = s->symbol_tracker[i];
if (max < s->symbol_tracker[i]) if (max < s->symbol_tracker[i])
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->maximum((fabs(max - min) < 0.05) ? max + 0.05 : max);
s->symbol_track_y->minimum(min); 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 --------------------------------------------------------*/ /*- 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]; char buf[132 + 1];
float x; 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->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 = new Fl_Group(0, 0, 380, 400);
s->c_const->box(FL_DOWN_BOX); s->c_const->box(FL_DOWN_BOX);
s->c_const->align(FL_ALIGN_TOP | FL_ALIGN_INSIDE); s->c_const->align(FL_ALIGN_TOP | FL_ALIGN_INSIDE);

View File

@ -50,7 +50,7 @@ extern "C"
{ {
#endif #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_clear_constel(qam_monitor_t *s);
int qam_monitor_update_constel(qam_monitor_t *s, const complexf_t *pt); 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); int qam_monitor_update_equalizer(qam_monitor_t *s, const complexf_t *coeffs, int len);

View File

@ -133,14 +133,17 @@ static void v17_rx_status(void *user_data, int status)
switch (status) switch (status)
{ {
case SIG_STATUS_TRAINING_SUCCEEDED: case SIG_STATUS_TRAINING_SUCCEEDED:
len = v17_rx_equalizer_state(s, &coeffs); printf("Training succeeded\n");
printf("Equalizer:\n"); if ((len = v17_rx_equalizer_state(s, &coeffs)))
for (i = 0; i < len; i++) {
printf("Equalizer:\n");
for (i = 0; i < len; i++)
#if defined(SPANDSP_USE_FIXED_POINT) #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 #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 #endif
}
break; break;
} }
} }
@ -183,10 +186,11 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex
int len; int len;
#if defined(SPANDSP_USE_FIXED_POINT) #if defined(SPANDSP_USE_FIXED_POINT)
complexi16_t *coeffs; complexi16_t *coeffs;
complexf_t constel_point;
#else #else
complexf_t *coeffs; complexf_t *coeffs;
#endif #endif
complexf_t constel_point;
complexf_t target_point;
float fpower; float fpower;
v17_rx_state_t *rx; v17_rx_state_t *rx;
static float smooth_power = 0.0f; 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; rx = (v17_rx_state_t *) user_data;
if (constel) if (constel)
{ {
fpower = (constel->re - target->re)*(constel->re - target->re) constel_point.re = constel->re/V17_CONSTELLATION_SCALING_FACTOR;
+ (constel->im - target->im)*(constel->im - target->im); constel_point.im = constel->im/V17_CONSTELLATION_SCALING_FACTOR;
#if defined(SPANDSP_USE_FIXED_POINT) target_point.re = target->re/V17_CONSTELLATION_SCALING_FACTOR,
fpower /= 4096.0*4096.0; target_point.im = target->im/V17_CONSTELLATION_SCALING_FACTOR,
#endif 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; smooth_power = 0.95f*smooth_power + 0.05f*fpower;
#if defined(ENABLE_GUI) #if defined(ENABLE_GUI)
if (use_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); 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_carrier_tracking(qam_monitor, v17_rx_carrier_frequency(rx));
qam_monitor_update_symbol_tracking(qam_monitor, v17_rx_symbol_timing_correction(rx)); qam_monitor_update_symbol_tracking(qam_monitor, v17_rx_symbol_timing_correction(rx));
} }
#endif #endif
printf("%8d [%8.4f, %8.4f] [%8.4f, %8.4f] %2x %8.4f %8.4f %9.4f %7.3f %7.4f\n", printf("%8d [%8.4f, %8.4f] [%8.4f, %8.4f] %2x %8.4f %8.4f %9.4f %7.3f %7.4f\n",
symbol_no, symbol_no,
#if defined(SPANDSP_USE_FIXED_POINT) constel_point.re,
constel->re/4096.0, constel_point.im,
constel->im/4096.0, target_point.re,
target->re/4096.0, target_point.im,
target->im/4096.0,
#else
constel->re,
constel->im,
target->re,
target->im,
#endif
symbol, symbol,
fpower, fpower,
smooth_power, smooth_power,
v17_rx_carrier_frequency(rx), v17_rx_carrier_frequency(rx),
v17_rx_signal_power(rx), v17_rx_signal_power(rx),
v17_rx_symbol_timing_correction(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++; symbol_no++;
if (--update_interval <= 0) if (--update_interval <= 0)
{ {
len = v17_rx_equalizer_state(rx, &coeffs); if ((len = v17_rx_equalizer_state(rx, &coeffs)))
printf("Equalizer A:\n"); {
for (i = 0; i < len; i++) printf("Equalizer A:\n");
for (i = 0; i < len; i++)
#if defined(SPANDSP_USE_FIXED_POINT) #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 #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 #endif
#if defined(ENABLE_GUI) #if defined(ENABLE_GUI)
if (use_gui) if (use_gui)
{ {
#if defined(SPANDSP_USE_FIXED_POINT) #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 #else
qam_monitor_update_equalizer(qam_monitor, coeffs, len); qam_monitor_update_equalizer(qam_monitor, coeffs, len);
#endif
}
#endif #endif
} }
#endif
update_interval = 100; update_interval = 100;
} }
} }
@ -481,7 +474,7 @@ int main(int argc, char *argv[])
#if defined(ENABLE_GUI) #if defined(ENABLE_GUI)
if (use_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) if (!decode_test_file)
{ {
start_line_model_monitor(129); start_line_model_monitor(129);

View File

@ -129,14 +129,16 @@ static void v22bis_rx_status(void *user_data, int status)
case SIG_STATUS_TRAINING_SUCCEEDED: case SIG_STATUS_TRAINING_SUCCEEDED:
bit_rate = v22bis_get_current_bit_rate(s->v22bis); bit_rate = v22bis_get_current_bit_rate(s->v22bis);
printf("Negotiated bit rate: %d\n", bit_rate); printf("Negotiated bit rate: %d\n", bit_rate);
len = v22bis_rx_equalizer_state(s->v22bis, &coeffs); if ((len = v22bis_rx_equalizer_state(s->v22bis, &coeffs)))
printf("Equalizer:\n"); {
for (i = 0; i < len; i++) printf("Equalizer:\n");
for (i = 0; i < len; i++)
#if defined(SPANDSP_USE_FIXED_POINT) #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 #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 #endif
}
break; break;
} }
} }
@ -181,26 +183,25 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex
int len; int len;
#if defined(SPANDSP_USE_FIXED_POINT) #if defined(SPANDSP_USE_FIXED_POINT)
complexi16_t *coeffs; complexi16_t *coeffs;
complexf_t constel_point;
#else #else
complexf_t *coeffs; complexf_t *coeffs;
#endif #endif
complexf_t constel_point;
complexf_t target_point;
float fpower; float fpower;
endpoint_t *s; endpoint_t *s;
s = (endpoint_t *) user_data; s = (endpoint_t *) user_data;
if (constel) 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 defined(ENABLE_GUI)
if (use_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); 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_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)); 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", printf("%8d [%8.4f, %8.4f] [%8.4f, %8.4f] %2x %8.4f %8.4f %8.4f\n",
s->symbol_no, s->symbol_no,
#if defined(SPANDSP_USE_FIXED_POINT) constel_point.re,
constel->re/1024.0, constel_point.im,
constel->im/1024.0, target_point.re,
target->re/1024.0, target_point.im,
target->im/1024.0,
#else
constel->re,
constel->im,
target->re,
target->im,
#endif
symbol, symbol,
fpower, fpower,
s->smooth_power, s->smooth_power,
@ -231,24 +225,26 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex
else else
{ {
printf("Gardner step %d\n", symbol); printf("Gardner step %d\n", symbol);
len = v22bis_rx_equalizer_state(s->v22bis, &coeffs); if ((len = v22bis_rx_equalizer_state(s->v22bis, &coeffs)))
printf("Equalizer A:\n"); {
for (i = 0; i < len; i++) printf("Equalizer A:\n");
for (i = 0; i < len; i++)
#if defined(SPANDSP_USE_FIXED_POINT) #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 #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 #endif
#if defined(ENABLE_GUI) #if defined(ENABLE_GUI)
if (use_gui) if (use_gui)
{ {
#if defined(SPANDSP_USE_FIXED_POINT) #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 #else
qam_monitor_update_equalizer(s->qam_monitor, coeffs, len); qam_monitor_update_equalizer(s->qam_monitor, coeffs, len);
#endif
}
#endif #endif
} }
#endif
} }
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
@ -381,8 +377,8 @@ int main(int argc, char *argv[])
#if defined(ENABLE_GUI) #if defined(ENABLE_GUI)
if (use_gui) if (use_gui)
{ {
endpoint[0].qam_monitor = qam_monitor_init(6.0f, "Calling 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, "Answering modem"); endpoint[1].qam_monitor = qam_monitor_init(6.0f, V22BIS_CONSTELLATION_SCALING_FACTOR, "Answering modem");
} }
#endif #endif
if ((model = both_ways_line_model_init(line_model_no, if ((model = both_ways_line_model_init(line_model_no,

View File

@ -129,14 +129,16 @@ static void v27ter_rx_status(void *user_data, int status)
switch (status) switch (status)
{ {
case SIG_STATUS_TRAINING_SUCCEEDED: case SIG_STATUS_TRAINING_SUCCEEDED:
len = v27ter_rx_equalizer_state(s, &coeffs); if ((len = v27ter_rx_equalizer_state(s, &coeffs)))
printf("Equalizer:\n"); {
for (i = 0; i < len; i++) printf("Equalizer:\n");
for (i = 0; i < len; i++)
#if defined(SPANDSP_USE_FIXED_POINT) #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 #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 #endif
}
break; break;
} }
} }
@ -179,115 +181,94 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex
int len; int len;
#if defined(SPANDSP_USE_FIXED_POINT) #if defined(SPANDSP_USE_FIXED_POINT)
complexi16_t *coeffs; complexi16_t *coeffs;
complexf_t constel_point;
#else #else
complexf_t *coeffs; complexf_t *coeffs;
#endif #endif
complexf_t constel_point;
complexf_t target_point;
float fpower; float fpower;
float error; float error;
v27ter_rx_state_t *rx; v27ter_rx_state_t *rx;
static float smooth_power = 0.0f; static float smooth_power = 0.0f;
#if defined(ENABLE_GUI) static int update_interval = 100;
static int reports = 0;
#endif
rx = (v27ter_rx_state_t *) user_data; rx = (v27ter_rx_state_t *) user_data;
if (constel) if (constel)
{ {
fpower = (constel->re - target->re)*(constel->re - target->re) constel_point.re = constel->re/V27TER_CONSTELLATION_SCALING_FACTOR;
+ (constel->im - target->im)*(constel->im - target->im); constel_point.im = constel->im/V27TER_CONSTELLATION_SCALING_FACTOR;
#if defined(SPANDSP_USE_FIXED_POINT) target_point.re = target->re/V27TER_CONSTELLATION_SCALING_FACTOR;
fpower /= 1024.0*1024.0; target_point.im = target->im/V27TER_CONSTELLATION_SCALING_FACTOR;
#endif 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; smooth_power = 0.95f*smooth_power + 0.05f*fpower;
#if defined(ENABLE_GUI) #if defined(ENABLE_GUI)
if (use_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); 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_carrier_tracking(qam_monitor, v27ter_rx_carrier_frequency(rx));
qam_monitor_update_symbol_tracking(qam_monitor, v27ter_rx_symbol_timing_correction(rx)); qam_monitor_update_symbol_tracking(qam_monitor, v27ter_rx_symbol_timing_correction(rx));
} }
#endif #endif
error = constel->im*target->re - constel->re*target->im; 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_point.re, constel_point.im, target_point.re, target_point.im);
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("%8d [%8.4f, %8.4f] [%8.4f, %8.4f] %2x %8.4f %8.4f %9.4f %7.3f %7.4f\n", printf("%8d [%8.4f, %8.4f] [%8.4f, %8.4f] %2x %8.4f %8.4f %9.4f %7.3f %7.4f\n",
symbol_no, symbol_no,
#if defined(SPANDSP_USE_FIXED_POINT) constel_point.re,
constel->re/1024.0, constel_point.im,
constel->im/1024.0, target_point.re,
target->re/1024.0, target_point.im,
target->im/1024.0,
#else
constel->re,
constel->im,
target->re,
target->im,
#endif
symbol, symbol,
fpower, fpower,
smooth_power, smooth_power,
v27ter_rx_carrier_frequency(rx), v27ter_rx_carrier_frequency(rx),
v27ter_rx_signal_power(rx), v27ter_rx_signal_power(rx),
v27ter_rx_symbol_timing_correction(rx)); v27ter_rx_symbol_timing_correction(rx));
len = v27ter_rx_equalizer_state(rx, &coeffs); symbol_no++;
printf("Equalizer B:\n"); if (--update_interval <= 0)
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)
{ {
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);
#else
qam_monitor_update_equalizer(qam_monitor, coeffs, len);
#endif
}
}
update_interval = 100;
}
#endif
}
else
{
printf("Gardner step %d\n", symbol);
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/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]));
#endif
#if defined(ENABLE_GUI)
if (use_gui)
{ {
#if defined(SPANDSP_USE_FIXED_POINT) #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 #else
qam_monitor_update_equalizer(qam_monitor, coeffs, len); qam_monitor_update_equalizer(qam_monitor, coeffs, len);
#endif #endif
reports = 0;
} }
}
#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 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(ENABLE_GUI)
if (use_gui)
{
#if defined(SPANDSP_USE_FIXED_POINT)
qam_monitor_update_int_equalizer(qam_monitor, coeffs, len);
#else
qam_monitor_update_equalizer(qam_monitor, coeffs, len);
#endif #endif
} }
#endif
} }
} }
/*- End of function --------------------------------------------------------*/ /*- End of function --------------------------------------------------------*/
@ -497,7 +478,7 @@ int main(int argc, char *argv[])
#if defined(ENABLE_GUI) #if defined(ENABLE_GUI)
if (use_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) if (!decode_test_file)
{ {
start_line_model_monitor(129); start_line_model_monitor(129);

View File

@ -129,14 +129,16 @@ static void v29_rx_status(void *user_data, int status)
{ {
case SIG_STATUS_TRAINING_SUCCEEDED: case SIG_STATUS_TRAINING_SUCCEEDED:
printf("Training succeeded\n"); printf("Training succeeded\n");
len = v29_rx_equalizer_state(s, &coeffs); if ((len = v29_rx_equalizer_state(s, &coeffs)))
printf("Equalizer:\n"); {
for (i = 0; i < len; i++) printf("Equalizer:\n");
for (i = 0; i < len; i++)
#if defined(SPANDSP_USE_FIXED_POINT) #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 #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 #endif
}
break; break;
} }
} }
@ -179,10 +181,11 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex
int len; int len;
#if defined(SPANDSP_USE_FIXED_POINT) #if defined(SPANDSP_USE_FIXED_POINT)
complexi16_t *coeffs; complexi16_t *coeffs;
complexf_t constel_point;
#else #else
complexf_t *coeffs; complexf_t *coeffs;
#endif #endif
complexf_t constel_point;
complexf_t target_point;
float fpower; float fpower;
v29_rx_state_t *rx; v29_rx_state_t *rx;
static float smooth_power = 0.0f; 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; rx = (v29_rx_state_t *) user_data;
if (constel) if (constel)
{ {
fpower = (constel->re - target->re)*(constel->re - target->re) constel_point.re = constel->re/V29_CONSTELLATION_SCALING_FACTOR;
+ (constel->im - target->im)*(constel->im - target->im); constel_point.im = constel->im/V29_CONSTELLATION_SCALING_FACTOR;
#if defined(SPANDSP_USE_FIXED_POINT) target_point.re = target->re/V29_CONSTELLATION_SCALING_FACTOR,
fpower /= 4096.0*4096.0; target_point.im = target->im/V29_CONSTELLATION_SCALING_FACTOR,
#endif 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; smooth_power = 0.95f*smooth_power + 0.05f*fpower;
#if defined(ENABLE_GUI) #if defined(ENABLE_GUI)
if (use_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); 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, v29_rx_carrier_frequency(rx));
//qam_monitor_update_carrier_tracking(qam_monitor, (fpower) ? fpower : 0.001f); //qam_monitor_update_carrier_tracking(qam_monitor, (fpower) ? fpower : 0.001f);
qam_monitor_update_symbol_tracking(qam_monitor, v29_rx_symbol_timing_correction(rx)); 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 #endif
printf("%8d [%8.4f, %8.4f] [%8.4f, %8.4f] %2x %8.4f %8.4f %9.4f %7.3f %7.4f\n", printf("%8d [%8.4f, %8.4f] [%8.4f, %8.4f] %2x %8.4f %8.4f %9.4f %7.3f %7.4f\n",
symbol_no, symbol_no,
#if defined(SPANDSP_USE_FIXED_POINT) constel_point.re,
constel->re/4096.0, constel_point.im,
constel->im/4096.0, target_point.re,
target->re/4096.0, target_point.im,
target->im/4096.0,
#else
constel->re,
constel->im,
target->re,
target->im,
#endif
symbol, symbol,
fpower, fpower,
smooth_power, smooth_power,
@ -234,24 +225,26 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex
symbol_no++; symbol_no++;
if (--update_interval <= 0) if (--update_interval <= 0)
{ {
len = v29_rx_equalizer_state(rx, &coeffs); if ((len = v29_rx_equalizer_state(rx, &coeffs)))
printf("Equalizer A:\n"); {
for (i = 0; i < len; i++) printf("Equalizer A:\n");
for (i = 0; i < len; i++)
#if defined(SPANDSP_USE_FIXED_POINT) #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 #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 #endif
#if defined(ENABLE_GUI) #if defined(ENABLE_GUI)
if (use_gui) if (use_gui)
{ {
#if defined(SPANDSP_USE_FIXED_POINT) #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 #else
qam_monitor_update_equalizer(qam_monitor, coeffs, len); qam_monitor_update_equalizer(qam_monitor, coeffs, len);
#endif
}
#endif #endif
} }
#endif
update_interval = 100; update_interval = 100;
} }
} }
@ -470,7 +463,7 @@ int main(int argc, char *argv[])
#if defined(ENABLE_GUI) #if defined(ENABLE_GUI)
if (use_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) if (!decode_test_file)
{ {
start_line_model_monitor(129); start_line_model_monitor(129);