ANC

概述

ANC(Active Noise Cancellation,主动降噪)通过电子线路将原噪声的相位倒过来,以产生与外界相对的声波,从而将噪音中和,达到降噪的目的。

功能特性

ANC 模块支持:

  • 支持 16 个 biquad group, 1 个 biquad group 包含 4 个 biquad filter,最小使用单位为 1 个 bqiuad group。

  • 支持不同 biquad group 按照用户指定方式级联。

  • 支持 biquad group 输出或者输出设置增益。

  • 支持 2 个输出, 单个输出支持最多 8 个输入源, 多个输入源经过相加后输出。

  • 支持 10 个 DRC, 均包含增益、limiter、noise gating 功能,其中 8 个通用 DRC 的位置可由用户指定, 2 个 DRC 只能作用于ANC输出。

  • 支持不同通用 DRC 按照用户指定方式级联。

  • 每个 biquad group 和 通用 DRC 最多支持 3 个 输入源, 多个输入源经过相加后作为新的输入。

  • 支持两组 biqaud filter 参数切换。

  • 典型输入采样率: 192 kHz、200 kHz、384 kHz、400 kHz、768 kHz 和 800 kHz 等多种配置。

ANC 与其他模块的连接关系图如下所示。

../../_images/ANC_mode_connection.png

ANC 与其它模块连接示意图

结构图

ANC 的内部结构如下图所示。

../../_images/ANC_architecture.png

ANC 结构图

单个 biquad group 的内部结构如下图所示。

../../_images/ANC_biquad_group_architecture.png

ANC biquad group 结构图

API 介绍

Defines

CONFIG_HARDWARE_ANC_GAIN_DECIMAL
ANC_COEFF_SCALE
WQ_ANC_FF_MIC_MAX
WQ_ANC_FB_MIC_MAX
WQ_ANC_EC_MAX
WQ_ANC_TOTAL_BIQUID_GROUP_NUM
WQ_ANC_ONE_BIQ_GRP_COEFF_NUM
WQ_ANC_COEFF_SWITCH_MIN_CNT
WQ_ANC_DRC_DEFAULT_LM_ATTACK_TIME_US
WQ_ANC_DRC_DEFAULT_LM_RELEASE_TIME_US
WQ_ANC_DRC_DEFAULT_GM_ATTACK_TIME_US
WQ_ANC_DRC_DEFAULT_GM_RELEASE_TIME_US

Typedefs

typedef struct wq_anc_path_info wq_anc_path_info_t
typedef enum _WQ_ANC_DUMP_POINT WQ_ANC_DUMP_POINT

For specific definitions, please refer to the header file wq_audio_resource.h.

typedef struct wq_anc_biquad_filter_coeff wq_anc_biquad_filter_coeff_t

For specific definitions, please refer to the header file wq_anc.h.

Enums

enum WQ_ANC_BUF_ID

Values:

enumerator WQ_ANC_BUF_ID_0
enumerator WQ_ANC_BUF_ID_1
enumerator WQ_ANC_BUF_ID_2
enumerator WQ_ANC_BUF_ID_3
enumerator WQ_ANC_BUF_ID_MAX
enum WQ_ANC_INSTS_ID

Values:

enumerator WQ_ANC_INSTS_ID_0
enumerator WQ_ANC_INSTS_ID_1
enumerator WQ_ANC_INSTS_ID_2
enumerator WQ_ANC_INSTS_ID_3
enumerator WQ_ANC_INSTS_ID_4
enumerator WQ_ANC_INSTS_ID_5
enumerator WQ_ANC_INSTS_ID_6
enumerator WQ_ANC_INSTS_ID_7
enumerator WQ_ANC_INSTS_ID_8
enumerator WQ_ANC_INSTS_ID_9
enumerator WQ_ANC_INSTS_ID_10
enumerator WQ_ANC_INSTS_ID_11
enumerator WQ_ANC_INSTS_ID_12
enumerator WQ_ANC_INSTS_ID_13
enumerator WQ_ANC_INSTS_ID_14
enumerator WQ_ANC_INSTS_ID_15
enumerator WQ_ANC_INSTS_ID_16
enumerator WQ_ANC_INSTS_ID_17
enumerator WQ_ANC_INSTS_ID_18
enumerator WQ_ANC_INSTS_ID_19
enumerator WQ_ANC_INSTS_ID_20
enumerator WQ_ANC_INSTS_ID_21
enumerator WQ_ANC_INSTS_ID_22
enumerator WQ_ANC_INSTS_ID_23
enumerator WQ_ANC_INSTS_ID_24
enumerator WQ_ANC_INSTS_ID_25
enumerator WQ_ANC_INSTS_ID_26
enumerator WQ_ANC_INSTS_ID_27
enumerator WQ_ANC_INSTS_ID_28
enumerator WQ_ANC_INSTS_ID_29
enumerator WQ_ANC_INSTS_ID_30
enumerator WQ_ANC_INSTS_ID_31
enumerator WQ_ANC_INSTS_ID_32
enumerator WQ_ANC_INSTS_ID_33
enumerator WQ_ANC_INSTS_ID_34
enumerator WQ_ANC_INSTS_ID_35
enumerator WQ_ANC_INSTS_ID_36
enumerator WQ_ANC_INSTS_ID_37
enumerator WQ_ANC_INSTS_ID_38
enumerator WQ_ANC_INSTS_ID_39
enumerator WQ_ANC_INSTS_ID_MAX
enum WQ_ANC_FUNC

Values:

enumerator WQ_ANC_FUNC_IIR
enumerator WQ_ANC_FUNC_FIR
enumerator WQ_ANC_FUNC_SUM
enumerator WQ_ANC_FUNC_DRC
enumerator WQ_ANC_FUNC_MAX
enum ANC_PATH_ID

Values:

enumerator ANC_PATH_ID_FF1_L
enumerator ANC_PATH_ID_FF2_L
enumerator ANC_PATH_ID_FF3_L
enumerator ANC_PATH_ID_FF4_L
enumerator ANC_PATH_ID_FB1_L
enumerator ANC_PATH_ID_FB2_L
enumerator ANC_PATH_ID_FB3_L
enumerator ANC_PATH_ID_FB4_L
enumerator ANC_PATH_ID_EC1_L
enumerator ANC_PATH_ID_EC2_L
enumerator ANC_PATH_ID_EC3_L
enumerator ANC_PATH_ID_EC4_L
enumerator ANC_PATH_ID_FF1_R
enumerator ANC_PATH_ID_FF2_R
enumerator ANC_PATH_ID_FF3_R
enumerator ANC_PATH_ID_FF4_R
enumerator ANC_PATH_ID_FB1_R
enumerator ANC_PATH_ID_FB2_R
enumerator ANC_PATH_ID_FB3_R
enumerator ANC_PATH_ID_FB4_R
enumerator ANC_PATH_ID_EC1_R
enumerator ANC_PATH_ID_EC2_R
enumerator ANC_PATH_ID_EC3_R
enumerator ANC_PATH_ID_EC4_R
enumerator ANC_PATH_ID_FF_TO_EC_L
enumerator ANC_PATH_ID_FF_TO_EC_R
enumerator ANC_PATH_ID_MIXER_DIRECT_L
enumerator ANC_PATH_ID_MIXER_DIRECT_R
enumerator ANC_PATH_ID_EC_DIRECT_OUT_L
enumerator ANC_PATH_ID_EC_DIRECT_OUT_R
enumerator ANC_PATH_ID_FF1_BACKUP_L
enumerator ANC_PATH_ID_FF2_BACKUP_L
enumerator ANC_PATH_ID_FF3_BACKUP_L
enumerator ANC_PATH_ID_FF4_BACKUP_L
enumerator ANC_PATH_ID_FB1_BACKUP_L
enumerator ANC_PATH_ID_FB2_BACKUP_L
enumerator ANC_PATH_ID_FB3_BACKUP_L
enumerator ANC_PATH_ID_FB4_BACKUP_L
enumerator ANC_PATH_ID_FF1_BACKUP_R
enumerator ANC_PATH_ID_FF2_BACKUP_R
enumerator ANC_PATH_ID_FF3_BACKUP_R
enumerator ANC_PATH_ID_FF4_BACKUP_R
enumerator ANC_PATH_ID_FB1_BACKUP_R
enumerator ANC_PATH_ID_FB2_BACKUP_R
enumerator ANC_PATH_ID_FB3_BACKUP_R
enumerator ANC_PATH_ID_FB4_BACKUP_R
enumerator ANC_PATH_ID_MAX
enum RET_INST_WRITE_T

Values:

enumerator RET_INST_WRITE_WAIT
enumerator RET_INST_WRITE_NOT_WAIT

Functions

WQ_RET wq_anc_dump_point_sel(WQ_ANC_DUMP_POINT point)

This function is choose anc internal dump point.

参数:

point -- anc dump point

返回:

WQ_RET WQ_RET_OK for success else error.

WQ_RET wq_anc_src_mixer_en(bool en)

This function is to enable mixer data to anc.

参数:

en -- true is enable , false is disable

返回:

WQ_RET WQ_RET_OK for success else error.

WQ_RET wq_anc_src_adc_en(bool en)

This function is to enable dfe data to anc.

参数:

en -- true is enable , false is disable

返回:

WQ_RET WQ_RET_OK for success else error.

void wq_anc_out_drc_global_config(const wq_anc_drc_global_config_t *cfg)

This function is to set out drc global parameter, see wq_anc_drc_global_config_t.

参数:

cfg -- config parameter, see wq_anc_drc_global_config_t

void wq_anc_printf_all_coeff(void)

This function is to printf anc current coeff.

This function is to enable ff path out link to ec path in.

参数:

en -- true is enable , false is disable

WQ_RET wq_anc_inst_cfg(uint8_t id, uint8_t cfg)

This function is to set inst func and link structure.

参数:
  • id -- instuction index

  • cfg -- instruction funcstion

返回:

WQ_RET WQ_RET_OK for success else error.

WQ_RET wq_anc_path_cfg_info(const wq_anc_path_info_t *anc_path_info)

This function is to trans anc path cfg info.

参数:

anc_path_info -- path cfg info

返回:

WQ_RET WQ_RET_OK for success else error.

WQ_RET wq_anc_get_cur_coeff(WQ_ANC_BIQUAD_ID biquad_id, wq_anc_biquad_filter_coeff_t *coeff)

This function is to get biq current coeff.

参数:
  • biquad_id -- biq index

  • coeff -- current coeff

返回:

WQ_RET WQ_RET_OK for success else error.

WQ_RET wq_anc_coeff_init(void)

This function is to init anc biquad coeff.

返回:

WQ_RET WQ_RET_OK for success else error.

int wq_anc_gain_float2int(float gain_dB)

This function is convert db gain to int value.

返回:

converted int value

float wq_anc_gain_int2float(int32_t gain_int)

This function is convert int value to db gain.

返回:

converted db gain

int32_t wq_anc_get_path_int_gain(uint8_t path_id)

This function is to get anc path gain.

参数:

path_id -- path index

返回:

path gain int value

WQ_RET wq_anc_switch_gain_and_biquad_coeff(const int32_t *gain, const uint32_t *anc_coeff, uint32_t coeff_num, wq_anc_switch_done_callback cb)

This function is to switch gain and biquad coeff.

参数:
  • gain -- gain value array

  • anc_coeff -- biquad coeff array

  • coeff_num -- num of biquad coeff array

  • cb -- is callback for mode switch completed

返回:

WQ_RET WQ_RET_OK for success else error.

void wq_anc_audio_dump_anc_point(WQ_AUDIO_DUMP_SRC src)

This function is to dump anc inner point.

参数:

src -- anc inner point

void wq_anc_biquad_switch_time_set(WQ_ANC_INSTS_ID inst_id, uint16_t switch_time_ms)

This function is to set anc biquad switch coeff time.

参数:
  • inst_id -- inst_id id

  • switch_time_ms -- switch time unit is ms

struct wq_anc_drc_config

Public Members

float make_up_db

anc drc make up, unit 1 dB

float limiter_threshold_db

anc drc limiter threshold dB

struct wq_anc_drc_global_config

Public Members

int32_t lm_attack_time

anc drc lm attack time us

int32_t lm_release_time

anc drc lm release time us

int32_t gm_attack_time

anc drc gm attack time us

int32_t gm_release_time

anc drc gm release time us

struct wq_anc_biquad_filter_coeff

Public Members

uint32_t a1
uint32_t a2
uint32_t b0
uint32_t b1
uint32_t b2
struct wq_anc_biquad

Public Members

WQ_ANC_BIQUAD_IN_MODULE biquad_src[WQ_ANC_BIQUAD_IN_SRC_ID_MAX]

anc biquad input source

struct wq_anc_drc

Public Members

WQ_ANC_DRC_IN_MODULE drc_src[WQ_ANC_DRC_IN_SRC_ID_MAX]

anc drc input source

struct wq_anc_config

Public Members

bool enable_irq

whether to enable switch coeff interruption

struct wq_anc_path_info

Public Members

uint8_t mic_start_inst

first inst_id of ff path used, binding inst_id and z0buf_id of ff_start_buf

uint8_t ec_start_inst

first inst_id of ec path used, binding inst_id and z0buf_id of ec_start_buf

uint8_t start_in_inst

anc output inst_id of anc off or link switch

uint8_t start_in_buf

anc output z0buf_id of anc off or link switch

uint8_t end_out_inst

anc output inst_id of anc on

uint8_t end_out_buf

anc output z0buf_id of anc on

uint8_t ff_path_num

ff path biq num

uint8_t fb_path_num

fb path biq num

uint8_t ec_path_num

ec path biq num

uint8_t ff_path_drc_inst

inst_id of drc in ff path

uint8_t ff_path_drc_buf

z0buf_id of drc in ff path

uint8_t fb_path_drc_inst

inst_id of drc in fb path

uint8_t fb_path_drc_buf

z0buf_id of drc in fb path

uint8_t ff_start_buf[WQ_ANC_FF_MIC_MAX]

ff path start z0buf

uint8_t fb_start_buf[WQ_ANC_FB_MIC_MAX]

fb path start z0buf

uint8_t ec_start_buf[WQ_ANC_EC_MAX]

ec path start z0buf

uint8_t ff_src_id[WQ_ANC_FF_MIC_MAX]

src id(rxdfe) of ff path, form the starting point with ff_start_buf

uint8_t fb_src_id[WQ_ANC_FB_MIC_MAX]

src id(rxdfe) of fb path, form the starting point with fb_start_buf

uint8_t ec_src_id[WQ_ANC_EC_MAX]

src id(mixer) of ec path, form the starting point with ec_start_buf

uint8_t ff_to_mix_bk_inst[WQ_ANC_FF_MIC_MAX]

Used to adjust the gain of the ff path and store the inst_id of ff and ff_bk sum point

uint8_t ff_to_mix_bk_buf[WQ_ANC_FF_MIC_MAX]

the z0buf_id of ff path at the sum point ff_to_mix_bk_inst

uint8_t bk_to_mix_ff_buf[WQ_ANC_FF_MIC_MAX]

the z0buf_id of ff_bk path at the sum point ff_to_mix_bk_inst

uint8_t fb_to_mix_bk_inst[WQ_ANC_FB_MIC_MAX]

Used to adjust the gain of the fb path and store the inst_id of fb and fb_bk sum point

uint8_t fb_to_mix_bk_buf[WQ_ANC_FB_MIC_MAX]

the z0buf_id of fb path at the sum point fb_to_mix_bk_inst

uint8_t bk_to_mix_fb_buf[WQ_ANC_FB_MIC_MAX]

the z0buf_id of fb_bk path at the sum point fb_to_mix_bk_inst

uint8_t fb_to_mix_ec_inst[WQ_ANC_FB_MIC_MAX]

Used to adjust the gain of the fb path and store the inst_id of fb and ec sum point

uint8_t fb_to_mix_ec_buf[WQ_ANC_FB_MIC_MAX]

the z0buf_id of fb path at the sum point fb_to_mix_ec_inst

uint8_t ec_to_mix_fb_buf[WQ_ANC_EC_MAX]

the z0buf_id of ec path at the sum point fb_to_mix_ec_inst

uint8_t ff_to_mix_ec_inst

inst_id of special path ff_to_ec point

uint8_t ff_to_mix_ec_buf

the z0buf_id of ec path at the sum point ff_to_mix_ec_inst

uint8_t ec_to_mix_ff_buf

the z0buf_id of ff path at the sum point ff_to_mix_ec_inst

uint8_t ec_path_end_inst[WQ_ANC_FB_MIC_MAX]

the last inst_id of ec path

uint8_t biq_remap_inst[WQ_ANC_INSTS_ID_MAX]

remap biquad id sorted by tool(FB/EC/FF/FBBK/FFBK) to inst_id

uint8_t ff_path_biq_num[WQ_ANC_FF_MIC_MAX]

biquad num of each ff path total used, share_biq + main_biq

uint8_t ff_share_biq_num[WQ_ANC_FF_MIC_MAX]

biquad num of ff and ff_bk shared

uint8_t ff_main_biq_num[WQ_ANC_FF_MIC_MAX]

biquad num of each ff path exclusived, not include ff_share_biq

uint8_t ff_bk_biq_num[WQ_ANC_FF_MIC_MAX]

biquad num of each ff_bk path exclusived, not include ff_share_biq

uint8_t fb_path_biq_num[WQ_ANC_FB_MIC_MAX]

biquad num of each fb path total used, share_biq + main_biq

uint8_t fb_share_biq_num[WQ_ANC_FB_MIC_MAX]

biquad num of fb and fb_bk shared

uint8_t fb_main_biq_num[WQ_ANC_FB_MIC_MAX]

biquad num of each fb path exclusived, not include fb_share_biq

uint8_t fb_bk_biq_num[WQ_ANC_FB_MIC_MAX]

biquad num of each fb_bk path exclusived, not include fb_share_biq

uint8_t ec_path_biq_num[WQ_ANC_EC_MAX]

biquad num of each ec path(EC1/EC2....)

uint8_t bk_biq_num

total biquad num of all FF_bk + FB_bk path

uint8_t inst_cfg[WQ_ANC_INSTS_ID_MAX]

in_buf_map:0~3, out_buf:4~5, func:6~7, ref WQ_ANC_BUF_ID and WQ_ANC_FUNC