# Line gain configuration

The AG 2000C supports input and output gain configuration on network voice ports (timeslots) from -6 dB to +6 dB in one dB increments.

Input gain is applied to the signal received from the network. Output gain is applied to the signal transmitted to the network. The default value for both input line gain and output line gain on the AG 2000C loop start board is nominal 0 dB.

This topic describes:

- Getting the line gain

- Setting the line gain

Caution: | Increasing gain can also increase noise, echo, and possibly cause oscillations on the telephone network. There also may be regulatory authority implications. Use gain with caution.

Decreasing gain may reduce echo and other noise.

## Getting the line gain

Use swiGetLocalTimeslotInfo to query the input or output line gain. Set the arguments for this function as follows:

Argument | Field | Value
--- | --- | ---
swihd |  | Handle returned by swiOpenSwitch.
args | localstream | 0 or 1. Refer to the AG 2000C switch model.
localtimeslot | 0..23. Refer to the AG 2000C switch model.
deviceid | MVIP95_ANALOG_LINE_DEVICE
parameterid | MVIP95_INPUT_GAIN or MVIP95_OUTPUT_GAIN
buffer |  | Points to the NMS_LINE_GAIN_PARMS structure.
size |  | Size of buffer, in bytes.

The NMS_LINE_GAIN_PARMS structure is:

typedef struct
{
INT32 gain;
} NMS_LINE_GAIN_PARMS;

The value returned in the gain component of NMS_LINE_GAIN_PARMS represents the gain in dB multiplied by 1000. For example, if the input gain on a particular network timeslot is currently set to -3 dB, after calling swiGetLocalTimeslotInfo for parameter MVIP95_INPUT_GAIN, the gain field is -3000.

The following sample code shows how to retrieve line gain applied to a signal received from the network:

#include "swidef.h" /* CT Access Switching service */
#include "mvip95.h" /* MVIP-95 definitions */
#include "nmshw.h" /* NMS hardware-specific definitions */
DWORD myGetReceiveGain ( SWIHD swihd, SWI_TERMINUS terminus, INT32* gain_dB )
{
SWI_LOCALTIMESLOT_ARGS args;
NMS_LINE_GAIN_PARMS device ;
DWORD rc ;
args.localstream = terminus.stream ;
args.localtimeslot = terminus.timeslot ;
args.deviceid = MVIP95_ANALOG_LINE_DEVICE ;
args.parameterid = MVIP95_INPUT_GAIN ;
rc = swiGetLocalTimeslotInfo(
/* CT Access switch handle */ swihd,
/* target device and config item */ & args,
/* buffer (defined by parameterid) */(void*) & device,
/* buffer size in bytes */ sizeof(device));
*gain_dB = device.gain / 1000 ;
return rc ;
}

The following sample code shows how to retrieve line gain applied to a signal transmitted to the network:

#include "swidef.h" /* CT Access Switching service */
#include "mvip95.h" /* MVIP-95 definitions */
#include "nmshw.h" /* NMS hardware-specific definitions */
DWORD myGetTransmitGain ( SWIHD swihd, SWI_TERMINUS terminus, INT32* gain_dB )
{
SWI_LOCALTIMESLOT_ARGS args ;
NMS_LINE_GAIN_PARMS device ;
DWORD rc ;
args.localstream = terminus.stream ;
args.localtimeslot = terminus.timeslot ;
args.deviceid = MVIP95_ANALOG_LINE_DEVICE ;
args.parameterid = MVIP95_OUTPUT_GAIN ;
rc = swiGetLocalTimeslotInfo(
/* CT Access switch handle */ swihd,
/* target device and config item */ & args,
/* buffer (defined by parameterid) */ (void*) & device,
/* buffer size in bytes */ sizeof(device));
*gain_dB = device.gain / 1000 ;
return rc ;
}

## Setting the line gain

Use swiConfigLocalTimeslot to set the the input or output line gain. Set the arguments for this function as follows:

Argument | Field | Value
--- | --- | ---
swihd |  | Handle returned by swiOpenSwitch.
args | localstream | 0 or 1. Refer to the AG 2000C switch model.
localtimeslot | 0..23. Refer to the AG 2000C switch model.
deviceid | MVIP95_ANALOG_LINE_DEVICE
parameterid | MVIP95_INPUT_GAIN or MVIP95_OUTPUT_GAIN
buffer |  | Points to the NMS_LINE_GAIN_PARMS structure.
size |  | Size of buffer, in bytes.

The NMS_LINE_GAIN_PARMS structure is:

typedef struct
{
INT32 gain;
} NMS_LINE_GAIN_PARMS;

Multiply the desired gain setting in dB by 1000. For example, to set the input line gain on a network voice port to -4 dB, set the gain field of NMS_LINE_GAIN_PARMS to -4000.

The following sample code shows how to configure gain applied to a signal received from the network:

#include "swidef.h" /* CT Access Switching service */
#include "mvip95.h" /* MVIP-95 definitions */
#include "nmshw.h" /* NMS hardware-specific definitions */
DWORD mySetReceiveGain ( SWIHD swihd, SWI_TERMINUS terminus, INT32 gain_dB )
{
SWI_LOCALTIMESLOT_ARGS args;
NMS_LINE_GAIN_PARMS device ;
args.localstream = terminus.stream ;
args.localtimeslot = terminus.timeslot ;
args.deviceid = MVIP95_ANALOG_LINE_DEVICE ;
args.parameterid = MVIP95_INPUT_GAIN ;
device.gain = gain_dB * 1000 ;
return swiConfigLocalTimeslot (
/* CT Access switch handle */ swihd,
/* target device and config item */ & args,
/* buffer (defined by parameterid) */ (void*) & device,
/* buffer size in bytes */ sizeof(device));
}

The following sample code shows how to configure line gain applied to a signal transmitted to the network:

#include "swidef.h" /* CT Access Switching service */
#include "mvip95.h" /* MVIP-95 definitions */
#include "nmshw.h" /* NMS hardware-specific definitions */
*/
DWORD mySetTransmitGain ( SWIHD swihd, SWI_TERMINUS terminus, INT32 gain_dB )
{
SWI_LOCALTIMESLOT_ARGS args;
NMS_LINE_GAIN_PARMS device ;
args.localstream = terminus.stream ;
args.localtimeslot = terminus.timeslot ;
args.deviceid = MVIP95_ANALOG_LINE_DEVICE ;
args.parameterid = MVIP95_OUTPUT_GAIN ;
device.gain = gain_dB * 1000 ;
return swiConfigLocalTimeslot (
/* CT Access switch handle */ swihd,
/* target device and config item */ & args,
/* buffer (defined by parameterid) */ (void*) & device,
/* buffer size in bytes */ sizeof(device));
}