Prosody speech processing: API: sm_play_cptone

Prototype Definition

int sm_play_cptone(struct sm_play_cptone_parms *cptonep)

Parameters

*cptonep
a structure of the following type:
typedef struct sm_play_cptone_parms {
	tSMChannelId channel;					/* in */
	tSM_UT32 duration;					/* in */
	tSM_INT wait_for_completion;				/* in */
	enum kSMPlayCPToneType {
		kSMPlayCPToneTypeOneShot,
		kSMPlayCPToneTypeRepeat,
		kSMPlayCPToneTypeContinuous,
	} type;							/* in */
	tSM_INT tone_count;					/* in */
	struct sm_cadence {
		tSM_INT tone_id;				/* in */
		tSM_INT on_cadence;				/* in */
		tSM_INT off_cadence;				/* in */
	} cadences[kSMMaxPlayCPToneCadences];			/* in */
} SM_PLAY_CPTONE_PARMS;

Description

This call allows an application to generate a call-progress tone on specified output channel channel.

If the call-progress tone is to be output continuously (or until interrupted by sm_play_cptone_abort()), the parameter duration should be set to zero. Otherwise duration should be set to the required call-progress tone duration in milliseconds (the duration parameter is ignored if type is kSMPlayCPToneTypeOneShot).

Each element of cadences specifies an on-period on_cadence and an off-period off_cadence both specified in milliseconds, and also tone_id referencing to one of the module's currently defined simple output tones (see Prosody speech processing: pre-loaded output tones, for list of ids for output tones downloaded with module firmware and see description of sm_add_output_tone() for how an application may define its own simple output tones). Here are some examples of call-progress tones which use kSMPlayCPToneTypeRepeat:

Nametone_count cadences
postone_idon_cadenceoff_cadence
U.K. ring tone2 017 400 208
117 400 2000
U.K. busy1 016 384 384
E.C. busy1 018 512 512
S.I.T.3 019 336 32
120 336 32
221 336 1008

The wait_for_completion flag may be set by the application in which case the API call will not complete 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 with no fixed duration, 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_cptone_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_cptone_status() returning the status kSMPlayCPToneStatusComplete. In this case the application must call sm_play_cptone_status() periodically and 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.

Note that the only way to stop a continuous tone is by calling sm_play_cptone_abort().

Fields

channel
The channel on which the tone is to be played.
duration
The duration of the tone (mS), or the value zero for indefinite length. This parameter is ignored if type is kSMPlayCPToneTypeOneShot.
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). If this value is zero, the application must have an event associated with this channel and invoke sm_play_cptone_status() whenever the event is set.
type
The style of playing to use. One of these values:
kSMPlayCPToneTypeOneShot
Output sequence of tone_count cadences just once.
kSMPlayCPToneTypeRepeat
Repeatedly output sequence of tone_count cadences.
kSMPlayCPToneTypeContinuous
Continuously output tone specified by tone_id in first element of cadences. Both on_cadence, off_cadence and other elements of cadences are ignored. Since this is the same as using sm_play_tone(), the use of this value is deprecated in favour of sm_play_tone().
tone_count
The number of items in cadences.
cadences
The sequence of tones.
tone_id
A tone identifier.
on_cadence
The duration (in mS) that this tone is on for.
off_cadence
The duration (in mS) of silence after this tone.

Returns

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


This function is part of the Prosody speech processing API.