#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
#include <time.h>
#include <fcntl.h>
#include "floating_fudge.h"
#include "spandsp/telephony.h"
#include "spandsp/queue.h"
#include "spandsp/dc_restore.h"
#include "spandsp/complex.h"
#include "spandsp/dds.h"
#include "spandsp/tone_detect.h"
#include "spandsp/tone_generate.h"
#include "spandsp/super_tone_rx.h"
#include "spandsp/dtmf.h"
#include "spandsp/bell_r2_mf.h"
Classes | |
struct | mf_digit_tones_t |
Defines | |
#define | M_PI 3.14159265358979323846264338327 |
#define | ms_to_samples(t) (((t)*SAMPLE_RATE)/1000) |
#define | BELL_MF_THRESHOLD 3343803100.0f |
#define | BELL_MF_TWIST 3.981f |
#define | BELL_MF_RELATIVE_PEAK 12.589f |
#define | BELL_MF_SAMPLES_PER_BLOCK 120 |
#define | R2_MF_THRESHOLD 1031766650.0f |
#define | R2_MF_TWIST 5.012f |
#define | R2_MF_RELATIVE_PEAK 12.589f |
#define | R2_MF_SAMPLES_PER_BLOCK 133 |
Functions | |
int | bell_mf_tx (bell_mf_tx_state_t *s, int16_t amp[], int max_samples) |
Generate a buffer of Bell MF tones. | |
size_t | bell_mf_tx_put (bell_mf_tx_state_t *s, const char *digits, int len) |
Put a string of digits in a Bell MF generator's input buffer. | |
bell_mf_tx_state_t * | bell_mf_tx_init (bell_mf_tx_state_t *s) |
Initialise a Bell MF generator context. | |
int | bell_mf_tx_free (bell_mf_tx_state_t *s) |
Free a Bell MF generator context. | |
int | r2_mf_tx (r2_mf_tx_state_t *s, int16_t amp[], int samples) |
Generate a block of R2 MF tones. | |
int | r2_mf_tx_put (r2_mf_tx_state_t *s, char digit) |
Generate a block of R2 MF tones. | |
r2_mf_tx_state_t * | r2_mf_tx_init (r2_mf_tx_state_t *s, int fwd) |
Initialise an R2 MF tone generator context. | |
int | r2_mf_tx_free (r2_mf_tx_state_t *s) |
Free an R2 MF tone generator context. | |
int | bell_mf_rx (bell_mf_rx_state_t *s, const int16_t amp[], int samples) |
Process a block of received Bell MF audio samples. | |
size_t | bell_mf_rx_get (bell_mf_rx_state_t *s, char *buf, int max) |
Get a string of digits from a Bell MF receiver's output buffer. | |
bell_mf_rx_state_t * | bell_mf_rx_init (bell_mf_rx_state_t *s, digits_rx_callback_t callback, void *user_data) |
Initialise a Bell MF receiver context. | |
int | bell_mf_rx_free (bell_mf_rx_state_t *s) |
Free a Bell MF receiver context. | |
int | r2_mf_rx (r2_mf_rx_state_t *s, const int16_t amp[], int samples) |
Process a block of received R2 MF audio samples. | |
int | r2_mf_rx_get (r2_mf_rx_state_t *s) |
Get the current digit from an R2 MF receiver. | |
r2_mf_rx_state_t * | r2_mf_rx_init (r2_mf_rx_state_t *s, int fwd, tone_report_func_t callback, void *user_data) |
Initialise an R2 MF receiver context. | |
int | r2_mf_rx_free (r2_mf_rx_state_t *s) |
Free an R2 MF receiver context. | |
Variables | |
int | bell_mf_gen_inited = FALSE |
tone_gen_descriptor_t | bell_mf_digit_tones [15] |
int | r2_mf_gen_inited = FALSE |
tone_gen_descriptor_t | r2_mf_fwd_digit_tones [15] |
tone_gen_descriptor_t | r2_mf_back_digit_tones [15] |
int bell_mf_rx | ( | bell_mf_rx_state_t * | s, | |
const int16_t | amp[], | |||
int | samples | |||
) |
Process a block of received Bell MF audio samples.
Process a block of received Bell MF audio samples.
s | The Bell MF receiver context. | |
amp | The audio sample buffer. | |
samples | The number of samples in the buffer. |
References bell_mf_rx_state_t::current_digits, bell_mf_rx_state_t::current_sample, bell_mf_rx_state_t::digits, bell_mf_rx_state_t::digits_callback, bell_mf_rx_state_t::digits_callback_data, goertzel_result(), bell_mf_rx_state_t::hits, bell_mf_rx_state_t::lost_digits, MAX_BELL_MF_DIGITS, and bell_mf_rx_state_t::out.
int bell_mf_rx_free | ( | bell_mf_rx_state_t * | s | ) |
Free a Bell MF receiver context.
s | The Bell MF receiver context. |
size_t bell_mf_rx_get | ( | bell_mf_rx_state_t * | s, | |
char * | buf, | |||
int | max | |||
) |
Get a string of digits from a Bell MF receiver's output buffer.
s | The Bell MF receiver context. | |
buf | The buffer for the received digits. | |
max | The maximum number of digits to be returned, |
References bell_mf_rx_state_t::current_digits, and bell_mf_rx_state_t::digits.
bell_mf_rx_state_t* bell_mf_rx_init | ( | bell_mf_rx_state_t * | s, | |
digits_rx_callback_t | callback, | |||
void * | user_data | |||
) |
Initialise a Bell MF receiver context.
s | The Bell MF receiver context. | |
callback | An optional callback routine, used to report received digits. If no callback routine is set, digits may be collected, using the bell_mf_rx_get() function. | |
user_data | An opaque pointer which is associated with the context, and supplied in callbacks. |
References bell_mf_rx_state_t::current_digits, bell_mf_rx_state_t::current_sample, bell_mf_rx_state_t::digits, bell_mf_rx_state_t::digits_callback, bell_mf_rx_state_t::digits_callback_data, goertzel_init(), bell_mf_rx_state_t::hits, bell_mf_rx_state_t::lost_digits, make_goertzel_descriptor(), and bell_mf_rx_state_t::out.
int bell_mf_tx | ( | bell_mf_tx_state_t * | s, | |
int16_t | amp[], | |||
int | max_samples | |||
) |
Generate a buffer of Bell MF tones.
s | The Bell MF generator context. | |
amp | The buffer for the generated signal. | |
max_samples | The required number of generated samples. |
References tone_gen_state_t::current_section, bell_mf_tx_state_t::queue, queue_read_byte(), and bell_mf_tx_state_t::tones.
int bell_mf_tx_free | ( | bell_mf_tx_state_t * | s | ) |
Free a Bell MF generator context.
s | The Bell MF generator context. |
bell_mf_tx_state_t* bell_mf_tx_init | ( | bell_mf_tx_state_t * | s | ) |
Initialise a Bell MF generator context.
s | The Bell MF generator context. |
References bell_mf_tx_state_t::current_sample, tone_gen_state_t::current_section, MAX_BELL_MF_DIGITS, bell_mf_tx_state_t::queue, queue_init(), QUEUE_READ_ATOMIC, QUEUE_WRITE_ATOMIC, and bell_mf_tx_state_t::tones.
size_t bell_mf_tx_put | ( | bell_mf_tx_state_t * | s, | |
const char * | digits, | |||
int | len | |||
) |
Put a string of digits in a Bell MF generator's input buffer.
s | The Bell MF generator context. | |
digits | The string of digits to be added. | |
len | The length of the string of digits. If negative, the string is assumed to be a NULL terminated string. |
References bell_mf_tx_state_t::queue, queue_free_space(), and queue_write().
int r2_mf_rx | ( | r2_mf_rx_state_t * | s, | |
const int16_t | amp[], | |||
int | samples | |||
) |
Process a block of received R2 MF audio samples.
Process a block of received R2 MF audio samples.
s | The R2 MF receiver context. | |
amp | The audio sample buffer. | |
samples | The number of samples in the buffer. |
References r2_mf_rx_state_t::callback, r2_mf_rx_state_t::callback_data, r2_mf_rx_state_t::current_digit, r2_mf_rx_state_t::current_sample, goertzel_result(), and r2_mf_rx_state_t::out.
int r2_mf_rx_free | ( | r2_mf_rx_state_t * | s | ) |
Free an R2 MF receiver context.
s | The R2 MF receiver context. |
int r2_mf_rx_get | ( | r2_mf_rx_state_t * | s | ) |
Get the current digit from an R2 MF receiver.
s | The R2 MF receiver context. |
References r2_mf_rx_state_t::current_digit.
r2_mf_rx_state_t* r2_mf_rx_init | ( | r2_mf_rx_state_t * | s, | |
int | fwd, | |||
tone_report_func_t | callback, | |||
void * | user_data | |||
) |
Initialise an R2 MF receiver context.
s | The R2 MF receiver context. | |
fwd | TRUE if the context is for forward signals. FALSE if the context is for backward signals. | |
callback | An optional callback routine, used to report received digits. If no callback routine is set, digits may be collected, using the r2_mf_rx_get() function. | |
user_data | An opaque pointer which is associated with the context, and supplied in callbacks. |
References r2_mf_rx_state_t::callback, r2_mf_rx_state_t::callback_data, r2_mf_rx_state_t::current_digit, r2_mf_rx_state_t::current_sample, r2_mf_rx_state_t::fwd, goertzel_init(), make_goertzel_descriptor(), and r2_mf_rx_state_t::out.
int r2_mf_tx | ( | r2_mf_tx_state_t * | s, | |
int16_t | amp[], | |||
int | samples | |||
) |
Generate a block of R2 MF tones.
s | The R2 MF generator context. | |
amp | The buffer for the generated signal. | |
samples | The required number of generated samples. |
References r2_mf_tx_state_t::digit, and r2_mf_tx_state_t::tone.
int r2_mf_tx_free | ( | r2_mf_tx_state_t * | s | ) |
Free an R2 MF tone generator context.
s | The R2 MF tone generator context. |
r2_mf_tx_state_t* r2_mf_tx_init | ( | r2_mf_tx_state_t * | s, | |
int | fwd | |||
) |
Initialise an R2 MF tone generator context.
s | The R2 MF generator context. | |
fwd | TRUE if the context is for forward signals. FALSE if the context is for backward signals. |
References r2_mf_tx_state_t::fwd, and make_tone_gen_descriptor().
int r2_mf_tx_put | ( | r2_mf_tx_state_t * | s, | |
char | digit | |||
) |
Generate a block of R2 MF tones.
s | The R2 MF generator context. | |
digit | The digit to be generated. |
References r2_mf_tx_state_t::digit, r2_mf_tx_state_t::fwd, and r2_mf_tx_state_t::tone.