Prosody WAV BFILE: API

The following functions are provided by the Prosody WAV BFILE API:

API call W Description
sm_replay_wav_bf_start()   Play a WAV file
sm_replay_wav_bf_close()   Close a WAV file opened by sm_replay_wav_bf_start
sm_record_wav_bf_start()   Record into a WAV file
sm_record_wav_bf_close()   Close a WAV file created by sm_record_wav_bf_start
sm_record_wav_bf_trim_close()   Trim and close a WAV file created by sm_record_wav_bf_start
sm_replay_wav_bf_get_type()   Determine the type of data in a WAV file

This document is also available as separate pages for each function.


Prosody WAV BFILE: API: sm_replay_wav_bf_start

Prototype Definition

int sm_replay_wav_bf_start(char *filename, SM_BFILE_REPLAY_PARMS *file_parms)

Parameters

filename
The name of the WAV file to be played.
file_parms
A pointer to a structure as for sm_replay_bfile_start().

Description

Opens and parses header of WAV file, sets up fd, replay_parms.type, and replay_parms.data_length, in structure pointed at by file_parms and then invokes sm_replay_bfile_start.

The other elements of the replay_parms structure must be set up as for sm_replay_bfile_start(). Note that the offset is assumed to be relative to the first octet of speech data following the WAV header. If offset, and replay_parms.data_length, are both set to zero then file_parms will be set up to replay all the speech data in the WAV file.

Note: It is the responsibility of the application to operate the replay as described in Prosody high level BFILE play/record documentation and to close the file following replay completion or abort (using sm_replay_wav_bf_close()).

Returns

0 if call completed successfully, otherwise a standard error such as:


Prosody WAV BFILE: API: sm_replay_wav_bf_close

Prototype Definition

int sm_replay_wav_bf_close(SM_BFILE_REPLAY_PARMS *file_parms)

Parameters

file_parms
A pointer to a structure passed into sm_replay_wav_bf_start() to start a replay which has not yet been closed.

Description

Following completion of WAV file replay this function may be called to close the replay file and release the associated file descriptor.

Returns

0 if call completed successfully, otherwise a standard error such as:


Prosody WAV BFILE: API: sm_record_wav_bf_start

Prototype Definition

int sm_record_wav_bf_start(char *filename, SM_BFILE_RECORD_PARMS *file_parms)

Parameters

filename
file_parms
A pointer to a structure as for sm_record_bfile_start().

Description

Creates file with given name, allocates space in file by writing blank WAV file header, sets up fd in structure pointed at by file_parms and then invokes sm_record_bfile_start.

The other elements of the record_parms. structure must be set up as for sm_record_bfile_start. The setting of the record_parms.type, parameter will determine type of WAV file created.

Note it is the responsibility of the application to close the file following record completion or abort using sm_record_wav_bf_close().

Returns

0 if call completed successfully, otherwise a standard error such as:


Prosody WAV BFILE: API: sm_record_wav_bf_close

Prototype Definition

int sm_record_wav_bf_close(SM_BFILE_RECORD_PARMS *file_parms)

Parameters

file_parms
A pointer to a structure passed into sm_record_wav_bf_start() to start a record which has not yet been closed.

Description

Following completion of a recording into a WAV file this function must be called to write the correct WAV header in space previously reserved by sm_record_wav_bf_start() then closes the file.

Note that the sampling_rate of the record_parms structure must be set to the recorded sample rate,as returned by sm_record_status(). This is done automatically except when sm_record_bfile_progress_istatus() has been used.

Returns

0 if call completed successfully, otherwise a standard error such as:


Prosody WAV BFILE: API: sm_record_wav_bf_trim_close

Prototype Definition

int sm_record_wav_bf_trim_close(SM_BFILE_RECORD_PARMS *file_parms, tSM_UT32 trimLength)

Parameters

file_parms
A pointer to a structure passed into sm_record_wav_bf_start() to start a record which has not yet been closed.
trimLength
The number of octets to trim from the end of the data.

Description

trimLength octets of data are subtracted from the WAV file length recorded in the WAV header and hence this amount of data will be omitted from the end of a replay of this WAV file. Then a sm_record_wav_bf_close() is performed.

Note that the sampling_rate of the record_parms structure must be set to the recorded sample rate,as returned by sm_record_status(). This is done automatically except when sm_record_bfile_progress_istatus() has been used.

Returns

0 if call completed successfully, otherwise a standard error such as:


Prosody WAV BFILE: API: sm_replay_wav_bf_get_type

Prototype Definition

int sm_replay_wav_bf_get_type(char *filename, int *replay_type)

Parameters

filename
The name of a WAV file.
replay_type
The address of where the data type code is to be saved.

Description

Given name of existing WAV file, returns in replay_type Prosody API data format type id that would be used by sm_replay_start.

Returns

0 if call completed successfully, otherwise a standard error such as:


These functions constitute the Prosody WAV BFILE API.