Author |
|
timkelly1980 Intermediate
Joined: February 07 2005 Posts: 25
|
Posted: May 30 2005 at 11:17am | IP Logged
|
|
|
I just need to simple DTMF generation (not detection) to my sip-phone app (ie user can press button and tone generated during call).
Do I need to buy your DTMF library? If so can you please email "pre-release" pricing, I presume it's pretty stable for just generating tones?
Tim Kelly
|
Back to Top |
|
|
timkelly1980 Intermediate
Joined: February 07 2005 Posts: 25
|
Posted: May 30 2005 at 1:02pm | IP Logged
|
|
|
Based on a guide at http://users.tkk.fi/~then/mytexts/dtmf_generation.html I tried making a tone "1".
But my code doesn't seem to do anything.... any hints!:
void __fastcall TDM1::PlayDTMF()
{
IVRTXHANDLE handle;
int spb;
int n = 0;
int j;
unsigned short int sample[1024];
SIP_SAFE(OpenTxIvrChannel( SIP_handle, 0, 0, &handle));
SIP_SAFE(SetTxIvrDataType(handle, WAVE_FORMAT_PCM, 8000, 16));
SIP_SAFE(GetTxIvrSampleBlockSize( handle, WAVE_FORMAT_PCM, 8000, 16, &spb));
for(j = 0 ; j < 1000 ; j++)
{
for(n = 0 ; n < (spb + 1) ; n++)
{
sample[n] = 128 + 63 * sin(n*2* pi * 697/8000) + 63 * sin(n * 2 * pi * 1209/8000);
}
SIP_SAFE(TransmitInCallIvrData(handle, &sample));
SIP_SAFE(WaitForIvrTransmitComplete( handle));
}
SIP_SAFE(CloseTxIvrChannel(handle));
}
|
Back to Top |
|
|
support Administrator
Joined: January 26 2005 Location: United States Posts: 1666
|
Posted: June 03 2005 at 11:12am | IP Logged
|
|
|
Hi Tim,
Please excuse the delay in this response.
I see our support group has already sent you an email outside of this forum explaining our DTMF codec library options.
Regarding your example code:
You can generate the PCM samples for any waveform you want and then send the samples to any phone line using a chunk of samples called a “sample block”.
Your code is pretty close to being correct. Here are some additional pointers:
1)
You should open a transmit IVR channel to the phone line once the phone call enters the SipInCall state. Search the C++ sample source code for the member function:
void CSingleLinePhoneDlg::PhoneCallActive(SIPHANDLE hSipEngine, int PhoneLine)
This proc opens a PCM 8000Hz sample channel to the phone line just like your code above. It does not call the GetTxIvrSampleBlockSize() API proc because it assumes a sample block size of 160 PCM samples. You can add a call to the GetTxIvrSampleBlockSize() API proc in the PhoneCallActive() proceure above. Add it after the call to SetTxIvrDataType(). The GetTxIvrSampleBlockSize() proc should return the value of 160. This represents 20ms of sample data per block (160 sampls/8000 samples per second == 20ms)
2)
You should place your waveform generation code in its own thread. This thread will
be responsible for generating the PCM samples that get sent to the phone line. See
the DtmfGeneratorCallback() proc in the sample code.
When your application wants to generate DTMF, allow your “sample generation thread” to run and generate PCM samples in blocks of 160 samples each. For each 160 PCM samples you generate, send them to the phone line (in blocks of 160 samples) using the TransmitInCallIvrData() API proc. Once again, see the DtmfGeneratorCallback() proc for basic guide lines.
When you send sample blocks to the phone line, you have 2 choices:
Send a block, wait 20ms, send another block, etc…..
Or send a bunch of blocks to the phone line in one shot. The phone line IVR transmit channels can buffer up to 64 initial blocks (1.28 seconds worth of data).
3)
Finally, when the phone call enters the SipCallComplete, close the transmit IVR channel using the CloseTxIvrChannel() API proc. For an example of this, search the sample C++ code for:
void CSingleLinePhoneDlg::CallComplete(SIPHANDLE hSipEngine, int PhoneLine)
Repost as necessary.
LanScape support
|
Back to Top |
|
|
|
|