Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# ADEC API Functions

group adec_func

  Functions

  void adec_init(adec_state_t *state, adec_config_t *config)

    Initialise ADEC data structures.

    This function initialises ADEC state for a given configuration. It must be called at startup to initialise the ADEC data structures before processing any frames, and can be called at any time after that to reset the ADEC instance, returning the internal ADEC state to its defaults.

    Example with ADEC configured for delay estimation only at startup

          adec_state_t adec_state;
          adec_config_t adec_conf;
          adec_conf.bypass = 1; // Bypass automatic DE correction
          adec_conf.force_de_cycle_trigger = 1; // Force a delay correction cycle, so that delay correction happens once after initialisation
          adec_init(&adec_state, &adec_conf);
          // Application needs to ensure that adec_state->adec_config.force_de_cycle_trigger is set to 0 after ADEC has requested a transition to delay estimation mode once in order to ensure that delay is corrected only at startup.

    Example with ADEC configured for automatic delay estimation and correction

          adec_state_t adec_state;
          adec_conf.bypass = 0;
          adec_conf.force_de_cycle_trigger = 0;
          adec_init(&adec_state, &adec_conf);

    Parameters:

      - state – [out] Pointer to ADEC state structure

      - config – [in] Pointer to ADEC configuration structure.

  void adec_process_frame(adec_state_t *state, adec_output_t *adec_output, const adec_input_t *adec_in)

    Perform ADEC processing on an input frame of data.

    This function takes information about the latest AEC processed frame and the latest measured delay estimate as input, and decides if a delay correction between input microphone and reference signals is required. If a correction is needed, it outputs a new requested input delay, optionally accompanied with a request for AEC restart in a different configuration. It updates the internal ADEC state structure to reflect the current state of the ADEC process.

    Parameters:

      - state – [inout] ADEC internal state structure

      - adec_output – [out] ADEC output structure

      - adec_in – [in] ADEC input structure

  void adec_estimate_delay(de_output_t *de_output, const bfp_complex_s32_t *H_hat, unsigned num_phases)

    Estimate microphone delay.

    This function measures the microphone signal delay wrt the reference signal. It does so by looking for the phase with the peak energy among all AEC filter phases and uses the peak energy phase index as the estimate of the microphone delay. Along with the measured delay, it also outputs information about the peak phase energy that can then be used to gauge the AEC filter convergence and the reliability of the measured delay.

    Parameters:

      - de_state – [out] Delay estimator output structure

      - H_hat – [in] bfp_complex_s32_t array storing the AEC filter spectrum

      - Number – [in] of phases in the AEC filter