Global Tone Generation enables the creation of user-defined tones. The Tone Generation template, TN_GEN, is used to define the tones with the following information:
5.3.1. Global Tone Generation FunctionsThe following functions are used to generate tones:
dx_bldtngen( ) |
|
dx_playtone( ) |
|
dx_bldtngen( ) is a convenience function that sets up the tone generation template data structure (TN_GEN) by allowing the assignment of specified values to the appropriate fields. The tone generation template is placed in the user's return buffer and can then be used by the dx_playtone( ) function to generate the tone.
dx_playtone( ) plays a tone specified by the tone generation template (pointed to by tngenp). Termination conditions are set using the DV_TPT structure. The reason for termination is returned by the ATDX_TERMMSK( ) function. dx_playtone( ) returns a 0 to indicate that it has completed successfully.
5.3.2. Building and Implementing a Tone Generation TemplateThe tone generation template defines the frequency, amplitude, and duration of a single or dual frequency tone to be played. You can use the convenience function dx_bldtngen( ) to set up the structure. Use dx_playtone( ) to play the tone.
The TN_GEN data structure is shown below:
typedef struct {
unsigned short tg_dflag; /* dual tone - 1, single tone - 0 */
unsigned short tg_freq1; /* frequency of tone 1 (in Hz) */
unsigned short tg_freq2; /* frequency of tone 2 (in Hz) */
short int tg_ampl1; /* amplitude of tone 1 (in dB) */
short int tg_ampl2; /* amplitude of tone 2 (in dB) */
short int tg_dur; /* duration (in 10 ms) */
} TN_GEN;
After you build the TN_GEN data structure, there are two ways to define each tone template:
After defining the template, pass TN_GEN to dx_playtone( ) to play the tone.
If you include the values in the structure, you must create a structure for each tone template. If you pass the values using the dx_playtone( ) function, then you can reuse the structure. If you are only changing one value in a template with many variables, it may be more convenient to use several structures in the code instead of reusing just one.
Click here to contact Dialogic Customer Engineering
Copyright 2001, Dialogic Corporation