mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-09 21:14:02 +00:00
Updated SpanDSP to snapshot on 2009-06-03 with some additions:
Fixed VS2005 version of make_modem_filter Fixed a couple of places where declaration and definition of functions do not have the same calling conventions. Only relevant for Win32 compiles. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13831 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -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.114 2009/04/26 08:25:37 steveu Exp $
|
||||
## $Id: Makefile.am,v 1.116 2009/05/30 15:23:13 steveu Exp $
|
||||
|
||||
AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
|
||||
AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
|
||||
@@ -172,7 +172,7 @@ dc_restore_tests_SOURCES = dc_restore_tests.c
|
||||
dc_restore_tests_LDADD = $(LIBDIR) -lspandsp
|
||||
|
||||
dds_tests_SOURCES = dds_tests.c
|
||||
dds_tests_LDADD = $(LIBDIR) -lspandsp
|
||||
dds_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
|
||||
|
||||
dtmf_rx_tests_SOURCES = dtmf_rx_tests.c
|
||||
dtmf_rx_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
|
||||
@@ -196,7 +196,7 @@ g1050_tests_SOURCES = g1050_tests.c media_monitor.cpp
|
||||
g1050_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
|
||||
|
||||
g168_tests_SOURCES = g168_tests.c
|
||||
g168_tests_LDADD = $(LIBDIR) -lspandsp
|
||||
g168_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
|
||||
|
||||
g711_tests_SOURCES = g711_tests.c
|
||||
g711_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
|
||||
@@ -244,10 +244,10 @@ playout_tests_SOURCES = playout_tests.c media_monitor.cpp
|
||||
playout_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
|
||||
|
||||
plc_tests_SOURCES = plc_tests.c
|
||||
plc_tests_LDADD = $(LIBDIR) -lspandsp
|
||||
plc_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
|
||||
|
||||
power_meter_tests_SOURCES = power_meter_tests.c
|
||||
power_meter_tests_LDADD = $(LIBDIR) -lspandsp
|
||||
power_meter_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
|
||||
|
||||
queue_tests_SOURCES = queue_tests.c
|
||||
queue_tests_LDADD = $(LIBDIR) -lspandsp
|
||||
@@ -268,7 +268,7 @@ sig_tone_tests_SOURCES = sig_tone_tests.c
|
||||
sig_tone_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
|
||||
|
||||
super_tone_rx_tests_SOURCES = super_tone_rx_tests.c
|
||||
super_tone_rx_tests_LDADD = $(LIBDIR) -lspandsp
|
||||
super_tone_rx_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(LIBDIR) -lspandsp
|
||||
|
||||
super_tone_tx_tests_SOURCES = super_tone_tx_tests.c
|
||||
super_tone_tx_tests_LDADD = -L$(top_builddir)/spandsp-sim -lspandsp-sim $(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: adsi_tests.c,v 1.56 2009/04/26 07:24:35 steveu Exp $
|
||||
* $Id: adsi_tests.c,v 1.57 2009/05/30 15:23:13 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page adsi_tests_page ADSI tests
|
||||
@@ -48,7 +48,7 @@ tests, these tests do not include line modelling.
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -87,7 +87,7 @@ adsi_tx_state_t *tx_adsi;
|
||||
int current_standard = 0;
|
||||
int good_message_received;
|
||||
int log_audio = FALSE;
|
||||
AFfilehandle outhandle = NULL;
|
||||
SNDFILE *outhandle = NULL;
|
||||
int short_preamble = FALSE;
|
||||
|
||||
static int adsi_create_message(adsi_tx_state_t *s, uint8_t *msg)
|
||||
@@ -674,13 +674,12 @@ static void basic_tests(int standard)
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle,
|
||||
amp,
|
||||
len);
|
||||
if (outframes != len)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -696,27 +695,27 @@ static void mitel_cm7291_side_2_and_bellcore_tests(int standard)
|
||||
{
|
||||
int j;
|
||||
int16_t amp[BLOCK_LEN];
|
||||
AFfilehandle inhandle;
|
||||
SNDFILE *inhandle;
|
||||
int frames;
|
||||
|
||||
/* The remainder of the Mitel tape is the talk-off test */
|
||||
/* Here we use the Bellcore test tapes (much tougher), in six
|
||||
wave files - 1 from each side of the original 3 cassette tapes */
|
||||
files - 1 from each side of the original 3 cassette tapes */
|
||||
printf("Talk-off tests for %s\n", adsi_standard_to_str(standard));
|
||||
rx_adsi = adsi_rx_init(NULL, standard, put_adsi_msg, NULL);
|
||||
for (j = 0; bellcore_files[j][0]; j++)
|
||||
{
|
||||
printf("Testing with %s\n", bellcore_files[j]);
|
||||
if ((inhandle = afOpenFile_telephony_read(bellcore_files[j], 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(bellcore_files[j], 1)) == NULL)
|
||||
{
|
||||
printf(" Cannot open speech file '%s'\n", bellcore_files[j]);
|
||||
exit(2);
|
||||
}
|
||||
while ((frames = afReadFrames(inhandle, AF_DEFAULT_TRACK, amp, BLOCK_LEN)))
|
||||
while ((frames = sf_readf_short(inhandle, amp, BLOCK_LEN)))
|
||||
{
|
||||
adsi_rx(rx_adsi, amp, frames);
|
||||
}
|
||||
if (afCloseFile(inhandle) != 0)
|
||||
if (sf_close(inhandle) != 0)
|
||||
{
|
||||
printf(" Cannot close speech file '%s'\n", bellcore_files[j]);
|
||||
exit(2);
|
||||
@@ -735,7 +734,7 @@ static void mitel_cm7291_side_2_and_bellcore_tests(int standard)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int16_t amp[BLOCK_LEN];
|
||||
AFfilehandle inhandle;
|
||||
SNDFILE *inhandle;
|
||||
int len;
|
||||
int test_standard;
|
||||
int first_standard;
|
||||
@@ -793,16 +792,16 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
}
|
||||
outhandle = AF_NULL_FILEHANDLE;
|
||||
outhandle = NULL;
|
||||
|
||||
tdd_character_set_tests();
|
||||
|
||||
if (decode_test_file)
|
||||
{
|
||||
/* We will decode the audio from a wave file. */
|
||||
if ((inhandle = afOpenFile_telephony_read(decode_test_file, 1)) == AF_NULL_FILEHANDLE)
|
||||
/* We will decode the audio from a file. */
|
||||
if ((inhandle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", decode_test_file);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
if (test_standard < 0)
|
||||
@@ -817,17 +816,14 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
for (;;)
|
||||
{
|
||||
len = afReadFrames(inhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
BLOCK_LEN);
|
||||
len = sf_readf_short(inhandle, amp, BLOCK_LEN);
|
||||
if (len == 0)
|
||||
break;
|
||||
adsi_rx(rx_adsi, amp, len);
|
||||
}
|
||||
if (afCloseFile(inhandle) != 0)
|
||||
if (sf_close(inhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", decode_test_file);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
adsi_rx_free(rx_adsi);
|
||||
@@ -836,9 +832,9 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (log_audio)
|
||||
{
|
||||
if ((outhandle = afOpenFile_telephony_write(OUTPUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -863,9 +859,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: async_tests.c,v 1.18 2008/11/30 10:17:31 steveu Exp $
|
||||
* $Id: async_tests.c,v 1.19 2009/05/30 15:23:13 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
|
||||
@@ -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: at_interpreter_tests.c,v 1.22 2009/04/24 22:35:25 steveu Exp $
|
||||
* $Id: at_interpreter_tests.c,v 1.23 2009/05/30 15:23:13 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -42,7 +42,7 @@ These tests exercise all the commands which should be understood by the AT inter
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
#include "spandsp.h"
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: bell_mf_rx_tests.c,v 1.15 2009/04/11 18:11:19 steveu Exp $
|
||||
* $Id: bell_mf_rx_tests.c,v 1.16 2009/05/30 15:23:13 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -48,7 +48,7 @@ a fair test of performance in a real PSTN channel.
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
|
||||
@@ -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: bell_mf_tx_tests.c,v 1.14 2008/11/30 10:17:31 steveu Exp $
|
||||
* $Id: bell_mf_tx_tests.c,v 1.15 2009/05/30 15:23:13 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -60,55 +60,40 @@ int main(int argc, char *argv[])
|
||||
bell_mf_tx_state_t *gen;
|
||||
int16_t amp[16384];
|
||||
int len;
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *outhandle;
|
||||
int outframes;
|
||||
int add_digits;
|
||||
|
||||
if ((outhandle = afOpenFile_telephony_write(OUTPUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
gen = bell_mf_tx_init(NULL);
|
||||
len = bell_mf_tx(gen, amp, 16384);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (bell_mf_tx_put(gen, "123", -1))
|
||||
printf("Ooops\n");
|
||||
len = bell_mf_tx(gen, amp, 16384);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (bell_mf_tx_put(gen, "456", -1))
|
||||
printf("Ooops\n");
|
||||
len = bell_mf_tx(gen, amp, 160);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (bell_mf_tx_put(gen, "789", -1))
|
||||
printf("Ooops\n");
|
||||
len = bell_mf_tx(gen, amp, 160);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (bell_mf_tx_put(gen, "*#", -1))
|
||||
printf("Ooops\n");
|
||||
len = bell_mf_tx(gen, amp, 160);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
add_digits = 1;
|
||||
do
|
||||
{
|
||||
@@ -116,10 +101,7 @@ int main(int argc, char *argv[])
|
||||
printf("Generated %d samples\n", len);
|
||||
if (len > 0)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
if (add_digits)
|
||||
{
|
||||
@@ -135,50 +117,32 @@ int main(int argc, char *argv[])
|
||||
bell_mf_tx_init(gen);
|
||||
len = bell_mf_tx(gen, amp, 16384);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (bell_mf_tx_put(gen, "123", -1))
|
||||
printf("Ooops\n");
|
||||
len = bell_mf_tx(gen, amp, 16384);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (bell_mf_tx_put(gen, "456", -1))
|
||||
printf("Ooops\n");
|
||||
len = bell_mf_tx(gen, amp, 160);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (bell_mf_tx_put(gen, "789", -1))
|
||||
printf("Ooops\n");
|
||||
len = bell_mf_tx(gen, amp, 160);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (bell_mf_tx_put(gen, "0*#", -1))
|
||||
printf("Ooops\n");
|
||||
len = bell_mf_tx(gen, amp, 160);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (bell_mf_tx_put(gen, "ABC", -1))
|
||||
printf("Ooops\n");
|
||||
len = bell_mf_tx(gen, amp, 160);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
add_digits = 1;
|
||||
do
|
||||
{
|
||||
@@ -186,10 +150,7 @@ int main(int argc, char *argv[])
|
||||
printf("Generated %d samples\n", len);
|
||||
if (len > 0)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
if (add_digits)
|
||||
{
|
||||
@@ -202,9 +163,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
while (len > 0);
|
||||
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit (2);
|
||||
}
|
||||
|
||||
|
||||
@@ -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: bert_tests.c,v 1.27 2009/04/14 16:04:54 steveu Exp $
|
||||
* $Id: bert_tests.c,v 1.28 2009/05/30 15:23:13 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -40,7 +40,7 @@ These tests exercise each of the BERT standards supported by the BERT module.
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
|
||||
@@ -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: dds_tests.c,v 1.24 2008/05/13 13:17:25 steveu Exp $
|
||||
* $Id: dds_tests.c,v 1.26 2009/06/02 14:55:36 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -43,9 +43,10 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <memory.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
#include "spandsp.h"
|
||||
#include "spandsp-sim.h"
|
||||
|
||||
#define OUTPUT_FILE_NAME "dds.wav"
|
||||
#define OUTPUT_FILE_NAME_COMPLEX "complex_dds.wav"
|
||||
@@ -60,8 +61,7 @@ int main(int argc, char *argv[])
|
||||
int outframes;
|
||||
complexf_t camp;
|
||||
int16_t buf[2*SAMPLES_PER_CHUNK];
|
||||
AFfilehandle outhandle;
|
||||
AFfilesetup filesetup;
|
||||
SNDFILE *outhandle;
|
||||
power_meter_t meter;
|
||||
power_meter_t meter_i;
|
||||
power_meter_t meter_q;
|
||||
@@ -70,19 +70,9 @@ int main(int argc, char *argv[])
|
||||
power_meter_init(&meter, 10);
|
||||
|
||||
printf("Non-complex DDS tests.\n");
|
||||
if ((filesetup = afNewFileSetup()) == AF_NULL_FILESETUP)
|
||||
if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to create file setup\n");
|
||||
exit(2);
|
||||
}
|
||||
afInitSampleFormat(filesetup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
|
||||
afInitRate(filesetup, AF_DEFAULT_TRACK, (float) SAMPLE_RATE);
|
||||
afInitFileFormat(filesetup, AF_FILE_WAVE);
|
||||
afInitChannels(filesetup, AF_DEFAULT_TRACK, 1);
|
||||
|
||||
if ((outhandle = afOpenFile(OUTPUT_FILE_NAME, "w", filesetup)) == AF_NULL_FILEHANDLE)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@@ -96,13 +86,10 @@ int main(int argc, char *argv[])
|
||||
buf[i] = alaw_to_linear(linear_to_alaw((dds(&phase, phase_inc)*scale) >> 15));
|
||||
power_meter_update(&meter, buf[i]);
|
||||
}
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
buf,
|
||||
SAMPLES_PER_CHUNK);
|
||||
outframes = sf_writef_short(outhandle, buf, SAMPLES_PER_CHUNK);
|
||||
if (outframes != SAMPLES_PER_CHUNK)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
printf("Level is %fdBOv/%fdBm0\n", power_meter_current_dbov(&meter), power_meter_current_dbm0(&meter));
|
||||
@@ -119,13 +106,10 @@ int main(int argc, char *argv[])
|
||||
buf[i] = alaw_to_linear(linear_to_alaw(dds(&phase, phase_inc)));
|
||||
power_meter_update(&meter, buf[i]);
|
||||
}
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
buf,
|
||||
SAMPLES_PER_CHUNK);
|
||||
outframes = sf_writef_short(outhandle, buf, SAMPLES_PER_CHUNK);
|
||||
if (outframes != SAMPLES_PER_CHUNK)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
printf("Level is %fdBOv/%fdBm0\n", power_meter_current_dbov(&meter), power_meter_current_dbm0(&meter));
|
||||
@@ -144,13 +128,10 @@ int main(int argc, char *argv[])
|
||||
buf[i] = alaw_to_linear(linear_to_alaw((dds(&phase, phase_inc)*scale) >> 15));
|
||||
power_meter_update(&meter, buf[i]);
|
||||
}
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
buf,
|
||||
SAMPLES_PER_CHUNK);
|
||||
outframes = sf_writef_short(outhandle, buf, SAMPLES_PER_CHUNK);
|
||||
if (outframes != SAMPLES_PER_CHUNK)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
printf("Level is %fdBOv/%fdBm0\n", power_meter_current_dbov(&meter), power_meter_current_dbm0(&meter));
|
||||
@@ -167,13 +148,10 @@ int main(int argc, char *argv[])
|
||||
buf[i] = alaw_to_linear(linear_to_alaw(dds(&phase, phase_inc)));
|
||||
power_meter_update(&meter, buf[i]);
|
||||
}
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
buf,
|
||||
SAMPLES_PER_CHUNK);
|
||||
outframes = sf_writef_short(outhandle, buf, SAMPLES_PER_CHUNK);
|
||||
if (outframes != SAMPLES_PER_CHUNK)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
printf("Level is %fdBOv/%fdBm0\n", power_meter_current_dbov(&meter), power_meter_current_dbm0(&meter));
|
||||
@@ -183,27 +161,16 @@ int main(int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
afFreeFileSetup(filesetup);
|
||||
|
||||
printf("Complex DDS tests,\n");
|
||||
if ((filesetup = afNewFileSetup()) == AF_NULL_FILESETUP)
|
||||
if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME_COMPLEX, 2)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to create file setup\n");
|
||||
exit(2);
|
||||
}
|
||||
afInitSampleFormat(filesetup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
|
||||
afInitRate(filesetup, AF_DEFAULT_TRACK, (float) SAMPLE_RATE);
|
||||
afInitFileFormat(filesetup, AF_FILE_WAVE);
|
||||
afInitChannels(filesetup, AF_DEFAULT_TRACK, 2);
|
||||
|
||||
if ((outhandle = afOpenFile(OUTPUT_FILE_NAME_COMPLEX, "w", filesetup)) == AF_NULL_FILEHANDLE)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUTPUT_FILE_NAME_COMPLEX);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME_COMPLEX);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@@ -220,13 +187,10 @@ int main(int argc, char *argv[])
|
||||
power_meter_update(&meter_i, buf[2*i]);
|
||||
power_meter_update(&meter_q, buf[2*i]);
|
||||
}
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
buf,
|
||||
SAMPLES_PER_CHUNK);
|
||||
outframes = sf_writef_short(outhandle, buf, SAMPLES_PER_CHUNK);
|
||||
if (outframes != SAMPLES_PER_CHUNK)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
printf("Level is %fdBOv/%fdBm0, %fdBOv/%fdBm0\n",
|
||||
@@ -242,12 +206,11 @@ int main(int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUTPUT_FILE_NAME_COMPLEX);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME_COMPLEX);
|
||||
exit(2);
|
||||
}
|
||||
afFreeFileSetup(filesetup);
|
||||
|
||||
printf("Tests passed.\n");
|
||||
return 0;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: dtmf_rx_tests.c,v 1.44 2008/11/30 10:17:31 steveu Exp $
|
||||
* $Id: dtmf_rx_tests.c,v 1.45 2009/05/30 15:23:13 steveu Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -94,7 +94,7 @@ they wish to give it away for free.
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -623,7 +623,7 @@ static void mitel_cm7291_side_2_and_bellcore_tests(void)
|
||||
int hits;
|
||||
int hit_types[256];
|
||||
char buf[128 + 1];
|
||||
AFfilehandle inhandle;
|
||||
SNDFILE *inhandle;
|
||||
int frames;
|
||||
dtmf_rx_state_t *dtmf_state;
|
||||
|
||||
@@ -633,7 +633,7 @@ static void mitel_cm7291_side_2_and_bellcore_tests(void)
|
||||
|
||||
/* The remainder of the Mitel tape is the talk-off test */
|
||||
/* Here we use the Bellcore test tapes (much tougher), in six
|
||||
wave files - 1 from each side of the original 3 cassette tapes */
|
||||
files - 1 from each side of the original 3 cassette tapes */
|
||||
/* Bellcore say you should get no more than 470 false detections with
|
||||
a good receiver. Dialogic claim 20. Of course, we can do better than
|
||||
that, eh? */
|
||||
@@ -641,13 +641,13 @@ static void mitel_cm7291_side_2_and_bellcore_tests(void)
|
||||
memset(hit_types, '\0', sizeof(hit_types));
|
||||
for (j = 0; bellcore_files[j][0]; j++)
|
||||
{
|
||||
if ((inhandle = afOpenFile_telephony_read(bellcore_files[j], 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(bellcore_files[j], 1)) == NULL)
|
||||
{
|
||||
printf(" Cannot open speech file '%s'\n", bellcore_files[j]);
|
||||
exit(2);
|
||||
}
|
||||
hits = 0;
|
||||
while ((frames = afReadFrames(inhandle, AF_DEFAULT_TRACK, amp, SAMPLE_RATE)))
|
||||
while ((frames = sf_readf_short(inhandle, amp, SAMPLE_RATE)))
|
||||
{
|
||||
dtmf_rx(dtmf_state, amp, frames);
|
||||
len = dtmf_rx_get(dtmf_state, buf, 128);
|
||||
@@ -658,7 +658,7 @@ static void mitel_cm7291_side_2_and_bellcore_tests(void)
|
||||
hits += len;
|
||||
}
|
||||
}
|
||||
if (afCloseFile(inhandle) != 0)
|
||||
if (sf_close(inhandle) != 0)
|
||||
{
|
||||
printf(" Cannot close speech file '%s'\n", bellcore_files[j]);
|
||||
exit(2);
|
||||
@@ -804,7 +804,7 @@ static void callback_function_tests(void)
|
||||
static void decode_test(const char *test_file)
|
||||
{
|
||||
int16_t amp[SAMPLES_PER_CHUNK];
|
||||
AFfilehandle inhandle;
|
||||
SNDFILE *inhandle;
|
||||
dtmf_rx_state_t *dtmf_state;
|
||||
char buf[128 + 1];
|
||||
int actual;
|
||||
@@ -815,16 +815,16 @@ static void decode_test(const char *test_file)
|
||||
if (use_dialtone_filter)
|
||||
dtmf_rx_parms(dtmf_state, TRUE, -1, -1, -99);
|
||||
|
||||
/* We will decode the audio from a wave file. */
|
||||
/* We will decode the audio from a file. */
|
||||
|
||||
if ((inhandle = afOpenFile_telephony_read(decode_test_file, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", decode_test_file);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
total = 0;
|
||||
while ((samples = afReadFrames(inhandle, AF_DEFAULT_TRACK, amp, SAMPLES_PER_CHUNK)) > 0)
|
||||
while ((samples = sf_readf_short(inhandle, amp, SAMPLES_PER_CHUNK)) > 0)
|
||||
{
|
||||
codec_munge(munge, amp, samples);
|
||||
dtmf_rx(dtmf_state, amp, samples);
|
||||
|
||||
@@ -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: dtmf_tx_tests.c,v 1.22 2008/11/30 10:17:31 steveu Exp $
|
||||
* $Id: dtmf_tx_tests.c,v 1.23 2009/05/30 15:23:13 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -60,40 +60,52 @@ int main(int argc, char *argv[])
|
||||
dtmf_tx_state_t *gen;
|
||||
int16_t amp[16384];
|
||||
int len;
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *outhandle;
|
||||
int outframes;
|
||||
int add_digits;
|
||||
|
||||
if ((outhandle = afOpenFile_telephony_write(OUTPUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
gen = dtmf_tx_init(NULL);
|
||||
len = dtmf_tx(gen, amp, 16384);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, amp, len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (dtmf_tx_put(gen, "123", -1))
|
||||
{
|
||||
printf("Ooops\n");
|
||||
exit(2);
|
||||
}
|
||||
len = dtmf_tx(gen, amp, 16384);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, amp, len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (dtmf_tx_put(gen, "456", -1))
|
||||
{
|
||||
printf("Ooops\n");
|
||||
exit(2);
|
||||
}
|
||||
len = dtmf_tx(gen, amp, 160);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, amp, len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (dtmf_tx_put(gen, "789", -1))
|
||||
{
|
||||
printf("Ooops\n");
|
||||
exit(2);
|
||||
}
|
||||
len = dtmf_tx(gen, amp, 160);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, amp, len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (dtmf_tx_put(gen, "*#", -1))
|
||||
{
|
||||
printf("Ooops\n");
|
||||
exit(2);
|
||||
}
|
||||
len = dtmf_tx(gen, amp, 160);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, amp, len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
add_digits = 1;
|
||||
do
|
||||
{
|
||||
@@ -101,7 +113,7 @@ int main(int argc, char *argv[])
|
||||
printf("Generated %d samples\n", len);
|
||||
if (len > 0)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, amp, len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
if (add_digits)
|
||||
{
|
||||
@@ -117,52 +129,73 @@ int main(int argc, char *argv[])
|
||||
dtmf_tx_init(gen);
|
||||
len = dtmf_tx(gen, amp, 16384);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, amp, len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (dtmf_tx_put(gen, "123", -1))
|
||||
{
|
||||
printf("Ooops\n");
|
||||
exit(2);
|
||||
}
|
||||
len = dtmf_tx(gen, amp, 16384);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, amp, len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (dtmf_tx_put(gen, "456", -1))
|
||||
{
|
||||
printf("Ooops\n");
|
||||
exit(2);
|
||||
}
|
||||
len = dtmf_tx(gen, amp, 160);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, amp, len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (dtmf_tx_put(gen, "789", -1))
|
||||
{
|
||||
printf("Ooops\n");
|
||||
exit(2);
|
||||
}
|
||||
len = dtmf_tx(gen, amp, 160);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, amp, len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (dtmf_tx_put(gen, "0*#", -1))
|
||||
{
|
||||
printf("Ooops\n");
|
||||
exit(2);
|
||||
}
|
||||
len = dtmf_tx(gen, amp, 160);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, amp, len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (dtmf_tx_put(gen, "ABCD", -1))
|
||||
{
|
||||
printf("Ooops\n");
|
||||
exit(2);
|
||||
}
|
||||
len = dtmf_tx(gen, amp, 160);
|
||||
printf("Generated %d samples\n", len);
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, amp, len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
|
||||
/* Try modifying the level and length of the digits */
|
||||
printf("Try different levels and timing\n");
|
||||
dtmf_tx_set_level(gen, -20, 5);
|
||||
dtmf_tx_set_timing(gen, 100, 200);
|
||||
if (dtmf_tx_put(gen, "123", -1))
|
||||
{
|
||||
printf("Ooops\n");
|
||||
exit(2);
|
||||
}
|
||||
do
|
||||
{
|
||||
len = dtmf_tx(gen, amp, 160);
|
||||
printf("Generated %d samples\n", len);
|
||||
if (len > 0)
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, amp, len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
while (len > 0);
|
||||
printf("Restore normal levels and timing\n");
|
||||
dtmf_tx_set_level(gen, -10, 0);
|
||||
dtmf_tx_set_timing(gen, 50, 55);
|
||||
if (dtmf_tx_put(gen, "A", -1))
|
||||
{
|
||||
printf("Ooops\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
add_digits = TRUE;
|
||||
do
|
||||
@@ -171,7 +204,7 @@ int main(int argc, char *argv[])
|
||||
printf("Generated %d samples\n", len);
|
||||
if (len > 0)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, amp, len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
if (add_digits)
|
||||
{
|
||||
@@ -184,10 +217,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
while (len > 0);
|
||||
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit (2);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: echo_tests.c,v 1.38 2009/02/10 13:06:47 steveu Exp $
|
||||
* $Id: echo_tests.c,v 1.39 2009/05/30 15:23:13 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page echo_can_tests_page Line echo cancellation for voice tests
|
||||
@@ -54,7 +54,7 @@ all the tests in G.168 are fully implemented at this time.
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <assert.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
#define GEN_CONST
|
||||
#include <math.h>
|
||||
@@ -107,7 +107,7 @@ typedef struct
|
||||
int max;
|
||||
int cur;
|
||||
float gain;
|
||||
AFfilehandle handle;
|
||||
SNDFILE *handle;
|
||||
int16_t signal[SAMPLE_RATE];
|
||||
} signal_source_t;
|
||||
|
||||
@@ -139,7 +139,7 @@ signal_source_t far_css;
|
||||
awgn_state_t local_noise_source;
|
||||
awgn_state_t far_noise_source;
|
||||
|
||||
AFfilehandle residue_handle;
|
||||
SNDFILE *residue_handle;
|
||||
int16_t residue_sound[SAMPLE_RATE];
|
||||
int residue_cur = 0;
|
||||
|
||||
@@ -157,7 +157,7 @@ level_measurement_device_t *sout_power_meter; /* Also known as Lret (pre NLP v
|
||||
level_measurement_device_t *sgen_power_meter;
|
||||
|
||||
#define RESULT_CHANNELS 7
|
||||
AFfilehandle result_handle;
|
||||
SNDFILE *result_handle;
|
||||
int16_t result_sound[SAMPLE_RATE*RESULT_CHANNELS];
|
||||
int result_cur;
|
||||
|
||||
@@ -188,10 +188,7 @@ static inline void put_residue(int16_t amp)
|
||||
residue_sound[residue_cur++] = amp;
|
||||
if (residue_cur >= SAMPLE_RATE)
|
||||
{
|
||||
outframes = afWriteFrames(residue_handle,
|
||||
AF_DEFAULT_TRACK,
|
||||
residue_sound,
|
||||
residue_cur);
|
||||
outframes = sf_writef_short(residue_handle, residue_sound, residue_cur);
|
||||
if (outframes != residue_cur)
|
||||
{
|
||||
fprintf(stderr, " Error writing residue sound\n");
|
||||
@@ -204,9 +201,9 @@ static inline void put_residue(int16_t amp)
|
||||
|
||||
static void signal_load(signal_source_t *sig, const char *name)
|
||||
{
|
||||
sig->handle = afOpenFile_telephony_read(name, 1);
|
||||
sig->handle = sf_open_telephony_read(name, 1);
|
||||
sig->name = name;
|
||||
sig->max = afReadFrames(sig->handle, AF_DEFAULT_TRACK, sig->signal, SAMPLE_RATE);
|
||||
sig->max = sf_readf_short(sig->handle, sig->signal, SAMPLE_RATE);
|
||||
if (sig->max < 0)
|
||||
{
|
||||
fprintf(stderr, " Error reading sound file '%s'\n", sig->name);
|
||||
@@ -217,7 +214,7 @@ static void signal_load(signal_source_t *sig, const char *name)
|
||||
|
||||
static void signal_free(signal_source_t *sig)
|
||||
{
|
||||
if (afCloseFile(sig->handle) != 0)
|
||||
if (sf_close(sig->handle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close sound file '%s'\n", sig->name);
|
||||
exit(2);
|
||||
@@ -597,10 +594,7 @@ static void run_test(echo_can_state_t *ctx, int16_t (*tx_source)(void), int16_t
|
||||
result_sound[result_cur++] = 0; // TODO: insert the EC's internal status here
|
||||
if (result_cur >= RESULT_CHANNELS*SAMPLE_RATE)
|
||||
{
|
||||
outframes = afWriteFrames(result_handle,
|
||||
AF_DEFAULT_TRACK,
|
||||
result_sound,
|
||||
result_cur/RESULT_CHANNELS);
|
||||
outframes = sf_writef_short(result_handle, result_sound, result_cur/RESULT_CHANNELS);
|
||||
if (outframes != result_cur/RESULT_CHANNELS)
|
||||
{
|
||||
fprintf(stderr, " Error writing result sound\n");
|
||||
@@ -615,10 +609,7 @@ static void run_test(echo_can_state_t *ctx, int16_t (*tx_source)(void), int16_t
|
||||
#endif
|
||||
if (result_cur >= 0)
|
||||
{
|
||||
outframes = afWriteFrames(result_handle,
|
||||
AF_DEFAULT_TRACK,
|
||||
result_sound,
|
||||
result_cur/RESULT_CHANNELS);
|
||||
outframes = sf_writef_short(result_handle, result_sound, result_cur/RESULT_CHANNELS);
|
||||
if (outframes != result_cur/RESULT_CHANNELS)
|
||||
{
|
||||
fprintf(stderr, " Error writing result sound\n");
|
||||
@@ -678,7 +669,7 @@ static int perform_test_sanity(void)
|
||||
/* Inject a burst of far sound */
|
||||
if (far_cur >= far_max)
|
||||
{
|
||||
far_max = afReadFrames(farhandle, AF_DEFAULT_TRACK, far_sound, SAMPLE_RATE);
|
||||
far_max = sf_readf_short(farhandle, far_sound, SAMPLE_RATE);
|
||||
if (far_max < 0)
|
||||
{
|
||||
fprintf(stderr, " Error reading far sound\n");
|
||||
@@ -734,10 +725,7 @@ static int perform_test_sanity(void)
|
||||
put_residue(clean - far_tx);
|
||||
if (result_cur >= RESULT_CHANNELS*SAMPLE_RATE)
|
||||
{
|
||||
outframes = afWriteFrames(result_handle,
|
||||
AF_DEFAULT_TRACK,
|
||||
result_sound,
|
||||
result_cur/RESULT_CHANNELS);
|
||||
outframes = sf_writef_short(result_handle, result_sound, result_cur/RESULT_CHANNELS);
|
||||
if (outframes != result_cur/RESULT_CHANNELS)
|
||||
{
|
||||
fprintf(stderr, " Error writing result sound\n");
|
||||
@@ -748,10 +736,7 @@ static int perform_test_sanity(void)
|
||||
}
|
||||
if (result_cur > 0)
|
||||
{
|
||||
outframes = afWriteFrames(result_handle,
|
||||
AF_DEFAULT_TRACK,
|
||||
result_sound,
|
||||
result_cur/RESULT_CHANNELS);
|
||||
outframes = sf_writef_short(result_handle, result_sound, result_cur/RESULT_CHANNELS);
|
||||
if (outframes != result_cur/RESULT_CHANNELS)
|
||||
{
|
||||
fprintf(stderr, " Error writing result sound\n");
|
||||
@@ -1494,10 +1479,10 @@ static int match_test_name(const char *name)
|
||||
static void simulate_ec(char *argv[], int two_channel_file, int mode)
|
||||
{
|
||||
echo_can_state_t *ctx;
|
||||
AFfilehandle txfile;
|
||||
AFfilehandle rxfile;
|
||||
AFfilehandle rxtxfile;
|
||||
AFfilehandle ecfile;
|
||||
SNDFILE *txfile;
|
||||
SNDFILE *rxfile;
|
||||
SNDFILE *rxtxfile;
|
||||
SNDFILE *ecfile;
|
||||
int ntx;
|
||||
int nrx;
|
||||
int nec;
|
||||
@@ -1515,14 +1500,14 @@ static void simulate_ec(char *argv[], int two_channel_file, int mode)
|
||||
ecfile = NULL;
|
||||
if (two_channel_file)
|
||||
{
|
||||
txfile = afOpenFile_telephony_read(argv[0], 1);
|
||||
rxfile = afOpenFile_telephony_read(argv[1], 1);
|
||||
ecfile = afOpenFile_telephony_write(argv[2], 1);
|
||||
txfile = sf_open_telephony_read(argv[0], 1);
|
||||
rxfile = sf_open_telephony_read(argv[1], 1);
|
||||
ecfile = sf_open_telephony_write(argv[2], 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
rxtxfile = afOpenFile_telephony_read(argv[0], 2);
|
||||
ecfile = afOpenFile_telephony_write(argv[1], 1);
|
||||
rxtxfile = sf_open_telephony_read(argv[0], 2);
|
||||
ecfile = sf_open_telephony_write(argv[1], 1);
|
||||
}
|
||||
|
||||
ctx = echo_can_init(TEST_EC_TAPS, 0);
|
||||
@@ -1532,7 +1517,7 @@ static void simulate_ec(char *argv[], int two_channel_file, int mode)
|
||||
{
|
||||
if (two_channel_file)
|
||||
{
|
||||
if ((ntx = afReadFrames(rxtxfile, AF_DEFAULT_TRACK, buf, 1)) < 0)
|
||||
if ((ntx = sf_readf_short(rxtxfile, buf, 1)) < 0)
|
||||
{
|
||||
fprintf(stderr, " Error reading tx sound file\n");
|
||||
exit(2);
|
||||
@@ -1543,12 +1528,12 @@ static void simulate_ec(char *argv[], int two_channel_file, int mode)
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((ntx = afReadFrames(txfile, AF_DEFAULT_TRACK, &rin, 1)) < 0)
|
||||
if ((ntx = sf_readf_short(txfile, &rin, 1)) < 0)
|
||||
{
|
||||
fprintf(stderr, " Error reading tx sound file\n");
|
||||
exit(2);
|
||||
}
|
||||
if ((nrx = afReadFrames(rxfile, AF_DEFAULT_TRACK, &sin, 1)) < 0)
|
||||
if ((nrx = sf_readf_short(rxfile, &sin, 1)) < 0)
|
||||
{
|
||||
fprintf(stderr, " Error reading rx sound file\n");
|
||||
exit(2);
|
||||
@@ -1557,7 +1542,7 @@ static void simulate_ec(char *argv[], int two_channel_file, int mode)
|
||||
rout = echo_can_hpf_tx(ctx, rin);
|
||||
sout = echo_can_update(ctx, rout, sin);
|
||||
|
||||
if ((nec = afWriteFrames(ecfile, AF_DEFAULT_TRACK, &sout, 1)) != 1)
|
||||
if ((nec = sf_writef_short(ecfile, &sout, 1)) != 1)
|
||||
{
|
||||
fprintf(stderr, " Error writing ec sound file\n");
|
||||
exit(2);
|
||||
@@ -1576,14 +1561,14 @@ static void simulate_ec(char *argv[], int two_channel_file, int mode)
|
||||
|
||||
if (two_channel_file)
|
||||
{
|
||||
afCloseFile(rxtxfile);
|
||||
sf_close(rxtxfile);
|
||||
}
|
||||
else
|
||||
{
|
||||
afCloseFile(txfile);
|
||||
afCloseFile(rxfile);
|
||||
sf_close(txfile);
|
||||
sf_close(rxfile);
|
||||
}
|
||||
afCloseFile(ecfile);
|
||||
sf_close(ecfile);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@@ -1666,8 +1651,8 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
if (simulate)
|
||||
{
|
||||
/* Process a pair of transmitted and received wave files, and produce
|
||||
an echo cancelled wave file. */
|
||||
/* Process a pair of transmitted and received audio files, and produce
|
||||
an echo cancelled audio file. */
|
||||
if (argc < ((two_channel_file) ? 2 : 3))
|
||||
{
|
||||
printf("not enough arguments for a simulation\n");
|
||||
@@ -1692,7 +1677,7 @@ int main(int argc, char *argv[])
|
||||
signal_load(&local_css, "sound_c1_8k.wav");
|
||||
signal_load(&far_css, "sound_c3_8k.wav");
|
||||
|
||||
if ((residue_handle = afOpenFile_telephony_write(RESIDUE_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((residue_handle = sf_open_telephony_write(RESIDUE_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to open '%s'\n", RESIDUE_FILE_NAME);
|
||||
exit(2);
|
||||
@@ -1704,7 +1689,7 @@ int main(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
time(&now);
|
||||
if ((result_handle = afOpenFile_telephony_write("echo_tests_result.wav", RESULT_CHANNELS)) == AF_NULL_FILEHANDLE)
|
||||
if ((result_handle = sf_open_telephony_write("echo_tests_result.wav", RESULT_CHANNELS)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to open result file\n");
|
||||
exit(2);
|
||||
@@ -1720,7 +1705,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
match_test_name(argv[i]);
|
||||
}
|
||||
if (afCloseFile(result_handle) != 0)
|
||||
if (sf_close(result_handle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close speech file '%s'\n", "result_sound.wav");
|
||||
exit(2);
|
||||
@@ -1729,7 +1714,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
signal_free(&local_css);
|
||||
signal_free(&far_css);
|
||||
if (afCloseFile(residue_handle) != 0)
|
||||
if (sf_close(residue_handle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close speech file '%s'\n", RESIDUE_FILE_NAME);
|
||||
exit(2);
|
||||
|
||||
@@ -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.55 2009/04/29 12:37:45 steveu Exp $
|
||||
* $Id: fax_decode.c,v 1.56 2009/05/30 15:23:13 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page fax_decode_page FAX decoder
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -446,10 +446,10 @@ int main(int argc, char *argv[])
|
||||
v29_rx_state_t *v29;
|
||||
v27ter_rx_state_t *v27ter;
|
||||
int16_t amp[SAMPLES_PER_CHUNK];
|
||||
AFfilehandle inhandle;
|
||||
SNDFILE *inhandle;
|
||||
SF_INFO info;
|
||||
int len;
|
||||
const char *filename;
|
||||
float x;
|
||||
logging_state_t *logging;
|
||||
|
||||
filename = "fax_samp.wav";
|
||||
@@ -457,26 +457,23 @@ int main(int argc, char *argv[])
|
||||
if (argc > 1)
|
||||
filename = argv[1];
|
||||
|
||||
if ((inhandle = afOpenFile(filename, "r", NULL)) == AF_NULL_FILEHANDLE)
|
||||
memset(&info, 0, sizeof(info));
|
||||
if ((inhandle = sf_open(filename, SFM_READ, &info)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", filename);
|
||||
fprintf(stderr, " Cannot open audio file '%s' for reading\n", filename);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetFrameSize(inhandle, AF_DEFAULT_TRACK, 1)) != 2.0)
|
||||
if (info.samplerate != SAMPLE_RATE)
|
||||
{
|
||||
printf(" Unexpected frame size in speech file '%s' (%f)\n", filename, x);
|
||||
printf(" Unexpected sample rate in audio file '%s'\n", filename);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetRate(inhandle, AF_DEFAULT_TRACK)) != (float) SAMPLE_RATE)
|
||||
if (info.channels != 1)
|
||||
{
|
||||
printf(" Unexpected sample rate in speech file '%s' (%f)\n", filename, x);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetChannels(inhandle, AF_DEFAULT_TRACK)) != 1.0)
|
||||
{
|
||||
printf(" Unexpected number of channels in speech file '%s' (%f)\n", filename, x);
|
||||
printf(" Unexpected number of channels in audio file '%s'\n", filename);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
memset(&t30_dummy, 0, sizeof(t30_dummy));
|
||||
span_log_init(&t30_dummy.logging, SPAN_LOG_FLOW, NULL);
|
||||
span_log_set_protocol(&t30_dummy.logging, "T.30");
|
||||
@@ -517,7 +514,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (;;)
|
||||
{
|
||||
len = afReadFrames(inhandle, AF_DEFAULT_TRACK, amp, SAMPLES_PER_CHUNK);
|
||||
len = sf_readf_short(inhandle, amp, SAMPLES_PER_CHUNK);
|
||||
if (len < SAMPLES_PER_CHUNK)
|
||||
break;
|
||||
fsk_rx(fsk, amp, len);
|
||||
@@ -527,9 +524,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
t4_rx_release(&t4_state);
|
||||
|
||||
if (afCloseFile(inhandle) != 0)
|
||||
if (sf_close(inhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", filename);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", filename);
|
||||
exit(2);
|
||||
}
|
||||
return 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: fax_tests.c,v 1.101 2009/02/20 12:34:20 steveu Exp $
|
||||
* $Id: fax_tests.c,v 1.102 2009/05/30 15:23:13 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page fax_tests_page FAX tests
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -179,8 +179,8 @@ static int document_handler(t30_state_t *s, void *user_data, int event)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
AFfilehandle wave_handle;
|
||||
AFfilehandle input_wave_handle;
|
||||
SNDFILE *wave_handle;
|
||||
SNDFILE *input_wave_handle;
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
@@ -282,22 +282,22 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
input_wave_handle = AF_NULL_FILEHANDLE;
|
||||
input_wave_handle = NULL;
|
||||
if (input_audio_file_name)
|
||||
{
|
||||
if ((input_wave_handle = afOpenFile_telephony_read(input_audio_file_name, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((input_wave_handle = sf_open_telephony_read(input_audio_file_name, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", input_audio_file_name);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", input_audio_file_name);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
wave_handle = AF_NULL_FILEHANDLE;
|
||||
wave_handle = NULL;
|
||||
if (log_audio)
|
||||
{
|
||||
if ((wave_handle = afOpenFile_telephony_write(OUTPUT_FILE_NAME_WAVE, 2)) == AF_NULL_FILEHANDLE)
|
||||
if ((wave_handle = sf_open_telephony_write(OUTPUT_FILE_NAME_WAVE, 2)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -427,7 +427,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if ((j & 1) == 0 && input_audio_file_name)
|
||||
{
|
||||
mc->len = afReadFrames(input_wave_handle, AF_DEFAULT_TRACK, mc->amp, SAMPLES_PER_CHUNK);
|
||||
mc->len = sf_readf_short(input_wave_handle, mc->amp, SAMPLES_PER_CHUNK);
|
||||
if (mc->len == 0)
|
||||
break;
|
||||
}
|
||||
@@ -492,7 +492,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (log_audio)
|
||||
{
|
||||
outframes = afWriteFrames(wave_handle, AF_DEFAULT_TRACK, out_amp, SAMPLES_PER_CHUNK);
|
||||
outframes = sf_writef_short(wave_handle, out_amp, SAMPLES_PER_CHUNK);
|
||||
if (outframes != SAMPLES_PER_CHUNK)
|
||||
break;
|
||||
}
|
||||
@@ -508,17 +508,17 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
if (afCloseFile(wave_handle))
|
||||
if (sf_close(wave_handle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if (input_audio_file_name)
|
||||
{
|
||||
if (afCloseFile(input_wave_handle))
|
||||
if (sf_close(input_wave_handle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", input_audio_file_name);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", input_audio_file_name);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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_utils.c,v 1.2 2009/04/25 14:17:47 steveu Exp $
|
||||
* $Id: fax_utils.c,v 1.3 2009/05/16 03:34:45 steveu Exp $
|
||||
*/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
@@ -93,7 +93,7 @@ void log_transfer_statistics(t30_state_t *s, const char *tag)
|
||||
t30_get_transfer_statistics(s, &t);
|
||||
printf("%s: bit rate %d\n", tag, t.bit_rate);
|
||||
printf("%s: ECM %s\n", tag, (t.error_correcting_mode) ? "on" : "off");
|
||||
printf("%s: pages tx %d, pages rx %d\n", tag, t.pages_tx, t.pages_rx);
|
||||
printf("%s: tx pages %d, rx pages %d\n", tag, t.pages_tx, t.pages_rx);
|
||||
printf("%s: pages in the file %d\n", tag, t.pages_in_file);
|
||||
printf("%s: image size %d x %d\n", tag, t.width, t.length);
|
||||
printf("%s: image resolution %d x %d\n", tag, t.x_resolution, t.y_resolution);
|
||||
|
||||
@@ -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: fsk_tests.c,v 1.56 2009/04/14 16:04:54 steveu Exp $
|
||||
* $Id: fsk_tests.c,v 1.57 2009/05/30 15:23:13 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page fsk_tests_page FSK modem tests
|
||||
@@ -35,7 +35,7 @@ These tests allow either:
|
||||
the basic performance of the receive modem. It is also the only test mode
|
||||
provided for evaluating the transmit modem.
|
||||
|
||||
- An FSK receive modem is used to decode FSK audio, stored in a wave file.
|
||||
- An FSK receive modem is used to decode FSK audio, stored in a file.
|
||||
This is good way to evaluate performance with audio recorded from other
|
||||
models of modem, and with real world problematic telephone lines.
|
||||
|
||||
@@ -51,7 +51,7 @@ These tests allow either:
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -178,8 +178,8 @@ int main(int argc, char *argv[])
|
||||
int16_t caller_model_amp[BLOCK_LEN];
|
||||
int16_t answerer_model_amp[BLOCK_LEN];
|
||||
int16_t out_amp[2*BLOCK_LEN];
|
||||
AFfilehandle inhandle;
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *outhandle;
|
||||
int outframes;
|
||||
int i;
|
||||
int j;
|
||||
@@ -255,13 +255,13 @@ int main(int argc, char *argv[])
|
||||
if (modem_under_test_2 >= 0)
|
||||
printf("Modem channel 2 is '%s'\n", preset_fsk_specs[modem_under_test_2].name);
|
||||
|
||||
outhandle = AF_NULL_FILEHANDLE;
|
||||
outhandle = NULL;
|
||||
|
||||
if (log_audio)
|
||||
{
|
||||
if ((outhandle = afOpenFile_telephony_write(OUTPUT_FILE_NAME, 2)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 2)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -278,9 +278,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (decode_test_file)
|
||||
{
|
||||
if ((inhandle = afOpenFile_telephony_read(decode_test_file, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", decode_test_file);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
caller_rx = fsk_rx_init(NULL, &preset_fsk_specs[modem_under_test_1], TRUE, put_bit, NULL);
|
||||
@@ -289,10 +289,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (;;)
|
||||
{
|
||||
samples = afReadFrames(inhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
caller_model_amp,
|
||||
BLOCK_LEN);
|
||||
samples = sf_readf_short(inhandle, caller_model_amp, BLOCK_LEN);
|
||||
if (samples < BLOCK_LEN)
|
||||
break;
|
||||
for (i = 0; i < samples; i++)
|
||||
@@ -300,9 +297,9 @@ int main(int argc, char *argv[])
|
||||
fsk_rx(caller_rx, caller_model_amp, samples);
|
||||
}
|
||||
|
||||
if (afCloseFile(inhandle) != 0)
|
||||
if (sf_close(inhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", decode_test_file);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -429,13 +426,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (log_audio)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
out_amp,
|
||||
BLOCK_LEN);
|
||||
outframes = sf_writef_short(outhandle, out_amp, BLOCK_LEN);
|
||||
if (outframes != BLOCK_LEN)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -477,12 +471,7 @@ int main(int argc, char *argv[])
|
||||
if (log_audio)
|
||||
{
|
||||
for (i = 0; i < 200; i++)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
out_amp,
|
||||
BLOCK_LEN);
|
||||
}
|
||||
outframes = sf_writef_short(outhandle, out_amp, BLOCK_LEN);
|
||||
}
|
||||
if (modem_under_test_1 >= 0)
|
||||
{
|
||||
@@ -514,9 +503,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: g1050_tests.c,v 1.17 2008/11/30 10:17:31 steveu Exp $
|
||||
* $Id: g1050_tests.c,v 1.18 2009/05/30 15:23:13 steveu Exp $
|
||||
*/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
#if defined(HAVE_MATH_H)
|
||||
#define GEN_CONST
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: g168_tests.c,v 1.19 2008/11/30 10:17:31 steveu Exp $
|
||||
* $Id: g168_tests.c,v 1.20 2009/05/30 15:23:13 steveu Exp $
|
||||
*/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -42,6 +42,7 @@
|
||||
|
||||
#include "spandsp.h"
|
||||
#include "spandsp/g168models.h"
|
||||
#include "spandsp-sim.h"
|
||||
|
||||
#define FALSE 0
|
||||
#define TRUE (!FALSE)
|
||||
@@ -52,76 +53,18 @@ typedef struct
|
||||
int max;
|
||||
int cur;
|
||||
float gain;
|
||||
AFfilehandle handle;
|
||||
SNDFILE *handle;
|
||||
int16_t signal[SAMPLE_RATE];
|
||||
} signal_source_t;
|
||||
|
||||
signal_source_t local_css;
|
||||
signal_source_t far_css;
|
||||
|
||||
static AFfilehandle afOpenFile_telephony_read(const char *name, int channels)
|
||||
{
|
||||
float x;
|
||||
AFfilehandle handle;
|
||||
|
||||
if ((handle = afOpenFile(name, "r", 0)) == AF_NULL_FILEHANDLE)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", name);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetFrameSize(handle, AF_DEFAULT_TRACK, 1)) != 2.0)
|
||||
{
|
||||
fprintf(stderr, " Unexpected frame size in wave file '%s'\n", name);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetRate(handle, AF_DEFAULT_TRACK)) != (float) SAMPLE_RATE)
|
||||
{
|
||||
printf(" Unexpected sample rate in wave file '%s'\n", name);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetChannels(handle, AF_DEFAULT_TRACK)) != (float) channels)
|
||||
{
|
||||
printf(" Unexpected number of channels in wave file '%s'\n", name);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
#if 0
|
||||
static AFfilehandle afOpenFile_telephony_write(const char *name, int channels)
|
||||
{
|
||||
AFfilesetup setup;
|
||||
AFfilehandle handle;
|
||||
|
||||
if ((setup = afNewFileSetup()) == AF_NULL_FILESETUP)
|
||||
{
|
||||
fprintf(stderr, " %s: Failed to create file setup\n", name);
|
||||
exit(2);
|
||||
}
|
||||
afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
|
||||
afInitRate(setup, AF_DEFAULT_TRACK, (float) SAMPLE_RATE);
|
||||
afInitFileFormat(setup, AF_FILE_WAVE);
|
||||
afInitChannels(setup, AF_DEFAULT_TRACK, channels);
|
||||
|
||||
if ((handle = afOpenFile(name, "w", setup)) == AF_NULL_FILEHANDLE)
|
||||
{
|
||||
fprintf(stderr, " Failed to open result file\n");
|
||||
exit(2);
|
||||
}
|
||||
afFreeFileSetup(setup);
|
||||
|
||||
return handle;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
#endif
|
||||
|
||||
static void signal_load(signal_source_t *sig, const char *name)
|
||||
{
|
||||
sig->handle = afOpenFile_telephony_read(name, 1);
|
||||
sig->handle = sf_open_telephony_read(name, 1);
|
||||
sig->name = name;
|
||||
sig->max = afReadFrames(sig->handle, AF_DEFAULT_TRACK, sig->signal, SAMPLE_RATE);
|
||||
sig->max = sf_readf_short(sig->handle, sig->signal, SAMPLE_RATE);
|
||||
if (sig->max < 0)
|
||||
{
|
||||
fprintf(stderr, " Error reading sound file '%s'\n", sig->name);
|
||||
@@ -132,7 +75,7 @@ static void signal_load(signal_source_t *sig, const char *name)
|
||||
|
||||
static void signal_free(signal_source_t *sig)
|
||||
{
|
||||
if (afCloseFile(sig->handle) != 0)
|
||||
if (sf_close(sig->handle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close sound file '%s'\n", sig->name);
|
||||
exit(2);
|
||||
|
||||
@@ -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: g711_tests.c,v 1.16 2009/04/22 12:57:40 steveu Exp $
|
||||
* $Id: g711_tests.c,v 1.17 2009/05/30 15:23:13 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page g711_tests_page A-law and u-law conversion tests
|
||||
@@ -40,7 +40,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -64,7 +64,7 @@ const uint8_t ulaw_1khz_sine[] = {0x1E, 0x0B, 0x0B, 0x1E, 0x9E, 0x8B, 0x8B, 0x9E
|
||||
|
||||
static void compliance_tests(int log_audio)
|
||||
{
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *outhandle;
|
||||
power_meter_t power_meter;
|
||||
int outframes;
|
||||
int i;
|
||||
@@ -82,12 +82,12 @@ static void compliance_tests(int log_audio)
|
||||
g711_state_t *transcode;
|
||||
g711_state_t *dec_state;
|
||||
|
||||
outhandle = AF_NULL_FILEHANDLE;
|
||||
outhandle = NULL;
|
||||
if (log_audio)
|
||||
{
|
||||
if ((outhandle = afOpenFile_telephony_write(OUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -127,13 +127,10 @@ static void compliance_tests(int log_audio)
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
65536);
|
||||
outframes = sf_writef_short(outhandle, amp, 65536);
|
||||
if (outframes != 65536)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -165,13 +162,10 @@ static void compliance_tests(int log_audio)
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
65536);
|
||||
outframes = sf_writef_short(outhandle, amp, 65536);
|
||||
if (outframes != 65536)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -224,13 +218,10 @@ static void compliance_tests(int log_audio)
|
||||
printf("Reference u-law 1kHz tone is %fdBm0\n", power_meter_current_dbm0(&power_meter));
|
||||
if (log_audio)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
8000);
|
||||
outframes = sf_writef_short(outhandle, amp, 8000);
|
||||
if (outframes != 8000)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -248,13 +239,10 @@ static void compliance_tests(int log_audio)
|
||||
printf("Reference A-law 1kHz tone is %fdBm0\n", power_meter_current_dbm0(&power_meter));
|
||||
if (log_audio)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
8000);
|
||||
outframes = sf_writef_short(outhandle, amp, 8000);
|
||||
if (outframes != 8000)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -338,9 +326,9 @@ static void compliance_tests(int log_audio)
|
||||
|
||||
if (log_audio)
|
||||
{
|
||||
if (afCloseFile(outhandle))
|
||||
if (sf_close(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -351,8 +339,8 @@ static void compliance_tests(int log_audio)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
AFfilehandle inhandle;
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *outhandle;
|
||||
int outframes;
|
||||
int opt;
|
||||
int samples;
|
||||
@@ -427,16 +415,16 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
out_file = (decode) ? OUT_FILE_NAME : ENCODED_FILE_NAME;
|
||||
}
|
||||
inhandle = AF_NULL_FILEHANDLE;
|
||||
outhandle = AF_NULL_FILEHANDLE;
|
||||
inhandle = NULL;
|
||||
outhandle = NULL;
|
||||
file = -1;
|
||||
enc_state = NULL;
|
||||
dec_state = NULL;
|
||||
if (encode)
|
||||
{
|
||||
if ((inhandle = afOpenFile_telephony_read(in_file, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(in_file, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", in_file);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", in_file);
|
||||
exit(2);
|
||||
}
|
||||
enc_state = g711_init(NULL, law);
|
||||
@@ -451,9 +439,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (decode)
|
||||
{
|
||||
if ((outhandle = afOpenFile_telephony_write(out_file, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(out_file, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", out_file);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", out_file);
|
||||
exit(2);
|
||||
}
|
||||
dec_state = g711_init(NULL, law);
|
||||
@@ -470,10 +458,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (encode)
|
||||
{
|
||||
samples = afReadFrames(inhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
indata,
|
||||
BLOCK_LEN);
|
||||
samples = sf_readf_short(inhandle, indata, BLOCK_LEN);
|
||||
if (samples <= 0)
|
||||
break;
|
||||
len2 = g711_encode(enc_state, g711data, indata, samples);
|
||||
@@ -487,13 +472,10 @@ int main(int argc, char *argv[])
|
||||
if (decode)
|
||||
{
|
||||
len3 = g711_decode(dec_state, outdata, g711data, len2);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
outdata,
|
||||
len3);
|
||||
outframes = sf_writef_short(outhandle, outdata, len3);
|
||||
if (outframes != len3)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -506,9 +488,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (encode)
|
||||
{
|
||||
if (afCloseFile(inhandle))
|
||||
if (sf_close(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", IN_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -518,9 +500,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (decode)
|
||||
{
|
||||
if (afCloseFile(outhandle))
|
||||
if (sf_close(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: g722_tests.c,v 1.30 2009/04/22 12:57:40 steveu Exp $
|
||||
* $Id: g722_tests.c,v 1.32 2009/06/02 14:55:36 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -69,7 +69,7 @@ and the resulting audio stored in post_g722.wav.
|
||||
#include <unistd.h>
|
||||
#include <memory.h>
|
||||
#include <ctype.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
#include "spandsp.h"
|
||||
|
||||
@@ -357,9 +357,9 @@ int main(int argc, char *argv[])
|
||||
int len3;
|
||||
int i;
|
||||
int file;
|
||||
AFfilehandle inhandle;
|
||||
AFfilehandle outhandle;
|
||||
AFfilesetup filesetup;
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *outhandle;
|
||||
SF_INFO info;
|
||||
int outframes;
|
||||
int samples;
|
||||
int opt;
|
||||
@@ -370,7 +370,6 @@ int main(int argc, char *argv[])
|
||||
int encode;
|
||||
int decode;
|
||||
int tone_test;
|
||||
float x;
|
||||
const char *in_file;
|
||||
const char *out_file;
|
||||
int16_t indata[BLOCK_LEN];
|
||||
@@ -477,54 +476,44 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
out_file = (decode) ? OUT_FILE_NAME : ENCODED_FILE_NAME;
|
||||
}
|
||||
inhandle = AF_NULL_FILEHANDLE;
|
||||
outhandle = AF_NULL_FILEHANDLE;
|
||||
inhandle = NULL;
|
||||
outhandle = NULL;
|
||||
file = -1;
|
||||
if (encode)
|
||||
{
|
||||
if (eight_k_in)
|
||||
{
|
||||
if ((inhandle = afOpenFile(in_file, "r", NULL)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open(in_file, SFM_READ, &info)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", in_file);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", in_file);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetFrameSize(inhandle, AF_DEFAULT_TRACK, 1)) != 2.0)
|
||||
if (info.samplerate != SAMPLE_RATE)
|
||||
{
|
||||
fprintf(stderr, " Unexpected frame size in wave file '%s'\n", in_file);
|
||||
fprintf(stderr, " Unexpected sample rate %d in audio file '%s'\n", info.samplerate, in_file);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetRate(inhandle, AF_DEFAULT_TRACK)) != (float) SAMPLE_RATE)
|
||||
if (info.channels != 1)
|
||||
{
|
||||
fprintf(stderr, " Unexpected sample rate %f in wave file '%s'\n", x, in_file);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetChannels(inhandle, AF_DEFAULT_TRACK)) != 1.0)
|
||||
{
|
||||
fprintf(stderr, " Unexpected number of channels in wave file '%s'\n", in_file);
|
||||
fprintf(stderr, " Unexpected number of channels in audio file '%s'\n", in_file);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((inhandle = afOpenFile(in_file, "r", NULL)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open(in_file, SFM_READ, &info)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", in_file);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", in_file);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetFrameSize(inhandle, AF_DEFAULT_TRACK, 1)) != 2.0)
|
||||
if (info.samplerate != G722_SAMPLE_RATE)
|
||||
{
|
||||
fprintf(stderr, " Unexpected frame size in wave file '%s'\n", in_file);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetRate(inhandle, AF_DEFAULT_TRACK)) != (float) G722_SAMPLE_RATE)
|
||||
{
|
||||
fprintf(stderr, " Unexpected sample rate %f in wave file '%s'\n", x, in_file);
|
||||
fprintf(stderr, " Unexpected sample rate %d in audio file '%s'\n", info.samplerate, in_file);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetChannels(inhandle, AF_DEFAULT_TRACK)) != 1.0)
|
||||
if (info.channels != 1)
|
||||
{
|
||||
fprintf(stderr, " Unexpected number of channels in wave file '%s'\n", in_file);
|
||||
fprintf(stderr, " Unexpected number of channels in audio file '%s'\n", in_file);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -543,24 +532,18 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (decode)
|
||||
{
|
||||
if ((filesetup = afNewFileSetup()) == AF_NULL_FILESETUP)
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.frames = 0;
|
||||
info.samplerate = (eight_k_out) ? SAMPLE_RATE : G722_SAMPLE_RATE;
|
||||
info.channels = 1;
|
||||
info.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
|
||||
info.sections = 1;
|
||||
info.seekable = 1;
|
||||
if ((outhandle = sf_open(out_file, SFM_WRITE, &info)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to create file setup\n");
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", out_file);
|
||||
exit(2);
|
||||
}
|
||||
afInitSampleFormat(filesetup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
|
||||
if (eight_k_out)
|
||||
afInitRate(filesetup, AF_DEFAULT_TRACK, (float) SAMPLE_RATE);
|
||||
else
|
||||
afInitRate(filesetup, AF_DEFAULT_TRACK, (float) G722_SAMPLE_RATE);
|
||||
afInitFileFormat(filesetup, AF_FILE_WAVE);
|
||||
afInitChannels(filesetup, AF_DEFAULT_TRACK, 1);
|
||||
if ((outhandle = afOpenFile(out_file, "w", filesetup)) == AF_NULL_FILEHANDLE)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", out_file);
|
||||
exit(2);
|
||||
}
|
||||
afFreeFileSetup(filesetup);
|
||||
if (eight_k_out)
|
||||
g722_decode_init(&dec_state, bit_rate, G722_PACKED | G722_SAMPLE_RATE_8000);
|
||||
else
|
||||
@@ -578,10 +561,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (encode)
|
||||
{
|
||||
samples = afReadFrames(inhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
indata,
|
||||
BLOCK_LEN);
|
||||
samples = sf_readf_short(inhandle, indata, BLOCK_LEN);
|
||||
if (samples <= 0)
|
||||
break;
|
||||
if (tone_test)
|
||||
@@ -600,13 +580,10 @@ int main(int argc, char *argv[])
|
||||
if (decode)
|
||||
{
|
||||
len3 = g722_decode(&dec_state, outdata, adpcmdata, len2);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
outdata,
|
||||
len3);
|
||||
outframes = sf_writef_short(outhandle, outdata, len3);
|
||||
if (outframes != len3)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -619,9 +596,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (encode)
|
||||
{
|
||||
if (afCloseFile(inhandle))
|
||||
if (sf_close(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", IN_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -631,9 +608,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (decode)
|
||||
{
|
||||
if (afCloseFile(outhandle))
|
||||
if (sf_close(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: g726_tests.c,v 1.32 2009/04/22 12:57:40 steveu Exp $
|
||||
* $Id: g726_tests.c,v 1.33 2009/05/30 15:23:13 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -73,7 +73,7 @@ decompressed, and the resulting audio stored in post_g726.wav.
|
||||
#include <unistd.h>
|
||||
#include <memory.h>
|
||||
#include <ctype.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -1224,8 +1224,8 @@ int main(int argc, char *argv[])
|
||||
int opt;
|
||||
int itutests;
|
||||
int bit_rate;
|
||||
AFfilehandle inhandle;
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *outhandle;
|
||||
int16_t amp[1024];
|
||||
int frames;
|
||||
int outframes;
|
||||
@@ -1266,14 +1266,14 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((inhandle = afOpenFile_telephony_read(IN_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(IN_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", IN_FILE_NAME);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", IN_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
if ((outhandle = afOpenFile_telephony_write(OUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@@ -1281,20 +1281,20 @@ int main(int argc, char *argv[])
|
||||
g726_init(&enc_state, bit_rate, G726_ENCODING_LINEAR, packing);
|
||||
g726_init(&dec_state, bit_rate, G726_ENCODING_LINEAR, packing);
|
||||
|
||||
while ((frames = afReadFrames(inhandle, AF_DEFAULT_TRACK, amp, 159)))
|
||||
while ((frames = sf_readf_short(inhandle, amp, 159)))
|
||||
{
|
||||
adpcm = g726_encode(&enc_state, adpcmdata, amp, frames);
|
||||
frames = g726_decode(&dec_state, amp, adpcmdata, adpcm);
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, amp, frames);
|
||||
outframes = sf_writef_short(outhandle, amp, frames);
|
||||
}
|
||||
if (afCloseFile(inhandle) != 0)
|
||||
if (sf_close(inhandle) != 0)
|
||||
{
|
||||
printf(" Cannot close wave file '%s'\n", IN_FILE_NAME);
|
||||
printf(" Cannot close audio file '%s'\n", IN_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
printf(" Cannot close wave file '%s'\n", OUT_FILE_NAME);
|
||||
printf(" Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
printf("'%s' transcoded to '%s' at %dbps.\n", IN_FILE_NAME, OUT_FILE_NAME, bit_rate);
|
||||
|
||||
@@ -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: gsm0610_tests.c,v 1.24 2009/04/22 12:57:40 steveu Exp $
|
||||
* $Id: gsm0610_tests.c,v 1.25 2009/05/30 15:23:13 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -123,7 +123,7 @@ will be compressed to GSM 06.10 data, decompressed, and the resulting audio stor
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -542,8 +542,8 @@ static void etsi_compliance_tests(void)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
AFfilehandle inhandle;
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *outhandle;
|
||||
int frames;
|
||||
int outframes;
|
||||
int bytes;
|
||||
@@ -580,14 +580,14 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((inhandle = afOpenFile_telephony_read(IN_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(IN_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", IN_FILE_NAME);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", IN_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
if ((outhandle = afOpenFile_telephony_write(OUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@@ -603,21 +603,21 @@ int main(int argc, char *argv[])
|
||||
exit(2);
|
||||
}
|
||||
|
||||
while ((frames = afReadFrames(inhandle, AF_DEFAULT_TRACK, pre_amp, 2*BLOCK_LEN)))
|
||||
while ((frames = sf_readf_short(inhandle, pre_amp, 2*BLOCK_LEN)))
|
||||
{
|
||||
bytes = gsm0610_encode(gsm0610_enc_state, gsm0610_data, pre_amp, frames);
|
||||
gsm0610_decode(gsm0610_dec_state, post_amp, gsm0610_data, bytes);
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, post_amp, frames);
|
||||
outframes = sf_writef_short(outhandle, post_amp, frames);
|
||||
}
|
||||
|
||||
if (afCloseFile(inhandle) != 0)
|
||||
if (sf_close(inhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", IN_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
gsm0610_release(gsm0610_enc_state);
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: ima_adpcm_tests.c,v 1.35 2008/11/30 10:17:31 steveu Exp $
|
||||
* $Id: ima_adpcm_tests.c,v 1.36 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -49,7 +49,7 @@ of the degradation in quality caused by the compression.
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -66,8 +66,8 @@ of the degradation in quality caused by the compression.
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
AFfilehandle inhandle;
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *outhandle;
|
||||
int frames;
|
||||
int dec_frames;
|
||||
int outframes;
|
||||
@@ -126,15 +126,15 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if ((inhandle = afOpenFile_telephony_read(in_file_name, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(in_file_name, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", in_file_name);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", in_file_name);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if ((outhandle = afOpenFile_telephony_write(OUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ int main(int argc, char *argv[])
|
||||
total_pre_samples = 0;
|
||||
total_compressed_bytes = 0;
|
||||
total_post_samples = 0;
|
||||
while ((frames = afReadFrames(inhandle, AF_DEFAULT_TRACK, pre_amp, chunk_size)))
|
||||
while ((frames = sf_readf_short(inhandle, pre_amp, chunk_size)))
|
||||
{
|
||||
total_pre_samples += frames;
|
||||
ima_bytes = ima_adpcm_encode(ima_enc_state, ima_data, pre_amp, frames);
|
||||
@@ -182,16 +182,16 @@ int main(int argc, char *argv[])
|
||||
hist_out = 0;
|
||||
diff_energy += (double) xx * (double) xx;
|
||||
}
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, post_amp, dec_frames);
|
||||
outframes = sf_writef_short(outhandle, post_amp, dec_frames);
|
||||
}
|
||||
if (afCloseFile(inhandle) != 0)
|
||||
if (sf_close(inhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", in_file_name);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", in_file_name);
|
||||
exit(2);
|
||||
}
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
ima_adpcm_release(ima_enc_state);
|
||||
|
||||
@@ -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.26 2009/01/12 17:20:59 steveu Exp $
|
||||
* $Id: line_model_tests.c,v 1.27 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page line_model_tests_page Telephony line model tests
|
||||
@@ -43,7 +43,7 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -73,25 +73,14 @@ static void complexify_tests(void)
|
||||
complexf_t cc;
|
||||
int16_t amp;
|
||||
int i;
|
||||
AFfilehandle outhandle;
|
||||
AFfilesetup filesetup;
|
||||
SNDFILE *outhandle;
|
||||
int outframes;
|
||||
int16_t out[40000];
|
||||
awgn_state_t noise1;
|
||||
|
||||
if ((filesetup = afNewFileSetup()) == AF_NULL_FILESETUP)
|
||||
{
|
||||
fprintf(stderr, " Failed to create file setup\n");
|
||||
exit(2);
|
||||
}
|
||||
afInitSampleFormat(filesetup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
|
||||
afInitRate(filesetup, AF_DEFAULT_TRACK, (float) SAMPLE_RATE);
|
||||
afInitFileFormat(filesetup, AF_FILE_WAVE);
|
||||
afInitChannels(filesetup, AF_DEFAULT_TRACK, 2);
|
||||
|
||||
if ((outhandle = afOpenFile(OUT_FILE_COMPLEXIFY, "w", filesetup)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_COMPLEXIFY, 2)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_COMPLEXIFY);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_COMPLEXIFY);
|
||||
exit(2);
|
||||
}
|
||||
awgn_init_dbm0(&noise1, 1234567, -10.0f);
|
||||
@@ -103,21 +92,17 @@ static void complexify_tests(void)
|
||||
out[2*i] = cc.re;
|
||||
out[2*i + 1] = cc.im;
|
||||
}
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
out,
|
||||
20000);
|
||||
outframes = sf_writef_short(outhandle, out, 20000);
|
||||
if (outframes != 20000)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
if (afCloseFile(outhandle))
|
||||
if (sf_close(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_COMPLEXIFY);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_COMPLEXIFY);
|
||||
exit(2);
|
||||
}
|
||||
afFreeFileSetup(filesetup);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@@ -127,9 +112,8 @@ static void test_one_way_model(int line_model_no, int speech_test)
|
||||
int16_t input1[BLOCK_LEN];
|
||||
int16_t output1[BLOCK_LEN];
|
||||
int16_t amp[2*BLOCK_LEN];
|
||||
AFfilehandle inhandle1;
|
||||
AFfilehandle outhandle;
|
||||
AFfilesetup filesetup;
|
||||
SNDFILE *inhandle1;
|
||||
SNDFILE *outhandle;
|
||||
int outframes;
|
||||
int samples;
|
||||
int i;
|
||||
@@ -144,34 +128,21 @@ static void test_one_way_model(int line_model_no, int speech_test)
|
||||
|
||||
awgn_init_dbm0(&noise1, 1234567, -10.0f);
|
||||
|
||||
if ((filesetup = afNewFileSetup()) == AF_NULL_FILESETUP)
|
||||
if ((inhandle1 = sf_open_telephony_read(IN_FILE_NAME1, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to create file setup\n");
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", IN_FILE_NAME1);
|
||||
exit(2);
|
||||
}
|
||||
afInitSampleFormat(filesetup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
|
||||
afInitRate(filesetup, AF_DEFAULT_TRACK, (float) SAMPLE_RATE);
|
||||
afInitFileFormat(filesetup, AF_FILE_WAVE);
|
||||
afInitChannels(filesetup, AF_DEFAULT_TRACK, 1);
|
||||
|
||||
if ((inhandle1 = afOpenFile(IN_FILE_NAME1, "r", NULL)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME1, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", IN_FILE_NAME1);
|
||||
exit(2);
|
||||
}
|
||||
if ((outhandle = afOpenFile(OUT_FILE_NAME1, "w", filesetup)) == AF_NULL_FILEHANDLE)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME1);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME1);
|
||||
exit(2);
|
||||
}
|
||||
for (i = 0; i < 10000; i++)
|
||||
{
|
||||
if (speech_test)
|
||||
{
|
||||
samples = afReadFrames(inhandle1,
|
||||
AF_DEFAULT_TRACK,
|
||||
input1,
|
||||
BLOCK_LEN);
|
||||
samples = sf_readf_short(inhandle1, input1, BLOCK_LEN);
|
||||
if (samples == 0)
|
||||
break;
|
||||
}
|
||||
@@ -189,27 +160,23 @@ static void test_one_way_model(int line_model_no, int speech_test)
|
||||
1);
|
||||
amp[j] = output1[j];
|
||||
}
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
samples);
|
||||
outframes = sf_writef_short(outhandle, amp, samples);
|
||||
if (outframes != samples)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if (afCloseFile(inhandle1))
|
||||
if (sf_close(inhandle1))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", IN_FILE_NAME1);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME1);
|
||||
exit(2);
|
||||
}
|
||||
if (afCloseFile(outhandle))
|
||||
if (sf_close(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME1);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME1);
|
||||
exit(2);
|
||||
}
|
||||
afFreeFileSetup(filesetup);
|
||||
one_way_line_model_release(model);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@@ -222,10 +189,9 @@ static void test_both_ways_model(int line_model_no, int speech_test)
|
||||
int16_t output1[BLOCK_LEN];
|
||||
int16_t output2[BLOCK_LEN];
|
||||
int16_t amp[2*BLOCK_LEN];
|
||||
AFfilehandle inhandle1;
|
||||
AFfilehandle inhandle2;
|
||||
AFfilehandle outhandle;
|
||||
AFfilesetup filesetup;
|
||||
SNDFILE *inhandle1;
|
||||
SNDFILE *inhandle2;
|
||||
SNDFILE *outhandle;
|
||||
int outframes;
|
||||
int samples;
|
||||
int i;
|
||||
@@ -242,49 +208,29 @@ 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);
|
||||
|
||||
filesetup = afNewFileSetup();
|
||||
if (filesetup == AF_NULL_FILESETUP)
|
||||
if ((inhandle1 = sf_open_telephony_read(IN_FILE_NAME1, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to create file setup\n");
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", IN_FILE_NAME1);
|
||||
exit(2);
|
||||
}
|
||||
afInitSampleFormat(filesetup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
|
||||
afInitRate(filesetup, AF_DEFAULT_TRACK, (float) SAMPLE_RATE);
|
||||
afInitFileFormat(filesetup, AF_FILE_WAVE);
|
||||
afInitChannels(filesetup, AF_DEFAULT_TRACK, 2);
|
||||
|
||||
inhandle1 = afOpenFile(IN_FILE_NAME1, "r", NULL);
|
||||
if (inhandle1 == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle2 = sf_open_telephony_read(IN_FILE_NAME2, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", IN_FILE_NAME1);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", IN_FILE_NAME2);
|
||||
exit(2);
|
||||
}
|
||||
inhandle2 = afOpenFile(IN_FILE_NAME2, "r", NULL);
|
||||
if (inhandle2 == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 2)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", IN_FILE_NAME2);
|
||||
exit(2);
|
||||
}
|
||||
outhandle = afOpenFile(OUT_FILE_NAME, "w", filesetup);
|
||||
if (outhandle == AF_NULL_FILEHANDLE)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
for (i = 0; i < 10000; i++)
|
||||
{
|
||||
if (speech_test)
|
||||
{
|
||||
samples = afReadFrames(inhandle1,
|
||||
AF_DEFAULT_TRACK,
|
||||
input1,
|
||||
BLOCK_LEN);
|
||||
samples = sf_readf_short(inhandle1, input1, BLOCK_LEN);
|
||||
if (samples == 0)
|
||||
break;
|
||||
samples = afReadFrames(inhandle2,
|
||||
AF_DEFAULT_TRACK,
|
||||
input2,
|
||||
samples);
|
||||
samples = sf_readf_short(inhandle2, input2, samples);
|
||||
if (samples == 0)
|
||||
break;
|
||||
}
|
||||
@@ -308,32 +254,28 @@ static void test_both_ways_model(int line_model_no, int speech_test)
|
||||
amp[2*j] = output1[j];
|
||||
amp[2*j + 1] = output2[j];
|
||||
}
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
samples);
|
||||
outframes = sf_writef_short(outhandle, amp, samples);
|
||||
if (outframes != samples)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if (afCloseFile(inhandle1))
|
||||
if (sf_close(inhandle1))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", IN_FILE_NAME1);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME1);
|
||||
exit(2);
|
||||
}
|
||||
if (afCloseFile(inhandle2))
|
||||
if (sf_close(inhandle2))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", IN_FILE_NAME2);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME2);
|
||||
exit(2);
|
||||
}
|
||||
if (afCloseFile(outhandle))
|
||||
if (sf_close(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
afFreeFileSetup(filesetup);
|
||||
both_ways_line_model_release(model);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@@ -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: lpc10_tests.c,v 1.23 2009/01/12 17:20:59 steveu Exp $
|
||||
* $Id: lpc10_tests.c,v 1.24 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -46,7 +46,7 @@ will be compressed to LPC10 data, decompressed, and the resulting audio stored i
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <ctype.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -67,9 +67,9 @@ will be compressed to LPC10 data, decompressed, and the resulting audio stored i
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
AFfilehandle inhandle;
|
||||
AFfilehandle refhandle;
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *refhandle;
|
||||
SNDFILE *outhandle;
|
||||
int frames;
|
||||
int outframes;
|
||||
double pre_energy;
|
||||
@@ -125,20 +125,20 @@ int main(int argc, char *argv[])
|
||||
|
||||
compress_file = -1;
|
||||
decompress_file = -1;
|
||||
inhandle = AF_NULL_FILEHANDLE;
|
||||
refhandle = AF_NULL_FILEHANDLE;
|
||||
outhandle = AF_NULL_FILEHANDLE;
|
||||
inhandle = NULL;
|
||||
refhandle = NULL;
|
||||
outhandle = NULL;
|
||||
if (!decompress)
|
||||
{
|
||||
if ((inhandle = afOpenFile_telephony_read(in_file_name, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(in_file_name, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", in_file_name);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", in_file_name);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if ((refhandle = afOpenFile_telephony_read(REF_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((refhandle = sf_open_telephony_read(REF_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", REF_FILE_NAME);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", REF_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -151,9 +151,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if ((outhandle = afOpenFile_telephony_write(OUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@@ -188,15 +188,15 @@ int main(int argc, char *argv[])
|
||||
while ((len = read(decompress_file, lpc10_data, BLOCKS_PER_READ*7)) > 0)
|
||||
{
|
||||
lpc10_decode(lpc10_dec_state, post_amp, lpc10_data, len/7);
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, post_amp, BLOCK_LEN*len/7);
|
||||
outframes = sf_writef_short(outhandle, post_amp, BLOCK_LEN*len/7);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
block_no = 0;
|
||||
while ((frames = afReadFrames(inhandle, AF_DEFAULT_TRACK, pre_amp, BLOCKS_PER_READ*BLOCK_LEN)) == BLOCKS_PER_READ*BLOCK_LEN
|
||||
while ((frames = sf_readf_short(inhandle, pre_amp, BLOCKS_PER_READ*BLOCK_LEN)) == BLOCKS_PER_READ*BLOCK_LEN
|
||||
&&
|
||||
(frames = afReadFrames(refhandle, AF_DEFAULT_TRACK, ref_amp, BLOCKS_PER_READ*BLOCK_LEN)) == BLOCKS_PER_READ*BLOCK_LEN)
|
||||
(frames = sf_readf_short(refhandle, ref_amp, BLOCKS_PER_READ*BLOCK_LEN)) == BLOCKS_PER_READ*BLOCK_LEN)
|
||||
{
|
||||
enc_len = lpc10_encode(lpc10_enc_state, lpc10_data, pre_amp, BLOCKS_PER_READ*BLOCK_LEN);
|
||||
if (compress)
|
||||
@@ -218,25 +218,25 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
block_no++;
|
||||
if (log_error)
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, log_amp, dec_len);
|
||||
outframes = sf_writef_short(outhandle, log_amp, dec_len);
|
||||
else
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, post_amp, dec_len);
|
||||
outframes = sf_writef_short(outhandle, post_amp, dec_len);
|
||||
}
|
||||
if (afCloseFile(inhandle) != 0)
|
||||
if (sf_close(inhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", in_file_name);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", in_file_name);
|
||||
exit(2);
|
||||
}
|
||||
if (afCloseFile(refhandle) != 0)
|
||||
if (sf_close(refhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", REF_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", REF_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
if (compress)
|
||||
|
||||
@@ -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: make_g168_css.c,v 1.17 2009/02/10 17:49:20 steveu Exp $
|
||||
* $Id: make_g168_css.c,v 1.18 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page makecss_page CSS construction for G.168 testing
|
||||
@@ -43,7 +43,7 @@
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
#if defined(HAVE_FFTW3_H)
|
||||
#include <fftw3.h>
|
||||
#else
|
||||
@@ -139,20 +139,18 @@ int main(int argc, char *argv[])
|
||||
double pk;
|
||||
double ms;
|
||||
double scale;
|
||||
AFfilehandle filehandle;
|
||||
AFfilesetup filesetup;
|
||||
SNDFILE *filehandle;
|
||||
SF_INFO info;
|
||||
awgn_state_t noise_source;
|
||||
|
||||
if ((filesetup = afNewFileSetup()) == AF_NULL_FILESETUP)
|
||||
{
|
||||
fprintf(stderr, " Failed to create file setup\n");
|
||||
exit(2);
|
||||
}
|
||||
afInitSampleFormat(filesetup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
|
||||
afInitRate(filesetup, AF_DEFAULT_TRACK, FAST_SAMPLE_RATE);
|
||||
afInitFileFormat(filesetup, AF_FILE_WAVE);
|
||||
afInitChannels(filesetup, AF_DEFAULT_TRACK, 1);
|
||||
if ((filehandle = afOpenFile("sound_c1.wav", "w", filesetup)) == AF_NULL_FILEHANDLE)
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.frames = 0;
|
||||
info.samplerate = FAST_SAMPLE_RATE;
|
||||
info.channels = 1;
|
||||
info.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
|
||||
info.sections = 1;
|
||||
info.seekable = 1;
|
||||
if ((filehandle = sf_open("sound_c1.wav", SFM_WRITE, &info)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to open result file\n");
|
||||
exit(2);
|
||||
@@ -243,26 +241,12 @@ int main(int argc, char *argv[])
|
||||
silence_sound[i] = 0.0;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
outframes = afWriteFrames(filehandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
voiced_sound,
|
||||
voiced_length);
|
||||
}
|
||||
outframes = sf_writef_short(filehandle, voiced_sound, voiced_length);
|
||||
printf("%d samples of voice\n", 16*voiced_length);
|
||||
outframes = afWriteFrames(filehandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
noise_sound,
|
||||
8192);
|
||||
outframes = afWriteFrames(filehandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
noise_sound,
|
||||
C1_NOISE_SAMPLES - 8192);
|
||||
outframes = sf_writef_short(filehandle, noise_sound, 8192);
|
||||
outframes = sf_writef_short(filehandle, noise_sound, C1_NOISE_SAMPLES - 8192);
|
||||
printf("%d samples of noise\n", C1_NOISE_SAMPLES);
|
||||
outframes = afWriteFrames(filehandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
silence_sound,
|
||||
C1_SILENCE_SAMPLES);
|
||||
outframes = sf_writef_short(filehandle, silence_sound, C1_SILENCE_SAMPLES);
|
||||
printf("%d samples of silence\n", C1_SILENCE_SAMPLES);
|
||||
|
||||
/* Now phase invert the C1 set of voice samples. */
|
||||
@@ -277,40 +261,28 @@ int main(int argc, char *argv[])
|
||||
noise_sound[i] = -noise_sound[i];
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
outframes = afWriteFrames(filehandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
voiced_sound,
|
||||
voiced_length);
|
||||
}
|
||||
outframes = sf_writef_short(filehandle, voiced_sound, voiced_length);
|
||||
printf("%d samples of voice\n", 16*voiced_length);
|
||||
outframes = afWriteFrames(filehandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
noise_sound,
|
||||
8192);
|
||||
outframes = afWriteFrames(filehandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
noise_sound,
|
||||
C1_NOISE_SAMPLES - 8192);
|
||||
outframes = sf_writef_short(filehandle, noise_sound, 8192);
|
||||
outframes = sf_writef_short(filehandle, noise_sound, C1_NOISE_SAMPLES - 8192);
|
||||
printf("%d samples of noise\n", C1_NOISE_SAMPLES);
|
||||
outframes = afWriteFrames(filehandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
silence_sound,
|
||||
C1_SILENCE_SAMPLES);
|
||||
outframes = sf_writef_short(filehandle, silence_sound, C1_SILENCE_SAMPLES);
|
||||
printf("%d samples of silence\n", C1_SILENCE_SAMPLES);
|
||||
|
||||
if (afCloseFile(filehandle) != 0)
|
||||
if (sf_close(filehandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close speech file '%s'\n", "sound_c1.wav");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
afInitSampleFormat(filesetup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
|
||||
afInitRate(filesetup, AF_DEFAULT_TRACK, FAST_SAMPLE_RATE);
|
||||
afInitFileFormat(filesetup, AF_FILE_WAVE);
|
||||
afInitChannels(filesetup, AF_DEFAULT_TRACK, 1);
|
||||
filehandle = afOpenFile("sound_c3.wav", "w", filesetup);
|
||||
if (filehandle == AF_NULL_FILEHANDLE)
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.frames = 0;
|
||||
info.samplerate = FAST_SAMPLE_RATE;
|
||||
info.channels = 1;
|
||||
info.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
|
||||
info.sections = 1;
|
||||
info.seekable = 1;
|
||||
if ((filehandle = sf_open("sound_c3.wav", SFM_WRITE, &info)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to open result file\n");
|
||||
exit(2);
|
||||
@@ -333,27 +305,13 @@ int main(int argc, char *argv[])
|
||||
printf("Noise level = %.2fdB, crest factor = %.2fdB\n", rms_to_dbm0(ms), rms_to_db(pk/ms));
|
||||
|
||||
for (i = 0; i < 14; i++)
|
||||
{
|
||||
outframes = afWriteFrames(filehandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
voiced_sound,
|
||||
voiced_length);
|
||||
}
|
||||
outframes = sf_writef_short(filehandle, voiced_sound, voiced_length);
|
||||
printf("%d samples of voice\n", 14*voiced_length);
|
||||
|
||||
outframes = afWriteFrames(filehandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
noise_sound,
|
||||
8192);
|
||||
outframes = afWriteFrames(filehandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
noise_sound,
|
||||
C3_NOISE_SAMPLES - 8192);
|
||||
outframes = sf_writef_short(filehandle, noise_sound, 8192);
|
||||
outframes = sf_writef_short(filehandle, noise_sound, C3_NOISE_SAMPLES - 8192);
|
||||
printf("%d samples of noise\n", C3_NOISE_SAMPLES);
|
||||
outframes = afWriteFrames(filehandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
silence_sound,
|
||||
C3_SILENCE_SAMPLES);
|
||||
outframes = sf_writef_short(filehandle, silence_sound, C3_SILENCE_SAMPLES);
|
||||
printf("%d samples of silence\n", C3_SILENCE_SAMPLES);
|
||||
|
||||
/* Now phase invert the set of voice samples. */
|
||||
@@ -369,34 +327,19 @@ int main(int argc, char *argv[])
|
||||
noise_sound[i] = -noise_sound[i];
|
||||
|
||||
for (i = 0; i < 14; i++)
|
||||
{
|
||||
outframes = afWriteFrames(filehandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
voiced_sound,
|
||||
voiced_length);
|
||||
}
|
||||
outframes = sf_writef_short(filehandle, voiced_sound, voiced_length);
|
||||
printf("%d samples of voice\n", 14*i);
|
||||
outframes = afWriteFrames(filehandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
noise_sound,
|
||||
8192);
|
||||
outframes = afWriteFrames(filehandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
noise_sound,
|
||||
C3_NOISE_SAMPLES - 8192);
|
||||
outframes = sf_writef_short(filehandle, noise_sound, 8192);
|
||||
outframes = sf_writef_short(filehandle, noise_sound, C3_NOISE_SAMPLES - 8192);
|
||||
printf("%d samples of noise\n", C3_NOISE_SAMPLES);
|
||||
outframes = afWriteFrames(filehandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
silence_sound,
|
||||
C3_SILENCE_SAMPLES);
|
||||
outframes = sf_writef_short(filehandle, silence_sound, C3_SILENCE_SAMPLES);
|
||||
printf("%d samples of silence\n", C3_SILENCE_SAMPLES);
|
||||
|
||||
if (afCloseFile(filehandle) != 0)
|
||||
if (sf_close(filehandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close speech file '%s'\n", "sound_c3.wav");
|
||||
exit(2);
|
||||
}
|
||||
afFreeFileSetup(filesetup);
|
||||
|
||||
fftw_destroy_plan(p);
|
||||
return 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: modem_connect_tones_tests.c,v 1.29 2008/11/30 10:17:31 steveu Exp $
|
||||
* $Id: modem_connect_tones_tests.c,v 1.30 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page modem_connect_tones_tests_page Modem connect tones tests
|
||||
@@ -42,7 +42,7 @@ These tests...
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -186,8 +186,8 @@ int main(int argc, char *argv[])
|
||||
modem_connect_tones_rx_state_t ans_pr_rx;
|
||||
modem_connect_tones_tx_state_t modem_tone_tx;
|
||||
awgn_state_t chan_noise_source;
|
||||
AFfilehandle inhandle;
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *outhandle;
|
||||
int outframes;
|
||||
int frames;
|
||||
int samples;
|
||||
@@ -264,9 +264,9 @@ int main(int argc, char *argv[])
|
||||
if (decode_test_file == NULL && test_list == 0)
|
||||
test_list = 0xFFFFFFFF;
|
||||
|
||||
if ((outhandle = afOpenFile_telephony_write(OUTPUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@@ -277,13 +277,10 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < 20*SAMPLE_RATE; i += SAMPLES_PER_CHUNK)
|
||||
{
|
||||
samples = modem_connect_tones_tx(&modem_tone_tx, amp, SAMPLES_PER_CHUNK);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
samples);
|
||||
outframes = sf_writef_short(outhandle, amp, samples);
|
||||
if (outframes != samples)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
/*endif*/
|
||||
@@ -299,13 +296,10 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < 20*SAMPLE_RATE; i += SAMPLES_PER_CHUNK)
|
||||
{
|
||||
samples = modem_connect_tones_tx(&modem_tone_tx, amp, SAMPLES_PER_CHUNK);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
samples);
|
||||
outframes = sf_writef_short(outhandle, amp, samples);
|
||||
if (outframes != samples)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
/*endif*/
|
||||
@@ -322,13 +316,10 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < 20*SAMPLE_RATE; i += SAMPLES_PER_CHUNK)
|
||||
{
|
||||
samples = modem_connect_tones_tx(&modem_tone_tx, amp, SAMPLES_PER_CHUNK);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
samples);
|
||||
outframes = sf_writef_short(outhandle, amp, samples);
|
||||
if (outframes != samples)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
/*endif*/
|
||||
@@ -345,13 +336,10 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < 20*SAMPLE_RATE; i += SAMPLES_PER_CHUNK)
|
||||
{
|
||||
samples = modem_connect_tones_tx(&modem_tone_tx, amp, SAMPLES_PER_CHUNK);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
samples);
|
||||
outframes = sf_writef_short(outhandle, amp, samples);
|
||||
if (outframes != samples)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
/*endif*/
|
||||
@@ -368,13 +356,10 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < 20*SAMPLE_RATE; i += SAMPLES_PER_CHUNK)
|
||||
{
|
||||
samples = modem_connect_tones_tx(&modem_tone_tx, amp, SAMPLES_PER_CHUNK);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
samples);
|
||||
outframes = sf_writef_short(outhandle, amp, samples);
|
||||
if (outframes != samples)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
/*endif*/
|
||||
@@ -383,9 +368,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
/*endif*/
|
||||
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
printf(" Cannot close wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
printf(" Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
/*endif*/
|
||||
@@ -926,7 +911,7 @@ int main(int argc, char *argv[])
|
||||
hits = 0;
|
||||
for (j = 0; bellcore_files[j][0]; j++)
|
||||
{
|
||||
if ((inhandle = afOpenFile_telephony_read(bellcore_files[j], 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(bellcore_files[j], 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open speech file '%s'\n", bellcore_files[j]);
|
||||
exit (2);
|
||||
@@ -935,7 +920,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
when = 0;
|
||||
hits = 0;
|
||||
while ((frames = afReadFrames(inhandle, AF_DEFAULT_TRACK, amp, 8000)))
|
||||
while ((frames = sf_readf_short(inhandle, amp, 8000)))
|
||||
{
|
||||
when++;
|
||||
modem_connect_tones_rx(&cng_rx, amp, frames);
|
||||
@@ -967,7 +952,7 @@ int main(int argc, char *argv[])
|
||||
/*endif*/
|
||||
}
|
||||
/*endwhile*/
|
||||
if (afCloseFile(inhandle) != 0)
|
||||
if (sf_close(inhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close speech file '%s'\n", bellcore_files[j]);
|
||||
exit(2);
|
||||
@@ -993,7 +978,7 @@ int main(int argc, char *argv[])
|
||||
modem_connect_tones_rx_init(&ced_rx, MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE, ced_detected, NULL);
|
||||
modem_connect_tones_rx_init(&ans_pr_rx, MODEM_CONNECT_TONES_ANS_PR, ec_dis_detected, NULL);
|
||||
hits = 0;
|
||||
if ((inhandle = afOpenFile_telephony_read(decode_test_file, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open speech file '%s'\n", decode_test_file);
|
||||
exit (2);
|
||||
@@ -1002,7 +987,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
when = 0;
|
||||
hits = 0;
|
||||
while ((frames = afReadFrames(inhandle, AF_DEFAULT_TRACK, amp, 8000)))
|
||||
while ((frames = sf_readf_short(inhandle, amp, 8000)))
|
||||
{
|
||||
when++;
|
||||
modem_connect_tones_rx(&cng_rx, amp, frames);
|
||||
@@ -1010,7 +995,7 @@ int main(int argc, char *argv[])
|
||||
modem_connect_tones_rx(&ans_pr_rx, amp, frames);
|
||||
}
|
||||
/*endwhile*/
|
||||
if (afCloseFile(inhandle) != 0)
|
||||
if (sf_close(inhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close speech file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
|
||||
@@ -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: modem_echo_tests.c,v 1.31 2008/11/30 10:17:31 steveu Exp $
|
||||
* $Id: modem_echo_tests.c,v 1.32 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page modem_echo_can_tests_page Line echo cancellation for modems tests
|
||||
@@ -37,9 +37,9 @@ now, the only aspect of these tests implemented is the line impulse response
|
||||
models in g168tests.c.
|
||||
|
||||
\section modem_echo_can_tests_page_sec_2 How does it work?
|
||||
The current test consists of feeding a wave file of real speech to the echo
|
||||
The current test consists of feeding an audio file of real speech to the echo
|
||||
cancellor as the transmit signal. A very simple model of a telephone line is
|
||||
used to simulate a simple echo from the transmit signal. A second wave file of
|
||||
used to simulate a simple echo from the transmit signal. A second audio file of
|
||||
real speech is also used to simulate a signal received form the far end of the
|
||||
line. This is gated so it is only placed for one second every 10 seconds,
|
||||
simulating the double talk condition. The resulting echo cancelled signal can
|
||||
@@ -62,7 +62,7 @@ current design is genuinely useful, if imperfect.
|
||||
Build the tests with the command "./build". Currently there is no proper make
|
||||
setup, or way to build individual tests. "./build" will built all the tests
|
||||
which currently exist for the DSP functions. The echo cancellation test assumes
|
||||
there are two wave files containing mono, 16 bit signed PCM speech data, sampled
|
||||
there are two audio files containing mono, 16 bit signed PCM speech data, sampled
|
||||
at 8kHz. These should be called local_sound.wav and far_sound.wav. A third wave
|
||||
file will be produced. This very crudely starts with the first 256 bytes from
|
||||
the local_sound.wav file, followed by the results of the echo cancellation. The
|
||||
@@ -87,7 +87,7 @@ cancellor.
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
#if defined(HAVE_MATH_H)
|
||||
#define GEN_CONST
|
||||
#endif
|
||||
@@ -113,7 +113,7 @@ typedef struct
|
||||
const char *name;
|
||||
int max;
|
||||
int cur;
|
||||
AFfilehandle handle;
|
||||
SNDFILE *handle;
|
||||
int16_t signal[8000];
|
||||
} signal_source_t;
|
||||
|
||||
@@ -121,7 +121,7 @@ signal_source_t local_css;
|
||||
|
||||
fir32_state_t line_model;
|
||||
|
||||
AFfilehandle resulthandle;
|
||||
SNDFILE *resulthandle;
|
||||
int16_t residue_sound[8000];
|
||||
int residue_cur = 0;
|
||||
int do_codec_munge = TRUE;
|
||||
@@ -138,10 +138,7 @@ static inline void put_residue(int16_t tx, int16_t residue)
|
||||
if (residue_cur >= 8000)
|
||||
{
|
||||
residue_cur >>= 1;
|
||||
outframes = afWriteFrames(resulthandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
residue_sound,
|
||||
residue_cur);
|
||||
outframes = sf_writef_short(resulthandle, residue_sound, residue_cur);
|
||||
if (outframes != residue_cur)
|
||||
{
|
||||
fprintf(stderr, " Error writing residue sound\n");
|
||||
@@ -155,12 +152,12 @@ static inline void put_residue(int16_t tx, int16_t residue)
|
||||
static void signal_load(signal_source_t *sig, const char *name)
|
||||
{
|
||||
sig->name = name;
|
||||
if ((sig->handle = afOpenFile_telephony_read(sig->name, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((sig->handle = sf_open_telephony_read(sig->name, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open sound file '%s'\n", sig->name);
|
||||
exit(2);
|
||||
}
|
||||
sig->max = afReadFrames(sig->handle, AF_DEFAULT_TRACK, sig->signal, 8000);
|
||||
sig->max = sf_readf_short(sig->handle, sig->signal, 8000);
|
||||
if (sig->max < 0)
|
||||
{
|
||||
fprintf(stderr, " Error reading sound file '%s'\n", sig->name);
|
||||
@@ -171,7 +168,7 @@ static void signal_load(signal_source_t *sig, const char *name)
|
||||
|
||||
static void signal_free(signal_source_t *sig)
|
||||
{
|
||||
if (afCloseFile(sig->handle) != 0)
|
||||
if (sf_close(sig->handle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close sound file '%s'\n", sig->name);
|
||||
exit(2);
|
||||
@@ -296,7 +293,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
signal_load(&local_css, "sound_c1_8k.wav");
|
||||
|
||||
if ((resulthandle = afOpenFile_telephony_write("modem_echo.wav", 2)) == AF_NULL_FILEHANDLE)
|
||||
if ((resulthandle = sf_open_telephony_write("modem_echo.wav", 2)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to open result file\n");
|
||||
exit(2);
|
||||
@@ -391,7 +388,7 @@ int main(int argc, char *argv[])
|
||||
modem_echo_can_free(ctx);
|
||||
signal_free(&local_css);
|
||||
|
||||
if (afCloseFile(resulthandle) != 0)
|
||||
if (sf_close(resulthandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close speech file '%s'\n", "result_sound.wav");
|
||||
exit(2);
|
||||
|
||||
@@ -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: noise_tests.c,v 1.17 2008/11/30 10:17:31 steveu Exp $
|
||||
* $Id: noise_tests.c,v 1.18 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page noise_tests_page Noise generator tests
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -72,11 +72,11 @@ int main (int argc, char *argv[])
|
||||
int bins[65536];
|
||||
int16_t amp[1024];
|
||||
noise_state_t noise_source;
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *outhandle;
|
||||
|
||||
if ((outhandle = afOpenFile_telephony_write(OUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@@ -164,13 +164,10 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
for (i = 0; i < 1024; i++)
|
||||
amp[i] = noise(&noise_source);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
1024);
|
||||
outframes = sf_writef_short(outhandle, amp, 1024);
|
||||
if (outframes != 1024)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -220,20 +217,17 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
for (i = 0; i < 1024; i++)
|
||||
amp[i] = noise(&noise_source);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
1024);
|
||||
outframes = sf_writef_short(outhandle, amp, 1024);
|
||||
if (outframes != 1024)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
if (afCloseFile(outhandle))
|
||||
if (sf_close(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: oki_adpcm_tests.c,v 1.36 2008/11/30 10:17:31 steveu Exp $
|
||||
* $Id: oki_adpcm_tests.c,v 1.37 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -50,7 +50,7 @@ compression may be tested.
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -67,8 +67,8 @@ compression may be tested.
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
AFfilehandle inhandle;
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *outhandle;
|
||||
int frames;
|
||||
int dec_frames;
|
||||
int outframes;
|
||||
@@ -116,14 +116,14 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if ((inhandle = afOpenFile_telephony_read(in_file_name, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(in_file_name, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", in_file_name);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", in_file_name);
|
||||
exit(2);
|
||||
}
|
||||
if ((outhandle = afOpenFile_telephony_write(OUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ int main(int argc, char *argv[])
|
||||
total_pre_samples = 0;
|
||||
total_compressed_bytes = 0;
|
||||
total_post_samples = 0;
|
||||
while ((frames = afReadFrames(inhandle, AF_DEFAULT_TRACK, pre_amp, 159)))
|
||||
while ((frames = sf_readf_short(inhandle, pre_amp, 159)))
|
||||
{
|
||||
total_pre_samples += frames;
|
||||
oki_bytes = oki_adpcm_encode(oki_enc_state, oki_data, pre_amp, frames);
|
||||
@@ -176,16 +176,16 @@ int main(int argc, char *argv[])
|
||||
diff_energy += (double) xx * (double) xx;
|
||||
//post_amp[i] = xx;
|
||||
}
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, post_amp, dec_frames);
|
||||
outframes = sf_writef_short(outhandle, post_amp, dec_frames);
|
||||
}
|
||||
if (afCloseFile(inhandle) != 0)
|
||||
if (sf_close(inhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", in_file_name);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", in_file_name);
|
||||
exit(2);
|
||||
}
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
oki_adpcm_release(oki_enc_state);
|
||||
|
||||
@@ -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: playout_tests.c,v 1.28 2009/02/10 13:06:47 steveu Exp $
|
||||
* $Id: playout_tests.c,v 1.29 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page playout_tests_page Playout (jitter buffering) tests
|
||||
@@ -38,11 +38,11 @@ how well the playout module copes.
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
#include "spandsp.h"
|
||||
|
||||
#include "spandsp/private/time_scale.h"
|
||||
#include "spandsp-sim.h"
|
||||
|
||||
#define INPUT_FILE_NAME "playout_in.wav"
|
||||
#define OUTPUT_FILE_NAME "playout_out.wav"
|
||||
@@ -71,31 +71,17 @@ static void dynamic_buffer_tests(void)
|
||||
int len;
|
||||
int inframes;
|
||||
int outframes;
|
||||
AFfilehandle inhandle;
|
||||
AFfilehandle outhandle;
|
||||
AFfilesetup filesetup;
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *outhandle;
|
||||
|
||||
filesetup = afNewFileSetup();
|
||||
if (filesetup == AF_NULL_FILESETUP)
|
||||
if ((inhandle = sf_open_telephony_read(INPUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to create file setup\n");
|
||||
fprintf(stderr, " Failed to open audio file '%s'\n", INPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
afInitSampleFormat(filesetup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
|
||||
afInitRate(filesetup, AF_DEFAULT_TRACK, (float) SAMPLE_RATE);
|
||||
afInitFileFormat(filesetup, AF_FILE_WAVE);
|
||||
afInitChannels(filesetup, AF_DEFAULT_TRACK, 2);
|
||||
|
||||
inhandle = afOpenFile(INPUT_FILE_NAME, "r", NULL);
|
||||
if (inhandle == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to open wave file '%s'\n", INPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
outhandle = afOpenFile(OUTPUT_FILE_NAME, "w", filesetup);
|
||||
if (outhandle == AF_NULL_FILEHANDLE)
|
||||
{
|
||||
fprintf(stderr, " Failed to create wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Failed to create audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@@ -115,10 +101,7 @@ static void dynamic_buffer_tests(void)
|
||||
if (i >= next_actual_receive)
|
||||
{
|
||||
amp = malloc(BLOCK_LEN*sizeof(int16_t));
|
||||
inframes = afReadFrames(inhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
BLOCK_LEN);
|
||||
inframes = sf_readf_short(inhandle, amp, BLOCK_LEN);
|
||||
if (inframes < BLOCK_LEN)
|
||||
break;
|
||||
ret = playout_put(s,
|
||||
@@ -174,7 +157,7 @@ printf("len = %d\n", len);
|
||||
buf[2*j] = out[j];
|
||||
buf[2*j + 1] = 10*playout_current_length(s);
|
||||
}
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, buf, len);
|
||||
outframes = sf_writef_short(outhandle, buf, len);
|
||||
if (outframes != len)
|
||||
{
|
||||
fprintf(stderr, " Error writing out sound\n");
|
||||
@@ -195,7 +178,7 @@ printf("len = %d\n", len);
|
||||
buf[2*j] = out[j];
|
||||
buf[2*j + 1] = 10*playout_current_length(s);
|
||||
}
|
||||
outframes = afWriteFrames(outhandle, AF_DEFAULT_TRACK, buf, len);
|
||||
outframes = sf_writef_short(outhandle, buf, len);
|
||||
if (outframes != len)
|
||||
{
|
||||
fprintf(stderr, " Error writing out sound\n");
|
||||
@@ -224,17 +207,16 @@ printf("len = %d\n", len);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (afCloseFile(inhandle) != 0)
|
||||
if (sf_close(inhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", INPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", INPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
afFreeFileSetup(filesetup);
|
||||
|
||||
printf("%10" PRId32 " %10" PRId32 " %10d\n", s->state_just_in_time, s->state_late, playout_current_length(s));
|
||||
|
||||
|
||||
@@ -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: plc_tests.c,v 1.25 2008/05/13 13:17:26 steveu Exp $
|
||||
* $Id: plc_tests.c,v 1.26 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page plc_tests_page Packet loss concealment tests
|
||||
@@ -51,18 +51,18 @@ audio file, called post_plc.wav. This file contains 8000 sample/second
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
#include "spandsp.h"
|
||||
#include "spandsp-sim.h"
|
||||
|
||||
#define INPUT_FILE_NAME "../test-data/local/short_nb_voice.wav"
|
||||
#define OUTPUT_FILE_NAME "post_plc.wav"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
AFfilehandle inhandle;
|
||||
AFfilehandle outhandle;
|
||||
AFfilesetup filesetup;
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *outhandle;
|
||||
plc_state_t plc;
|
||||
int inframes;
|
||||
int outframes;
|
||||
@@ -106,23 +106,13 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((filesetup = afNewFileSetup()) == AF_NULL_FILESETUP)
|
||||
{
|
||||
fprintf(stderr, " Failed to create file setup\n");
|
||||
exit(2);
|
||||
}
|
||||
afInitSampleFormat(filesetup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
|
||||
afInitRate(filesetup, AF_DEFAULT_TRACK, (float) SAMPLE_RATE);
|
||||
afInitFileFormat(filesetup, AF_FILE_WAVE);
|
||||
afInitChannels(filesetup, AF_DEFAULT_TRACK, 1);
|
||||
|
||||
phase_rate = 0;
|
||||
inhandle = NULL;
|
||||
if (tone < 0)
|
||||
{
|
||||
if ((inhandle = afOpenFile(INPUT_FILE_NAME, "r", NULL)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(INPUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to open wave file '%s'\n", INPUT_FILE_NAME);
|
||||
fprintf(stderr, " Failed to open audio file '%s'\n", INPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -130,9 +120,9 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
phase_rate = dds_phase_ratef((float) tone);
|
||||
}
|
||||
if ((outhandle = afOpenFile(OUTPUT_FILE_NAME, "w", filesetup)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to open wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Failed to open audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
plc_init(&plc);
|
||||
@@ -141,10 +131,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (tone < 0)
|
||||
{
|
||||
inframes = afReadFrames(inhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
block_len);
|
||||
inframes = sf_readf_short(inhandle, amp, block_len);
|
||||
if (inframes != block_len)
|
||||
break;
|
||||
}
|
||||
@@ -170,10 +157,7 @@ int main(int argc, char *argv[])
|
||||
if (block_synthetic)
|
||||
memset(amp, 0, sizeof(int16_t)*inframes);
|
||||
}
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
inframes);
|
||||
outframes = sf_writef_short(outhandle, amp, inframes);
|
||||
if (outframes != inframes)
|
||||
{
|
||||
fprintf(stderr, " Error writing out sound\n");
|
||||
@@ -183,18 +167,17 @@ int main(int argc, char *argv[])
|
||||
printf("Dropped %d of %d blocks\n", lost_blocks, block_no);
|
||||
if (tone < 0)
|
||||
{
|
||||
if (afCloseFile(inhandle) != 0)
|
||||
if (sf_close(inhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", INPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", INPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
afFreeFileSetup(filesetup);
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@@ -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: power_meter_tests.c,v 1.22 2008/11/30 10:17:31 steveu Exp $
|
||||
* $Id: power_meter_tests.c,v 1.24 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page power_meter_tests_page Power meter tests
|
||||
@@ -40,16 +40,177 @@ Both tones and noise are used to check the meter's behaviour.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <memory.h>
|
||||
#include <float.h>
|
||||
#include <time.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
//#endif
|
||||
|
||||
#include "spandsp.h"
|
||||
#include "spandsp-sim.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
#define IN_FILE_NAME "../test-data/local/short_nb_voice.wav"
|
||||
#define OUT_FILE_NAME "power_meter_tests.wav"
|
||||
|
||||
static int power_surge_detector_tests(void)
|
||||
{
|
||||
SNDFILE *outhandle;
|
||||
power_surge_detector_state_t *sig;
|
||||
int i;
|
||||
int sample;
|
||||
int16_t amp[8000];
|
||||
int16_t amp_out[2*8000];
|
||||
awgn_state_t *awgnx;
|
||||
int32_t phase_rate;
|
||||
uint32_t phase_acc;
|
||||
int16_t phase_scale;
|
||||
float signal_power;
|
||||
int32_t signal_level;
|
||||
int signal_present;
|
||||
int prev_signal_present;
|
||||
int ok;
|
||||
int extremes[4];
|
||||
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 2)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
sig = power_surge_detector_init(NULL, -50.0f, 5.0f);
|
||||
prev_signal_present = FALSE;
|
||||
|
||||
phase_rate = dds_phase_rate(450.0f);
|
||||
phase_acc = 0;
|
||||
|
||||
phase_scale = dds_scaling_dbm0(-33.0f);
|
||||
awgnx = awgn_init_dbm0(NULL, 1234567, -45.0f);
|
||||
|
||||
extremes[0] = 8001;
|
||||
extremes[1] = -1;
|
||||
extremes[2] = 8001;
|
||||
extremes[3] = -1;
|
||||
for (sample = 0; sample < 800000; sample += 8000)
|
||||
{
|
||||
ok = 0;
|
||||
for (i = 0; i < 8000; i++)
|
||||
{
|
||||
amp[i] = awgn(awgnx);
|
||||
if (i < 4000)
|
||||
amp[i] += dds_mod(&phase_acc, phase_rate, phase_scale, 0);
|
||||
|
||||
signal_level = power_surge_detector(sig, amp[i]);
|
||||
signal_present = (signal_level != 0);
|
||||
if (prev_signal_present != signal_present)
|
||||
{
|
||||
signal_power = power_surge_detector_current_dbm0(sig);
|
||||
if (signal_present)
|
||||
{
|
||||
if (ok == 0 && i >= 0 && i < 25)
|
||||
ok = 1;
|
||||
if (extremes[0] > i)
|
||||
extremes[0] = i;
|
||||
if (extremes[1] < i)
|
||||
extremes[1] = i;
|
||||
printf("On at %f (%fdBm0)\n", (sample + i)/8000.0, signal_power);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ok == 1 && i >= 4000 + 0 && i < 4000 + 35)
|
||||
ok = 2;
|
||||
if (extremes[2] > i)
|
||||
extremes[2] = i;
|
||||
if (extremes[3] < i)
|
||||
extremes[3] = i;
|
||||
printf("Off at %f (%fdBm0)\n", (sample + i)/8000.0, signal_power);
|
||||
}
|
||||
prev_signal_present = signal_present;
|
||||
}
|
||||
amp_out[2*i] = amp[i];
|
||||
amp_out[2*i + 1] = signal_present*5000;
|
||||
}
|
||||
sf_writef_short(outhandle, amp_out, 8000);
|
||||
if (ok != 2
|
||||
||
|
||||
extremes[0] < 1
|
||||
||
|
||||
extremes[1] > 30
|
||||
||
|
||||
extremes[2] < 4001
|
||||
||
|
||||
extremes[3] > 4030)
|
||||
{
|
||||
printf(" Surge not detected correctly (%d)\n", ok);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
sf_close(outhandle);
|
||||
printf("Min on %d, max on %d, min off %d, max off %d\n", extremes[0], extremes[1], extremes[2], extremes[3]);
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static int power_surge_detector_file_test(const char *file)
|
||||
{
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *outhandle;
|
||||
int inframes;
|
||||
power_surge_detector_state_t *sig;
|
||||
int i;
|
||||
int16_t amp[8000];
|
||||
int16_t amp_out[2*8000];
|
||||
int sample;
|
||||
float signal_power;
|
||||
int32_t signal_level;
|
||||
int signal_present;
|
||||
int prev_signal_present;
|
||||
|
||||
if ((inhandle = sf_open_telephony_read(file, 1)) == NULL)
|
||||
{
|
||||
printf(" Cannot open speech file '%s'\n", file);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
sig = power_surge_detector_init(NULL, -50.0f, 6.0f);
|
||||
prev_signal_present = FALSE;
|
||||
|
||||
sample = 0;
|
||||
while ((inframes = sf_readf_short(inhandle, amp, 8000)))
|
||||
{
|
||||
for (i = 0; i < inframes; i++)
|
||||
{
|
||||
signal_level = power_surge_detector(sig, amp[i]);
|
||||
signal_present = (signal_level != 0);
|
||||
if (prev_signal_present != signal_present)
|
||||
{
|
||||
signal_power = power_surge_detector_current_dbm0(sig);
|
||||
if (signal_present)
|
||||
printf("On at %f (%fdBm0)\n", (sample + i)/8000.0, signal_power);
|
||||
else
|
||||
printf("Off at %f (%fdBm0)\n", (sample + i)/8000.0, signal_power);
|
||||
prev_signal_present = signal_present;
|
||||
}
|
||||
amp_out[2*i] = amp[i];
|
||||
amp_out[2*i + 1] = signal_present*5000;
|
||||
}
|
||||
sf_writef_short(outhandle, amp_out, inframes);
|
||||
sample += inframes;
|
||||
}
|
||||
sf_close(inhandle);
|
||||
sf_close(outhandle);
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
static int power_meter_tests(void)
|
||||
{
|
||||
awgn_state_t noise_source;
|
||||
power_meter_t meter;
|
||||
@@ -62,6 +223,9 @@ int main(int argc, char *argv[])
|
||||
int32_t level;
|
||||
|
||||
power_meter_init(&meter, 7);
|
||||
printf("Testing with zero in the power register\n");
|
||||
printf("Power: expected %fdBm0, got %fdBm0\n", -90.169f, power_meter_current_dbm0(&meter));
|
||||
printf("Power: expected %fdBOv, got %fdBOv\n", -96.329f, power_meter_current_dbov(&meter));
|
||||
|
||||
printf("Testing with a square wave 10dB from maximum\n");
|
||||
for (i = 0; i < 1000; i++)
|
||||
@@ -159,8 +323,46 @@ int main(int argc, char *argv[])
|
||||
printf("Test failed (dBOv)\n");
|
||||
exit(2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int basic_tests;
|
||||
int decode;
|
||||
int opt;
|
||||
const char *in_file;
|
||||
|
||||
basic_tests = TRUE;
|
||||
decode = FALSE;
|
||||
in_file = IN_FILE_NAME;
|
||||
while ((opt = getopt(argc, argv, "d:")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'd':
|
||||
in_file = optarg;
|
||||
basic_tests = FALSE;
|
||||
decode = TRUE;
|
||||
break;
|
||||
default:
|
||||
//usage();
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
if (basic_tests)
|
||||
{
|
||||
power_meter_tests();
|
||||
power_surge_detector_tests();
|
||||
}
|
||||
if (decode)
|
||||
{
|
||||
power_surge_detector_file_test(in_file);
|
||||
}
|
||||
printf("Tests passed\n");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
/*- End of file ------------------------------------------------------------*/
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: r2_mf_rx_tests.c,v 1.13 2009/04/11 18:11:19 steveu Exp $
|
||||
* $Id: r2_mf_rx_tests.c,v 1.14 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -51,7 +51,7 @@ a fair test of performance in a real PSTN channel.
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
|
||||
@@ -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: r2_mf_tx_tests.c,v 1.15 2008/11/30 10:17:31 steveu Exp $
|
||||
* $Id: r2_mf_tx_tests.c,v 1.16 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -47,7 +47,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -63,14 +63,14 @@ int main(int argc, char *argv[])
|
||||
r2_mf_tx_state_t gen;
|
||||
int16_t amp[1000];
|
||||
int len;
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *outhandle;
|
||||
int outframes;
|
||||
int digit;
|
||||
const char *digits = "0123456789BCDEF";
|
||||
|
||||
if ((outhandle = afOpenFile_telephony_write(OUTPUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@@ -81,22 +81,12 @@ int main(int argc, char *argv[])
|
||||
len = r2_mf_tx(&gen, amp, 1000);
|
||||
printf("Generated %d samples of %c\n", len, digits[digit]);
|
||||
if (len > 0)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
}
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
r2_mf_tx_put(&gen, 0);
|
||||
len = r2_mf_tx(&gen, amp, 1000);
|
||||
printf("Generated %d samples\n", len);
|
||||
if (len > 0)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
}
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
|
||||
r2_mf_tx_init(&gen, TRUE);
|
||||
@@ -106,27 +96,17 @@ int main(int argc, char *argv[])
|
||||
len = r2_mf_tx(&gen, amp, 1000);
|
||||
printf("Generated %d samples of %c\n", len, digits[digit]);
|
||||
if (len > 0)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
}
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
r2_mf_tx_put(&gen, 0);
|
||||
len = r2_mf_tx(&gen, amp, 1000);
|
||||
printf("Generated %d samples\n", len);
|
||||
if (len > 0)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
}
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit (2);
|
||||
}
|
||||
|
||||
|
||||
@@ -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.56 2009/04/02 13:43:49 steveu Exp $
|
||||
# $Id: regression_tests.sh,v 1.58 2009/05/19 14:47:02 steveu Exp $
|
||||
#
|
||||
|
||||
ITUTESTS_TIF=../test-data/itu/fax/itutests.tif
|
||||
@@ -686,28 +686,28 @@ echo tone_detect_tests not enabled
|
||||
#echo tone_generate_tests completed OK
|
||||
echo tone_generate_tests not enabled
|
||||
|
||||
./v17_tests -b 14400 -s -42 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
./v17_tests -b 14400 -s -42 -n -66 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
RETVAL=$?
|
||||
if [ $RETVAL != 0 ]
|
||||
then
|
||||
echo v17_tests failed!
|
||||
exit $RETVAL
|
||||
fi
|
||||
./v17_tests -b 12000 -s -42 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
./v17_tests -b 12000 -s -42 -n -61 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
RETVAL=$?
|
||||
if [ $RETVAL != 0 ]
|
||||
then
|
||||
echo v17_tests failed!
|
||||
exit $RETVAL
|
||||
fi
|
||||
./v17_tests -b 9600 -s -42 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
./v17_tests -b 9600 -s -42 -n -59 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
RETVAL=$?
|
||||
if [ $RETVAL != 0 ]
|
||||
then
|
||||
echo v17_tests failed!
|
||||
exit $RETVAL
|
||||
fi
|
||||
./v17_tests -b 7200 -s -42 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
./v17_tests -b 7200 -s -42 -n -56 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
RETVAL=$?
|
||||
if [ $RETVAL != 0 ]
|
||||
then
|
||||
@@ -733,14 +733,14 @@ echo v17_tests completed OK
|
||||
#echo v22bis_tests completed OK
|
||||
echo v22bis_tests not enabled
|
||||
|
||||
./v27ter_tests -b 4800 -s -42 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
./v27ter_tests -b 4800 -s -42 -n -57 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
RETVAL=$?
|
||||
if [ $RETVAL != 0 ]
|
||||
then
|
||||
echo v27ter_tests failed!
|
||||
exit $RETVAL
|
||||
fi
|
||||
./v27ter_tests -b 2400 -s -42 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
./v27ter_tests -b 2400 -s -42 -n -51 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
RETVAL=$?
|
||||
if [ $RETVAL != 0 ]
|
||||
then
|
||||
@@ -749,21 +749,21 @@ then
|
||||
fi
|
||||
echo v27ter_tests completed OK
|
||||
|
||||
./v29_tests -b 9600 -s -42 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
./v29_tests -b 9600 -s -42 -n -62 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
RETVAL=$?
|
||||
if [ $RETVAL != 0 ]
|
||||
then
|
||||
echo v29_tests failed!
|
||||
exit $RETVAL
|
||||
fi
|
||||
./v29_tests -b 7200 -s -42 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
./v29_tests -b 7200 -s -42 -n -58 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
RETVAL=$?
|
||||
if [ $RETVAL != 0 ]
|
||||
then
|
||||
echo v29_tests failed!
|
||||
exit $RETVAL
|
||||
fi
|
||||
./v29_tests -b 4800 -s -42 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
./v29_tests -b 4800 -s -42 -n -54 >$STDOUT_DEST 2>$STDERR_DEST
|
||||
RETVAL=$?
|
||||
if [ $RETVAL != 0 ]
|
||||
then
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: rfc2198_sim_tests.c,v 1.6 2008/11/30 10:17:31 steveu Exp $
|
||||
* $Id: rfc2198_sim_tests.c,v 1.7 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
#if defined(HAVE_MATH_H)
|
||||
#define GEN_CONST
|
||||
#endif
|
||||
|
||||
@@ -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.24 2008/11/30 10:17:31 steveu Exp $
|
||||
* $Id: sig_tone_tests.c,v 1.25 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -42,7 +42,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -171,7 +171,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
int16_t amp[SAMPLES_PER_CHUNK];
|
||||
int16_t out_amp[2*SAMPLES_PER_CHUNK];
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *outhandle;
|
||||
int outframes;
|
||||
int i;
|
||||
int type;
|
||||
@@ -182,9 +182,9 @@ int main(int argc, char *argv[])
|
||||
awgn_state_t noise_source;
|
||||
codec_munge_state_t *munge;
|
||||
|
||||
if ((outhandle = afOpenFile_telephony_write(OUT_FILE_NAME, 2)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 2)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
/*endif*/
|
||||
@@ -240,13 +240,10 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < rx_samples; i++)
|
||||
out_amp[2*i + 1] = amp[i];
|
||||
/*endfor*/
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
out_amp,
|
||||
rx_samples);
|
||||
outframes = sf_writef_short(outhandle, out_amp, rx_samples);
|
||||
if (outframes != rx_samples)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
/*endif*/
|
||||
@@ -254,9 +251,9 @@ int main(int argc, char *argv[])
|
||||
/*endfor*/
|
||||
}
|
||||
/*endfor*/
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
/*endif*/
|
||||
|
||||
@@ -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: super_tone_rx_tests.c,v 1.30 2008/11/30 10:17:31 steveu Exp $
|
||||
* $Id: super_tone_rx_tests.c,v 1.33 2009/06/02 14:55:36 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -42,8 +42,7 @@
|
||||
#include <strings.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <sys/socket.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
#if defined(HAVE_LIBXML_XMLMEMORY_H)
|
||||
#include <libxml/xmlmemory.h>
|
||||
@@ -60,6 +59,7 @@
|
||||
//#endif
|
||||
|
||||
#include "spandsp.h"
|
||||
#include "spandsp-sim.h"
|
||||
|
||||
#define IN_FILE_NAME "super_tone.wav"
|
||||
|
||||
@@ -80,7 +80,7 @@ const char *bellcore_files[] =
|
||||
|
||||
const char *tone_names[20] = {NULL};
|
||||
|
||||
AFfilehandle inhandle;
|
||||
SNDFILE *inhandle;
|
||||
|
||||
super_tone_rx_segment_t tone_segments[20][10];
|
||||
|
||||
@@ -378,24 +378,9 @@ int main(int argc, char *argv[])
|
||||
super_tone_rx_state_t *super;
|
||||
super_tone_rx_descriptor_t desc;
|
||||
|
||||
if ((inhandle = afOpenFile(IN_FILE_NAME, "r", 0)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(IN_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", IN_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetFrameSize(inhandle, AF_DEFAULT_TRACK, 1)) != 2.0)
|
||||
{
|
||||
printf(" Unexpected frame size in wave file '%s'\n", IN_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetRate(inhandle, AF_DEFAULT_TRACK)) != (float) SAMPLE_RATE)
|
||||
{
|
||||
printf(" Unexpected sample rate in wave file '%s'\n", IN_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetChannels(inhandle, AF_DEFAULT_TRACK)) != 1.0)
|
||||
{
|
||||
printf(" Unexpected number of channels in wave file '%s'\n", IN_FILE_NAME);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", IN_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
super_tone_rx_make_descriptor(&desc);
|
||||
@@ -411,7 +396,7 @@ int main(int argc, char *argv[])
|
||||
super_tone_rx_segment_callback(super, tone_segment);
|
||||
awgn_init_dbm0(&noise_source, 1234567, -30.0f);
|
||||
printf("Processing file\n");
|
||||
while ((frames = afReadFrames(inhandle, AF_DEFAULT_TRACK, amp, 8000)))
|
||||
while ((frames = sf_readf_short(inhandle, amp, 8000)))
|
||||
{
|
||||
/* Add some noise to the signal for a more meaningful test. */
|
||||
//for (sample = 0; sample < frames; sample++)
|
||||
@@ -422,7 +407,7 @@ int main(int argc, char *argv[])
|
||||
sample += x;
|
||||
}
|
||||
}
|
||||
if (afCloseFile(inhandle))
|
||||
if (sf_close(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", IN_FILE_NAME);
|
||||
exit(2);
|
||||
@@ -431,27 +416,12 @@ int main(int argc, char *argv[])
|
||||
/* Test for voice immunity */
|
||||
for (j = 0; bellcore_files[j][0]; j++)
|
||||
{
|
||||
if ((inhandle = afOpenFile(bellcore_files[j], "r", 0)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(bellcore_files[j], 1)) == NULL)
|
||||
{
|
||||
printf(" Cannot open wave file '%s'\n", bellcore_files[j]);
|
||||
printf(" Cannot open audio file '%s'\n", bellcore_files[j]);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetFrameSize(inhandle, AF_DEFAULT_TRACK, 1)) != 2.0)
|
||||
{
|
||||
printf(" Unexpected frame size in wave file '%s'\n", bellcore_files[j]);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetRate(inhandle, AF_DEFAULT_TRACK)) != (float) SAMPLE_RATE)
|
||||
{
|
||||
printf(" Unexpected sample rate in wave file '%s'\n", bellcore_files[j]);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetChannels(inhandle, AF_DEFAULT_TRACK)) != 1.0)
|
||||
{
|
||||
printf(" Unexpected number of channels in wave file '%s'\n", bellcore_files[j]);
|
||||
exit(2);
|
||||
}
|
||||
while ((frames = afReadFrames(inhandle, AF_DEFAULT_TRACK, amp, 8000)))
|
||||
while ((frames = sf_readf_short(inhandle, amp, 8000)))
|
||||
{
|
||||
for (sample = 0; sample < frames; )
|
||||
{
|
||||
@@ -459,7 +429,7 @@ int main(int argc, char *argv[])
|
||||
sample += x;
|
||||
}
|
||||
}
|
||||
if (afCloseFile(inhandle) != 0)
|
||||
if (sf_close(inhandle) != 0)
|
||||
{
|
||||
printf(" Cannot close speech file '%s'\n", bellcore_files[j]);
|
||||
exit(2);
|
||||
|
||||
@@ -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: super_tone_tx_tests.c,v 1.25 2009/02/10 17:44:18 steveu Exp $
|
||||
* $Id: super_tone_tx_tests.c,v 1.26 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <time.h>
|
||||
#include <inttypes.h>
|
||||
#include <sys/socket.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
#if defined(HAVE_LIBXML_XMLMEMORY_H)
|
||||
#include <libxml/xmlmemory.h>
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
#define OUT_FILE_NAME "super_tone.wav"
|
||||
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *outhandle;
|
||||
|
||||
super_tone_tx_step_t *tone_tree = NULL;
|
||||
|
||||
@@ -82,13 +82,10 @@ static void play_tones(super_tone_tx_state_t *tone, int max_samples)
|
||||
do
|
||||
{
|
||||
len = super_tone_tx(tone, amp, 160);
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (outframes != len)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
total_length += len;
|
||||
@@ -286,7 +283,7 @@ static void get_tone_set(const char *tone_file, const char *set_id)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if ((outhandle = afOpenFile_telephony_write(OUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
@@ -294,7 +291,7 @@ int main(int argc, char *argv[])
|
||||
#if defined(HAVE_LIBXML2)
|
||||
get_tone_set("../spandsp/global-tones.xml", (argc > 1) ? argv[1] : "hk");
|
||||
#endif
|
||||
if (afCloseFile (outhandle) != 0)
|
||||
if (sf_close (outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
|
||||
@@ -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: t31_tests.c,v 1.71 2009/02/20 12:38:37 steveu Exp $
|
||||
* $Id: t31_tests.c,v 1.72 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -48,7 +48,7 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -661,8 +661,8 @@ static int t30_tests(int log_audio, int test_sending)
|
||||
int16_t out_amp[2*SAMPLES_PER_CHUNK];
|
||||
int t30_len;
|
||||
int t31_len;
|
||||
AFfilehandle wave_handle;
|
||||
AFfilehandle in_handle;
|
||||
SNDFILE *wave_handle;
|
||||
SNDFILE *in_handle;
|
||||
int fast_send;
|
||||
int fast_send_tcf;
|
||||
int fast_blocks;
|
||||
@@ -671,12 +671,12 @@ static int t30_tests(int log_audio, int test_sending)
|
||||
logging_state_t *logging;
|
||||
int i;
|
||||
|
||||
wave_handle = AF_NULL_FILEHANDLE;
|
||||
wave_handle = NULL;
|
||||
if (log_audio)
|
||||
{
|
||||
if ((wave_handle = afOpenFile_telephony_write(OUTPUT_WAVE_FILE_NAME, 2)) == AF_NULL_FILEHANDLE)
|
||||
if ((wave_handle = sf_open_telephony_write(OUTPUT_WAVE_FILE_NAME, 2)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUTPUT_WAVE_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_WAVE_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -686,9 +686,9 @@ static int t30_tests(int log_audio, int test_sending)
|
||||
in_handle = NULL;
|
||||
if (decode_test_file)
|
||||
{
|
||||
if ((in_handle = afOpenFile_telephony_read(decode_test_file, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((in_handle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", decode_test_file);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -864,24 +864,24 @@ static int t30_tests(int log_audio, int test_sending)
|
||||
|
||||
if (log_audio)
|
||||
{
|
||||
outframes = afWriteFrames(wave_handle, AF_DEFAULT_TRACK, out_amp, SAMPLES_PER_CHUNK);
|
||||
outframes = sf_writef_short(wave_handle, out_amp, SAMPLES_PER_CHUNK);
|
||||
if (outframes != SAMPLES_PER_CHUNK)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (decode_test_file)
|
||||
{
|
||||
if (afCloseFile(in_handle) != 0)
|
||||
if (sf_close(in_handle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", decode_test_file);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
if (afCloseFile(wave_handle) != 0)
|
||||
if (sf_close(wave_handle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUTPUT_WAVE_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_WAVE_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: t38_gateway_tests.c,v 1.81 2009/04/25 14:27:18 steveu Exp $
|
||||
* $Id: t38_gateway_tests.c,v 1.82 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -51,7 +51,7 @@ These tests exercise the path
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
#if !defined(_WIN32)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@@ -234,7 +234,7 @@ int main(int argc, char *argv[])
|
||||
int msg_len;
|
||||
uint8_t msg[1024];
|
||||
int outframes;
|
||||
AFfilehandle wave_handle;
|
||||
SNDFILE *wave_handle;
|
||||
int use_ecm;
|
||||
int use_tep;
|
||||
int feedback_audio;
|
||||
@@ -327,12 +327,12 @@ int main(int argc, char *argv[])
|
||||
if (use_ecm)
|
||||
printf("Using ECM\n");
|
||||
|
||||
wave_handle = AF_NULL_FILEHANDLE;
|
||||
wave_handle = NULL;
|
||||
if (log_audio)
|
||||
{
|
||||
if ((wave_handle = afOpenFile_telephony_write(OUTPUT_FILE_NAME_WAVE, 4)) == AF_NULL_FILEHANDLE)
|
||||
if ((wave_handle = sf_open_telephony_write(OUTPUT_FILE_NAME_WAVE, 4)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -599,7 +599,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
outframes = afWriteFrames(wave_handle, AF_DEFAULT_TRACK, out_amp, SAMPLES_PER_CHUNK);
|
||||
outframes = sf_writef_short(wave_handle, out_amp, SAMPLES_PER_CHUNK);
|
||||
if (outframes != SAMPLES_PER_CHUNK)
|
||||
break;
|
||||
}
|
||||
@@ -627,9 +627,9 @@ int main(int argc, char *argv[])
|
||||
fax_release(fax_state_b);
|
||||
if (log_audio)
|
||||
{
|
||||
if (afCloseFile(wave_handle) != 0)
|
||||
if (sf_close(wave_handle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: t38_gateway_to_terminal_tests.c,v 1.65 2009/04/25 14:27:18 steveu Exp $
|
||||
* $Id: t38_gateway_to_terminal_tests.c,v 1.66 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -51,7 +51,7 @@ These tests exercise the path
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
#if !defined(_WIN32)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@@ -208,7 +208,7 @@ int main(int argc, char *argv[])
|
||||
int use_tep;
|
||||
int feedback_audio;
|
||||
int use_transmit_on_idle;
|
||||
AFfilehandle wave_handle;
|
||||
SNDFILE *wave_handle;
|
||||
const char *input_file_name;
|
||||
int i;
|
||||
int seq_no;
|
||||
@@ -288,12 +288,12 @@ int main(int argc, char *argv[])
|
||||
if (use_ecm)
|
||||
printf("Using ECM\n");
|
||||
|
||||
wave_handle = AF_NULL_FILEHANDLE;
|
||||
wave_handle = NULL;
|
||||
if (log_audio)
|
||||
{
|
||||
if ((wave_handle = afOpenFile_telephony_write(OUTPUT_FILE_NAME_WAVE, 2)) == AF_NULL_FILEHANDLE)
|
||||
if ((wave_handle = sf_open_telephony_write(OUTPUT_FILE_NAME_WAVE, 2)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -482,7 +482,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
outframes = afWriteFrames(wave_handle, AF_DEFAULT_TRACK, out_amp, SAMPLES_PER_CHUNK);
|
||||
outframes = sf_writef_short(wave_handle, out_amp, SAMPLES_PER_CHUNK);
|
||||
if (outframes != SAMPLES_PER_CHUNK)
|
||||
break;
|
||||
}
|
||||
@@ -498,9 +498,9 @@ int main(int argc, char *argv[])
|
||||
t38_terminal_release(t38_state_b);
|
||||
if (log_audio)
|
||||
{
|
||||
if (afCloseFile(wave_handle) != 0)
|
||||
if (sf_close(wave_handle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: t38_terminal_to_gateway_tests.c,v 1.64 2009/04/25 14:27:19 steveu Exp $
|
||||
* $Id: t38_terminal_to_gateway_tests.c,v 1.65 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -51,7 +51,7 @@ These tests exercise the path
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
#if !defined(_WIN32)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@@ -203,7 +203,7 @@ int main(int argc, char *argv[])
|
||||
uint8_t msg[1024];
|
||||
int log_audio;
|
||||
int outframes;
|
||||
AFfilehandle wave_handle;
|
||||
SNDFILE *wave_handle;
|
||||
int t38_version;
|
||||
int use_ecm;
|
||||
int use_tep;
|
||||
@@ -288,12 +288,12 @@ int main(int argc, char *argv[])
|
||||
if (use_ecm)
|
||||
printf("Using ECM\n");
|
||||
|
||||
wave_handle = AF_NULL_FILEHANDLE;
|
||||
wave_handle = NULL;
|
||||
if (log_audio)
|
||||
{
|
||||
if ((wave_handle = afOpenFile_telephony_write(OUTPUT_FILE_NAME_WAVE, 2)) == AF_NULL_FILEHANDLE)
|
||||
if ((wave_handle = sf_open_telephony_write(OUTPUT_FILE_NAME_WAVE, 2)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -482,7 +482,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
outframes = afWriteFrames(wave_handle, AF_DEFAULT_TRACK, out_amp, SAMPLES_PER_CHUNK);
|
||||
outframes = sf_writef_short(wave_handle, out_amp, SAMPLES_PER_CHUNK);
|
||||
if (outframes != SAMPLES_PER_CHUNK)
|
||||
break;
|
||||
}
|
||||
@@ -498,9 +498,9 @@ int main(int argc, char *argv[])
|
||||
fax_release(fax_state_b);
|
||||
if (log_audio)
|
||||
{
|
||||
if (afCloseFile(wave_handle) != 0)
|
||||
if (sf_close(wave_handle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: t4_tests.c,v 1.68 2009/03/01 12:39:02 steveu Exp $
|
||||
* $Id: t4_tests.c,v 1.69 2009/05/16 03:34:45 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
|
||||
@@ -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: testadsi.c,v 1.22 2008/05/13 13:17:26 steveu Exp $
|
||||
* $Id: testadsi.c,v 1.23 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
#include <linux/zaptel.h>
|
||||
#include <pthread.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
#include <tiffio.h>
|
||||
|
||||
#include "unicall.h"
|
||||
@@ -59,8 +59,8 @@
|
||||
#define TRUE (!FALSE)
|
||||
|
||||
int caller_mode = FALSE;
|
||||
static AFfilehandle rxhandle;
|
||||
static AFfilehandle txhandle;
|
||||
static SNDFILE *rxhandle;
|
||||
static SNDFILE *txhandle;
|
||||
|
||||
#if 0
|
||||
int adsi_create_message(adsi_tx_state_t *s, uint8_t *msg)
|
||||
@@ -196,7 +196,7 @@ void channel_read_adsi_channel(uc_t *uc, int chan, void *user_data, uint8_t *buf
|
||||
for (i = 0; i < len; i++)
|
||||
pcm_buf[i] = alaw_to_linear(buf[i]);
|
||||
/*endfor*/
|
||||
outframes = afWriteFrames(rxhandle,
|
||||
outframes = sf_writef_short(rxhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
pcm_buf,
|
||||
len);
|
||||
@@ -254,7 +254,7 @@ int channel_write_adsi_channel(uc_t *uc, int chan, void *user_data, uint8_t *buf
|
||||
printf("Message put - %d bytes\n", len);
|
||||
}
|
||||
len = adsi_tx(&(chan_stuff[chan].adsi_tx), pcm_buf, max_len);
|
||||
afWriteFrames(txhandle,
|
||||
sf_writef_short(txhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
pcm_buf,
|
||||
len);
|
||||
@@ -563,13 +563,13 @@ int main(int argc, char *argv[])
|
||||
afInitFileFormat(filesetup, AF_FILE_WAVE);
|
||||
afInitChannels(filesetup, AF_DEFAULT_TRACK, 1);
|
||||
rxhandle = afOpenFile("rxadsi.wav", "w", filesetup);
|
||||
if (rxhandle == AF_NULL_FILEHANDLE)
|
||||
if (rxhandle == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to open adsi audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
txhandle = afOpenFile("txadsi.wav", "w", filesetup);
|
||||
if (txhandle == AF_NULL_FILEHANDLE)
|
||||
if (txhandle == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to open adsi audio file\n");
|
||||
exit(2);
|
||||
|
||||
@@ -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: testfax.c,v 1.32 2008/05/13 13:17:26 steveu Exp $
|
||||
* $Id: testfax.c,v 1.33 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
#include <linux/zaptel.h>
|
||||
#include <pthread.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
#include <tiffio.h>
|
||||
|
||||
#include "unicall.h"
|
||||
@@ -57,8 +57,8 @@
|
||||
#include "spandsp.h"
|
||||
|
||||
int caller_mode = FALSE;
|
||||
static AFfilehandle rxhandle;
|
||||
static AFfilehandle txhandle;
|
||||
static SNDFILE *rxhandle;
|
||||
static SNDFILE *txhandle;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -104,7 +104,7 @@ void channel_read_fax_channel(uc_t *uc, int chan, void *user_data, uint8_t *buf,
|
||||
int outframes;
|
||||
|
||||
#if 0
|
||||
outframes = afWriteFrames(rxhandle,
|
||||
outframes = sf_writef_short(rxhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
buf,
|
||||
len >> 1);
|
||||
@@ -149,7 +149,7 @@ int channel_write_fax_channel(uc_t *uc, int chan, void *user_data, uint8_t *buf,
|
||||
int len;
|
||||
|
||||
len = t30_tx(&(chan_stuff[chan].fax), (int16_t *) buf, max_len >> 1);
|
||||
afWriteFrames(txhandle, AF_DEFAULT_TRACK, buf, len);
|
||||
sf_writef_short(txhandle, AF_DEFAULT_TRACK, buf, len);
|
||||
if (len > 0)
|
||||
len <<= 1;
|
||||
return len;
|
||||
@@ -532,13 +532,13 @@ int main(int argc, char *argv[])
|
||||
afInitFileFormat(filesetup, AF_FILE_WAVE);
|
||||
afInitChannels(filesetup, AF_DEFAULT_TRACK, 1);
|
||||
rxhandle = afOpenFile("rxfax.wav", "w", filesetup);
|
||||
if (rxhandle == AF_NULL_FILEHANDLE)
|
||||
if (rxhandle == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to open fax audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
txhandle = afOpenFile("txfax.wav", "w", filesetup);
|
||||
if (txhandle == AF_NULL_FILEHANDLE)
|
||||
if (txhandle == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to open fax audio file\n");
|
||||
exit(2);
|
||||
|
||||
@@ -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: time_scale_tests.c,v 1.23 2008/11/15 14:27:29 steveu Exp $
|
||||
* $Id: time_scale_tests.c,v 1.24 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page time_scale_tests_page Time scaling tests
|
||||
@@ -44,7 +44,7 @@ This file also contains 8000 sample/second 16 bits/sample linear audio.
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
#include "spandsp.h"
|
||||
|
||||
@@ -57,9 +57,9 @@ This file also contains 8000 sample/second 16 bits/sample linear audio.
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
AFfilehandle inhandle;
|
||||
AFfilehandle outhandle;
|
||||
AFfilesetup filesetup;
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *outhandle;
|
||||
SF_INFO info;
|
||||
int16_t in[BLOCK_LEN];
|
||||
int16_t out[5*(BLOCK_LEN + TIME_SCALE_MAX_SAMPLE_RATE/TIME_SCALE_MIN_PITCH)];
|
||||
int frames;
|
||||
@@ -68,7 +68,6 @@ int main(int argc, char *argv[])
|
||||
int count;
|
||||
int max;
|
||||
time_scale_state_t state;
|
||||
float x;
|
||||
float rate;
|
||||
float sample_rate;
|
||||
const char *in_file_name;
|
||||
@@ -97,35 +96,29 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((inhandle = afOpenFile(in_file_name, "r", 0)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open(in_file_name, SFM_READ, &info)) == NULL)
|
||||
{
|
||||
printf(" Cannot open wave file '%s'\n", in_file_name);
|
||||
printf(" Cannot open audio file '%s'\n", in_file_name);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetFrameSize(inhandle, AF_DEFAULT_TRACK, 1)) != 2.0)
|
||||
if (info.channels != 1)
|
||||
{
|
||||
printf(" Unexpected frame size in wave file '%s'\n", in_file_name);
|
||||
printf(" Unexpected number of channels in audio file '%s'\n", in_file_name);
|
||||
exit(2);
|
||||
}
|
||||
if ((x = afGetChannels(inhandle, AF_DEFAULT_TRACK)) != 1.0)
|
||||
{
|
||||
printf(" Unexpected number of channels in wave file '%s'\n", in_file_name);
|
||||
exit(2);
|
||||
}
|
||||
sample_rate = afGetRate(inhandle, AF_DEFAULT_TRACK);
|
||||
sample_rate = info.samplerate;
|
||||
|
||||
if ((filesetup = afNewFileSetup()) == AF_NULL_FILESETUP)
|
||||
memset(&info, 0, sizeof(info));
|
||||
info.frames = 0;
|
||||
info.samplerate = sample_rate;
|
||||
info.channels = 1;
|
||||
info.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
|
||||
info.sections = 1;
|
||||
info.seekable = 1;
|
||||
|
||||
if ((outhandle = sf_open(OUT_FILE_NAME, SFM_WRITE, &info)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Failed to create file setup\n");
|
||||
exit(2);
|
||||
}
|
||||
afInitSampleFormat(filesetup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
|
||||
afInitRate(filesetup, AF_DEFAULT_TRACK, sample_rate);
|
||||
afInitFileFormat(filesetup, AF_FILE_WAVE);
|
||||
afInitChannels(filesetup, AF_DEFAULT_TRACK, 1);
|
||||
if ((outhandle = afOpenFile(OUT_FILE_NAME, "w", filesetup)) == AF_NULL_FILEHANDLE)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@@ -137,13 +130,13 @@ int main(int argc, char *argv[])
|
||||
max = time_scale_max_output_len(&state, BLOCK_LEN);
|
||||
printf("Rate is %f, longest output block is %d\n", rate, max);
|
||||
count = 0;
|
||||
while ((frames = afReadFrames(inhandle, AF_DEFAULT_TRACK, in, BLOCK_LEN)))
|
||||
while ((frames = sf_readf_short(inhandle, in, BLOCK_LEN)))
|
||||
{
|
||||
new_frames = time_scale(&state, out, in, frames);
|
||||
out_frames = afWriteFrames(outhandle, AF_DEFAULT_TRACK, out, new_frames);
|
||||
out_frames = sf_writef_short(outhandle, out, new_frames);
|
||||
if (out_frames != new_frames)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
if (sweep_rate && ++count > 100)
|
||||
@@ -160,17 +153,16 @@ int main(int argc, char *argv[])
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
if (afCloseFile(inhandle) != 0)
|
||||
if (sf_close(inhandle) != 0)
|
||||
{
|
||||
printf(" Cannot close wave file '%s'\n", in_file_name);
|
||||
printf(" Cannot close audio file '%s'\n", in_file_name);
|
||||
exit(2);
|
||||
}
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
printf(" Cannot close wave file '%s'\n", OUT_FILE_NAME);
|
||||
printf(" Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
afFreeFileSetup(filesetup);
|
||||
return 0;
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@@ -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: tone_detect_tests.c,v 1.11 2008/11/30 12:38:27 steveu Exp $
|
||||
* $Id: tone_detect_tests.c,v 1.12 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page tone_detect_tests_page Tone detection tests
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
|
||||
@@ -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: tone_generate_tests.c,v 1.21 2008/11/30 10:17:31 steveu Exp $
|
||||
* $Id: tone_generate_tests.c,v 1.22 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page tone_generate_tests_page Tone generation tests
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -56,12 +56,12 @@ int main(int argc, char *argv[])
|
||||
int i;
|
||||
int16_t amp[16384];
|
||||
int len;
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *outhandle;
|
||||
int outframes;
|
||||
|
||||
if ((outhandle = afOpenFile_telephony_write(OUTPUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@@ -84,10 +84,7 @@ int main(int argc, char *argv[])
|
||||
printf("Generated %d samples\n", len);
|
||||
if (len <= 0)
|
||||
break;
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
|
||||
/* Try a different tone pair */
|
||||
@@ -109,10 +106,7 @@ int main(int argc, char *argv[])
|
||||
printf("Generated %d samples\n", len);
|
||||
if (len <= 0)
|
||||
break;
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
|
||||
/* Try a different tone pair */
|
||||
@@ -134,10 +128,7 @@ int main(int argc, char *argv[])
|
||||
printf("Generated %d samples\n", len);
|
||||
if (len <= 0)
|
||||
break;
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
|
||||
/* Try a single tone */
|
||||
@@ -159,10 +150,7 @@ int main(int argc, char *argv[])
|
||||
printf("Generated %d samples\n", len);
|
||||
if (len <= 0)
|
||||
break;
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
|
||||
/* Try a single non-repeating tone */
|
||||
@@ -184,10 +172,7 @@ int main(int argc, char *argv[])
|
||||
printf("Generated %d samples\n", len);
|
||||
if (len <= 0)
|
||||
break;
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
|
||||
/* Try a single non-repeating tone at 0dBm0 */
|
||||
@@ -209,10 +194,7 @@ int main(int argc, char *argv[])
|
||||
printf("Generated %d samples\n", len);
|
||||
if (len <= 0)
|
||||
break;
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
|
||||
/* Try an AM modulated tone at a modest modulation level (25%) */
|
||||
@@ -234,10 +216,7 @@ int main(int argc, char *argv[])
|
||||
printf("Generated %d samples\n", len);
|
||||
if (len <= 0)
|
||||
break;
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
|
||||
/* Try an AM modulated tone at maximum modulation level (100%) */
|
||||
@@ -259,15 +238,12 @@ int main(int argc, char *argv[])
|
||||
printf("Generated %d samples\n", len);
|
||||
if (len <= 0)
|
||||
break;
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
}
|
||||
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit (2);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: tsb85_tests.c,v 1.30 2009/02/20 12:34:20 steveu Exp $
|
||||
* $Id: tsb85_tests.c,v 1.32 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \file */
|
||||
@@ -47,7 +47,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
#if defined(HAVE_LIBXML_XMLMEMORY_H)
|
||||
#include <libxml/xmlmemory.h>
|
||||
@@ -75,7 +75,7 @@
|
||||
|
||||
#define SAMPLES_PER_CHUNK 160
|
||||
|
||||
AFfilehandle out_handle;
|
||||
SNDFILE *out_handle;
|
||||
|
||||
int use_receiver_not_ready = FALSE;
|
||||
int test_local_interrupt = FALSE;
|
||||
@@ -335,6 +335,7 @@ static void faxtester_real_time_frame_handler(faxtester_state_t *s,
|
||||
{
|
||||
span_log_buf(&s->logging, SPAN_LOG_FLOW, "Expected", awaited, abs(awaited_len));
|
||||
span_log_buf(&s->logging, SPAN_LOG_FLOW, "Received", msg, len);
|
||||
printf("Test failed\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -359,6 +360,7 @@ static void faxtester_front_end_step_complete_handler(faxtester_state_t *s, void
|
||||
static void faxtester_front_end_step_timeout_handler(faxtester_state_t *s, void *user_data)
|
||||
{
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "FAX tester step timed out\n");
|
||||
printf("Test failed\n");
|
||||
exit(2);
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
@@ -644,6 +646,7 @@ static int next_step(faxtester_state_t *s)
|
||||
return 1;
|
||||
}
|
||||
/* Finished */
|
||||
printf("Test passed\n");
|
||||
exit(0);
|
||||
}
|
||||
while (s->cur && xmlStrcmp(s->cur->name, (const xmlChar *) "step") != 0)
|
||||
@@ -651,6 +654,7 @@ static int next_step(faxtester_state_t *s)
|
||||
if (s->cur == NULL)
|
||||
{
|
||||
/* Finished */
|
||||
printf("Test passed\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -965,6 +969,7 @@ printf("Push '%s'\n", next_tx_file);
|
||||
if (t4_tx_init(&t4_state, path, -1, -1) == NULL)
|
||||
{
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "Failed to init T.4 send\n");
|
||||
printf("Test failed\n");
|
||||
exit(2);
|
||||
}
|
||||
t4_tx_set_min_row_bits(&t4_state, min_row_bits);
|
||||
@@ -981,6 +986,7 @@ printf("Push '%s'\n", next_tx_file);
|
||||
if (t4_tx_start_page(&t4_state))
|
||||
{
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "Failed to start T.4 send\n");
|
||||
printf("Test failed\n");
|
||||
exit(2);
|
||||
}
|
||||
len = t4_tx_get_chunk(&t4_state, image, sizeof(image));
|
||||
@@ -1003,6 +1009,7 @@ printf("Push '%s'\n", next_tx_file);
|
||||
if (t4_tx_init(&t4_state, path, -1, -1) == NULL)
|
||||
{
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "Failed to init T.4 send\n");
|
||||
printf("Test failed\n");
|
||||
exit(2);
|
||||
}
|
||||
t4_tx_set_min_row_bits(&t4_state, min_row_bits);
|
||||
@@ -1019,6 +1026,7 @@ printf("Push '%s'\n", next_tx_file);
|
||||
if (t4_tx_start_page(&t4_state))
|
||||
{
|
||||
span_log(&s->logging, SPAN_LOG_FLOW, "Failed to start T.4 send\n");
|
||||
printf("Test failed\n");
|
||||
exit(2);
|
||||
}
|
||||
/*endif*/
|
||||
@@ -1060,9 +1068,10 @@ static void exchange(faxtester_state_t *s)
|
||||
|
||||
if (log_audio)
|
||||
{
|
||||
if ((out_handle = afOpenFile_telephony_write(OUTPUT_FILE_NAME_WAVE, 2)) == AF_NULL_FILEHANDLE)
|
||||
if ((out_handle = sf_open_telephony_write(OUTPUT_FILE_NAME_WAVE, 2)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
printf("Test failed\n");
|
||||
exit(2);
|
||||
}
|
||||
/*endif*/
|
||||
@@ -1118,7 +1127,7 @@ static void exchange(faxtester_state_t *s)
|
||||
for (i = 0; i < len; i++)
|
||||
out_amp[2*i + 1] = amp[i];
|
||||
/*endfor*/
|
||||
if (afWriteFrames(out_handle, AF_DEFAULT_TRACK, out_amp, SAMPLES_PER_CHUNK) != SAMPLES_PER_CHUNK)
|
||||
if (sf_writef_short(out_handle, out_amp, SAMPLES_PER_CHUNK) != SAMPLES_PER_CHUNK)
|
||||
break;
|
||||
/*endif*/
|
||||
}
|
||||
@@ -1127,9 +1136,10 @@ static void exchange(faxtester_state_t *s)
|
||||
/*endfor*/
|
||||
if (log_audio)
|
||||
{
|
||||
if (afCloseFile(out_handle))
|
||||
if (sf_close(out_handle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME_WAVE);
|
||||
printf("Test failed\n");
|
||||
exit(2);
|
||||
}
|
||||
/*endif*/
|
||||
@@ -1209,6 +1219,7 @@ static int get_test_set(faxtester_state_t *s, const char *test_file, const char
|
||||
if ((doc = xmlParseFile(test_file)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "No document\n");
|
||||
printf("Test failed\n");
|
||||
exit(2);
|
||||
}
|
||||
/*endif*/
|
||||
@@ -1216,6 +1227,7 @@ static int get_test_set(faxtester_state_t *s, const char *test_file, const char
|
||||
if (!xmlValidateDocument(&valid, doc))
|
||||
{
|
||||
fprintf(stderr, "Invalid document\n");
|
||||
printf("Test failed\n");
|
||||
exit(2);
|
||||
}
|
||||
/*endif*/
|
||||
@@ -1223,15 +1235,17 @@ static int get_test_set(faxtester_state_t *s, const char *test_file, const char
|
||||
/* Check the document is of the right kind */
|
||||
if ((cur = xmlDocGetRootElement(doc)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Empty document\n");
|
||||
xmlFreeDoc(doc);
|
||||
fprintf(stderr, "Empty document\n");
|
||||
printf("Test failed\n");
|
||||
exit(2);
|
||||
}
|
||||
/*endif*/
|
||||
if (xmlStrcmp(cur->name, (const xmlChar *) "fax-tests"))
|
||||
{
|
||||
fprintf(stderr, "Document of the wrong type, root node != fax-tests");
|
||||
xmlFreeDoc(doc);
|
||||
fprintf(stderr, "Document of the wrong type, root node != fax-tests");
|
||||
printf("Test failed\n");
|
||||
exit(2);
|
||||
}
|
||||
/*endif*/
|
||||
@@ -1240,7 +1254,10 @@ static int get_test_set(faxtester_state_t *s, const char *test_file, const char
|
||||
cur = cur->next;
|
||||
/*endwhile*/
|
||||
if (cur == NULL)
|
||||
{
|
||||
printf("Test failed\n");
|
||||
exit(2);
|
||||
}
|
||||
/*endif*/
|
||||
while (cur)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#
|
||||
# $Id: tsb85_tests.sh,v 1.7 2009/04/30 15:04:20 steveu Exp $
|
||||
# $Id: tsb85_tests.sh,v 1.8 2009/05/24 07:18:36 steveu Exp $
|
||||
#
|
||||
|
||||
run_tsb85_test()
|
||||
@@ -35,14 +35,13 @@ for TEST in MRGN01 MRGN02 MRGN03 MRGN04 MRGN05 MRGN06a MRGN06b MRGN07 MRGN08 ; d
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
#MRGN14 fails because ???
|
||||
#MRGN14 fails because we don't adequately distinguish between receiving a
|
||||
#bad image signal and receiving none at all.
|
||||
#MRGN16 fails because we don't adequately distinguish between receiving a
|
||||
#bad image signal and receiving none at all.
|
||||
#MRGN17 fails because we don't adequately distinguish between receiving a
|
||||
#bad HDLC message and receiving none at all.
|
||||
|
||||
#for TEST in MRGN09 MRGN10 MRGN11 MRGN12 MRGN13 MRGN14 MRGN15 MRGN16 MRGN17 ; do
|
||||
for TEST in MRGN09 MRGN10 MRGN11 MRGN12 MRGN13 MRGN15 ; do
|
||||
for TEST in MRGN09 MRGN10 MRGN11 MRGN12 MRGN13 MRGN15 MRGN17 ; do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
@@ -54,7 +53,7 @@ for TEST in OREN01 OREN02 OREN03 OREN04 OREN05 OREN06 OREN07 OREN08 OREN09 OREN1
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
# MRGX03 is failing because the V.27ter modemsays it trained on HDLC
|
||||
# MRGX03 is failing because the V.27ter modem says it trained on HDLC
|
||||
# MRGX05 is failing because we don't distinguish MPS immediately after MCF from MPS after
|
||||
# a corrupt image signal.
|
||||
|
||||
@@ -95,6 +94,8 @@ for TEST in OTGC10 OTGC11 ; do
|
||||
run_tsb85_test
|
||||
done
|
||||
|
||||
#OTEN02 fails because ?????
|
||||
|
||||
#for TEST in OTEN01 OTEN02 OTEN03 OTEN04 OTEN05 OTEN06 ; do
|
||||
for TEST in OTEN01 OTEN03 OTEN04 OTEN05 OTEN06 ; do
|
||||
run_tsb85_test
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Id: v17_tests.c,v 1.102 2009/04/25 16:30:52 steveu Exp $
|
||||
* $Id: v17_tests.c,v 1.103 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page v17_tests_page V.17 modem tests
|
||||
@@ -36,7 +36,7 @@ These tests test one way paths, as V.17 is a half-duplex modem. They allow eithe
|
||||
receive modem. It is also the only test mode provided for evaluating the
|
||||
transmit modem.
|
||||
|
||||
- A V.17 receive modem is used to decode V.17 audio, stored in a wave file.
|
||||
- A V.17 receive modem is used to decode V.17 audio, stored in a audio file.
|
||||
This is good way to evaluate performance with audio recorded from other
|
||||
models of modem, and with real world problematic telephone lines.
|
||||
|
||||
@@ -62,7 +62,7 @@ display of modem status is maintained.
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -226,8 +226,8 @@ int main(int argc, char *argv[])
|
||||
bert_results_t bert_results;
|
||||
int16_t gen_amp[BLOCK_LEN];
|
||||
int16_t amp[BLOCK_LEN];
|
||||
AFfilehandle inhandle;
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *outhandle;
|
||||
int outframes;
|
||||
int samples;
|
||||
int tep;
|
||||
@@ -311,20 +311,20 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (log_audio)
|
||||
{
|
||||
if ((outhandle = afOpenFile_telephony_write(OUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
if (decode_test_file)
|
||||
{
|
||||
/* We will decode the audio from a wave file. */
|
||||
/* We will decode the audio from a file. */
|
||||
tx = NULL;
|
||||
if ((inhandle = afOpenFile_telephony_read(decode_test_file, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", decode_test_file);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -381,10 +381,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (decode_test_file)
|
||||
{
|
||||
samples = afReadFrames(inhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
BLOCK_LEN);
|
||||
samples = sf_readf_short(inhandle, amp, BLOCK_LEN);
|
||||
#if defined(ENABLE_GUI)
|
||||
if (use_gui)
|
||||
qam_monitor_update_audio_level(qam_monitor, amp, samples);
|
||||
@@ -445,13 +442,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
gen_amp,
|
||||
samples);
|
||||
outframes = sf_writef_short(outhandle, gen_amp, samples);
|
||||
if (outframes != samples)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -485,17 +479,17 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
if (decode_test_file)
|
||||
{
|
||||
if (afCloseFile(inhandle))
|
||||
if (sf_close(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", decode_test_file);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
if (afCloseFile(outhandle))
|
||||
if (sf_close(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: v18_tests.c,v 1.5 2009/04/11 18:11:19 steveu Exp $
|
||||
* $Id: v18_tests.c,v 1.8 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page v18_tests_page V.18 tests
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -58,19 +58,32 @@
|
||||
#define SAMPLES_PER_CHUNK 160
|
||||
|
||||
int log_audio = FALSE;
|
||||
AFfilehandle outhandle = NULL;
|
||||
SNDFILE *outhandle = NULL;
|
||||
|
||||
char *decode_test_file = NULL;
|
||||
|
||||
int good_message_received;
|
||||
|
||||
const char *qbf_tx = "The quick Brown Fox Jumps Over The Lazy dog 0123456789!@#$%^&*()'";
|
||||
const char *qbf_rx = "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG 0123456789!X$$/'+.()'";
|
||||
const char *full_baudot_rx =
|
||||
"\b \n\n\n\r?\n\n\n !\"$$/+'().+,-./"
|
||||
"0123456789:;(=)?"
|
||||
"XABCDEFGHIJKLMNOPQRSTUVWXYZ(/)' "
|
||||
"'ABCDEFGHIJKLMNOPQRSTUVWXYZ(!) ";
|
||||
|
||||
#if 1
|
||||
static void put_text_msg(void *user_data, const uint8_t *msg, int len)
|
||||
{
|
||||
if (strcmp((const char *) msg, "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG 0123456789#$*()"))
|
||||
printf("%s\n", msg);
|
||||
if (strcmp((const char *) msg, qbf_rx))
|
||||
{
|
||||
printf("Result:\n%s\n", msg);
|
||||
printf("Reference result:\n%s\n", qbf_rx);
|
||||
}
|
||||
else
|
||||
{
|
||||
good_message_received = TRUE;
|
||||
}
|
||||
}
|
||||
/*- End of function --------------------------------------------------------*/
|
||||
|
||||
@@ -91,7 +104,11 @@ static void basic_tests(int mode)
|
||||
/* Fake an OK condition for the first message test */
|
||||
good_message_received = TRUE;
|
||||
push = 0;
|
||||
v18_put(v18_a, "The quick Brown Fox Jumps Over The Lazy dog 0123456789!@#$%^&*()", -1);
|
||||
if (v18_put(v18_a, qbf_tx, -1) != strlen(qbf_tx))
|
||||
{
|
||||
printf("V.18 put failed\n");
|
||||
exit(2);
|
||||
}
|
||||
for (i = 0; i < 100000; i++)
|
||||
{
|
||||
if (push == 0)
|
||||
@@ -111,7 +128,11 @@ static void basic_tests(int mode)
|
||||
exit(2);
|
||||
}
|
||||
good_message_received = FALSE;
|
||||
v18_put(v18_a, "The quick Brown Fox Jumps Over The Lazy dog 0123456789!@#$%^&*()", -1);
|
||||
if (v18_put(v18_a, qbf_tx, -1) != strlen(qbf_tx))
|
||||
{
|
||||
printf("V.18 put failed\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (len < SAMPLES_PER_CHUNK)
|
||||
@@ -121,13 +142,10 @@ static void basic_tests(int mode)
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
len);
|
||||
outframes = sf_writef_short(outhandle, amp, len);
|
||||
if (outframes != len)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -165,39 +183,42 @@ static int test_x_03(void)
|
||||
|
||||
static int test_x_04(void)
|
||||
{
|
||||
const char *s;
|
||||
const char *ref;
|
||||
char result[1024];
|
||||
char *t;
|
||||
int ch;
|
||||
int xx;
|
||||
int yy;
|
||||
int i;
|
||||
v18_state_t *v18_state;
|
||||
|
||||
/* III.5.4.5.4 5 Bit to T.50 character conversion */
|
||||
v18_state = v18_init(NULL, TRUE, V18_MODE_5BIT_45, NULL, NULL);
|
||||
s = "The quick Brown Fox Jumps Over The Lazy dog 0123456789!@#$%^&*()";
|
||||
printf("Original:\n%s\n", s);
|
||||
printf("Original:\n");
|
||||
t = result;
|
||||
while ((ch = *s++))
|
||||
for (i = 0; i < 127; i++)
|
||||
{
|
||||
ch = i;
|
||||
printf("%c", ch);
|
||||
xx = v18_encode_baudot(v18_state, ch);
|
||||
if ((xx & 0x3E0))
|
||||
if (xx)
|
||||
{
|
||||
yy = v18_decode_baudot(v18_state, (xx >> 5) & 0x1F);
|
||||
if ((xx & 0x3E0))
|
||||
{
|
||||
yy = v18_decode_baudot(v18_state, (xx >> 5) & 0x1F);
|
||||
if (yy)
|
||||
*t++ = yy;
|
||||
}
|
||||
yy = v18_decode_baudot(v18_state, xx & 0x1F);
|
||||
if (yy)
|
||||
*t++ = yy;
|
||||
}
|
||||
yy = v18_decode_baudot(v18_state, xx & 0x1F);
|
||||
if (yy)
|
||||
*t++ = yy;
|
||||
}
|
||||
printf("\n");
|
||||
*t = '\0';
|
||||
v18_free(v18_state);
|
||||
ref = "THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG 0123456789#$*()";
|
||||
printf("Result:\n%s\n", result);
|
||||
printf("Reference result:\n%s\n", ref);
|
||||
if (strcmp(result, ref) != 0)
|
||||
printf("Reference result:\n%s\n", full_baudot_rx);
|
||||
if (strcmp(result, full_baudot_rx) != 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
@@ -256,30 +277,27 @@ static int decode_test_data_file(int mode, const char *filename)
|
||||
{
|
||||
v18_state_t *v18_state;
|
||||
int16_t amp[SAMPLES_PER_CHUNK];
|
||||
AFfilehandle inhandle;
|
||||
SNDFILE *inhandle;
|
||||
int len;
|
||||
|
||||
printf("Decoding as '%s'\n", v18_mode_to_str(mode));
|
||||
/* We will decode the audio from a wave file. */
|
||||
if ((inhandle = afOpenFile_telephony_read(decode_test_file, 1)) == AF_NULL_FILEHANDLE)
|
||||
/* We will decode the audio from a file. */
|
||||
if ((inhandle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", decode_test_file);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
v18_state = v18_init(NULL, FALSE, mode, put_v18_msg, NULL);
|
||||
for (;;)
|
||||
{
|
||||
len = afReadFrames(inhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
SAMPLES_PER_CHUNK);
|
||||
len = sf_readf_short(inhandle, amp, SAMPLES_PER_CHUNK);
|
||||
if (len == 0)
|
||||
break;
|
||||
v18_rx(v18_state, amp, len);
|
||||
}
|
||||
if (afCloseFile(inhandle) != 0)
|
||||
if (sf_close(inhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", decode_test_file);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
v18_free(v18_state);
|
||||
@@ -429,12 +447,12 @@ int main(int argc, char *argv[])
|
||||
if (argc > 0)
|
||||
match = argv[0];
|
||||
|
||||
outhandle = AF_NULL_FILEHANDLE;
|
||||
outhandle = NULL;
|
||||
if (log_audio)
|
||||
{
|
||||
if ((outhandle = afOpenFile_telephony_write(OUTPUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -477,9 +495,9 @@ int main(int argc, char *argv[])
|
||||
basic_tests(V18_MODE_5BIT_45);
|
||||
if (log_audio)
|
||||
{
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: v22bis_tests.c,v 1.61 2009/04/25 16:30:52 steveu Exp $
|
||||
* $Id: v22bis_tests.c,v 1.62 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page v22bis_tests_page V.22bis modem tests
|
||||
@@ -50,7 +50,7 @@ display of modem status is maintained.
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
#include "spandsp.h"
|
||||
@@ -210,8 +210,8 @@ int main(int argc, char *argv[])
|
||||
int16_t amp[2][BLOCK_LEN];
|
||||
int16_t model_amp[2][BLOCK_LEN];
|
||||
int16_t out_amp[2*BLOCK_LEN];
|
||||
AFfilehandle inhandle;
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *outhandle;
|
||||
int outframes;
|
||||
int samples;
|
||||
int samples2;
|
||||
@@ -281,23 +281,23 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
}
|
||||
inhandle = AF_NULL_FILEHANDLE;
|
||||
inhandle = NULL;
|
||||
if (decode_test_file)
|
||||
{
|
||||
/* We will decode the audio from a wave file. */
|
||||
if ((inhandle = afOpenFile_telephony_read(decode_test_file, 1)) == AF_NULL_FILEHANDLE)
|
||||
/* We will decode the audio from a file. */
|
||||
if ((inhandle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", decode_test_file);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
outhandle = AF_NULL_FILEHANDLE;
|
||||
outhandle = NULL;
|
||||
if (log_audio)
|
||||
{
|
||||
if ((outhandle = afOpenFile_telephony_write(OUT_FILE_NAME, 2)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 2)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -369,10 +369,7 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
if (decode_test_file)
|
||||
{
|
||||
samples2 = afReadFrames(inhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
model_amp[0],
|
||||
samples);
|
||||
samples2 = sf_readf_short(inhandle, model_amp[0], samples);
|
||||
if (samples2 != samples)
|
||||
break;
|
||||
}
|
||||
@@ -388,13 +385,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (log_audio)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
out_amp,
|
||||
BLOCK_LEN);
|
||||
outframes = sf_writef_short(outhandle, out_amp, BLOCK_LEN);
|
||||
if (outframes != BLOCK_LEN)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -405,17 +399,17 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
if (decode_test_file)
|
||||
{
|
||||
if (afCloseFile(inhandle))
|
||||
if (sf_close(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", decode_test_file);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
if (afCloseFile(outhandle) != 0)
|
||||
if (sf_close(outhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: v27ter_tests.c,v 1.104 2009/04/25 16:30:52 steveu Exp $
|
||||
* $Id: v27ter_tests.c,v 1.105 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page v27ter_tests_page V.27ter modem tests
|
||||
@@ -35,7 +35,7 @@ These tests test one way paths, as V.27ter is a half-duplex modem. They allow ei
|
||||
receive modem. It is also the only test mode provided for evaluating the
|
||||
transmit modem.
|
||||
|
||||
- A V.27ter receive modem is used to decode V.27ter audio, stored in a wave file.
|
||||
- A V.27ter receive modem is used to decode V.27ter audio, stored in an audio file.
|
||||
This is good way to evaluate performance with audio recorded from other
|
||||
models of modem, and with real world problematic telephone lines.
|
||||
|
||||
@@ -61,7 +61,7 @@ display of modem status is maintained.
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -225,8 +225,8 @@ int main(int argc, char *argv[])
|
||||
bert_results_t bert_results;
|
||||
int16_t gen_amp[BLOCK_LEN];
|
||||
int16_t amp[BLOCK_LEN];
|
||||
AFfilehandle inhandle;
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *outhandle;
|
||||
int outframes;
|
||||
int samples;
|
||||
int tep;
|
||||
@@ -311,20 +311,20 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (log_audio)
|
||||
{
|
||||
if ((outhandle = afOpenFile_telephony_write(OUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
if (decode_test_file)
|
||||
{
|
||||
/* We will decode the audio from a wave file. */
|
||||
/* We will decode the audio from a file. */
|
||||
tx = NULL;
|
||||
if ((inhandle = afOpenFile_telephony_read(decode_test_file, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", decode_test_file);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -372,10 +372,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (decode_test_file)
|
||||
{
|
||||
samples = afReadFrames(inhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
BLOCK_LEN);
|
||||
samples = sf_readf_short(inhandle, amp, BLOCK_LEN);
|
||||
#if defined(ENABLE_GUI)
|
||||
if (use_gui)
|
||||
qam_monitor_update_audio_level(qam_monitor, amp, samples);
|
||||
@@ -434,13 +431,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (log_audio)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
gen_amp,
|
||||
samples);
|
||||
outframes = sf_writef_short(outhandle, gen_amp, samples);
|
||||
if (outframes != samples)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -473,17 +467,17 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
if (decode_test_file)
|
||||
{
|
||||
if (afCloseFile(inhandle))
|
||||
if (sf_close(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", decode_test_file);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
if (afCloseFile(outhandle))
|
||||
if (sf_close(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: v29_tests.c,v 1.118 2009/04/25 16:30:52 steveu Exp $
|
||||
* $Id: v29_tests.c,v 1.119 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page v29_tests_page V.29 modem tests
|
||||
@@ -35,7 +35,7 @@ These tests test one way paths, as V.29 is a half-duplex modem. They allow eithe
|
||||
receive modem. It is also the only test mode provided for evaluating the
|
||||
transmit modem.
|
||||
|
||||
- A V.29 receive modem is used to decode V.29 audio, stored in a wave file.
|
||||
- A V.29 receive modem is used to decode V.29 audio, stored in an audio file.
|
||||
This is good way to evaluate performance with audio recorded from other
|
||||
models of modem, and with real world problematic telephone lines.
|
||||
|
||||
@@ -61,7 +61,7 @@ display of modem status is maintained.
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -248,8 +248,8 @@ int main(int argc, char *argv[])
|
||||
bert_results_t bert_results;
|
||||
int16_t gen_amp[BLOCK_LEN];
|
||||
int16_t amp[BLOCK_LEN];
|
||||
AFfilehandle inhandle;
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *outhandle;
|
||||
int outframes;
|
||||
int samples;
|
||||
int tep;
|
||||
@@ -334,20 +334,20 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (log_audio)
|
||||
{
|
||||
if ((outhandle = afOpenFile_telephony_write(OUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUT_FILE_NAME, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
if (decode_test_file)
|
||||
{
|
||||
/* We will decode the audio from a wave file. */
|
||||
/* We will decode the audio from a file. */
|
||||
tx = NULL;
|
||||
if ((inhandle = afOpenFile_telephony_read(decode_test_file, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open wave file '%s'\n", decode_test_file);
|
||||
fprintf(stderr, " Cannot open audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -402,10 +402,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
if (decode_test_file)
|
||||
{
|
||||
samples = afReadFrames(inhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
amp,
|
||||
BLOCK_LEN);
|
||||
samples = sf_readf_short(inhandle, amp, BLOCK_LEN);
|
||||
#if defined(ENABLE_GUI)
|
||||
if (use_gui)
|
||||
qam_monitor_update_audio_level(qam_monitor, amp, samples);
|
||||
@@ -462,13 +459,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
gen_amp,
|
||||
samples);
|
||||
outframes = sf_writef_short(outhandle, gen_amp, samples);
|
||||
if (outframes != samples)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
@@ -502,17 +496,17 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
if (decode_test_file)
|
||||
{
|
||||
if (afCloseFile(inhandle))
|
||||
if (sf_close(inhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", decode_test_file);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if (log_audio)
|
||||
{
|
||||
if (afCloseFile(outhandle))
|
||||
if (sf_close(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: v8_tests.c,v 1.32 2009/04/24 22:35:25 steveu Exp $
|
||||
* $Id: v8_tests.c,v 1.33 2009/05/30 15:23:14 steveu Exp $
|
||||
*/
|
||||
|
||||
/*! \page v8_tests_page V.8 tests
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <audiofile.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
//#if defined(WITH_SPANDSP_INTERNALS)
|
||||
#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES
|
||||
@@ -98,8 +98,8 @@ int main(int argc, char *argv[])
|
||||
int remnant;
|
||||
int caller_available_modulations;
|
||||
int answerer_available_modulations;
|
||||
AFfilehandle inhandle;
|
||||
AFfilehandle outhandle;
|
||||
SNDFILE *inhandle;
|
||||
SNDFILE *outhandle;
|
||||
int opt;
|
||||
char *decode_test_file;
|
||||
logging_state_t *logging;
|
||||
@@ -150,9 +150,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (decode_test_file == NULL)
|
||||
{
|
||||
if ((outhandle = afOpenFile_telephony_write(OUTPUT_FILE_NAME, 2)) == AF_NULL_FILEHANDLE)
|
||||
if ((outhandle = sf_open_telephony_write(OUTPUT_FILE_NAME, 2)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot create wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot create audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@@ -187,19 +187,16 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < samples; i++)
|
||||
out_amp[2*i + 1] = amp[i];
|
||||
|
||||
outframes = afWriteFrames(outhandle,
|
||||
AF_DEFAULT_TRACK,
|
||||
out_amp,
|
||||
samples);
|
||||
outframes = sf_writef_short(outhandle, out_amp, samples);
|
||||
if (outframes != samples)
|
||||
{
|
||||
fprintf(stderr, " Error writing wave file\n");
|
||||
fprintf(stderr, " Error writing audio file\n");
|
||||
exit(2);
|
||||
}
|
||||
}
|
||||
if (afCloseFile(outhandle))
|
||||
if (sf_close(outhandle))
|
||||
{
|
||||
fprintf(stderr, " Cannot close wave file '%s'\n", OUTPUT_FILE_NAME);
|
||||
fprintf(stderr, " Cannot close audio file '%s'\n", OUTPUT_FILE_NAME);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@@ -220,21 +217,21 @@ int main(int argc, char *argv[])
|
||||
logging = v8_get_logging_state(v8_answerer);
|
||||
span_log_set_level(logging, SPAN_LOG_FLOW | SPAN_LOG_SHOW_TAG);
|
||||
span_log_set_tag(logging, "decoder");
|
||||
if ((inhandle = afOpenFile_telephony_read(decode_test_file, 1)) == AF_NULL_FILEHANDLE)
|
||||
if ((inhandle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
|
||||
{
|
||||
fprintf(stderr, " Cannot open speech file '%s'\n", decode_test_file);
|
||||
exit (2);
|
||||
}
|
||||
/*endif*/
|
||||
|
||||
while ((samples = afReadFrames(inhandle, AF_DEFAULT_TRACK, amp, SAMPLES_PER_CHUNK)))
|
||||
while ((samples = sf_readf_short(inhandle, amp, SAMPLES_PER_CHUNK)))
|
||||
{
|
||||
remnant = v8_rx(v8_answerer, amp, samples);
|
||||
}
|
||||
/*endwhile*/
|
||||
|
||||
v8_free(v8_answerer);
|
||||
if (afCloseFile(inhandle) != 0)
|
||||
if (sf_close(inhandle) != 0)
|
||||
{
|
||||
fprintf(stderr, " Cannot close speech file '%s'\n", decode_test_file);
|
||||
exit(2);
|
||||
|
||||
Reference in New Issue
Block a user