mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-14 05:18:31 +00:00
update to spandsp snapshot 20091005
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15084 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
1 parent
4e440b6e4c
commit
dab4d9068d
46 files changed
+1316
-505
No files matched your search
@@ -16,7 +16,7 @@
|
||||
## along with this program; if not, write to the Free Software
|
||||
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
##
|
||||
## $Id: Makefile.am,v 1.116 2009/05/30 15:23:13 steveu Exp $
|
||||
## $Id: Makefile.am,v 1.117 2009/09/22 13:11:04 steveu Exp $
|
||||
|
||||
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
|
||||
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
|
||||
@@ -99,6 +99,7 @@ noinst_PROGRAMS = adsi_tests \
|
||||
sig_tone_tests \
|
||||
super_tone_rx_tests \
|
||||
super_tone_tx_tests \
|
||||
swept_tone_tests \
|
||||
t4_tests \
|
||||
t31_tests \
|
||||
t38_core_tests \
|
||||
@@ -273,6 +274,9 @@ super_tone_rx_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR
|
||||
super_tone_tx_tests_SOURCES = super_tone_tx_tests.c
|
||||
super_tone_tx_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
|
||||
|
||||
swept_tone_tests_SOURCES = swept_tone_tests.c
|
||||
swept_tone_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
|
||||
|
||||
t4_tests_SOURCES = t4_tests.c
|
||||
t4_tests_LDADD = $(LIBDIR) -lspandsp
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: fax_decode.c,v 1.56 2009/05/30 15:23:13 steveu Exp $
|
||||
* $Id: fax_decode.c,v 1.57 2009/09/15 14:01:53 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page fax_decode_page FAX decoder
|
||||
@@ -124,7 +124,7 @@ static void print_frame(const char *io, const uint8_t *fr, int frlen)
|
||||
type = fr[2] & 0xFE;
|
||||
if (type == T30_DIS || type == T30_DTC || type == T30_DCS)
|
||||
t30_decode_dis_dtc_dcs(&t30_dummy, fr, frlen);
|
||||
if (type == T30_NSF)
|
||||
if (type == T30_NSF || type == T30_NSS || type == T30_NSC)
|
||||
{
|
||||
if (t35_decode(&fr[3], frlen - 3, &country, &vendor, &model))
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: line_model_tests.c,v 1.27 2009/05/30 15:23:14 steveu Exp $
|
||||
* $Id: line_model_tests.c,v 1.28 2009/09/23 16:02:59 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page line_model_tests_page Telephony line model tests
|
||||
@@ -62,7 +62,7 @@
|
||||
#define IN_FILE_NAME1 "line_model_test_in1.wav"
|
||||
#define IN_FILE_NAME2 "line_model_test_in2.wav"
|
||||
#define OUT_FILE_NAME1 "line_model_one_way_test_out.wav"
|
||||
#define OUT_FILE_NAME "line_model_test_out.wav"
|
||||
#define OUT_FILE_NAME2 "line_model_two_way_test_out.wav"
|
||||
|
||||
int channel_codec;
|
||||
int rbs_pattern;
|
||||
@@ -128,10 +128,17 @@ static void test_one_way_model(int line_model_no, int speech_test)
|
||||
|
||||
awgn_init_dbm0(&noise1, 1234567, -10.0f);
|
||||
|
||||
if ((inhandle1 = sf_open_telephony_read(IN_FILE_NAME1, 1)) == NULL)
|
||||
if (speech_test)
|
||||
{
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", IN_FILE_NAME1);
|
||||
exit(2);
|
||||
if ((inhandle1 = sf_open_telephony_read(IN_FILE_NAME1, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", IN_FILE_NAME1);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
inhandle1 = NULL;
|
||||
}
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME1, 1)) == NULL)
|
||||
{
|
||||
@@ -167,10 +174,13 @@ static void test_one_way_model(int line_model_no, int speech_test)
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if (sf_close(inhandle1))
|
||||
if (speech_test)
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME1);
|
||||
exit(2);
|
||||
if (sf_close(inhandle1))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME1);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if (sf_close(outhandle))
|
||||
{
|
||||
@@ -208,19 +218,27 @@ static void test_both_ways_model(int line_model_no, int speech_test)
|
||||
awgn_init_dbm0(&noise1, 1234567, -10.0f);
|
||||
awgn_init_dbm0(&noise2, 1234567, -10.0f);
|
||||
|
||||
if ((inhandle1 = sf_open_telephony_read(IN_FILE_NAME1, 1)) == NULL)
|
||||
if (speech_test)
|
||||
{
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", IN_FILE_NAME1);
|
||||
exit(2);
|
||||
if ((inhandle1 = sf_open_telephony_read(IN_FILE_NAME1, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", IN_FILE_NAME1);
|
||||
exit(2);
|
||||
}
|
||||
if ((inhandle2 = sf_open_telephony_read(IN_FILE_NAME2, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", IN_FILE_NAME2);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if ((inhandle2 = sf_open_telephony_read(IN_FILE_NAME2, 1)) == NULL)
|
||||
else
|
||||
{
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", IN_FILE_NAME2);
|
||||
exit(2);
|
||||
inhandle1 =
|
||||
inhandle2 = NULL;
|
||||
}
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 2)) == NULL)
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME2, 2)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME2);
|
||||
exit(2);
|
||||
}
|
||||
for (i = 0; i < 10000; i++)
|
||||
@@ -261,25 +279,80 @@ static void test_both_ways_model(int line_model_no, int speech_test)
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if (sf_close(inhandle1))
|
||||
if (speech_test)
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME1);
|
||||
exit(2);
|
||||
}
|
||||
if (sf_close(inhandle2))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME2);
|
||||
exit(2);
|
||||
if (sf_close(inhandle1))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME1);
|
||||
exit(2);
|
||||
}
|
||||
if (sf_close(inhandle2))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME2);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if (sf_close(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME2);
|
||||
exit(2);
|
||||
}
|
||||
both_ways_line_model_release(model);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static void test_line_filter(int line_model_no)
|
||||
{
|
||||
float out;
|
||||
double sumin;
|
||||
double sumout;
|
||||
int i;
|
||||
int j;
|
||||
int p;
|
||||
int ptr;
|
||||
int len;
|
||||
swept_tone_state_t *s;
|
||||
float filter[129];
|
||||
int16_t buf[BLOCK_LEN];
|
||||
|
||||
s = swept_tone_init(NULL, 200.0f, 3900.0f, -10.0f, 120*SAMPLE_RATE, 0);
|
||||
for (j = 0; j < 129; j++)
|
||||
filter[j] = 0.0f;
|
||||
ptr = 0;
|
||||
for (;;)
|
||||
{
|
||||
if ((len = swept_tone(s, buf, BLOCK_LEN)) <= 0)
|
||||
break;
|
||||
sumin = 0.0;
|
||||
sumout = 0.0;
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
/* Add the sample in the filter buffer */
|
||||
p = ptr;
|
||||
filter[p] = buf[i];
|
||||
if (++p == 129)
|
||||
p = 0;
|
||||
ptr = p;
|
||||
|
||||
/* Apply the filter */
|
||||
out = 0.0f;
|
||||
for (j = 0; j < 129; j++)
|
||||
{
|
||||
out += line_models[line_model_no][128 - j]*filter[p];
|
||||
if (++p >= 129)
|
||||
p = 0;
|
||||
}
|
||||
sumin += buf[i]*buf[i];
|
||||
sumout += out*out;
|
||||
}
|
||||
/*endfor*/
|
||||
printf("%7.1f %f\n", swept_tone_current_frequency(s), 10.0*log10(sumout/sumin));
|
||||
}
|
||||
/*endfor*/
|
||||
swept_tone_free(s);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int line_model_no;
|
||||
@@ -319,6 +392,7 @@ int main(int argc, char *argv[])
|
||||
complexify_tests();
|
||||
test_one_way_model(line_model_no, speech_test);
|
||||
test_both_ways_model(line_model_no, speech_test);
|
||||
test_line_filter(line_model_no);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
@@ -17,7 +17,7 @@
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
# $Id: regression_tests.sh,v 1.58 2009/05/19 14:47:02 steveu Exp $
|
||||
# $Id: regression_tests.sh,v 1.59 2009/09/22 13:28:18 steveu Exp $
|
||||
#
|
||||
|
||||
ITUTESTS_TIF=../test-data/itu/fax/itutests.tif
|
||||
@@ -468,6 +468,16 @@ echo super_tone_rx_tests not enabled
|
||||
#echo super_tone_tx_tests completed OK
|
||||
echo super_tone_tx_tests not enabled
|
||||
|
||||
#./swept_tone_tests >$STDOUT_DEST 2>$STDERR_DEST
|
||||
#RETVAL=$?
|
||||
#if [ $RETVAL != 0 ]
|
||||
#then
|
||||
# echo swept_tone_tests failed!
|
||||
# exit $RETVAL
|
||||
#fi
|
||||
#echo swept_tone_tests completed OK
|
||||
echo swept_tone_tests not enabled
|
||||
|
||||
./t31_tests -r >$STDOUT_DEST 2>$STDERR_DEST
|
||||
RETVAL=$?
|
||||
if [ $RETVAL != 0 ]
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: sig_tone_tests.c,v 1.25 2009/05/30 15:23:14 steveu Exp $
|
||||
* $Id: sig_tone_tests.c,v 1.27 2009/09/23 16:02:59 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -58,112 +58,97 @@
|
||||
static int sampleno = 0;
|
||||
static int tone_1_present = 0;
|
||||
static int tone_2_present = 0;
|
||||
static int ping = 0;
|
||||
static int tx_section = 0;
|
||||
static int dial_pulses = 0;
|
||||
|
||||
void map_frequency_response(sig_tone_rx_state_t *s);
|
||||
|
||||
static int tx_handler(void *user_data, int what)
|
||||
static void tx_handler(void *user_data, int what, int level, int duration)
|
||||
{
|
||||
//printf("What - %d\n", what);
|
||||
if ((what & SIG_TONE_UPDATE_REQUEST))
|
||||
sig_tone_tx_state_t *s;
|
||||
|
||||
s = (sig_tone_tx_state_t *) user_data;
|
||||
//printf("What - %d, duration - %d\n", what, duration);
|
||||
if ((what & SIG_TONE_TX_UPDATE_REQUEST))
|
||||
{
|
||||
printf("Tx: update request\n");
|
||||
/* The signaling processor wants to know what to do next */
|
||||
if (sampleno < ms_to_samples(100))
|
||||
/* The sig tone transmit side wants to know what to do next */
|
||||
switch (tx_section)
|
||||
{
|
||||
/* 100ms off-hook */
|
||||
printf("100ms off-hook - %d samples\n", 800 - sampleno);
|
||||
return 0x02 | ((ms_to_samples(100) - sampleno) << 16);
|
||||
}
|
||||
else if (sampleno < ms_to_samples(600))
|
||||
{
|
||||
/* 500ms idle */
|
||||
printf("500ms idle - %d samples\n", ms_to_samples(600) - sampleno);
|
||||
return 0x02 | SIG_TONE_1_PRESENT | ((ms_to_samples(600) - sampleno) << 16);
|
||||
}
|
||||
else if (sampleno < ms_to_samples(700))
|
||||
{
|
||||
/* 100ms seize */
|
||||
printf("100ms seize - %d samples\n", ms_to_samples(700) - sampleno);
|
||||
return 0x02 | ((ms_to_samples(700) - sampleno) << 16);
|
||||
}
|
||||
else if (sampleno < ms_to_samples(1700))
|
||||
{
|
||||
if (ping)
|
||||
{
|
||||
printf("33ms break - %d samples\n", ms_to_samples(33));
|
||||
ping = !ping;
|
||||
return 0x02 | (ms_to_samples(33) << 16);
|
||||
}
|
||||
case 0:
|
||||
printf("33ms break - %d samples\n", ms_to_samples(33));
|
||||
tx_section++;
|
||||
sig_tone_tx_set_mode(s, SIG_TONE_1_PRESENT, ms_to_samples(33));
|
||||
break;
|
||||
case 1:
|
||||
printf("67ms make - %d samples\n", ms_to_samples(67));
|
||||
if (++dial_pulses == 9)
|
||||
tx_section++;
|
||||
else
|
||||
{
|
||||
printf("67ms make - %d samples\n", ms_to_samples(67));
|
||||
ping = !ping;
|
||||
return 0x02 | SIG_TONE_1_PRESENT | (ms_to_samples(67) << 16);
|
||||
}
|
||||
/*endif*/
|
||||
tx_section--;
|
||||
sig_tone_tx_set_mode(s, 0, ms_to_samples(67));
|
||||
break;
|
||||
case 2:
|
||||
tx_section++;
|
||||
sig_tone_tx_set_mode(s, SIG_TONE_1_PRESENT, ms_to_samples(600));
|
||||
break;
|
||||
case 3:
|
||||
sig_tone_tx_set_mode(s, SIG_TONE_1_PRESENT | SIG_TONE_TX_PASSTHROUGH, 0);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0x02 | SIG_TONE_1_PRESENT | ((ms_to_samples(700) - sampleno) << 16) | SIG_TONE_TX_PASSTHROUGH;
|
||||
}
|
||||
/*endif*/
|
||||
/*endswitch*/
|
||||
}
|
||||
/*endif*/
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static int rx_handler(void *user_data, int what)
|
||||
static void rx_handler(void *user_data, int what, int level, int duration)
|
||||
{
|
||||
//printf("What - %d\n", what);
|
||||
float ms;
|
||||
|
||||
ms = 1000.0f*(float) duration/(float) SAMPLE_RATE;
|
||||
printf("What - %d, duration - %d\n", what, duration);
|
||||
if ((what & SIG_TONE_1_CHANGE))
|
||||
{
|
||||
tone_1_present = what & SIG_TONE_1_PRESENT;
|
||||
printf("Rx: tone 1 is %s after %d samples\n", (tone_1_present) ? "on" : "off", (what >> 16) & 0xFFFF);
|
||||
printf("Rx: tone 1 is %s after %d samples (%fms)\n", (tone_1_present) ? "on" : "off", duration, ms);
|
||||
}
|
||||
/*endif*/
|
||||
if ((what & SIG_TONE_2_CHANGE))
|
||||
{
|
||||
tone_2_present = what & SIG_TONE_2_PRESENT;
|
||||
printf("Rx: tone 2 is %s after %d samples\n", (tone_2_present) ? "on" : "off", (what >> 16) & 0xFFFF);
|
||||
printf("Rx: tone 2 is %s after %d samples (%fms)\n", (tone_2_present) ? "on" : "off", duration, ms);
|
||||
}
|
||||
/*endif*/
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
void map_frequency_response(sig_tone_rx_state_t *s)
|
||||
static void map_frequency_response(sig_tone_rx_state_t *s)
|
||||
{
|
||||
int16_t buf[8192];
|
||||
awgn_state_t noise_source;
|
||||
int i;
|
||||
int f;
|
||||
uint32_t phase_acc;
|
||||
int32_t phase_rate;
|
||||
int32_t scaling;
|
||||
double sum;
|
||||
int len;
|
||||
double sumin;
|
||||
double sumout;
|
||||
swept_tone_state_t *swept;
|
||||
|
||||
/* Things like noise don't highlight the frequency response of the high Q notch
|
||||
very well. We use a slowly swept frequency to check it. */
|
||||
awgn_init_dbm0(&noise_source, 1234567, -10.0f);
|
||||
for (f = 1; f < 4000; f++)
|
||||
swept = swept_tone_init(NULL, 200.0f, 3900.0f, -10.0f, 120*SAMPLE_RATE, 0);
|
||||
for (;;)
|
||||
{
|
||||
phase_rate = dds_phase_rate(f);
|
||||
scaling = dds_scaling_dbm0(-10);
|
||||
phase_acc = 0;
|
||||
for (i = 0; i < 8192; i++)
|
||||
buf[i] = dds_mod(&phase_acc, phase_rate, scaling, 0);
|
||||
if ((len = swept_tone(swept, buf, SAMPLES_PER_CHUNK)) <= 0)
|
||||
break;
|
||||
sumin = 0.0;
|
||||
for (i = 0; i < len; i++)
|
||||
sumin += (double) buf[i]*(double) buf[i];
|
||||
sig_tone_rx(s, buf, len);
|
||||
sumout = 0.0;
|
||||
for (i = 0; i < len; i++)
|
||||
sumout += (double) buf[i]*(double) buf[i];
|
||||
/*endfor*/
|
||||
sig_tone_rx(s, buf, 8192);
|
||||
sum = 0.0;
|
||||
for (i = 1000; i < 8192; i++)
|
||||
sum += (double) buf[i]*(double) buf[i];
|
||||
/*endfor*/
|
||||
sum = sqrt(sum);
|
||||
printf("%7d %f\n", f, sum);
|
||||
printf("%7.1f %f\n", swept_tone_current_frequency(swept), 10.0*log10(sumout/sumin));
|
||||
}
|
||||
/*endfor*/
|
||||
swept_tone_free(swept);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@@ -189,45 +174,56 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
/*endif*/
|
||||
|
||||
awgn_init_dbm0(&noise_source, 1234567, -10.0f);
|
||||
awgn_init_dbm0(&noise_source, 1234567, -20.0f);
|
||||
|
||||
for (type = 1; type <= 3; type++)
|
||||
{
|
||||
sampleno = 0;
|
||||
tone_1_present = 0;
|
||||
tone_2_present = 0;
|
||||
ping = 0;
|
||||
tx_section = 0;
|
||||
munge = NULL;
|
||||
switch (type)
|
||||
{
|
||||
case 1:
|
||||
printf("2280Hz tests.\n");
|
||||
munge = codec_munge_init(MUNGE_CODEC_ALAW, 0);
|
||||
sig_tone_tx_init(&tx_state, SIG_TONE_2280HZ, tx_handler, NULL);
|
||||
sig_tone_rx_init(&rx_state, SIG_TONE_2280HZ, rx_handler, NULL);
|
||||
sig_tone_tx_init(&tx_state, SIG_TONE_2280HZ, tx_handler, &tx_state);
|
||||
sig_tone_rx_init(&rx_state, SIG_TONE_2280HZ, rx_handler, &rx_state);
|
||||
rx_state.current_rx_tone |= SIG_TONE_RX_PASSTHROUGH;
|
||||
break;
|
||||
case 2:
|
||||
printf("26000Hz tests.\n");
|
||||
printf("2600Hz tests.\n");
|
||||
munge = codec_munge_init(MUNGE_CODEC_ULAW, 0);
|
||||
sig_tone_tx_init(&tx_state, SIG_TONE_2600HZ, tx_handler, NULL);
|
||||
sig_tone_rx_init(&rx_state, SIG_TONE_2600HZ, rx_handler, NULL);
|
||||
sig_tone_tx_init(&tx_state, SIG_TONE_2600HZ, tx_handler, &tx_state);
|
||||
sig_tone_rx_init(&rx_state, SIG_TONE_2600HZ, rx_handler, &rx_state);
|
||||
rx_state.current_rx_tone |= SIG_TONE_RX_PASSTHROUGH;
|
||||
break;
|
||||
case 3:
|
||||
printf("2400Hz/26000Hz tests.\n");
|
||||
printf("2400Hz/2600Hz tests.\n");
|
||||
munge = codec_munge_init(MUNGE_CODEC_ULAW, 0);
|
||||
sig_tone_tx_init(&tx_state, SIG_TONE_2400HZ_2600HZ, tx_handler, NULL);
|
||||
sig_tone_rx_init(&rx_state, SIG_TONE_2400HZ_2600HZ, rx_handler, NULL);
|
||||
sig_tone_tx_init(&tx_state, SIG_TONE_2400HZ_2600HZ, tx_handler, &tx_state);
|
||||
sig_tone_rx_init(&rx_state, SIG_TONE_2400HZ_2600HZ, rx_handler, &rx_state);
|
||||
rx_state.current_rx_tone |= SIG_TONE_RX_PASSTHROUGH;
|
||||
break;
|
||||
}
|
||||
/*endswitch*/
|
||||
|
||||
//map_frequency_response(&rx_state);
|
||||
/* Set to the default of hook condition */
|
||||
sig_tone_rx_set_mode(&rx_state, SIG_TONE_RX_PASSTHROUGH | SIG_TONE_RX_FILTER_TONE, 0);
|
||||
sig_tone_tx_set_mode(&tx_state, SIG_TONE_1_PRESENT | SIG_TONE_2_PRESENT | SIG_TONE_TX_PASSTHROUGH, 0);
|
||||
|
||||
for (sampleno = 0; sampleno < 20000; sampleno += SAMPLES_PER_CHUNK)
|
||||
map_frequency_response(&rx_state);
|
||||
|
||||
sig_tone_rx_set_mode(&rx_state, SIG_TONE_RX_PASSTHROUGH, 0);
|
||||
for (sampleno = 0; sampleno < 30000; sampleno += SAMPLES_PER_CHUNK)
|
||||
{
|
||||
if (sampleno == 8000)
|
||||
{
|
||||
/* 100ms seize */
|
||||
printf("100ms seize - %d samples\n", ms_to_samples(100));
|
||||
dial_pulses = 0;
|
||||
sig_tone_tx_set_mode(&tx_state, 0, ms_to_samples(100));
|
||||
}
|
||||
for (i = 0; i < SAMPLES_PER_CHUNK; i++)
|
||||
amp[i] = awgn(&noise_source);
|
||||
/*endfor*/
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* SpanDSP - a series of DSP components for telephony
|
||||
*
|
||||
* swept_tone_tests.c
|
||||
*
|
||||
* Written by Steve Underwood <steveu@coppice.org>
|
||||
*
|
||||
* Copyright (C) 2009 Steve Underwood
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: swept_tone_tests.c,v 1.2 2009/09/22 13:28:18 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <memory.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
#include "spandsp.h"
|
||||
#include "spandsp-sim.h"
|
||||
|
||||
#define OUTPUT_FILE_NAME "swept_tone.wav"
|
||||
|
||||
#define BLOCK_LEN 160
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
int outframes;
|
||||
int len;
|
||||
SNDFILE *outhandle;
|
||||
power_meter_t meter;
|
||||
swept_tone_state_t *s;
|
||||
int16_t buf[BLOCK_LEN];
|
||||
|
||||
power_meter_init(&meter, 10);
|
||||
|
||||
if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
printf("Test with swept tone.\n");
|
||||
s = swept_tone_init(NULL, 200.0f, 3900.0f, -10.0f, 60*SAMPLE_RATE, 1);
|
||||
for (j = 0; j < 60*SAMPLE_RATE; j += BLOCK_LEN)
|
||||
{
|
||||
len = swept_tone(s, buf, BLOCK_LEN);
|
||||
for (i = 0; i < len; i++)
|
||||
power_meter_update(&meter, buf[i]);
|
||||
outframes = sf_writef_short(outhandle, buf, len);
|
||||
if (outframes != len)
|
||||
{
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
#if 0
|
||||
printf("Current freq %.1fHz, Level is %fdBOv/%fdBm0\n",
|
||||
swept_tone_current_frequency(s),
|
||||
power_meter_current_dbov(&meter),
|
||||
power_meter_current_dbm0(&meter));
|
||||
#else
|
||||
printf("%.1f %f\n",
|
||||
swept_tone_current_frequency(s),
|
||||
power_meter_current_dbm0(&meter));
|
||||
#endif
|
||||
}
|
||||
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
printf("Tests passed.\n");
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
Reference in new issue
Block a user