NS¶
NS API Functions¶
- group NS API functions
Functions
-
void ns_init(ns_state_t *ns)¶
Initialise the NS.
This function initialises the NS state with the provided configuration. It must be called at startup to initialise the NS before processing any frames, and can be called at any time after that to reset the NS instance, returning the internal NS state to its defaults.
- Example
ns_state_t ns; ns_init(&ns);
- Parameters:
ns – [out] NS state structure
- void ns_process_frame(
- ns_state_t *ns,
- int32_t output[NS_FRAME_ADVANCE],
- const int32_t input[NS_FRAME_ADVANCE],
Perform NS processing on a frame of input data.
This function updates the NS’s internal state based on the input 1.31 frame, and returns an output 1.31 frame containing the result of the NS algorithm applied to the input.
The
inputandoutputpointers can be equal to perform the processing in-place.- Example
int32_t input[NS_FRAME_ADVANCE]; int32_t output[NS_FRAME_ADVANCE]; ns_state_t ns; ns_init(&ns); ns_process_frame(&ns, output, input);
- Parameters:
ns – [inout] NS state structure
output – [out] Array to return the resulting frame of data
input – [in] Array of frame data on which to perform the NS
-
void ns_init(ns_state_t *ns)¶
NS Defines and Structure Definitions¶
- group NS API structure definitions
Defines
-
NS_FRAME_ADVANCE¶
Length of the frame of data on which the NS will operate.
-
NS_PROC_FRAME_LENGTH¶
Time domain samples block length used internally.
-
NS_PROC_FRAME_BINS¶
Number of bins of spectrum data computed when doing a DFT of a NS_PROC_FRAME_LENGTH length time domain vector. The NS_PROC_FRAME_BINS spectrum values represent the bins from DC to Nyquist.
-
NS_INT_EXP¶
The exponent used internally to keep q1.31 format.
-
NS_WINDOW_LENGTH¶
The length of the window applied in time domain
-
struct ns_state_t¶
- #include <ns_state.h>
NS state structure.
This structure holds the current state of the NS instance and members are updated each time that
ns_process_frame()runs. Many of these members are exponentially-weighted moving averages (EWMA) which influence the behaviour of the NS filter. The user should not directly modify any of these members.Public Members
-
int32_t data_S[NS_PROC_FRAME_BINS]¶
int32_t array to hold the data for S.
-
int32_t data_S_min[NS_PROC_FRAME_BINS]¶
int32_t array to hold the data for S_min.
-
int32_t data_S_tmp[NS_PROC_FRAME_BINS]¶
int32_t array to hold the data for S_tmp.
-
int32_t data_p[NS_PROC_FRAME_BINS]¶
int32_t array to hold the data for p.
-
int32_t data_adt[NS_PROC_FRAME_BINS]¶
int32_t array to hold the data for alpha_d_tilde.
-
int32_t data_lambda_hat[NS_PROC_FRAME_BINS]¶
int32_t array to hold the data for lambda_hat.
-
int32_t data_prev_frame[NS_PROC_FRAME_LENGTH - NS_FRAME_ADVANCE]¶
int32_t array to hold the data for prev_frame.
-
int32_t data_ovelap[NS_FRAME_ADVANCE]¶
int32_t array to hold the data for overlap.
-
int32_t data_rev_wind[NS_WINDOW_LENGTH / 2]¶
int32_t array to hold the data for rev_wind.
-
float_s32_t delta¶
EWMA of the energy ratio to calculate p.
-
float_s32_t alpha_d¶
EWMA of the smoothing parameter for alpha_d_tilde.
-
float_s32_t alpha_s¶
EWMA of the smoothing parameter for S.
-
float_s32_t alpha_p¶
EWMA of the smoothing parameter for p.
-
float_s32_t one_minus_aplha_d¶
EWMA of the 1 - alpha_d parameter.
-
float_s32_t one_minus_alpha_s¶
EWMA of the 1 - alpha_s parameter.
-
float_s32_t one_minus_alpha_p¶
EWMA of the 1 - alpha_p parameter.
-
unsigned reset_period¶
Filter reset period value for auto-reset, specified in samples.
-
unsigned reset_counter¶
Filter reset counter.
-
int32_t data_S[NS_PROC_FRAME_BINS]¶
-
NS_FRAME_ADVANCE¶