Table of Contents Index NMS Glossary Previous Page Next Page (Page 29 of 69 in this chapter) Version


adiRecordToMemory

Description

Initiates recording into a single memory-resident buffer.

Prototype

DWORD adiRecordToMemory ( CTAHD ctahd,
unsigned encoding,
void *buffer,
unsigned bufsize,
ADI_RECORD_PARMS *parms )

ctahd CTA context handle returned by ctaCreateContext.

encoding Encoding type (refer to adidef.h for a complete list of ADI_ENCODING_xxx values).

buffer Pointer into process memory to receive encoded data.

bufsize Number of bytes pointed by buffer (bufsize can be arbitrarily large and is truncated to a multiple of the framesize for the selected encoding).

parms Pointer to record parameters according to the following structure (NULL designates default values):

typedef struct
{
DWORD size; /* Size of this structure */
DWORD DTMFabort; /* Abort on DTMF; */
INT32 gain; /* Recording gain in dB */
/*-[SLC parms (used if silence det)] */
DWORD novoicetime; /* Length of initial silence to stop */

/* Recording (ms); use 0 to deactivate */
/* Initial silence detection. */
DWORD silencetime; /* Length of silence to stop recording */
/* After voice has been detected (ms); */
/* Use 0 to deactivate. */
INT32 silenceampl; /* Qualif level for silence (dBm) */

DWORD silencedeglitch;

/* Deglitch while qualifying silence(ms) */

/*-[Beep for record] ---------------------*/

DWORD beepfreq; /* Beep frequency (Hz) */
INT32 beepampl; /* Beep amplitude (dBm) */
DWORD beeptime; /* Beep time (ms) 0=no beep */
/*--[AGC parms] --------------------------*/

DWORD AGCenable; /* Enable AGC; use 1 to activate */

INT32 AGCtargetampl; /* Target AGC level (dBm) */
INT32 AGCsilenceampl; /* Silence level (dBm) */
DWORD AGCattacktime; /* Attack time (ms) */
DWORD AGCdecaytime; /* Decay time (ms) */
} ADI_RECORD_PARMS;

Return Values

Events

DSP File

For AG and CG hardware, each encoding rate of this function requires a specific DSP file to be loaded. For more information about DSP files and encoding rates refer to adiPlayAsync.

Note: Refer to the QX 2000 Installation and Developer's Manual for DSP file information specific to the QX board family. Refer to the AG 2000 Installation and Developer's Manual, the AG 4000 Installation and Developer's Manual, and to the AG 4000C Installation and Developer's Manual for the DSP files for the AG 2000 and AG 4000/C boards. Refer to the CG 6000C Installation and Developer's Manual for the DSP files for the CG 6000C board.

Details

This function initiates recording to a memory-resident buffer of specified size and returns to the application. The ADI service records data into the buffer until one of the terminating conditions described in the ADIEVN_RECORDING_DONE event occurs.

Refer to the ADI Service Developer's Manual for a complete discussion of encoding methods, buffer sizes, and recording operations.

Note: You cannot initiate a record operation while playing voice or generating tones unless beeptime or beepfreq is 0. You cannot start a record operation if the energy detector is active, unless both novoicetime and silencetime are zero.

See Also

adiStartRecording, adiRecordAsync, adiStopRecording, adiGetEncodingInfo

Example


/* Record to supplied buffer, stopping after 1 second of silence. */
int myRecord( CTAHD ctahd, unsigned encoding,
              void *buf, unsigned bufsize, unsigned *bytesrecorded )
{
    ADI_RECORD_PARMS parms;
 CTA_EVENT        event;
    unsigned         datarate;          /* average bytes/sec */
    int              myret;
    unsigned         silencetime = 1000;
    unsigned         trimsize = 0;

    /* Modify default silence timeout */
    adiGetParms (ADI_RECORD_PARMID, &parms, sizeof parms);
    parms.silencetime = silencetime;

    if( adiRecordToMemory (ctahd, encoding, buf, bufsize, &parms) != SUCCESS )
        return MYFAILURE;

    do 
    {
        myGetEvent( &event );           /* see ctaWaitEvent example */
    } while (event.id != ADIEVN_RECORD_DONE);

    switch (event.value)
    {
        case CTA_REASON_FINISHED:           /* Buffer filled */
            myret = SUCCESS;
            break;

        case CTA_REASON_NO_VOICE:           /* No voice detected */
            *bytesrecorded = 0;
            myret = SUCCESS;
            break;

        case CTA_REASON_RELEASED:           /* The call was terminated */
            myret = MYDISCONNECT;
            break;

        case CTA_REASON_STOPPED:            /* adiStopRecording was called */
        case CTA_REASON_DIGIT:              /* Aborted due to touchtone */
            /* DTMF is trimmed automatically by AG board */
            *bytesrecorded = event.size;
            myret = SUCCESS;
            break;
        case CTA_REASON_VOICE_END:          /* Silence after voice */
            *bytesrecorded = event.size;
            adiGetEncodingInfo (ctahd, encoding, NULL, &datarate, NULL);
            trimsize = datarate * silencetime / 1000;
            myret = SUCCESS;
            break;
    
        default:                            /* an error code */
            myret = MYFAILURE;
            break;
    }

    if (myret == SUCCESS)
    {
        if (*bytesrecorded > trimsize)
            *bytesrecorded -= trimsize;
        else
            *bytesrecorded = 0;
    }

    return myret;
}



Table of Contents Index NMS Glossary Previous Page Next Page (Page 29 of 69 in this chapter) Version


Want to send us feedback on our documentation? Email: Tech_Pubs@nmss.com
Copyright © 2000, Natural MicroSystems, Inc. All rights reserved.