Restructure: Move dtmf from common code to 'libdtmf'
parent
17b34fbae6
commit
fd3a4d7ac2
|
@ -20,6 +20,7 @@ compile
|
|||
.libs
|
||||
.dirstamp
|
||||
m4
|
||||
src/libdtmf/libdtmf.a
|
||||
src/libgermanton/libgermanton.a
|
||||
src/libtimer/libtimer.a
|
||||
src/libsamplerate/libsamplerate.a
|
||||
|
|
|
@ -75,6 +75,7 @@ AS_IF([test "x$with_soapy" == "xyes"],[AC_MSG_NOTICE( Compiling with SoapySDR su
|
|||
AS_IF([test "x$somethingmagick" == "xyes"],[AC_MSG_NOTICE( Compiling with ImageMagick )],[AC_MSG_NOTICE( ImageMagick not supported )])
|
||||
|
||||
AC_OUTPUT(
|
||||
src/libdtmf/Makefile
|
||||
src/libgermanton/Makefile
|
||||
src/libtimer/Makefile
|
||||
src/libsamplerate/Makefile
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
AUTOMAKE_OPTIONS = foreign
|
||||
SUBDIRS = libgermanton libtimer libsamplerate libscrambler libfilter common anetz bnetz cnetz nmt amps tacs jtacs r2000 tv test
|
||||
SUBDIRS = libdtmf libgermanton libtimer libsamplerate libscrambler libfilter common anetz bnetz cnetz nmt amps tacs jtacs r2000 tv test
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ libcommon_a_SOURCES = \
|
|||
wave.c \
|
||||
goertzel.c \
|
||||
jitter.c \
|
||||
dtmf.c \
|
||||
emphasis.c \
|
||||
compandor.c \
|
||||
fft.c \
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
AM_CPPFLAGS = -Wall -Wextra -g $(all_includes)
|
||||
|
||||
noinst_LIBRARIES = libdtmf.a
|
||||
|
||||
libdtmf_a_SOURCES = \
|
||||
dtmf_encode.c
|
|
@ -20,19 +20,19 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "sample.h"
|
||||
#include "dtmf.h"
|
||||
#include "../common/sample.h"
|
||||
#include "dtmf_encode.h"
|
||||
|
||||
#define PI M_PI
|
||||
|
||||
static double tx_peak_dtmf_low = 0.2818 / SPEECH_LEVEL; /* -11 dBm, relative to speech level */
|
||||
static double tx_peak_dtmf_high = 0.3548 / SPEECH_LEVEL;/* -9 dBm, relative to speech level */
|
||||
#define PEAK_DTMF_LOW 0.2818 /* -11 dBm, relative to 0 dBm level */
|
||||
#define PEAK_DTMF_HIGH 0.3548 /* -9 dBm, relative to 0 dBm level */
|
||||
#define DTMF_DURATION 0.100 /* duration in seconds */
|
||||
|
||||
static sample_t dsp_sine_dtmf_low[65536];
|
||||
static sample_t dsp_sine_dtmf_high[65536];
|
||||
|
||||
void dtmf_init(dtmf_t *dtmf, int samplerate)
|
||||
void dtmf_encode_init(dtmf_enc_t *dtmf, int samplerate, double dBm_level)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -42,13 +42,13 @@ void dtmf_init(dtmf_t *dtmf, int samplerate)
|
|||
|
||||
// FIXME: do this globally and not per instance */
|
||||
for (i = 0; i < 65536; i++) {
|
||||
dsp_sine_dtmf_low[i] = sin((double)i / 65536.0 * 2.0 * PI) * tx_peak_dtmf_low;
|
||||
dsp_sine_dtmf_high[i] = sin((double)i / 65536.0 * 2.0 * PI) * tx_peak_dtmf_high;
|
||||
dsp_sine_dtmf_low[i] = sin((double)i / 65536.0 * 2.0 * PI) * PEAK_DTMF_LOW * dBm_level;
|
||||
dsp_sine_dtmf_high[i] = sin((double)i / 65536.0 * 2.0 * PI) * PEAK_DTMF_HIGH * dBm_level;
|
||||
}
|
||||
}
|
||||
|
||||
/* set dtmf tone */
|
||||
void dtmf_set_tone(dtmf_t *dtmf, char tone)
|
||||
void dtmf_encode_set_tone(dtmf_enc_t *dtmf, char tone)
|
||||
{
|
||||
double f1, f2;
|
||||
|
||||
|
@ -80,7 +80,7 @@ void dtmf_set_tone(dtmf_t *dtmf, char tone)
|
|||
}
|
||||
|
||||
/* Generate audio stream from DTMF tone. Keep phase for next call of function. */
|
||||
void dtmf_tone(dtmf_t *dtmf, sample_t *samples, int length)
|
||||
void dtmf_encode(dtmf_enc_t *dtmf, sample_t *samples, int length)
|
||||
{
|
||||
double *phaseshift, *phase;
|
||||
int i, pos, max;
|
|
@ -1,14 +1,14 @@
|
|||
|
||||
typedef struct dtmf {
|
||||
typedef struct dtmf_enc {
|
||||
int samplerate; /* samplerate */
|
||||
char tone; /* current tone to be played */
|
||||
int pos; /* sample counter for tone */
|
||||
int max; /* max number of samples for tone duration */
|
||||
double phaseshift65536[2]; /* how much the phase of sine wave changes per sample */
|
||||
double phase65536[2]; /* current phase */
|
||||
} dtmf_t;
|
||||
} dtmf_enc_t;
|
||||
|
||||
void dtmf_init(dtmf_t *dtmf, int samplerate);
|
||||
void dtmf_set_tone(dtmf_t *dtmf, char tone);
|
||||
void dtmf_tone(dtmf_t *dtmf, sample_t *samples, int length);
|
||||
void dtmf_encode_init(dtmf_enc_t *dtmf, int samplerate, double dBm_level);
|
||||
void dtmf_encode_set_tone(dtmf_enc_t *dtmf, char tone);
|
||||
void dtmf_encode(dtmf_enc_t *dtmf, sample_t *samples, int length);
|
||||
|
|
@ -22,6 +22,7 @@ nmt_SOURCES = \
|
|||
nmt_LDADD = \
|
||||
$(COMMON_LA) \
|
||||
libdmssms.a \
|
||||
$(top_builddir)/src/libdtmf/libdtmf.a \
|
||||
$(top_builddir)/src/common/libmobile.a \
|
||||
$(top_builddir)/src/common/libcommon.a \
|
||||
$(top_builddir)/src/libtimer/libtimer.a \
|
||||
|
|
|
@ -148,8 +148,8 @@ int dsp_init_sender(nmt_t *nmt, double deviation_factor)
|
|||
nmt->dial_phaseshift65536 = 65536.0 / ((double)nmt->sender.samplerate / DIALTONE_HZ);
|
||||
PDEBUG(DDSP, DEBUG_DEBUG, "dial_phaseshift = %.4f\n", nmt->dial_phaseshift65536);
|
||||
|
||||
/* dtmf */
|
||||
dtmf_init(&nmt->dtmf, 8000);
|
||||
/* dtmf, generate tone relative to speech level */
|
||||
dtmf_encode_init(&nmt->dtmf, 8000, 1.0 / SPEECH_LEVEL);
|
||||
|
||||
nmt->dmp_frame_level = display_measurements_add(&nmt->sender, "Frame Level", "%.1f %% (last)", DISPLAY_MEAS_LAST, DISPLAY_MEAS_LEFT, 0.0, 150.0, 100.0);
|
||||
nmt->dmp_frame_quality = display_measurements_add(&nmt->sender, "Frame Quality", "%.1f %% (last)", DISPLAY_MEAS_LAST, DISPLAY_MEAS_LEFT, 0.0, 100.0, 100.0);
|
||||
|
@ -342,7 +342,7 @@ void sender_receive(sender_t *sender, sample_t *samples, int length, double __at
|
|||
if (nmt->compandor)
|
||||
expand_audio(&nmt->cstate, samples, count);
|
||||
if (nmt->dsp_mode == DSP_MODE_DTMF)
|
||||
dtmf_tone(&nmt->dtmf, samples, count);
|
||||
dtmf_encode(&nmt->dtmf, samples, count);
|
||||
spl = nmt->sender.rxbuf;
|
||||
pos = nmt->sender.rxbuf_pos;
|
||||
for (i = 0; i < count; i++) {
|
||||
|
|
|
@ -1454,7 +1454,7 @@ static void rx_active(nmt_t *nmt, frame_t *frame)
|
|||
break;
|
||||
}
|
||||
digit = nmt_value2digit(frame->digit);
|
||||
dtmf_set_tone(&nmt->dtmf, digit);
|
||||
dtmf_encode_set_tone(&nmt->dtmf, digit);
|
||||
PDEBUG_CHAN(DNMT, DEBUG_INFO, "Received (odd) digit %c.\n", digit);
|
||||
nmt->mft_num++;
|
||||
break;
|
||||
|
@ -1477,7 +1477,7 @@ static void rx_active(nmt_t *nmt, frame_t *frame)
|
|||
break;
|
||||
}
|
||||
digit = nmt_value2digit(frame->digit);
|
||||
dtmf_set_tone(&nmt->dtmf, digit);
|
||||
dtmf_encode_set_tone(&nmt->dtmf, digit);
|
||||
PDEBUG_CHAN(DNMT, DEBUG_INFO, "Received (even) digit %c.\n", digit);
|
||||
nmt->mft_num++;
|
||||
break;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "../common/sender.h"
|
||||
#include "../libtimer/timer.h"
|
||||
#include "../common/compandor.h"
|
||||
#include "../common/dtmf.h"
|
||||
#include "../libdtmf/dtmf_encode.h"
|
||||
#include "../common/call.h"
|
||||
#include "../common/fsk.h"
|
||||
#include "../common/goertzel.h"
|
||||
|
@ -77,7 +77,7 @@ typedef struct nmt {
|
|||
sender_t sender;
|
||||
nmt_sysinfo_t sysinfo;
|
||||
compandor_t cstate;
|
||||
dtmf_t dtmf;
|
||||
dtmf_enc_t dtmf;
|
||||
struct transaction *trans; /* pointer to transaction, if bound to channel */
|
||||
|
||||
/* sender's states */
|
||||
|
|
Loading…
Reference in New Issue