spandsp: bell_r2_mf.h File Reference

spandsp 0.0.6

Macros | Typedefs | Functions
bell_r2_mf.h File Reference

Go to the source code of this file.

## Macros
#define | MAX_BELL_MF_DIGITS 128

## Typedefs
typedef struct bell_mf_tx_state_s | bell_mf_tx_state_t
typedef struct bell_mf_rx_state_s | bell_mf_rx_state_t
typedef struct r2_mf_tx_state_s | r2_mf_tx_state_t
typedef struct r2_mf_rx_state_s | r2_mf_rx_state_t

## Functions
int | bell_mf_tx (bell_mf_tx_state_t *s, int16_t amp[], int max_samples)
| Generate a buffer of Bell MF tones.
int | 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_release (bell_mf_tx_state_t *s)
| Release 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_release (r2_mf_tx_state_t *s)
| Release 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_release (bell_mf_rx_state_t *s)
| Release 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_release (r2_mf_rx_state_t *s)
| Release an R2 MF receiver context.
int | r2_mf_rx_free (r2_mf_rx_state_t *s)
| Free an R2 MF receiver context.

## Macro Definition Documentation

## ◆ MAX_BELL_MF_DIGITS

#define MAX_BELL_MF_DIGITS 128

The maximum number of Bell MF digits we can buffer.

## Typedef Documentation

## ◆ bell_mf_rx_state_t

typedef struct bell_mf_rx_state_s bell_mf_rx_state_t

Bell MF digit detector descriptor.

## ◆ bell_mf_tx_state_t

typedef struct bell_mf_tx_state_s bell_mf_tx_state_t

Bell MF generator state descriptor. This defines the state of a single working instance of a Bell MF generator.

## ◆ r2_mf_rx_state_t

typedef struct r2_mf_rx_state_s r2_mf_rx_state_t

MFC/R2 tone detector descriptor.

## ◆ r2_mf_tx_state_t

typedef struct r2_mf_tx_state_s r2_mf_tx_state_t

MFC/R2 tone detector descriptor.

## Function Documentation

## ◆ bell_mf_rx()

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.

Parameters

  s | The Bell MF receiver context.
  amp | The audio sample buffer.
  samples | The number of samples in the buffer.

Returns
  The number of samples unprocessed.

References bell_mf_rx_state_s::current_digits, bell_mf_rx_state_s::current_sample, bell_mf_rx_state_s::digits, bell_mf_rx_state_s::digits_callback, bell_mf_rx_state_s::digits_callback_data, bell_mf_rx_state_s::hits, bell_mf_rx_state_s::lost_digits, MAX_BELL_MF_DIGITS, and bell_mf_rx_state_s::out.

## ◆ bell_mf_rx_free()

int bell_mf_rx_free | ( | bell_mf_rx_state_t * | s | ) |

Free a Bell MF receiver context.

Parameters

  s | The Bell MF receiver context.

Returns
  0 for OK, else -1.

## ◆ bell_mf_rx_get()

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.

Parameters

  s | The Bell MF receiver context.
  buf | The buffer for the received digits.
  max | The maximum number of digits to be returned,

Returns
  The number of digits actually returned.

References bell_mf_rx_state_s::current_digits, and bell_mf_rx_state_s::digits.

## ◆ bell_mf_rx_init()

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.

Parameters

  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.

Returns
  A pointer to the Bell MF receiver context.

References bell_mf_rx_state_s::current_digits, bell_mf_rx_state_s::current_sample, bell_mf_rx_state_s::digits, bell_mf_rx_state_s::digits_callback, bell_mf_rx_state_s::digits_callback_data, bell_mf_rx_state_s::hits, bell_mf_rx_state_s::lost_digits, and bell_mf_rx_state_s::out.

## ◆ bell_mf_rx_release()

int bell_mf_rx_release | ( | bell_mf_rx_state_t * | s | ) |

Release a Bell MF receiver context.

Parameters

  s | The Bell MF receiver context.

Returns
  0 for OK, else -1.

## ◆ bell_mf_tx()

int bell_mf_tx | ( | bell_mf_tx_state_t * | s,
|  | int16_t | amp[],
|  | int | max_samples
| ) |  |

Generate a buffer of Bell MF tones.

Parameters

  s | The Bell MF generator context.
  amp | The buffer for the generated signal.
  max_samples | The required number of generated samples.

Returns
  The number of samples actually generated. This may be less than max_samples if the input buffer empties.

References queue_read_byte(), and bell_mf_tx_state_s::tones.

## ◆ bell_mf_tx_free()

int bell_mf_tx_free | ( | bell_mf_tx_state_t * | s | ) |

Free a Bell MF generator context.

Parameters

  s | The Bell MF generator context.

Returns
  0 for OK, else -1.

## ◆ bell_mf_tx_init()

bell_mf_tx_state_t * bell_mf_tx_init | ( | bell_mf_tx_state_t * | s | ) |

Initialise a Bell MF generator context.

Parameters

  s | The Bell MF generator context.

Returns
  A pointer to the Bell MF generator context.

References MAX_BELL_MF_DIGITS, queue_init(), QUEUE_READ_ATOMIC, QUEUE_WRITE_ATOMIC, and bell_mf_tx_state_s::tones.

## ◆ bell_mf_tx_put()

int 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.

Parameters

  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.

Returns
  The number of digits actually added. This may be less than the length of the digit string, if the buffer fills up.

References queue_free_space(), and queue_write().

## ◆ bell_mf_tx_release()

int bell_mf_tx_release | ( | bell_mf_tx_state_t * | s | ) |

Release a Bell MF generator context.

Parameters

  s | The Bell MF generator context.

Returns
  0 for OK, else -1.

## ◆ r2_mf_rx()

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.

Parameters

  s | The R2 MF receiver context.
  amp | The audio sample buffer.
  samples | The number of samples in the buffer.

Returns
  The number of samples unprocessed.

References r2_mf_rx_state_s::callback, r2_mf_rx_state_s::callback_data, r2_mf_rx_state_s::current_digit, r2_mf_rx_state_s::current_sample, and r2_mf_rx_state_s::out.

## ◆ r2_mf_rx_free()

int r2_mf_rx_free | ( | r2_mf_rx_state_t * | s | ) |

Free an R2 MF receiver context.

Parameters

  s | The R2 MF receiver context.

Returns
  0 for OK, else -1.

## ◆ r2_mf_rx_get()

int r2_mf_rx_get | ( | r2_mf_rx_state_t * | s | ) |

Get the current digit from an R2 MF receiver.

Parameters

  s | The R2 MF receiver context.

Returns
  The number digits being received.

References r2_mf_rx_state_s::current_digit.

## ◆ r2_mf_rx_init()

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.

Parameters

  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.

Returns
  A pointer to the R2 MF receiver context.

References r2_mf_rx_state_s::callback, r2_mf_rx_state_s::callback_data, r2_mf_rx_state_s::current_digit, r2_mf_rx_state_s::current_sample, r2_mf_rx_state_s::fwd, and r2_mf_rx_state_s::out.

## ◆ r2_mf_rx_release()

int r2_mf_rx_release | ( | r2_mf_rx_state_t * | s | ) |

Release an R2 MF receiver context.

Parameters

  s | The R2 MF receiver context.

Returns
  0 for OK, else -1.

## ◆ r2_mf_tx()

int r2_mf_tx | ( | r2_mf_tx_state_t * | s,
|  | int16_t | amp[],
|  | int | samples
| ) |  |

Generate a block of R2 MF tones.

Parameters

  s | The R2 MF generator context.
  amp | The buffer for the generated signal.
  samples | The required number of generated samples.

Returns
  The number of samples actually generated.

References r2_mf_tx_state_s::digit, and r2_mf_tx_state_s::tone.

## ◆ r2_mf_tx_free()

int r2_mf_tx_free | ( | r2_mf_tx_state_t * | s | ) |

Free an R2 MF tone generator context.

Parameters

  s | The R2 MF tone generator context.

Returns
  0 for OK, else -1.

## ◆ r2_mf_tx_init()

r2_mf_tx_state_t * r2_mf_tx_init | ( | r2_mf_tx_state_t * | s,
|  | int | fwd
| ) |  |

Initialise an R2 MF tone generator context.

Parameters

  s | The R2 MF generator context.
  fwd | TRUE if the context is for forward signals. FALSE if the context is for backward signals.

Returns
  A pointer to the MFC/R2 generator context.

References r2_mf_tx_state_s::fwd, and tone_gen_descriptor_init().

## ◆ r2_mf_tx_put()

int r2_mf_tx_put | ( | r2_mf_tx_state_t * | s,
|  | char | digit
| ) |  |

Generate a block of R2 MF tones.

Parameters

  s | The R2 MF generator context.
  digit | The digit to be generated.

Returns
  0 for OK, or -1 for a bad request.

References r2_mf_tx_state_s::digit, r2_mf_tx_state_s::fwd, and r2_mf_tx_state_s::tone.

## ◆ r2_mf_tx_release()

int r2_mf_tx_release | ( | r2_mf_tx_state_t * | s | ) |

Release an R2 MF tone generator context.

Parameters

  s | The R2 MF tone generator context.

Returns
  0 for OK, else -1.