Add parameter to DTMF decode to change frequency margin
There is no user for this yet.
This commit is contained in:
@@ -90,7 +90,7 @@ int dsp_init_sender(jolly_t *jolly, int nbfm, double squelch_db, int repeater)
|
|||||||
/* init dtmf audio processing.
|
/* init dtmf audio processing.
|
||||||
* each frequency may be +6 dB deviation, which means a total deviation of +12 dB is allowed for detection.
|
* each frequency may be +6 dB deviation, which means a total deviation of +12 dB is allowed for detection.
|
||||||
* also we allow a minimum of -30 dB for each tone. */
|
* also we allow a minimum of -30 dB for each tone. */
|
||||||
rc = dtmf_decode_init(&jolly->dtmf, jolly, jolly_receive_dtmf, 8000, db2level(6.0), db2level(-30.0));
|
rc = dtmf_decode_init(&jolly->dtmf, jolly, jolly_receive_dtmf, 8000, db2level(6.0), db2level(-30.0), DTMF_FREQ_MARGIN_PERCENT_DEFAULT);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
LOGP(DDSP, LOGL_ERROR, "Failed to init DTMF decoder!\n");
|
LOGP(DDSP, LOGL_ERROR, "Failed to init DTMF decoder!\n");
|
||||||
goto error;
|
goto error;
|
||||||
|
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
static const char dtmf_digit[] = " 123A456B789C*0#D";
|
static const char dtmf_digit[] = " 123A456B789C*0#D";
|
||||||
|
|
||||||
int dtmf_decode_init(dtmf_dec_t *dtmf, void *priv, void (*recv_digit)(void *priv, char digit, dtmf_meas_t *meas), int samplerate, double max_amplitude, double min_amplitude)
|
int dtmf_decode_init(dtmf_dec_t *dtmf, void *priv, void (*recv_digit)(void *priv, char digit, dtmf_meas_t *meas), int samplerate, double max_amplitude, double min_amplitude, double freq_margin)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ int dtmf_decode_init(dtmf_dec_t *dtmf, void *priv, void (*recv_digit)(void *priv
|
|||||||
dtmf->priv = priv;
|
dtmf->priv = priv;
|
||||||
dtmf->recv_digit = recv_digit;
|
dtmf->recv_digit = recv_digit;
|
||||||
dtmf->samplerate = samplerate;
|
dtmf->samplerate = samplerate;
|
||||||
dtmf->freq_margin = 1.03; /* 1.8 .. 3.5 % */
|
dtmf->freq_margin = freq_margin;
|
||||||
dtmf->max_amplitude = max_amplitude;
|
dtmf->max_amplitude = max_amplitude;
|
||||||
dtmf->min_amplitude = min_amplitude;
|
dtmf->min_amplitude = min_amplitude;
|
||||||
dtmf->forward_twist = db2level(4.0);
|
dtmf->forward_twist = db2level(4.0);
|
||||||
@@ -118,7 +118,7 @@ void dtmf_decode(dtmf_dec_t *dtmf, sample_t *samples, int length)
|
|||||||
int amplitude_ok, twist_ok;
|
int amplitude_ok, twist_ok;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
margin = dtmf->freq_margin;
|
margin = dtmf->freq_margin / 100.0 + 1.0;
|
||||||
min_amplitude = dtmf->min_amplitude;
|
min_amplitude = dtmf->min_amplitude;
|
||||||
max_amplitude = dtmf->max_amplitude;
|
max_amplitude = dtmf->max_amplitude;
|
||||||
forward_twist = dtmf->forward_twist;
|
forward_twist = dtmf->forward_twist;
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
#include "../libfm/fm.h"
|
#include "../libfm/fm.h"
|
||||||
|
|
||||||
typedef struct ftmf_meas {
|
#define DTMF_FREQ_MARGIN_PERCENT_DEFAULT 3 /* 1.8 .. 3.5 % */
|
||||||
|
|
||||||
|
typedef struct dtmf_meas {
|
||||||
double frequency_low;
|
double frequency_low;
|
||||||
double frequency_high;
|
double frequency_high;
|
||||||
double amplitude_low;
|
double amplitude_low;
|
||||||
@@ -28,7 +30,7 @@ typedef struct dtmf_dec {
|
|||||||
dtmf_meas_t meas; /* measurements */
|
dtmf_meas_t meas; /* measurements */
|
||||||
} dtmf_dec_t;
|
} dtmf_dec_t;
|
||||||
|
|
||||||
int dtmf_decode_init(dtmf_dec_t *dtmf, void *priv, void (*recv_digit)(void *priv, char digit, dtmf_meas_t *meas), int samplerate, double max_amplitude, double min_amplitude);
|
int dtmf_decode_init(dtmf_dec_t *dtmf, void *priv, void (*recv_digit)(void *priv, char digit, dtmf_meas_t *meas), int samplerate, double max_amplitude, double min_amplitude, double freq_margin);
|
||||||
void dtmf_decode_exit(dtmf_dec_t *dtmf);
|
void dtmf_decode_exit(dtmf_dec_t *dtmf);
|
||||||
void dtmf_decode_reset(dtmf_dec_t *dtmf);
|
void dtmf_decode_reset(dtmf_dec_t *dtmf);
|
||||||
void dtmf_decode(dtmf_dec_t *dtmf, sample_t *samples, int length);
|
void dtmf_decode(dtmf_dec_t *dtmf, sample_t *samples, int length);
|
||||||
|
@@ -65,7 +65,8 @@ int main(void)
|
|||||||
|
|
||||||
fm_init(0);
|
fm_init(0);
|
||||||
|
|
||||||
dtmf_decode_init(&dtmf_dec, NULL, recv_digit, SAMPLERATE, db2level(0), db2level(-30.0));
|
/* decoder uses a strict frequency offset of 0.1 percent. */
|
||||||
|
dtmf_decode_init(&dtmf_dec, NULL, recv_digit, SAMPLERATE, db2level(0), db2level(-30.0), 0.1);
|
||||||
|
|
||||||
for (f = 0; f < 8; f++) {
|
for (f = 0; f < 8; f++) {
|
||||||
printf("Testing filter with frequency %.0f Hz:\n", test_frequency[f]);
|
printf("Testing filter with frequency %.0f Hz:\n", test_frequency[f]);
|
||||||
|
Reference in New Issue
Block a user