Playing WAV File in Dialogic Boards

by Uttam Pegu on April 15, 2009

Dialogic boards can play VOX files as well as WAV files. While many people use dx_playwav() function of Dialogic API to play WAV files, dx_playiottdata() function can also be used to play WAV files as shown in the code snippet below.

While the most famous dialogic sample demo application does not play any audio file, found in C:\Program Files\Dialogic\demos\gc_basic_call_model ( by default), gc_basic_call_model.c is the should be the first sample program for anyone willing to develop IVR Software of IVRS Applications using Dialogic Boards.

Using WAV file in IVRS Software has advantage. There are many WAV file editors, some free and some licensed available to make WAV files easily. Use of many TTS engines too becomes much easier if WAV file is used for playback of voice prompts. But VOX file does not have necessarily any disadvantage! It can be just a personal choice.

While searching internet, I tried to find some sample code snippet for playing WAV files using dx_playiottdata(), and I could not find one. So I thought I myself should put up a sample code snippet which might be useful to some beginners.

Here is the code snippet:

int play(char *filename)
{
int retStatus = -1; // Unknown Error

int handle;
char filepath[1000];

strcat(filepath,filename);

if ( ( handle= dx_fileopen( filepath, O_RDONLY|O_BINARY, 0666) ) == -1 )
{
// Errore handling here
}

/* rewind to top of file */
lseek(handle,0L,0);

/*
* Clear and Set-Up the IOTT strcuture
*/
memset( iott, 0, sizeof( DX_IOTT ) );

iott[ 0 ].io_type = IO_DEV | IO_EOT;
iott[ 0 ].io_fhandle = handle;
iott[ 0 ].io_length = -1;

/*
* Clear and then Set the DV_TPT structures
*/
memset( tpt, 0, sizeof( DV_TPT ) );

/* Terminate Play on Receiving any DTMF tone */
tpt[ 0 ].tp_type = IO_CONT;
tpt[ 0 ].tp_termno = DX_MAXDTMF;
tpt[ 0 ].tp_length = 1;
tpt[ 0 ].tp_flags = TF_MAXDTMF;

if(dx_playiottdata(voiceh,iott,tpt,&xpbWavTbl[0],EV_ASYNC)==-1)
{
// Error Handling
retStatus = 1;
}
else
{
// Playy successfully
retStatus = 0;
}

return retStatus;
}

Popularity: 8% [?]


{ 3 comments… read them below or add one }

1 shailendra April 17, 2009 at 5:48 pm

Thanks buddy…
This is working….

2 Uttam Pegu April 20, 2009 at 11:38 am

Dear Shailendra,
Thank you for your feedback.

Regards

Uttam Pegu

3 aaron December 18, 2009 at 8:04 pm

hi

Any one know how to Terminate Play on Receiving any DTMF tone but keeping the digit in the digit buffer?

regards
aaron

Leave a Comment

Previous post:

Next post:

Page 1 of 0