Prosody signal path processing: API

The following functions are provided by the Prosody signal path processing API:

API call W Description
sm_path_agc()   Configure a signal path to perform automatic gain control
sm_path_agc_adjust_settings()   Adjust AGC settings.
sm_path_avf_amrnb_dec() P Configure a signal path to decode AVF encapsulated AMR-NB encoded data to linear audio
sm_path_avf_amrnb_enc() P Configure a signal path to encode linear audio to AVF encapsulated AMR-NB encoded data
sm_path_create()   Create a signal path
sm_path_datafeed_connect()   Connect a datafeed to a signal path
sm_path_delay()   Configure a signal path to apply a delay to signal
sm_path_destroy()   Destroy a previously allocated signal path
sm_path_echocancel()   Configure a signal path to perform echo cancellation
sm_path_emphasis()   Configure a signal path to apply a filter to emphasise or deemphasise high frequencies
sm_path_get_datafeed()   Obtain a datafeed from a signal path
sm_path_get_event()   Obtain an event for a path
sm_path_mix()   Configure a signal path to add in another signal
sm_path_pitchshift()   Configure a signal path to perform pitch shifting
sm_path_resample()   Configure a signal path to convert signal to a different sampling rate
sm_path_status()   Determine path status
sm_path_stop()   Instructs a path to stop all processing
sm_path_tonedetect()   Configure a signal path to detect and optionally eliminate tones
sm_path_ttyeliminate()   Configure a signal path to eliminate TTY signals

Key to W column:

P Preliminary documentation - this functionality is under development. It could be changed or withdrawn, and may not be implemented in this release

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


Prosody signal path processing: API: sm_path_agc

Prototype Definition

int sm_path_agc(struct sm_path_agc_parms *agcp)

Parameters

*agcp
a structure of the following type:
typedef struct sm_path_agc_parms {
	tSMPathId path;						/* in */
	tSM_INT agc;						/* in */
	tSM_INT volume;						/* in */
} SM_PATH_AGC_PARMS;

Description

Configures automatic gain control and fixed volume adjustment on a signal path. The agc parameter controls whether or not automatic gain control is applied to the signal. If agc is non-zero then automatic gain control is applied. The volume adjustment specified is performed after the AGC and has a range of at least -24 to +8 dB. Volume adjustment is always applied, even if AGC is disabled.

Requires the module gainbg.

Fields

path
The signal path to be configured
agc
Indicator of whether automatic gain control is to be enabled (non-zero) or disabled (zero).
volume
The volume adjustment (dBm0).

Returns

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


Prosody signal path processing: API: sm_path_agc_adjust_settings

Prototype Definition

int sm_path_agc_adjust_settings(struct sm_path_agc_adjust_settings_parms *agcadjp)

Parameters

*agcadjp
a structure of the following type:
typedef struct sm_path_agc_adjust_settings_parms {
	tSMPathId path;						/* in */
	float max_level_decay;					/* in */
	float target_level;					/* in */
} SM_PATH_AGC_ADJUST_SETTINGS_PARMS;

Description

Fields

path
The signal path which has AGC enabled.
max_level_decay
The rate at which the AGC decays the estimate of the loudest signal, as a fraction.
target_level
The target output level in dBm0.

Returns

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


Prosody signal path processing: API: sm_path_avf_amrnb_dec

This function is under development. It could be changed or withdrawn, and may not be implemented in this release.

Prototype Definition

int sm_path_avf_amrnb_dec(struct sm_path_avf_amrnb_dec_parms *amrnbdecparms)

Parameters

*amrnbdecparms
a structure of the following type:
typedef struct sm_path_avf_amrnb_dec_parms {
	tSMPathId path;						/* in */
	tSM_INT enable;						/* in */
} SM_PATH_AVF_AMRNB_DEC_PARMS;

Description

Configures AVF encapsulated AMR-NB decoding on a signal path.

Fields

path (Only in Preliminary Documentation)
The signal path to be configured
enable (Only in Preliminary Documentation)
Enables (non-zero) or disables (zero) the AMR-NB decoder.

Returns

0 if call completed successfully, otherwise a standard error.


Prosody signal path processing: API: sm_path_avf_amrnb_enc

This function is under development. It could be changed or withdrawn, and may not be implemented in this release.

Prototype Definition

int sm_path_avf_amrnb_enc(struct sm_path_avf_amrnb_enc_parms *amrnbencparms)

Parameters

*amrnbencparms
a structure of the following type:
typedef struct sm_path_avf_amrnb_enc_parms {
	tSMPathId path;						/* in */
	tSM_INT enable;						/* in */
	tSM_INT payload_type;					/* in */
	tSM_INT bitrate;					/* in */
	tSM_INT vad_enable;					/* in */
} SM_PATH_AVF_AMRNB_ENC_PARMS;

Description

Configures AVF encapsulated AMR-NB encoding on a signal path. Requires the module amr-nb-prs or amr-nb-all.

Fields

path (Only in Preliminary Documentation)
The signal path to be configured
enable (Only in Preliminary Documentation)
Enables (non-zero) or disables (zero) the AMR-NB encoder.
payload_type (Only in Preliminary Documentation)
The payload type which should be used in the output AVF. Note that on AVF replay the payload type in the AVF is ignored so, in general, the value supplied here is irrelevant. However if, for instance, the resulting file was to be output using a streaming server, the payload type may well be used.
bitrate (Only in Preliminary Documentation)
The speed to use in bits per second. It must be one of the speeds which the AMR codec can encode, which are: 4750, 5150, 5900, 6700, 7400, 7950, 10200, and 12200.
vad_enable (Only in Preliminary Documentation)
Whether to enable the Voice Activity Detector.

Returns

0 if call completed successfully, otherwise a standard error.


Prosody signal path processing: API: sm_path_create

Prototype Definition

int sm_path_create(struct sm_path_create_parms *createp)

Parameters

*createp
a structure of the following type:
typedef struct sm_path_create_parms {
	tSMPathId path;						/* out */
	tSMModuleId module;					/* in */
} SM_PATH_CREATE_PARMS;

Description

Creates a signal path. A signal path permits a variety of transformations to be performed on a signal. If no transformations are enabled, a path acts as a pass through.

The modules inchan and passthru are required.

Fields

path
The created signal path.
module
A value obtained from sm_open_module() which indicates the module on which the path is to be created.

Returns

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


Prosody signal path processing: API: sm_path_datafeed_connect

Prototype Definition

int sm_path_datafeed_connect(struct sm_path_datafeed_connect_parms *datafeedp)

Parameters

*datafeedp
a structure of the following type:
typedef struct sm_path_datafeed_connect_parms {
	tSMPathId path;						/* in */
	tSMDatafeedId data_source;				/* in */
} SM_PATH_DATAFEED_CONNECT_PARMS;

Description

Connects a datafeed to a signal path. The data_source must be a datafeed obtained from sm_channel_get_datafeed(), sm_tdmrx_get_datafeed() sm_vmprx_get_datafeed() or sm_path_get_datafeed(). Datafeed connections can only be made between objects allocated on the same tSMModuleId. The signal path path will receive any data that is generated by the output task from which data_source was derived.

To disconnect a signal path from a datafeed, specify kSMNullDatafeedId as the tSMDatafeedId in data_source

Requires the module datafeed to have been downloaded.

Fields

path
The signal path that will receive and process the data
data_source
The datafeed acting as a source of data for the signal path

Returns

0 if call completed successfully, otherwise a standard error.


Prosody signal path processing: API: sm_path_delay

Prototype Definition

int sm_path_delay(struct sm_path_delay_parms *delayparms)

Parameters

*delayparms
a structure of the following type:
typedef struct sm_path_delay_parms {
	tSMPathId path;						/* in */
	tSM_INT enable;						/* in */
	tSM_INT delay;						/* in */
} SM_PATH_DELAY_PARMS;

Description

Delays signal by specified number of samples. If signal path already has a delay configured, the delay is changed to new value. A new or increased delay has gap filled with silence.

Requires the module delay to be loaded.

Fields

path
The signal path to be configured
enable
Enables (non-zero) or disables (zero) delay.
delay
Delay value measured in samples.

Returns

0 if call completed successfully, otherwise a standard error.


Prosody signal path processing: API: sm_path_destroy

Prototype Definition

int sm_path_destroy(tSMPathId path)

Parameters

path
A tSMPathId that has been prevously created by a call to sm_path_create() .

Description

Destroys path and invalidates the tSMPathId.

Returns

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


Prosody signal path processing: API: sm_path_echocancel

Prototype Definition

int sm_path_echocancel(struct sm_path_echocancel_parms *cancelp)

Parameters

*cancelp
a structure of the following type:
typedef struct sm_path_echocancel_parms {
	tSMPathId path;						/* in */
	tSM_INT enable;						/* in */
	tSMDatafeedId reference;				/* in */
	tSM_INT non_linear;					/* in */
	enum kSMPathEchoNonLinearMode {
		kSMPathEchoNonLinearModeMuting,
		kSMPathEchoNonLinearModeCNG,
	} mode;							/* in */
	tSM_INT use_agc;					/* in */
	tSM_INT fix_agc;					/* in */
	tSM_INT span;						/* in */
	tSM_INT delay;						/* in */
	enum kSMPathEchoToneAction {
		kSMPathEchoToneActionNone,
		kSMPathEchoTonetActionMuteTTY,
	} tone_action;						/* in */
} SM_PATH_ECHOCANCEL_PARMS;

Description

Configures echo cancellation on a signal path. The input is examined for an echo of the reference signal, and any echo found is suppressed.

Non-linear echo cancellation can operate in two modes. The default is non-linear echo cancellation with muting, which is suitable for large-scale conferencing and/or IVR applications, where it is important that the signal is completely muted whenever the caller is not speaking.

Non-linear echo cancellation with comfort noise generation (CNG) never mutes the signal. Instead it replaces any residual traces of echo with "comfort noise". This mode of operation is most appropriate to IP gateway applications where background noise is desirable to maintain the illusion of continuity.

If tone_action is set to mute TTY, the echo cancellation algorithm will expect to encounter TTY tones on its primary input and its reference. Its output will be muted whenever such tones are present on its reference and for a short time afterwards (thus muting echoes of tones). It will pass though TTY tones present on its primary input at other times. This behaviour should only be enabled if TTY tones are expected in the signal path. It would normally be used with non-linear mode disabled.

Requires the module echocan.

Fields

path
The signal path to be configured
enable
Enables (non-zero) or disables (zero) echo cancellation of the input signal.
reference
The datafeed which is the reference signal. Only used if enable is non-zero.
non_linear
Enables (non-zero) or disables (zero) non-linear processing. The exact behaviour of the non-linear processing module is controlled by mode . Negative values represent the lower limit in dBm0. Positive values cause the default value of -42dBm0 to be used. Only used if enable is non-zero.
mode
Selects the non-linear echo cancellation mode to be used. Only used if non_linear is non-zero. One of these values:
kSMPathEchoNonLinearModeMuting
Uses non-linear processing to suppress the signal whenever echo or background noise are dominant. This mode of operation is suitable for large-scale conferencing and/or IVR applications, where it is important that the signal is completely muted whenever the caller is not speaking.
kSMPathEchoNonLinearModeCNG
Uses non-linear processing to replace the signal with comfort noise whenever echo might otherwise be audible. This mode of operation is most appropriate to IP gateway applications where background noise is desirable to maintain the illusion of continuity.
use_agc
Enables (non-zero) or disables (zero) the use of automatic gain control on the input signal. Only used if enable is non-zero.
fix_agc
Enables (non-zero) or disables (zero) holding the gain fixed at its current value. This can be used after the AGC gain factor has adjusted itself to prevent further changes. Only used if enable is non-zero.
span
If non-zero, sets the span (in milliseconds) of the echo cancellation. A side effect of this is that the input conditioning may be re-initialised. Only used if enable is non-zero.
delay
If non-zero, sets delay (in milliseconds) before the reference signal is presented to echo cancellation reference input (allowing application to compensate for time it takes reference signal to reach the TDM circuit, so avoiding the effective span being diminished by this amount). Input conditioning is re-initialised. To set a zero delay, use the value -1. If zero, the delay is unchanged and input conditioning is not re-initialised. The default delay is zero milliseconds.
tone_action
One of these values:
kSMPathEchoToneActionNone
No special action on occurence of tones.
kSMPathEchoTonetActionMuteTTY
TTY tones are expected - when detected action taken to mute TTY echo but passthrough non-echo TTY.

Returns

0 if call completed successfully, otherwise a standard error.


Prosody signal path processing: API: sm_path_emphasis

Prototype Definition

int sm_path_emphasis(struct sm_path_emphasis_parms *emphparms)

Parameters

*emphparms
a structure of the following type:
typedef struct sm_path_emphasis_parms {
	tSMPathId path;						/* in */
	tSM_INT enable;						/* in */
	enum kSMPathEmphMode {
		kSMPathEmphModeHFEmphasis,
		kSMPathEmphModeHFDeemphasis,
	} mode;							/* in */
	tSM_INT gain;						/* in */
} SM_PATH_EMPHASIS_PARMS;

Description

Configures a high-frequency emphasis/de-emphasis filter. In emphasis mode, response curve is approximately -3dB at 0Hz rising to 0dB at 300Hz and 20dB at 3330Hz. In de-emphasis mode, the inverse filter is applied: 3dB at 0Hz falling to 0dB at 300Hz and -20dB at 3330Hz. Disabling the filter also disables the gain. Note that the frequencies quoted are proportional to the input signal sample rate and those given are for an input signal sample rate of 8000 samples per second.

Requires the module emph to be loaded.

Fields

path
The signal path to be configured
enable
Enables (non-zero) or disables (zero) filter.
mode
Indicates what mode the filter operates in. One of these values:
kSMPathEmphModeHFEmphasis
Puts the filter into HF emphasis mode.
kSMPathEmphModeHFDeemphasis
Puts the filter into HF de-emphasis mode.
gain
Extra gain to apply to the signal as part of the filter, in dB.

Returns

0 if call completed successfully, otherwise a standard error.


Prosody signal path processing: API: sm_path_get_datafeed

Prototype Definition

int sm_path_get_datafeed(struct sm_path_datafeed_parms *datafeedp)

Parameters

*datafeedp
a structure of the following type:
typedef struct sm_path_datafeed_parms {
	tSMPathId path;						/* in */
	tSMDatafeedId datafeed;					/* out */
} SM_PATH_DATAFEED_PARMS;

Description

Request a datafeed identifier from a signal path. This identifer can subsequently be used in a call to sm_channel_datafeed_connect(), sm_tdmtx_datafeed_connect() or sm_vmptx_datafeed_connect() to connect the result of the signal path procesing to a speech channel (tSMChannelId), TDM[tx], or a VMP[tx] respectively. It is valid until the path is destroyed. Datafeed connections can only be made between objects allocated on the same tSMModuleId.

Requires the module datafeed to have been downloaded.

Fields

path
The signal path from which to obtain a datafeed
datafeed
The datafeed object representing the processed signal from the signal path

Returns

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


Prosody signal path processing: API: sm_path_get_event

Prototype Definition

int sm_path_get_event(struct sm_path_event_parms *eventp)

Parameters

*eventp
a structure of the following type:
typedef struct sm_path_event_parms {
	tSMPathId path;						/* in */
	tSMEventId event;					/* out */
} SM_PATH_EVENT_PARMS;

Description

If the call completes successfully event will hold the tSMEventId belonging to path. The tSMEventId is valid until the path is destroyed using sm_path_destroy(). This event will be signalled when a status change occurs on the path. When the event is signalled the user must call sm_path_status() to discover the nature of the status change.

Fields

path
The path
event
The event identifier

Returns

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


Prosody signal path processing: API: sm_path_mix

Prototype Definition

int sm_path_mix(struct sm_path_mix_parms *mixp)

Parameters

*mixp
a structure of the following type:
typedef struct sm_path_mix_parms {
	tSMPathId path;						/* in */
	tSM_INT enable;						/* in */
	tSMDatafeedId mixin;					/* in */
	tSM_INT volume;						/* in */
} SM_PATH_MIX_PARMS;

Description

Configures signal mixing on a signal path. The specified signal is added into the signal being processed by this path, and the result is adjusted according to the volume parameter, which has a range of at least -24 to +8 dB. Typically, the signal is adjusted by -6 dB to prevent the sum of the two signals being louder than each original signal.

Requires the module gainbg.

Fields

path
The signal path to be configured
enable
Enables (non-zero) or disables (zero) adding another signal to the input signal.
mixin
The datafeed which is the signal to be added. Only used if enable is non-zero.
volume
Volume adjustment (dB).

Returns

0 if call completed successfully, otherwise a standard error.


Prosody signal path processing: API: sm_path_pitchshift

Prototype Definition

int sm_path_pitchshift(struct sm_path_pitchshift_parms *pitchshiftp)

Parameters

*pitchshiftp
a structure of the following type:
typedef struct sm_path_pitchshift_parms {
	tSMPathId path;						/* in */
	float shift;						/* in */
} SM_PATH_PITCHSHIFT_PARMS;

Description

Configures pitch shifting on a signal path.

Requires the module pitchshift.

Fields

path
The signal path to be configured
shift
The number of octaves by which the signal is to be shifted. Values less than zero cause a downward shift (for example, the value -0.08333 configures a shift down one semitone), values greater than zero cause an upward shift, and the value zero disables pitch shifting.

Returns

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


Prosody signal path processing: API: sm_path_resample

Prototype Definition

int sm_path_resample(struct sm_path_resample_parms *resamplep)

Parameters

*resamplep
a structure of the following type:
typedef struct sm_path_resample_parms {
	tSMPathId path;						/* in */
	tSM_INT uprate;						/* in */
	tSM_INT downrate;					/* in */
} SM_PATH_RESAMPLE_PARMS;

Description

Configures sample rate conversion on a signal path. If uprate and downrate are equal, sample rate conversion is disabled. Otherwise the signal is converted to a sampling rate of uprate / downrate times the original sampling rate. For example, if uprate is two, and downrate is one, the sampling rate is doubled. To produce the best audio quality, and to use the least processor time, uprate should always be kept as small as possible. For example, uprate = 2, with downrate = 3, would decrease the sampling rate to two-thirds of the original value, but so would uprate = 4, with downrate = 6. Both the audio quality and the CPU loading will be noticeably better with uprate = 2, than with uprate = 4.

Requires the module resample.

Fields

path
The signal path to be configured
uprate
Sets the up-sampling ratio. This value must be in the range 1..6.
downrate
Sets the down-sampling ratio. This value must be in the range 1..6.

Returns

0 if call completed successfully, otherwise a standard error.


Prosody signal path processing: API: sm_path_status

Prototype Definition

int sm_path_status(struct sm_path_status_parms *statusp)

Parameters

*statusp
a structure of the following type:
typedef struct sm_path_status_parms {
	tSMPathId path;						/* in */
	enum kSMPathStatus {
		kSMPathStatusRunning,
		kSMPathStatusOngoingTone,
		kSMPathStatusEndTone,
		kSMPathStatusStopped,
	} status;						/* out */
	union {
		struct {
			tSM_INT id;				/* out */
			unsigned duration;			/* out */
		} tone;						/* out */
	} u;							/* out */
} SM_PATH_STATUS_PARMS;

Description

Returns the current status of the path or an error to indicate that a problem occurred.

When the event, obtained from sm_path_get_event(), is signalled the user must call this function to determine the nature of the status change. The change in status may indicate that an error occurred whilst processing a user request or it may be notifiying the user of a change to the previous state of the path.

Fields

path
The path to interrogate
status
One of these values:
kSMPathStatusRunning
Indicates that there is nothing significant to report.
kSMPathStatusOngoingTone
Tone detector reports ongoing tone or silence.
kSMPathStatusEndTone
Tone detector reports previously ongoing tone or silence has completed.
kSMPathStatusStopped
Indicates that the path has stopped and can be destroyed.
u
Additional information relating to the current status of the path
tone
This field is only valid if the status is either kSMPathStatusOngoingTone or kSMPathStatusEndTone.
id
The id for the recognised tone (or zero if silence).
duration
The ongoing or final duration of the tone or silence.

Returns

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


Prosody signal path processing: API: sm_path_stop

Prototype Definition

int sm_path_stop(struct sm_path_stop_parms *stopp)

Parameters

*stopp
a structure of the following type:
typedef struct sm_path_stop_parms {
	tSMPathId path;						/* in */
} SM_PATH_STOP_PARMS;

Description

Requests that a path stops executing. The user will be notified that a path has terminated by a final status, kSMPAthStatusStopped, from sm_path_status(). Once the stopped status notification has been received the path can be destroyed using sm_path_destroy().

Once the path has stopped the event should no longer be used to wait for status notifications as it will be signalled permanently. The event is invalidated when sm_path_destroy() is called.

Fields

path
A tSMPathId that has been previously created by a call to sm_path_create().

Returns

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


Prosody signal path processing: API: sm_path_tonedetect

Prototype Definition

int sm_path_tonedetect(struct sm_path_tonedetect_parms *tdparms)

Parameters

*tdparms
a structure of the following type:
typedef struct sm_path_tonedetect_parms {
	tSMPathId path;						/* in */
	tSM_INT elim;						/* in */
	enum kSMPathToneDetectMode {
		kSMPathToneDetectModeNone,
		kSMPathToneDetectModeMinDurationNoMinimum,
		kSMPathToneDetectModeMinDuration40,
		kSMPathToneDetectModeMinDuration64,
	} min_duration;						/* in */
	tSM_INT tone_set_id;					/* in */
} SM_PATH_TONEDETECT_PARMS;

Description

Configures a tone detector on signal path. Detected tones are reported through sm_path_status(). Tones that are detected may optionally be eliminated. When eliminating tones, the signal is delayed by small amount so entire tone can be eliminated.

Requires the module td to be loaded.

Fields

path
The signal path to be configured
elim
Enables (non-zero) or disables (zero) elimination of detected tones from signal.
min_duration
Tone detection mode - see sm_listen_for() for more details. One of these values:
kSMPathToneDetectModeNone
Tone detection disabled.
kSMPathToneDetectModeMinDurationNoMinimum
Simple tone detection enabled, no minimum period.
kSMPathToneDetectModeMinDuration40
Robust detection of tones with duration as short as 40mS.
kSMPathToneDetectModeMinDuration64
Simple tone detection enabled, tone must be valid for 64ms to be detected.
tone_set_id
Selects tone set used for tone detection - use same as for active_tone_set_id field in sm_listen_for().

Returns

0 if call completed successfully, otherwise a standard error.


Prosody signal path processing: API: sm_path_ttyeliminate

Prototype Definition

int sm_path_ttyeliminate(struct sm_path_ttyeliminate_parms *ttyeliminatep)

Parameters

*ttyeliminatep
a structure of the following type:
typedef struct sm_path_ttyeliminate_parms {
	tSMPathId path;						/* in */
	tSM_INT enable;						/* in */
} SM_PATH_TTYELIMINATE_PARMS;

Description

Configures TTY elimination on a signal path.

Requires the module ttyasyrx.

Fields

path
The signal path to be configured
enable
Enables (non-zero) or disables (zero) elimination of TTY signals.

Returns

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


These functions constitute the Prosody signal path processing API.