340 Voice API for Windows Operating Systems Library Reference — November 2003
dx_rec( ) — record voice data from a single channel
#include <fcntl.h>
#include <srllib.h>
#include <dxxxlib.h>
#include <windows.h>
#define MAXLEN 10000
main()
{
DV_TPT tpt;
DX_IOTT iott[2];
int chdev;
char basebufp[MAXLEN];
/*
* open the channel using dx_open( )
*/
if ((chdev = dx_open("dxxxB1C1",NULL)) == -1) {
/* process error */
}
/*
* Set up the DV_TPT structures for MAXDTMF
*/
dx_clrtpt(&tpt,1);
tpt.tp_type = IO_EOT; /* last entry in the table */
tpt.tp_termno = DX_MAXDTMF; /* Maximum digits */
tpt.tp_length = 1; /* terminate on the first digit */
tpt.tp_flags = TF_MAXDTMF; /* Use the default flags */
/*
* Set up the DX_IOTT. The application records the voice data to memory
* allocated by the user.
*/
iott[0].io_type = IO_MEM|IO_CONT; /* Record to memory */
iott[0].io_bufp = basebufp; /* Set up pointer to buffer */
iott[0].io_offset = 0; /* Start at beginning of buffer */
iott[0].io_length = MAXLEN; /* Record 10,000 bytes of voice data */
iott[1].io_type = IO_DEV|IO_EOT; /* Record to file, last DX_IOTT entry */
iott[1].io_bufp = 0; /* Set up pointer to buffer */
iott[1].io_offset = 0; /* Start at beginning of buffer */
iott[1].io_length = MAXLEN; /* Record 10,000 bytes of voice data */
if((iott[1].io_fhandle = dx_fileopen("file.vox",
O_RDWR|O_CREAT|O_TRUNC|O_BINARY,0666)) == -1) {
/* process error */
}
/* clear previously entered digits */
if (dx_clrdigbuf(chdev) == -1) {
/* process error */
}
if (
dx_rec(chdev,&iott[0],&tpt,RM_TONE|EV_SYNC)
== -1) {
/* process error */
}
/* Analyze the data recorded */
.
.
}
!
!!
!Example 2
This example illustrates how to use dx_rec( ) in asynchronous mode.