
Description | Cautions | Errors | Example | See Also
Name: |
long lm_LearnTone(cd, lm_parmp, tn_amplp, dflagp, tn_rangep, tn_tonep, tn_infop, mode) | |
Inputs: |
int cd |
|
LM_PARM *lm_parmp |
| |
TN_AMP *tn_amplp |
| |
short *dflagp |
| |
TN_DESC *tn_rangep |
| |
TN_DESC *tn_tonep |
| |
TN_INFOLIST *tn_infolistp |
| |
int mode |
| |
Outputs: |
none | |
Returns: |
0 if success |
|
Includes: |
srllib.h dxxxlib.h lmodelib.h | |
Mode: |
synchronous | |
Category: |
learn mode | |
Platform: |
Springware | |
The lm_LearnTone( ) function initiates learn mode to characterize a tone that occurs on the specified channel and to obtain the complete tone description for use with global tone detection or call progress analysis. For more information on global tone detection and call progress analysis, see the Voice Software Reference -- Features Guide.
Parameter |
Description | |
cd |
Specifies the channel device handle. | |
lm_parmp |
Points to the LM_PARM data structure which specifies parameters used to characterize the tone. For more information, see the LM_PARM structure in Chapter 6. Data Structure Reference. | |
tn_amplp |
Points to the TN_AMP data structure. This specifies tone amplitude boundaries that restrict the learning to a specified amplitude range. For example, you can set the amplitude range lower to learn a poor quality tone, although noise may interfere with the results, or you can set the amplitude range higher to detect a high-quality tone. For more information, see TN_AMP structure in Chapter 6. Data Structure Reference. | |
dflagp |
Specifies the single/dual tone flag, which indicates whether the tone is a single tone or dual tone. This flag must be set manually. When you set this flag manually, make sure you take the voice board dual-tone resolution into account. | |
0 |
If unknown or new tone | |
1 |
single tone (or a dual tone that falls below the dual-tone resolution) | |
2 |
dual tone | |
tn_rangep |
Points to the TN_DESC data structure specifying optional tone learning boundaries to restrict learning to the specified range. For more information, see TN_DESC structure in Chapter 6. Data Structure Reference. If you set tn_rangep to NULL, this feature is disabled. | |
tn_tonep |
Points to the TN_DESC data structure specifying the tone description. This parameter serves two different purposes: (1) it specifies an existing tone description as optional input to the lm_LearnTone( ) function, and learn mode incorporates this input into the final tone description, and (2) it provides the final tone description that is returned by lm_LearnTone( ). See Requirements section for more information on using this parameter. | |
tn_infolistp |
Points to the TN_INFOLIST structure which contains an array of tone information (TN_INFO data structure). This structure provides the actual frequency and on/off times for each frame (sample) of a detected tone. This information is used primarily for debugging. | |
If you set tn_infolistp to NULL, this feature is disabled, and the data is not available for your analysis. | ||
If you want to analyze the data on which learn mode bases the final tone description, you must allocate an array of memory for saving the tone information of each sample. The required memory is equal to the number of lm_frames (stored in LM_PARM structure) + OFFSET (defined in lmodelib.h) multiplied by the size of the TN_INFO structure. OFFSET allows the library to store tone information for extra frames. The tn_infolistp parameter is also used to learn disconnect tones with more than one on time and more than one off time. | ||
mode |
You must set the mode to EV_SYNC for synchronous operation. | |
Requirements
For a list of error codes, see Section 5.2. Learn Mode Error Codes.
/* This example code shows how to "learn" a dial tone. */
/*
The line is set off-hook to generate a dial tone,
then lm_LearnTone( ) is called to learn the tone.
/*
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include "srllib.h"
#include "dxxxlib.h"
#include "lmodelib.h"
#define DEVICE "dxxxB1C1"
#define ERR -1
int lrn_Learn(int lrnDev);
int main()
{
int i,rc;
int Caller;
/* learn the dial tone here */
/* Prepare the scenario for dial tone */
if ((Caller = dx_open(DEVICE,(int)NULL)) == ERR)
{
//Error occurred in opening DEVICE
//Handle the error here and return
//error
return(ERR);
}
if ( dx_sethook(Caller, DX_OFFHOOK, EV_SYNC) == ERR)
{
//Error to set off hook
return(ERR);
}
printf("Start learning...............\n");
if ((rc = lrn_Learn(Caller)) != ERR)
{
printf("Finish learning...............\n");
}
else
{
printf("Error in Learning...\n");
}
//reset the channel
return 0;
}
int lrn_Learn(int Dev)
{
LM_PARM parm;
TN_AMP amp;
TN_DESC desc;
short flagDual;
int ret = -1;
lm_clrparm(&parm);
lm_clramp(&);
lm_clrdesc(&desc);
flagDual = 0; //Unknown
//set necessary fields of lm_parm
parm.lm_frames = 10;
parm.lm_qualid = QT_LMMID;
parm.lm_cadflag = 0;
/* min duration for tone to qualify as continuous */
parm.lm_cnt_min = 400;
parm.lm_method = 2;
ret = lm_LearnTone(Dev, &parm, &, &flagDual, NULL, &desc, NULL, EV_SYNC, NULL);
if( ret == ERR )
{
//Learning failed so process and return error
return(ERR):
}
/*process tone ( frequency and cadence) information returned in desc structure. */
return(ret);
}
Click here to contact Telecom Support Resources
Copyright 2003, Intel Corporation