Files
99_7018_lmx/apps/earphone/include/aec_user.h

210 lines
6.4 KiB
C
Raw Normal View History

2025-10-29 13:10:02 +08:00
#ifndef _AEC_USER_H_
#define _AEC_USER_H_
#include "generic/typedef.h"
#include "user_cfg.h"
#define AEC_DEBUG_ONLINE 0
#define AEC_READ_CONFIG 1
/*
*CVP()
*/
#define CVP_MODE_NONE 0x00 //清晰语音处理关闭
#define CVP_MODE_NORMAL 0x01 //通用模式
#define CVP_MODE_DMS 0x02 //双mic降噪(ENC)模式
#define CVP_MODE_SMS 0x03 //单mic系统(外加延时估计)
#define CVP_MODE_SMS_TDE 0x04 //单mic系统(内置延时估计)
#define CVP_MODE_SEL CVP_MODE_NORMAL
#define AEC_EN BIT(0)
#define NLP_EN BIT(1)
#define ANS_EN BIT(2)
#define ENC_EN BIT(3)
#define AGC_EN BIT(4)
#define WNC_EN BIT(5)
#define MFDT_EN BIT(6)
/*aec module enable bit define*/
#define AEC_MODE_ADVANCE (AEC_EN | NLP_EN | ANS_EN )
#define AEC_MODE_REDUCE (NLP_EN | ANS_EN )
#define AEC_MODE_SIMPLEX (ANS_EN)
/*
*SMS模式选择
*(1)SMS模式性能更好ram和mips
*(2)SMS_NORMAL和SMS_TDE功能一样SMS_TDE内置了延时估计和延时补偿
*
*/
#define SMS_DISABLE 0
#define SMS_NORMAL 1
#define SMS_TDE 2
#define TCFG_AUDIO_SMS_ENABLE SMS_DISABLE
/*
*DMS版本配置
*DMS_GLOBAL_V100:
*DMS_GLOBAL_V200:ram和mips
*/
#define TCFG_AUDIO_DMS_GLOBAL_VERSION DMS_GLOBAL_V100
#if (defined(CONFIG_MEDIA_NEW_ENABLE) || (defined(CONFIG_MEDIA_DEVELOP_ENABLE)))
extern const u8 CONST_AEC_SIMPLEX;
/*兼容SMS和DMS*/
#if TCFG_AUDIO_TRIPLE_MIC_ENABLE
#include "commproc_tms.h"
#define aec_open aec_tms_init
#define aec_close aec_tms_exit
#define aec_in_data aec_tms_fill_in_data
#define aec_in_data_ref aec_tms_fill_in_ref_data
#define aec_in_data_ref_1 aec_tms_fill_in_ref_1_data
#define aec_ref_data aec_tms_fill_ref_data
#elif TCFG_AUDIO_DUAL_MIC_ENABLE
#include "commproc_dms.h"
#if (TCFG_AUDIO_DMS_SEL == DMS_NORMAL)
#define aec_open aec_dms_init
#define aec_close aec_dms_exit
#define aec_in_data aec_dms_fill_in_data
#define aec_in_data_ref aec_dms_fill_in_ref_data
#define aec_ref_data aec_dms_fill_ref_data
#else
#define aec_open aec_dms_flexible_init
#define aec_close aec_dms_flexible_exit
#define aec_in_data aec_dms_flexible_fill_in_data
#define aec_in_data_ref aec_dms_flexible_fill_in_ref_data
#define aec_ref_data aec_dms_flexible_fill_ref_data
#endif/*TCFG_AUDIO_DMS_SEL*/
void aec_cfg_fill(AEC_DMS_CONFIG *cfg);
/*
*********************************************************************
* Audio AEC Output Select
* Description:
* Arguments : sel = Default
* = Master mic(mic)
* = Slave mic(mic)
* agc agc自动增益控制模块
* Return : None.
* Note(s) : mic的频响和ENC指标
*********************************************************************
*/
void audio_aec_output_sel(CVP_OUTPUT_ENUM sel, u8 agc);
#elif (TCFG_AUDIO_SMS_ENABLE == SMS_TDE)
#include "commproc.h"
#define aec_open sms_tde_init
#define aec_close sms_tde_exit
#define aec_in_data sms_tde_fill_in_data
#define aec_in_data_ref(...)
#define aec_ref_data sms_tde_fill_ref_data
void aec_cfg_fill(AEC_CONFIG *cfg);
#else
#include "commproc.h"
#define aec_open aec_init
#define aec_close aec_exit
#define aec_in_data aec_fill_in_data
#define aec_in_data_ref(...)
#define aec_ref_data aec_fill_ref_data
void aec_cfg_fill(AEC_CONFIG *cfg);
#endif
s8 aec_debug_online(void *buf, u16 size);
void aec_input_clear_enable(u8 enable);
int audio_aec_init(u16 sample_rate);
void audio_aec_close(void);
void audio_aec_inbuf(s16 *buf, u16 len);
void audio_aec_inbuf_ref(s16 *buf, u16 len);
void audio_aec_inbuf_ref_1(s16 *buf, u16 len);
void audio_aec_refbuf(s16 *buf, u16 len);
u8 audio_aec_status(void);
void audio_aec_reboot(u8 reduce);
void audio_aec_ref_start(u8 en);
/*
*********************************************************************
* Audio AEC Open
* Description: AEC模块
* Arguments : sr (8000/16000)
* enablebit 使(AEC/NLP/AGC/ANS...)
* out_hdl NULL则用默认的回调
* Return : 0
* Note(s) : audio_aec_init的扩展使
*
*********************************************************************
*/
int audio_aec_open(u16 sample_rate, s16 enablebit, int (*out_hdl)(s16 *data, u16 len));
/*
*********************************************************************
* Audio CVP IOCTL
* Description: CVP功能配置
* Arguments : cmd
* value
* priv
* Return : 0
* Note(s) : (1)NS模块:
* audio_cvp_ioctl(CVP_NS_SWITCH,1,NULL); //降噪关
* audio_cvp_ioctl(CVP_NS_SWITCH,0,NULL); //降噪开
*********************************************************************
*/
int audio_cvp_ioctl(int cmd, int value, void *priv);
/*获取风噪的检测结果1有风噪0无风噪*/
int audio_cvp_dms_wnc_state(void);
/*获取单双麦切换状态
* 0: ;
* 1:
* -1:
*/
int audio_cvp_dms_malfunc_state();
/*
* mic的能量值MFDT_EN才能用
* mic: 0
* mic1
* return[0~90.3],-1
*/
float audio_cvp_dms_mic_energy(u8 mic);
/*tri_en: 1 正常3MIC降噪
* 0 2MIC降噪使 FB MIC数据*/
int audio_tms_mode_choose(u8 tri_en);
#else
extern struct aec_s_attr aec_param;
extern const u8 CONST_AEC_SIMPLEX;
struct aec_s_attr *aec_param_init(u16 sr);
s8 aec_debug_online(void *buf, u16 size);
void aec_cfg_fill(AEC_CONFIG *cfg);
void aec_input_clear_enable(u8 enable);
#endif /* #if (defined(CONFIG_MEDIA_NEW_ENABLE) || (defined(CONFIG_MEDIA_DEVELOP_ENABLE))) */
//aec 上行音效
enum {
SOUND_ORIGINAL, //原声
SOUND_UNCLE, //大叔
SOUND_GODDESS, //女神
};
#if defined(AEC_PRESETS_UL_EQ_CONFIG) && AEC_PRESETS_UL_EQ_CONFIG
#ifndef UL_PRESETS_EQ_NSECTION
#define UL_PRESETS_EQ_NSECTION 5
#endif
#if (UL_PRESETS_EQ_NSECTION > EQ_SECTION_MAX )
#error "EQ_SETCTION_MAX too samll"
#endif
void aec_ul_eq_update();
void ul_presets_eq_set(u8 tab_num);
#endif/*AEC_PRESETS_UL_EQ_CONFIG*/
#endif/*_AEC_USER_H_*/