Prosody speech processing: API: sm_replay_start

Prototype Definition

int sm_replay_start(struct sm_replay_parms *replayp)

Parameters

*replayp
a structure of the following type:
typedef struct sm_replay_parms {
	tSMChannelId channel;					/* in */
	tSMChannelId background;				/* in */
	tSM_INT volume;						/* in */
	tSM_INT agc;						/* in */
	tSM_INT speed;						/* in */
	enum kSMDataFormat {
		kSMDataFormatNone=0,
		kSMDataFormatALawPCM=30,
		kSMDataFormatULawPCM=31,
		kSMDataFormatOKIADPCM=32,
		kSMDataFormatACUBLKPCM=33,
		kSMDataFormat16bit=34,
		kSMDataFormat8bit=35,
		kSMDataFormatSigned8bit=36,
		kSMDataFormatIMAADPCM=17,
	} type;							/* in */
	tSM_UT32 data_length;					/* in */
	/* Only in Prosody version 2 (TiNG) */
	tSM_UT32 sampling_rate;					/* in */
	/* End of part only in Prosody version 2 (TiNG) */
} SM_REPLAY_PARMS;

Description

Prepares output channel channel for replay of data (a replay job).

Normally the background parameter would be set to kSMNullChannelId. If however, this parameter has assigned to it the channel id of another output channel, then the signal generated on the output channel channel will be combined with the data currently being output on background. Note that a channel must not be reconfigured while it is in use as a background channel for other channels.

Only on Prosody version 1:

The background signal will continue to be output even when the replay job completes.

Only on Prosody version 2 (TiNG):

To keep a continuous background signal while playing a mixture of different recorded signals and silence, start the replay only once and use sm_put_replay_data() as necessary to feed it data for each signal. To produce silence, simply stop sending data for a suitable period (the channel will report an underrun when it starts sending silence).

The volume parameter determines the gain applied to the replayed data and has a range of -24 to +8 in dB. Only on Prosody version 2 (TiNG): A wider range may be accepted.

The agc parameter controls whether automatic gain control is applied to the replayed data. If agc is non-zero then automatic gain control is applied. Even if this is the case, the output level is still governed by volume. The behaviour of the AGC algorithm may be controlled by changing its parameters, see sm_adjust_agc_module_params for more details.

The speed parameter determines rate of replay and is a percentage value expressing the rate of replay compared with the normal replay rate. Only certain speeds are supported, so the speed specified is rounded to the nearest supported value. The following speeds are currently supported:

Ratio Percentage
2:1 200
3:2 150
4:3 133
1:1 100
3:4 75
2:3 67
1:2 50
Only on Prosody version 2 (TiNG): An application should not rely on a speed being rounded to a specific value. Other speeds may also be supported, so a requested speed may round to a value nearer than expected.

If speed is set to zero, the data is replayed at an unadjusted rate.

The type parameter determines the format of data that will played back over the timeslot.

Note that, for compatibility with earlier releases of Prosody, many other values are permitted for the type field. These compatibility values specify a combination of data type and sampling rate. When one of these is used in the type field, the sampling_rate field must be zero, and the actual rate used will be as listed here. They are:

compatibility code new code
type sampling rate
kSMDataFormat8KHzALawPCM kSMDataFormatALawPCM 8000
kSMDataFormat8KHzULawPCM kSMDataFormatULawPCM 8000
kSMDataFormat8KHzOKIADPCM kSMDataFormatOKIADPCM 8000
kSMDataFormat8KHzACUBLKPCM kSMDataFormatACUBLKPCM 8000
kSMDataFormat6KHzALawPCM kSMDataFormatALawPCM 6000
kSMDataFormat6KHzULawPCM kSMDataFormatULawPCM 6000
kSMDataFormat6KHzOKIADPCM kSMDataFormatOKIADPCM 6000
kSMDataFormat6KHzACUBLKPCM kSMDataFormatACUBLKPCM 6000
kSMDataFormat8KHz16bitMono kSMDataFormat16bit 8000
kSMDataFormat8KHz8bitMono kSMDataFormat8bit 8000
kSMDataFormat8KHzSigned8bitMono kSMDataFormatSigned8bit 8000
kSMDataFormatIMAADPCM kSMDataFormatIMAADPCM 8000

Only on Prosody version 1: The following notes apply:
Only on Prosody version 2 (TiNG): Any form of replay requires the module outchan to have been downloaded in addition to the module that is required for the specific type of replay, and any module required for the sampling rate:

replay type extra firmware required
kSMDataFormatALawPCM playA
kSMDataFormatULawPCM playmu
kSMDataFormatOKIADPCM playoki
kSMDataFormatACUBLKPCM playablk
kSMDataFormatSigned8bit play8b
kSMDataFormat8bit playms8b
kSMDataFormat16bit play16b
kSMDataFormatIMAADPCM playima

The sampling rate firmware:

sampling rate extra firmware required
8000 -
6000 sixkout
11000 11_to_8

See document Prosody application note: speech processing replay and record data formats for more details on data formats supported by Prosody and their appropriate use.

The data_length parameter indicates the total number of octets of speech data that the application intends to supply to the driver for replay on the given timeslot. If data_length is set to zero, the replay will be of indefinite length (in this case the replay job can be completed with sm_put_last_replay_data()).

If an event has been previously associated with channel (see sm_channel_set_event), then the driver will notify the application with that event whenever:

Only on Prosody version 1: Note replay will not actually be initiated until the first few buffers of data are supplied by calls to sm_put_replay_data().
Only on Prosody version 2 (TiNG): The channel is reserved for replaying until sm_replay_status() returns the status kSMReplayStatusComplete. No other output activity can take place on the channel during this time.

Fields

channel
The channel to perform the replay.
background
A channel which is producing a signal to be added to the replay signal. Only on Prosody version 2 (TiNG): Requires the module gainbg.
volume
The volume adjustment (dB). Only on Prosody version 2 (TiNG): Requires the module gainbg.
agc
Indicator of whether automatic gain control is to be enabled. (non-zero) or not (zero). Only on Prosody version 2 (TiNG): Requires the module gainbg.
speed
The percentage of full speed at which the replay should work. The value zero also represents full speed.
Only on Prosody version 2 (TiNG): Speeds faster than 100% require the module fast to have been downloaded, while speeds slower than 100% require the module slow.
type
The type of data to replay. (See the main text above for compatibility codes that can also be used in this field.) One of these values:
kSMDataFormatNone
Special value for test purposes only. This indicates that the channel should prepare as if it was about to play or record data, but not actually transfer any data.
kSMDataFormatALawPCM
G.711 A-law. This uses 8 bits per sample.
kSMDataFormatULawPCM
G.711 mu-law. This uses 8 bits per sample.
kSMDataFormatOKIADPCM
A 4-bit coding scheme.
kSMDataFormatACUBLKPCM
Aculab proprietary compressed speech. It averages two bits per sample, but encodes blocks of speech, so it does not have an exact bit rate per sample.
kSMDataFormat16bit
16-bit linear coding, where each sample is a signed value (-32768 to 32767). The first octet of each sample is the less significant one.
kSMDataFormat8bit
8-bit unsigned linear coding, where each sample is an unsigned value (0 to 255). This is Microsoft's 8-bit format.
kSMDataFormatSigned8bit
8-bit linear coding, where each sample is a signed value (-128 to 127).
kSMDataFormatIMAADPCM
A 4-bit coding scheme standardised by the Interactive Multimedia Association (IMA).
data_length
The length of the replay (in octets) or zero for indefinite length replay.
sampling_rate (Only in Prosody version 2 (TiNG))
The sampling rate of the data to be played. Currently supported values are:

Returns

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


This function is part of the Prosody speech processing API.