提交 287678bc authored 作者: Steve Underwood's avatar Steve Underwood

Tweaks to spandsp tests

Addition of tones to modem connect tones
Repeat function for V.18 TDD
上级 860b5318
......@@ -19,8 +19,6 @@
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
MAINTAINERCLEANFILES = Makefile.in
DISTCLEANFILES = $(srcdir)/at_interpreter_dictionary.h \
$(srcdir)/math_fixed_tables.h \
$(srcdir)/v17_v32bis_rx_fixed_rrc.h \
......@@ -46,6 +44,10 @@ DISTCLEANFILES = $(srcdir)/at_interpreter_dictionary.h \
$(srcdir)/v29tx_fixed_rrc.h \
$(srcdir)/v29tx_floating_rrc.h
CLEANFILES = ${DISTCLEANFILES}
MOSTLYCLEANFILES = ${DISTCLEANFILES}
MAINTAINERCLEANFILES = ${DISTCLEANFILES}
EXTRA_DIST = floating_fudge.h \
libspandsp.dsp \
libspandsp.2005.sln \
......@@ -322,7 +324,8 @@ nobase_include_HEADERS = spandsp/ademco_contactid.h \
nodist_include_HEADERS = spandsp.h
noinst_HEADERS = faxfont.h \
noinst_HEADERS = cielab_luts.h \
faxfont.h \
filter_tools.h \
gsm0610_local.h \
lpc10_encdecs.h \
......
......@@ -179,18 +179,20 @@ SPAN_DECLARE_NONSTD(void) async_rx_put_bit(void *user_data, int bit)
{
/* Align the received value */
if (s->data_bits < 8)
s->byte_in_progress >>= (8 - s->data_bits);
s->byte_in_progress = (s->byte_in_progress & 0xFF) >> (8 - s->data_bits);
s->put_byte(s->user_data, s->byte_in_progress);
s->bitpos = 0;
}
else if (s->use_v14)
else
{
if (s->use_v14)
{
/* This is actually the start bit for the next character, and
the stop bit has been dropped from the stream. This is the
rate adaption specified in V.14 */
/* Align the received value */
if (s->data_bits < 8)
s->byte_in_progress >>= (8 - s->data_bits);
s->byte_in_progress = (s->byte_in_progress & 0xFF) >> (8 - s->data_bits);
s->put_byte(s->user_data, s->byte_in_progress);
s->bitpos = 1;
s->parity_bit = 0;
......@@ -202,6 +204,7 @@ SPAN_DECLARE_NONSTD(void) async_rx_put_bit(void *user_data, int bit)
s->bitpos = 0;
}
}
}
}
/*- End of function --------------------------------------------------------*/
......
差异被折叠。
......@@ -336,6 +336,7 @@ SPAN_DECLARE(int) fax_modems_free(fax_modems_state_t *s)
{
if (s)
free(s);
/*endif*/
return 0;
}
/*- End of function --------------------------------------------------------*/
......
......@@ -70,16 +70,16 @@ const fsk_spec_t preset_fsk_specs[] =
},
{
"V23 ch 1",
2100,
1300,
1700 + 400,
1700 - 400,
-14,
-30,
1200*100
},
{
"V23 ch 2",
450,
390,
420 + 30,
420 - 30,
-14,
-30,
75*100
......@@ -102,27 +102,35 @@ const fsk_spec_t preset_fsk_specs[] =
},
{
"Bell202",
2200,
1200,
1700 + 500,
1700 - 500,
-14,
-30,
1200*100
},
{
"Weitbrecht 45.45", /* Used for TDD (Telecoms Device for the Deaf) */
1800,
1400,
"Weitbrecht 45.45", /* Used for US TDD (Telecoms Device for the Deaf) */
1600 + 200,
1600 - 200,
-14,
-30,
4545
},
{
"Weitbrecht 50", /* Used for TDD (Telecoms Device for the Deaf) */
1800,
1400,
"Weitbrecht 50", /* Used for Internatioal TDD (Telecoms Device for the Deaf) */
1600 + 200,
1600 - 200,
-14,
-30,
5000
50*100
},
{
"V21 (110bps) ch 1",
1080 + 100,
1080 - 100,
-14,
-30,
110*100
}
};
......@@ -476,6 +484,10 @@ SPAN_DECLARE_NONSTD(int) fsk_rx(fsk_rx_state_t *s, const int16_t *amp, int len)
s->put_bit(s->put_bit_user_data, baudstate);
}
break;
case FSK_FRAME_MODE_5N1_FRAMES:
case FSK_FRAME_MODE_7N1_FRAMES:
case FSK_FRAME_MODE_7E1_FRAMES:
case FSK_FRAME_MODE_7E2_FRAMES:
default:
/* Gather the specified number of bits, with robust checking to ensure reasonable voice immunity.
The first bit should be a start bit (0), and the last bit should be a stop bit (1) */
......@@ -527,24 +539,22 @@ SPAN_DECLARE_NONSTD(int) fsk_rx(fsk_rx_state_t *s, const int16_t *amp, int len)
state as the next bit */
if (s->last_bit == baudstate)
{
s->frame_bits |= (baudstate << s->framing_mode);
s->frame_bits >>= 1;
s->baud_phase -= (SAMPLE_RATE*100);
if (++s->frame_state > s->framing_mode)
{
/* Check we have a stop bit */
if (baudstate == 1)
{
/* Check we have a start bit */
if ((s->frame_bits & 1) == 0)
/* Check we have a stop bit and a start bit */
if (baudstate == 1 && (s->frame_bits & 0x02) == 0)
{
/* Drop the start bit, and pass the rest back */
s->frame_bits >>= 1;
s->put_bit(s->put_bit_user_data, s->frame_bits);
}
s->put_bit(s->put_bit_user_data, s->frame_bits >> 2);
}
s->frame_state = 0;
}
else
{
s->frame_bits |= (baudstate << s->framing_mode);
s->frame_bits >>= 1;
}
s->baud_phase -= (SAMPLE_RATE*100);
}
else
{
......
......@@ -94,6 +94,8 @@ SPAN_DECLARE(const char *) modem_connect_tone_to_str(int tone)
return "FAX preamble";
case MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE:
return "FAX CED or preamble";
case MODEM_CONNECT_TONES_BELL_ANS:
return "Bell ANS";
case MODEM_CONNECT_TONES_CALLING_TONE:
return "Calling tone";
}
......@@ -206,6 +208,20 @@ SPAN_DECLARE_NONSTD(int) modem_connect_tones_tx(modem_connect_tones_tx_state_t *
}
s->duration_timer -= len;
break;
case MODEM_CONNECT_TONES_BELL_ANS:
if (s->duration_timer < len)
len = s->duration_timer;
if (s->duration_timer > ms_to_samples(2600))
{
/* There is some initial silence to be generated. */
if ((i = s->duration_timer - ms_to_samples(2600)) > len)
i = len;
memset(amp, 0, sizeof(int16_t)*i);
}
for ( ; i < len; i++)
amp[i] = dds_mod(&s->tone_phase, s->tone_phase_rate, s->level, 0);
s->duration_timer -= len;
break;
case MODEM_CONNECT_TONES_CALLING_TONE:
for ( ; i < len; i++)
{
......@@ -301,6 +317,17 @@ SPAN_DECLARE(modem_connect_tones_tx_state_t *) modem_connect_tones_tx_init(modem
s->mod_phase = 0;
s->hop_timer = ms_to_samples(450);
break;
case MODEM_CONNECT_TONES_BELL_ANS:
/* 0.2s of silence, then 2.6s to 4s of 2225Hz+-15Hz tone, then 75ms of silence. */
s->tone_phase_rate = dds_phase_rate(2225.0);
s->level = dds_scaling_dbm0(-11);
s->mod_phase_rate = 0;
s->mod_level = 0;
s->duration_timer = ms_to_samples(200 + 2600);
s->tone_phase = 0;
s->mod_phase = 0;
s->hop_timer = 0;
break;
case MODEM_CONNECT_TONES_CALLING_TONE:
/* 0.6s of 1300Hz+-15Hz + 2.0s of silence repeating. */
s->tone_phase_rate = dds_phase_rate(1300.0);
......@@ -441,7 +468,7 @@ SPAN_DECLARE_NONSTD(int) modem_connect_tones_rx(modem_connect_tones_rx_state_t *
/* A Cauer notch at 1100Hz, spread just wide enough to meet our detection bandwidth
criteria. */
/* Poles 0.736618498*exp(+-1047/4000 * PI * j)
Zeroes exp(+-1099.5 * PI * j) */
Zeroes exp(+-1099.5/4000 * PI * j) */
v1 = 0.792928f*famp + 1.0018744927985f*s->znotch_1 - 0.54196833412465f*s->znotch_2;
famp = v1 - 1.2994747954630f*s->znotch_1 + s->znotch_2;
s->znotch_2 = s->znotch_1;
......@@ -487,7 +514,7 @@ SPAN_DECLARE_NONSTD(int) modem_connect_tones_rx(modem_connect_tones_rx_state_t *
famp = amp[i];
/* A Cauer bandpass at 15Hz, with which we demodulate the AM signal. */
/* Poles 0.9983989*exp(+-15/4000 * PI * j)
Zeroes exp(0 * PI * j) */
Zeroes exp(0/4000 * PI * j) */
v1 = fabs(famp) + 1.996667f*s->z15hz_1 - 0.9968004f*s->z15hz_2;
filtered = 0.001599787f*(v1 - s->z15hz_2);
s->z15hz_2 = s->z15hz_1;
......@@ -497,8 +524,8 @@ SPAN_DECLARE_NONSTD(int) modem_connect_tones_rx(modem_connect_tones_rx_state_t *
/* A Cauer notch at 2100Hz, spread just wide enough to meet our detection bandwidth
criteria. */
/* Poles 0.7144255*exp(+-2105.612/4000 * PI * j)
Zeroes exp(+-2099.9 * PI * j) */
v1 = 0.76000f*famp - 0.1183852f*s->znotch_1 - 0.5104039f*s->znotch_2;
Zeroes exp(+-2099.9/4000 * PI * j) */
v1 = 0.7552f*famp - 0.1183852f*s->znotch_1 - 0.5104039f*s->znotch_2;
famp = v1 + 0.1567596f*s->znotch_1 + s->znotch_2;
s->znotch_2 = s->znotch_1;
s->znotch_1 = v1;
......@@ -585,6 +612,44 @@ SPAN_DECLARE_NONSTD(int) modem_connect_tones_rx(modem_connect_tones_rx_state_t *
}
}
break;
case MODEM_CONNECT_TONES_BELL_ANS:
for (i = 0; i < len; i++)
{
famp = amp[i];
/* A Cauer notch at 2225Hz, spread just wide enough to meet our detection bandwidth
criteria. */
/* Poles 0.7144255*exp(+-2230.612/4000 * PI * j)
Zeroes exp(+-2224.9/4000 * PI * j) */
v1 = 0.739651f*famp - 0.257384f*s->znotch_1 - 0.510404f*s->znotch_2;
famp = v1 + 0.351437f*s->znotch_1 + s->znotch_2;
s->znotch_2 = s->znotch_1;
s->znotch_1 = v1;
notched = (int16_t) lfastrintf(famp);
/* Estimate the overall energy in the channel, and the energy in
the notch (i.e. overall channel energy - tone energy => noise).
Use abs instead of multiply for speed (is it really faster?). */
s->channel_level += ((abs(amp[i]) - s->channel_level) >> 5);
s->notch_level += ((abs(notched) - s->notch_level) >> 5);
if (s->channel_level > 70 && s->notch_level*6 < s->channel_level)
{
/* There is adequate energy in the channel, and it is mostly at 2225Hz. */
if (s->tone_present != MODEM_CONNECT_TONES_BELL_ANS)
{
if (++s->tone_cycle_duration >= ms_to_samples(415))
report_tone_state(s, MODEM_CONNECT_TONES_BELL_ANS, lfastrintf(log10f(s->channel_level/32768.0f)*20.0f + DBM0_MAX_POWER + 0.8f));
}
}
else
{
/* If the signal looks wrong, even for a moment, we consider this the
end of the tone. */
if (s->tone_present == MODEM_CONNECT_TONES_BELL_ANS)
report_tone_state(s, MODEM_CONNECT_TONES_NONE, -99);
s->tone_cycle_duration = 0;
}
}
break;
case MODEM_CONNECT_TONES_CALLING_TONE:
for (i = 0; i < len; i++)
{
......@@ -592,7 +657,7 @@ SPAN_DECLARE_NONSTD(int) modem_connect_tones_rx(modem_connect_tones_rx_state_t *
/* A Cauer notch at 1300Hz, spread just wide enough to meet our detection bandwidth
criteria. */
/* Poles 0.736618498*exp(+-1247/4000 * PI * j)
Zeroes exp(+-1299.5 * PI * j) */
Zeroes exp(+-1299.5/4000 * PI * j) */
v1 = 0.755582f*famp + 0.820887174515f*s->znotch_1 - 0.541968324778f*s->znotch_2;
famp = v1 - 1.0456667108f*s->znotch_1 + s->znotch_2;
s->znotch_2 = s->znotch_1;
......
......@@ -110,7 +110,8 @@ enum
FSK_BELL103CH2,
FSK_BELL202,
FSK_WEITBRECHT, /* 45.45 baud version, used for TDD (Telecom Device for the Deaf) */
FSK_WEITBRECHT50 /* 50 baud version, used for TDD (Telecom Device for the Deaf) */
FSK_WEITBRECHT50, /* 50 baud version, used for TDD (Telecom Device for the Deaf) */
FSK_V21CH1_110 /* 110 bps version of V.21 channel 1, as used by V.18 */
};
enum
......@@ -119,7 +120,8 @@ enum
FSK_FRAME_MODE_SYNC = 1,
FSK_FRAME_MODE_5N1_FRAMES = 7, /* 5 bits of data + start bit + stop bit */
FSK_FRAME_MODE_7N1_FRAMES = 9, /* 7 bits of data + start bit + stop bit */
FSK_FRAME_MODE_8N1_FRAMES = 10 /* 8 bits of data + start bit + stop bit */
FSK_FRAME_MODE_7E1_FRAMES = 10, /* 7 bits of data + even parity + start bit + stop bit */
FSK_FRAME_MODE_7E2_FRAMES = 11 /* 7 bits of data + even parity + start bit + 2 stop bits */
};
SPAN_DECLARE_DATA extern const fsk_spec_t preset_fsk_specs[];
......
......@@ -76,9 +76,11 @@ enum
This is only valid as a tone type to receive. It is never reported as a detected tone
type. The report will either be for FAX preamble or CED/ANS tone. */
MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE = 7,
/*! \brief Bell ANS tone is a pure continuous 2225Hz+-15Hz tone for 3.3s+-0.7s. */
MODEM_CONNECT_TONES_BELL_ANS = 8,
/*! \brief Calling tone is a pure 1300Hz tone, in 0.6s bursts, with 2s silences in between. The
bursts repeat for as long as is required. */
MODEM_CONNECT_TONES_CALLING_TONE = 8
MODEM_CONNECT_TONES_CALLING_TONE = 9
};
/*! \brief FAX CED tone is the same as ANS tone. */
......
......@@ -45,7 +45,7 @@ struct async_tx_state_s
void *user_data;
/*! \brief A current, partially transmitted, character. */
int byte_in_progress;
unsigned int byte_in_progress;
/*! \brief The current bit position within a partially transmitted character. */
int bitpos;
/*! \brief Parity bit. */
......@@ -73,7 +73,7 @@ struct async_rx_state_s
void *user_data;
/*! \brief A current, partially complete, character. */
int byte_in_progress;
unsigned int byte_in_progress;
/*! \brief The current bit position within a partially complete character. */
int bitpos;
/*! \brief Parity bit. */
......
......@@ -56,6 +56,7 @@ struct v18_state_s
int rx_msg_len;
int bit_pos;
int in_progress;
int repeat_shifts;
/*! \brief Error and flow logging control */
logging_state_t logging;
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论