RTS API Documentation
1.10.11
|
Tone Generation Routines. More...
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <math.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <assert.h>
#include <stdarg.h>
#include <libteletone.h>
Go to the source code of this file.
Data Structures | |
struct | teletone_dds_state |
struct | teletone_generation_session |
An abstraction to store a tone generation session. More... | |
Macros | |
#define | TELETONE_VOL_DB_MAX 0 |
#define | TELETONE_VOL_DB_MIN -63 |
#define | MAX_PHASE_TONES 4 |
#define | SINE_TABLE_MAX 128 |
#define | SINE_TABLE_LEN (SINE_TABLE_MAX - 1) |
#define | MAX_PHASE_ACCUMULATOR 0x10000 * 0x10000 |
#define | DBM0_MAX_POWER (3.14f + 3.02f) |
Typedefs | |
typedef struct teletone_dds_state | teletone_dds_state_t |
typedef int16_t | teletone_audio_t |
typedef int(* | tone_handler) (struct teletone_generation_session *ts, teletone_tone_map_t *map) |
typedef struct teletone_generation_session | teletone_generation_session_t |
Functions | |
float | powf (float, float) |
static __inline__ int32_t | teletone_dds_phase_rate (teletone_process_t tone, uint32_t rate) |
static __inline__ int16_t | teletone_dds_state_modulate_sample (teletone_dds_state_t *dds, uint32_t pindex) |
static __inline__ void | teletone_dds_state_set_tx_level (teletone_dds_state_t *dds, float tx_level) |
static __inline__ void | teletone_dds_state_reset_accum (teletone_dds_state_t *dds) |
static __inline__ int | teletone_dds_state_set_tone (teletone_dds_state_t *dds, teletone_process_t tone, uint32_t rate, uint32_t pindex) |
int | teletone_set_tone (teletone_generation_session_t *ts, int index,...) |
Assign a set of tones to a tone_session indexed by a paticular index/character. More... | |
int | teletone_set_map (teletone_tone_map_t *map,...) |
Assign a set of tones to a single tone map. More... | |
int | teletone_init_session (teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data) |
Initilize a tone generation session. More... | |
int | teletone_destroy_session (teletone_generation_session_t *ts) |
Free the buffer allocated by a tone generation session. More... | |
int | teletone_mux_tones (teletone_generation_session_t *ts, teletone_tone_map_t *map) |
Execute a single tone generation instruction. More... | |
int | teletone_run (teletone_generation_session_t *ts, const char *cmd) |
Execute a tone generation script and call callbacks after each instruction. More... | |
Variables | |
int16_t | TELETONE_SINES [SINE_TABLE_MAX] |
Tone Generation Routines.
This module is responsible for tone generation specifics
Definition in file libteletone_generate.h.
#define DBM0_MAX_POWER (3.14f + 3.02f) |
Definition at line 147 of file libteletone_generate.h.
Referenced by teletone_dds_state_set_tx_level().
#define MAX_PHASE_ACCUMULATOR 0x10000 * 0x10000 |
Definition at line 144 of file libteletone_generate.h.
Referenced by teletone_dds_phase_rate().
#define MAX_PHASE_TONES 4 |
Definition at line 132 of file libteletone_generate.h.
Referenced by teletone_dds_state_modulate_sample(), and teletone_dds_state_set_tone().
#define SINE_TABLE_LEN (SINE_TABLE_MAX - 1) |
Definition at line 143 of file libteletone_generate.h.
Referenced by teletone_dds_state_modulate_sample().
#define SINE_TABLE_MAX 128 |
Definition at line 142 of file libteletone_generate.h.
Referenced by teletone_dds_state_modulate_sample().
#define TELETONE_VOL_DB_MAX 0 |
Definition at line 130 of file libteletone_generate.h.
#define TELETONE_VOL_DB_MIN -63 |
Definition at line 131 of file libteletone_generate.h.
Referenced by teletone_mux_tones(), and teletone_run().
typedef int16_t teletone_audio_t |
Definition at line 208 of file libteletone_generate.h.
typedef struct teletone_dds_state teletone_dds_state_t |
Definition at line 140 of file libteletone_generate.h.
typedef struct teletone_generation_session teletone_generation_session_t |
Definition at line 257 of file libteletone_generate.h.
typedef int(* tone_handler) (struct teletone_generation_session *ts, teletone_tone_map_t *map) |
Definition at line 210 of file libteletone_generate.h.
float powf | ( | float | , |
float | |||
) |
Referenced by teletone_dds_state_set_tx_level().
|
static |
Definition at line 151 of file libteletone_generate.h.
References MAX_PHASE_ACCUMULATOR.
Referenced by teletone_dds_state_set_tone().
|
static |
Definition at line 156 of file libteletone_generate.h.
References MAX_PHASE_TONES, teletone_dds_state::phase_accumulator, teletone_dds_state::phase_rate, teletone_dds_state::scale_factor, SINE_TABLE_LEN, SINE_TABLE_MAX, and TELETONE_SINES.
Referenced by teletone_mux_tones().
|
static |
Definition at line 185 of file libteletone_generate.h.
References teletone_dds_state::phase_accumulator.
|
static |
Definition at line 190 of file libteletone_generate.h.
References MAX_PHASE_TONES, teletone_dds_state::phase_rate, and teletone_dds_phase_rate().
Referenced by teletone_mux_tones().
|
static |
Definition at line 179 of file libteletone_generate.h.
References DBM0_MAX_POWER, powf(), teletone_dds_state::scale_factor, and teletone_dds_state::tx_level.
Referenced by teletone_mux_tones().
int teletone_destroy_session | ( | teletone_generation_session_t * | ts | ) |
Free the buffer allocated by a tone generation session.
ts | the tone generation session to destroy |
Definition at line 177 of file libteletone_generate.c.
References teletone_generation_session::buffer, and teletone_generation_session::samples.
Referenced by inband_dtmf_generate_callback(), main(), setup_ringback(), switch_ivr_gentones(), switch_ivr_originate(), and switch_ivr_wait_for_answer().
int teletone_init_session | ( | teletone_generation_session_t * | ts, |
int | buflen, | ||
tone_handler | handler, | ||
void * | user_data | ||
) |
Initilize a tone generation session.
ts | the tone generation session to initilize |
buflen | the size of the buffer(in samples) to dynamically allocate |
handler | a callback function to execute when a tone generation instruction is complete |
user_data | optional user data to send |
Definition at line 134 of file libteletone_generate.c.
References teletone_generation_session::buffer, buflen, teletone_generation_session::channels, teletone_generation_session::datalen, teletone_generation_session::decay_factor, teletone_generation_session::decay_step, teletone_generation_session::duration, teletone_generation_session::dynamic, teletone_generation_session::handler, memset(), teletone_generation_session::rate, teletone_set_tone(), teletone_generation_session::tmp_duration, teletone_generation_session::tmp_wait, teletone_generation_session::user_data, teletone_generation_session::volume, and teletone_generation_session::wait.
Referenced by inband_dtmf_generate_callback(), main(), setup_ringback(), switch_ivr_gentones(), and switch_ivr_wait_for_answer().
int teletone_mux_tones | ( | teletone_generation_session_t * | ts, |
teletone_tone_map_t * | map | ||
) |
Execute a single tone generation instruction.
ts | the tone generation session to consult for parameters |
map | the tone mapping to use for the frequencies |
Definition at line 206 of file libteletone_generate.c.
References teletone_generation_session::buffer, teletone_generation_session::channels, teletone_generation_session::datalen, teletone_generation_session::debug, teletone_generation_session::debug_stream, teletone_generation_session::decay_direction, teletone_generation_session::decay_factor, teletone_generation_session::decay_step, teletone_generation_session::duration, teletone_generation_session::dynamic, ensure_buffer(), teletone_tone_map_t::freqs, memset(), teletone_generation_session::rate, teletone_generation_session::samples, teletone_dds_state_modulate_sample(), teletone_dds_state_set_tone(), teletone_dds_state_set_tx_level(), TELETONE_MAX_TONES, TELETONE_VOL_DB_MIN, teletone_generation_session::tmp_duration, teletone_generation_session::tmp_wait, teletone_generation_session::volume, and teletone_generation_session::wait.
Referenced by teletone_dtmf_generate_handler(), and teletone_handler().
int teletone_run | ( | teletone_generation_session_t * | ts, |
const char * | cmd | ||
) |
Execute a tone generation script and call callbacks after each instruction.
ts | the tone generation session to execute on |
cmd | the script to execute |
Definition at line 314 of file libteletone_generate.c.
References teletone_generation_session::channels, cur, teletone_generation_session::debug, teletone_generation_session::debug_stream, teletone_generation_session::decay_direction, teletone_generation_session::decay_factor, teletone_generation_session::decay_step, teletone_generation_session::duration, teletone_tone_map_t::freqs, teletone_generation_session::handler, teletone_generation_session::loops, teletone_generation_session::LOOPS, memset(), my_strdup(), teletone_generation_session::rate, TELETONE_MAX_TONES, TELETONE_TONE_RANGE, TELETONE_VOL_DB_MIN, teletone_generation_session::tmp_duration, teletone_generation_session::tmp_wait, teletone_generation_session::TONES, teletone_generation_session::volume, and teletone_generation_session::wait.
Referenced by inband_dtmf_generate_callback(), main(), setup_ringback(), switch_ivr_gentones(), and switch_ivr_wait_for_answer().
int teletone_set_map | ( | teletone_tone_map_t * | map, |
... | |||
) |
Assign a set of tones to a single tone map.
map | the map to assign the tones to |
... | up to TELETONE_MAX_TONES frequencies terminated by 0.0 |
Definition at line 118 of file libteletone_generate.c.
References teletone_tone_map_t::freqs, and TELETONE_MAX_TONES.
int teletone_set_tone | ( | teletone_generation_session_t * | ts, |
int | index, | ||
... | |||
) |
Assign a set of tones to a tone_session indexed by a paticular index/character.
ts | the tone generation session |
index | the index to map the tone to |
... | up to TELETONE_MAX_TONES frequencies terminated by 0.0 |
Definition at line 102 of file libteletone_generate.c.
References teletone_tone_map_t::freqs, index, TELETONE_MAX_TONES, and teletone_generation_session::TONES.
Referenced by teletone_init_session().
int16_t TELETONE_SINES[SINE_TABLE_MAX] |
Definition at line 82 of file libteletone_generate.c.
Referenced by teletone_dds_state_modulate_sample().