Skip to content

Commit 933d40d

Browse files
committed
V.29 and V.17 now use the Godard TED module, and their internal Godard TED code has been removed.o
1 parent 39cd63d commit 933d40d

File tree

10 files changed

+42
-284
lines changed

10 files changed

+42
-284
lines changed

src/fax.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
#include "spandsp/fsk.h"
7474
#include "spandsp/modem_connect_tones.h"
7575
#include "spandsp/v8.h"
76+
#include "spandsp/godard.h"
7677
#include "spandsp/v29tx.h"
7778
#include "spandsp/v29rx.h"
7879
#include "spandsp/v27ter_tx.h"
@@ -111,6 +112,7 @@
111112
#include "spandsp/private/fsk.h"
112113
#include "spandsp/private/modem_connect_tones.h"
113114
#include "spandsp/private/v8.h"
115+
#include "spandsp/private/godard.h"
114116
#if defined(SPANDSP_SUPPORT_V34)
115117
#include "spandsp/private/bitstream.h"
116118
#include "spandsp/private/v34.h"

src/fax_modems.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#include "spandsp/hdlc.h"
7070
#include "spandsp/silence_gen.h"
7171
#include "spandsp/fsk.h"
72+
#include "spandsp/godard.h"
7273
#include "spandsp/v29tx.h"
7374
#include "spandsp/v29rx.h"
7475
#include "spandsp/v27ter_tx.h"
@@ -88,6 +89,7 @@
8889
#include "spandsp/private/power_meter.h"
8990
#include "spandsp/private/modem_echo.h"
9091
#include "spandsp/private/fsk.h"
92+
#include "spandsp/private/godard.h"
9193
#if defined(SPANDSP_SUPPORT_V34)
9294
#include "spandsp/private/v34.h"
9395
#endif

src/make_modem_godard_descriptor.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*
22
* SpanDSP - a series of DSP components for telephony
33
*
4-
* make_modem_godard_coefficients.c - Create coefficient sets for Godard
5-
* symbol sync. filters as a pair of
6-
* fixed and floating point descriptor
7-
* structures for spandsp.
4+
* make_modem_godard_descriptor.c - Create coefficient sets for Godard
5+
* symbol sync. filters as a pair of
6+
* fixed and floating point descriptor
7+
* structures for spandsp.
88
*
99
* Written by Steve Underwood <[email protected]>
1010
*
@@ -154,7 +154,7 @@ int main(int argc, char **argv)
154154
printf(" FILE MAY BE OVERWRITTEN DURING FUTURE BUILDS OF THE SOFTWARE */\n");
155155
printf("\n");
156156
printf("\n");
157-
printf("static const godard_timing_sync_descriptor_t godard_desc =\n");
157+
printf("static const godard_ted_descriptor_t godard_desc =\n");
158158
printf("{\n");
159159
printf(" /* %.1f samples/second , %.1fHz carrier, %.1f baud, %.3f alpha */\n",
160160
sample_rate,

src/spandsp/private/v17rx.h

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,6 @@ struct v17_rx_state_s
8686
/*! \brief The equalizer signal buffer. */
8787
complexi16_t eq_buf[V17_EQUALIZER_LEN];
8888

89-
/*! Low band edge filter for symbol sync. */
90-
int32_t symbol_sync_low[2];
91-
/*! High band edge filter for symbol sync. */
92-
int32_t symbol_sync_high[2];
93-
/*! DC filter for symbol sync. */
94-
int32_t symbol_sync_dc_filter[2];
95-
/*! Baud phase for symbol sync. */
96-
int32_t baud_phase;
97-
9889
/*! \brief A measure of how much mismatch there is between the real constellation,
9990
and the decoded symbol positions. */
10091
int64_t training_error;
@@ -123,15 +114,6 @@ struct v17_rx_state_s
123114
/*! \brief The equalizer signal buffer. */
124115
complexf_t eq_buf[V17_EQUALIZER_LEN];
125116

126-
/*! Low band edge filter for symbol sync. */
127-
float symbol_sync_low[2];
128-
/*! High band edge filter for symbol sync. */
129-
float symbol_sync_high[2];
130-
/*! DC filter for symbol sync. */
131-
float symbol_sync_dc_filter[2];
132-
/*! Baud phase for symbol sync. */
133-
float baud_phase;
134-
135117
/*! \brief A measure of how much mismatch there is between the real constellation,
136118
and the decoded symbol positions. */
137119
float training_error;
@@ -146,6 +128,8 @@ struct v17_rx_state_s
146128
/*! \brief A pointer to the current constellation. */
147129
const complexf_t *constellation;
148130
#endif
131+
godard_ted_state_t godard;
132+
149133
/*! \brief Current offset into the RRC pulse shaping filter buffer. */
150134
int rrc_filter_step;
151135

@@ -197,10 +181,6 @@ struct v17_rx_state_s
197181
/*! \brief The current half of the baud. */
198182
int baud_half;
199183

200-
/*! \brief The total symbol timing correction since the carrier came up.
201-
This is only for performance analysis purposes. */
202-
int total_baud_timing_correction;
203-
204184
/*! \brief The previous symbol phase angles for the coarse carrier aquisition step. */
205185
int32_t last_angles[2];
206186
/*! \brief History list of phase angle differences for the coarse carrier aquisition step. */

src/spandsp/private/v29rx.h

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,6 @@ struct v29_rx_state_s
7676
/*! \brief The equalizer signal buffer. */
7777
complexi16_t eq_buf[V29_EQUALIZER_LEN];
7878

79-
/*! Low band edge filter for symbol sync. */
80-
int32_t symbol_sync_low[2];
81-
/*! High band edge filter for symbol sync. */
82-
int32_t symbol_sync_high[2];
83-
/*! DC filter for symbol sync. */
84-
int32_t symbol_sync_dc_filter[2];
85-
/*! Baud phase for symbol sync. */
86-
int32_t baud_phase;
87-
8879
/*! \brief A measure of how much mismatch there is between the real constellation,
8980
and the decoded symbol positions. */
9081
int32_t training_error;
@@ -110,15 +101,6 @@ struct v29_rx_state_s
110101
/*! \brief The equalizer signal buffer. */
111102
complexf_t eq_buf[V29_EQUALIZER_LEN];
112103

113-
/*! Low band edge filter for symbol sync. */
114-
float symbol_sync_low[2];
115-
/*! High band edge filter for symbol sync. */
116-
float symbol_sync_high[2];
117-
/*! DC filter for symbol sync. */
118-
float symbol_sync_dc_filter[2];
119-
/*! Baud phase for symbol sync. */
120-
float baud_phase;
121-
122104
/*! \brief A measure of how much mismatch there is between the real constellation,
123105
and the decoded symbol positions. */
124106
float training_error;
@@ -130,6 +112,8 @@ struct v29_rx_state_s
130112
/*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */
131113
float rrc_filter[V29_RX_FILTER_STEPS];
132114
#endif
115+
godard_ted_state_t godard;
116+
133117
/*! \brief Current offset into the RRC pulse shaping filter buffer. */
134118
int rrc_filter_step;
135119

@@ -180,10 +164,6 @@ struct v29_rx_state_s
180164
/*! \brief The current half of the baud. */
181165
int baud_half;
182166

183-
/*! \brief The total symbol timing correction since the carrier came up.
184-
This is only for performance analysis purposes. */
185-
int total_baud_timing_correction;
186-
187167
/*! \brief The previous symbol phase angles for the coarse carrier aquisition step. */
188168
int32_t last_angles[2];
189169
/*! \brief History list of phase angle differences for the coarse carrier aquisition step. */

src/t31.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
#include "spandsp/super_tone_rx.h"
7676
#include "spandsp/fsk.h"
7777
#include "spandsp/modem_connect_tones.h"
78+
#include "spandsp/godard.h"
7879
#include "spandsp/v8.h"
7980
#include "spandsp/v29tx.h"
8081
#include "spandsp/v29rx.h"
@@ -106,6 +107,7 @@
106107
#include "spandsp/private/fsk.h"
107108
#include "spandsp/private/modem_connect_tones.h"
108109
#include "spandsp/private/v8.h"
110+
#include "spandsp/private/godard.h"
109111
#if defined(SPANDSP_SUPPORT_V34)
110112
#include "spandsp/private/v34.h"
111113
#endif

src/t38_gateway.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
#include "spandsp/ssl_fax.h"
7373
#include "spandsp/silence_gen.h"
7474
#include "spandsp/fsk.h"
75+
#include "spandsp/godard.h"
7576
#include "spandsp/v29tx.h"
7677
#include "spandsp/v29rx.h"
7778
#include "spandsp/v27ter_tx.h"
@@ -109,6 +110,7 @@
109110
#include "spandsp/private/silence_gen.h"
110111
#include "spandsp/private/power_meter.h"
111112
#include "spandsp/private/fsk.h"
113+
#include "spandsp/private/godard.h"
112114
#if defined(SPANDSP_SUPPORT_V34)
113115
#include "spandsp/private/bitstream.h"
114116
#include "spandsp/private/v34.h"

src/v17rx.c

Lines changed: 8 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@
6868
#define SPANDSP_USE_FIXED_POINTx
6969
#endif
7070

71+
#include "spandsp/godard.h"
7172
#include "spandsp/v29rx.h"
7273
#include "spandsp/v17tx.h"
7374
#include "spandsp/v17rx.h"
7475

7576
#include "spandsp/private/logging.h"
7677
#include "spandsp/private/power_meter.h"
78+
#include "spandsp/private/godard.h"
7779
#include "spandsp/private/v17rx.h"
7880

7981
#if defined(SPANDSP_USE_FIXED_POINTx)
@@ -101,6 +103,7 @@
101103
#include "v17_v32bis_rx_rrc.h"
102104
#include "v17_v32bis_tx_constellation_maps.h"
103105
#include "v17_v32bis_rx_constellation_maps.h"
106+
#include "v17_v32bis_rx_godard.h"
104107

105108
/*! The nominal frequency of the carrier, in Hertz */
106109
#define CARRIER_NOMINAL_FREQ 1800.0f
@@ -128,23 +131,6 @@
128131
/*! The 16 bit pattern used in the bridge section of the training sequence */
129132
#define V17_BRIDGE_WORD 0x8880
130133

131-
/* Coefficients for the band edge symbol timing synchroniser (alpha = 0.99) */
132-
/* low_edge = 2.0f*M_PI*(CARRIER_NOMINAL_FREQ - BAUD_RATE/2.0f)/SAMPLE_RATE; */
133-
/* high_edge = 2.0f*M_PI*(CARRIER_NOMINAL_FREQ + BAUD_RATE/2.0f)/SAMPLE_RATE; */
134-
#define SIN_LOW_BAND_EDGE 0.453990499f
135-
#define COS_LOW_BAND_EDGE 0.891006542f
136-
#define SIN_HIGH_BAND_EDGE 0.707106781f
137-
#define COS_HIGH_BAND_EDGE -0.707106781f
138-
#define ALPHA 0.99f
139-
140-
#define SYNC_LOW_BAND_EDGE_COEFF_0 FP_SYNC_SCALE(2.0f*ALPHA*COS_LOW_BAND_EDGE)
141-
#define SYNC_LOW_BAND_EDGE_COEFF_1 FP_SYNC_SCALE(-ALPHA*ALPHA)
142-
#define SYNC_LOW_BAND_EDGE_COEFF_2 FP_SYNC_SCALE(-ALPHA*SIN_LOW_BAND_EDGE)
143-
#define SYNC_HIGH_BAND_EDGE_COEFF_0 FP_SYNC_SCALE(2.0f*ALPHA*COS_HIGH_BAND_EDGE)
144-
#define SYNC_HIGH_BAND_EDGE_COEFF_1 FP_SYNC_SCALE(-ALPHA*ALPHA)
145-
#define SYNC_HIGH_BAND_EDGE_COEFF_2 FP_SYNC_SCALE(-ALPHA*SIN_HIGH_BAND_EDGE)
146-
#define SYNC_MIXED_EDGES_COEFF_3 FP_SYNC_SCALE(-ALPHA*ALPHA*(SIN_HIGH_BAND_EDGE*COS_LOW_BAND_EDGE - SIN_LOW_BAND_EDGE*COS_HIGH_BAND_EDGE))
147-
148134
enum
149135
{
150136
TRAINING_STAGE_NORMAL_OPERATION = 0,
@@ -182,7 +168,7 @@ SPAN_DECLARE(float) v17_rx_carrier_frequency(v17_rx_state_t *s)
182168

183169
SPAN_DECLARE(float) v17_rx_symbol_timing_correction(v17_rx_state_t *s)
184170
{
185-
return (float) s->total_baud_timing_correction/((float) RX_PULSESHAPER_COEFF_SETS*10.0f/3.0f);
171+
return (float) godard_ted_correction(&s->godard)/((float) RX_PULSESHAPER_COEFF_SETS*10.0f/3.0f);
186172
}
187173
/*- End of function --------------------------------------------------------*/
188174

@@ -603,65 +589,6 @@ static int decode_baud(v17_rx_state_t *s, complexf_t *z)
603589
}
604590
/*- End of function --------------------------------------------------------*/
605591

606-
static __inline__ void symbol_sync(v17_rx_state_t *s)
607-
{
608-
int i;
609-
#if defined(SPANDSP_USE_FIXED_POINTx)
610-
int32_t v;
611-
int32_t p;
612-
#else
613-
float v;
614-
float p;
615-
#endif
616-
617-
/* This routine adapts the position of the half baud samples entering the equalizer. */
618-
619-
/* This symbol sync scheme is based on the technique first described by Dominique Godard in
620-
Passband Timing Recovery in an All-Digital Modem Receiver
621-
IEEE TRANSACTIONS ON COMMUNICATIONS, VOL. COM-26, NO. 5, MAY 1978 */
622-
623-
/* This is slightly rearranged from figure 3b of the Godard paper, as this saves a couple of
624-
maths operations */
625-
#if defined(SPANDSP_USE_FIXED_POINTx)
626-
/* TODO: The scalings used here need more thorough evaluation, to see if overflows are possible. */
627-
/* Cross correlate */
628-
v = (((s->symbol_sync_low[1] >> (FP_SYNC_SHIFT_FACTOR/2))*(s->symbol_sync_high[0] >> (FP_SYNC_SHIFT_FACTOR/2))) >> 14)*SYNC_LOW_BAND_EDGE_COEFF_2
629-
- (((s->symbol_sync_low[0] >> (FP_SYNC_SHIFT_FACTOR/2))*(s->symbol_sync_high[1] >> (FP_SYNC_SHIFT_FACTOR/2))) >> 14)*SYNC_HIGH_BAND_EDGE_COEFF_2
630-
+ (((s->symbol_sync_low[1] >> (FP_SYNC_SHIFT_FACTOR/2))*(s->symbol_sync_high[1] >> (FP_SYNC_SHIFT_FACTOR/2))) >> 14)*SYNC_MIXED_EDGES_COEFF_3;
631-
/* Filter away any DC component */
632-
p = v - s->symbol_sync_dc_filter[1];
633-
s->symbol_sync_dc_filter[1] = s->symbol_sync_dc_filter[0];
634-
s->symbol_sync_dc_filter[0] = v;
635-
/* A little integration will now filter away much of the HF noise */
636-
s->baud_phase -= p;
637-
v = labs(s->baud_phase);
638-
#else
639-
/* Cross correlate */
640-
v = s->symbol_sync_low[1]*s->symbol_sync_high[0]*SYNC_LOW_BAND_EDGE_COEFF_2
641-
- s->symbol_sync_low[0]*s->symbol_sync_high[1]*SYNC_HIGH_BAND_EDGE_COEFF_2
642-
+ s->symbol_sync_low[1]*s->symbol_sync_high[1]*SYNC_MIXED_EDGES_COEFF_3;
643-
/* Filter away any DC component */
644-
p = v - s->symbol_sync_dc_filter[1];
645-
s->symbol_sync_dc_filter[1] = s->symbol_sync_dc_filter[0];
646-
s->symbol_sync_dc_filter[0] = v;
647-
/* A little integration will now filter away much of the HF noise */
648-
s->baud_phase -= p;
649-
v = fabsf(s->baud_phase);
650-
#endif
651-
if (v > FP_SYNC_SCALE_32(100.0f))
652-
{
653-
i = (v > FP_SYNC_SCALE_32(1000.0f)) ? 15 : 1;
654-
if (s->baud_phase < FP_SYNC_SCALE_32(0.0f))
655-
i = -i;
656-
/*endif*/
657-
//printf("v = %10.5f %5d - %f %f %d\n", v, i, p, s->baud_phase, s->total_baud_timing_correction);
658-
s->eq_put_step += i;
659-
s->total_baud_timing_correction += i;
660-
}
661-
/*endif*/
662-
}
663-
/*- End of function --------------------------------------------------------*/
664-
665592
#if defined(SPANDSP_USE_FIXED_POINTx)
666593
static void process_half_baud(v17_rx_state_t *s, const complexi16_t *sample)
667594
#else
@@ -714,7 +641,7 @@ static void process_half_baud(v17_rx_state_t *s, const complexf_t *sample)
714641
/*endif*/
715642

716643
/* Symbol timing synchronisation */
717-
symbol_sync(s);
644+
s->eq_put_step += godard_ted_per_baud(&s->godard);
718645

719646
z = equalizer_get(s);
720647

@@ -1330,32 +1257,11 @@ SPAN_DECLARE(int) v17_rx(v17_rx_state_t *s, const int16_t amp[], int len)
13301257
#if defined(SPANDSP_USE_FIXED_POINTx)
13311258
v = vec_circular_dot_prodi16(s->rrc_filter, rx_pulseshaper_re[step], V17_RX_FILTER_STEPS, s->rrc_filter_step) >> 15;
13321259
sample.re = (v*s->agc_scaling) >> 10;
1333-
/* Symbol timing synchronisation band edge filters */
1334-
/* Low Nyquist band edge filter */
1335-
v = ((s->symbol_sync_low[0]*SYNC_LOW_BAND_EDGE_COEFF_0) >> FP_SYNC_SHIFT_FACTOR)
1336-
+ ((s->symbol_sync_low[1]*SYNC_LOW_BAND_EDGE_COEFF_1) >> FP_SYNC_SHIFT_FACTOR)
1337-
+ sample.re;
1338-
s->symbol_sync_low[1] = s->symbol_sync_low[0];
1339-
s->symbol_sync_low[0] = v;
1340-
/* High Nyquist band edge filter */
1341-
v = ((s->symbol_sync_high[0]*SYNC_HIGH_BAND_EDGE_COEFF_0) >> FP_SYNC_SHIFT_FACTOR)
1342-
+ ((s->symbol_sync_high[1]*SYNC_HIGH_BAND_EDGE_COEFF_1) >> FP_SYNC_SHIFT_FACTOR)
1343-
+ sample.re;
1344-
s->symbol_sync_high[1] = s->symbol_sync_high[0];
1345-
s->symbol_sync_high[0] = v;
13461260
#else
13471261
v = vec_circular_dot_prodf(s->rrc_filter, rx_pulseshaper_re[step], V17_RX_FILTER_STEPS, s->rrc_filter_step);
13481262
sample.re = v*s->agc_scaling;
1349-
/* Symbol timing synchronisation band edge filters */
1350-
/* Low Nyquist band edge filter */
1351-
v = s->symbol_sync_low[0]*SYNC_LOW_BAND_EDGE_COEFF_0 + s->symbol_sync_low[1]*SYNC_LOW_BAND_EDGE_COEFF_1 + sample.re;
1352-
s->symbol_sync_low[1] = s->symbol_sync_low[0];
1353-
s->symbol_sync_low[0] = v;
1354-
/* High Nyquist band edge filter */
1355-
v = s->symbol_sync_high[0]*SYNC_HIGH_BAND_EDGE_COEFF_0 + s->symbol_sync_high[1]*SYNC_HIGH_BAND_EDGE_COEFF_1 + sample.re;
1356-
s->symbol_sync_high[1] = s->symbol_sync_high[0];
1357-
s->symbol_sync_high[0] = v;
13581263
#endif
1264+
godard_ted_rx(&s->godard, sample.re);
13591265
/* Put things into the equalization buffer at T/2 rate. The symbol synchronisation
13601266
will fiddle the step to align this with the symbols. */
13611267
if (s->eq_put_step <= 0)
@@ -1569,18 +1475,9 @@ SPAN_DECLARE(int) v17_rx_restart(v17_rx_state_t *s, int bit_rate, int short_trai
15691475
span_log(&s->logging, SPAN_LOG_FLOW, "Gains %f %f\n", (float) s->agc_scaling_save, (float) s->agc_scaling);
15701476
span_log(&s->logging, SPAN_LOG_FLOW, "Phase rates %f %f\n", dds_frequencyf(s->carrier_phase_rate), dds_frequencyf(s->carrier_phase_rate_save));
15711477

1572-
/* Initialise the working data for symbol timing synchronisation */
1573-
for (i = 0; i < 2; i++)
1574-
{
1575-
s->symbol_sync_low[i] = FP_SCALE(0.0f);
1576-
s->symbol_sync_high[i] = FP_SCALE(0.0f);
1577-
s->symbol_sync_dc_filter[i] = FP_SCALE(0.0f);
1578-
}
1579-
/*endfor*/
1580-
s->baud_phase = FP_SCALE(0.0f);
1581-
s->baud_half = 0;
1478+
godard_ted_init(&s->godard, &godard_desc);
15821479

1583-
s->total_baud_timing_correction = 0;
1480+
s->baud_half = 0;
15841481

15851482
return 0;
15861483
}

0 commit comments

Comments
 (0)