(Page 40 of 80 in this chapter)


adiRecordAsync

Description

Initiates recording in asynchronous buffer mode.

Prototype

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

ctahd Context handle returned by adiOpenPort.

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

maxmsec Maximum duration for recording (milliseconds).

buffer Pointer to buffer to receive recorded data.

bufsize Number of bytes available at 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 uses default values):

typedef struct
{
DWORD size; /* size of this structure */
DWORD DTMFabort;
/* mask that specifies DTMF tones to abort; */
/* 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 ; use 0 to deactivate. */ INT32 silenceampl; /* qualif level for silence (dBm) */ DWORD silencedeglitch;
/* deglitch while qualifying silence */
/*-[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 Requirement

Each encoding rate of this function requires a specific DSP file to be loaded by agmon as shown in the following table:

DSP File

Encoding Rate

voice.dsp/voxr.dsp

ADI_ENCODE_NMS_16,

ADI_ENCODE_NMS_24,

ADI_ENCODE_NMS_32,

ADI_ENCODE_NMS_64

rvoice.dsp

ADI_ENCODE_MULAW, ADI_ENCODE_ALAW, ADI_ENCODE_PCM8M16

okirec.dsp

ADI_ENCODE_OKI_24, ADI_ENCODE_OKI_32

wavrec.dsp

ADI_ENCODE_PCM11M8, ADI_ENCODE_PCM11M16

g726r.dsp

ADI_ENCODE_G726

Details

This function initiates a voice record operation. The data is supplied to the application in a sequence of buffers. The application submits empty buffers using adiSubmitRecordBuffer for the duration of the operation. These buffers are then filled with recorded voice data and ADIEVN_RECORD_BUFFER_FULL events are returned. The application has complete latitude and responsibility for allocating, flushing, and submitting the buffers.

When AG Access needs another buffer, it sets the ADI_RECORD_BUFFER_REQ bit in the event value field for the ADIEVN_RECORD_STARTED and ADIEVN_RECORD_BUFFER_FULL events. The application responds by submitting another empty buffer using adiSubmitRecordBuffer. The application should not submit buffers unless requested by AG Access. AG Access owns the buffer until either a ADIEVN_RECORD_BUFFER_FULL event or a ADIEVEN_RECORD_DONE event is delivered to the application.

The last buffer before the DONE event may be a partial buffer. The DONE event itself will not include a buffer of data.

The record operation terminates when the application receives the ADIEVN_RECORD_DONE event. You can also stop a record operation by sending a 0 (zero) length buffer.

For optimum performance, the bufsize should be the largest frame multiple that will fit in one AG board buffer. You can obtain this size by calling adiGetEncodingInfo (see the maxbufsize argument).

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

See Also

adiSubmitRecordBuffer, adiRecordToMemory, adiStartRecording, adiStopRecording, adiGetEncodingInfo

Example

See the playrec demonstration program.



(Page 40 of 80 in this chapter)


Tech_Support@nmss.com
Copyright © 1996, Natural MicroSystems, Inc. All rights reserved.