≡ Menu

Playing WAV File in Dialogic Boards

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 FilesDialogicdemosgc_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;
}

Next post:

Previous post:

{ 5 comments… add one }
  • shailendra April 17, 2009, 5:48 pm

    Thanks buddy…
    This is working….

  • Uttam Pegu April 20, 2009, 11:38 am

    Dear Shailendra,
    Thank you for your feedback.

    Regards

    Uttam Pegu

  • aaron December 18, 2009, 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

  • Pijush September 26, 2010, 10:03 am

    I’m using linux version of the demo application. My application shows audio play successfully but i didn’t hear any sound. here is code:

    int net, voice;
    if (gc_GetNetworkH(pline->ldev, &net) == GC_SUCCESS) {
    }
    if (gc_GetVoiceH(pline->ldev, &voice) == GC_SUCCESS) {
    }

    if (dx_adjsv(voice, SV_VOLUMETBL, SV_ABSPOS, SV_ADD4DB) == -1) {
    printf(“nUnable to increase volume level.n”);
    }

    DX_IOTT iott;
    DV_TPT tpt;
    DX_XPB xpb;

    xpb.wFileFormat = FILE_FORMAT_VOX;
    xpb.wDataFormat = DATA_FORMAT_DIALOGIC_ADPCM;
    xpb.nSamplesPerSec = DRT_8KHZ;
    xpb.wBitsPerSample = 4;

    dx_clrtpt(&tpt, 1);
    tpt.tp_type = IO_EOT;
    tpt.tp_termno = DX_MAXDTMF;
    tpt.tp_length = 10;
    tpt.tp_flags = TF_MAXDTMF;

    if (dx_clrdigbuf(voice) == -1) {
    printf(“nDigit Buffer Clear Errorn”);
    }

    iott.io_type = IO_DEV | IO_EOT;
    iott.io_bufp = 0;
    iott.io_offset = 0;
    iott.io_length = -1;
    iott.io_fhandle = open(“file.vox”, O_RDONLY);

    SC_TSINFO sc_tsinfo;
    long scts;
    sc_tsinfo.sc_numts = 1;
    sc_tsinfo.sc_tsarrayp = &scts;

    if (dx_getxmitslot(voice, &sc_tsinfo) == -1) {
    printf(“nError at dx_getxmitslot() function: %sn”, ATDV_ERRMSGP(
    voice));
    initiate_exit();
    exitdemo(1);
    } else {
    printf(“ndx_getxmitslot() function passed.n”);
    }

    sc_tsinfo.sc_numts = 1;
    sc_tsinfo.sc_tsarrayp = &scts;

    if (gc_GetXmitSlot(pline->ldev, &sc_tsinfo) == -1) {
    printf(“nError at gc_GetXmitSlot() function: %sn”, ATDV_ERRMSGP(
    voice));
    initiate_exit();
    exitdemo(1);
    } else {
    printf(“n gc_GetXmitSlot() function passed.n”);
    }

    if (gc_Listen(pline->ldev, &sc_tsinfo, EV_SYNC) == GC_SUCCESS) {
    printf(“ngc_Listen() function passed.n”);

    if (dx_listen(voice, &sc_tsinfo) == GC_SUCCESS) {
    printf(“ndx_listen() function passed.n”);

    if (dx_playiottdata(voice, &iott, &tpt, &xpb, EV_SYNC)
    != GC_SUCCESS) {
    printf(
    “nPLaying critical error dx_playiottdata() function %sn”,
    ATDV_ERRMSGP(voice));
    initiate_exit();
    exitdemo(1);
    } else {
    printf(“ndx_playiottdata() function passed.n”);
    printf(“nPlaying done….n”);
    }
    } else {
    printf(“ndx_listen() function failed….n”);
    initiate_exit();
    exitdemo(1);
    }

    } else {
    printf(“ngc_listen() function failed.n”);
    initiate_exit();
    exitdemo(1);
    }

    if (gc_UnListen(pline->ldev, EV_SYNC) == GC_SUCCESS) {
    printf(“n gc_unlisten() success.n”);
    }

    if (dx_unlisten(voice) == GC_SUCCESS) {
    printf(“n dx_unlisten() success.n”);
    initiate_exit();
    exitdemo(1);
    }

    Please help me.

  • PE October 29, 2014, 9:31 pm

    Hi, where can I find SDK for D/4PCIU dialogic board?

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.