spandsp 3.0.0
agc_float.c File Reference
#include <inttypes.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "spandsp/telephony.h"
#include "spandsp/alloc.h"
#include "spandsp/logging.h"
#include "spandsp/math_fixed.h"
#include "spandsp/agc_float.h"
#include "spandsp/private/logging.h"
#include "spandsp/private/agc_float.h"

Macros

#define DC_BLOCK_COEFF   0.9921875
#define power_threshold_dbm0(len, thresh)

Functions

agcf_descriptor_tagcf_make_descriptor (agcf_descriptor_t *s, float signal_target_power, float signal_on_power_threshold, float signal_off_power_threshold, int signal_on_persistence_check, int signal_off_persistence_check)
 Create an AGC descriptor.
int agcf_free_descriptor (agcf_descriptor_t *s)
bool agcf_from_int16_rx (agcf_state_t *s, float out[], const int16_t in[], int len)
 Process a block of received samples.
bool agcf_rx (agcf_state_t *s, float out[], const float in[], int len)
 Process a block of received samples.
float agcf_get_scaling (agcf_state_t *s)
void agcf_set_scaling (agcf_state_t *s, float scaling)
float agcf_current_power_dbm0 (agcf_state_t *s)
void agcf_set_adaption (agcf_state_t *s, bool adapt)
logging_state_tagcf_get_logging_state (agcf_state_t *s)
 Get the logging context associated with an AGC context.
agcf_state_tagcf_init (agcf_state_t *s, const agcf_descriptor_t *desc)
 Initialise an AGC context.
int agcf_release (agcf_state_t *s)
 Release an AGC receive context.
int agcf_free (agcf_state_t *s)
 Free the resources of an ADSI receive context.

Macro Definition Documentation

◆ power_threshold_dbm0

#define power_threshold_dbm0 ( len,
thresh )
Value:
(float) (((len)*32768.0f*32768.0f/2.0f)*powf(10.0f, ((thresh) - DBM0_MAX_SINE_POWER)/10.0f))

Function Documentation

◆ agcf_free()

int agcf_free ( agcf_state_t * s)

Free the resources of an ADSI receive context.

Parameters
sThe ADSI receive context.
Returns
0 for OK.

◆ agcf_from_int16_rx()

bool agcf_from_int16_rx ( agcf_state_t * s,
float out[],
const int16_t in[],
int len )

Process a block of received samples.

Process a block of received samples.

Parameters
outThe output buffer for the scaled samples.
inThe input buffer for the samples.
lenThe length of the in and out buffers.
Returns
True if a signal is present.

◆ agcf_get_logging_state()

logging_state_t * agcf_get_logging_state ( agcf_state_t * s)

Get the logging context associated with an AGC context.

Get the logging context associated with an AGC context.

Parameters
sThe AGC context.
Returns
A pointer to the logging context

◆ agcf_get_scaling()

float agcf_get_scaling ( agcf_state_t * s)

Get the current scaling.

◆ agcf_init()

agcf_state_t * agcf_init ( agcf_state_t * s,
const agcf_descriptor_t * desc )

Initialise an AGC context.

Parameters
sThe AGC context.
desc
Returns
A pointer to the initialised context, or NULL if there was a problem.

◆ agcf_make_descriptor()

agcf_descriptor_t * agcf_make_descriptor ( agcf_descriptor_t * s,
float signal_target_power,
float signal_on_power_threshold,
float signal_off_power_threshold,
int signal_on_persistence_check,
int signal_off_persistence_check )

Create an AGC descriptor.

Parameters
sThe AGC context.
signal_target_powerThe power to normalize to, in dBm0.
signal_on_power_thresholdThe minimum power to declare signal on, in dBm0.
signal_off_power_thresholdThe maximum power to declare signal off, in dBm0.
signal_on_persistence_checkPersistence check count for signal on.
signal_off_persistence_checkPersistence check count for signal off.
Returns
A pointer to the initialised context, or NULL if there was a problem.

◆ agcf_release()

int agcf_release ( agcf_state_t * s)

Release an AGC receive context.

Parameters
sThe ADSI receive context.
Returns
0 for OK.

◆ agcf_rx()

bool agcf_rx ( agcf_state_t * s,
float out[],
const float in[],
int len )

Process a block of received samples.

Process a block of received samples.

Parameters
outThe output buffer for the scaled samples.
inThe input buffer for the samples.
lenThe length of the in and out buffers.
Returns
True if a signal is present.

◆ agcf_set_adaption()

void agcf_set_adaption ( agcf_state_t * s,
bool adapt )

Enable or disable AGC adpation.

◆ agcf_set_scaling()

void agcf_set_scaling ( agcf_state_t * s,
float scaling )

Set the scaling, instead of adapting it. This allows a known good scaling factor to be resused within a session.