int sm_replay_start(struct sm_replay_parms *replayp)
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, kSMDataFormatSpeex=37, } type; /* in */ tSM_UT32 data_length; /* in */ tSM_UT32 sampling_rate; /* in */ } SM_REPLAY_PARMS;
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.
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 at least -24 to +8 in dB.
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 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 |
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 |
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:
The sampling rate firmware:
sampling rate | extra firmware required |
---|---|
8000 | - |
6000 | sixkout |
11000 | 11_to_8 |
12000 | sixkout |
16000 | - |
22000 | 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:
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.
0 if call completed successfully, otherwise a standard error such as:
This function is part of the Prosody speech processing API.