vceSetWaveInfo

Loads a new entry in the WAVE encoding table.

Prototype

DWORD vceSetWaveInfo ( CTAHD ctahd, unsigned encoding, VCE_WAVE_INFO *waveinfo)

Argument

Description

ctahd

Handle returned by ctaCreateContext or ctaAttachContext.

encoding

Encoding ID.

waveinfo

Buffer to receive the following VCE_WAVE_INFO structure:

typedef struct
{
  DWORD  size;
  WORD   format;
  WORD   nchannels;
  DWORD  samplespersec;
  DWORD  datarate;
  WORD   blocksize;
  DWORD  bitspersample;
} VCE_WAVE_INFO;

The VCE_WAVE_INFO structure fields are described in the Details section.


Return values

Return value

Description

SUCCESS

 

CTAERR_BAD_SIZE

size is less than the size of VCE_WAVE_INFO.

CTAERR_INVALID_CTAHD

Context handle is invalid.

CTAERR_SVR_COMM

Server communication error.

VCEERR_MIXED_ENCODING

A different entry for the same encoding exists in this or another context.


Details

vceSetWaveInfo adds an entry to the Voice Message service wave information table. The Voice Message service maintains this table to map encoding values to WAVE file header information. vceCreateFile uses this table to create a new WAVE file for a specified encoding. vceOpenFile uses this table to determine the encoding used in an existing WAVE file.

The table contains compiled-in entries for all of the encoding values in vcedef.h. If an attached play or record service makes another encoding available, add a new entry to the table using vceSetWaveInfo to play or record WAVE files with the new encoding.

The VCE_WAVE_INFO structure contains the following fields:

Field

Description

size

Size of the structure, in bytes. This is set to:

sizeof (VCE_WAVE_INFO)

format

WAVE format type as defined by Microsoft, for example, WAVE_FORMAT_PCM (defined in the Microsoft header file mmreg.h).

nchannels

Number of discrete channels in the format. Use 1 for mono and 2 for stereo.

samplespersec

Sample rate in samples per second.

datarate

Average bytes per second.

blocksize

Minimum block size of the data. For PCM data, the block size is the number of bytes in a single sample.

bitspersample

Number of bits per sample.


See also

vceGetWaveInfo

Example

/*
 * Add 11 khz 8 bit stereo PCM encoding to the WAVE info table.
 * The encoding value is passed in.
 */

#define WAVE_FORMAT_PCM  1    /* As defined in mmreg.h */

DWORD myAdd11khzStereo(CTAHD ctahd, unsigned encoding)
{
    VCE_WAVE_INFO waveinfo;
    waveinfo.size           = sizeof waveinfo ;
    waveinfo.format         = WAVE_FORMAT_PCM;
    waveinfo.nchannels      = 2;       /* stereo           */
    waveinfo.samplespersec  = 11025;
    waveinfo.datarate       = 22050;   /* bytes per second */
    waveinfo.blocksize      = 2;       /* 2 8-bit channels */
    waveinfo.bitspersample  = 8;

    return vceSetWaveInfo(ctahd, encoding, &waveinfo);
}