Return to LanScape's home page Go back a page...       Active TopicsActive Topics   Display List of Forum MembersMember List   Knowledge Base SearchSearch   HelpHelp  RegisterRegister  LoginLogin

LanScape VOIP Media Engine™ - Technical Support
 LanScape Support Forum -> LanScape VOIP Media Engine™ - Technical Support
Subject Topic: DTMF generation Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
timkelly1980
Intermediate
Intermediate


Joined: February 07 2005
Posts: 25
Posted: May 30 2005 at 11:17am | IP Logged Quote timkelly1980

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 View timkelly1980's Profile Search for other posts by timkelly1980
 
timkelly1980
Intermediate
Intermediate


Joined: February 07 2005
Posts: 25
Posted: May 30 2005 at 1:02pm | IP Logged Quote timkelly1980

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 View timkelly1980's Profile Search for other posts by timkelly1980
 
support
Administrator
Administrator


Joined: January 26 2005
Location: United States
Posts: 1666
Posted: June 03 2005 at 11:12am | IP Logged Quote support


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 View support's Profile Search for other posts by support Visit support's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum






Contact LanScape Hear what the Lawyers have to say How youm may use this site Read your privacy rights