Merge branch 'master' into smgmaster

This commit is contained in:
Moises Silva committed 2010-10-04 22:08:19 -04:00
commit 5f7ab903bb
307 files changed
+16815 -2494

No files matched your search

+1 -1
View File
@@ -1 +1 @@
Thu Nov 19 09:24:37 EST 2009
Mon Sep 27 13:15:54 CDT 2010
+12 -1
View File
@@ -824,7 +824,13 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *),
* Modifier check. Note that if APR_INT64_T_FMT is "d",
* the first if condition is never true.
*/
if ((sizeof(APR_INT64_T_FMT) == 4 &&
/* HACK BY FREESWITCH TEAM TO FIX COMPATIBILITY 2010-09-27 */
if (*fmt == 'l' && *(fmt + 1) == 'l') {
var_type = IS_QUAD;
fmt += 2;
}
else if ((sizeof(APR_INT64_T_FMT) == 4 &&
fmt[0] == APR_INT64_T_FMT[0] &&
fmt[1] == APR_INT64_T_FMT[1]) ||
(sizeof(APR_INT64_T_FMT) == 3 &&
@@ -843,6 +849,11 @@ APR_DECLARE(int) apr_vformatter(int (*flush_func)(apr_vformatter_buff_t *),
else if (*fmt == 'l') {
var_type = IS_LONG;
fmt++;
/* HACK BY FREESWITCH TEAM TO FIX COMPATIBILITY 2010-09-27 */
if (*fmt == 'l') {
var_type = IS_QUAD;
fmt++;
}
}
else if (*fmt == 'h') {
var_type = IS_SHORT;
+1 -1
View File
@@ -207,7 +207,7 @@ AC_CHECK_HEADERS([sndfile.h])
AC_LANG([C])
if test "${build}" == "${host}"
if test "${build}" = "${host}"
then
case "${host}" in
x86_64-*)
+3
View File
@@ -36,7 +36,10 @@
#define closesocket(x) close(x)
#include <fcntl.h>
#else
#pragma warning (disable:6386)
/* These warnings need to be ignored warning in sdk header */
#include <Ws2tcpip.h>
#pragma warning (default:6386)
#endif
+1 -1
View File
@@ -110,7 +110,7 @@ ESL_DECLARE(int) esl_config_next_pair(esl_config_t *cfg, char **var, char **val)
*var = *val = NULL;
if (!cfg->path) {
if (!cfg || !cfg->file) {
return 0;
}
+3
View File
@@ -513,6 +513,9 @@ ESL_DECLARE(esl_status_t) esl_event_serialize(esl_event_t *event, char **str, es
char *encode_buf = NULL; /* used for url encoding of variables to make sure unsafe things stay out of the serialized copy */
int clen = 0;
if (!event || !event->headers)
return ESL_FAIL;
*str = NULL;
dlen = blocksize * 2;
+1 -1
View File
@@ -312,7 +312,7 @@ ftmod_r2_la_LIBADD = $(MYLIB)
endif
dox doxygen:
cd docs && doxygen $(FT_SRCDIR)/docs/Doxygen.conf
doxygen $(FT_SRCDIR)/docs/Doxygen.conf
mod_freetdm/mod_freetdm.$(DYNAMIC_LIB_EXTEN): $(MYLIB) mod_freetdm/mod_freetdm.c
cd mod_freetdm && make
+2 -2
View File
@@ -1,3 +1,3 @@
FREETDM (WORK IN PROGRESS)
FreeTDM
http://wiki.freeswitch.org/wiki/FreeTDM
*shrug*
+64
View File
@@ -0,0 +1,64 @@
#!/bin/bash
INSTALLPREFIX="/usr/local/freetdm"
VERSION=""
NODOCS="NO"
for i in $*
do
case $i in
--version=*)
VERSION=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
;;
--prefix=*)
INSTALLPREFIX=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
;;
--nodocs)
NODOCS="YES"
;;
*)
# unknown option
echo "Unknown option $i"
exit
;;
esac
done
if [ "x$VERSION" = "x" ]
then
echo "Provide a version number with --version=<version>"
exit 1
fi
if [ ! -d $INSTALLPREFIX ]
then
mkdir -p $INSTALLPREFIX || exit 1
fi
make clean
make mod_freetdm-clean
if [ $NODOCS = "NO" ]
then
make dox || exit 1
fi
major=$(echo "$VERSION" | cut -d. -f1)
minor=$(echo "$VERSION" | cut -d. -f2)
micro=$(echo "$VERSION" | cut -d. -f3)
release="freetdm-$VERSION"
echo "Creating $release ($major.$minor.$micro) at $INSTALLPREFIX/$release (directory will be removed if exists already) ... press any key to continue"
read
mkdir -p $INSTALLPREFIX/$release
cp -r ./* $INSTALLPREFIX/$release
find $INSTALLPREFIX/ -name .libs -exec rm -rf {} \;
find $INSTALLPREFIX/ -name .deps -exec rm -rf {} \;
find $INSTALLPREFIX/ -name *.so -exec rm -rf {} \;
find $INSTALLPREFIX/ -name *.lo -exec rm -rf {} \;
tar -C $INSTALLPREFIX -czf $INSTALLPREFIX/$release.tar.gz $release/
+39 -22
View File
@@ -1284,6 +1284,7 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_set_state(const char *file, const char *f
case FTDM_CHANNEL_STATE_RING:
case FTDM_CHANNEL_STATE_PROGRESS_MEDIA:
case FTDM_CHANNEL_STATE_PROGRESS:
case FTDM_CHANNEL_STATE_IDLE:
case FTDM_CHANNEL_STATE_GET_CALLERID:
case FTDM_CHANNEL_STATE_GENRING:
ok = 1;
@@ -1792,7 +1793,6 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_open(uint32_t span_id, uint32_t chan_id,
ftdm_channel_t *best_rated = NULL;
ftdm_status_t status = FTDM_FAIL;
int best_rate = 0;
int may_be_available = 0;
*ftdmchan = NULL;
@@ -1827,38 +1827,55 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_open(uint32_t span_id, uint32_t chan_id,
ftdm_mutex_lock(check->mutex);
/* The following if's and gotos replace a big if (this || this || this || this) else { nothing; } */
/* if it is not a voice channel, nothing else to check to open it */
if (!FTDM_IS_VOICE_CHANNEL(check)) {
goto openchan;
}
/* if it's an FXS device with a call active and has callwaiting enabled, we allow to open it twice */
if (check->type == FTDM_CHAN_TYPE_FXS
&& check->token_count == 1
&& ftdm_channel_test_feature(check, FTDM_CHANNEL_FEATURE_CALLWAITING)) {
goto openchan;
}
/* if channel is available, time to open it */
if (chan_is_avail(check)) {
goto openchan;
}
/* not available, but still might be available ... */
calculate_best_rate(check, &best_rated, &best_rate);
if (best_rated) {
may_be_available = 1;
goto openchan;
}
/* the channel is only allowed to be open if not in use, or, for FXS devices with a call with call waiting enabled */
if (
(check->type == FTDM_CHAN_TYPE_FXS
&& check->token_count == 1
&& ftdm_channel_test_feature(check, FTDM_CHANNEL_FEATURE_CALLWAITING))
||
chan_is_avail(check)
||
may_be_available) {
if (!ftdm_test_flag(check, FTDM_CHANNEL_OPEN)) {
status = check->fio->open(check);
if (status == FTDM_SUCCESS) {
ftdm_set_flag(check, FTDM_CHANNEL_OPEN);
}
} else {
status = FTDM_SUCCESS;
/* channel is unavailable, do not open the channel */
goto unlockchan;
openchan:
if (!ftdm_test_flag(check, FTDM_CHANNEL_OPEN)) {
status = check->fio->open(check);
if (status == FTDM_SUCCESS) {
ftdm_set_flag(check, FTDM_CHANNEL_OPEN);
}
ftdm_set_flag(check, FTDM_CHANNEL_INUSE);
ftdm_set_flag(check, FTDM_CHANNEL_OUTBOUND);
*ftdmchan = check;
} else {
status = FTDM_SUCCESS;
}
ftdm_set_flag(check, FTDM_CHANNEL_INUSE);
ftdm_set_flag(check, FTDM_CHANNEL_OUTBOUND);
*ftdmchan = check;
unlockchan:
ftdm_mutex_unlock(check->mutex);
done:
ftdm_mutex_unlock(globals.mutex);
if (status != FTDM_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "Failed to open channel %d:%d\n", span_id, chan_id);
}
return status;
}
+1 -1
View File
@@ -388,7 +388,7 @@ done:
UNREFERENCED_PARAMETER(ms);
UNREFERENCED_PARAMETER(callback);
UNREFERENCED_PARAMETER(data);
UNREFERENCED_PARAMETER(timer);
UNREFERENCED_PARAMETER(timerid);
#endif
return status;
}
@@ -1087,10 +1087,17 @@ static void *ftdm_libpri_run(ftdm_thread_t *me, void *obj)
got_d = 1;
x++;
break;
} else {
ftdm_log(FTDM_LOG_ERROR, "failed to open d-channel #%d %d:%d\n", x, span->channels[i]->span_id, span->channels[i]->chan_id);
}
}
}
}
if (!got_d) {
ftdm_log(FTDM_LOG_ERROR, "Failed to get a D-channel in span %d\n", span->span_id);
break;
}
if (lpwrap_init_pri(&isdn_data->spri,
@@ -1133,7 +1140,9 @@ static void *ftdm_libpri_run(ftdm_thread_t *me, void *obj)
}
ftdm_log(FTDM_LOG_CRIT, "PRI down on span %d\n", isdn_data->spri.span->span_id);
isdn_data->spri.dchan->state = FTDM_CHANNEL_STATE_DOWN;
if (isdn_data->spri.dchan) {
isdn_data->spri.dchan->state = FTDM_CHANNEL_STATE_DOWN;
}
if (!down) {
ftdm_set_state_all(span, FTDM_CHANNEL_STATE_RESTART);
@@ -1147,7 +1156,7 @@ static void *ftdm_libpri_run(ftdm_thread_t *me, void *obj)
ftdm_sleep(5000);
}
ftdm_log(FTDM_LOG_DEBUG, "PRI thread ended on span %d\n", isdn_data->spri.span->span_id);
ftdm_log(FTDM_LOG_DEBUG, "PRI thread ended on span %d\n", span->span_id);
ftdm_clear_flag(span, FTDM_SPAN_IN_THREAD);
ftdm_clear_flag(isdn_data, FTMOD_LIBPRI_RUNNING);
@@ -177,7 +177,7 @@ int lpwrap_init_pri(struct lpwrap_pri *spri, ftdm_span_t *span, ftdm_channel_t *
spri->dchan = dchan;
spri->span = span;
if ((spri->pri = pri_new_cb(spri->dchan->sockfd, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri))){
if (spri->dchan && (spri->pri = pri_new_cb(spri->dchan->sockfd, node, swtype, __pri_lpwrap_read, __pri_lpwrap_write, spri))){
unsigned char buf[4] = { 0 };
size_t buflen = sizeof(buf), len = 0;
pri_set_debug(spri->pri, debug);
@@ -1020,8 +1020,8 @@ int ftmod_ss7_mtp3_route_config(int id)
cfg.t.cfg.s.snRout.slsRange = LSN_ANSI_5BIT_SLS_RANGE; /* max value of SLS for this DPC */
}
cfg.t.cfg.s.snRout.lsetSel = 0x1; /* linkset selection bit in SLS for STP */
cfg.t.cfg.s.snRout.multiMsgPrior = FALSE; /* TRUE if multiple cong priorities of messages */
cfg.t.cfg.s.snRout.rctReq = TRUE; /* route set congestion test required or not */
cfg.t.cfg.s.snRout.multiMsgPrior = TRUE; /* TRUE if multiple cong priorities of messages */
cfg.t.cfg.s.snRout.rctReq = TRUE; /* route set congestion test required or not */
cfg.t.cfg.s.snRout.slsLnk = FALSE;
#ifdef LSNV2
# if (SS7_NTT || defined(TDS_ROLL_UPGRADE_SUPPORT))
@@ -240,9 +240,7 @@ ftdm_status_t ftdm_sngss7_handle_cli_cmd(ftdm_stream_handle_t *stream, const cha
/**********************************************************************/
} else if (!strcasecmp(argv[c], "mem")) {
/**********************************************************************/
/*uint32_t availMem;*/
/*sng_sta_mem(&availMem);*/
sng_isup_reg_info_show();
/**********************************************************************/
} else if (!strcasecmp(argv[c], "stats")) {
/**********************************************************************/
@@ -73,6 +73,7 @@ ftdm_status_t handle_local_ubl(uint32_t suInstId, uint32_t spInstId, uint32_t ci
ftdm_status_t handle_ucic(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
ftdm_status_t handle_cgb_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
ftdm_status_t handle_cgu_req(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
ftdm_status_t handle_olm_msg(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt);
/******************************************************************************/
/* FUNCTIONS ******************************************************************/
@@ -928,7 +929,7 @@ ftdm_status_t handle_sta_ind(uint32_t suInstId, uint32_t spInstId, uint32_t circ
/**************************************************************************/
case SIT_STA_OVERLOAD: /* Overload */
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx Overload\n", sngss7_info->circuit->cic);
SS7_WARN(" %s indication not currently supported\n", DECODE_LCC_EVENT(evntType));
handle_olm_msg(suInstId, spInstId, circuit, globalFlg, evntType, siStaEvnt);
break;
/**************************************************************************/
case SIT_STA_LMCGBREQ: /* when LM requests ckt grp blocking */
@@ -1685,8 +1686,10 @@ ftdm_status_t handle_ucic(uint32_t suInstId, uint32_t spInstId, uint32_t circuit
{
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
sngss7_chan_data_t *sngss7_info = NULL;
sngss7_span_data_t *sngss7_span = NULL;
ftdm_channel_t *ftdmchan = NULL;
/* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
@@ -1695,6 +1698,15 @@ ftdm_status_t handle_ucic(uint32_t suInstId, uint32_t spInstId, uint32_t circuit
return FTDM_FAIL;
}
/* check if we just sent a GRS request...*/
sngss7_span = ftdmchan->span->mod_data;
if (sngss7_span->tx_grs.circuit > 0) {
/* we need to put all circuits on this UCIC */
sngss7_span->ucic.circuit = sngss7_span->tx_grs.circuit;
sngss7_span->ucic.range = sngss7_span->tx_grs.range;
goto done;
}
/* lock the channel */
ftdm_mutex_lock(ftdmchan->mutex);
@@ -1706,7 +1718,7 @@ ftdm_status_t handle_ucic(uint32_t suInstId, uint32_t spInstId, uint32_t circuit
/* unlock the channel again before we exit */
ftdm_mutex_unlock(ftdmchan->mutex);
done:
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_SUCCESS;
}
@@ -1983,6 +1995,30 @@ ftdm_status_t handle_cgu_req(uint32_t suInstId, uint32_t spInstId, uint32_t circ
return FTDM_SUCCESS;
}
/******************************************************************************/
ftdm_status_t handle_olm_msg(uint32_t suInstId, uint32_t spInstId, uint32_t circuit, uint8_t globalFlg, uint8_t evntType, SiStaEvnt *siStaEvnt)
{
SS7_FUNC_TRACE_ENTER(__FUNCTION__);
sngss7_chan_data_t *sngss7_info = NULL;
ftdm_channel_t *ftdmchan = NULL;
/* get the ftdmchan and ss7_chan_data from the circuit */
if (extract_chan_data(circuit, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", circuit);
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_FAIL;
}
/* handle overload */
SS7_ERROR_CHAN(ftdmchan,"[CIC:%d]Rx Overload\n", sngss7_info->circuit->cic);
sng_isup_reg_info_show();
SS7_FUNC_TRACE_EXIT(__FUNCTION__);
return FTDM_SUCCESS;
}
/******************************************************************************/
/* For Emacs:
* Local Variables:
@@ -356,6 +356,12 @@ static void *ftdm_sangoma_ss7_run(ftdm_thread_t * me, void *obj)
check_if_rx_grs_processed(ftdmspan);
} /* if (sngss7_span->rx_grs.range > 0) */
/* check if there is a UCIC to be processed on the span */
if (sngss7_span->ucic.range > 0) {
/* process the span wide UCIC */
process_span_ucic(ftdmspan);
} /* if (sngss7_span->ucic.range > 0) */
/* check each channel on the span to see if there is an un-procressed SUS/RES flag */
check_for_res_sus_flag(ftdmspan);
} /* master while loop */
@@ -592,6 +598,8 @@ void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
} else {
/* inbound call so we need to send out ACM */
ft_to_sngss7_acm (ftdmchan);
ftdm_set_state_locked (ftdmchan, FTDM_CHANNEL_STATE_PROGRESS_MEDIA);
}
break;
@@ -763,9 +771,7 @@ void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
ft_to_sngss7_gra(ftdmchan);
/* clean out the spans GRS structure */
sngss7_span_data_t *span = ftdmchan->span->mod_data;
span->rx_grs.circuit = 0;
span->rx_grs.range = 0;
clear_rx_grs_data(sngss7_info);
}
/* clear the grp reset flag */
@@ -783,9 +789,7 @@ void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
clear_tx_grs_flags(sngss7_info);
/* clean out the spans GRA structure */
sngss7_span_data_t *span = ftdmchan->span->mod_data;
span->rx_gra.circuit = 0;
span->rx_gra.range = 0;
clear_rx_gra_data(sngss7_info);
} /* if (sngss7_test_flag(sngss7_info, FLAG_GRP_RESET_TX_RSP)) */
/* check if we came from reset (aka we just processed a reset) */
@@ -877,6 +881,11 @@ void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
/* set the unblk flag */
sngss7_set_flag(sngss7_info, FLAG_CKT_UCIC_UNBLK);
/* clear the block flag */
sngss7_clear_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);
/* process the flag */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
/* break out of the processing for now */
@@ -1112,7 +1121,9 @@ void ftdm_sangoma_ss7_process_state_change (ftdm_channel_t * ftdmchan)
/* remove any reset flags */
clear_rx_grs_flags(sngss7_info);
clear_rx_grs_data(sngss7_info);
clear_tx_grs_flags(sngss7_info);
clear_tx_grs_data(sngss7_info);
clear_rx_rsc_flags(sngss7_info);
clear_tx_rsc_flags(sngss7_info);
@@ -1321,7 +1332,7 @@ static ftdm_status_t ftdm_sangoma_ss7_start(ftdm_span_t * span)
sngss7_clear_flag(sngss7_info, FLAG_INFID_PAUSED);
sngss7_set_flag(sngss7_info, FLAG_INFID_RESUME);
}
#if 0
#if 1
/* throw the grp reset flag */
sngss7_set_flag(sngss7_info, FLAG_GRP_RESET_TX);
if (x == 1) {
@@ -361,6 +361,7 @@ typedef struct sngss7_span_data {
sngss7_group_data_t tx_cgb;
sngss7_group_data_t rx_cgu;
sngss7_group_data_t tx_cgu;
sngss7_group_data_t ucic;
ftdm_queue_t *event_queue;
}sngss7_span_data_t;
@@ -566,10 +567,15 @@ ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan);
ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan);
ftdm_status_t check_for_res_sus_flag(ftdm_span_t *ftdmspan);
ftdm_status_t process_span_ucic(ftdm_span_t *ftdmspan);
ftdm_status_t clear_rx_grs_flags(sngss7_chan_data_t *sngss7_info);
ftdm_status_t clear_tx_grs_flags(sngss7_chan_data_t *sngss7_info);
ftdm_status_t clear_rx_rsc_flags(sngss7_chan_data_t *sngss7_info);
ftdm_status_t clear_tx_rsc_flags(sngss7_chan_data_t *sngss7_info);
ftdm_status_t clear_rx_grs_data(sngss7_chan_data_t *sngss7_info);
ftdm_status_t clear_rx_gra_data(sngss7_chan_data_t *sngss7_info);
ftdm_status_t clear_tx_grs_data(sngss7_chan_data_t *sngss7_info);
/* in ftmod_sangoma_ss7_timers.c */
@@ -62,10 +62,15 @@ ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan);
ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan);
ftdm_status_t check_for_res_sus_flag(ftdm_span_t *ftdmspan);
ftdm_status_t process_span_ucic(ftdm_span_t *ftdmspan);
ftdm_status_t clear_rx_grs_flags(sngss7_chan_data_t *sngss7_info);
ftdm_status_t clear_tx_grs_flags(sngss7_chan_data_t *sngss7_info);
ftdm_status_t clear_rx_rsc_flags(sngss7_chan_data_t *sngss7_info);
ftdm_status_t clear_tx_rsc_flags(sngss7_chan_data_t *sngss7_info);
ftdm_status_t clear_rx_grs_data(sngss7_chan_data_t *sngss7_info);
ftdm_status_t clear_rx_gra_data(sngss7_chan_data_t *sngss7_info);
ftdm_status_t clear_tx_grs_data(sngss7_chan_data_t *sngss7_info);
/******************************************************************************/
/* FUNCTIONS ******************************************************************/
@@ -159,8 +164,8 @@ uint8_t copy_cgPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCgPtyNum *cgPtyNum)
} else {
/* keep the odd flag down */
odd = 0;
/* throw the flag */
flag = 1;
/* break right away since we don't need to write the digits */
break;
}
/* push the digits into the trillium structure */
@@ -261,14 +266,14 @@ uint8_t copy_cdPtyNum_to_sngss7(ftdm_caller_data_t *ftdm, SiCdPtyNum *cdPtyNum)
upper = (atoi(&tmp[0])) << 4;
} else {
/* there is no upper ... fill in ST */
upper = 0xF;
/* throw the odd flag */
odd = 1;
upper = 0xF0;
/* keep the odd flag down */
odd = 0;
/* throw the end flag */
flag = 1;
} /* if (tmp != '\0') */
} else {
/* keep the odd flag down */
/* throw the odd flag */
odd = 1;
/* need to add the ST */
lower = 0xF;
@@ -525,7 +530,7 @@ ftdm_status_t check_if_rx_grs_processed(ftdm_span_t *ftdmspan)
int bit = 0;
ftdm_log(FTDM_LOG_DEBUG, "Found Rx GRS on span %d...checking circuits\n", ftdmspan->span_id);
ftdm_log(FTDM_LOG_DEBUG, "Found Rx GRS on span %s...checking circuits\n", ftdmspan->name);
/* check all the circuits in the range to see if they are done resetting */
for ( i = sngss7_span->rx_grs.circuit; i < (sngss7_span->rx_grs.circuit + sngss7_span->rx_grs.range + 1); i++) {
@@ -614,7 +619,7 @@ ftdm_status_t check_if_rx_gra_started(ftdm_span_t *ftdmspan)
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->mod_data;
int i;
for ( i = sngss7_span->rx_gra.circuit; i < (sngss7_span->rx_gra.circuit + sngss7_span->rx_gra.range + 1); i++) {
for (i = sngss7_span->rx_gra.circuit; i < (sngss7_span->rx_gra.circuit + sngss7_span->rx_gra.range + 1); i++) {
/* extract the channel in question */
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
@@ -756,6 +761,48 @@ ftdm_status_t check_for_res_sus_flag(ftdm_span_t *ftdmspan)
return FTDM_SUCCESS;
}
/******************************************************************************/
ftdm_status_t process_span_ucic(ftdm_span_t *ftdmspan)
{
ftdm_channel_t *ftdmchan = NULL;
sngss7_chan_data_t *sngss7_info = NULL;
sngss7_span_data_t *sngss7_span = (sngss7_span_data_t *)ftdmspan->mod_data;
int i;
for (i = sngss7_span->ucic.circuit; i < (sngss7_span->ucic.circuit + sngss7_span->ucic.range + 1); i++) {
/* extract the channel in question */
if (extract_chan_data(i, &sngss7_info, &ftdmchan)) {
SS7_ERROR("Failed to extract channel data for circuit = %d!\n", i);
continue;
}
/* lock the channel */
ftdm_mutex_lock(ftdmchan->mutex);
SS7_INFO_CHAN(ftdmchan,"[CIC:%d]Rx UCIC\n", sngss7_info->circuit->cic);
/* clear up any pending state changes */
while (ftdm_test_flag (ftdmchan, FTDM_CHANNEL_STATE_CHANGE)) {
ftdm_sangoma_ss7_process_state_change (ftdmchan);
}
/* throw the ckt block flag */
sngss7_set_flag(sngss7_info, FLAG_CKT_UCIC_BLOCK);
/* set the channel to suspended state */
ftdm_set_state_locked(ftdmchan, FTDM_CHANNEL_STATE_SUSPENDED);
/* unlock the channel again before we exit */
ftdm_mutex_unlock(ftdmchan->mutex);
}
/* clear out the ucic data since we're done with it */
memset(&sngss7_span->ucic, 0x0, sizeof(sngss7_group_data_t));
return FTDM_SUCCESS;
}
/******************************************************************************/
ftdm_status_t clear_rx_grs_flags(sngss7_chan_data_t *sngss7_info)
{
@@ -767,6 +814,29 @@ ftdm_status_t clear_rx_grs_flags(sngss7_chan_data_t *sngss7_info)
return FTDM_SUCCESS;
}
/******************************************************************************/
ftdm_status_t clear_rx_grs_data(sngss7_chan_data_t *sngss7_info)
{
ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan;
sngss7_span_data_t *sngss7_span = ftdmchan->span->mod_data;
/* clear the rx_grs data fields */
memset(&sngss7_span->rx_grs, 0x0, sizeof(sngss7_group_data_t));
return FTDM_SUCCESS;
}
/******************************************************************************/
ftdm_status_t clear_rx_gra_data(sngss7_chan_data_t *sngss7_info)
{
ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan;
sngss7_span_data_t *sngss7_span = ftdmchan->span->mod_data;
/* clear the rx_grs data fields */
memset(&sngss7_span->rx_gra, 0x0, sizeof(sngss7_group_data_t));
return FTDM_SUCCESS;
}
/******************************************************************************/
ftdm_status_t clear_tx_grs_flags(sngss7_chan_data_t *sngss7_info)
{
@@ -779,6 +849,20 @@ ftdm_status_t clear_tx_grs_flags(sngss7_chan_data_t *sngss7_info)
return FTDM_SUCCESS;
}
/******************************************************************************/
ftdm_status_t clear_tx_grs_data(sngss7_chan_data_t *sngss7_info)
{
ftdm_channel_t *ftdmchan = sngss7_info->ftdmchan;
sngss7_span_data_t *sngss7_span = ftdmchan->span->mod_data;
/* clear the rx_grs data fields */
memset(&sngss7_span->tx_grs, 0x0, sizeof(sngss7_group_data_t));
return FTDM_SUCCESS;
}
/******************************************************************************/
/******************************************************************************/
ftdm_status_t clear_rx_rsc_flags(sngss7_chan_data_t *sngss7_info)
{
+5 -3
View File
@@ -170,8 +170,8 @@ static const char *chanpath = NULL;
static const char dahdi_ctlpath[] = "/dev/dahdi/ctl";
static const char dahdi_chanpath[] = "/dev/dahdi/channel";
static const char zt_ctlpath[] = "/dev/ftdm/ctl";
static const char zt_chanpath[] = "/dev/ftdm/channel";
static const char zt_ctlpath[] = "/dev/zap/ctl";
static const char zt_chanpath[] = "/dev/zap/channel";
static ftdm_socket_t CONTROL_FD = ZT_INVALID_SOCKET;
@@ -974,7 +974,7 @@ FIO_SPAN_POLL_EVENT_FUNCTION(zt_poll_event)
*/
FIO_SPAN_NEXT_EVENT_FUNCTION(zt_next_event)
{
uint32_t i, event_id = 0;
uint32_t i, event_id = FTDM_OOB_INVALID;
zt_event_t zt_event_id = 0;
for(i = 1; i <= span->chan_count; i++) {
@@ -1022,6 +1022,8 @@ FIO_SPAN_NEXT_EVENT_FUNCTION(zt_next_event)
event_id = FTDM_OOB_OFFHOOK;
} else if (span->channels[i]->type == FTDM_CHAN_TYPE_FXO) {
event_id = FTDM_OOB_RING_START;
} else {
event_id = FTDM_OOB_NOOP;
}
}
break;
+1 -4
View File
@@ -667,9 +667,6 @@ FT_DECLARE(ftdm_status_t) ftdm_span_set_sig_status(ftdm_span_t *span, ftdm_signa
/*! \brief Get span signaling status (ie: whether protocol layer is up or down) */
FT_DECLARE(ftdm_status_t) ftdm_span_get_sig_status(ftdm_span_t *span, ftdm_signaling_status_t *status);
/*! \brief Get span signaling status (ie: whether protocol layer is up or down) */
FT_DECLARE(void) ftdm_channel_clear_detected_tones(ftdm_channel_t *ftdmchan);
/*!
* \brief Set user private data in the channel
*
@@ -1268,7 +1265,7 @@ FT_DECLARE(const char *) ftdm_channel_get_state_str(const ftdm_channel_t *channe
FT_DECLARE(const char *) ftdm_channel_get_last_state_str(const ftdm_channel_t *channel);
/*! \brief For display debugging purposes you can display this string which describes the history of the channel
* \param The channel
* \param channel The channel to get the history from
* \return History string for the channel. You must free the string with ftdm_free
*/
FT_DECLARE(char *) ftdm_channel_get_history_str(const ftdm_channel_t *channel);
@@ -595,6 +595,10 @@ FT_DECLARE(ftdm_status_t) ftdm_channel_queue_dtmf(ftdm_channel_t *ftdmchan, cons
/* dequeue pending signals and notify the user via the span signal callback */
FT_DECLARE(ftdm_status_t) ftdm_span_trigger_signals(const ftdm_span_t *span);
/*! \brief clear the tone detector state */
FT_DECLARE(void) ftdm_channel_clear_detected_tones(ftdm_channel_t *ftdmchan);
/*!
\brief Assert condition
*/
@@ -384,7 +384,7 @@ struct ftdm_iterator {
unsigned int allocated:1;
union {
struct {
int32_t index;
uint32_t index;
const ftdm_span_t *span;
} chaniter;
ftdm_hash_iterator_t *hashiter;
+2 -2
View File
@@ -28,11 +28,11 @@ AC_ARG_WITH(libgnutls-prefix,
no_libgnutls=""
if test "$LIBGNUTLS_CONFIG" != "no"; then
LIBGNUTLS_CFLAGS=`$LIBGNUTLS_CONFIG $libgnutls_config_args --cflags`
LIBGNUTLS_LIBS="`$LIBGNUTLS_CONFIG $libgnutls_config_args --libs` -lpthread"
LIBGNUTLS_LIBS="`$LIBGNUTLS_CONFIG $libgnutls_config_args --libs` -lpthread -lgcrypt"
libgnutls_config_version=`$LIBGNUTLS_CONFIG $libgnutls_config_args --version`
elif test "$PKG_CONFIG" != "no"; then
LIBGNUTLS_CFLAGS=`$PKG_CONFIG --cflags gnutls`
LIBGNUTLS_LIBS="`$PKG_CONFIG --libs gnutls` -lpthread"
LIBGNUTLS_LIBS="`$PKG_CONFIG --libs gnutls` -lpthread -lgcrypt"
libgnutls_config_version=`$PKG_CONFIG --modversion gnutls`
else
no_libgnutls=yes
+3 -3
View File
@@ -175,14 +175,14 @@ AC_CHECK_HEADERS([sys/select.h])
AC_CHECK_HEADERS([sys/ioctl.h])
AC_CHECK_HEADERS([sys/fcntl.h])
AC_CHECK_HEADERS([audiofile.h])
if test "${build}" == "${host}"
if test "${build}" = "${host}"
then
AC_CHECK_HEADERS([X11/X.h])
fi
AC_LANG([C++])
if test "${build}" == "${host}"
if test "${build}" = "${host}"
then
case "${host}" in
x86_64-*)
@@ -193,7 +193,7 @@ fi
AC_LANG([C])
if test "${build}" == "${host}"
if test "${build}" = "${host}"
then
case "${host}" in
x86_64-*)
View File
Whitespace-only changes.
View File
Whitespace-only changes.
+502
View File
@@ -0,0 +1,502 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
<one line to give the library's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
View File
Whitespace-only changes.
+236
View File
@@ -0,0 +1,236 @@
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
Software Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. (Caching is
disabled by default to prevent problems with accidental use of stale
cache files.)
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You only need
`configure.ac' if you want to change it or regenerate `configure' using
a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that the
`configure' script does not know about. Run `./configure --help' for
details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not support the `VPATH'
variable, you have to compile the package for one architecture at a
time in the source code directory. After you have installed the
package for one architecture, use `make distclean' before reconfiguring
for another architecture.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out automatically,
but needs to determine by the type of machine the package will run on.
Usually, assuming the package is built to be run on the _same_
architectures, `configure' can figure that out, but if it prints a
message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share, you
can create a site shell script called `config.site' that gives default
values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script). Here is a another example:
/bin/bash ./configure CONFIG_SHELL=/bin/bash
Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
configuration-related scripts to be executed by `/bin/bash'.
`configure' Invocation
======================
`configure' recognizes the following options to control how it operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.
+98
View File
@@ -0,0 +1,98 @@
AM_CFLAGS = -Isrc -Wall -lm
AUTOMAKE_OPTS = gnu
NAME = libcodec2
AM_CPPFLAGS = $(AM_CFLAGS)
EXTRA_DIST = pitch/hts1a.p \
pitch/hts2a.p \
octave/glottal.m \
octave/lsp_pdf.m \
octave/phase.m \
octave/pl2.m \
octave/plinterp.m \
octave/plnlp.m \
octave/plpitch.m \
octave/postfilter.m \
octave/load_raw.m \
octave/phase2.m \
octave/pitch_test.m \
octave/plamp.m \
octave/pl.m \
octave/plphase.m \
octave/png.m \
octave/pulse.m \
raw/b0067.raw \
raw/forig_speex_8k.raw \
raw/hts1.raw \
raw/hts2.raw \
raw/mmt1.raw \
raw/morig_speex_8k.raw \
raw/f2400.raw \
raw/hts1a_g729a.raw \
raw/hts2a_g729a.raw \
raw/hts.raw \
raw/mmt1_speex_8k.raw \
raw/forig_g729a.raw \
raw/hts1a_gsm13k.raw \
raw/hts2a_gsm13k.raw \
raw/m2400.raw \
raw/morig_g729a.raw \
raw/forig_gsm13k.raw \
raw/hts1a.raw \
raw/hts2a.raw \
raw/mmt1_g729a.raw \
raw/morig_gsm13k.raw \
raw/forig.raw \
raw/hts1a_speex_8k.raw \
raw/hts2a_speex_8k.raw \
raw/mmt1_gsm13k.raw \
raw/morig.raw \
script/menu.sh \
script/playraw.sh \
script/raw2wav.sh \
script/wav2raw.sh \
wav/f2400.wav \
wav/hts1a_c2_v0.1.wav \
wav/hts1a.wav \
wav/hts2a_speex_8k.wav \
wav/mmt1_speex_8k.wav \
wav/morig.wav \
wav/forig_speex_8k.wav \
wav/hts1a_g729a.wav \
wav/hts2a_c2_v0.1.wav \
wav/hts2a.wav \
wav/mmt1.wav \
wav/forig.wav \
wav/hts1a_speex_8k.wav \
wav/hts2a_g729a.wav \
wav/m2400.wav \
wav/morig_speex_8k.wav \
src/globals.c \
doc/A_m.gif \
doc/omega_0.gif \
doc/phi_m.gif \
doc/s_n.gif \
doc/s_n.txt \
unittest/lsp2.txt \
unittest/lsp7.txt \
unittest/lspd78.txt \
unittest/lsp3.txt \
unittest/lsp8.txt \
unittest/lspd910.txt \
unittest/lsp4.txt \
unittest/lsp9.txt \
unittest/lsp10.txt \
unittest/lsp5.txt \
unittest/lspd123.txt \
unittest/lsp1.txt \
unittest/lsp6.txt \
unittest/lspd456.txt \
src/codeall.sh \
src/fq20.sh \
src/listen1.sh \
src/listen.sh \
src/listensim.sh \
src/sim.sh
SUBDIRS = src unittest
View File
Whitespace-only changes.
View File
Whitespace-only changes.
+4
View File
@@ -0,0 +1,4 @@
#! /bin/sh
srcpath=$(dirname $0 2>/dev/null ) || srcpath="."
$srcpath/configure "$@" --disable-shared --with-pic
+26
View File
@@ -0,0 +1,26 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.59])
AC_INIT(libcodec2, 1.0, david@rowetel.com)
AM_INIT_AUTOMAKE(libcodec2,1.0)
# Checks for programs.
AC_PROG_CC
AC_PROG_LIBTOOL
# Checks for libraries.
# FIXME: Replace `main' with a function in `-lm':
AC_CHECK_LIB([m], [main])
# Checks for header files.
AC_CHECK_HEADERS([stdlib.h string.h])
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([floor pow sqrt])
AC_CONFIG_FILES([Makefile src/Makefile unittest/Makefile])
AC_OUTPUT
Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 552 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

+1
View File
@@ -0,0 +1 @@
s(n)=A_1cos(\omega_0+\phi_1)+A_2cos(2\omega_0+\phi_2)+...+A_Lcos(L\omega_0+\phi_L)
+25
View File
@@ -0,0 +1,25 @@
% glottal.m
% David Rowe 12 Sep 2009
% Matlab script to generate the phase spectra of a glottal pulse
% lpc10 pulse from spandsp. When the file glottal.c was used as a part of the
% excitation phase component in phase.c, phase_synth_zero_order(), no difference
% in speech quality was apparent. So left out of code for now.
sh=12
kexc = [ 8, -16, 26, -48, 86, -162, 294, -502, 718, -728, 184 672, -610, -672, 184, 728, 718, 502, 294, 162, 86, 48, 26, 16, 8];
kexc = shift(kexc,sh);
kexc = [kexc(1:sh) zeros(1,512-25) kexc(sh+1:25)];
figure(1)
plot(kexc)
figure(2)
G = fft(kexc);
plot((1:256)*(4000/256),unwrap(angle(G(1:256))))
f=fopen("glottal.c","wt");
fprintf(f,"float glottal[]={\n");
for m=1:255
fprintf(f," %f,\n",angle(G(m)));
endfor
fprintf(f," %f};\n",angle(G(256)));
fclose(f);
+8
View File
@@ -0,0 +1,8 @@
% load_raw.m
% David Rowe 7 Oct 2009
function s = load_raw(fn)
fs=fopen(fn,"rb");
s = fread(fs,Inf,"short");
plot(s)
endfunction
+50
View File
@@ -0,0 +1,50 @@
% lsp_pdf.m
% David Rowe 2 Oct 2009
% Plots histograms (PDF estimates) of LSP training data
function lsp_pdf(lsp)
[r,c] = size(lsp);
% LSPs
figure(3);
clf;
[x,y] = hist(lsp(:,1),100);
plot(y*4000/pi,x,";1;");
hold on;
for i=2:c
[x,y] = hist(lsp(:,i),100);
legend = sprintf(";%d;",i);
plot(y*4000/pi,x,legend);
endfor
hold off;
grid;
% LSP differences
figure(4);
clf;
subplot(211)
[x,y] = hist(lsp(:,1),100);
plot(y,x,";1;");
hold on;
for i=2:5
[x,y] = hist(lsp(:,i) - lsp(:,i-1),100);
legend = sprintf(";%d;",i);
plot(y,x,legend);
endfor
hold off;
grid;
subplot(212)
[x,y] = hist(lsp(:,6)-lsp(:,5),100);
plot(y,x,";6;");
hold on;
for i=7:c
[x,y] = hist(lsp(:,i) - lsp(:,i-1),100);
legend = sprintf(";%d;",i);
plot(y,x,legend);
endfor
hold off;
grid;
endfunction
+56
View File
@@ -0,0 +1,56 @@
% phase.m
% David Rowe August 2009
% experiments with phase for sinusoidal codecs
function phase(samname, F0, png)
Wo=2*pi*F0/8000;
P=2*pi/Wo;
L = floor(pi/Wo);
Nsam = 16000;
N = 80;
F = Nsam/N;
A = 10000/L;
phi = zeros(1,L);
s = zeros(1,Nsam);
for m=floor(L/2):L
phi_off(m) = -m*Wo*8;
end
for f=1:F
phi(1) = phi(1) + Wo*N;
phi(1) = mod(phi(1),2*pi);
for m=1:L
phi(m) = m*phi(1);
end
x = zeros(1,N);
for m=1:L
x = x + A*cos(m*Wo*(0:(N-1)) + phi(m));
endfor
s((f-1)*N+1:f*N) = x;
endfor
figure(1);
clf;
plot(s(1:250));
fs=fopen(samname,"wb");
fwrite(fs,s,"short");
fclose(fs);
if (nargin == 3)
% small image to fit blog
__gnuplot_set__ terminal png size 450,300
ss = sprintf("__gnuplot_set__ output \"%s.png\"", samname);
eval(ss)
replot;
% for some reason I need this to stop large plot getting wiped
__gnuplot_set__ output "/dev/null"
endif
endfunction
+50
View File
@@ -0,0 +1,50 @@
% phase2.m
% David Rowe Sep 2009
% experiments with phase for sinusoidal codecs, looking at phase
% of excitation with real Am samples from hts1
function phase2(samname, png)
N = 16000;
f=45;
model = load("../src/hts1a_model.txt");
phase = load("../src/hts1a_phase_phase.txt");
Wo = model(f,1);
P=2*pi/Wo;
L = model(f,2);
A = model(f,3:(L+2));
phi = phase(f,1:L);
phi = zeros(1,L);
for m=L/2:L
phi(m) = 2*pi*rand(1,1);
end
s = zeros(1,N);
for m=1:L
s_m = A(m)*cos(m*Wo*(0:(N-1)) + phi(m));
s = s + s_m;
endfor
figure(1);
clf;
plot(s(1:250));
fs=fopen(samname,"wb");
fwrite(fs,s,"short");
fclose(fs);
if (nargin == 2)
% small image to fit blog
__gnuplot_set__ terminal png size 450,300
ss = sprintf("__gnuplot_set__ output \"%s.png\"", samname);
eval(ss)
replot;
% for some reason I need this to stop large plot getting wiped
__gnuplot_set__ output "/dev/null"
endif
endfunction
+39
View File
@@ -0,0 +1,39 @@
% pitch_test.m
% David Rowe Sep 2009
% Constructs a sequence to test the pitch estimator
function pitch_test(samname)
M=320;
F=200;
fs=fopen(samname,"wb");
f0 = 100;
for f=1:200
Wo=2*pi*f0/8000;
P=2*pi/Wo;
L = floor(pi/Wo);
A = 10000/L;
phi = zeros(1,L);
s = zeros(1,M);
for m=1:L
s = s + A*cos(m*Wo*(0:(M-1)) + phi(m));
endfor
figure(1);
clf;
plot(s);
fwrite(fs,s,"short");
f0 = f0 + 5;
if (f0 > 400)
f0 = 100;
endif
endfor
fclose(fs);
endfunction
+42
View File
@@ -0,0 +1,42 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
function pl(samname1, start_sam, end_sam, pngname)
fs=fopen(samname1,"rb");
s=fread(fs,Inf,"short");
st = 1;
en = length(s);
if (nargin >= 2)
st = start_sam;
endif
if (nargin >= 3)
en = end_sam;
endif
figure(1);
clf;
plot(s(st:en));
axis([1 en-st min(s) max(s)]);
if (nargin == 4)
% small image
__gnuplot_set__ terminal png size 420,300
ss = sprintf("__gnuplot_set__ output \"%s.png\"", pngname);
eval(ss)
replot;
% larger image
__gnuplot_set__ terminal png size 800,600
ss = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname);
eval(ss)
replot;
endif
endfunction
+50
View File
@@ -0,0 +1,50 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
function pl2(samname1, samname2, start_sam, end_sam, pngname)
fs1=fopen(samname1,"rb");
s1=fread(fs1,Inf,"short");
fs2=fopen(samname2,"rb");
s2=fread(fs2,Inf,"short");
st = 1;
en = length(s1);
if (nargin >= 3)
st = start_sam;
endif
if (nargin >= 4)
en = end_sam;
endif
figure(1);
clf;
subplot(211);
l1 = strcat("r;",samname1,";");
plot(s1(st:en), l1);
axis([1 en-st min(s1(st:en)) max(s1(st:en))]);
subplot(212);
l2 = strcat("r;",samname2,";");
plot(s2(st:en),l2);
axis([1 en-st min(s1(st:en)) max(s1(st:en))]);
if (nargin == 5)
% small image
__gnuplot_set__ terminal png size 420,300
s = sprintf("__gnuplot_set__ output \"%s.png\"", pngname);
eval(s)
replot;
% larger image
__gnuplot_set__ terminal png size 800,600
s = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname);
eval(s)
replot;
endif
endfunction
+166
View File
@@ -0,0 +1,166 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
%
% Plot ampltiude modelling information from dump files.
function plamp(samname, f)
sn_name = strcat(samname,"_sn.txt");
Sn = load(sn_name);
sw_name = strcat(samname,"_sw.txt");
Sw = load(sw_name);
sw__name = strcat(samname,"_sw_.txt");
if (file_in_path(".",sw__name))
Sw_ = load(sw__name);
endif
model_name = strcat(samname,"_model.txt");
model = load(model_name);
modelq_name = strcat(samname,"_qmodel.txt");
if (file_in_path(".",modelq_name))
modelq = load(modelq_name);
endif
pw_name = strcat(samname,"_pw.txt");
if (file_in_path(".",pw_name))
Pw = load(pw_name);
endif
lsp_name = strcat(samname,"_lsp.txt");
if (file_in_path(".",lsp_name))
lsp = load(lsp_name);
endif
phase_name = strcat(samname,"_phase.txt");
if (file_in_path(".",phase_name))
phase = load(phase_name);
endif
phase_name_ = strcat(samname,"_phase_.txt");
if (file_in_path(".",phase_name_))
phase_ = load(phase_name_);
endif
snr_name = strcat(samname,"_snr.txt");
if (file_in_path(".",snr_name))
snr = load(snr_name);
endif
k = ' ';
do
figure(1);
clf;
% s = [ Sn(2*(f-2)-1,:) Sn(2*(f-2),:) ];
s = [ Sn(2*f-1,:) Sn(2*f,:) ];
plot(s);
axis([1 length(s) -20000 20000]);
figure(2);
Wo = model(f,1);
L = model(f,2);
Am = model(f,3:(L+2));
plot((1:L)*Wo*4000/pi, 20*log10(Am),";Am;r");
axis([1 4000 -10 80]);
hold on;
% plot((0:255)*4000/256, Sw(f-2,:),";Sw;");
plot((0:255)*4000/256, Sw(f,:),";Sw;");
if (file_in_path(".",modelq_name))
Amq = modelq(f,3:(L+2));
plot((1:L)*Wo*4000/pi, 20*log10(Amq),";Amq;g" );
if (file_in_path(".",pw_name))
plot((0:255)*4000/256, 10*log10(Pw(f,:)),";Pw;c");
endif
signal = Am * Am';
noise = (Am-Amq) * (Am-Amq)';
snr1 = 10*log10(signal/noise);
Am_err_label = sprintf(";Am error SNR %4.2f dB;m",snr1);
plot((1:L)*Wo*4000/pi, 20*log10(Amq) - 20*log10(Am), Am_err_label);
endif
if (file_in_path(".",snr_name))
snr_label = sprintf(";phase SNR %4.2f dB;",snr(f));
plot(1,1,snr_label);
endif
% phase model - determine SNR and error spectrum for phase model 1
if (file_in_path(".",phase_name_))
orig = Am.*exp(j*phase(f,1:L));
synth = Am.*exp(j*phase_(f,1:L));
signal = orig * orig';
noise = (orig-synth) * (orig-synth)';
snr_phase = 10*log10(signal/noise);
phase_err_label = sprintf(";phase_err SNR %4.2f dB;",snr_phase);
plot((1:L)*Wo*4000/pi, 20*log10(orig-synth), phase_err_label);
endif
if (file_in_path(".",lsp_name))
for l=1:10
plot([lsp(f,l)*4000/pi lsp(f,l)*4000/pi], [60 80], 'r');
endfor
endif
hold off;
if (file_in_path(".",phase_name))
figure(3);
plot((1:L)*Wo*4000/pi, phase(f,1:L), ";phase;");
axis;
if (file_in_path(".",phase_name_))
hold on;
plot((1:L)*Wo*4000/pi, phase_(f,1:L), ";phase_;");
hold off;
endif
figure(2);
endif
% autocorrelation function to research voicing est
%M = length(s);
%sw = s .* hanning(M)';
%for k=0:159
% R(k+1) = sw(1:320-k) * sw(1+k:320)';
%endfor
%figure(4);
%R_label = sprintf(";R(k) %3.2f;",max(R(20:159))/R(1));
%plot(R/R(1),R_label);
%grid
% interactive menu
printf("\rframe: %d menu: n-next b-back p-png q-quit ", f);
fflush(stdout);
k = kbhit();
if (k == 'n')
f = f + 1;
endif
if (k == 'b')
f = f - 1;
endif
% optional print to PNG
if (k == 'p')
figure(1);
pngname = sprintf("%s_%d_sn.png",samname,f);
print(pngname, '-dpng', "-S500,500")
pngname = sprintf("%s_%d_sn_large.png",samname,f);
print(pngname, '-dpng', "-S800,600")
figure(2);
pngname = sprintf("%s_%d_sw.png",samname,f);
print(pngname, '-dpng', "-S500,500")
pngname = sprintf("%s_%d_sw_large.png",samname,f);
print(pngname, '-dpng', "-S800,600")
endif
until (k == 'q')
printf("\n");
endfunction
+11
View File
@@ -0,0 +1,11 @@
load ../unittest/tinterp_prev.txt;
load ../unittest/tinterp_interp.txt;
load ../unittest/tinterp_next.txt;
clf;
plot(tinterp_prev(:,1), 20.0*log10(tinterp_prev(:,2)),";prev;")
hold on;
plot(tinterp_interp(:,1), 20.0*log10(tinterp_interp(:,2)),'g+-;interp;')
plot(tinterp_next(:,1), 20.0*log10(tinterp_next(:,2)),'ro-;next;')
hold off;
axis([0 pi 0 80])
+134
View File
@@ -0,0 +1,134 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
%
% Plot NLP states from dump files.
function plnlp(samname, f)
sn_name = strcat(samname,"_sn.txt");
Sn = load(sn_name);
sw_name = strcat(samname,"_sw.txt");
Sw = load(sw_name);
fw_name = strcat(samname,"_fw.txt");
if (file_in_path(".",fw_name))
fw = load(fw_name);
endif
e_name = strcat(samname,"_e.txt");
if (file_in_path(".",e_name))
e = load(e_name);
endif
p_name = strcat(samname,".p");
if (file_in_path(".",p_name))
p = load(p_name);
endif
sq_name = strcat(samname,"_sq.txt");
if (file_in_path(".",sq_name))
sq = load(sq_name);
endif
dec_name = strcat(samname,"_dec.txt");
if (file_in_path(".",dec_name))
dec = load(dec_name);
endif
do
figure(1);
clf;
s = [ Sn(2*f-1,:) Sn(2*f,:) ];
plot(s, ";Sn;");
grid
axis([1 length(s) -20000 20000]);
figure(2);
plot((0:255)*4000/256, Sw(f,:),";Sw;");
grid
axis([1 4000 -10 80]);
hold on;
f0 = 8000/p(f);
Wo = 2*pi/p(f);
L = floor(pi/Wo);
f0_label = sprintf("b;P=%3.1f F0=%3.0f;",p(f),f0);
for m=1:L-1
plot([ m*Wo*4000/pi m*Wo*4000/pi], [10 60], 'b');
endfor
plot([ L*Wo*4000/pi L*Wo*4000/pi], [10 60], f0_label);
hold off;
if (file_in_path(".",fw_name))
figure(3);
if (file_in_path(".",e_name))
subplot(211);
endif
plot((0:255)*800/256, fw(f,:)/max(fw(f,:)), ";Fw;");
axis([1 400 0 1]);
if (file_in_path(".",e_name))
subplot(212);
e_concat = [ e(2*f-1,:) e(2*f,:) ];
plot(e_concat(1:400)/max(e_concat(1:400)), "+;MBE E(f);");
axis([1 400 0 1]);
endif
endif
if (file_in_path(".",sq_name))
figure(4);
sq_concat = [ sq(2*f-1,:) sq(2*f,:) ];
axis
plot(sq_concat, ";sq;");
endif
if (file_in_path(".",dec_name))
figure(5);
plot(dec(f,:), ";dec;");
endif
figure(2);
% interactive menu
printf("\rframe: %d menu: n-next b-back p-png q-quit ", f);
fflush(stdout);
k = kbhit();
if (k == 'n')
f = f + 1;
endif
if (k == 'b')
f = f - 1;
endif
% optional print to PNG
if (k == 'p')
pngname = sprintf("%s_%d",samname,f);
% small image
__gnuplot_set__ terminal png size 420,300
ss = sprintf("__gnuplot_set__ output \"%s.png\"", pngname);
eval(ss)
replot;
% larger image
__gnuplot_set__ terminal png size 800,600
ss = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname);
eval(ss)
replot;
% for some reason I need this to stop large plot getting wiped
__gnuplot_set__ output "/dev/null"
endif
until (k == 'q')
printf("\n");
endfunction
+198
View File
@@ -0,0 +1,198 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
%
% Plot phase modelling information from dump files.
function plphase(samname, f)
sn_name = strcat(samname,"_sn.txt");
Sn = load(sn_name);
sw_name = strcat(samname,"_sw.txt");
Sw = load(sw_name);
model_name = strcat(samname,"_model.txt");
model = load(model_name);
sw__name = strcat(samname,"_sw_.txt");
if (file_in_path(".",sw__name))
Sw_ = load(sw__name);
endif
pw_name = strcat(samname,"_pw.txt");
if (file_in_path(".",pw_name))
Pw = load(pw_name);
endif
ak_name = strcat(samname,"_ak.txt");
if (file_in_path(".",ak_name))
ak = load(ak_name);
endif
phase_name = strcat(samname,"_phase.txt");
if (file_in_path(".",phase_name))
phase = load(phase_name);
endif
phase_name_ = strcat(samname,"_phase_.txt");
if (file_in_path(".",phase_name_))
phase_ = load(phase_name_);
endif
snr_name = strcat(samname,"_snr.txt");
if (file_in_path(".",snr_name))
snr = load(snr_name);
endif
sn_name_ = strcat(samname,".raw");
if (file_in_path(".",sn_name_))
fs_ = fopen(sn_name_,"rb");
sn_ = fread(fs_,Inf,"short");
endif
k = ' ';
do
figure(1);
clf;
s = [ Sn(2*f-1,:) Sn(2*f,:) ];
plot(s);
grid;
axis([1 length(s) -20000 20000]);
if (k == 'p')
pngname = sprintf("%s_%d_sn",samname,f);
png(pngname);
endif
figure(2);
Wo = model(f,1);
L = model(f,2);
Am = model(f,3:(L+2));
plot((1:L)*Wo*4000/pi, 20*log10(Am),"r;Am;");
axis([1 4000 -10 80]);
hold on;
plot((0:255)*4000/256, Sw(f,:),";Sw;");
grid;
if (file_in_path(".",sw__name))
plot((0:255)*4000/256, Sw_(f,:),"g;Sw_;");
endif
if (file_in_path(".",pw_name))
plot((0:255)*4000/256, 10*log10(Pw(f,:)),";Pw;");
endif
if (file_in_path(".",snr_name))
snr_label = sprintf(";phase SNR %4.2f dB;",snr(f));
plot(1,1,snr_label);
endif
% phase model - determine SNR and error spectrum for phase model 1
if (file_in_path(".",phase_name_))
orig = Am.*exp(j*phase(f,1:L));
synth = Am.*exp(j*phase_(f,1:L));
signal = orig * orig';
noise = (orig-synth) * (orig-synth)';
snr_phase = 10*log10(signal/noise);
phase_err_label = sprintf("g;phase_err SNR %4.2f dB;",snr_phase);
plot((1:L)*Wo*4000/pi, 20*log10(orig-synth), phase_err_label);
endif
hold off;
if (k == 'p')
pngname = sprintf("%s_%d_sw",samname,f);
png(pngname);
endif
if (file_in_path(".",phase_name))
figure(3);
plot((1:L)*Wo*4000/pi, phase(f,1:L)*180/pi, "-o;phase;");
axis;
if (file_in_path(".", phase_name_))
hold on;
plot((1:L)*Wo*4000/pi, phase_(f,1:L)*180/pi, "g;phase_;");
grid
hold off;
endif
if (k == 'p')
pngname = sprintf("%s_%d_phase",samname,f);
png(pngname);
endif
endif
% synthesised speech
if (file_in_path(".",sn_name_))
figure(4);
s_ = sn_((f-3)*80+1:(f+1)*80);
plot(s_);
axis([1 length(s_) -20000 20000]);
if (k == 'p')
pngname = sprintf("%s_%d_sn_",samname,f)
png(pngname);
endif
endif
if (file_in_path(".",ak_name))
figure(5);
axis;
akw = ak(f,:);
weight = 1.0 .^ (0:length(akw)-1);
akw = akw .* weight;
H = 1./fft(akw,8000);
subplot(211);
plot(20*log10(abs(H(1:4000))),";LPC mag spec;");
grid;
subplot(212);
plot(angle(H(1:4000))*180/pi,";LPC phase spec;");
grid;
if (k == 'p')
% stops multimode errors from gnuplot, I know not why...
figure(2);
figure(5);
pngname = sprintf("%s_%d_lpc",samname,f);
png(pngname);
endif
endif
% autocorrelation function to research voicing est
%M = length(s);
%sw = s .* hanning(M)';
%for k=0:159
% R(k+1) = sw(1:320-k) * sw(1+k:320)';
%endfor
%figure(4);
%R_label = sprintf(";R(k) %3.2f;",max(R(20:159))/R(1));
%plot(R/R(1),R_label);
%grid
figure(2);
% interactive menu
printf("\rframe: %d menu: n-next b-back p-png q-quit ", f);
fflush(stdout);
k = kbhit();
if (k == 'n')
f = f + 1;
endif
if (k == 'b')
f = f - 1;
endif
% optional print to PNG
if (k == 'p')
pngname = sprintf("%s_%d",samname,f);
png(pngname);
endif
until (k == 'q')
printf("\n");
endfunction
+36
View File
@@ -0,0 +1,36 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
%
% plpitch.m
% Plots two pitch tracks on top of each other, used for comparing pitch
% estimators
function plpitch(pitch1_name, pitch2_name, start_fr, end_fr)
pitch1 = load(pitch1_name);
pitch2 = load(pitch2_name);
st = 1;
en = length(pitch1);
if (nargin >= 3)
st = start_fr;
endif
if (nargin >= 4)
en = end_fr;
endif
figure(1);
clf;
l1 = strcat("r;",pitch1_name,";")
l1
st
en
plot(pitch1(st:en), l1);
axis([1 en-st 20 160]);
l2 = strcat("g;",pitch2_name,";");
hold on;
plot(pitch2(st:en),l2);
hold off;
endfunction
+25
View File
@@ -0,0 +1,25 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
%
% Replot current plot as a png, generates small and large versions
function png(pngname)
% small image
__gnuplot_set__ terminal png size 420,300
ss = sprintf("__gnuplot_set__ output \"%s.png\"", pngname);
eval(ss)
replot;
% larger image
__gnuplot_set__ terminal png size 800,600
ss = sprintf("__gnuplot_set__ output \"%s_large.png\"", pngname);
eval(ss)
replot;
% for some reason I need this to stop large plot getting wiped
__gnuplot_set__ output "/dev/null"
endfunction
+24
View File
@@ -0,0 +1,24 @@
% Copyright David Rowe 2009
% This program is distributed under the terms of the GNU General Public License
% Version 2
%
% Plot postfilter doing its thing
function postfilter(samname)
p = load(samname);
figure(1);
plot(p(:,1),";energy;");
hold on;
plot(p(:,2),";bg_est;");
hold off;
grid;
pngname=sprintf("%s_postfilter_1", samname);
png(pngname);
figure(2);
plot(p(:,3),";% unvoiced;");
grid;
pngname=sprintf("%s_postfilter_2", samname);
png(pngname);
endfunction
+37
View File
@@ -0,0 +1,37 @@
% pulse.m
% David Rowe August 2009
%
% Experiments with human pulse perception for sinusoidal codecs
function pulse(samname)
A = 1000;
K = 16000;
N = 80;
frames = K/N;
s = zeros(1,K);
for f=1:frames
% lets try placing np random pulses in every frame
P = 20 + (160-20)*rand(1,1);
Wo = 2*pi/P;
L = floor(pi/Wo);
sf = zeros(1,N);
for m=1:L/2:L
pos = floor(rand(1,1)*N)+1;
%pos = 50;
for l=m:m+L/2-1
sf = sf + A*cos(l*Wo*((f-1)*N+1:f*N) - pos*l*Wo);
endfor
endfor
s((f-1)*N+1:f*N) = sf;
endfor
plot(s(1:250));
fs=fopen(samname,"wb");
fwrite(fs,s,"short");
fclose(fs);
endfunction
+298
View File
@@ -0,0 +1,298 @@
111.627907
97.959183
97.959183
97.959183
87.272736
78.048775
112.280701
120.000008
61.538464
68.817207
84.210526
90.140846
90.140846
90.140846
101.587303
80.000000
72.727272
95.522392
90.140846
90.140846
101.587303
90.140846
85.333336
86.486488
91.428574
91.428574
91.428574
91.428574
91.428574
90.140846
86.486488
86.486488
85.333336
85.333336
85.333336
81.012657
74.418610
71.111115
71.111115
71.111115
71.111115
68.085106
68.085106
67.368423
67.368423
70.329674
70.329674
70.329674
71.111115
74.418610
74.418610
75.294121
79.012352
85.333336
96.969704
111.627907
111.627907
120.000008
111.627907
104.347832
104.347832
97.959183
104.347832
104.347832
104.347832
104.347832
104.347832
104.347832
104.347832
104.347832
97.959183
97.959183
112.280701
112.280701
96.969704
96.969704
96.969704
110.344841
104.347832
97.959183
97.959183
104.347832
97.959183
104.347832
120.000008
104.347832
120.000008
120.000008
97.959183
83.116882
75.294121
71.910118
71.910110
71.910110
71.910110
75.294121
76.190483
80.000008
80.000008
84.210526
85.333336
90.140846
101.587303
108.474571
104.347832
120.000008
120.000008
104.347832
104.347832
71.111115
88.888893
75.294121
111.627907
120.000008
120.000008
97.959183
111.627907
111.627907
111.627907
97.959183
92.307693
92.307693
92.307693
92.307693
120.000008
111.627907
111.627907
86.486488
85.333336
85.333336
90.140846
95.522392
101.587311
101.587311
104.918037
104.347832
104.347832
111.627907
120.000008
97.959183
104.347832
111.627907
88.888893
80.000000
81.012657
85.333336
85.333336
86.486488
91.428574
90.140846
91.428574
96.969704
96.969704
95.522392
95.522392
95.522392
96.969704
96.969704
98.461533
104.918022
97.959183
97.959183
97.959183
104.347832
120.000008
120.000008
92.307693
92.307693
77.108429
79.012344
75.294121
75.294121
76.190483
76.190483
80.000008
81.012657
85.333336
85.333336
85.333336
85.333336
85.333336
90.140846
90.140846
91.428574
96.969704
98.461533
120.000008
120.000008
104.347832
97.959183
97.959183
104.918037
120.000008
120.000008
120.000008
104.347832
92.307693
72.727272
72.727272
76.190483
84.210533
88.888901
120.000008
104.347832
120.000008
120.000008
111.627907
92.307693
97.959183
97.959183
111.627907
120.000008
120.000008
97.959183
97.959183
104.347832
104.347832
104.347832
111.627907
120.000008
97.959183
104.347832
97.959183
97.959183
84.210526
94.117653
96.969704
110.344841
120.000008
97.959183
97.959183
104.347832
97.959183
104.347832
97.959183
97.959183
111.627907
120.000008
92.307693
92.307693
98.461533
98.461533
104.918022
111.627907
111.627907
92.307693
97.959183
92.307693
92.307693
92.307693
92.307693
92.307693
57.657658
90.140846
90.140846
95.522392
101.587311
101.587311
108.474586
111.627907
97.959183
111.627907
120.000008
92.307693
74.418610
74.418610
74.418610
74.418610
76.190483
72.727280
76.190483
76.190483
69.565224
66.666672
54.700855
56.637169
56.637169
71.910110
90.140846
90.140846
72.727272
72.727272
72.727272
72.727272
55.172413
57.142857
55.172413
90.140846
95.522392
101.587311
101.587311
71.910110
74.418610
46.376812
40.000000
95.522392
0
0
+300
View File
@@ -0,0 +1,300 @@
0.0000000e+000
9.2753623e+001
5.4237288e+001
8.5906040e+001
7.0329670e+001
5.5652174e+001
5.4237288e+001
5.4935622e+001
5.4700855e+001
7.5739645e+001
7.3563218e+001
1.2307692e+002
1.1428571e+002
7.3563218e+001
7.7108434e+001
1.8550725e+002
1.2673267e+002
1.0847458e+002
7.8527607e+001
8.8888889e+001
8.3116883e+001
8.1012658e+001
1.0756303e+002
1.3061224e+002
4.8301887e+001
4.7940075e+001
4.8120301e+001
4.9230769e+001
4.9420849e+001
4.6886447e+001
4.2953020e+001
3.9263804e+001
3.7869822e+001
3.5457064e+001
3.4224599e+001
3.3333333e+001
3.2820513e+001
3.2000000e+001
3.1295844e+001
2.9906542e+001
2.9493088e+001
2.9090909e+001
2.8699552e+001
2.8131868e+001
2.7826087e+001
2.7826087e+001
2.7826087e+001
2.8193833e+001
2.7467811e+001
2.6890756e+001
5.4468085e+001
5.4237288e+001
6.4974619e+001
1.0756303e+002
8.8888889e+001
1.0406504e+002
4.4599303e+001
5.4468085e+001
3.6260623e+001
3.6260623e+001
8.1012658e+001
7.0329670e+001
1.2929293e+002
9.9224806e+001
4.3097643e+001
4.4137931e+001
4.5714286e+001
4.7407407e+001
4.8301887e+001
4.9230769e+001
4.9420849e+001
5.0996016e+001
5.1405622e+001
5.1405622e+001
5.2244898e+001
5.2459016e+001
5.2459016e+001
5.2244898e+001
5.3333333e+001
5.2459016e+001
5.2244898e+001
5.1405622e+001
5.1405622e+001
5.1200000e+001
5.0996016e+001
5.0196078e+001
4.9230769e+001
4.9230769e+001
4.9230769e+001
4.9420849e+001
4.9230769e+001
4.9042146e+001
9.8461538e+001
1.0158730e+002
5.1821862e+001
9.0140845e+001
1.0491803e+002
1.4382022e+002
5.2459016e+001
5.2459016e+001
1.2929293e+002
1.6410256e+002
8.0000000e+001
7.3563218e+001
1.0158730e+002
9.9224806e+001
4.9042146e+001
4.9042146e+001
4.9042146e+001
5.9259259e+001
1.4382022e+002
7.2316384e+001
1.0847458e+002
1.1228070e+002
1.6202532e+002
8.1528662e+001
7.2727273e+001
1.8550725e+002
6.0093897e+001
1.0847458e+002
8.9510490e+001
7.1508380e+001
4.0125392e+001
4.0634921e+001
4.0634921e+001
4.0251572e+001
4.0506329e+001
4.3986254e+001
4.0506329e+001
9.8461538e+001
5.6140351e+001
6.5641026e+001
5.4237288e+001
1.1636364e+002
3.4316354e+001
3.4972678e+001
3.7758112e+001
4.0634921e+001
4.0506329e+001
4.1290323e+001
4.2524917e+001
4.3389831e+001
4.4599303e+001
4.4912281e+001
4.6545455e+001
4.7232472e+001
4.8301887e+001
4.9230769e+001
4.9420849e+001
5.0393701e+001
5.1405622e+001
5.3333333e+001
5.3112033e+001
1.1034483e+002
9.7709924e+001
1.4382022e+002
5.0996016e+001
5.1821862e+001
5.0996016e+001
5.2032520e+001
5.3112033e+001
5.3556485e+001
5.4468085e+001
5.5652174e+001
5.4700855e+001
5.4700855e+001
5.4935622e+001
5.4700855e+001
5.4700855e+001
5.4468085e+001
5.4468085e+001
5.4468085e+001
5.4468085e+001
5.3333333e+001
5.1405622e+001
5.0996016e+001
5.0000000e+001
4.8120301e+001
4.8669202e+001
4.7058824e+001
4.6376812e+001
4.5070423e+001
4.4912281e+001
4.4137931e+001
4.2809365e+001
4.2666667e+001
4.2105263e+001
4.1423948e+001
4.1290323e+001
4.1290323e+001
4.1290323e+001
4.0634921e+001
4.0634921e+001
4.0634921e+001
4.0634921e+001
4.0764331e+001
4.1423948e+001
4.2953020e+001
4.5551601e+001
1.7534247e+002
4.7232472e+001
1.3763441e+002
1.3061224e+002
4.5551601e+001
4.3686007e+001
4.8669202e+001
9.4117647e+001
8.1012658e+001
1.1228070e+002
1.3617021e+002
4.3097643e+001
4.3835616e+001
4.6376812e+001
4.6545455e+001
4.6043165e+001
4.8301887e+001
4.9042146e+001
4.9420849e+001
5.1200000e+001
5.1405622e+001
5.2244898e+001
1.2929293e+002
1.2929293e+002
1.5238095e+002
1.5238095e+002
1.3913043e+002
9.0140845e+001
1.0940171e+002
9.0140845e+001
1.2307692e+002
8.9510490e+001
6.9565217e+001
7.3142857e+001
1.1034483e+002
7.8048780e+001
7.2727273e+001
1.0078740e+002
1.0940171e+002
1.1743119e+002
8.7074830e+001
1.8550725e+002
6.5306122e+001
1.3617021e+002
5.2674897e+001
1.0940171e+002
1.5238095e+002
1.4065934e+002
1.0756303e+002
1.0406504e+002
5.0793651e+001
4.9420849e+001
4.4444444e+001
7.0329670e+001
7.2727273e+001
7.4418605e+001
1.1636364e+002
1.0406504e+002
1.2307692e+002
1.2549020e+002
1.7297297e+002
4.5878136e+001
4.9805447e+001
6.2745098e+001
9.2086331e+001
9.1428571e+001
5.7142857e+001
4.8484848e+001
4.1157556e+001
2.2857143e+001
3.0046948e+001
9.4814815e+001
5.7918552e+001
9.0140845e+001
7.4418605e+001
7.4418605e+001
5.4700855e+001
9.5522388e+001
7.4853801e+001
9.4117647e+001
9.5522388e+001
9.9224806e+001
8.1012658e+001
1.1851852e+002
6.8817204e+001
8.5906040e+001
6.7015707e+001
4.3537415e+001
6.5306122e+001
3.1295844e+001
7.5739645e+001
6.2135922e+001
9.9224806e+001
5.7657658e+001
5.2244898e+001
5.8447489e+001
0.0000000e+000
0.0000000e+000
0.0000000e+000
0.0000000e+000
0.0000000e+000
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+70
View File
@@ -0,0 +1,70 @@
#!/bin/bash
# ./menu.sh
#
# David Rowe
# Created August 2009
#
# Presents a menu of sound files, press 1 to play file1, 2 to play file2 etc
#
# The aim is to make comparing files with different processing easier than
# using up-arrow on the command line. Based on cdialog.
#
# usage:
# menu.sh file1.raw file2.raw ........ [-d playbackdevice]
#
# for example:
#
# ../script/menu.sh hts1a.raw hts1a_uq.raw
#
# or:
#
# ../script/menu.sh hts1a.raw hts1a_uq.raw -d /dev/dsp1
#
# Copyright (C) 2007 David Rowe
#
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
files=0
items="Q-Quit\n"
while [ ! -z "$1" ]
do
case "$1" in
-d) dsp="${1} ${2}"; shift;;
*) files=`expr 1 + $files`;
new_file=$1;
file[$files]=$new_file;
items="${items} ${files}-${new_file}\n";;
esac
shift
done
readchar=1
echo -n -e "\r" $items"- "
while [ $readchar -ne 0 ]
do
echo -n -e "\r -"
stty cbreak # or stty raw
readchar=`dd if=/dev/tty bs=1 count=1 2>/dev/null`
stty -cbreak
if [ $readchar == 'q' ] ; then
readchar=0
fi
if [ $readchar -ne 0 ] ; then
play -r 8000 -s -2 ${file[$readchar]} $dsp 2> /dev/null
fi
done
echo
+6
View File
@@ -0,0 +1,6 @@
#!/bin/sh
# Plays a raw file
# usage:
# playraw file.raw
# playraw file.raw -d /dev/dsp1 (e.g. for USB headphones)
play -r 8000 -s -2 $1 $2 $3
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
# Converts 16 bit signed short 8 kHz raw (headerless) files to wave
sox -r 8000 -s -2 $1 $2
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
# Converts wave files to raw (headerless) files
sox $1 -t raw $2
+53
View File
@@ -0,0 +1,53 @@
AM_CFLAGS = -I../src -Wall -DFLOATING_POINT -DVAR_ARRAYS
AUTOMAKE_OPTS = gnu
NAME = libcodec2
AM_CPPFLAGS = $(AM_CFLAGS)
lib_LTLIBRARIES = libcodec2.la
libcodec2_la_SOURCES = dump.c \
lpc.c \
nlp.c \
postfilter.c \
sine.c \
codec2.c \
four1.c \
interp.c \
lsp.c \
phase.c \
quantise.c \
pack.c \
codebook.c
libcodec2_la_CFLAGS = $(AM_CFLAGS)
libcodec2_la_LDFLAGS = $(LIBS)
library_includedir = $(prefix)
library_include_HEADERS = codec2.h \
defines.h \
four1.h \
interp.h \
lsp.h \
phase.h \
quantise.h \
comp.h \
dump.h \
globals.h \
lpc.h \
nlp.h \
postfilter.h \
sine.h \
codebook.h
bin_PROGRAMS = c2dec c2enc c2sim
c2dec_SOURCES = c2dec.c
c2dec_LDADD = $(lib_LTLIBRARIES)
c2dec_LDFLAGS = $(LIBS)
c2enc_SOURCES = c2enc.c
c2enc_LDADD = $(lib_LTLIBRARIES)
c2enc_LDFLAGS = $(LIBS)
c2sim_SOURCES = c2sim.c
c2sim_LDADD = $(lib_LTLIBRARIES)
c2sim_LDFLAGS = $(LIBS)
+80
View File
@@ -0,0 +1,80 @@
/*---------------------------------------------------------------------------*\
FILE........: c2dec.c
AUTHOR......: David Rowe
DATE CREATED: 23/8/2010
Decodes a file of bits to a file of raw speech samples using codec2. Demo
program for codec2.
NOTE: the bit file is not packed, 51 bits/frame actually consumes 51
bytes/frame on disk. If you are using this for a real world
application you may want to pack the 51 bytes into 7 bytes.
\*---------------------------------------------------------------------------*/
/*
Copyright (C) 2010 David Rowe
All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 2.1, as
published by the Free Software Foundation. This program is
distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "codec2.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
int main(int argc, char *argv[])
{
static const int bitsSize = ((CODEC2_BITS_PER_FRAME + 7) / 8);
void *codec2;
FILE *fin;
FILE *fout;
short buf[CODEC2_SAMPLES_PER_FRAME];
unsigned char bits[bitsSize];
if (argc != 3) {
printf("usage: %s InputBitFile OutputRawSpeechFile\n", argv[0]);
exit(1);
}
if ( (fin = fopen(argv[1],"rb")) == NULL ) {
fprintf(stderr, "Error opening input bit file: %s: %s.\n",
argv[1], strerror(errno));
exit(1);
}
if ( (fout = fopen(argv[2],"wb")) == NULL ) {
fprintf(stderr, "Error opening output speech file: %s: %s.\n",
argv[2], strerror(errno));
exit(1);
}
codec2 = codec2_create();
while(fread(bits, sizeof(char), bitsSize, fin) == bitsSize) {
codec2_decode(codec2, buf, bits);
fwrite(buf, sizeof(short), CODEC2_SAMPLES_PER_FRAME, fout);
}
codec2_destroy(codec2);
fclose(fin);
fclose(fout);
return 0;
}
+82
View File
@@ -0,0 +1,82 @@
/*---------------------------------------------------------------------------*\
FILE........: c2enc.c
AUTHOR......: David Rowe
DATE CREATED: 23/8/2010
Encodes a file of raw speech samples using codec2 and ouputs a file
of bits (each bit is stored in the LSB or each output byte). Demo
program for codec2.
NOTE: the bit file is not packed, 51 bits/frame actually consumes 51
bytes/frame on disk. If you are using this for a real world
application you may want to pack the 51 bytes into 7 bytes.
\*---------------------------------------------------------------------------*/
/*
Copyright (C) 2010 David Rowe
All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 2.1, as
published by the Free Software Foundation. This program is
distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "codec2.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
int main(int argc, char *argv[])
{
static const int bitsSize = ((CODEC2_BITS_PER_FRAME + 7) / 8);
void *codec2;
FILE *fin;
FILE *fout;
short buf[CODEC2_SAMPLES_PER_FRAME];
unsigned char bits[bitsSize];
if (argc != 3) {
printf("usage: %s InputRawspeechFile OutputBitFile\n", argv[0]);
exit(1);
}
if ( (fin = fopen(argv[1],"rb")) == NULL ) {
fprintf(stderr, "Error opening input bit file: %s: %s.\n",
argv[1], strerror(errno));
exit(1);
}
if ( (fout = fopen(argv[2],"wb")) == NULL ) {
fprintf(stderr, "Error opening output speech file: %s: %s.\n",
argv[2], strerror(errno));
exit(1);
}
codec2 = codec2_create();
while(fread(buf, sizeof(short), CODEC2_SAMPLES_PER_FRAME, fin) ==
CODEC2_SAMPLES_PER_FRAME) {
codec2_encode(codec2, bits, buf);
fwrite(bits, sizeof(char), bitsSize, fout);
}
codec2_destroy(codec2);
fclose(fin);
fclose(fout);
return 0;
}
+408
View File
@@ -0,0 +1,408 @@
/*---------------------------------------------------------------------------*\
FILE........: c2sim.c
AUTHOR......: David Rowe
DATE CREATED: 20/8/2010
Codec2 simulation. Combines encoder and decoder and allows switching in
out various algorithms and quantisation steps.
\*---------------------------------------------------------------------------*/
/*
Copyright (C) 2009 David Rowe
All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 2.1, as
published by the Free Software Foundation. This program is
distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <math.h>
#include "defines.h"
#include "sine.h"
#include "nlp.h"
#include "dump.h"
#include "lpc.h"
#include "lsp.h"
#include "quantise.h"
#include "phase.h"
#include "postfilter.h"
#include "interp.h"
/*---------------------------------------------------------------------------*\
switch_present()
Searches the command line arguments for a "switch". If the switch is
found, returns the command line argument where it ws found, else returns
NULL.
\*---------------------------------------------------------------------------*/
int switch_present(sw,argc,argv)
register char sw[]; /* switch in string form */
register int argc; /* number of command line arguments */
register char *argv[]; /* array of command line arguments in string form */
{
register int i; /* loop variable */
for(i=1; i<argc; i++)
if (!strcmp(sw,argv[i]))
return(i);
return 0;
}
void synth_one_frame(short buf[], MODEL *model, float Sn_[], float Pn[]);
/*---------------------------------------------------------------------------*\
MAIN
\*---------------------------------------------------------------------------*/
int main(int argc, char *argv[])
{
FILE *fout; /* output speech file */
FILE *fin; /* input speech file */
short buf[N]; /* input/output buffer */
float Sn[M]; /* float input speech samples */
COMP Sw[FFT_ENC]; /* DFT of Sn[] */
float w[M]; /* time domain hamming window */
COMP W[FFT_ENC]; /* DFT of w[] */
MODEL model;
float Pn[2*N]; /* trapezoidal synthesis window */
float Sn_[2*N]; /* synthesised speech */
int i; /* loop variable */
int frames;
float prev_Wo;
float pitch;
int voiced1;
char out_file[MAX_STR];
int arg;
float snr;
float sum_snr;
int lpc_model, order;
int lsp, lsp_quantiser;
float ak[LPC_MAX];
COMP Sw_[FFT_ENC];
int dump;
int phase0;
float ex_phase[MAX_AMP+1];
int postfilt;
float bg_est;
int hand_voicing;
FILE *fvoicing;
MODEL prev_model, interp_model;
int decimate;
void *nlp_states;
for(i=0; i<M; i++)
Sn[i] = 1.0;
for(i=0; i<2*N; i++)
Sn_[i] = 0;
prev_Wo = TWO_PI/P_MAX;
prev_model.Wo = TWO_PI/P_MIN;
prev_model.L = floor(PI/prev_model.Wo);
for(i=1; i<=prev_model.L; i++) {
prev_model.A[i] = 0.0;
prev_model.phi[i] = 0.0;
}
for(i=1; i<=MAX_AMP; i++) {
ex_phase[i] = 0.0;
}
nlp_states = nlp_create();
if (argc < 2) {
fprintf(stderr, "\nCodec2 - 2400 bit/s speech codec - Simulation Program\n"
"\thttp://rowetel.com/codec2.html\n\n"
"usage: %s InputFile [-o OutputFile]\n"
"\t[-o lpc Order]\n"
"\t[--lsp]\n"
"\t[--phase0]\n"
"\t[--postfilter]\n"
"\t[--hand_voicing]\n"
"\t[--dec]\n"
"\t[--dump DumpFilePrefix]\n", argv[0]);
exit(1);
}
/* Interpret command line arguments -------------------------------------*/
/* Input file */
if ((fin = fopen(argv[1],"rb")) == NULL) {
fprintf(stderr, "Error opening input bit file: %s: %s.\n",
argv[1], strerror(errno));
exit(1);
}
/* Output file */
if ((arg = switch_present("-o",argc,argv))) {
if ((fout = fopen(argv[arg+1],"wb")) == NULL) {
fprintf(stderr, "Error opening output speech file: %s: %s.\n",
argv[arg+1], strerror(errno));
exit(1);
}
strcpy(out_file,argv[arg+1]);
}
else
fout = NULL;
lpc_model = 0;
if ((arg = switch_present("--lpc",argc,argv))) {
lpc_model = 1;
order = atoi(argv[arg+1]);
if ((order < 4) || (order > 20)) {
fprintf(stderr, "Error in lpc order: %d\n", order);
exit(1);
}
}
dump = switch_present("--dump",argc,argv);
if (dump)
dump_on(argv[dump+1]);
lsp = switch_present("--lsp",argc,argv);
lsp_quantiser = 0;
phase0 = switch_present("--phase0",argc,argv);
if (phase0) {
ex_phase[0] = 0;
}
hand_voicing = switch_present("--hand_voicing",argc,argv);
if (hand_voicing) {
fvoicing = fopen(argv[hand_voicing+1],"rt");
assert(fvoicing != NULL);
}
bg_est = 0.0;
postfilt = switch_present("--postfilter",argc,argv);
decimate = switch_present("--dec",argc,argv);
/* Initialise ------------------------------------------------------------*/
make_analysis_window(w,W);
make_synthesis_window(Pn);
quantise_init();
/* Main loop ------------------------------------------------------------*/
frames = 0;
sum_snr = 0;
while(fread(buf,sizeof(short),N,fin)) {
frames++;
/* Read input speech */
for(i=0; i<M-N; i++)
Sn[i] = Sn[i+N];
for(i=0; i<N; i++)
Sn[i+M-N] = buf[i];
/* Estimate pitch */
nlp(nlp_states,Sn,N,M,P_MIN,P_MAX,&pitch,Sw,&prev_Wo);
prev_Wo = TWO_PI/pitch;
model.Wo = TWO_PI/pitch;
/* estimate model parameters */
dft_speech(Sw, Sn, w);
two_stage_pitch_refinement(&model, Sw);
estimate_amplitudes(&model, Sw, W);
dump_Sn(Sn); dump_Sw(Sw); dump_model(&model);
/* optional zero-phase modelling */
if (phase0) {
float Wn[M]; /* windowed speech samples */
float Rk[LPC_ORD+1]; /* autocorrelation coeffs */
dump_phase(&model.phi[0], model.L);
/* find aks here, these are overwritten if LPC modelling is enabled */
for(i=0; i<M; i++)
Wn[i] = Sn[i]*w[i];
autocorrelate(Wn,Rk,M,LPC_ORD);
levinson_durbin(Rk,ak,LPC_ORD);
if (lpc_model)
assert(order == LPC_ORD);
dump_ak(ak, LPC_ORD);
/* determine voicing */
snr = est_voicing_mbe(&model, Sw, W, (FS/TWO_PI)*model.Wo, Sw_);
dump_Sw_(Sw_);
dump_snr(snr);
/* just to make sure we are not cheating - kill all phases */
for(i=0; i<MAX_AMP; i++)
model.phi[i] = 0;
if (hand_voicing) {
fscanf(fvoicing,"%d\n",&model.voiced);
}
}
/* optional LPC model amplitudes */
if (lpc_model) {
int lpc_correction;
float e;
float lsps[LPC_ORD];
int lsp_indexes[LPC_ORD];
e = speech_to_uq_lsps(lsps, ak, Sn, w, order);
lpc_correction = need_lpc_correction(&model, ak, e);
if (lsp) {
encode_lsps(lsp_indexes, lsps, LPC_ORD);
/*
for(i=0; i<LPC_ORD; i++)
printf("lsps[%d] = %f lsp_indexes[%d] = %d\n",
i, lsps[i], i, lsp_indexes[i]);
printf("\n");
*/
decode_lsps(lsps, lsp_indexes, LPC_ORD);
bw_expand_lsps(lsps, LPC_ORD);
lsp_to_lpc(lsps, ak, LPC_ORD);
}
e = decode_energy(encode_energy(e));
model.Wo = decode_Wo(encode_Wo(model.Wo));
aks_to_M2(ak, order, &model, e, &snr, 1);
apply_lpc_correction(&model, lpc_correction);
sum_snr += snr;
dump_quantised_model(&model);
}
/* option decimation to 20ms rate, which enables interpolation
routine to synthesise in between frame */
if (decimate) {
if (!phase0) {
printf("needs --phase0 to resample phase for interpolated Wo\n");
exit(0);
}
/* odd frame - interpolate */
if (frames%2) {
#ifdef TEST
model.voiced = 1;
prev_model.voiced = 1;
if (fabs(prev_model.Wo - model.Wo) < 0.1*model.Wo) {
interp_model.voiced = 1;
interpolate(&interp_model, &prev_model, &model);
for(i=0; i<=interp_model.L; i++) {
interp_model.phi[i] = phi1[i];
}
printf("interp\n");
}
else
interp_model = tmp_model;
#endif
interp_model.voiced = voiced1;
interpolate(&interp_model, &prev_model, &model);
if (phase0)
phase_synth_zero_order(&interp_model, ak, ex_phase);
if (postfilt)
postfilter(&interp_model, &bg_est);
synth_one_frame(buf, &interp_model, Sn_, Pn);
if (fout != NULL) fwrite(buf,sizeof(short),N,fout);
if (phase0)
phase_synth_zero_order(&model, ak, ex_phase);
if (postfilt)
postfilter(&model, &bg_est);
synth_one_frame(buf, &model, Sn_, Pn);
if (fout != NULL) fwrite(buf,sizeof(short),N,fout);
prev_model = model;
}
else {
voiced1 = model.voiced;
}
}
else {
if (phase0)
phase_synth_zero_order(&model, ak, ex_phase);
if (postfilt)
postfilter(&model, &bg_est);
synth_one_frame(buf, &model, Sn_, Pn);
if (fout != NULL) fwrite(buf,sizeof(short),N,fout);
}
}
if (fout != NULL)
fclose(fout);
if (lpc_model)
printf("SNR av = %5.2f dB\n", sum_snr/frames);
if (dump)
dump_off();
if (hand_voicing)
fclose(fvoicing);
nlp_destroy(nlp_states);
return 0;
}
void synth_one_frame(short buf[], MODEL *model, float Sn_[], float Pn[])
{
int i;
synthesise(Sn_, model, Pn, 1);
for(i=0; i<N; i++) {
if (Sn_[i] > 32767.0)
buf[i] = 32767;
else if (Sn_[i] < -32767.0)
buf[i] = -32767;
else
buf[i] = Sn_[i];
}
}
+9
View File
@@ -0,0 +1,9 @@
#!/bin/sh
# codeall.sh
# David Rowe 24 sep 2009
# Code all samples using various processing steps
./code.sh hts1a
./code.sh hts2a
./code.sh mmt1
./code.sh morig
./code.sh forig
+162
View File
@@ -0,0 +1,162 @@
float codebook_lsp1[] = {
225,
250,
275,
300,
325,
350,
375,
400,
425,
450,
475,
500,
525,
550,
575,
600,0,0,0,0,0,0,0,0,0,0
};
float codebook_lsp2[] = {
325,
350,
375,
400,
425,
450,
475,
500,
525,
550,
575,
600,
625,
650,
675,
700,0,0,0,0,0,0,0,0,0,0
};
float codebook_lsp3[] = {
500,
550,
600,
650,
700,
750,
800,
850,
900,
950,
1000,
1050,
1100,
1150,
1200,
1250,0,0,0,0,0,0,0,0,0,0
};
float codebook_lsp4[] = {
700,
800,
900,
1000,
1100,
1200,
1300,
1400,
1500,
1600,
1700,
1800,
1900,
2000,
2100,
2200,0,0,0,0,0,0,0,0,0,0
};
float codebook_lsp5[] = {
950,
1050,
1150,
1250,
1350,
1450,
1550,
1650,
1750,
1850,
1950,
2050,
2150,
2250,
2350,
2450,0,0,0,0,0,0,0,0,0,0
};
float codebook_lsp6[] = {
1100,
1200,
1300,
1400,
1500,
1600,
1700,
1800,
1900,
2000,
2100,
2200,
2300,
2400,
2500,
2600,0,0,0,0,0,0,0,0,0,0
};
float codebook_lsp7[] = {
1500,
1600,
1700,
1800,
1900,
2000,
2100,
2200,
2300,
2400,
2500,
2600,
2700,
2800,
2900,
3000,0,0,0,0,0,0,0,0,0,0
};
float codebook_lsp8[] = {
2300,
2400,
2500,
2600,
2700,
2800,
2900,
3000,0,0,0,0,0,0,0,0,0,0
};
float codebook_lsp9[] = {
2500,
2600,
2700,
2800,
2900,
3000,
3100,
3200,0,0,0,0,0,0,0,0,0,0
};
float codebook_lsp10[] = {
2900,
3100,
3300,
3500,0,0,0,0,0,0,0,0,0,0
};
+15
View File
@@ -0,0 +1,15 @@
#ifndef CODEBOOK_H
#define CODEBOOK_H
extern float codebook_lsp1[];
extern float codebook_lsp2[];
extern float codebook_lsp3[];
extern float codebook_lsp4[];
extern float codebook_lsp5[];
extern float codebook_lsp6[];
extern float codebook_lsp7[];
extern float codebook_lsp8[];
extern float codebook_lsp9[];
extern float codebook_lsp10[];
#endif
+337
View File
@@ -0,0 +1,337 @@
/*---------------------------------------------------------------------------*\
FILE........: codec2.c
AUTHOR......: David Rowe
DATE CREATED: 21/8/2010
Codec2 fully quantised encoder and decoder functions. If you want use
codec2, the codec2_xxx functions are for you.
\*---------------------------------------------------------------------------*/
/*
Copyright (C) 2010 David Rowe
All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 2.1, as
published by the Free Software Foundation. This program is
distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "defines.h"
#include "sine.h"
#include "nlp.h"
#include "dump.h"
#include "lpc.h"
#include "quantise.h"
#include "phase.h"
#include "interp.h"
#include "postfilter.h"
#include "codec2.h"
typedef struct {
float Sn[M]; /* input speech */
float w[M]; /* time domain hamming window */
COMP W[FFT_ENC]; /* DFT of w[] */
float Pn[2*N]; /* trapezoidal synthesis window */
float Sn_[2*N]; /* synthesised speech */
float prev_Wo; /* previous frame's pitch estimate */
float ex_phase; /* excitation model phase track */
float bg_est; /* background noise estimate for post filter */
MODEL prev_model; /* model parameters from 20ms ago */
void *nlp; /* pitch predictor states */
} CODEC2;
/*---------------------------------------------------------------------------*\
FUNCTION HEADERS
\*---------------------------------------------------------------------------*/
void analyse_one_frame(CODEC2 *c2, MODEL *model, short speech[]);
void synthesise_one_frame(CODEC2 *c2, short speech[], MODEL *model,float ak[]);
/*---------------------------------------------------------------------------*\
FUNCTIONS
\*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*\
FUNCTION....: codec2_create
AUTHOR......: David Rowe
DATE CREATED: 21/8/2010
Create and initialise an instance of the codec. Returns a pointer
to the codec states or NULL on failure. One set of states is
sufficient for a full duuplex codec (i.e. an encoder and decoder).
You don't need separate states for encoders and decoders. See
c2enc.c and c2dec.c for examples.
\*---------------------------------------------------------------------------*/
void *codec2_create()
{
CODEC2 *c2;
int i,l;
c2 = (CODEC2*)malloc(sizeof(CODEC2));
if (c2 == NULL)
return NULL;
for(i=0; i<M; i++)
c2->Sn[i] = 1.0;
for(i=0; i<2*N; i++)
c2->Sn_[i] = 0;
make_analysis_window(c2->w,c2->W);
make_synthesis_window(c2->Pn);
quantise_init();
c2->prev_Wo = 0.0;
c2->bg_est = 0.0;
c2->ex_phase = 0.0;
for(l=1; l<=MAX_AMP; l++)
c2->prev_model.A[l] = 0.0;
c2->prev_model.Wo = TWO_PI/P_MAX;
c2->nlp = nlp_create();
if (c2->nlp == NULL) {
free (c2);
return NULL;
}
return (void*)c2;
}
/*---------------------------------------------------------------------------*\
FUNCTION....: codec2_create
AUTHOR......: David Rowe
DATE CREATED: 21/8/2010
Destroy an instance of the codec.
\*---------------------------------------------------------------------------*/
void codec2_destroy(void *codec2_state)
{
CODEC2 *c2;
assert(codec2_state != NULL);
c2 = (CODEC2*)codec2_state;
nlp_destroy(c2->nlp);
free(codec2_state);
}
/*---------------------------------------------------------------------------*\
FUNCTION....: codec2_encode
AUTHOR......: David Rowe
DATE CREATED: 21/8/2010
Encodes 160 speech samples (20ms of speech) into 51 bits.
The codec2 algorithm actually operates internally on 10ms (80
sample) frames, so we run the encoding algorithm twice. On the
first frame we just send the voicing bit. One the second frame we
send all model parameters.
The bit allocation is:
Parameter bits/frame
--------------------------------------
Harmonic magnitudes (LSPs) 36
Low frequency LPC correction 1
Energy 5
Wo (fundamental frequnecy) 7
Voicing (10ms update) 2
TOTAL 51
\*---------------------------------------------------------------------------*/
void codec2_encode(void *codec2_state, unsigned char * bits, short speech[])
{
CODEC2 *c2;
MODEL model;
int voiced1, voiced2;
int lsp_indexes[LPC_ORD];
int lpc_correction;
int energy_index;
int Wo_index;
int i;
unsigned int nbit = 0;
assert(codec2_state != NULL);
c2 = (CODEC2*)codec2_state;
/* first 10ms analysis frame - we just want voicing */
analyse_one_frame(c2, &model, speech);
voiced1 = model.voiced;
/* second 10ms analysis frame */
analyse_one_frame(c2, &model, &speech[N]);
voiced2 = model.voiced;
Wo_index = encode_Wo(model.Wo);
encode_amplitudes(lsp_indexes,
&lpc_correction,
&energy_index,
&model,
c2->Sn,
c2->w);
memset(bits, '\0', ((CODEC2_BITS_PER_FRAME + 7) / 8));
pack(bits, &nbit, Wo_index, WO_BITS);
for(i=0; i<LPC_ORD; i++) {
pack(bits, &nbit, lsp_indexes[i], lsp_bits(i));
}
pack(bits, &nbit, lpc_correction, 1);
pack(bits, &nbit, energy_index, E_BITS);
pack(bits, &nbit, voiced1, 1);
pack(bits, &nbit, voiced2, 1);
assert(nbit == CODEC2_BITS_PER_FRAME);
}
/*---------------------------------------------------------------------------*\
FUNCTION....: codec2_decode
AUTHOR......: David Rowe
DATE CREATED: 21/8/2010
Decodes frames of 51 bits into 160 samples (20ms) of speech.
\*---------------------------------------------------------------------------*/
void codec2_decode(void *codec2_state, short speech[],
const unsigned char * bits)
{
CODEC2 *c2;
MODEL model;
int voiced1, voiced2;
int lsp_indexes[LPC_ORD];
int lpc_correction;
int energy_index;
int Wo_index;
float ak[LPC_ORD+1];
int i;
unsigned int nbit = 0;
MODEL model_interp;
assert(codec2_state != NULL);
c2 = (CODEC2*)codec2_state;
Wo_index = unpack(bits, &nbit, WO_BITS);
for(i=0; i<LPC_ORD; i++) {
lsp_indexes[i] = unpack(bits, &nbit, lsp_bits(i));
}
lpc_correction = unpack(bits, &nbit, 1);
energy_index = unpack(bits, &nbit, E_BITS);
voiced1 = unpack(bits, &nbit, 1);
voiced2 = unpack(bits, &nbit, 1);
assert(nbit == CODEC2_BITS_PER_FRAME);
model.Wo = decode_Wo(Wo_index);
model.L = PI/model.Wo;
decode_amplitudes(&model,
ak,
lsp_indexes,
lpc_correction,
energy_index);
model.voiced = voiced2;
model_interp.voiced = voiced1;
interpolate(&model_interp, &c2->prev_model, &model);
synthesise_one_frame(c2, speech, &model_interp, ak);
synthesise_one_frame(c2, &speech[N], &model, ak);
memcpy(&c2->prev_model, &model, sizeof(MODEL));
}
/*---------------------------------------------------------------------------*\
FUNCTION....: synthesise_one_frame()
AUTHOR......: David Rowe
DATE CREATED: 23/8/2010
Synthesise 80 speech samples (10ms) from model parameters.
\*---------------------------------------------------------------------------*/
void synthesise_one_frame(CODEC2 *c2, short speech[], MODEL *model, float ak[])
{
int i;
phase_synth_zero_order(model, ak, &c2->ex_phase);
postfilter(model, &c2->bg_est);
synthesise(c2->Sn_, model, c2->Pn, 1);
for(i=0; i<N; i++) {
if (c2->Sn_[i] > 32767.0)
speech[i] = 32767;
else if (c2->Sn_[i] < -32767.0)
speech[i] = -32767;
else
speech[i] = c2->Sn_[i];
}
}
/*---------------------------------------------------------------------------*\
FUNCTION....: analyse_one_frame()
AUTHOR......: David Rowe
DATE CREATED: 23/8/2010
Extract sinusoidal model parameters from 80 speech samples (10ms of
speech).
\*---------------------------------------------------------------------------*/
void analyse_one_frame(CODEC2 *c2, MODEL *model, short speech[])
{
COMP Sw[FFT_ENC];
COMP Sw_[FFT_ENC];
float pitch;
int i;
/* Read input speech */
for(i=0; i<M-N; i++)
c2->Sn[i] = c2->Sn[i+N];
for(i=0; i<N; i++)
c2->Sn[i+M-N] = speech[i];
dft_speech(Sw, c2->Sn, c2->w);
/* Estimate pitch */
nlp(c2->nlp,c2->Sn,N,M,P_MIN,P_MAX,&pitch,Sw,&c2->prev_Wo);
c2->prev_Wo = TWO_PI/pitch;
model->Wo = TWO_PI/pitch;
model->L = PI/model->Wo;
/* estimate model parameters */
dft_speech(Sw, c2->Sn, c2->w);
two_stage_pitch_refinement(model, Sw);
estimate_amplitudes(model, Sw, c2->W);
est_voicing_mbe(model, Sw, c2->W, (FS/TWO_PI)*model->Wo, Sw_);
}
+43
View File
@@ -0,0 +1,43 @@
/*---------------------------------------------------------------------------*\
FILE........: codec2.h
AUTHOR......: David Rowe
DATE CREATED: 21/8/2010
Codec2 fully quantised encoder and decoder functions. If you want use
codec2, these are the functions you need to call.
\*---------------------------------------------------------------------------*/
/*
Copyright (C) 2010 David Rowe
All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 2.1, as
published by the Free Software Foundation. This program is
distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __CODEC2__
#define __CODEC2__
#include "codebook.h"
#define CODEC2_SAMPLES_PER_FRAME 160
#define CODEC2_BITS_PER_FRAME 51
void *codec2_create();
void codec2_destroy(void *codec2_state);
void codec2_encode(void *codec2_state, unsigned char * bits, short speech_in[]);
void codec2_decode(void *codec2_state, short speech_out[],
const unsigned char * bits);
#endif
+39
View File
@@ -0,0 +1,39 @@
/*---------------------------------------------------------------------------*\
FILE........: comp.h
AUTHOR......: David Rowe
DATE CREATED: 24/08/09
Complex number definition.
\*---------------------------------------------------------------------------*/
/*
Copyright (C) 2009 David Rowe
All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 2.1, as
published by the Free Software Foundation. This program is
distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __COMP__
#define __COMP__
/* Complex number */
typedef struct {
float real;
float imag;
} COMP;
#endif
+84
View File
@@ -0,0 +1,84 @@
/*---------------------------------------------------------------------------*\
FILE........: defines.h
AUTHOR......: David Rowe
DATE CREATED: 23/4/93
Defines and structures used throughout the codec.
\*---------------------------------------------------------------------------*/
/*
Copyright (C) 2009 David Rowe
All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 2.1, as
published by the Free Software Foundation. This program is
distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __DEFINES__
#define __DEFINES__
/*---------------------------------------------------------------------------*\
DEFINES
\*---------------------------------------------------------------------------*/
/* General defines */
#define N 80 /* number of samples per frame */
#define MAX_AMP 80 /* maximum number of harmonics */
#define PI 3.141592654 /* mathematical constant */
#define TWO_PI 6.283185307 /* mathematical constant */
#define FS 8000 /* sample rate in Hz */
#define MAX_STR 256 /* maximum string size */
#define NW 279 /* analysis window size */
#define FFT_ENC 512 /* size of FFT used for encoder */
#define FFT_DEC 512 /* size of FFT used in decoder */
#define TW 40 /* Trapezoidal synthesis window overlap */
#define V_THRESH 4.0 /* voicing threshold in dB */
#define LPC_MAX 20 /* maximum LPC order */
#define LPC_ORD 10 /* phase modelling LPC order */
/* Pitch estimation defines */
#define M 320 /* pitch analysis frame size */
#define P_MIN 20 /* minimum pitch */
#define P_MAX 160 /* maximum pitch */
/*---------------------------------------------------------------------------*\
TYPEDEFS
\*---------------------------------------------------------------------------*/
/* Complex number */
typedef struct {
float real;
float imag;
} COMP;
/* Structure to hold model parameters for one frame */
typedef struct {
float Wo; /* fundamental frequency estimate in radians */
int L; /* number of harmonics */
float A[MAX_AMP]; /* amplitiude of each harmonic */
float phi[MAX_AMP]; /* phase of each harmonic */
int voiced; /* non-zero if this frame is voiced */
} MODEL;
#endif
+402
View File
@@ -0,0 +1,402 @@
/*---------------------------------------------------------------------------*\
FILE........: dump.c
AUTHOR......: David Rowe
DATE CREATED: 25/8/09
Routines to dump data to text files for Octave analysis.
\*---------------------------------------------------------------------------*/
/*
All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 2.1, as
published by the Free Software Foundation. This program is
distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "defines.h"
#include "dump.h"
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
static int dumpon = 0;
static FILE *fsn = NULL;
static FILE *fsw = NULL;
static FILE *fsw_ = NULL;
static FILE *fmodel = NULL;
static FILE *fqmodel = NULL;
static FILE *fpw = NULL;
static FILE *flsp = NULL;
static FILE *fphase = NULL;
static FILE *fphase_ = NULL;
static FILE *ffw = NULL;
static FILE *fe = NULL;
static FILE *fsq = NULL;
static FILE *fdec = NULL;
static FILE *fsnr = NULL;
static FILE *fak = NULL;
static FILE *fbg = NULL;
static FILE *fE = NULL;
static char prefix[MAX_STR];
void dump_on(char p[]) {
dumpon = 1;
strcpy(prefix, p);
}
void dump_off(){
if (fsn != NULL)
fclose(fsn);
if (fsw != NULL)
fclose(fsw);
if (fsw_ != NULL)
fclose(fsw_);
if (fmodel != NULL)
fclose(fmodel);
if (fqmodel != NULL)
fclose(fqmodel);
if (fpw != NULL)
fclose(fpw);
if (flsp != NULL)
fclose(flsp);
if (fphase != NULL)
fclose(fphase);
if (fphase_ != NULL)
fclose(fphase_);
if (ffw != NULL)
fclose(ffw);
if (fe != NULL)
fclose(fe);
if (fsq != NULL)
fclose(fsq);
if (fdec != NULL)
fclose(fdec);
if (fsnr != NULL)
fclose(fsnr);
if (fak != NULL)
fclose(fak);
if (fbg != NULL)
fclose(fbg);
if (fE != NULL)
fclose(fE);
}
void dump_Sn(float Sn[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fsn == NULL) {
sprintf(s,"%s_sn.txt", prefix);
fsn = fopen(s, "wt");
assert(fsn != NULL);
}
/* split across two lines to avoid max line length problems */
/* reconstruct in Octave */
for(i=0; i<M/2; i++)
fprintf(fsn,"%f\t",Sn[i]);
fprintf(fsn,"\n");
for(i=M/2; i<M; i++)
fprintf(fsn,"%f\t",Sn[i]);
fprintf(fsn,"\n");
}
void dump_Sw(COMP Sw[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fsw == NULL) {
sprintf(s,"%s_sw.txt", prefix);
fsw = fopen(s, "wt");
assert(fsw != NULL);
}
for(i=0; i<FFT_ENC/2; i++)
fprintf(fsw,"%f\t",
10.0*log10(Sw[i].real*Sw[i].real + Sw[i].imag*Sw[i].imag));
fprintf(fsw,"\n");
}
void dump_Sw_(COMP Sw_[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fsw_ == NULL) {
sprintf(s,"%s_sw_.txt", prefix);
fsw_ = fopen(s, "wt");
assert(fsw_ != NULL);
}
for(i=0; i<FFT_ENC/2; i++)
fprintf(fsw_,"%f\t",
10.0*log10(Sw_[i].real*Sw_[i].real + Sw_[i].imag*Sw_[i].imag));
fprintf(fsw_,"\n");
}
void dump_model(MODEL *model) {
int l;
char s[MAX_STR];
if (!dumpon) return;
if (fmodel == NULL) {
sprintf(s,"%s_model.txt", prefix);
fmodel = fopen(s, "wt");
assert(fmodel != NULL);
}
fprintf(fmodel,"%f\t%d\t", model->Wo, model->L);
for(l=1; l<=model->L; l++)
fprintf(fmodel,"%f\t",model->A[l]);
for(l=model->L+1; l<MAX_AMP; l++)
fprintf(fmodel,"0.0\t");
fprintf(fmodel,"%d\t",model->voiced);
fprintf(fmodel,"\n");
}
void dump_quantised_model(MODEL *model) {
int l;
char s[MAX_STR];
if (!dumpon) return;
if (fqmodel == NULL) {
sprintf(s,"%s_qmodel.txt", prefix);
fqmodel = fopen(s, "wt");
assert(fqmodel != NULL);
}
fprintf(fqmodel,"%f\t%d\t", model->Wo, model->L);
for(l=1; l<=model->L; l++)
fprintf(fqmodel,"%f\t",model->A[l]);
for(l=model->L+1; l<MAX_AMP; l++)
fprintf(fqmodel,"0.0\t");
fprintf(fqmodel,"\n");
}
void dump_phase(float phase[], int L) {
int l;
char s[MAX_STR];
if (!dumpon) return;
if (fphase == NULL) {
sprintf(s,"%s_phase.txt", prefix);
fphase = fopen(s, "wt");
assert(fphase != NULL);
}
for(l=1; l<=L; l++)
fprintf(fphase,"%f\t",phase[l]);
for(l=L+1; l<MAX_AMP; l++)
fprintf(fphase,"%f\t",0.0);
fprintf(fphase,"\n");
}
void dump_phase_(float phase_[], int L) {
int l;
char s[MAX_STR];
if (!dumpon) return;
if (fphase_ == NULL) {
sprintf(s,"%s_phase_.txt", prefix);
fphase_ = fopen(s, "wt");
assert(fphase_ != NULL);
}
for(l=1; l<=L; l++)
fprintf(fphase_,"%f\t",phase_[l]);
for(l=L+1; l<MAX_AMP; l++)
fprintf(fphase_,"%f\t",0.0);
fprintf(fphase_,"\n");
}
void dump_snr(float snr) {
char s[MAX_STR];
if (!dumpon) return;
if (fsnr == NULL) {
sprintf(s,"%s_snr.txt", prefix);
fsnr = fopen(s, "wt");
assert(fsnr != NULL);
}
fprintf(fsnr,"%f\n",snr);
}
void dump_Pw(COMP Pw[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fpw == NULL) {
sprintf(s,"%s_pw.txt", prefix);
fpw = fopen(s, "wt");
assert(fpw != NULL);
}
for(i=0; i<FFT_DEC/2; i++)
fprintf(fpw,"%f\t",Pw[i].real);
fprintf(fpw,"\n");
}
void dump_lsp(float lsp[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (flsp == NULL) {
sprintf(s,"%s_lsp.txt", prefix);
flsp = fopen(s, "wt");
assert(flsp != NULL);
}
for(i=0; i<10; i++)
fprintf(flsp,"%f\t",lsp[i]);
fprintf(flsp,"\n");
}
void dump_ak(float ak[], int order) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fak == NULL) {
sprintf(s,"%s_ak.txt", prefix);
fak = fopen(s, "wt");
assert(fak != NULL);
}
for(i=0; i<=order; i++)
fprintf(fak,"%f\t",ak[i]);
fprintf(fak,"\n");
}
void dump_Fw(COMP Fw[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (ffw == NULL) {
sprintf(s,"%s_fw.txt", prefix);
ffw = fopen(s, "wt");
assert(ffw != NULL);
}
for(i=0; i<256; i++)
fprintf(ffw,"%f\t",Fw[i].real);
fprintf(ffw,"\n");
}
void dump_e(float e_hz[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fe == NULL) {
sprintf(s,"%s_e.txt", prefix);
fe = fopen(s, "wt");
assert(fe != NULL);
}
for(i=0; i<500/2; i++)
fprintf(fe,"%f\t",e_hz[i]);
fprintf(fe,"\n");
for(i=500/2; i<500; i++)
fprintf(fe,"%f\t",e_hz[i]);
fprintf(fe,"\n");
}
void dump_sq(float sq[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fsq == NULL) {
sprintf(s,"%s_sq.txt", prefix);
fsq = fopen(s, "wt");
assert(fsq != NULL);
}
for(i=0; i<M/2; i++)
fprintf(fsq,"%f\t",sq[i]);
fprintf(fsq,"\n");
for(i=M/2; i<M; i++)
fprintf(fsq,"%f\t",sq[i]);
fprintf(fsq,"\n");
}
void dump_dec(COMP Fw[]) {
int i;
char s[MAX_STR];
if (!dumpon) return;
if (fdec == NULL) {
sprintf(s,"%s_dec.txt", prefix);
fdec = fopen(s, "wt");
assert(fdec != NULL);
}
for(i=0; i<320/5; i++)
fprintf(fdec,"%f\t",Fw[i].real);
fprintf(fdec,"\n");
}
void dump_bg(float e, float bg_est, float percent_uv) {
char s[MAX_STR];
if (!dumpon) return;
if (fbg == NULL) {
sprintf(s,"%s_bg.txt", prefix);
fbg = fopen(s, "wt");
assert(fbg != NULL);
}
fprintf(fbg,"%f\t%f\t%f\n", e, bg_est, percent_uv);
}
void dump_E(float E) {
char s[MAX_STR];
if (!dumpon) return;
if (fE == NULL) {
sprintf(s,"%s_E.txt", prefix);
fE = fopen(s, "wt");
assert(fE != NULL);
}
fprintf(fE,"%f\n", 10.0*log10(E));
}
Loaded 100 of 307 files, more files were not shown because too many files have changed in this diff. Show more