spandsp 0.0.6
super_tone_rx.c File Reference
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <fcntl.h>
#include <ctype.h>
#include <time.h>
#include <inttypes.h>
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/fast_convert.h"
#include "spandsp/complex.h"
#include "spandsp/vector_float.h"
#include "spandsp/complex_vector_float.h"
#include "spandsp/tone_detect.h"
#include "spandsp/tone_generate.h"
#include "spandsp/super_tone_rx.h"
#include "spandsp/private/super_tone_rx.h"

Macros

#define DETECTION_THRESHOLD   2104205.6f /* -42dBm0 [((SUPER_TONE_BINS*SUPER_TONE_BINS*32768.0/1.4142)*10^((-42 - DBM0_MAX_SINE_POWER)/20.0))^2] */
#define TONE_TWIST   3.981f /* 6dB */
#define TONE_TO_TOTAL_ENERGY   1.995f /* 3dB */

Functions

int super_tone_rx_add_tone (super_tone_rx_descriptor_t *desc)
int super_tone_rx_add_element (super_tone_rx_descriptor_t *desc, int tone, int f1, int f2, int min, int max)
super_tone_rx_descriptor_tsuper_tone_rx_make_descriptor (super_tone_rx_descriptor_t *desc)
int super_tone_rx_free_descriptor (super_tone_rx_descriptor_t *desc)
void super_tone_rx_tone_callback (super_tone_rx_state_t *s, tone_report_func_t callback, void *user_data)
void super_tone_rx_segment_callback (super_tone_rx_state_t *s, tone_segment_func_t callback)
super_tone_rx_state_tsuper_tone_rx_init (super_tone_rx_state_t *s, super_tone_rx_descriptor_t *desc, tone_report_func_t callback, void *user_data)
int super_tone_rx_release (super_tone_rx_state_t *s)
int super_tone_rx_free (super_tone_rx_state_t *s)
int super_tone_rx (super_tone_rx_state_t *s, const int16_t amp[], int samples)
 Apply supervisory tone detection processing to a block of audio samples.
int super_tone_rx_fillin (super_tone_rx_state_t *s, int samples)
 Allow for a missing block of samples to a supervisory tone detector.

Function Documentation

◆ super_tone_rx()

int super_tone_rx ( super_tone_rx_state_t * super,
const int16_t amp[],
int samples )

Apply supervisory tone detection processing to a block of audio samples.

Apply supervisory tone detection processing to a block of audio samples.

Parameters
superThe supervisory tone context.
ampThe audio sample buffer.
samplesThe number of samples in the buffer.
Returns
The number of samples processed.

◆ super_tone_rx_add_element()

int super_tone_rx_add_element ( super_tone_rx_descriptor_t * desc,
int tone,
int f1,
int f2,
int min,
int max )

Add a new tone pattern element to a tone pattern in a supervisory tone detector.

Parameters
descThe supervisory tone set desciptor.
toneThe tone ID within the descriptor.
f1Frequency 1 (-1 for a silent period).
f2Frequency 2 (-1 for a silent period, or only one frequency).
minThe minimum duration, in ms.
maxThe maximum duration, in ms.
Returns
The new number of elements in the tone description.

◆ super_tone_rx_add_tone()

int super_tone_rx_add_tone ( super_tone_rx_descriptor_t * desc)

Add a new tone pattern to a supervisory tone detector set.

Parameters
descThe supervisory tone set descriptor.
Returns
The new tone ID.

◆ super_tone_rx_fillin()

int super_tone_rx_fillin ( super_tone_rx_state_t * s,
int samples )

Allow for a missing block of samples to a supervisory tone detector.

Allow for a missing block of samples to a supervisory tone detector.

Parameters
superThe supervisory tone context.
samplesThe number of samples to allow for.
Returns
The number of samples processed.

◆ super_tone_rx_free()

int super_tone_rx_free ( super_tone_rx_state_t * s)

Free a supervisory tone detector.

Parameters
sThe supervisory tone context.
Returns
0 for OK, -1 for fail.

◆ super_tone_rx_free_descriptor()

int super_tone_rx_free_descriptor ( super_tone_rx_descriptor_t * desc)

Free a supervisory tone detector descriptor.

Parameters
descThe supervisory tone set desciptor.
Returns
0 for OK, -1 for fail.

◆ super_tone_rx_init()

super_tone_rx_state_t * super_tone_rx_init ( super_tone_rx_state_t * s,
super_tone_rx_descriptor_t * desc,
tone_report_func_t callback,
void * user_data )

Initialise a supervisory tone detector.

Parameters
sThe supervisory tone detector context.
descThe tone descriptor.
callbackThe callback routine called to report the valid detection or termination of one of the monitored tones.
user_dataAn opaque pointer passed when calling the callback routine.
Returns
The supervisory tone detector context.

◆ super_tone_rx_make_descriptor()

super_tone_rx_descriptor_t * super_tone_rx_make_descriptor ( super_tone_rx_descriptor_t * desc)

Create a new supervisory tone detector descriptor.

Parameters
descThe supervisory tone set desciptor. If NULL, the routine will allocate space for a descriptor.
Returns
The supervisory tone set descriptor.

◆ super_tone_rx_release()

int super_tone_rx_release ( super_tone_rx_state_t * s)

Release a supervisory tone detector.

Parameters
sThe supervisory tone context.
Returns
0 for OK, -1 for fail.

◆ super_tone_rx_segment_callback()

void super_tone_rx_segment_callback ( super_tone_rx_state_t * s,
tone_segment_func_t callback )

Define a callback routine to be called each time a tone pattern element is complete. This is mostly used when analysing a tone.

Parameters
sThe supervisory tone context.
callbackThe callback routine.

◆ super_tone_rx_tone_callback()

void super_tone_rx_tone_callback ( super_tone_rx_state_t * s,
tone_report_func_t callback,
void * user_data )

Define a callback routine to be called to report the valid detection or termination of one of the monitored tones.

Parameters
sThe supervisory tone context.
callbackThe callback routine called to report the valid detection or termination of one of the monitored tones.
user_dataAn opaque pointer passed when calling the callback routine.