first
This commit is contained in:
503
apps/common/icsd/adt/icsd_adt.c
Normal file
503
apps/common/icsd/adt/icsd_adt.c
Normal file
@ -0,0 +1,503 @@
|
||||
#include "app_config.h"
|
||||
#if ((defined TCFG_AUDIO_ANC_ACOUSTIC_DETECTOR_EN) && TCFG_AUDIO_ANC_ACOUSTIC_DETECTOR_EN && \
|
||||
TCFG_AUDIO_ANC_ENABLE)
|
||||
#include "system/task.h"
|
||||
#include "icsd_adt.h"
|
||||
#include "icsd_adt_app.h"
|
||||
#include "classic/tws_api.h"
|
||||
#include "icsd_anc.h"
|
||||
#include "tone_player.h"
|
||||
#include "icsd_anc_user.h"
|
||||
|
||||
#define ICSD_ADT_TASK_NAME "icsd_adt"
|
||||
|
||||
const u8 VDT_TRAIN_EN = 0;
|
||||
|
||||
u8 adt_task = 0;
|
||||
u8 src_task = 0;
|
||||
int (*adt_printf)(const char *format, ...);
|
||||
int (*wat_printf)(const char *format, ...);
|
||||
int (*ein_printf)(const char *format, ...);
|
||||
int printf_off(const char *format, ...)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define ADT_DATA_DEBUG 0
|
||||
void icsd_adt_run_output(__adt_result *adt_result)
|
||||
{
|
||||
u8 voice_state = adt_result->voice_state;
|
||||
u8 wind_lvl = adt_result->wind_lvl;
|
||||
u8 wat_result = adt_result->wat_result;
|
||||
u8 ein_state = adt_result->ein_state;
|
||||
|
||||
#if ADT_DATA_DEBUG
|
||||
extern void icsd_adt_output_demo(__adt_result * adt_result);
|
||||
icsd_adt_output_demo(adt_result);
|
||||
#else
|
||||
void audio_acoustic_detector_output_hdl(u8 voice_state, u8 wind_lvl, u8 wat_result);
|
||||
audio_acoustic_detector_output_hdl(voice_state, wind_lvl, wat_result);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define AUDIO_ADC_CH0 BIT(0)
|
||||
#define AUDIO_ADC_CH1 BIT(1)
|
||||
#define AUDIO_ADC_CH2 BIT(2)
|
||||
#define AUDIO_ADC_CH3 BIT(3)
|
||||
void icsd_adt_mic_ch_analog_open(u32 ch)
|
||||
{
|
||||
if (ch & AUDIO_ADC_CH0) {
|
||||
/*close mic0 analog config*/
|
||||
SFR(JL_ADDA->ADA_CON4, 15, 1, 0); // AUDADC_MICA_BUFP_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON4, 14, 1, 0); // AUDADC_MICA_BUFN_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON4, 4, 1, 1); // AUDADC_MICA_AMP_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 8, 1, 1); // AUDADC_CHA_S2_RSTB_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 7, 1, 1); // AUDADC_CHA_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 6, 1, 1); // AUDADC_CHA_BIAS_EN_10v
|
||||
}
|
||||
if (ch & AUDIO_ADC_CH1) {
|
||||
/*close mic1 analog config*/
|
||||
SFR(JL_ADDA->ADA_CON5, 15, 1, 0); // AUDADC_MICB_BUFP_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON5, 14, 1, 0); // AUDADC_MICB_BUFN_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON5, 4, 1, 1); // AUDADC_MICB_AMP_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 11, 1, 1); // AUDADC_CHB_S2_RSTB_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 10, 1, 1); // AUDADC_CHB_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 9, 1, 1); // AUDADC_CHB_BIAS_EN_10v
|
||||
}
|
||||
if (ch & AUDIO_ADC_CH2) {
|
||||
/*close mic2 analog config*/
|
||||
SFR(JL_ADDA->ADA_CON6, 15, 1, 0); // AUDADC_MICC_BUFP_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON6, 14, 1, 0); // AUDADC_MICC_BUFN_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON6, 4, 1, 1); // AUDADC_MICC_AMP_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 14, 1, 1); // AUDADC_CHC_S2_RSTB_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 13, 1, 1); // AUDADC_CHC_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 12, 1, 1); // AUDADC_CHC_BIAS_EN_10v
|
||||
}
|
||||
if (ch & AUDIO_ADC_CH3) {
|
||||
/*close mic3 analog config*/
|
||||
SFR(JL_ADDA->ADA_CON7, 15, 1, 0); // AUDADC_MICD_BUFP_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON7, 14, 1, 0); // AUDADC_MICD_BUFN_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON7, 4, 1, 1); // AUDADC_MICD_AMP_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 17, 1, 1); // AUDADC_CHD_S2_RSTB_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 16, 1, 1); // AUDADC_CHD_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 15, 1, 1); // AUDADC_CHD_BIAS_EN_10v
|
||||
}
|
||||
}
|
||||
|
||||
void icsd_adt_mic_ch_analog_close(u32 ch)
|
||||
{
|
||||
if (ch & AUDIO_ADC_CH0) {
|
||||
/*close mic0 analog config*/
|
||||
SFR(JL_ADDA->ADA_CON4, 15, 1, 0); // AUDADC_MICA_BUFP_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON4, 14, 1, 0); // AUDADC_MICA_BUFN_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON4, 4, 1, 0); // AUDADC_MICA_AMP_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 8, 1, 0); // AUDADC_CHA_S2_RSTB_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 7, 1, 0); // AUDADC_CHA_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 6, 1, 0); // AUDADC_CHA_BIAS_EN_10v
|
||||
}
|
||||
if (ch & AUDIO_ADC_CH1) {
|
||||
/*close mic1 analog config*/
|
||||
SFR(JL_ADDA->ADA_CON5, 15, 1, 0); // AUDADC_MICB_BUFP_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON5, 14, 1, 0); // AUDADC_MICB_BUFN_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON5, 4, 1, 0); // AUDADC_MICB_AMP_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 11, 1, 0); // AUDADC_CHB_S2_RSTB_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 10, 1, 0); // AUDADC_CHB_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 9, 1, 0); // AUDADC_CHB_BIAS_EN_10v
|
||||
}
|
||||
if (ch & AUDIO_ADC_CH2) {
|
||||
/*close mic2 analog config*/
|
||||
SFR(JL_ADDA->ADA_CON6, 15, 1, 0); // AUDADC_MICC_BUFP_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON6, 14, 1, 0); // AUDADC_MICC_BUFN_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON6, 4, 1, 0); // AUDADC_MICC_AMP_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 14, 1, 0); // AUDADC_CHC_S2_RSTB_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 13, 1, 0); // AUDADC_CHC_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 12, 1, 0); // AUDADC_CHC_BIAS_EN_10v
|
||||
}
|
||||
if (ch & AUDIO_ADC_CH3) {
|
||||
/*close mic3 analog config*/
|
||||
SFR(JL_ADDA->ADA_CON7, 15, 1, 0); // AUDADC_MICD_BUFP_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON7, 14, 1, 0); // AUDADC_MICD_BUFN_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON7, 4, 1, 0); // AUDADC_MICD_AMP_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 17, 1, 0); // AUDADC_CHD_S2_RSTB_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 16, 1, 0); // AUDADC_CHD_EN_10v
|
||||
SFR(JL_ADDA->ADA_CON1, 15, 1, 0); // AUDADC_CHD_BIAS_EN_10v
|
||||
}
|
||||
}
|
||||
|
||||
u8 talk_mic_analog_close = 0;
|
||||
u8 audio_adt_talk_mic_analog_close()
|
||||
{
|
||||
if (talk_mic_analog_close == 0) {
|
||||
printf("-----------audio_adt_talk_mic_analog_close\n");
|
||||
u8 talk_mic_ch = icsd_get_talk_mic_ch();
|
||||
icsd_adt_mic_ch_analog_close(talk_mic_ch);
|
||||
talk_mic_analog_close = 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 audio_adt_talk_mic_analog_open()
|
||||
{
|
||||
if (talk_mic_analog_close) {
|
||||
printf("-----------audio_adt_talk_mic_analog_open\n");
|
||||
u8 talk_mic_ch = icsd_get_talk_mic_ch();
|
||||
icsd_adt_mic_ch_analog_open(talk_mic_ch);
|
||||
talk_mic_analog_close = 0;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
float adt_pow10(float n)
|
||||
{
|
||||
float pow10n = exp_float((float)n / log10_float(exp_float((float)1.0)));
|
||||
return pow10n;
|
||||
}
|
||||
|
||||
u32 icsd_adt_get_role()
|
||||
{
|
||||
return tws_api_get_role();
|
||||
}
|
||||
|
||||
u32 icsd_adt_get_tws_state()
|
||||
{
|
||||
return tws_api_get_tws_state();
|
||||
}
|
||||
|
||||
#define TWS_FUNC_ID_SDADT_M2S TWS_FUNC_ID('A', 'D', 'T', 'M')
|
||||
REGISTER_TWS_FUNC_STUB(icsd_adt_m2s) = {
|
||||
.func_id = TWS_FUNC_ID_SDADT_M2S,
|
||||
.func = icsd_adt_m2s_cb,
|
||||
};
|
||||
#define TWS_FUNC_ID_SDADT_S2M TWS_FUNC_ID('A', 'D', 'T', 'S')
|
||||
REGISTER_TWS_FUNC_STUB(icsd_adt_s2m) = {
|
||||
.func_id = TWS_FUNC_ID_SDADT_S2M,
|
||||
.func = icsd_adt_s2m_cb,
|
||||
};
|
||||
|
||||
void icsd_adt_tws_m2s(u8 cmd)
|
||||
{
|
||||
local_irq_disable();
|
||||
s8 data[8];
|
||||
icsd_adt_m2s_packet(data, cmd);
|
||||
int ret = tws_api_send_data_to_sibling(data, 8, TWS_FUNC_ID_SDADT_M2S);
|
||||
local_irq_enable();
|
||||
}
|
||||
|
||||
void icsd_adt_tws_s2m(u8 cmd)
|
||||
{
|
||||
local_irq_disable();
|
||||
s8 data[8];
|
||||
icsd_adt_s2m_packet(data, cmd);
|
||||
int ret = tws_api_send_data_to_sibling(data, 8, TWS_FUNC_ID_SDADT_S2M);
|
||||
local_irq_enable();
|
||||
}
|
||||
|
||||
void icsd_adt_anc_dma_on(u8 out_sel, int *buf, int len)
|
||||
{
|
||||
anc_dma_on_double(out_sel, buf, len);
|
||||
}
|
||||
|
||||
void icsd_adt_dma_done()
|
||||
{
|
||||
icsd_acoustic_detector_ancdma_done();
|
||||
}
|
||||
|
||||
void icsd_adt_hw_suspend()
|
||||
{
|
||||
anc_core_dma_ie(0);
|
||||
anc_core_dma_stop();
|
||||
}
|
||||
|
||||
void icsd_adt_hw_resume()
|
||||
{
|
||||
audio_acoustic_detector_updata();
|
||||
icsd_adt_szout_init();
|
||||
}
|
||||
|
||||
void icsd_adt_FFT_radix256(int *in_cur, int *out)
|
||||
{
|
||||
u32 fft_config;
|
||||
fft_config = hw_fft_config(256, 8, 1, 0, 1);
|
||||
hw_fft_run(fft_config, in_cur, out);
|
||||
}
|
||||
|
||||
void icsd_adt_FFT_radix128(int *in_cur, int *out)
|
||||
{
|
||||
u32 fft_config;
|
||||
fft_config = hw_fft_config(128, 7, 1, 0, 1);
|
||||
hw_fft_run(fft_config, in_cur, out);
|
||||
}
|
||||
|
||||
void icsd_adt_FFT_radix64(int *in_cur, int *out)
|
||||
{
|
||||
u32 fft_config;
|
||||
fft_config = hw_fft_config(64, 6, 1, 0, 1);
|
||||
hw_fft_run(fft_config, in_cur, out);
|
||||
}
|
||||
|
||||
void icsd_post_anctask_msg(u8 cmd)
|
||||
{
|
||||
audio_anc_post_msg_adt(cmd);
|
||||
}
|
||||
|
||||
void icsd_post_adttask_msg(u8 cmd)
|
||||
{
|
||||
if (adt_task == 1) {
|
||||
os_taskq_post_msg("icsd_adt", 1, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
void icsd_post_srctask_msg(u8 cmd)
|
||||
{
|
||||
if (src_task == 1) {
|
||||
os_taskq_post_msg("icsd_src", 1, cmd);
|
||||
}
|
||||
}
|
||||
|
||||
void icsd_adt_task(void *priv)
|
||||
{
|
||||
int res = 0;
|
||||
int msg[30];
|
||||
while (1) {
|
||||
res = os_taskq_pend(NULL, msg, ARRAY_SIZE(msg));
|
||||
if (res == OS_TASKQ) {
|
||||
icsd_adt_task_handler(msg[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void icsd_adt_task_create()
|
||||
{
|
||||
if (adt_task == 0) {
|
||||
task_create(icsd_adt_task, NULL, ICSD_ADT_TASK_NAME);
|
||||
adt_task = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void icsd_adt_task_kill()
|
||||
{
|
||||
if (adt_task == 1) {
|
||||
task_kill(ICSD_ADT_TASK_NAME);
|
||||
adt_task = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void icsd_src_task(void *priv)
|
||||
{
|
||||
int res = 0;
|
||||
int msg[30];
|
||||
while (1) {
|
||||
res = os_taskq_pend(NULL, msg, ARRAY_SIZE(msg));
|
||||
if (res == OS_TASKQ) {
|
||||
icsd_src_task_handler(msg[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void icsd_src_task_create()
|
||||
{
|
||||
if (src_task == 0) {
|
||||
task_create(icsd_src_task, NULL, "icsd_src");
|
||||
src_task = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void icsd_src_task_kill()
|
||||
{
|
||||
if (src_task == 1) {
|
||||
task_kill("icsd_src");
|
||||
src_task = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void icsd_adt_start()
|
||||
{
|
||||
adt_printf = _adt_printf;
|
||||
wat_printf = _wat_printf;
|
||||
ein_printf = _ein_printf;
|
||||
printf("icsd_adt_start====================================\n");
|
||||
}
|
||||
|
||||
void icsd_adt_szout_init()
|
||||
{
|
||||
#if ADT_USE_ADAPTIVE_SZ
|
||||
extern float icsd_anc_sz_data[120 + 40];
|
||||
extern float icsd_anc_pz_data[120 + 40];
|
||||
extern u8 sz_out_exist;//需要打开自适应ANC库中的 自适应SZ输出使能:ANC_SZ_OUT_EN
|
||||
icsd_adt_szout_set(icsd_anc_sz_data, icsd_anc_pz_data, sz_out_exist);
|
||||
#else
|
||||
icsd_adt_szout_set(0, 0, 0);
|
||||
#endif
|
||||
}
|
||||
const u16 ADT_DEBUG_INF = 0;//ADT_INF_1;//state
|
||||
//state = 1, pwr = 7, dov = 8, angle_err = 7, angle_tlk = 3
|
||||
const u8 adt_errpxx_dB_thr = 80;//60;
|
||||
const u8 adt_err_zcv_thr = 10;//12;
|
||||
const u8 pwr_inside_even_flag0_thr = 5; //pwr
|
||||
const u8 angle_err_even_flag0_thr = 3;//4; //angle_err
|
||||
const u8 angle_talk_even_flag0_thr = 2; //angle_tlk
|
||||
const u16 f1f2_angsum_thr = 200;
|
||||
#ifndef ADT_CLIENT_BOARD
|
||||
const u8 final_speech_even_thr = 4; //dov
|
||||
|
||||
|
||||
const u8 ADT_TWS_MODE = 1;
|
||||
const u8 ADT_DET_VER = 6;
|
||||
const u8 ADT_PATH_CONFIG = ADT_PATH_DAC_SRC_EN | ADT_PATH_3M_EN;
|
||||
const u8 ADT_EIN_VER = ADT_EIN_TWS_V0;
|
||||
const float ref_gain_sel = 3;
|
||||
const float err_gain_sel = 3;
|
||||
u8 pnc_ref_pwr_thr = 160;
|
||||
u8 pnc_err_pwr_thr = 100;
|
||||
u8 tpc_ref_pwr_thr = 120;
|
||||
u8 tpc_err_pwr_thr = 100;
|
||||
u8 anc_ref_pwr_thr = 120;
|
||||
u8 anc_err_pwr_thr = 100;
|
||||
|
||||
const float wat_pn_gain = 0.22;
|
||||
const float wat_bypass_gain = 16;
|
||||
const float wat_anc_gain = 0.22;
|
||||
|
||||
const float wdac_senc = 0.7; //越小播音乐时灵敏度越高
|
||||
const float wdac[8] = { 0.35, 0.54, 0.57, 0.48, 0.37, 0.22, 0.38, 0.37};//播放音乐/100
|
||||
const float wref[8] = {1.62, 0.90, 0.71, 0.60, 0.54, 0.50, 0.47, 0.46};//播放外部噪声
|
||||
const float wref_tran[8] = {1.82, 1.80, 1.58, 1.30, 1.16, 1.12, 1.11, 1.12};
|
||||
const float wref_ancs[8] = {1.92, 0.48, 0.07, 0.03, 0.05, 0.06, 0.06, 0.04 };
|
||||
const float fdac[8] = {0.18, 0.051, 0.02, 0.02, 0.02, 0.02, 0.02, 0.05};//播放音乐/1000
|
||||
u8 icsd_get_ang_flag(float *_target_angle)
|
||||
{
|
||||
u8 af1 = _target_angle[1] > 15 || _target_angle[1] < -130;
|
||||
u8 af2 = _target_angle[2] > 15 || _target_angle[2] < -130;
|
||||
u8 af3 = _target_angle[3] > 15 || _target_angle[3] < -130;
|
||||
u8 ang_flag = af1 && af2 && af3;
|
||||
/* printf("get ang flag:%d\n", ang_flag); */
|
||||
return ang_flag;
|
||||
}
|
||||
|
||||
void icsd_adt_ein_parm_HT03(__icsd_adt_parm *_ADT_PARM)
|
||||
{
|
||||
_ADT_PARM->anc_in_pz_sum = -80;
|
||||
_ADT_PARM->anc_out_pz_sum = 0;
|
||||
_ADT_PARM->anc_in_sz_mean = 1;
|
||||
_ADT_PARM->anc_out_sz_mean = -12;
|
||||
_ADT_PARM->anc_in_fb_sum = 60;
|
||||
_ADT_PARM->anc_out_fb_sum = 30;
|
||||
|
||||
_ADT_PARM->pnc_in_pz_sum = -80;
|
||||
_ADT_PARM->pnc_out_pz_sum = 0;
|
||||
_ADT_PARM->pnc_in_sz_mean = 1;
|
||||
_ADT_PARM->pnc_out_sz_mean = -12;
|
||||
_ADT_PARM->pnc_in_fb_sum = 60;
|
||||
_ADT_PARM->pnc_out_fb_sum = 30;
|
||||
|
||||
_ADT_PARM->trans_in_pz_sum = 2;
|
||||
_ADT_PARM->trans_out_pz_sum = 26;
|
||||
_ADT_PARM->trans_in_sz_mean = 2;
|
||||
_ADT_PARM->trans_out_sz_mean = -7;
|
||||
_ADT_PARM->trans_in_fb_sum = 20;
|
||||
_ADT_PARM->trans_out_fb_sum = -20;
|
||||
}
|
||||
|
||||
void icsd_adt_voice_board_data()
|
||||
{
|
||||
__icsd_adt_parm *ADT_PARM;
|
||||
ADT_PARM = zalloc(sizeof(__icsd_adt_parm));
|
||||
|
||||
extern const float HT03_ADT_FLOAT_DATA[];
|
||||
extern const float HT03_sz_out_data[28];
|
||||
extern const float HT03_pz_out_data[28];
|
||||
ADT_PARM->adt_float_data = (void *)HT03_ADT_FLOAT_DATA;
|
||||
ADT_PARM->sz_inptr = (float *)HT03_sz_out_data;
|
||||
ADT_PARM->pz_inptr = (float *)HT03_pz_out_data;
|
||||
icsd_adt_ein_parm_HT03(ADT_PARM);
|
||||
|
||||
icsd_adt_parm_set(ADT_PARM);
|
||||
free(ADT_PARM);
|
||||
|
||||
icsd_adt_szout_init();
|
||||
}
|
||||
#else
|
||||
|
||||
#include "icsd_adt_client_board.c"
|
||||
|
||||
#endif/*ADC_CLIENT_BOARD*/
|
||||
|
||||
|
||||
//=======================================================================================================
|
||||
|
||||
#if ADT_DATA_DEBUG
|
||||
|
||||
void icsd_play_num0()
|
||||
{
|
||||
icsd_adt_tone_play(ICSD_ADT_TONE_NUM0);
|
||||
}
|
||||
void icsd_play_num1()
|
||||
{
|
||||
icsd_adt_tone_play(ICSD_ADT_TONE_NUM1);
|
||||
}
|
||||
void icsd_play_num2()
|
||||
{
|
||||
icsd_adt_tone_play(ICSD_ADT_TONE_NUM2);
|
||||
}
|
||||
void icsd_play_num3()
|
||||
{
|
||||
icsd_adt_tone_play(ICSD_ADT_TONE_NUM3);
|
||||
}
|
||||
void icsd_play_normal()
|
||||
{
|
||||
icsd_adt_tone_play(ICSD_ADT_TONE_NORMAL);
|
||||
}
|
||||
|
||||
void icsd_adt_output_demo(__adt_result *adt_result)
|
||||
{
|
||||
#if ADT_EAR_IN_EN
|
||||
static u8 hold = 0;
|
||||
static u8 hold_flg = 0;
|
||||
static int hold_time = 0;
|
||||
if (adt_result->ein_state == 0) {
|
||||
hold = 1;
|
||||
hold_flg = 1;
|
||||
hold_time = 0;
|
||||
printf("------------------------------------------------------------------ein state:0\n");
|
||||
} else {
|
||||
if (hold_flg) {
|
||||
hold_flg = 0;
|
||||
hold_time = jiffies;
|
||||
printf("set hold time:%d\n", hold_time);
|
||||
}
|
||||
if ((hold_time > 0) && (hold)) {
|
||||
if (jiffies > (hold_time + 100)) {
|
||||
printf("hold time out:%d\n", jiffies);
|
||||
hold = 0;
|
||||
}
|
||||
}
|
||||
printf("--------------------------------ein state:1\n");
|
||||
}
|
||||
if (hold) {
|
||||
//return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (adt_result->wind_lvl) {
|
||||
printf("------wind lvl:%d\n", adt_result->wind_lvl);
|
||||
}
|
||||
if (adt_result->voice_state) {
|
||||
icsd_play_normal();
|
||||
}
|
||||
switch (adt_result->wat_result) {
|
||||
case 2:
|
||||
icsd_play_num2();
|
||||
break;
|
||||
case 3:
|
||||
icsd_play_num3();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /*ADT_DATA_DEBUG*/
|
||||
|
||||
#endif /*(defined TCFG_AUDIO_ANC_ACOUSTIC_DETECTOR_EN) && TCFG_AUDIO_ANC_ACOUSTIC_DETECTOR_EN*/
|
||||
|
||||
306
apps/common/icsd/adt/icsd_adt.h
Normal file
306
apps/common/icsd/adt/icsd_adt.h
Normal file
@ -0,0 +1,306 @@
|
||||
#ifndef _ICSD_ADT_H
|
||||
#define _ICSD_ADT_H
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "os/os_type.h"
|
||||
#include "os/os_api.h"
|
||||
#include "classic/tws_api.h"
|
||||
#include "math.h"
|
||||
|
||||
#if 0
|
||||
#define _adt_printf printf //打开智能免摘库打印信息
|
||||
#else
|
||||
extern int printf_off(const char *format, ...);
|
||||
#define _adt_printf printf_off
|
||||
#endif/*log_en*/
|
||||
|
||||
#if 0
|
||||
#define _wat_printf printf //打开广域点击库打印信息
|
||||
#else
|
||||
extern int printf_off(const char *format, ...);
|
||||
#define _wat_printf printf_off
|
||||
#endif/*log_en*/
|
||||
|
||||
#if 0
|
||||
#define _wind_printf printf //打开风噪检测库打印信息
|
||||
#else
|
||||
extern int printf_off(const char *format, ...);
|
||||
#define _wind_printf printf_off
|
||||
#endif/*log_en*/
|
||||
|
||||
#if 0
|
||||
#define _ein_printf printf //打开入耳检测库打印信息
|
||||
#else
|
||||
extern int printf_off(const char *format, ...);
|
||||
#define _ein_printf printf_off
|
||||
#endif/*log_en*/
|
||||
|
||||
#define ADT_CALIBRATION_EN 0
|
||||
#define ADT_USE_ADAPTIVE_SZ 0//使用自适应SZ
|
||||
#define ADT_EAR_IN_EN 0
|
||||
|
||||
#define ADT_VDT_EN BIT(0) //智能免摘
|
||||
#define ADT_WDT_EN BIT(1) //风噪检测
|
||||
#define ADT_WAT_EN BIT(2) //广域点击
|
||||
#define ADT_EIN_EN BIT(3) //入耳检测
|
||||
|
||||
#define ADT_PATH_VDT_ANCL_ON BIT(0) //智能免摘使用ancl通路数据
|
||||
#define ADT_PATH_WAT_EMIC_ON BIT(1) //广域点击使用errmic数据通路
|
||||
#define ADT_PATH_VAD_ON BIT(2) //通过VAD检测降低功耗
|
||||
#define ADT_PATH_DAC_SRC_EN BIT(3)
|
||||
#define ADT_PATH_3M_EN BIT(4)
|
||||
|
||||
|
||||
#define ADT_INF_1 BIT(0)
|
||||
#define ADT_INF_2 BIT(1)
|
||||
#define ADT_INF_3 BIT(2)
|
||||
|
||||
extern const u8 ADT_PATH_CONFIG;
|
||||
#define ICSD_TWS_STA_SIBLING_CONNECTED TWS_STA_SIBLING_CONNECTED//tws已连接
|
||||
|
||||
typedef struct {
|
||||
u8 voice_state;
|
||||
u8 wind_lvl;
|
||||
u8 wat_result;
|
||||
u8 ein_state;
|
||||
} __adt_result;
|
||||
|
||||
struct icsd_acoustic_detector_infmt {
|
||||
u16 sample_rate; //当前播放采样率
|
||||
u8 ff_gain;
|
||||
u8 fb_gain;
|
||||
u8 adt_mode; // TWS: 0 HEADSET: 1
|
||||
u8 dac_mode; //低压0 高压1
|
||||
u8 mic0_type; // MIC0 类型
|
||||
u8 mic1_type; // MIC1 类型
|
||||
u8 mic2_type; // MIC2 类型
|
||||
u8 mic3_type; // MIC3 类型
|
||||
u8 sensitivity; //智能免摘灵敏度设置
|
||||
void *lfb_coeff;
|
||||
void *lff_coeff;
|
||||
void *ltrans_coeff;
|
||||
void *ltransfb_coeff;
|
||||
float gains_l_fbgain;
|
||||
float gains_l_ffgain;
|
||||
float gains_l_transgain;
|
||||
float gains_l_transfbgain;
|
||||
u8 gain_sign;
|
||||
u8 lfb_yorder;
|
||||
u8 lff_yorder;
|
||||
u8 ltrans_yorder;
|
||||
u8 ltransfb_yorder;
|
||||
u32 trans_alogm;
|
||||
u32 alogm;
|
||||
|
||||
void *alloc_ptr; //外部申请的ram地址
|
||||
/*
|
||||
算法结果输出
|
||||
voice_state: 0 无讲话; 1 有讲话
|
||||
wind_lvl: 0-70 风噪等级
|
||||
*/
|
||||
void (*output_hdl)(u8 voice_state, u8 wind_lvl); //算法结果输出
|
||||
void (*anc_dma_post_msg)(void); //ANC task dma 抄数回调接口
|
||||
void (*anc_dma_output_callback); //ANC DMA下采样数据输出回调,用于写卡分析
|
||||
};
|
||||
|
||||
struct icsd_acoustic_detector_libfmt {
|
||||
int adc_isr_len; //ADC中断长度
|
||||
int adc_sr; //ADC 采样率
|
||||
int lib_alloc_size; //算法ram需求大小
|
||||
u8 mic_num; //需要打开的mic个数
|
||||
};
|
||||
|
||||
enum {
|
||||
ICSD_ANC_LFF_MIC = 0,
|
||||
ICSD_ANC_LFB_MIC = 1,
|
||||
ICSD_ANC_RFF_MIC = 2,
|
||||
ICSD_ANC_RFB_MIC = 3,
|
||||
ICSD_ANC_TALK_MIC = 4,
|
||||
ICSD_ANC_MIC_NULL = 0XFF, //对应的MIC没有数值,则表示这个MIC没有开启
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
void *adt_float_data;
|
||||
float *sz_inptr;
|
||||
float *pz_inptr;
|
||||
s16 anc_in_pz_sum;
|
||||
s16 anc_in_sz_mean;
|
||||
s16 anc_in_fb_sum;
|
||||
s16 anc_out_pz_sum;
|
||||
s16 anc_out_sz_mean;
|
||||
s16 anc_out_fb_sum;
|
||||
|
||||
s16 pnc_in_pz_sum;
|
||||
s16 pnc_in_sz_mean;
|
||||
s16 pnc_in_fb_sum;
|
||||
s16 pnc_out_pz_sum;
|
||||
s16 pnc_out_sz_mean;
|
||||
s16 pnc_out_fb_sum;
|
||||
|
||||
s16 trans_in_pz_sum;
|
||||
s16 trans_in_sz_mean;
|
||||
s16 trans_in_fb_sum;
|
||||
s16 trans_out_pz_sum;
|
||||
s16 trans_out_sz_mean;
|
||||
s16 trans_out_fb_sum;
|
||||
} __icsd_adt_parm;
|
||||
|
||||
enum {
|
||||
RESUME_ANCMODE = 0,
|
||||
RESUME_BYPASSMODE,
|
||||
};
|
||||
enum {
|
||||
ADT_DACMODE_LOW = 0,
|
||||
ADT_DACMODE_HIGH,
|
||||
};
|
||||
enum {
|
||||
ADT_TWS = 0,
|
||||
ADT_HEADSET,
|
||||
};
|
||||
enum {
|
||||
ADT_ANC_ON = 0,
|
||||
ADT_ANC_OFF,
|
||||
};
|
||||
enum {
|
||||
ADT_VOICE_WIND_MODE = 0, //智能免摘 + 风噪
|
||||
ADT_WAT_MODE, //广域点击
|
||||
ADT_VW_WAT_MODE, //智能免摘 + 风噪检测 + 广域点击
|
||||
};
|
||||
enum {
|
||||
ADT_EIN_UNSUPPORT = 0,
|
||||
ADT_EIN_TWS_V0,
|
||||
ADT_EIN_HEADSET_V0,
|
||||
};
|
||||
|
||||
extern const float wat_pn_gain;
|
||||
extern const float wat_anc_gain;
|
||||
extern const float wat_bypass_gain;
|
||||
extern const u8 final_speech_even_thr;
|
||||
extern const u8 VDT_TRAIN_EN;
|
||||
extern const float ref_gain_sel;
|
||||
extern const float err_gain_sel;
|
||||
extern u8 pnc_ref_pwr_thr;
|
||||
extern u8 pnc_err_pwr_thr;
|
||||
extern u8 tpc_ref_pwr_thr;
|
||||
extern u8 tpc_err_pwr_thr;
|
||||
extern u8 anc_ref_pwr_thr;
|
||||
extern u8 anc_err_pwr_thr;
|
||||
extern const float wref[8];
|
||||
extern const float wref_tran[8];
|
||||
extern const float wref_ancs[8];
|
||||
extern const float wdac_senc;
|
||||
extern const float wdac[8];
|
||||
extern const float fdac[8];
|
||||
extern const u8 ADT_DET_VER;
|
||||
extern const u8 ADT_TWS_MODE;
|
||||
extern const u8 ADT_EIN_VER;
|
||||
extern float anc_trans_lfb_gain;
|
||||
extern float anc_trans_rfb_gain;
|
||||
extern const double anc_trans_lfb_coeff[];
|
||||
extern const double anc_trans_rfb_coeff[];
|
||||
|
||||
extern int (*adt_printf)(const char *format, ...);
|
||||
extern int (*wat_printf)(const char *format, ...);
|
||||
extern int (*ein_printf)(const char *format, ...);
|
||||
|
||||
extern void icsd_adt_tws_m2s(u8 cmd);
|
||||
extern void icsd_adt_tws_s2m(u8 cmd);
|
||||
//LIB调用的算术函数
|
||||
extern float sin_float(float x);
|
||||
extern float cos_float(float x);
|
||||
extern float cos_hq(float x);
|
||||
extern float sin_hq(float x);
|
||||
extern float log10_float(float x);
|
||||
extern float exp_float(float x);
|
||||
extern float root_float(float x);
|
||||
//extern float pow10(float n);
|
||||
extern float adt_pow10(float n);
|
||||
extern float angle_float(float x, float y);
|
||||
//ADT调用的APP函数
|
||||
|
||||
extern int audio_dac_read_anc_reset(void);
|
||||
extern int audio_acoustic_detector_updata();
|
||||
extern void tws_tx_unsniff_req(void);
|
||||
extern int tws_api_get_role(void);
|
||||
extern int tws_api_get_tws_state();
|
||||
extern u8 anc_dma_done_ppflag();
|
||||
extern void anc_core_dma_ie(u8 en);
|
||||
extern void anc_core_dma_stop(void);
|
||||
extern int os_task_create(void (*task_func)(void *p_arg), void *p_arg, u8 prio, u32 stksize, int qsize, const char *name);
|
||||
extern int os_task_del(const char *name);
|
||||
extern int os_taskq_post_msg(const char *name, int argc, ...);
|
||||
extern int os_taskq_pend(const char *fmt, int *argv, int argc);
|
||||
extern void anc_dma_on_double(u8 out_sel, int *buf, int len);
|
||||
extern int audio_resample_hw_push_data_out(void *resample);
|
||||
extern void audio_resample_hw_close(void *resample);
|
||||
extern void *audio_resample_hw_open(u8 channel, int in_rate, int out_rate, u8 type);
|
||||
extern int audio_resample_hw_set_output_handler(void *resample, void *priv, int (*handler)(void *, void *, int));
|
||||
extern int audio_resample_hw_write(void *resample, void *data, int len);
|
||||
extern void audio_anc_post_msg_adt(u8 cmd);
|
||||
extern void hw_fft_run(unsigned int fft_config, const int *in, int *out);
|
||||
extern unsigned int hw_fft_config(int N, int log2N, int is_same_addr, int is_ifft, int is_real);
|
||||
//APP调用的ADT函数
|
||||
extern void icsd_adt_start();
|
||||
extern void icsd_adt_anctask_handle(u8 cmd);
|
||||
//APP调用的LIB函数
|
||||
extern void icsd_acoustic_detector_get_libfmt(struct icsd_acoustic_detector_libfmt *libfmt, u8 function);
|
||||
extern void icsd_acoustic_detector_set_infmt(struct icsd_acoustic_detector_infmt *fmt);
|
||||
extern void icsd_acoustic_detector_infmt_updata(struct icsd_acoustic_detector_infmt *fmt);
|
||||
extern void icsd_acoustic_detector_open(void);
|
||||
extern void icsd_acoustic_detector_close();
|
||||
extern void icsd_acoustic_detector_resume(u8 mode, u8 anc_onoff);
|
||||
extern void icsd_acoustic_detector_suspend();
|
||||
extern void icsd_acoustic_detector_ancdma_done();//ancdma done回调
|
||||
extern void icsd_acoustic_detector_mic_input_hdl(void *priv, s16 *buf, int len);
|
||||
extern void icsd_adt_set_audio_sample_rate(u16 sample_rate);
|
||||
//LIB调用的ADT函数
|
||||
extern void icsd_adt_FFT_radix256(int *in_cur, int *out);
|
||||
extern void icsd_adt_FFT_radix128(int *in_cur, int *out);
|
||||
extern void icsd_adt_FFT_radix64(int *in_cur, int *out);
|
||||
extern void icsd_adt_anc_dma_on(u8 out_sel, int *buf, int len);
|
||||
extern void icsd_adt_hw_suspend();
|
||||
extern void icsd_adt_hw_resume();
|
||||
extern void icsd_post_adttask_msg(u8 cmd);
|
||||
extern void icsd_post_srctask_msg(u8 cmd);
|
||||
extern void icsd_adt_src_close(void *resample);
|
||||
extern void *icsd_adt_src_init(int in_rate, int out_rate, int (*handler)(void *, void *, int));
|
||||
extern void icsd_adt_src_push(void *resample);
|
||||
extern void icsd_adt_src_write(void *data, int len, void *resample);
|
||||
extern void icsd_adt_run_output(__adt_result *adt_result);
|
||||
extern void icsd_post_anctask_msg(u8 cmd);
|
||||
extern void icsd_adt_voice_board_data();
|
||||
extern void icsd_adt_tx_unsniff_req();
|
||||
extern u32 icsd_adt_get_tws_state();
|
||||
extern u32 icsd_adt_get_role();
|
||||
extern u8 icsd_get_ang_flag(float *_target_angle);
|
||||
//ADT调用的LIB函数
|
||||
extern void icsd_adt_version();
|
||||
extern void icsd_adt_parm_set(__icsd_adt_parm *_ADT_PARM);
|
||||
extern void icsd_adt_szout_set(float *anc_sz_data, float *anc_pz_data, u8 sz_out_exist);
|
||||
extern void icsd_adt_task_handler(int msg);
|
||||
extern void icsd_src_task_handler(int msg);
|
||||
extern void icsd_adt_s2m_packet(s8 *data, u8 cmd);
|
||||
extern void icsd_adt_m2s_packet(s8 *data, u8 cmd);
|
||||
|
||||
extern void icsd_adt_szout_init();
|
||||
extern void icsd_adt_dma_done();
|
||||
extern void icsd_adt_task_create();
|
||||
extern void icsd_adt_task_kill();
|
||||
extern void icsd_src_task_create();
|
||||
extern void icsd_src_task_kill();
|
||||
extern void icsd_adt_m2s_cb(void *_data, u16 len, bool rx);
|
||||
extern void icsd_adt_s2m_cb(void *_data, u16 len, bool rx);
|
||||
|
||||
extern u8 audio_adt_talk_mic_analog_close();
|
||||
extern u8 audio_adt_talk_mic_analog_open();
|
||||
extern u8 talk_mic_analog_close;
|
||||
|
||||
extern u8 oral_function;
|
||||
extern const u8 adt_errpxx_dB_thr;
|
||||
extern const u8 adt_err_zcv_thr;
|
||||
extern const u8 pwr_inside_even_flag0_thr;
|
||||
extern const u8 angle_err_even_flag0_thr;
|
||||
extern const u8 angle_talk_even_flag0_thr;
|
||||
extern const u16 f1f2_angsum_thr;
|
||||
extern const u16 ADT_DEBUG_INF;
|
||||
#endif
|
||||
1955
apps/common/icsd/adt/icsd_adt_app.c
Normal file
1955
apps/common/icsd/adt/icsd_adt_app.c
Normal file
File diff suppressed because it is too large
Load Diff
189
apps/common/icsd/adt/icsd_adt_app.h
Normal file
189
apps/common/icsd/adt/icsd_adt_app.h
Normal file
@ -0,0 +1,189 @@
|
||||
#ifndef __ICSD_ADT_APP_H_
|
||||
#define __ICSD_ADT_APP_H_
|
||||
|
||||
#include "typedef.h"
|
||||
#include "icsd_anc_user.h"
|
||||
// #include "icsd_adt_client_board.h"
|
||||
|
||||
#define SPEAK_TO_CHAT_TASK_NAME "speak_to_chat"
|
||||
|
||||
/*智能免摘检测到声音和退出通透是否播放提示音*/
|
||||
#define SPEAK_TO_CHAT_PLAY_TONE_EN 1
|
||||
|
||||
/*智能免摘每次检测到声音的测试提示音*/
|
||||
#define SPEAK_TO_CHAT_TEST_TONE_EN 0
|
||||
|
||||
/* 通过蓝牙spp发送风噪信息
|
||||
* 需要同时打开USER_SUPPORT_PROFILE_SPP和APP_ONLINE_DEBUG*/
|
||||
#define ICSD_ADT_WIND_INFO_SPP_DEBUG_EN 0
|
||||
|
||||
enum {
|
||||
AUDIO_ADT_CLOSE = 0, //关闭关闭
|
||||
AUDIO_ADT_OPEN, //打开状态
|
||||
AUDIO_ADT_CHAT, //免摘状态
|
||||
};
|
||||
|
||||
enum {
|
||||
ANC_WIND_NOISE_LVL0 = 1,
|
||||
ANC_WIND_NOISE_LVL1,
|
||||
ANC_WIND_NOISE_LVL2,
|
||||
ANC_WIND_NOISE_LVL3,
|
||||
ANC_WIND_NOISE_LVL4,
|
||||
ANC_WIND_NOISE_LVL5,
|
||||
};
|
||||
|
||||
enum {
|
||||
WIND_AREA_TAP_DOUBLE_CLICK = 2, //双击
|
||||
WIND_AREA_TAP_THIRD_CLICK, //三击
|
||||
WIND_AREA_TAP_MULTIPLE_CLICK, //大于3次多次连击
|
||||
};
|
||||
|
||||
enum {
|
||||
ADT_MODE_CLOSE = 0,
|
||||
ADT_SPEAK_TO_CHAT_MODE = BIT(0), //智能免摘
|
||||
ADT_WIND_NOISE_DET_MODE = BIT(1),//风噪检测
|
||||
ADT_WIDE_AREA_TAP_MODE = BIT(2), //广域点击
|
||||
};
|
||||
|
||||
enum {
|
||||
/*任务消息*/
|
||||
ICSD_ADT_VOICE_STATE = 1,
|
||||
ICSD_ADT_WIND_LVL,
|
||||
ICSD_ADT_WAT_RESULT,
|
||||
ICSD_ADT_TONE_PLAY,
|
||||
SPEAK_TO_CHAT_TASK_KILL,
|
||||
ICSD_ANC_MODE_SWITCH,
|
||||
ICSD_ADT_STATE_SYNC,
|
||||
|
||||
/*对耳信息同步*/
|
||||
SYNC_ICSD_ADT_VOICE_STATE,
|
||||
SYNC_ICSD_ADT_WIND_LVL_CMP,
|
||||
SYNC_ICSD_ADT_WAT_RESULT,
|
||||
SYNC_ICSD_ADT_WIND_LVL_RESULT,
|
||||
SYNC_ICSD_ADT_SUSPEND,
|
||||
SYNC_ICSD_ADT_OPEN,
|
||||
SYNC_ICSD_ADT_CLOSE,
|
||||
SYNC_ICSD_ADT_SET_ANC_FADE_GAIN,
|
||||
};
|
||||
|
||||
/*打开智能免摘*/
|
||||
int audio_speak_to_chat_open();
|
||||
|
||||
/*关闭智能免摘*/
|
||||
int audio_speak_to_chat_close();
|
||||
|
||||
void audio_speak_to_chat_demo();
|
||||
|
||||
/*设置免摘定时结束的时间,单位ms*/
|
||||
int audio_speak_to_char_end_time_set(u16 time);
|
||||
|
||||
/*设置智能免摘检测的灵敏度*/
|
||||
int audio_speak_to_chat_sensitivity_set(u8 sensitivity);
|
||||
|
||||
/*获取是否需要先开anc再开免摘的状态*/
|
||||
u8 get_adt_open_in_anc_state();
|
||||
|
||||
void audio_anc_mode_switch_in_adt(u8 anc_mode);
|
||||
|
||||
/*打开声音检测*/
|
||||
int audio_acoustic_detector_open();
|
||||
|
||||
/*关闭声音检测*/
|
||||
int audio_acoustic_detector_close();
|
||||
|
||||
int audio_speak_to_chat_open_in_anc_done();
|
||||
|
||||
void audio_icsd_adt_resume();
|
||||
void audio_icsd_adt_suspend();
|
||||
/*char 定时结束后从通透同步恢复anc on /anc off*/
|
||||
void audio_speak_to_char_suspend(void);
|
||||
void audio_speak_to_char_sync_suspend(void);
|
||||
|
||||
/*获取智能免摘是否打开*/
|
||||
u8 audio_speak_to_chat_is_running();
|
||||
|
||||
/*获取智能免摘状态*/
|
||||
u8 get_speak_to_chat_state();
|
||||
|
||||
/*获取adt的模式*/
|
||||
u8 get_icsd_adt_mode();
|
||||
|
||||
/*同步tws配对时,同步adt的状态*/
|
||||
void audio_anc_icsd_adt_state_sync(u8 *data);
|
||||
void audio_icsd_adt_state_sync_done(u8 adt_mode, u8 speak_to_chat_state);
|
||||
|
||||
/*检测到讲话状态同步*/
|
||||
void set_speak_to_chat_voice_state(u8 state);
|
||||
void audio_speak_to_chat_voice_state_sync(void);
|
||||
|
||||
int anc_adt_init();
|
||||
|
||||
int audio_icsd_adt_open(u8 adt_mode);
|
||||
int audio_icsd_adt_sync_open(u8 adt_mode);
|
||||
/*打开所有模块*/
|
||||
int audio_icsd_adt_open_all();
|
||||
|
||||
int audio_icsd_adt_sync_close(u8 adt_mode);
|
||||
int audio_icsd_adt_close(u8 adt_mode);
|
||||
int audio_icsd_adt_res_close(u8 adt_mode);
|
||||
/*关闭所有模块*/
|
||||
int audio_icsd_adt_close_all();
|
||||
|
||||
u8 audio_icsd_adt_is_running();
|
||||
|
||||
/*打开广域点击*/
|
||||
int audio_wat_click_open();
|
||||
|
||||
/*关闭广域点击*/
|
||||
int audio_wat_click_close();
|
||||
|
||||
/*设置是否忽略广域点击
|
||||
* ingore: 1 忽略点击,0 响应点击
|
||||
* 忽略点击的时间,单位ms*/
|
||||
int audio_wide_area_tap_ignore_flag_set(u8 ignore, u16 time);
|
||||
|
||||
/*广域点击开关demo*/
|
||||
void audio_wat_click_demo();
|
||||
|
||||
/*广域点击事件处理*/
|
||||
void audio_wat_area_tap_event_handle(u8 wat_result);
|
||||
|
||||
/*打开风噪检测*/
|
||||
int audio_icsd_wind_detect_open();
|
||||
|
||||
/*关闭风噪检测*/
|
||||
int audio_icsd_wind_detect_close();
|
||||
|
||||
/*获取风噪等级*/
|
||||
u8 get_audio_icsd_wind_lvl();
|
||||
|
||||
/*风噪检测开关demo*/
|
||||
void audio_icsd_wind_detect_demo();
|
||||
|
||||
/*风噪检测处理*/
|
||||
void audio_anc_wind_noise_process(u8 wind_lvl);
|
||||
|
||||
/*参数更新接口*/
|
||||
int audio_acoustic_detector_updata();
|
||||
void set_icsd_adt_param_updata();
|
||||
|
||||
/*获取免摘需要多少个mic*/
|
||||
u8 get_icsd_adt_mic_num();
|
||||
|
||||
extern void set_anc_adt_state(u8 state);
|
||||
extern void *get_anc_lfb_coeff();
|
||||
extern void *get_anc_lff_coeff();
|
||||
extern void *get_anc_ltrans_coeff();
|
||||
extern void *get_anc_ltrans_fb_coeff();
|
||||
extern float get_anc_gains_l_fbgain();
|
||||
extern float get_anc_gains_l_ffgain();
|
||||
extern float get_anc_gains_l_transgain();
|
||||
extern float get_anc_gains_lfb_transgain();
|
||||
extern u8 get_anc_l_fbyorder();
|
||||
extern u8 get_anc_l_ffyorder();
|
||||
extern u8 get_anc_l_transyorder();
|
||||
extern u8 get_anc_lfb_transyorder();
|
||||
extern u32 get_anc_gains_alogm();
|
||||
extern u32 get_anc_gains_trans_alogm();
|
||||
|
||||
#endif
|
||||
296
apps/common/icsd/adt/icsd_adt_client_board.c
Normal file
296
apps/common/icsd/adt/icsd_adt_client_board.c
Normal file
@ -0,0 +1,296 @@
|
||||
#if ADT_CLIENT_BOARD == HT03_HYBRID_6G
|
||||
const u8 ADT_TWS_MODE = 1;
|
||||
//const u8 ADT_DET_VER = 2;
|
||||
//const u8 ADT_PATH_CONFIG = 0;
|
||||
const u8 ADT_DET_VER = 4;
|
||||
const u8 ADT_PATH_CONFIG = ADT_PATH_DAC_SRC_EN;
|
||||
const u8 ADT_EIN_VER = ADT_EIN_TWS_V0;
|
||||
const float ref_gain_sel = 3;
|
||||
const float err_gain_sel = 3;
|
||||
u8 pnc_ref_pwr_thr = 160;
|
||||
u8 pnc_err_pwr_thr = 100;
|
||||
u8 tpc_ref_pwr_thr = 120;
|
||||
u8 tpc_err_pwr_thr = 100;
|
||||
u8 anc_ref_pwr_thr = 120;
|
||||
u8 anc_err_pwr_thr = 100;
|
||||
const float wat_pn_gain = 1;
|
||||
const float wat_bypass_gain = 16;
|
||||
const float wat_anc_gain = 1;
|
||||
const u8 final_speech_even_thr = 4;
|
||||
const float wdac_senc = 1;
|
||||
const float wdac[8] = {1, 1, 0.92, 0.80, 0.67, 0.62, 0.7, 0.7};//播放一笑江湖DJ /100
|
||||
const float wref[8] = {6.78, 3.66, 0.58, 0.37, 0.31, 0.29, 0.28, 0.27};//播放外部噪声
|
||||
const float wref_tran[8] = {1.26, 1.06, 1.06, 1.00, 1.00, 1.18, 1.16, 1.03 };
|
||||
const float wref_ancs[8] = {2.06, 2.00, 0.011, 0.006, 0.009, 0.012, 0.014, 0.018 };
|
||||
const float fdac[8] = {0.18, 0.051, 0.02, 0.02, 0.02, 0.02, 0.02, 0.05};//播放一笑江湖DJ /1000
|
||||
u8 icsd_get_ang_flag(float *_target_angle)
|
||||
{
|
||||
u8 af1 = _target_angle[1] > 15 || _target_angle[1] < -130;
|
||||
u8 af2 = _target_angle[2] > 15 || _target_angle[2] < -130;
|
||||
u8 af3 = _target_angle[3] > 15 || _target_angle[3] < -130;
|
||||
u8 ang_flag = af1 && af2 && af3;
|
||||
return ang_flag;
|
||||
}
|
||||
|
||||
#elif ADT_CLIENT_BOARD == G96_HYBRID
|
||||
const u8 ADT_TWS_MODE = 1;
|
||||
//const u8 ADT_DET_VER = 5;
|
||||
//const u8 ADT_PATH_CONFIG = 0;
|
||||
const u8 ADT_DET_VER = 4;
|
||||
const u8 ADT_PATH_CONFIG = ADT_PATH_DAC_SRC_EN;
|
||||
const u8 ADT_EIN_VER = ADT_EIN_TWS_V0;
|
||||
const float ref_gain_sel = 4;
|
||||
const float err_gain_sel = 1;
|
||||
u8 pnc_ref_pwr_thr = 160;
|
||||
u8 pnc_err_pwr_thr = 100;
|
||||
u8 tpc_ref_pwr_thr = 120;
|
||||
u8 tpc_err_pwr_thr = 100;
|
||||
u8 anc_ref_pwr_thr = 120;
|
||||
u8 anc_err_pwr_thr = 135;
|
||||
const float wat_pn_gain = 2.4;
|
||||
const float wat_bypass_gain = 16;
|
||||
const float wat_anc_gain = 2.5;
|
||||
const u8 final_speech_even_thr = 4;
|
||||
const float wdac_senc = 1;
|
||||
const float wdac[8] = {2.98, 2.29, 1.94, 1.95, 1.76, 1.54, 1.44, 1.29};
|
||||
const float wref[8] = {6.76, 1.98, 1.57, 1.50, 1.41, 1.32, 1.16, 1.02};
|
||||
const float wref_tran[8] = {4.26, 2.36, 2.36, 2.79, 3.00, 3.18, 3.16, 3.03 };
|
||||
const float wref_ancs[8] = {2.06, 2.00, 0.11, 0.06, 0.09, 0.12, 0.14, 0.18 };
|
||||
const float fdac[8] = {0.008, 0.008, 0.008, 0.008, 0.01, 0.01, 0.01, 0.01};
|
||||
u8 icsd_get_ang_flag(float *_target_angle)
|
||||
{
|
||||
u8 af1 = _target_angle[4] < 15 && _target_angle[4] > -150;
|
||||
u8 af2 = _target_angle[2] < 15 && _target_angle[2] > -150;
|
||||
u8 af3 = _target_angle[3] < 15 && _target_angle[3] > -150;
|
||||
u8 ang_flag = af1 && af2 && af3;
|
||||
return ang_flag;
|
||||
}
|
||||
|
||||
#elif ADT_CLIENT_BOARD == G97_HYBRID
|
||||
const u8 ADT_TWS_MODE = 1;
|
||||
const u8 ADT_DET_VER = 3;
|
||||
const u8 ADT_PATH_CONFIG = 0;
|
||||
//const u8 ADT_DET_VER = 4;
|
||||
//const u8 ADT_PATH_CONFIG = ADT_PATH_DAC_SRC_EN;
|
||||
const u8 ADT_EIN_VER = ADT_EIN_UNSUPPORT;
|
||||
const float ref_gain_sel = 2;
|
||||
const float err_gain_sel = 1;
|
||||
u8 pnc_ref_pwr_thr = 160;
|
||||
u8 pnc_err_pwr_thr = 100;
|
||||
u8 tpc_ref_pwr_thr = 120;
|
||||
u8 tpc_err_pwr_thr = 100;
|
||||
u8 anc_ref_pwr_thr = 120;
|
||||
u8 anc_err_pwr_thr = 135;
|
||||
const float wat_pn_gain = 2.88;
|
||||
const float wat_bypass_gain = 19.2;
|
||||
const float wat_anc_gain = 3;
|
||||
const u8 final_speech_even_thr = 4;
|
||||
const float wdac_senc = 1;
|
||||
const float wdac[8] = {10.43, 4.85, 1.36, 1.09, 0.87, 0.71, 0.63, 0.59};
|
||||
const float wref[8] = {7.31, 1.90, 0.43, 0.33, 0.28, 0.25, 0.22, 0.20};
|
||||
const float wref_tran[8] = {8.23, 3.33, 1.72, 1.64, 1.48, 1.30, 1.12, 1.04};
|
||||
const float wref_ancs[8] = {4.62, 1.32, 0.09, 0.06, 0.07, 0.10, 0.13, 0.15 };
|
||||
const float fdac[8] = {0.18, 0.051, 0.02, 0.02, 0.02, 0.02, 0.02, 0.05};
|
||||
u8 icsd_get_ang_flag(float *_target_angle)
|
||||
{
|
||||
u8 af1 = _target_angle[1] < -120 || _target_angle[1] > 20;
|
||||
u8 af2 = _target_angle[2] < -120 || _target_angle[2] > 20;
|
||||
u8 af3 = _target_angle[3] < -120 || _target_angle[3] > 20;
|
||||
u8 ang_flag = af1 && af2 && af3;
|
||||
|
||||
printf("ang:%d %d %d af:%d %d %d\n", (int)_target_angle[1], (int)_target_angle[2], (int)_target_angle[3], af1, af2, af3);
|
||||
return ang_flag;
|
||||
}
|
||||
|
||||
#elif ADT_CLIENT_BOARD == H3_HYBRID
|
||||
const u8 ADT_TWS_MODE = 0;
|
||||
const u8 ADT_DET_VER = 1;
|
||||
const u8 ADT_PATH_CONFIG = 0;
|
||||
const u8 ADT_EIN_VER = ADT_EIN_HEADSET_V0;
|
||||
const float ref_gain_sel = 3;
|
||||
const float err_gain_sel = 3;
|
||||
u8 pnc_ref_pwr_thr = 160;
|
||||
u8 pnc_err_pwr_thr = 100;
|
||||
u8 tpc_ref_pwr_thr = 120;
|
||||
u8 tpc_err_pwr_thr = 100;
|
||||
u8 anc_ref_pwr_thr = 120;
|
||||
u8 anc_err_pwr_thr = 135;
|
||||
const float wat_pn_gain = 1;
|
||||
const float wat_bypass_gain = 16;
|
||||
const float wat_anc_gain = 1;
|
||||
const u8 final_speech_even_thr = 4;
|
||||
const float wdac_senc = 1;
|
||||
const float wref[8] = {6.78, 3.66, 0.58, 0.37, 0.31, 0.29, 0.28, 0.27};
|
||||
const float wdac[8] = {1, 1, 0.92, 0.80, 0.67, 0.62, 0.7, 0.7};
|
||||
const float wref_tran[8] = {4.26, 2.36, 2.36, 2.79, 3.00, 3.18, 3.16, 3.03 };
|
||||
const float wref_ancs[8] = {2.06, 2.00, 0.011, 0.006, 0.009, 0.012, 0.014, 0.018 };
|
||||
const float fdac[8] = {0.18, 0.051, 0.02, 0.02, 0.02, 0.02, 0.02, 0.05};
|
||||
|
||||
#elif ADT_CLIENT_BOARD == ANC05_HYBRID
|
||||
const u8 ADT_TWS_MODE = 0;
|
||||
const u8 ADT_DET_VER = 1;
|
||||
const u8 ADT_PATH_CONFIG = 0;
|
||||
const u8 ADT_EIN_VER = ADT_EIN_UNSUPPORT;
|
||||
const float ref_gain_sel = 3;
|
||||
const float err_gain_sel = 3;
|
||||
u8 pnc_ref_pwr_thr = 160;
|
||||
u8 pnc_err_pwr_thr = 100;
|
||||
u8 tpc_ref_pwr_thr = 120;
|
||||
u8 tpc_err_pwr_thr = 100;
|
||||
u8 anc_ref_pwr_thr = 120;
|
||||
u8 anc_err_pwr_thr = 135;
|
||||
const float wat_pn_gain = 1;
|
||||
const float wat_bypass_gain = 16;
|
||||
const float wat_anc_gain = 1;
|
||||
const u8 final_speech_even_thr = 4;
|
||||
const float wdac_senc = 1;
|
||||
const float wref[8] = {6.78, 3.66, 0.58, 0.37, 0.31, 0.29, 0.28, 0.27};
|
||||
const float wdac[8] = {1, 1, 0.92, 0.80, 0.67, 0.62, 0.7, 0.7};
|
||||
const float wref_tran[8] = {4.26, 2.36, 2.36, 2.79, 3.00, 3.18, 3.16, 3.03 };
|
||||
const float wref_ancs[8] = {2.06, 2.00, 0.011, 0.006, 0.009, 0.012, 0.014, 0.018 };
|
||||
const float fdac[8] = {0.18, 0.051, 0.02, 0.02, 0.02, 0.02, 0.02, 0.05};
|
||||
|
||||
#else
|
||||
const float wdac_senc = 1;
|
||||
const u8 ADT_TWS_MODE = 1;
|
||||
const u8 ADT_DET_VER = 0;
|
||||
const u8 ADT_PATH_CONFIG = 0;
|
||||
const u8 ADT_EIN_VER = ADT_EIN_UNSUPPORT;
|
||||
const float ref_gain_sel = 3;
|
||||
const float err_gain_sel = 3;
|
||||
u8 pnc_ref_pwr_thr = 160;
|
||||
u8 pnc_err_pwr_thr = 100;
|
||||
u8 tpc_ref_pwr_thr = 120;
|
||||
u8 tpc_err_pwr_thr = 100;
|
||||
u8 anc_ref_pwr_thr = 120;
|
||||
u8 anc_err_pwr_thr = 135;
|
||||
const float wat_pn_gain = 1;
|
||||
const float wat_bypass_gain = 16;
|
||||
const float wat_anc_gain = 1;
|
||||
const u8 final_speech_even_thr = 4;
|
||||
const float wref[8] = {6.78, 3.66, 0.58, 0.37, 0.31, 0.29, 0.28, 0.27};
|
||||
const float wdac[8] = {1, 1, 0.92, 0.80, 0.67, 0.62, 0.7, 0.7};
|
||||
const float wref_tran[8] = {4.26, 2.36, 2.36, 2.79, 3.00, 3.18, 3.16, 3.03 };
|
||||
const float wref_ancs[8] = {2.06, 2.00, 0.011, 0.006, 0.009, 0.012, 0.014, 0.018 };
|
||||
const float fdac[8] = {0.18, 0.051, 0.02, 0.02, 0.02, 0.02, 0.02, 0.05};
|
||||
|
||||
#endif
|
||||
|
||||
void icsd_adt_ein_parm_HT03(__icsd_adt_parm *_ADT_PARM)
|
||||
{
|
||||
_ADT_PARM->anc_in_pz_sum = -80;
|
||||
_ADT_PARM->anc_out_pz_sum = 0;
|
||||
_ADT_PARM->anc_in_sz_mean = 1;
|
||||
_ADT_PARM->anc_out_sz_mean = -12;
|
||||
_ADT_PARM->anc_in_fb_sum = 60;
|
||||
_ADT_PARM->anc_out_fb_sum = 30;
|
||||
|
||||
_ADT_PARM->pnc_in_pz_sum = -80;
|
||||
_ADT_PARM->pnc_out_pz_sum = 0;
|
||||
_ADT_PARM->pnc_in_sz_mean = 1;
|
||||
_ADT_PARM->pnc_out_sz_mean = -12;
|
||||
_ADT_PARM->pnc_in_fb_sum = 60;
|
||||
_ADT_PARM->pnc_out_fb_sum = 30;
|
||||
|
||||
_ADT_PARM->trans_in_pz_sum = 2;
|
||||
_ADT_PARM->trans_out_pz_sum = 26;
|
||||
_ADT_PARM->trans_in_sz_mean = 2;
|
||||
_ADT_PARM->trans_out_sz_mean = -7;
|
||||
_ADT_PARM->trans_in_fb_sum = 20;
|
||||
_ADT_PARM->trans_out_fb_sum = -20;
|
||||
}
|
||||
|
||||
void icsd_adt_ein_parm(__icsd_adt_parm *_ADT_PARM)
|
||||
{
|
||||
_ADT_PARM->anc_in_pz_sum = -80;
|
||||
_ADT_PARM->anc_out_pz_sum = 0;
|
||||
_ADT_PARM->anc_in_sz_mean = 1;
|
||||
_ADT_PARM->anc_out_sz_mean = -12;
|
||||
_ADT_PARM->anc_in_fb_sum = 60;
|
||||
_ADT_PARM->anc_out_fb_sum = 30;
|
||||
|
||||
_ADT_PARM->pnc_in_pz_sum = -80;
|
||||
_ADT_PARM->pnc_out_pz_sum = 0;
|
||||
_ADT_PARM->pnc_in_sz_mean = 1;
|
||||
_ADT_PARM->pnc_out_sz_mean = -12;
|
||||
_ADT_PARM->pnc_in_fb_sum = 60;
|
||||
_ADT_PARM->pnc_out_fb_sum = 30;
|
||||
|
||||
_ADT_PARM->trans_in_pz_sum = 2;
|
||||
_ADT_PARM->trans_out_pz_sum = 26;
|
||||
_ADT_PARM->trans_in_sz_mean = 2;
|
||||
_ADT_PARM->trans_out_sz_mean = -7;
|
||||
_ADT_PARM->trans_in_fb_sum = 20;
|
||||
_ADT_PARM->trans_out_fb_sum = -20;
|
||||
}
|
||||
|
||||
void icsd_adt_voice_board_data()
|
||||
{
|
||||
__icsd_adt_parm *ADT_PARM;
|
||||
|
||||
ADT_PARM = zalloc(sizeof(__icsd_adt_parm));
|
||||
#if ADT_CLIENT_BOARD == HT03_HYBRID_6G
|
||||
adt_printf("ADT HT03\n");
|
||||
extern const float HT03_ADT_FLOAT_DATA[];
|
||||
extern const float HT03_sz_out_data[28];
|
||||
extern const float HT03_pz_out_data[28];
|
||||
ADT_PARM->adt_float_data = (void *)HT03_ADT_FLOAT_DATA;
|
||||
ADT_PARM->sz_inptr = (float *)HT03_sz_out_data;
|
||||
ADT_PARM->pz_inptr = (float *)HT03_pz_out_data;
|
||||
icsd_adt_ein_parm_HT03(ADT_PARM);
|
||||
|
||||
#elif ADT_CLIENT_BOARD == G96_HYBRID
|
||||
adt_printf("ADT G96\n");
|
||||
extern const float G96_ADT_FLOAT_DATA[];
|
||||
extern const float G96_sz_out_data[28];
|
||||
extern const float G96_pz_out_data[28];
|
||||
ADT_PARM->adt_float_data = (void *)G96_ADT_FLOAT_DATA;
|
||||
ADT_PARM->sz_inptr = (float *)G96_sz_out_data;
|
||||
ADT_PARM->pz_inptr = (float *)G96_pz_out_data;
|
||||
icsd_adt_ein_parm(ADT_PARM);
|
||||
|
||||
#elif ADT_CLIENT_BOARD == G97_HYBRID
|
||||
adt_printf("ADT G97\n");
|
||||
extern const float G97_ADT_FLOAT_DATA[];
|
||||
extern const float G97_sz_out_data[28];
|
||||
extern const float G97_pz_out_data[28];
|
||||
ADT_PARM->adt_float_data = (void *)G97_ADT_FLOAT_DATA;
|
||||
ADT_PARM->sz_inptr = (float *)G97_sz_out_data;
|
||||
ADT_PARM->pz_inptr = (float *)G97_pz_out_data;
|
||||
icsd_adt_ein_parm(ADT_PARM);
|
||||
|
||||
#elif ADT_CLIENT_BOARD == H3_HYBRID
|
||||
adt_printf("ADT H3\n");
|
||||
extern const float H3_ADT_FLOAT_DATA[];
|
||||
extern const float H3_sz_out_data[28];
|
||||
extern const float H3_pz_out_data[28];
|
||||
ADT_PARM->adt_float_data = (void *)H3_ADT_FLOAT_DATA;
|
||||
ADT_PARM->sz_inptr = (float *)H3_sz_out_data;
|
||||
ADT_PARM->pz_inptr = (float *)H3_pz_out_data;
|
||||
icsd_adt_ein_parm(ADT_PARM);
|
||||
|
||||
#elif ADT_CLIENT_BOARD == ANC05_HYBRID
|
||||
adt_printf("ADT ANC05\n");
|
||||
extern const float ANC05_ADT_FLOAT_DATA[];
|
||||
extern const float ANC05_sz_out_data[28];
|
||||
extern const float ANC05_pz_out_data[28];
|
||||
ADT_PARM->adt_float_data = (void *)ANC05_ADT_FLOAT_DATA;
|
||||
ADT_PARM->sz_inptr = (float *)ANC05_sz_out_data;
|
||||
ADT_PARM->pz_inptr = (float *)ANC05_pz_out_data;
|
||||
icsd_adt_ein_parm(ADT_PARM);
|
||||
|
||||
#else
|
||||
adt_printf("ADT XXX\n");
|
||||
#endif
|
||||
|
||||
icsd_adt_parm_set(ADT_PARM);
|
||||
free(ADT_PARM);
|
||||
|
||||
icsd_adt_szout_init();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user