Prosody speech processing: API: sm_play_tone

Prototype Definition

int sm_play_tone(struct sm_play_tone_parms *tonep)

Parameters

*tonep
a structure of the following type:
typedef struct sm_play_tone_parms {
	tSMChannelId channel;					/* in */
	tSM_UT32 duration;					/* in */
	tSM_INT wait_for_completion;				/* in */
	tSM_INT tone_id;					/* in */
} SM_PLAY_TONE_PARMS;

Description

This call allows an application to generate a simple output tone specified by tone_id on a given output channel channel, either continuously or for a given duration.

The parameter tone_id references one of the pre-loaded simple output tones, listed in Prosody speech processing: pre-loaded output tones, or one previously defined through a call to sm_add_output_tone().

If the tone is to be output continuously (or until aborted with sm_play_tone_abort()), the parameter duration should be set to zero. Otherwise duration should be set to the required tone duration in milliseconds.

The wait_for_completion flag may be set by the application in which case this API call will not return until the tone has been completely output, however no other Prosody API function can be performed on the channel during this waiting period. Obviously setting this flag is not useful when the tone has been specified as being a continuous tone since there would then be no way to stop the tone. See the document Prosody application note: waiting for completion for examples of how to wait without blocking other functions.

Alternatively the application can wait to be notified by an event that tone generation of a given duration has completed. When a write event has been associated with channel (see sm_channel_set_event), then the driver will notify the application with that event whenever it needs to invoke sm_play_tone_status().

This requires the module tonegen to have been downloaded.

The channel is reserved for playing the tone until the API has reported completion. If the wait_for_completion flag is set, then the API considers that completion has been reported when this API function returns, otherwise completion is reported only by sm_play_tone_status() returning the status kSMPlayToneStatusComplete. In this case the application must call sm_play_tone_status() repeatedly until it reports completion. It should use an event on the channel to notify it when to check the status. No other output activity can take place on the channel until the completion of the tone has been reported, Note that the event itself does not indicate completion of the tone. It is possible for the event to be signalled even if the tone has not yet completed, so it is essential that the application checks the status and continues waiting if the tone has not completed.

Fields

channel
The channel on which the tone is to be generated.
duration
The duration of the tone, or the value zero to indicate a tone that will continue until explicitly aborted with sm_play_tone_abort().
wait_for_completion
An indicator of whether this function would return as soon as it has set up the generation of the tone (0), or wait until the end of the tone (non-zero).
tone_id
The tone to generate.

Returns

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


This function is part of the Prosody speech processing API.