first
This commit is contained in:
24
include_lib/media/AudioEffect_DataType.h
Normal file
24
include_lib/media/AudioEffect_DataType.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef _AUDIOEFFECT_DATATYPE_
|
||||
#define _AUDIOEFFECT_DATATYPE_
|
||||
|
||||
enum PCMDataType {
|
||||
DATA_INT_16BIT = 0,
|
||||
DATA_INT_32BIT,
|
||||
DATA_FLOAT_32BIT
|
||||
};
|
||||
|
||||
enum {
|
||||
af_DATABIT_NOTSUPPORT = 0x404,
|
||||
};
|
||||
|
||||
|
||||
typedef struct _af_DataType_ {
|
||||
unsigned char IndataBit;
|
||||
unsigned char OutdataBit;
|
||||
char IndataInc;
|
||||
char OutdataInc;
|
||||
char Qval;
|
||||
} af_DataType;
|
||||
|
||||
#endif // !_AUDIOEFFECT_DATATYPE_
|
||||
|
||||
39
include_lib/media/VirtualBass_api.h
Normal file
39
include_lib/media/VirtualBass_api.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef VIRTUALBASS_API_H
|
||||
#define VIRTUALBASS_API_H
|
||||
|
||||
#include "AudioEffect_DataType.h"
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#define AT_VBSS(x)
|
||||
#define AT_VBSS_CODE
|
||||
#define AT_VBSS_CONST
|
||||
#define AT_VBSS_SPARSE_CODE
|
||||
#define AT_VBSS_SPARSE_CONST
|
||||
|
||||
#else
|
||||
#define AT_VBSS(x) __attribute((section(#x)))
|
||||
#define AT_VBSS_CODE AT_VBSS(.vbss_code)
|
||||
#define AT_VBSS_CONST AT_VBSS(.vbss_const)
|
||||
#define AT_VBSS_SPARSE_CODE AT_VBSS(.vbss_sparse_code)
|
||||
#define AT_VBSS_SPARSE_CONST AT_VBSS(.vbss_sparse_const)
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct _VirtualBassParam {
|
||||
int ratio;
|
||||
int boost;
|
||||
int fc;
|
||||
int channel;
|
||||
int SampleRate;
|
||||
af_DataType pcm_info;
|
||||
} VirtualBassParam;
|
||||
|
||||
int getVirtualBassBuf();
|
||||
int VirtualBassInit(void *WorkBuf, VirtualBassParam *param);
|
||||
int VirtualBassReserveLowFreq(void *WorkBuf, VirtualBassParam *param, int ReserveLowFreqEnable);
|
||||
void VirtualBassUpdate(void *WorkBuf, VirtualBassParam *param);
|
||||
int VirtualBassRun(void *WorkBuf, int *tmpbuf, void *in, void *out, int per_channel_npoint);
|
||||
|
||||
#endif // !VIRTUALBASS_API_H
|
||||
|
||||
17
include_lib/media/a2dp_sample_detect.h
Normal file
17
include_lib/media/a2dp_sample_detect.h
Normal file
@ -0,0 +1,17 @@
|
||||
/*****************************************************************
|
||||
>file name : a2dp_sample_detect.h
|
||||
>create time : Mon 23 Jul 2021 11:26:34 AM CST
|
||||
*****************************************************************/
|
||||
#ifndef _A2DP_SAMPLE_DETECT_H_
|
||||
#define _A2DP_SAMPLE_DETECT_H_
|
||||
#include "typedef.h"
|
||||
#include "audio_base.h"
|
||||
|
||||
void *a2dp_sample_detect_open(int sample_rate, u32 coding_type);
|
||||
|
||||
int a2dp_frame_sample_detect_start(void *hdl, u32 time);
|
||||
|
||||
int a2dp_frame_sample_detect(void *hdl, void *data, int len, u32 time);
|
||||
|
||||
void a2dp_sample_detect_close(void *hdl);
|
||||
#endif
|
||||
18
include_lib/media/aispeech/asr/include/vad_asr_demo.h
Normal file
18
include_lib/media/aispeech/asr/include/vad_asr_demo.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef _AISPEECH_VAD_ASR_DEMO_H
|
||||
#define _AISPEECH_VAD_ASR_DEMO_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void *aispeech_vad_asr_init(void);
|
||||
void aispeech_vad_asr_deinit(void);
|
||||
int aispeech_vad_asr_feed(char *data, int data_len);
|
||||
|
||||
typedef int (*asr_output_handler)(int status, const char *json, int bytes);
|
||||
void aispeech_asr_register_handler(asr_output_handler func);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // _AISPEECH_VAD_ASR_MANAGER_H
|
||||
17
include_lib/media/aispeech/enc/include/aispeech_enc.h
Normal file
17
include_lib/media/aispeech/enc/include/aispeech_enc.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef _AISPEECH_NR_H_
|
||||
#define _AISPEECH_NR_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int Aispeech_NR_getmemsize(short sample_rate);
|
||||
int Aispeech_NR_init(char *pcMemPool, unsigned int memPoolLen, short sample_rate);
|
||||
int Aispeech_NR_run(short *mic0, short *mic1, short *mic2, short *ref, short *out, short points);
|
||||
int Aispeech_NR_deinit(void);
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
67
include_lib/media/audio_def.h
Normal file
67
include_lib/media/audio_def.h
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
*******************************************************************
|
||||
* Audio Common Definitions
|
||||
*
|
||||
*Note(s):
|
||||
* (1)Only macro definitions can be defined here.
|
||||
* (2)Use (1UL << (n)) instead of BIT(n)
|
||||
*******************************************************************
|
||||
*/
|
||||
#ifndef _AUDIO_DEF_H_
|
||||
#define _AUDIO_DEF_H_
|
||||
|
||||
/*
|
||||
*******************************************************************
|
||||
* DAC Definitions
|
||||
*******************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
*******************************************************************
|
||||
* ADC Definitions
|
||||
*******************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************
|
||||
* Linein(Aux) Definitions
|
||||
*******************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
*******************************************************************
|
||||
* ANC Definitions
|
||||
*******************************************************************
|
||||
*/
|
||||
//ANC Mode Enable
|
||||
#define ANC_FF_EN (1UL << (0))
|
||||
#define ANC_FB_EN (1UL << (1))
|
||||
#define ANC_HYBRID_EN (1UL << (2))
|
||||
|
||||
//ANC芯片版本定义
|
||||
#define ANC_VERSION_BR30 0x01 //AD697N/AC897N
|
||||
#define ANC_VERSION_BR30C 0x02 //AC699N/AD698N
|
||||
#define ANC_VERSION_BR36 0x03 //AC700N
|
||||
#define ANC_VERSION_BR28 0x04 //AC701N/BR40
|
||||
//多滤波器版本
|
||||
#define ANC_VERSION_BR28_MULT 0xA4 //AC701N 支持多滤波器
|
||||
|
||||
/*
|
||||
*******************************************************************
|
||||
* PCM Output Definitions
|
||||
*******************************************************************
|
||||
*/
|
||||
#define AUDIO_WAY_TYPE_DAC (1UL << (0))
|
||||
#define AUDIO_WAY_TYPE_IIS (1UL << (1))
|
||||
#define AUDIO_WAY_TYPE_FM (1UL << (2))
|
||||
#define AUDIO_WAY_TYPE_HDMI (1UL << (3))
|
||||
#define AUDIO_WAY_TYPE_SPDIF (1UL << (4))
|
||||
#define AUDIO_WAY_TYPE_BT (1UL << (5))
|
||||
#define AUDIO_WAY_TYPE_DONGLE (1UL << (6))
|
||||
|
||||
#define AUDIO_WAY_TYPE_MAX 7
|
||||
#define AUDIO_WAY_TYPE_ALL 0x00ffffff
|
||||
|
||||
#endif/*_AUDIO_DEF_H_*/
|
||||
164
include_lib/media/audio_drc.h
Normal file
164
include_lib/media/audio_drc.h
Normal file
@ -0,0 +1,164 @@
|
||||
#ifndef CONFIG_EFFECT_CORE_V2_ENABLE
|
||||
#include "application/audio_drc.h"
|
||||
#else
|
||||
|
||||
#ifndef _DRC_API_H_
|
||||
#define _DRC_API_H_
|
||||
|
||||
#include "typedef.h"
|
||||
#include "media/sw_drc.h"
|
||||
#include "media/audio_stream.h"
|
||||
#include "system/init.h"
|
||||
|
||||
#define CROSSOVER_EN BIT(0) //多带分频器使能
|
||||
#define MORE_BAND_EN BIT(1) //多带分频后,再做一次全带处理使能
|
||||
struct audio_drc_filter_info {
|
||||
CrossOverParam_TOOL_SET *crossover;
|
||||
wdrc_struct_TOOL_SET *wdrc;
|
||||
// struct drc_ch *pch; //左声道系数
|
||||
// struct drc_ch *R_pch; //右声道系数
|
||||
};
|
||||
|
||||
typedef int (*audio_drc_filter_cb)(void *drc, struct audio_drc_filter_info *info);
|
||||
|
||||
struct audio_drc_param {
|
||||
u32 channels : 8; //通道数 (channels|(L_wdrc))或(channels|(R_wdrc))
|
||||
u32 online_en : 1; //是否支持在线调试
|
||||
u32 remain_en : 1; //写1
|
||||
u32 stero_div : 1; //是否左右声道 拆分的 drc效果,一般写0
|
||||
u32 reserved : 21;
|
||||
audio_drc_filter_cb cb; //系数更新的回调函数,用户赋值
|
||||
u32 sr; //数据采样率
|
||||
u8 drc_name; //在线调试是,根据drc_name区分更新系数,一般写0
|
||||
u8 out_32bit; //是否支持32bit 的输入数据处理 1:使能 0:不使能
|
||||
u8 nband; //多带之后,再使能一次 全带处理
|
||||
CrossOverParam_TOOL_SET *crossover;
|
||||
wdrc_struct_TOOL_SET *wdrc;//[0]low [1]mid [2]high [3]whole
|
||||
// struct drc_ch *parm; //系数输入
|
||||
};
|
||||
|
||||
struct audio_drc {
|
||||
CrossOverParam_TOOL_SET *crossover_inside;//
|
||||
wdrc_struct_TOOL_SET *wdrc_inside;
|
||||
// struct drc_ch sw_drc[2]; //软件drc 系数地址
|
||||
// struct drc_ch *drc_param; //在线调试暂存软件drc系数地址,由外部赋值
|
||||
CrossOverParam_TOOL_SET *crossover;//
|
||||
wdrc_struct_TOOL_SET *wdrc;
|
||||
|
||||
u32 sr; //采样率
|
||||
u32 channels : 8; //通道数(channels|(L_wdrc))或(channels|(R_wdrc))
|
||||
u32 remain_flag : 1; //输出数据支持remain
|
||||
u32 updata : 1; //系数更标志
|
||||
u32 online_en : 1; //是否支持在线更新系数
|
||||
u32 remain_en : 1; //是否支持remain输出
|
||||
u32 start : 1; //无效
|
||||
u32 run32bit : 8; //是否使能32bit位宽数据处理1:使能 0:不使能
|
||||
u32 need_restart : 1; //是否需要重更新系数 1:是 0:否
|
||||
u32 stero_div : 1; //是否左右声道拆分的drc效果,1:是 0:否
|
||||
u8 other_band;
|
||||
audio_drc_filter_cb cb; //系数更新回调
|
||||
void *hdl; //软件drc句柄
|
||||
void *output_priv; //输出回调私有指针
|
||||
int (*output)(void *priv, void *data, u32 len);//输出回调函数
|
||||
u32 drc_name; //drc标识
|
||||
struct list_head hentry; //
|
||||
u8 *file_path; //离线效果文件路径
|
||||
|
||||
|
||||
struct audio_stream_entry entry; // 音频流入口
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief drc打开
|
||||
@param drc:句柄
|
||||
@param param:drc打开传入参数
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_drc_open(struct audio_drc *drc, struct audio_drc_param *param);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief drc设置输出数据回调
|
||||
@param drc:句柄
|
||||
@param *output:输出回调
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_drc_set_output_handle(struct audio_drc *drc, int (*output)(void *priv, void *data, u32 len), void *output_priv);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief drc设置采样率
|
||||
@param drc:句柄
|
||||
@param sr:采样率
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_drc_set_samplerate(struct audio_drc *drc, int sr);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief drc设置是否处理32bit输入数据
|
||||
@param drc:句柄
|
||||
@param run_32bit:1:32bit 0:16bit
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_drc_set_32bit_mode(struct audio_drc *drc, u8 run_32bit);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief drc启动
|
||||
@param drc:句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_drc_start(struct audio_drc *drc);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief drc数据处理
|
||||
@param drc:句柄
|
||||
@param *data:输入数据地址
|
||||
@param len:输入数据长度
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_drc_run(struct audio_drc *drc, s16 *data, u32 len);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief drc关闭
|
||||
@param drc:句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_drc_close(struct audio_drc *drc);
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief audio_drc_open重新封装,简化使用,该接口不接入audio_stream流处理
|
||||
@param *parm: drc参数句柄,参数详见结构体struct audio_drc_param
|
||||
@return eq句柄
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
struct audio_drc *audio_dec_drc_open(struct audio_drc_param *parm);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief audio_drc_close重新封装,简化使用,该接口不接入audio_stream流处理
|
||||
@param drc句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_dec_drc_close(struct audio_drc *drc);
|
||||
|
||||
|
||||
int audio_dec_drc_run(struct audio_drc *drc, s16 *data, u32 len);
|
||||
void cur_crossover_set_update(u32 drc_name, CrossOverParam_TOOL_SET *crossover_parm);
|
||||
void cur_drc_set_update(u32 drc_name, u8 type, void *wdrc_parm);
|
||||
void cur_drc_set_bypass(u32 drc_name, u8 tar, u8 bypass);
|
||||
void audio_drc_init(void);
|
||||
int drc_get_filter_info(void *_drc, struct audio_drc_filter_info *info);
|
||||
struct audio_drc *get_cur_drc_hdl_by_name(u32 drc_name);
|
||||
#endif
|
||||
|
||||
#endif /*CONFIG_EFFECT_CORE_V2_ENABLE*/
|
||||
315
include_lib/media/audio_eq.h
Normal file
315
include_lib/media/audio_eq.h
Normal file
@ -0,0 +1,315 @@
|
||||
#ifndef CONFIG_EFFECT_CORE_V2_ENABLE
|
||||
#include "application/audio_eq.h"
|
||||
#else
|
||||
|
||||
#ifndef _EQ_API_H_
|
||||
#define _EQ_API_H_
|
||||
|
||||
#include "typedef.h"
|
||||
#include "asm/hw_eq.h"
|
||||
#include "media/audio_stream.h"
|
||||
#include "system/timer.h"
|
||||
#include "system/init.h"
|
||||
|
||||
#define EQ_CHANNEL_MAX 2
|
||||
|
||||
#define EQ_SR_IDX_MAX 9
|
||||
|
||||
#define AUDIO_EQ_HIGH 2
|
||||
#define AUDIO_EQ_BASS 3
|
||||
|
||||
/*eq type*/
|
||||
typedef enum {
|
||||
EQ_MODE_NORMAL = 0,
|
||||
EQ_MODE_ROCK,
|
||||
EQ_MODE_POP,
|
||||
EQ_MODE_CLASSIC,
|
||||
EQ_MODE_JAZZ,
|
||||
EQ_MODE_COUNTRY,
|
||||
EQ_MODE_CUSTOM,//自定义
|
||||
EQ_MODE_MAX,
|
||||
} EQ_MODE;
|
||||
|
||||
/*eq type*/
|
||||
typedef enum {
|
||||
EQ_TYPE_FILE = 0x01,
|
||||
EQ_TYPE_ONLINE,
|
||||
EQ_TYPE_MODE_TAB,
|
||||
} EQ_TYPE;
|
||||
|
||||
#define audio_eq_filter_info eq_coeff_info
|
||||
|
||||
typedef int (*audio_eq_filter_cb)(void *eq, int sr, struct audio_eq_filter_info *info);
|
||||
|
||||
struct eq_parm {
|
||||
u8 in_mode;
|
||||
u8 out_mode;
|
||||
u8 run_mode;
|
||||
u8 data_in_mode;
|
||||
u8 data_out_mode;
|
||||
};
|
||||
struct audio_eq_param {
|
||||
u8 no_wait : 1; //是否使能异步eq, 1:使能 0:不使能
|
||||
u8 max_nsection : 6;//最大的eq段数,根据使用填写,要小于等于EQ_SECTION_MAX
|
||||
u8 nsection : 6; //实际需要的eq段数,需小于等于max_nsection
|
||||
u8 out_32bit : 1; //是否支持32bit eq输出,仅在 no_wait 写1时,out_32bit 才能写1
|
||||
u8 channels : 2; //通道数
|
||||
u8 fade: 1; //系数更新是否需要淡入
|
||||
float fade_step; //淡入步进(0.1f~1.0f)
|
||||
audio_eq_filter_cb cb;//获取eq系数的回调函数
|
||||
u32 eq_name; //eq名字
|
||||
u32 sr; //采样率,更根据当前数据实际采样率填写
|
||||
|
||||
float global_gain;
|
||||
struct eq_seg_info *seg;//
|
||||
float global_gain_r;
|
||||
struct eq_seg_info *seg_r;//
|
||||
void *parm; //struct eq_parm
|
||||
|
||||
|
||||
void *priv; //私有指针
|
||||
int (*output)(void *priv, void *data, u32 len);//异步eq输出回调,节点方式使用时,output 配NULL
|
||||
void (*irq_callback)(void *priv);//总段回调函数,数据流激活
|
||||
};
|
||||
struct audio_eq_fade {
|
||||
u8 nsection;
|
||||
u16 timer;
|
||||
float cur_global_gain;
|
||||
float use_global_gain;
|
||||
float cur_global_gain_r;
|
||||
float use_global_gain_r;
|
||||
struct eq_seg_info *cur_seg;
|
||||
struct eq_seg_info *use_seg;
|
||||
} ;
|
||||
|
||||
struct high_bass {
|
||||
int freq; //频率写0, 内部会用默认125hz 和12khz
|
||||
int gain; //增益范围 -12~12
|
||||
};
|
||||
|
||||
|
||||
#ifdef CONFIG_EQ_SUPPORT_ASYNC
|
||||
struct audio_eq_async {
|
||||
u16 ptr;
|
||||
u16 len;
|
||||
u16 buf_len;
|
||||
u8 clear;
|
||||
u8 out_stu;
|
||||
char *buf;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct audio_eq {
|
||||
void *eq_ch; //硬件eq句柄
|
||||
u8 updata; //系数是否需要更新
|
||||
u8 start; //eq start标识
|
||||
u8 max_nsection; //eq最大段数
|
||||
u8 cur_nsection; //当前eq段数
|
||||
u8 check_hw_running; //检测到硬件正在运行时不等待其完成1:设置检查 0:不检查
|
||||
u8 async_en;
|
||||
u8 out_32bit;
|
||||
u8 ch_num;
|
||||
u32 sr; //采样率
|
||||
u32 eq_name; //eq标识
|
||||
u32 mask[2];
|
||||
float global_gain;
|
||||
float global_gain_r;
|
||||
s16 *eq_out_buf;//同步方式,32bit输出,当out为NULL时,内部申请eq_out_buf
|
||||
int out_buf_size;
|
||||
int eq_out_points;
|
||||
int eq_out_total;
|
||||
struct audio_stream_entry entry; // 音频流入口
|
||||
|
||||
#ifdef CONFIG_EQ_SUPPORT_ASYNC
|
||||
void *run_buf;
|
||||
void *run_out_buf;
|
||||
int run_len;
|
||||
struct audio_eq_async async; //异步eq 输出管理
|
||||
#endif
|
||||
u32 mute_cnt_l; //左声道eq mem清除计数
|
||||
u32 mute_cnt_r; //右声道eq mem清除计数
|
||||
u32 mute_cnt_max; //记录最大点数,超过该点数,清eq mem
|
||||
|
||||
audio_eq_filter_cb cb; //系数回调
|
||||
void *output_priv; //私有指针
|
||||
int (*output)(void *priv, void *data, u32 len); //输出回调
|
||||
|
||||
struct eq_seg_info *eq_seg_tab; //运算前系数表,特殊应用时,可使用
|
||||
struct eq_seg_info *seg; //运算前系数表,由audio_eq_param初始化时指定
|
||||
struct eq_seg_info *seg_r; //运算前系数表,由audio_eq_param初始化时指定
|
||||
int *eq_coeff_tab; //运算后系数表
|
||||
struct list_head hentry; //
|
||||
const char *event_owner; //记录data_handler所处的任务
|
||||
struct audio_eq_fade *fade;
|
||||
float fade_step;
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq模块初始化
|
||||
@param
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_eq_init(void);
|
||||
void audio_eq_init_new(int eq_section_num);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq 打开
|
||||
@param *param: eq参数句柄,参数详见结构体struct audio_eq_param
|
||||
@return eq句柄
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_eq_open(struct audio_eq *eq, struct audio_eq_param *param);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 异步eq设置输出回调
|
||||
@param eq:句柄
|
||||
@param *output:回调函数
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_eq_set_output_handle(struct audio_eq *eq, int (*output)(void *priv, void *data, u32 len), void *output_priv);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 同步eq设置输出buf
|
||||
@param eq:句柄
|
||||
@param *output:回调函数
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_eq_set_output_buf(struct audio_eq *eq, s16 *buf, u32 len);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq设置采样率
|
||||
@param eq:句柄
|
||||
@param sr:采样率
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_eq_set_samplerate(struct audio_eq *eq, int sr);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq设置输入输出通道数
|
||||
@param eq:句柄
|
||||
@param channel:通道数
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_eq_set_channel(struct audio_eq *eq, u8 channel);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 设置检查eq是否正在运行
|
||||
@param eq:句柄
|
||||
@param check_hw_running: 1:设置检查 0:不检查
|
||||
@return
|
||||
@note 检测到硬件正在运行时不等待其完成,直接返回, 仅异步EQ有效
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_eq_set_check_running(struct audio_eq *eq, u8 check_hw_running);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 设置eq信息
|
||||
@param eq:句柄
|
||||
@param channels:设置输入输出通道数
|
||||
@param out_32bit:使能eq输出32bit数据,1:输出32bit数据, 0:输出16bit是数据
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_eq_set_info(struct audio_eq *eq, u8 channels, u8 out_32bit);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 设置eq信息
|
||||
@param eq:句柄
|
||||
@param channels:设置入输出通道数
|
||||
@param in_mode:使能eq输入32bit数据,2:float, 1:输入32bit数据, 0:输入16bit是数据
|
||||
@param out_mode:使能eq输出32bit数据,2:float, 1:输出32bit数据, 0:输出16bit是数据
|
||||
@param run_mode:运行模式,0:normal, 1:mono, 2:stero
|
||||
@param data_in_mode:输入数据存放方式 0:块模式 1:序列模式
|
||||
@param data_out_mode:输入数据存放方式 0:块模式 1:序列模式
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_eq_set_info_new(struct audio_eq *eq, u8 channels, u8 in_mode, u8 out_mode, u8 run_mode, u8 data_in_mode, u8 data_out_mode);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq启动
|
||||
@param eq:句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_eq_start(struct audio_eq *eq);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq的数据处理
|
||||
@param eq:句柄
|
||||
@param *data:输入数据地址
|
||||
@param len:输入数据长度
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_eq_run(struct audio_eq *eq, s16 *data, u32 len);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq关闭
|
||||
@param eq:句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_eq_close(struct audio_eq *eq);
|
||||
|
||||
|
||||
#ifdef CONFIG_EQ_SUPPORT_ASYNC
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 清除异步eq剩余的数据
|
||||
@param eq:句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_eq_async_data_clear(struct audio_eq *eq);
|
||||
#endif
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 获取异步eq剩余的数据
|
||||
@param eq:句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_eq_data_len(struct audio_eq *eq);
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief audio_eq_open重新封装,简化使用,该接口不接入audio_stream流处理
|
||||
@param *parm: eq参数句柄,参数详见结构体struct audio_eq_param
|
||||
@return eq句柄
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
struct audio_eq *audio_dec_eq_open(struct audio_eq_param *parm);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief audio_eq_close重新封装,简化使用,该接口不接入audio_stream流处理
|
||||
@param eq句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_dec_eq_close(struct audio_eq *eq);
|
||||
|
||||
|
||||
int audio_dec_eq_run(struct audio_eq *eq, s16 *data, s16 *out, u16 len);
|
||||
|
||||
|
||||
void cur_eq_set_global_gain(u32 eq_name, float g_Gain);
|
||||
void cur_eq_set_update(u32 eq_name, struct eq_seg_info *seg, u32 nsection, u32 design);
|
||||
|
||||
void cur_eq_right_ch_set_global_gain(u32 eq_name, float g_Gain);
|
||||
void cur_eq_right_ch_set_update(u32 eq_name, struct eq_seg_info *seg, u32 nsection, u32 design);
|
||||
|
||||
int eq_get_filter_info(void *_eq, int sr, struct audio_eq_filter_info *info);
|
||||
struct audio_eq *get_cur_eq_hdl_by_name(u32 eq_name);
|
||||
#endif
|
||||
|
||||
#endif /*CONFIG_EFFECT_CORE_V2_ENABLE*/
|
||||
63
include_lib/media/audio_gain_process.h
Normal file
63
include_lib/media/audio_gain_process.h
Normal file
@ -0,0 +1,63 @@
|
||||
#ifndef __AUDIO_GAIN_PORCESS__H
|
||||
#define __AUDIO_GAIN_PORCESS__H
|
||||
|
||||
#include "media/audio_stream.h"
|
||||
|
||||
#ifndef RUN_NORMAL
|
||||
#define RUN_NORMAL 0
|
||||
#endif
|
||||
|
||||
#ifndef RUN_BYPASS
|
||||
#define RUN_BYPASS 1
|
||||
#endif
|
||||
|
||||
struct aud_gain_parm {
|
||||
float gain;//增加多少dB
|
||||
u8 channel;//通道数
|
||||
u8 indata_inc;//channel ==1 ?1:2;
|
||||
u8 outdata_inc;//channel ==1 ?1:2;
|
||||
u8 bit_wide;//0:16bit 1:32bit
|
||||
u16 gain_name;
|
||||
};
|
||||
struct aud_gain_parm_update {
|
||||
float gain;//增加多少dB powf(10, 界面值gain / 20.0f)
|
||||
};
|
||||
struct aud_gain_process {
|
||||
struct audio_stream_entry entry; // 音频流入口
|
||||
struct list_head hentry; //
|
||||
struct aud_gain_parm parm;
|
||||
u8 status; //内部运行状态机
|
||||
u8 update; //设置参数更新标志
|
||||
};
|
||||
|
||||
|
||||
struct aud_gain_process *audio_gain_process_open(struct aud_gain_parm *parm);
|
||||
void audio_gain_process_run(struct aud_gain_process *hdl, s16 *data, int len);
|
||||
void audio_gain_process_close(struct aud_gain_process *hdl);
|
||||
void audio_gain_process_update(u16 gain_name, struct aud_gain_parm_update *parm);
|
||||
void audio_gain_process_bypass(u16 gain_name, u8 bypass);
|
||||
struct aud_gain_process *get_cur_gain_hdl_by_name(u32 gain_name);
|
||||
|
||||
/*
|
||||
* *in:输入数据地址
|
||||
* *out:输出数据地址
|
||||
* gain:dB值(powf(10, 界面值gain / 20.0f))
|
||||
* channel:输入数据通道数
|
||||
* Indatainc:同个声道相邻两点的差值 channel ==1 ?1:2
|
||||
* OutdataInc:同个声道相邻两点的差值 channel ==1 ?1:2
|
||||
* per_channel_npoint:一个声道的点数
|
||||
* */
|
||||
extern void GainProcess_16Bit(short *in, short *out, float gain, int channel, int IndataInc, int OutdataInc, int per_channel_npoint); //16位宽
|
||||
/*
|
||||
* *in:输入数据地址
|
||||
* *out:输出数据地址
|
||||
* gain:dB值powf(10, 界面值gain / 20.0f)
|
||||
* channel:输入数据通道数
|
||||
* Indatainc:同个声道相邻两点的差值 channel ==1 ?1:2
|
||||
* OutdataInc:同个声道相邻两点的差值 channel ==1 ?1:2
|
||||
* per_channel_npoint:一个声道的点数
|
||||
* */
|
||||
extern void GainProcess_32Bit(int *in, int *out, float gain, int channel, int IndataInc, int OutdataInc, int per_channel_npoint); //32位宽
|
||||
|
||||
|
||||
#endif
|
||||
62
include_lib/media/audio_howling.h
Normal file
62
include_lib/media/audio_howling.h
Normal file
@ -0,0 +1,62 @@
|
||||
#ifndef CONFIG_EFFECT_CORE_V2_ENABLE
|
||||
#include "application/audio_howling.h"
|
||||
#else
|
||||
|
||||
#ifndef _AUDIO_HOWLING_API_H
|
||||
#define _AUDIO_HOWLING_API_H
|
||||
|
||||
#include "media/howling_api.h"
|
||||
|
||||
|
||||
#define TRAP_MODE 0
|
||||
#define SHIFT_PITCH_MODE 1
|
||||
#define PEMAFROW_MODE 2
|
||||
#define SHIFT_PHASE_MODE 3
|
||||
|
||||
#define HOWLING_MODE SHIFT_PITCH_MODE
|
||||
|
||||
#if (HOWLING_MODE == TRAP_MODE)
|
||||
#define REVERB_RUN_POINT_NUM 160 //固定160个点
|
||||
#elif (HOWLING_MODE == SHIFT_PHASE_MODE) //
|
||||
#define REVERB_RUN_POINT_NUM 256 //固定256个点
|
||||
#elif (HOWLING_MODE == PEMAFROW_MODE)
|
||||
#define REVERB_RUN_POINT_NUM 128 //固定128
|
||||
#else
|
||||
#define REVERB_RUN_POINT_NUM 0 //无限制
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 啸叫抑制模块打开
|
||||
@param howl_para:陷波模式时为啸叫抑制参数 ,pemafrow模式为DAC输出数据buf,;
|
||||
sample_rate:输入数据采样率;
|
||||
channels: 输入数据通道数;
|
||||
mode: 0 陷波模式;1 移频模式 2 pemafrow模式
|
||||
@return 啸叫抑制句柄,
|
||||
@note 陷波模式 要外部保证每次运算数据为160点,pemafrow 为128个点
|
||||
对应模式需外部使能,默认只开 移频模式
|
||||
const int config_howling_enable_pemafrow_mode = 1;
|
||||
const int config_howling_enable_trap_mode = 1;
|
||||
const int config_howling_enable_pitchps_mode = 1;
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
HOWLING_API_STRUCT *open_howling(void *howl_para, u16 sample_rate, u8 channel, u8 mode);
|
||||
/*
|
||||
* 啸叫抑制模块数据处理
|
||||
*/
|
||||
void run_howling(HOWLING_API_STRUCT *howling_hdl, short *in, short *out, int len);
|
||||
/*
|
||||
* 啸叫抑制模块关闭
|
||||
*/
|
||||
void close_howling(HOWLING_API_STRUCT *holing_hdl);
|
||||
/*
|
||||
* 啸叫抑制模块暂停处理
|
||||
*/
|
||||
void pause_howling(HOWLING_API_STRUCT *holing_hdl, u8 run_mark);
|
||||
|
||||
void howling_update_bypass(HOWLING_API_STRUCT *hdl, u8 bypass);
|
||||
|
||||
void update_howling_parm(HOWLING_API_STRUCT *howling_hdl, void *parm);
|
||||
#endif
|
||||
|
||||
#endif /*CONFIG_EFFECT_CORE_V2_ENABLE*/
|
||||
12
include_lib/media/audio_llns.h
Normal file
12
include_lib/media/audio_llns.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef _AUDIO_LLNS_H_
|
||||
#define _AUDIO_LLNS_H_
|
||||
|
||||
#include "generic/typedef.h"
|
||||
|
||||
int audio_llns_heap_query(int *share_size, int *private_size, int sr);
|
||||
void *audio_llns_init(char *private_buffer, int private_size, char *share_buffer, int share_size, int sr, float gainfloor, float suppress_level);
|
||||
int audio_llns_run(void *hdl, short *inbuf, u16 inbuf_size, short *outbuf);
|
||||
int audio_llns_close(void *hdl);
|
||||
|
||||
|
||||
#endif/*_AUDIO_LLNS_H_*/
|
||||
321
include_lib/media/audio_stream.h
Normal file
321
include_lib/media/audio_stream.h
Normal file
@ -0,0 +1,321 @@
|
||||
#ifndef AUDIO_STREAM_H
|
||||
#define AUDIO_STREAM_H
|
||||
|
||||
#include "generic/includes.h"
|
||||
#include "media/audio_base.h"
|
||||
|
||||
|
||||
// 数据流IOCTRL命令
|
||||
#define AUDIO_STREAM_IOCTRL_CMD_CHECK_ACTIVE (1) // 检查数据流是否活动
|
||||
|
||||
|
||||
struct audio_stream_entry;
|
||||
struct audio_frame_copy;
|
||||
|
||||
|
||||
/*
|
||||
* 数据流中的传输内容
|
||||
*/
|
||||
struct audio_data_frame {
|
||||
u8 channel; // 通道数
|
||||
u16 stop : 1; // 数据流停止标志
|
||||
u16 data_sync : 1; // 数据流同步标志
|
||||
u16 no_subsequent : 1; // 1-不再执行后续的数据流;0-正常执行
|
||||
u32 sample_rate; // 采样率
|
||||
u16 offset; // 数据偏移
|
||||
u16 data_len; // 数据长度
|
||||
s16 *data; // 数据地址
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* 数据流
|
||||
* 多个数据流节点组成一个数据流
|
||||
*/
|
||||
struct audio_stream {
|
||||
struct audio_stream_entry *entry; // 数据流节点
|
||||
void *priv; // resume私有参数
|
||||
void (*resume)(void *priv); // 激活回调接口
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* 数据流群组
|
||||
* 用于串联多个数据流,在调用resume/clear等操作时依次处理各个数据流
|
||||
* 如数据流stream0最后一个节点是entry0_n,数据流1最后一个节点是entry1_n
|
||||
* 把这两个数据流加入到群组test_group中
|
||||
* audio_stream_group_add_entry(&test_group, &entry0_n);
|
||||
* audio_stream_group_add_entry(&test_group, &entry1_n);
|
||||
* 另一个数据流streamX的第一个节点是entryX_0,把群组关联到streamX数据流
|
||||
* entryX_0.group = &test_group;
|
||||
* 那么调用streamX中的resume就会依次调用stream0和stream1的resume了
|
||||
*/
|
||||
struct audio_stream_group {
|
||||
struct audio_stream_entry *entry; // 数据流节点
|
||||
};
|
||||
|
||||
/*
|
||||
* 数据流节点
|
||||
* 数据流节点依次串联,数据依次往后传递
|
||||
*/
|
||||
struct audio_stream_entry {
|
||||
u8 pass_by; // 1-同步处理(即往后传的buf就是上层传入的buf);
|
||||
// 0-异步处理(数据存到其他buf再往后传)
|
||||
u8 remain; // 1-上次数据没输出完。0-上次数据输出完
|
||||
u16 offset; // 同步处理时的数据偏移
|
||||
struct audio_stream *stream; // 所属的数据流
|
||||
struct audio_stream_entry *input; // 上一个节点
|
||||
struct audio_stream_entry *output; // 下一个节点
|
||||
struct audio_stream_entry *sibling; // 数据流群组中的数据流节点链表
|
||||
struct audio_stream_group *group; // 数据流群组节点
|
||||
struct audio_frame_copy *frame_copy; // 数据分支节点
|
||||
int (*prob_handler)(struct audio_stream_entry *, struct audio_data_frame *in); // 预处理
|
||||
int (*data_handler)(struct audio_stream_entry *, struct audio_data_frame *in,
|
||||
struct audio_data_frame *out); // 数据处理
|
||||
void (*data_process_len)(struct audio_stream_entry *, int len); // 后级返回使用的数据长度
|
||||
void (*data_clear)(struct audio_stream_entry *); // 清除节点数据
|
||||
int (*ioctrl)(struct audio_stream_entry *, int cmd, int *param); // 节点IOCTRL
|
||||
};
|
||||
|
||||
/*
|
||||
* 数据流分支
|
||||
* 支持一传多(分支)功能,内部自动生成struct audio_frame_copy来处理多个分支
|
||||
* 有多少个分支就会申请多少个空间,数据分别拷贝到对应分支空间然后往后传递
|
||||
*/
|
||||
struct audio_frame_copy {
|
||||
struct list_head head; // 链表。用于连接各个分支
|
||||
struct audio_data_frame frame; // 保存上层的传输内容
|
||||
struct audio_stream_entry entry; // 连接上层的节点
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Stream Open
|
||||
* Description: 创建一个数据流
|
||||
* Arguments : *priv resume回调的私有参数
|
||||
* resume 模块唤醒数据流时的回调函数
|
||||
* Return : 数据流句柄
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
struct audio_stream *audio_stream_open(void *priv, void (*resume)(void *priv));
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Stream Add First
|
||||
* Description: 添加第一个数据流节点
|
||||
* Arguments : *stream 数据流句柄
|
||||
* *entry 数据流节点句柄
|
||||
* Return : None.
|
||||
* Note(s) : 第一个节点一般为解码输出
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_stream_add_first(struct audio_stream *stream,
|
||||
struct audio_stream_entry *entry);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Stream Add Head
|
||||
* Description: 将节点插入到数据流的first节点后面
|
||||
* Arguments : *stream 数据流句柄
|
||||
* *entry 数据流节点句柄
|
||||
* Return : None.
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_stream_add_head(struct audio_stream *stream,
|
||||
struct audio_stream_entry *entry);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Stream Add Tail
|
||||
* Description: 将节点放到数据流的最后
|
||||
* Arguments : *stream 数据流句柄
|
||||
* *entry 数据流节点句柄
|
||||
* Return : None.
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_stream_add_tail(struct audio_stream *stream,
|
||||
struct audio_stream_entry *entry);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Stream Add Entry
|
||||
* Description: 将output节点添加到input节点之后
|
||||
* Arguments : *input 数据流节点句柄
|
||||
* *output 需要添加的数据流节点句柄
|
||||
* Return : None.
|
||||
* Note(s) : 如果input节点后面已经连接有节点,将创建数据流分支处理
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_stream_add_entry(struct audio_stream_entry *input,
|
||||
struct audio_stream_entry *output);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Stream Add List
|
||||
* Description: 将entry数组中节点按顺序添加到数据流中
|
||||
* Arguments : *stream 数据流句柄
|
||||
* *entry[] 数据流节点数组
|
||||
* num 节点总个数
|
||||
* Return : None.
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_stream_add_list(struct audio_stream *stream,
|
||||
struct audio_stream_entry *entry[], int num);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Stream Delete Entry
|
||||
* Description: 将节点从数据流中删除
|
||||
* Arguments : *entry 数据流节点句柄
|
||||
* Return : None.
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_stream_del_entry(struct audio_stream_entry *entry);
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Stream Delete List Entry
|
||||
* Description: 依次将数组中的节点删除
|
||||
* Arguments : *entry[] 数据流节点数组
|
||||
* num 节点总个数
|
||||
* Return : None.
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_stream_del_list(struct audio_stream_entry *entry[], int num);
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Stream Group Add Entry
|
||||
* Description: 将节点加入到群组之中
|
||||
* Arguments : *group 数据流群组句柄
|
||||
* *entry 数据流节点句柄
|
||||
* Return : None.
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_stream_group_add_entry(struct audio_stream_group *group,
|
||||
struct audio_stream_entry *entry);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Stream Group Delete Entry
|
||||
* Description: 将节点从群组之中删除
|
||||
* Arguments : *group 数据流群组句柄
|
||||
* *entry 数据流节点句柄
|
||||
* Return : None.
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_stream_group_del_entry(struct audio_stream_group *group,
|
||||
struct audio_stream_entry *entry);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Stream Group Get Entry Number
|
||||
* Description: 获取群组中的节点个数
|
||||
* Arguments : *group 数据流群组句柄
|
||||
* Return : 节点个数
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
int audio_stream_group_entry_num(struct audio_stream_group *group);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Stream Run
|
||||
* Description: 数据处理接口
|
||||
* Arguments : *entry 数据流节点句柄
|
||||
* *input 输入数据
|
||||
* Return : 负数-出错
|
||||
* Note(s) : 数据流依次递归往后传输。直到最后一个节点,或者no_subsequent==1,
|
||||
* 或者prob_handler/data_handler处理错误返回负数
|
||||
*********************************************************************
|
||||
*/
|
||||
int audio_stream_run(struct audio_stream_entry *from, struct audio_data_frame *input);
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Stream Resume
|
||||
* Description: 唤醒数据流
|
||||
* Arguments : *entry 数据流节点句柄
|
||||
* Return : 0-成功
|
||||
* Note(s) : 最终会递归调用到struct audio_stream结构体中的.resume回调接口
|
||||
*********************************************************************
|
||||
*/
|
||||
int audio_stream_resume(struct audio_stream_entry *entry);
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Stream Clear From Entry
|
||||
* Description: 清除指定节点及后续所有节点的数据
|
||||
* Arguments : *entry 数据流节点句柄
|
||||
* Return : None.
|
||||
* Note(s) : 会清除offset/pass_by等记录,并且调用data_clear回调接口清除用户数据
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_stream_clear_from(struct audio_stream_entry *entry);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Stream Clear
|
||||
* Description: 清除数据流所有节点数据
|
||||
* Arguments : *stream 数据流句柄
|
||||
* Return : None.
|
||||
* Note(s) : 会清除offset/pass_by等记录,并且调用data_clear回调接口清除用户数据
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_stream_clear(struct audio_stream *stream);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Stream Clear By Entry
|
||||
* Description: 通过数据流某个节点清除数据流所有节点数据
|
||||
* Arguments : *entry 数据流节点句柄
|
||||
* Return : None.
|
||||
* Note(s) : 先找到数据流起始位置,再调用audio_stream_clear()清除所有节点
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_stream_clear_by_entry(struct audio_stream_entry *entry);
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Stream Check Active From Entry
|
||||
* Description: 检测指定节点及后续节点是否有活动情况
|
||||
* Arguments : *entry 数据流节点句柄
|
||||
* Return : true 活动
|
||||
* Note(s) : 只要中间有某个节点活动就会返回数据流活动
|
||||
*********************************************************************
|
||||
*/
|
||||
int audio_stream_check_active_from(struct audio_stream_entry *entry);
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Stream Close
|
||||
* Description: 关闭数据流
|
||||
* Arguments : *stream 数据流句柄
|
||||
* Return : None.
|
||||
* Note(s) : 需关闭所有数据流节点之后才能调用该函数
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_stream_close(struct audio_stream *stream);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
186
include_lib/media/audio_surround.h
Normal file
186
include_lib/media/audio_surround.h
Normal file
@ -0,0 +1,186 @@
|
||||
#ifndef CONFIG_EFFECT_CORE_V2_ENABLE
|
||||
#include "application/audio_surround.h"
|
||||
#else
|
||||
|
||||
#ifndef _AUDIO_SURROUND_API_H_
|
||||
#define _AUDIO_SURROUND_API_H_
|
||||
|
||||
#include "system/includes.h"
|
||||
#include "media/includes.h"
|
||||
#include "media/effect_sur_api.h"
|
||||
|
||||
typedef struct _surround_update_parm {
|
||||
int surround_type; //音效类型
|
||||
int rotatestep; //旋转速度
|
||||
int damping; //高频衰减速度
|
||||
int feedback; //整体衰减速度
|
||||
int roomsize; //空间大小
|
||||
} surround_update_parm;
|
||||
|
||||
typedef struct _surround_open_parm {
|
||||
u32 sur_name;
|
||||
u8 channel; //通道数立体声配2, 左声道配EFFECT_CH_L, 右声道配EFFECT_CH_R
|
||||
u8 surround_effect_type; //默认的环绕音效类型
|
||||
} surround_open_parm;
|
||||
|
||||
|
||||
typedef struct _surround_hdl {
|
||||
SUR_FUNC_API *ops; //环绕音效底层io
|
||||
void *work_buf; //底层模块运行的句柄及buf
|
||||
|
||||
surround_open_parm parm; //打开模块传入的参数
|
||||
u8 status; //内部运行状态机
|
||||
u8 update; //设置参数更新标志
|
||||
u8 eff_type;
|
||||
|
||||
struct audio_stream_entry entry; // 音频流入口
|
||||
struct list_head hentry; //
|
||||
|
||||
} surround_hdl;
|
||||
|
||||
/*cmd*/
|
||||
enum {
|
||||
EFFECT_3D_PANORAMA = 0, //3d全景
|
||||
EFFECT_3D_ROTATES, //3d环绕
|
||||
EFFECT_FLOATING_VOICE, //流动人声
|
||||
EFFECT_GLORY_OF_KINGS, //王者荣耀
|
||||
EFFECT_FOUR_SENSION_BATTLEFIELD, //四季战场
|
||||
|
||||
EFFECT_SUR2, //一种新的环绕声(仿某耳机的环绕音效)需将const_surround_en|BIT(2)
|
||||
/*如使用以下效果,需将const_surround_en|BIT(1), mips占用 55M ram33k*/
|
||||
EFFECT_3D_PANORAMA2, //3d全景另一种效果
|
||||
EFFECT_KTV, //ktv模式
|
||||
EFFECT_3DTHE, //3D影院
|
||||
EFFECT_HALL, //音乐厅
|
||||
EFFECT_VOICE, //清澈人声
|
||||
EFFECT_SUR, //全景环绕
|
||||
|
||||
EFFECT_OFF2, //音效开关(数据会经过模块,但不做处理,保证数据延续,避免由音效开关引起的哒哒音,)
|
||||
EFFECT_OFF, //音效开关(数据直接不经过模块)
|
||||
};
|
||||
|
||||
|
||||
//{EFFECT_3D_TYPE1, 2, 120, 110, 128},//3D全景
|
||||
//{EFFECT_3D_ROTATE, 2, 60, 70, 128},//3D旋转, step旋转速度 建议1~8
|
||||
//{EFFECT_3D_LRDRIFT, 140, 120, 95, 128}, //流动人声,step流动速度 建议40~400
|
||||
//{EFFECT_3D_TYPE0, 2, 120, 95, 128},//王者荣耀
|
||||
//{EFFECT_3D_TYPE1, 2, 60, 100, 30},//四季战场,同全景,但把整体调小了
|
||||
//以上是内置默认效果
|
||||
|
||||
|
||||
#if 0
|
||||
//如启用多效果调节,需将const_surround_en|BIT(1),调用update接口传参使用。
|
||||
//{EFFECT_3D_TYPE2, 2, 90, 100, 100},//3d全景的另一效果,该效果,mips占用 55M ram33k.
|
||||
//第一个参数2是无效参数.
|
||||
//第2个参数90调节反馈强度范围是1到150,大点的话空间感比较强。
|
||||
//第3个参数是 湿声增益,可调范围是0到128。
|
||||
//第4个参数调节空间大小,范围是0-100,是反馈参数,有效范围0到100。
|
||||
|
||||
//例如:
|
||||
surround_update_parm parm = {0};
|
||||
parm.surround_type = EFFECT_3D_TYPE2;
|
||||
parm.rotatestep = 2;
|
||||
parm.damping = 90;
|
||||
parm.feedback = 100;
|
||||
parm.roomsize = 100;
|
||||
audio_surround_parm_update(hdl, EFFECT_3D_PANORAMA2, &parm);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
//如需要自定义 ktv模式、3d影院、音乐厅、清澈人声、全景环绕
|
||||
//参数顺序
|
||||
//dry,wet,delay,rot60,Erwet,Erfactor,Ewidth,Ertolate,predelay,width,diffusion,dampinglpf,basslpf,bassB
|
||||
const static int surmode_present[][14] = {
|
||||
{55, 70, 35, 8000, 80, 80, 80, 80, 20, 100, 70, 6500, 4000, 18}, //EFFECT_KTV
|
||||
{60, 60, 90, 9030, 90, 90, 90, 90, 18, 100, 75, 7000, 1000, 29}, //EFFECT_3DTHE
|
||||
{50, 70, 100, 12000, 100, 100, 100, 100, 20, 100, 72, 9000, 50, 3}, //EFFECT_HALL
|
||||
{40, 70, 20, 2010, 100, 70, 70, 100, 15, 100, 70, 5500, 3500, 60}, //EFFECT_VOICE
|
||||
{60, 70, 100, 9000, 80, 80, 80, 90, 10, 100, 72, 8000, 500, 15}, //EFFECT_SUR
|
||||
};
|
||||
|
||||
parm.surround_type = EFFECT_3D_TYPE2;
|
||||
parm.rotatestep = 2;
|
||||
parm.damping = -1;
|
||||
parm.feedback = 100;
|
||||
parm.roomsize = (int)surmode_present[0];
|
||||
audio_surround_parm_update(hdl, EFFECT_KTV, &parm);
|
||||
|
||||
//如使用默认的 ktv模式、3d影院、音乐厅、清澈人声、全景环绕
|
||||
audio_surround_parm_update(hdl, EFFECT_KTV, NULL);
|
||||
audio_surround_parm_update(hdl, EFFECT_3DTHE, NULL);
|
||||
audio_surround_parm_update(hdl, EFFECT_HALL, NULL);
|
||||
audio_surround_parm_update(hdl, EFFECT_VOICE, NULL);
|
||||
audio_surround_parm_update(hdl, EFFECT_SUR, NULL);
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief audio_surround_open 环绕音效打开
|
||||
@param *parm: 环绕音效始化参数,详见结构体surround_open_parm
|
||||
@return 句柄
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
surround_hdl *audio_surround_open(surround_open_parm *parm);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief audio_surround_parm_update 环绕音效参数更新
|
||||
@param cmd:EFFECT_3D_PANORAMA,EFFECT_3D_ROTATES,EFFECT_FLOATING_VOICE,EFFECT_GLORY_OF_KINGS,EFFECT_FOUR_SENSION_BATTLEFIELD
|
||||
@param *parm:参数指针,NULL则使用默认德参数,否则传入自定义参数
|
||||
@return 0:成功 -1: 失败
|
||||
@note 对耳时,左右声道效果,须设置保持一致
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_surround_parm_update(u32 sur_name, u32 cmd, surround_update_parm *parm);
|
||||
|
||||
/* surround_update_parm parm = {0}; */
|
||||
// parm.surround_type = EFFECT_3D_TYPE1;
|
||||
// parm.rotatestep = 2;//旋转速度
|
||||
// parm.damping = 120;//高频衰减速度
|
||||
// parm.feedback = 110;//整体衰减速度
|
||||
// parm.roomsize = 128;//空间大小
|
||||
/* audio_surround_parm_update(hdl, EFFECT_3D_PANORAMA, &parm); */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief audio_surround_close 环绕音效关闭处理
|
||||
@param _hdl:句柄
|
||||
@return 0:成功 -1:失败
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_surround_close(surround_hdl *_hdl);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief audio_surround_run 环绕音效处理
|
||||
@param _hdl:句柄
|
||||
@param data:需要处理的数据
|
||||
@param len:数据长度
|
||||
@return 0:成功 -1:失败
|
||||
@note 无数据流节点时,直接使用改接口进行环绕音效的处理
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_surround_run(surround_hdl *_hdl, void *data, u32 len);
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief audio_surround_switch_nch 通道切换
|
||||
@param _hdl:句柄
|
||||
@param nch:通道数 2 4 或者EFFECT_CH_L EFFECT_CH_R
|
||||
@return 0:成功 -1:失败
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_surround_switch_nch(surround_hdl *_hdl, int nch);
|
||||
void audio_surround_bypass(u32 sur_name, u8 bypass);
|
||||
|
||||
#ifndef RUN_NORMAL
|
||||
#define RUN_NORMAL 0
|
||||
#endif
|
||||
|
||||
#ifndef RUN_BYPASS
|
||||
#define RUN_BYPASS 1
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#endif /*CONFIG_EFFECT_CORE_V2_ENABLE*/
|
||||
46
include_lib/media/audio_vbass.h
Normal file
46
include_lib/media/audio_vbass.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef CONFIG_EFFECT_CORE_V2_ENABLE
|
||||
#include "application/audio_vbass.h"
|
||||
#else
|
||||
#ifndef _AUDIO_VBASS_API_H_
|
||||
#define _AUDIO_VBASS_API_H_
|
||||
#include "system/includes.h"
|
||||
#include "media/audio_stream.h"
|
||||
#include "media/VirtualBass_api.h"
|
||||
|
||||
typedef struct _VirtualBassUdateParam {
|
||||
int ratio;
|
||||
int boost;
|
||||
int fc;
|
||||
} VirtualBassUdateParam;
|
||||
|
||||
|
||||
typedef struct _vbass_hdl {
|
||||
struct audio_stream_entry entry; // 音频流入口
|
||||
struct list_head hentry; //
|
||||
void *workbuf; //vbass 运行句柄及buf
|
||||
VirtualBassParam parm;
|
||||
u32 vbass_name;
|
||||
u8 status; //内部运行状态机
|
||||
u8 update; //设置参数更新标志
|
||||
} vbass_hdl;
|
||||
|
||||
|
||||
vbass_hdl *audio_vbass_open(u32 vbass_name, VirtualBassParam *parm);
|
||||
int audio_vbass_close(vbass_hdl *hdl);
|
||||
|
||||
int audio_vbass_parm_update(u32 vbass_name, VirtualBassUdateParam *parm);
|
||||
void audio_vbass_bypass(u32 vbass_name, u8 bypass);
|
||||
vbass_hdl *get_cur_vbass_hdl_by_name(u32 vbass_name);
|
||||
|
||||
#ifndef RUN_NORMAL
|
||||
#define RUN_NORMAL 0
|
||||
#endif
|
||||
|
||||
#ifndef RUN_BYPASS
|
||||
#define RUN_BYPASS 1
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
#endif /*CONFIG_EFFECT_CORE_V2_ENABLE*/
|
||||
|
||||
56
include_lib/media/bt_audio_timestamp.h
Normal file
56
include_lib/media/bt_audio_timestamp.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*****************************************************************
|
||||
>file name : bt_audio_timestamp.h
|
||||
>create time : Fri 21 May 2021 03:05:35 PM CST
|
||||
*****************************************************************/
|
||||
#ifndef _BT_AUDIO_TIMESTAMP_H_
|
||||
#define _BT_AUDIO_TIMESTAMP_H_
|
||||
#include "typedef.h"
|
||||
|
||||
#define TWS_A2DP_AUDIO 0
|
||||
#define TWS_ESCO_AUDIO 1
|
||||
#define TWS_FILE_AUDIO 2
|
||||
#define TWS_SHARE_AUDIO 3
|
||||
#define TWS_UNKOWN_AUDIO 8
|
||||
|
||||
/*===================================A2DP 音频时间戳接口==================================*/
|
||||
void *a2dp_audio_timestamp_create(int sample_rate, u32 timestamp, u8 factor);
|
||||
|
||||
u32 a2dp_audio_update_timestamp(void *handle, u16 seqn, u32 dts);
|
||||
|
||||
void a2dp_audio_delay_offset_update(void *handle, int distance);
|
||||
|
||||
int a2dp_audio_sample_rate(void *handle);
|
||||
|
||||
bool a2dp_audio_timestamp_is_available(void *handle, u16 seqn, u32 dts, int *drop);
|
||||
|
||||
int tws_a2dp_share_timestamp(void *handle);
|
||||
|
||||
void a2dp_audio_set_base_time(void *handle, u32 base_time);
|
||||
|
||||
void a2dp_audio_timestamp_close(void *handle);
|
||||
|
||||
int a2dp_tws_audio_conn_offline(void);
|
||||
|
||||
void a2dp_tws_audio_conn_delete(void);
|
||||
|
||||
/*========================================================================================*/
|
||||
|
||||
/*===================================ESCO 音频时间戳接口==================================*/
|
||||
void *esco_audio_timestamp_create(u8 frame_clkn, u32 delay_time, u8 factor);
|
||||
|
||||
u32 esco_audio_timestamp_update(void *handle, u32 time);
|
||||
|
||||
void esco_audio_timestamp_close(void *handle);
|
||||
/*========================================================================================*/
|
||||
|
||||
|
||||
/*===================================FILE 音频时间戳接口==================================*/
|
||||
void *file_audio_timestamp_create(u32 magic, int sample_rate, u32 timestamp, u32 delay_time, u8 factor);
|
||||
|
||||
bool tws_file_timestamp_available(void *handle);
|
||||
|
||||
u32 file_audio_timestamp_update(void *handle, u32 dts);
|
||||
|
||||
void file_audio_timestamp_close(void *handle);
|
||||
/*========================================================================================*/
|
||||
#endif
|
||||
61
include_lib/media/cvp/aec_uart_debug.h
Normal file
61
include_lib/media/cvp/aec_uart_debug.h
Normal file
@ -0,0 +1,61 @@
|
||||
#ifndef _AEC_UART_DEBUG_H_
|
||||
#define _AEC_UART_DEBUG_H_
|
||||
|
||||
#include "generic/typedef.h"
|
||||
|
||||
/*
|
||||
*********************************************************
|
||||
* aec_uart_open
|
||||
* Description: 打开数据写卡接口
|
||||
* Arguments_v1 : nch 总通道数, single_size 单个通道的数据大小
|
||||
* Arguments_v2 : nch 允许发送的最大通道数, single_size 单次发送允许的最大包长
|
||||
* Return : 0 成功 其他 失败
|
||||
* Note(s) : None.
|
||||
*********************************************************
|
||||
*/
|
||||
int aec_uart_open(u8 nch, u16 single_size);
|
||||
|
||||
/*
|
||||
*********************************************************
|
||||
* aec_uart_init
|
||||
* Description: 数据写卡初始化
|
||||
* Arguments : None.
|
||||
* Return : 0 成功 其他 失败
|
||||
* Note(s) : None.
|
||||
*********************************************************
|
||||
*/
|
||||
int aec_uart_init(void);
|
||||
|
||||
/*
|
||||
*********************************************************
|
||||
* aec_uart_fill
|
||||
* Description: 填写对应通道的数据
|
||||
* Arguments : ch 通道号,buf 数据地址,size 数据大小
|
||||
* Return : 0 成功 其他 失败
|
||||
* Note(s) : None.
|
||||
*********************************************************
|
||||
*/
|
||||
int aec_uart_fill(u8 ch, void *buf, u16 size);
|
||||
|
||||
/*
|
||||
*********************************************************
|
||||
* aec_uart_write
|
||||
* Description: 将写入通话的数据写入串口buffer
|
||||
* Arguments : None.
|
||||
* Return : None.
|
||||
* Note(s) : None.
|
||||
*********************************************************
|
||||
*/
|
||||
void aec_uart_write(void);
|
||||
|
||||
/*
|
||||
*********************************************************
|
||||
* aec_uart_close
|
||||
* Description: 关闭数据写卡
|
||||
* Arguments : None.
|
||||
* Return : 0 成功 其他 失败
|
||||
* Note(s) : None.
|
||||
*********************************************************
|
||||
*/
|
||||
int aec_uart_close(void);
|
||||
#endif/*_AEC_UART_DEBUG_H_*/
|
||||
201
include_lib/media/cvp/commproc.h
Normal file
201
include_lib/media/cvp/commproc.h
Normal file
@ -0,0 +1,201 @@
|
||||
#ifndef _COMMPROC_H_
|
||||
#define _COMMPROC_H_
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "cvp_common.h"
|
||||
|
||||
/*降噪版本定义*/
|
||||
#define ANS_V100 0xA1
|
||||
#define ANS_V200 0xA2
|
||||
|
||||
//aec_cfg:
|
||||
typedef struct __AEC_CONFIG {
|
||||
u8 mic_again; //DAC增益,default:3(0~14)
|
||||
u8 dac_again; //MIC增益,default:22(0~31)
|
||||
u8 aec_mode; //AEC模式,default:advance(diable(0), reduce(1), advance(2))
|
||||
u8 ul_eq_en; //上行EQ使能,default:enable(disable(0), enable(1))
|
||||
/*AGC*/
|
||||
float ndt_fade_in; //单端讲话淡入步进default: 1.f(0.1 ~ 5 dB)
|
||||
float ndt_fade_out; //单端讲话淡出步进default: 0.7f(0.1 ~ 5 dB)
|
||||
float dt_fade_in; //双端讲话淡入步进default: 1.3f(0.1 ~ 5 dB)
|
||||
float dt_fade_out; //双端讲话淡出步进default: 0.7f(0.1 ~ 5 dB)
|
||||
float ndt_max_gain; //单端讲话放大上限,default: 12.f(0 ~ 24 dB)
|
||||
float ndt_min_gain; //单端讲话放大下限,default: 0.f(-20 ~ 24 dB)
|
||||
float ndt_speech_thr; //单端讲话放大阈值,default: -50.f(-70 ~ -40 dB)
|
||||
float dt_max_gain; //双端讲话放大上限,default: 12.f(0 ~ 24 dB)
|
||||
float dt_min_gain; //双端讲话放大下限,default: 0.f(-20 ~ 24 dB)
|
||||
float dt_speech_thr; //双端讲话放大阈值,default: -40.f(-70 ~ -40 dB)
|
||||
float echo_present_thr; //单端双端讲话阈值,default:-70.f(-70 ~ -40 dB)
|
||||
/*AEC*/
|
||||
float aec_dt_aggress; //原音回音追踪等级, default: 1.0f(1 ~ 5)
|
||||
float aec_refengthr; //进入回音消除参考值, default: -70.0f(-90 ~ -60 dB)
|
||||
/*ES*/
|
||||
float es_aggress_factor;//回音前级动态压制,越小越强,default: -3.0f(-1 ~ -5)
|
||||
float es_min_suppress; //回音后级静态压制,越大越强,default: 4.f(0 ~ 10)
|
||||
/*ANS*/
|
||||
float ans_aggress; //噪声前级动态压制,越大越强default: 1.25f(1 ~ 2)
|
||||
float ans_suppress; //噪声后级静态压制,越小越强default: 0.04f(0 ~ 1)
|
||||
} _GNU_PACKED_ AEC_CONFIG;
|
||||
|
||||
struct aec_s_attr {
|
||||
u8 agc_en: 1;
|
||||
u8 ul_eq_en: 1;
|
||||
u8 wideband: 1;
|
||||
u8 toggle: 1;
|
||||
u8 wn_en: 1;
|
||||
u8 dly_est : 1;
|
||||
u8 reserved: 2;
|
||||
|
||||
u8 dst_delay;/*延时估计目标延时*/
|
||||
u8 EnableBit;
|
||||
u8 packet_dump;
|
||||
u8 SimplexTail;
|
||||
u8 aec_tail_length; //AEC复杂等级:2~10,default:5
|
||||
float AGC_NDT_fade_in_step; //in dB
|
||||
float AGC_NDT_fade_out_step; //in dB
|
||||
float AGC_NDT_max_gain; //in dB
|
||||
float AGC_NDT_min_gain; //in dB
|
||||
float AGC_NDT_speech_thr; //in dB
|
||||
float AGC_DT_fade_in_step; //in dB
|
||||
float AGC_DT_fade_out_step; //in dB
|
||||
float AGC_DT_max_gain; //in dB
|
||||
float AGC_DT_min_gain; //in dB
|
||||
float AGC_DT_speech_thr; //in dB
|
||||
float AGC_echo_present_thr; //In dB
|
||||
int AGC_echo_look_ahead; //in ms
|
||||
int AGC_echo_hold; // in ms
|
||||
u16 hw_delay_offset;/*dac hardware delay offset*/
|
||||
u16 wn_gain;/*white_noise gain*/
|
||||
int SimplexThr;
|
||||
float ES_AggressFactor;
|
||||
float ES_MinSuppress;
|
||||
float ES_Unconverge_OverDrive;
|
||||
float ANS_AggressFactor;
|
||||
float ANS_MinSuppress;
|
||||
float ANS_NoiseLevel;
|
||||
int (*cvp_advanced_options)(void *aec,
|
||||
void *nlp,
|
||||
void *ns,
|
||||
void *tde,
|
||||
void *agc);
|
||||
int (*aec_probe)(short *mic0, short *mic2, short *mic3, short *ref, u16 len);
|
||||
int (*aec_post)(s16 *dat, u16 len);
|
||||
int (*aec_update)(u8 aec_mode);
|
||||
int (*output_handle)(s16 *dat, u16 len);
|
||||
u8 output_way; // 0:dac 1:fm
|
||||
u8 ANS_mode;
|
||||
u8 fm_tx_start;
|
||||
u8 far_noise_gate;//default:10
|
||||
|
||||
float AEC_RefEngThr;
|
||||
float AEC_DT_AggressiveFactor;
|
||||
//float AES_AggressFactor;
|
||||
//float AES_RefEngThr;
|
||||
|
||||
/*Extended-Parameters*/
|
||||
u16 ref_sr;
|
||||
u16 ref_channel; /*参考数据声道数*/
|
||||
u16 adc_ref_en; /*adc回采参考数据使能*/
|
||||
|
||||
/*DNS Parameters*/
|
||||
float DNS_GainFloor; //最小压制 range[0:1.00]
|
||||
float DNS_OverDrive; //降噪强度 range[0:6.0]
|
||||
float DNS_highGain; //EQ强度 range[1.0:3.5]
|
||||
float DNS_rbRate; //混响强度 range[0:0.9]
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* AEC Init
|
||||
* Description: AEC模块初始化
|
||||
* Arguments : attr AEC模块参数
|
||||
* Return : 0 成功 其他 失败
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
s32 aec_init(struct aec_s_attr *attr);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* AEC Exit
|
||||
* Description: AEC退出
|
||||
* Arguments : None.
|
||||
* Return : 0 成功 其他 失败
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
s32 aec_exit();
|
||||
u32 aec_output_read(s16 *buf, u16 npoint);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* AEC Input
|
||||
* Description: AEC源数据输入
|
||||
* Arguments : dat 参考数据
|
||||
* len 参考数据长度
|
||||
* Return : 0 成功 其他 失败
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
s32 aec_fill_in_data(void *dat, u16 len);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* AEC Reference
|
||||
* Description: AEC参考数据输入
|
||||
* Arguments : dat 参考数据
|
||||
* len 参考数据长度
|
||||
* Return : 0 成功 其他 失败
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
s32 aec_fill_ref_data(void *dat, u16 len);
|
||||
|
||||
/*adc回采dac数据做ref*/
|
||||
int aec_fill_in_ref_data(void *dat, u16 len);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* AEC Toggle
|
||||
* Description: AEC bypass设置
|
||||
* Arguments : toggle bypass开关
|
||||
* Return : None.
|
||||
* Note(s) : 该接口用于切换算法开关,1为正常流程,0为bypass,数据
|
||||
* 不经算法处理
|
||||
*********************************************************************
|
||||
*/
|
||||
void aec_toggle(u8 toggle);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* AEC CFG Updata
|
||||
* Description: AEC模块配置动态更新
|
||||
* Arguments : cfg AEC模块参数
|
||||
* Return : 0 成功 其他 失败
|
||||
* Note(s) : 该接口用于使用过程,动态修改模块参数
|
||||
*********************************************************************
|
||||
*/
|
||||
int aec_cfg_update(AEC_CONFIG *cfg);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* AEC Reboot
|
||||
* Description: AEC模块重新启动
|
||||
* Arguments : enablebit 重新启动使能的模块
|
||||
* Return : 0 成功 其他 失败
|
||||
* Note(s) : 该接口用于重新启动AEC模块
|
||||
*********************************************************************
|
||||
*/
|
||||
int aec_reboot(u8 enablebit);
|
||||
|
||||
int sms_tde_init(struct aec_s_attr *attr);
|
||||
int sms_tde_exit();
|
||||
int sms_tde_fill_in_data(void *dat, u16 len);
|
||||
int sms_tde_fill_ref_data(void *dat, u16 len);
|
||||
int sms_tde_fill_in_ref_data(void *dat, u16 len);
|
||||
void sms_tde_toggle(u8 toggle);
|
||||
int cvp_sms_read_ref_data(void);
|
||||
int cvp_sms_tde_read_ref_data(void);
|
||||
|
||||
#endif
|
||||
258
include_lib/media/cvp/commproc_dms.h
Normal file
258
include_lib/media/cvp/commproc_dms.h
Normal file
@ -0,0 +1,258 @@
|
||||
#ifndef _COMMPROC_DMS_H_
|
||||
#define _COMMPROC_DMS_H_
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "cvp_common.h"
|
||||
|
||||
/*降噪版本定义*/
|
||||
#define DMS_V100 0xA1
|
||||
#define DMS_V200 0xA2
|
||||
|
||||
//dms_cfg:
|
||||
typedef struct {
|
||||
u8 mic_again; //DAC增益,default:3(0~14)
|
||||
u8 dac_again; //MIC增益,default:22(0~31)
|
||||
u8 enable_module; //使能模块
|
||||
u8 ul_eq_en; //上行EQ使能,default:enable(disable(0), enable(1))
|
||||
/*AGC*/
|
||||
float ndt_fade_in; //单端讲话淡入步进default: 1.3f(0.1 ~ 5 dB)
|
||||
float ndt_fade_out; //单端讲话淡出步进default: 0.7f(0.1 ~ 5 dB)
|
||||
float dt_fade_in; //双端讲话淡入步进default: 1.3f(0.1 ~ 5 dB)
|
||||
float dt_fade_out; //双端讲话淡出步进default: 0.7f(0.1 ~ 5 dB)
|
||||
float ndt_max_gain; //单端讲话放大上限,default: 12.f(0 ~ 24 dB)
|
||||
float ndt_min_gain; //单端讲话放大下限,default: 0.f(-20 ~ 24 dB)
|
||||
float ndt_speech_thr; //单端讲话放大阈值,default: -50.f(-70 ~ -40 dB)
|
||||
float dt_max_gain; //双端讲话放大上限,default: 12.f(0 ~ 24 dB)
|
||||
float dt_min_gain; //双端讲话放大下限,default: 0.f(-20 ~ 24 dB)
|
||||
float dt_speech_thr; //双端讲话放大阈值,default: -40.f(-70 ~ -40 dB)
|
||||
float echo_present_thr; //单端双端讲话阈值,default:-70.f(-70 ~ -40 dB)
|
||||
/*aec*/
|
||||
int aec_process_maxfrequency; //default:8000,range[3000:8000]
|
||||
int aec_process_minfrequency; //default:0,range[0:1000]
|
||||
int af_length; //default:128 range[128:256]
|
||||
/*nlp*/
|
||||
int nlp_process_maxfrequency; //default:8000,range[3000:8000]
|
||||
int nlp_process_minfrequency; //default:0,range[0:1000]
|
||||
float overdrive; //default:1,range[0:30]
|
||||
/*ans*/
|
||||
float aggressfactor; //default:1.25,range[1:2]
|
||||
float minsuppress; //default:0.04,range[0.01:0.1]
|
||||
float init_noise_lvl; //default:-75dB,range[-100:-30]
|
||||
/*enc*/
|
||||
int enc_process_maxfreq; //default:8000,range[3000:8000]
|
||||
int enc_process_minfreq; //default:0,range[0:1000]
|
||||
int sir_maxfreq; //default:3000,range[1000:8000]
|
||||
float mic_distance; //default:0.015,range[0.035:0.015]
|
||||
float target_signal_degradation;//default:1,range[0:1]
|
||||
float enc_aggressfactor; //default:4.f,range[0:4]
|
||||
float enc_minsuppress; //default:0.09f,range[0:0.1]
|
||||
/*common*/
|
||||
float global_minsuppress; //default:0.0,range[0.0:0.09]
|
||||
} _GNU_PACKED_ AEC_DMS_CONFIG;
|
||||
|
||||
//dms_flexible_cfg:
|
||||
typedef struct {
|
||||
u8 ver; //Ver:01
|
||||
u8 mic_again; //MIC0增益,default:10(0~14)
|
||||
u8 mic1_again; //MIC1增益,default:3(0~14)
|
||||
u8 dac_again; //DAC增益,default:22(0~31)
|
||||
u8 enable_module; //使能模块 NS:BIT(2) ENC:BIT(3) AGC:BIT(4)
|
||||
u8 ul_eq_en; //上行EQ使能,default:enable(disable(0), enable(1))
|
||||
u8 reserved[2];
|
||||
|
||||
/*AGC*/
|
||||
float ndt_fade_in; //单端讲话淡入步进default: 1.3f(0.1 ~ 5 dB)
|
||||
float ndt_fade_out; //单端讲话淡出步进default: 0.7f(0.1 ~ 5 dB)
|
||||
float dt_fade_in; //双端讲话淡入步进default: 1.3f(0.1 ~ 5 dB)
|
||||
float dt_fade_out; //双端讲话淡出步进default: 0.7f(0.1 ~ 5 dB)
|
||||
float ndt_max_gain; //单端讲话放大上限,default: 12.f(0 ~ 24 dB)
|
||||
float ndt_min_gain; //单端讲话放大下限,default: 0.f(-20 ~ 24 dB)
|
||||
float ndt_speech_thr; //单端讲话放大阈值,default: -50.f(-70 ~ -40 dB)
|
||||
float dt_max_gain; //双端讲话放大上限,default: 12.f(0 ~ 24 dB)
|
||||
float dt_min_gain; //双端讲话放大下限,default: 0.f(-20 ~ 24 dB)
|
||||
float dt_speech_thr; //双端讲话放大阈值,default: -40.f(-70 ~ -40 dB)
|
||||
float echo_present_thr; //单端双端讲话阈值,default:-70.f(-70 ~ -40 dB)
|
||||
/*aec*/
|
||||
int aec_process_maxfrequency; //default:8000,range[3000:8000]
|
||||
int aec_process_minfrequency; //default:0,range[0:1000]
|
||||
int af_length; //default:128 range[128:256]
|
||||
/*nlp*/
|
||||
int nlp_process_maxfrequency; //default:8000,range[3000:8000]
|
||||
int nlp_process_minfrequency; //default:0,range[0:1000]
|
||||
float overdrive; //default:1,range[0:30]
|
||||
/*ans*/
|
||||
float aggressfactor; //default:1.25,range[1:2]
|
||||
float minsuppress; //default:0.04,range[0.01:0.1]
|
||||
float init_noise_lvl; //default:-75dB,range[-100:-30]
|
||||
/*enc*/
|
||||
float enc_suppress_pre; //ENC前级压制,越大越强 default:0.6f,range[0:1]
|
||||
float enc_suppress_post; //ENC后级压制,越大越强 default:0.15f,range[0:1]
|
||||
float enc_minsuppress; //ENC后级压制下限 default:0.09f,range[0:1]
|
||||
float enc_disconverge_erle_thr; //滤波器发散控制阈值,越大控制越强 default:-6.f,range[-20:5]
|
||||
|
||||
} DMS_FLEXIBLE_CONFIG;
|
||||
|
||||
struct dms_attr {
|
||||
u8 ul_eq_en: 1;
|
||||
u8 wideband: 1;
|
||||
u8 wn_en: 1;
|
||||
u8 dly_est : 1;
|
||||
u8 aptfilt_only: 1;
|
||||
u8 reserved: 3;
|
||||
|
||||
u8 dst_delay;/*延时估计目标延时*/
|
||||
u8 EnableBit;
|
||||
u8 packet_dump;
|
||||
u8 SimplexTail;
|
||||
u8 output_sel;/*dms output选择*/
|
||||
u16 hw_delay_offset;/*dac hardware delay offset*/
|
||||
u16 wn_gain;/*white_noise gain*/
|
||||
/*AGC*/
|
||||
float AGC_NDT_fade_in_step; //in dB
|
||||
float AGC_NDT_fade_out_step; //in dB
|
||||
float AGC_NDT_max_gain; //in dB
|
||||
float AGC_NDT_min_gain; //in dB
|
||||
float AGC_NDT_speech_thr; //in dB
|
||||
float AGC_DT_fade_in_step; //in dB
|
||||
float AGC_DT_fade_out_step; //in dB
|
||||
float AGC_DT_max_gain; //in dB
|
||||
float AGC_DT_min_gain; //in dB
|
||||
float AGC_DT_speech_thr; //in dB
|
||||
float AGC_echo_present_thr; //In dB
|
||||
int AGC_echo_look_ahead; //in ms
|
||||
int AGC_echo_hold; // in ms
|
||||
/*AEC*/
|
||||
int aec_process_maxfrequency; //default:8000,range[3000:8000]
|
||||
int aec_process_minfrequency; //default:0,range[0:1000]
|
||||
int af_length; //default:128 range[128:256]
|
||||
/*NLP*/
|
||||
int nlp_process_maxfrequency; //default:8000,range[3000:8000]
|
||||
int nlp_process_minfrequency; //default:0,range[0:1000]
|
||||
float overdrive; //default:1,range[0:30]
|
||||
/*ANS*/
|
||||
float aggressfactor; //default:1.25,range[1:2]
|
||||
float minsuppress; //default:0.04,range[0.01:0.1]
|
||||
float init_noise_lvl; //default:-75db,range[-100:-30]
|
||||
/*ENC*/
|
||||
int enc_process_maxfreq; //default:8000,range[3000:8000]
|
||||
int enc_process_minfreq; //default:0,range[0:1000]
|
||||
int sir_maxfreq; //default:3000,range[1000:8000]
|
||||
float mic_distance; //default:0.015,range[0.035:0.015]
|
||||
float target_signal_degradation;//default:1,range[0:1]
|
||||
float enc_aggressfactor; //default:4.f,range[0:4]
|
||||
float enc_minsuppress; //default:0.09f,range[0:0.1]
|
||||
/*BCS*/
|
||||
int bone_process_maxfreq;
|
||||
int bone_process_minfreq;
|
||||
float bone_init_noise_lvl;
|
||||
int Bone_AEC_Process_MaxFrequency;
|
||||
int Bone_AEC_Process_MinFrequency;
|
||||
/*common*/
|
||||
float global_minsuppress; //default:0.0,range[0.0:0.09]
|
||||
/*data handle*/
|
||||
int (*cvp_advanced_options)(void *aec,
|
||||
void *nlp,
|
||||
void *ns,
|
||||
void *enc,
|
||||
void *agc,
|
||||
void *wn,
|
||||
void *mfdt);
|
||||
int (*aec_probe)(short *mic0, short *mic2, short *mic3, short *ref, u16 len);
|
||||
int (*aec_post)(s16 *dat, u16 len);
|
||||
int (*aec_update)(u8 EnableBit);
|
||||
int (*output_handle)(s16 *dat, u16 len);
|
||||
|
||||
/*flexible enc*/
|
||||
int flexible_af_length; //default:512 range[128、256、512、1024]
|
||||
int sir_minfreq; //default:100,range[0:8000]
|
||||
int SIR_mean_MaxFrequency; //default:1000,range[0:8000]
|
||||
int SIR_mean_MinFrequency; //default:100,range[0:8000]
|
||||
float ENC_CoheFlgMax_gamma; //default:0.5f,range[0:1]
|
||||
float coheXD_thr; //default:0.5f,range[0:1]
|
||||
float Disconverge_ERLE_Thr; //default:-6.f,range[-20:5]
|
||||
|
||||
/*WN*/
|
||||
float wn_detect_time; //in second
|
||||
float wn_detect_time_ratio_thr; //0-1
|
||||
float wn_detect_thr; //0-1
|
||||
float wn_minsuppress; //0-1
|
||||
|
||||
/*Extended-Parameters*/
|
||||
u16 ref_sr;
|
||||
u16 ref_channel; /*参考数据声道数*/
|
||||
u16 adc_ref_en; /*adc回采参考数据使能*/
|
||||
|
||||
/*DNS Parameters*/
|
||||
float DNS_highGain; //EQ强度 range[1.0:3.5]
|
||||
float DNS_rbRate; //混响强度 range[0:0.9];
|
||||
|
||||
/*MFDT Parameters*/
|
||||
float detect_time; // // 检测时间s,影响状态切换的速度
|
||||
float detect_eng_diff_thr; // 0~-90 dB 两个mic能量差异持续大于此阈值超过检测时间则会检测为故障
|
||||
float detect_eng_lowerbound; // 0~-90 dB 当处于故障状态时,正常的mic能量大于此阈值才会检测能量差异,避免安静环境下误判切回正常状态
|
||||
int MalfuncDet_MaxFrequency;// 检测信号的最大频率成分
|
||||
int MalfuncDet_MinFrequency;// 检测信号的最小频率成分
|
||||
int OnlyDetect;// 0 -> 故障切换到单mic模式, 1-> 只检测不切换
|
||||
};
|
||||
|
||||
s32 aec_dms_init(struct dms_attr *attr);
|
||||
s32 aec_dms_exit();
|
||||
s32 aec_dms_fill_in_data(void *dat, u16 len);
|
||||
int aec_dms_fill_in_ref_data(void *dat, u16 len);
|
||||
s32 aec_dms_fill_ref_data(void *dat, u16 len);
|
||||
void aec_dms_toggle(u8 toggle);
|
||||
int aec_dms_cfg_update(AEC_DMS_CONFIG *cfg);
|
||||
int aec_dms_reboot(u8 enablebit);
|
||||
|
||||
s32 aec_dms_flexible_init(struct dms_attr *attr);
|
||||
s32 aec_dms_flexible_exit();
|
||||
s32 aec_dms_flexible_fill_in_data(void *dat, u16 len);
|
||||
int aec_dms_flexible_fill_in_ref_data(void *dat, u16 len);
|
||||
s32 aec_dms_flexible_fill_ref_data(void *dat, u16 len);
|
||||
void aec_dms_flexible_toggle(u8 toggle);
|
||||
int aec_dms_flexible_cfg_update(DMS_FLEXIBLE_CONFIG *cfg);
|
||||
int aec_dms_flexible_reboot(u8 enablebit);
|
||||
|
||||
/*获取风噪的检测结果,1:有风噪,0:无风噪*/
|
||||
int cvp_dms_get_wind_detect_state(void);
|
||||
|
||||
/*单双麦切换状态
|
||||
* 0: 正常双麦 ;
|
||||
* 1: 副麦坏了,触发故障
|
||||
* -1: 主麦坏了,触发故障
|
||||
*/
|
||||
int cvp_dms_get_malfunc_state(void);
|
||||
|
||||
/*
|
||||
* 获取mic的能量值,开了MFDT_EN才能用
|
||||
* mic: 0 获取主麦能量
|
||||
* mic:1 获取副麦能量
|
||||
* return:返回能量值,[0~90.3],返回-1表示错误
|
||||
*/
|
||||
float cvp_dms_get_mic_energy(u8 mic);
|
||||
|
||||
typedef enum {
|
||||
DMS_FLEXIBLE_DUAL_MIC = 0, //双mic
|
||||
DMS_FLEXIBLE_USE_TALK_MIC, //通话mic(主麦)
|
||||
DMS_FLEXIBLE_USE_REF_MIC, //参考mic(副麦)
|
||||
} DMS_FLEXIBLE_MIC;
|
||||
|
||||
/* 话务耳机切换使用的mic
|
||||
* DMS_FLEXIBLE_DUAL_MIC :正常双麦话务耳机
|
||||
* DMS_FLEXIBLE_USE_TALK_MIC :使用主麦
|
||||
* DMS_FLEXIBLE_USE_REF_MIC :使用副麦
|
||||
*/
|
||||
int aec_dms_flexible_selete_mic(DMS_FLEXIBLE_MIC mic);
|
||||
|
||||
int cvp_dms_read_ref_data(void);
|
||||
int cvp_dms_flexible_read_ref_data(void);
|
||||
|
||||
/*
|
||||
* 获取风噪检测信息
|
||||
* wd_flag: 0 没有风噪,1 有风噪
|
||||
* 风噪强度r: 0~BIT(16)
|
||||
* wd_lev: 风噪等级,0:弱风,1:中风,2:强风
|
||||
* */
|
||||
int jlsp_get_wind_detect_info(int *wd_flag, int *wd_val, int *wd_lev);
|
||||
|
||||
#endif/*_COMMPROC_DMS_H_*/
|
||||
26
include_lib/media/cvp/commproc_ns.h
Normal file
26
include_lib/media/cvp/commproc_ns.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef _COMMPROC_NS_H_
|
||||
#define _COMMPROC_NS_H_
|
||||
|
||||
#include "generic/typedef.h"
|
||||
|
||||
typedef struct {
|
||||
char wideband;
|
||||
char mode;
|
||||
float AggressFactor;
|
||||
float MinSuppress;
|
||||
float NoiseLevel;
|
||||
} noise_suppress_param;
|
||||
|
||||
int noise_suppress_frame_point_query(noise_suppress_param *param);
|
||||
int noise_suppress_mem_query(noise_suppress_param *param);
|
||||
int noise_suppress_open(noise_suppress_param *param);
|
||||
int noise_suppress_close(void);
|
||||
int noise_suppress_run(short *in, short *out, int npoint);
|
||||
|
||||
enum {
|
||||
NS_CMD_NOISE_FLOOR = 1,
|
||||
NS_CMD_LOWCUTTHR,
|
||||
};
|
||||
int noise_suppress_config(u32 cmd, int arg, void *priv);
|
||||
|
||||
#endif/*_COMMPROC_NS_H_*/
|
||||
198
include_lib/media/cvp/commproc_tms.h
Normal file
198
include_lib/media/cvp/commproc_tms.h
Normal file
@ -0,0 +1,198 @@
|
||||
#ifndef _COMMPROC_DMS_H_
|
||||
#define _COMMPROC_DMS_H_
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "cvp_common.h"
|
||||
|
||||
/*agc类型定义*/
|
||||
#define AGC_EXTERNAL 0
|
||||
#define AGC_INTERNAL 1
|
||||
|
||||
//tms_cfg:
|
||||
typedef struct {
|
||||
u8 ver; //Ver:01
|
||||
u8 mic_again; //MIC增益,default:3(0~14)
|
||||
u8 fb_mic_again; //FB MIC增益,default:3(0~14)
|
||||
u8 dac_again; //DAC增益,default:22(0~31)
|
||||
|
||||
u8 talk_mic_ch; //主MIC通道选择
|
||||
u8 talk_ref_mic_ch; //副MIC通道选择
|
||||
u8 talk_fb_mic_ch; //FB通道选择
|
||||
|
||||
u8 enable_module; //使能模块
|
||||
u8 ul_eq_en; //上行EQ使能,default:enable(disable(0), enable(1))
|
||||
u8 agc_type;
|
||||
union {
|
||||
/*AGC*/
|
||||
struct {
|
||||
float ndt_fade_in; //单端讲话淡入步进default: 1.3f(0.1 ~ 5 dB)
|
||||
float ndt_fade_out; //单端讲话淡出步进default: 0.7f(0.1 ~ 5 dB)
|
||||
float dt_fade_in; //双端讲话淡入步进default: 1.3f(0.1 ~ 5 dB)
|
||||
float dt_fade_out; //双端讲话淡出步进default: 0.7f(0.1 ~ 5 dB)
|
||||
float ndt_max_gain; //单端讲话放大上限,default: 12.f(0 ~ 24 dB)
|
||||
float ndt_min_gain; //单端讲话放大下限,default: 0.f(-20 ~ 24 dB)
|
||||
float ndt_speech_thr; //单端讲话放大阈值,default: -50.f(-70 ~ -40 dB)
|
||||
float dt_max_gain; //双端讲话放大上限,default: 12.f(0 ~ 24 dB)
|
||||
float dt_min_gain; //双端讲话放大下限,default: 0.f(-20 ~ 24 dB)
|
||||
float dt_speech_thr; //双端讲话放大阈值,default: -40.f(-70 ~ -40 dB)
|
||||
float echo_present_thr; //单端双端讲话阈值,default:-70.f(-70 ~ -40 dB)
|
||||
} agc_ext;
|
||||
|
||||
/*JLSP AGC*/
|
||||
struct {
|
||||
int min_mag_db_level;
|
||||
int max_mag_db_level;
|
||||
int addition_mag_db_level;
|
||||
int clip_mag_db_level;
|
||||
int floor_mag_db_level;
|
||||
} agc_int;
|
||||
} agc;
|
||||
/*aec*/
|
||||
int aec_process_maxfrequency; //default:8000,range[3000:8000]
|
||||
int aec_process_minfrequency; //default:0,range[0:1000]
|
||||
int af_length; //default:128 range[128:256]
|
||||
/*nlp*/
|
||||
int nlp_process_maxfrequency; //default:8000,range[3000:8000]
|
||||
int nlp_process_minfrequency; //default:0,range[0:1000]
|
||||
float overdrive; //default:1,range[0:30]
|
||||
/*ans*/
|
||||
float aggressfactor; //default:1.25,range[1:2]
|
||||
float minsuppress; //default:0.04,range[0.01:0.1]
|
||||
float init_noise_lvl; //default:-75dB,range[-100:-30]
|
||||
/*enc*/
|
||||
int enc_process_maxfreq; //default:8000,range[3000:8000]
|
||||
int enc_process_minfreq; //default:0,range[0:1000]
|
||||
int sir_maxfreq; //default:3000,range[1000:8000]
|
||||
float mic_distance; //default:0.015,range[0.035:0.015]
|
||||
float target_signal_degradation;//default:1,range[0:1]
|
||||
float enc_aggressfactor; //default:1.f,range[0:4]
|
||||
float enc_minsuppress; //default:0.09f,range[0:0.1]
|
||||
float Tri_SnrThreshold0; //sir设定阈值
|
||||
float Tri_SnrThreshold1; //sir设定阈值
|
||||
float Tri_CompenDb; //mic增益补偿
|
||||
/*wn*/
|
||||
float wn_msc_th; //双麦非相关性阈值,default:0.6f(0 ~ 1)
|
||||
float ms_th; //麦增益能量阈值, default:80.f(0-255)dB
|
||||
int wn_gain_offset; //风噪能量增益偏移阈值
|
||||
|
||||
} _GNU_PACKED_ AEC_TMS_CONFIG;
|
||||
|
||||
struct tms_attr {
|
||||
u8 ul_eq_en: 1;
|
||||
u8 wideband: 1;
|
||||
u8 wn_en: 1;
|
||||
u8 dly_est : 1;
|
||||
u8 aptfilt_only: 1;
|
||||
u8 reserved: 3;
|
||||
|
||||
u8 dst_delay;/*延时估计目标延时*/
|
||||
u8 EnableBit;
|
||||
u8 FB_EnableBit;
|
||||
u8 packet_dump;
|
||||
u8 SimplexTail;
|
||||
u8 output_sel;/*dms output选择*/
|
||||
u16 hw_delay_offset;/*dac hardware delay offset*/
|
||||
u16 wn_gain;/*white_noise gain*/
|
||||
u8 agc_type; /*agc类型*/
|
||||
/*AGC*/
|
||||
float AGC_NDT_fade_in_step; //in dB
|
||||
float AGC_NDT_fade_out_step; //in dB
|
||||
float AGC_NDT_max_gain; //in dB
|
||||
float AGC_NDT_min_gain; //in dB
|
||||
float AGC_NDT_speech_thr; //in dB
|
||||
float AGC_DT_fade_in_step; //in dB
|
||||
float AGC_DT_fade_out_step; //in dB
|
||||
float AGC_DT_max_gain; //in dB
|
||||
float AGC_DT_min_gain; //in dB
|
||||
float AGC_DT_speech_thr; //in dB
|
||||
float AGC_echo_present_thr; //In dB
|
||||
int AGC_echo_look_ahead; //in ms
|
||||
int AGC_echo_hold; // in ms
|
||||
/*jlsp agc*/
|
||||
int min_mag_db_level;
|
||||
int max_mag_db_level;
|
||||
int addition_mag_db_level;
|
||||
int clip_mag_db_level;
|
||||
int floor_mag_db_level;
|
||||
/*AEC*/
|
||||
int aec_process_maxfrequency; //default:8000,range[3000:8000]
|
||||
int aec_process_minfrequency; //default:0,range[0:1000]
|
||||
int af_length; //default:128 range[128:256]
|
||||
/*NLP*/
|
||||
int nlp_process_maxfrequency; //default:8000,range[3000:8000]
|
||||
int nlp_process_minfrequency; //default:0,range[0:1000]
|
||||
float overdrive; //default:1,range[0:30]
|
||||
/*ANS*/
|
||||
float aggressfactor; //default:1.25,range[1:2]
|
||||
float minsuppress; //default:0.04,range[0.01:0.1]
|
||||
float init_noise_lvl; //default:-75db,range[-100:-30]
|
||||
/*DNS Parameters*/
|
||||
float DNS_highGain; //EQ强度 range[1.0:3.5]
|
||||
float DNS_rbRate; //混响强度 range[0:0.9];
|
||||
int enhance_flag; //是否高频增强 range[0,1]
|
||||
/*ENC*/
|
||||
int Tri_CutTh; //fb麦统计截止频率
|
||||
float Tri_SnrThreshold0; //sir设定阈值
|
||||
float Tri_SnrThreshold1; //sir设定阈值
|
||||
float *Tri_TransferFunc; //fb -> main传递函数
|
||||
float Tri_FbCompenDb; //fb补偿增益
|
||||
int Tri_TfEqSel; //eq,传递函数的选择:0选择eq,1选择传递函数,2选择传递函数和eq
|
||||
int enc_process_maxfreq; //default:8000,range[3000:8000]
|
||||
int enc_process_minfreq; //default:0,range[0:1000]
|
||||
int sir_maxfreq; //default:3000,range[1000:8000]
|
||||
float mic_distance; //default:0.015,range[0.035:0.015]
|
||||
float target_signal_degradation;//default:1,range[0:1]
|
||||
float enc_aggressfactor; //default:4.f,range[0:4]
|
||||
float enc_minsuppress; //default:0.09f,range[0:0.1]
|
||||
float Tri_CompenDb; //mic增益补偿, dB
|
||||
int Tri_Bf_Enhance; //bf是否高频增强
|
||||
/*wn*/
|
||||
float wn_msc_th; //双麦非相关性阈值,default:0.6f(0 ~ 1)
|
||||
float ms_th; //麦增益能量阈值, default:80.f(0-255)dB
|
||||
int wn_gain_offset; //风噪能量增益偏移阈值
|
||||
/*common*/
|
||||
float global_minsuppress; //default:0.0,range[0.0:0.09]
|
||||
/*data handle*/
|
||||
int (*cvp_advanced_options)(void *aec,
|
||||
void *nlp,
|
||||
void *ns,
|
||||
void *enc,
|
||||
void *agc,
|
||||
void *wn,
|
||||
void *mfdt);
|
||||
int (*aec_probe)(short *mic0, short *mic2, short *mic3, short *ref, u16 len);
|
||||
int (*aec_post)(s16 *dat, u16 len);
|
||||
int (*aec_update)(u8 EnableBit);
|
||||
int (*output_handle)(s16 *dat, u16 len);
|
||||
|
||||
/*Extended-Parameters*/
|
||||
u16 ref_sr;
|
||||
u16 ref_channel; /*参考数据声道数*/
|
||||
u16 adc_ref_en; /*adc回采参考数据使能*/
|
||||
};
|
||||
|
||||
s32 aec_tms_init(struct tms_attr *attr);
|
||||
s32 aec_tms_exit();
|
||||
s32 aec_tms_fill_in_data(void *dat, u16 len);
|
||||
int aec_tms_fill_in_ref_data(void *dat, u16 len);
|
||||
int aec_tms_fill_in_ref_1_data(void *dat, u16 len);
|
||||
s32 aec_tms_fill_ref_data(void *dat, u16 len);
|
||||
void aec_tms_toggle(u8 toggle);
|
||||
int aec_tms_cfg_update(AEC_TMS_CONFIG *cfg);
|
||||
int aec_tms_reboot(u8 enablebit);
|
||||
|
||||
int cvp_tms_read_ref_data(void);
|
||||
|
||||
/*
|
||||
* 获取风噪检测信息
|
||||
* wd_flag: 0 没有风噪,1 有风噪
|
||||
* 风噪强度r: 0~BIT(16)
|
||||
* wd_lev: 风噪等级,0:弱风,1:中风,2:强风
|
||||
* */
|
||||
int jlsp_tms_get_wind_detect_info(int *wd_flag, int *wd_val, int *wd_lev);
|
||||
|
||||
/*tri_en: 1 正常3MIC降噪
|
||||
* 0 变成2MIC降噪,不使用 FB MIC数据*/
|
||||
int jlsp_tms_mode_choose(u8 tri_en);
|
||||
|
||||
#endif/*_COMMPROC_DMS_H_*/
|
||||
60
include_lib/media/cvp/cvp_common.h
Normal file
60
include_lib/media/cvp/cvp_common.h
Normal file
@ -0,0 +1,60 @@
|
||||
#ifndef _CVP_COMMON_H_
|
||||
#define _CVP_COMMON_H_
|
||||
|
||||
/*DMS版本定义*/
|
||||
#define DMS_GLOBAL_V100 0xB1
|
||||
#define DMS_GLOBAL_V200 0xB2
|
||||
|
||||
/*
|
||||
* V200新算法回声消除nlp模式
|
||||
* JLSP_NLP_MODE1: 模式1为单独的NLP回声抑制,回声压制会偏过,该模式下NLP模块可以单独开启
|
||||
* JLSP_NLP_MODE2: 模式2下回声信号会先经过AEC线性压制,然后进行NLP非线性压制
|
||||
* 此模式NLP不能单独打开需要同时打开AEC,使用AEC模块压制不够时,建议开启该模式
|
||||
*/
|
||||
#define JLSP_NLP_MODE1 0x01 //模式一(默认)
|
||||
#define JLSP_NLP_MODE2 0x02 //模式二
|
||||
|
||||
/*
|
||||
* V200新算法风噪降噪模式
|
||||
* JLSP_WD_MODE1: 模式1为常规的降风噪模式,风噪残余会偏大些
|
||||
* JLSP_WD_MODE2: 模式2为神经网络降风噪,风噪抑制会比较干净,但是会需要多消耗31kb的flash
|
||||
*/
|
||||
#define JLSP_WD_MODE1 0x01 //常规降噪
|
||||
#define JLSP_WD_MODE2 0x02 //nn降风噪,目前该算法启用会多31kflash
|
||||
|
||||
/*DMS输出选择*/
|
||||
typedef enum {
|
||||
DMS_OUTPUT_SEL_DEFAULT = 0, /*默认输出:dms处理后的数据*/
|
||||
DMS_OUTPUT_SEL_MASTER, /*主mic原始数据*/
|
||||
DMS_OUTPUT_SEL_SLAVE, /*副mic原始数据*/
|
||||
DMS_OUTPUT_SEL_FBMIC, /*FB mic原始数据*/
|
||||
} CVP_OUTPUT_ENUM;
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio CVP IOCTL
|
||||
* Description: CVP功能配置
|
||||
* Arguments : cmd 操作命令
|
||||
* value 操作数
|
||||
* priv 操作内存地址
|
||||
* Return : 0 成功 其他 失败
|
||||
* Note(s) : (1)比如动态开关降噪NS模块:
|
||||
* aec_dms_ioctl(CVP_NS_SWITCH,1,NULL); //降噪关
|
||||
* aec_dms_ioctl(CVP_NS_SWITCH,0,NULL); //降噪开
|
||||
*********************************************************************
|
||||
*/
|
||||
enum {
|
||||
CVP_AEC_SWITCH = 1,
|
||||
CVP_NLP_SWITCH,
|
||||
CVP_NS_SWITCH,
|
||||
CVP_AGC_SWITCH,
|
||||
CVP_ENC_SWITCH,
|
||||
CVP_AGC_MAX_LVL,
|
||||
};
|
||||
int aec_ioctl(int cmd, int value, void *priv);
|
||||
int aec_dms_ioctl(int cmd, int value, void *priv);
|
||||
int aec_dms_flexible_ioctl(int cmd, int value, void *priv);
|
||||
|
||||
|
||||
#endif /*_CVP_COMMON_H_*/
|
||||
|
||||
260
include_lib/media/cvp/lib_h/jlsp_ns.h
Normal file
260
include_lib/media/cvp/lib_h/jlsp_ns.h
Normal file
@ -0,0 +1,260 @@
|
||||
#ifndef __JLSP_NS_H__
|
||||
#define __JLSP_NS_H__
|
||||
|
||||
//出现单个麦掩蔽参数
|
||||
typedef struct {
|
||||
float detect_time;//检测时间
|
||||
float detect_eng_diff_thr; /*0~-90 dB 两个mic能量差异持续大于此阈值超过检测时间则会检测为故障*/
|
||||
float detect_eng_lowerbound;// 0~-90 dB start detect when mic energy lower than this
|
||||
int MalfuncDet_MaxFrequency;//检测频率上限
|
||||
int MalfuncDet_MinFrequency;//检测频率下限
|
||||
int OnlyDetect;// 0 -> 故障切换到单mic模式, 1-> 只检测不切换
|
||||
} JLSP_dms_micsel_cfg;
|
||||
|
||||
//beamforming参数设置
|
||||
|
||||
typedef struct {
|
||||
int UseExWeight; //挂空
|
||||
int *ENC_WeightA; //挂空
|
||||
int *ENC_WeightB; //挂空
|
||||
int ENC_Weight_Q; //挂空
|
||||
|
||||
int ENC_Process_MaxFrequency; //设定enc处理的最大频率,设定范围(3000~8000),默认8000
|
||||
int ENC_Process_MinFrequency; //设定enc处理的最小频率,设定范围(0~1000),默认为0
|
||||
int SIR_MaxFrequency; //设定enc信噪比处理最大频率,设定范围(1000~8000),默认3000
|
||||
float Mic_Distance; //设定主副mic的距离,单位(m),范围(0.015~35),默认0.015
|
||||
float Target_Signal_Degradation; //根据主副麦能量的diff值,设定范围(0~1),默认1.0
|
||||
float AggressFactor; //设置enc压制强度,设定范围(0~4),默认4
|
||||
float minSuppress; //设定enc抑制的最小值,设定范围(0~0.1),默认0.09
|
||||
|
||||
float compen_db; //补偿增益控制,单位(db),具体调节配合麦的增益协同调节,一般设定范围为(0~20)
|
||||
int bf_enhance; //该值默认设置为0,设为1时,高频成分会丰富些,但是低信噪比下高频噪声也会偏大
|
||||
int lowFreqHoldEn;
|
||||
float bfSupressFactor;
|
||||
} JLSP_dms_bf_cfg;
|
||||
|
||||
/*3麦降噪参数*/
|
||||
typedef struct {
|
||||
int Tri_CutTh; //fb麦统计截止频率
|
||||
float Tri_SnrThreshold0; //sir设定阈值
|
||||
float Tri_SnrThreshold1; //sir设定阈值
|
||||
float *Tri_TransferFunc; //fb -> main传递函数
|
||||
float Tri_FbAlignedDb; //fb和主副麦之间需要补偿增益
|
||||
float Tri_FbCompenDb; //fb补偿增益
|
||||
int Tri_TfEqSel; //eq,传递函数的选择:0选择eq,1选择传递函数,2选择传递函数和eq
|
||||
//int Tri_TransferMode; //传递函数模式选择,0:基于幅度的传递函数,1:基于幅度和相位的传递函数
|
||||
|
||||
|
||||
int Tri_Process_MaxFrequency;
|
||||
int Tri_Process_MinFrequency;
|
||||
int Tri_SIR_MaxFrequency;
|
||||
float Tri_Mic_Distance;
|
||||
float Tri_Target_Signal_Degradation;
|
||||
float Tri_AggressFactor;
|
||||
float Tri_MinSuppress;
|
||||
|
||||
float Tri_CompenDb; //mic增益补偿
|
||||
int Tri_Bf_Enhance;
|
||||
int Tri_LowFreqHoldEn;
|
||||
float Tri_SupressFactor;
|
||||
|
||||
} JLSP_tri_cfg;
|
||||
|
||||
//回声消除设置参数
|
||||
typedef struct {
|
||||
int AEC_Process_MaxFrequency; //设定回声消除处理的最大频率,设定范围(3000~8000),默认值为8000
|
||||
int AEC_Process_MinFrequency; //设定回声消除处理的最小频率,设定范围(0~1000),默认值为0
|
||||
int AF_Length; //挂空
|
||||
float muf; //设定aec滤波器的学习速率,默认0.02,设定范围(0.0001~0.5)
|
||||
} JLSP_dms_aec_cfg;
|
||||
|
||||
|
||||
//非线性回声压制设置参数
|
||||
typedef struct {
|
||||
int NLP_Process_MaxFrequency; //设定回声抑制的最大频率,设定范围(3000~8000),默认值为8000
|
||||
int NLP_Process_MinFrequency; //设定回声抑制的最小频率,设定范围(0~1000),默认值为0
|
||||
float OverDrive; //定设压制强度,越大压制越强,设定范围(0~5)默认为1.0
|
||||
} JLSP_dms_nlp_cfg;
|
||||
|
||||
|
||||
//dns参数设置
|
||||
typedef struct {
|
||||
float AggressFactor; //降噪强度,设置范围(0.3~6.0),默认值:1.0
|
||||
float minSuppress; //增益最小值控制,越小降噪越强,设置范围(0.0~1.0),默认为0.1
|
||||
float init_noise_lvl; //初始噪声水平
|
||||
float high_gain; //单麦高频增强,默认设置为1.0,设置范围为(1.0~3.0)
|
||||
float rb_rate; //单麦混响增强,默认设置为0.1,设置范围为(0~0.9)
|
||||
int enhance_flag; //是否开启双麦高频增强,默认为1
|
||||
} JLSP_dms_dns_cfg;
|
||||
|
||||
typedef struct {
|
||||
int min_mag_db_level; //语音能量放大下限阈值(单位db,默认-50,范围(-90db~-35db))
|
||||
int max_mag_db_level; //语音能量放大上限阈值(单位db,默认-3,范围(-90db~0db))
|
||||
int addition_mag_db_level; //语音补偿能量值(单位db,默认0,范围(0db~20db))
|
||||
int clip_mag_db_level; //语音最大截断能量值(单位db,默认-3,范围(-10db~db))
|
||||
int floor_mag_db_level; //语音最小截断能量值(单位db,默认-70,范围(-90db~-35db)
|
||||
} JLSP_agc_cfg;
|
||||
|
||||
//风噪检测参数设置
|
||||
typedef struct {
|
||||
float wn_msc_th; //双麦非相关性阈值 (0-1)
|
||||
float ms_th; //麦增益能量阈值(0-255)
|
||||
int wn_inty1;
|
||||
int wn_inty2;
|
||||
float wn_gain1;
|
||||
float wn_gain2;
|
||||
|
||||
int t1_bot; //低风噪等级能量下限阈值
|
||||
int t1_top; //低风噪等级能量上限阈值
|
||||
int t2_bot; //强风噪等级能量下限阈值
|
||||
int t2_top; //强风噪等级能量上限阈值
|
||||
int offset; //风噪能量增益偏移阈值
|
||||
|
||||
int t1_bot_cnt_limit; //风强变到弱风等级连续帧数计数,位宽16bit
|
||||
int t1_top_cnt_limit; //风强由弱风变到中风等级连续帧数计数,位宽16bit
|
||||
int t2_bot_cnt_limit; //风强由强风变到中风连续帧数计数,位宽16bit
|
||||
int t2_top_cnt_limit; //风强变到强风连续帧数计数,位宽16bit
|
||||
} JLSP_dms_wind_cfg;
|
||||
|
||||
/*
|
||||
gain_floor: 增益的最小值控制,范围0~1,建议值(0~0.2)之间
|
||||
over_drive: 控制降噪强度:
|
||||
0 < over_drive < 1,越小降噪强度越轻,太小噪声会很大;
|
||||
over_drive = 1,正常降噪
|
||||
over_drive > 1,降噪强度加强,越大降噪强度越强,太大会吃音
|
||||
建议调节范围0.3~3之间来控制降噪强度的强弱
|
||||
high_gain: 控制声音的宏亮度,范围(1.0f~3.5f),越大声音越宏亮,太大可能会使噪声增加, 为1.0f表示不做增强, 建议设置2.0f左右
|
||||
rb_rate: 混响强度,设置范围(0.0f~0.9f),越大混响越强, 为0.0f表示不增强, 建议默认设置0.5f
|
||||
*/
|
||||
|
||||
void *JLSP_ns_init(char *private_buffer, char *shared_buffer, float gain_floor, float over_drive, float high_gain, float rb_rate, int samplerate, const int is_dual);
|
||||
int JLSP_ns_get_heap_size(int *private_size, int *shared_size, int samplerate, int is_dual);
|
||||
|
||||
int JLSP_ns_reset(void *m);//单双麦共用
|
||||
void JLSP_ns_update_shared_buffer(void *m, char *shared_buffer);//单双麦共用
|
||||
int JLSP_ns_process(void *m, void *input, void *output, int *outsize);
|
||||
int JLSP_ns_free(void *m);//单双麦共用
|
||||
|
||||
void JLSP_ns_set_noiselevel(void *m, float noise_level_init);//单双麦共用
|
||||
|
||||
|
||||
/*功能:初始化snr相关参数
|
||||
* stop_freq: 高通滤波器的截止频率
|
||||
* snr_th: 人声阈值设定,即大于该值才会进行snr压制处理, 采用db进行设置, 默认-25db
|
||||
* commpress_params: 压制系数
|
||||
* 0db一下分为了5个区间进行压缩,压缩系数范围(0~3),越大压制越强,建议范围(0~1.0f)
|
||||
* snr < -10, 压制系数compress_params[4]
|
||||
* snr < -8, 压制系数compress_params[3]
|
||||
* snr < -5, 压制系数compress_params[2]
|
||||
* snr < -3, 压制系数compress_params[1]
|
||||
* snr < 0, 压制系数compress_params[0]
|
||||
*/
|
||||
void JLSP_init_snr(void *m, int stop_freq, int snr_th, float *compress_params);
|
||||
|
||||
/*功能: 获取当前帧snr
|
||||
* 返回:当前帧snr值
|
||||
*/
|
||||
float JLSP_get_snr(void *m);
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 双麦降噪接口
|
||||
*/
|
||||
void JLSP_wd_single(unsigned char wd_act);
|
||||
/*
|
||||
*wd_flag: 0: no wind 1: wind
|
||||
*wd_val: wind strong bit(16)
|
||||
*wd_lev: wind level 0:弱风,1:中风, 2:强风
|
||||
*/
|
||||
int JLSP_get_wd_info(void *handle, int *wd_flag, int *wd_val, int *wd_lev);
|
||||
|
||||
/*设置使用的模块*/
|
||||
void JLSP_enable_module(int Enablebit);//仅双麦使用
|
||||
|
||||
/*初始化*/
|
||||
void *JLSP_DualMicSystem_Init(char *private_buf,
|
||||
char *share_buf,
|
||||
void *aec_cfg,
|
||||
void *nlp_cfg,
|
||||
void *bf_cfg,
|
||||
void *dns_cfg,
|
||||
void *wn_cfg,
|
||||
void *micsel_cfg,
|
||||
int samplerate,
|
||||
int EnableBit);
|
||||
|
||||
/*数据处理,返回风噪大小*/
|
||||
int JLSP_DualMicSystem_Process(void *handle,
|
||||
short *near,
|
||||
short *near_ref,
|
||||
short *far,
|
||||
short *out,
|
||||
int points);
|
||||
|
||||
//检测各个麦是否被堵住或者破坏相关信息
|
||||
/*获取单双麦切换状态
|
||||
* 0: 正常双麦 ;
|
||||
* 1: 副麦坏了,触发故障
|
||||
* -1: 主麦坏了,触发故障
|
||||
*/
|
||||
int JLSP_DualMicSystem_GetMicState(void *handle);
|
||||
/*
|
||||
* 获取mic的能量值,开了MFDT_EN才能用
|
||||
* mic: 0 获取主麦能量
|
||||
* mic:1 获取副麦能量
|
||||
* return:返回能量值,[0~90.3]
|
||||
*/
|
||||
float JLSP_DualMicSystem_GetMicEnergy(void *handle, unsigned char mic);
|
||||
/*设置初始使用单双麦切换状态
|
||||
* 0: 正常双麦 ;
|
||||
* 1: 副麦坏了,触发故障
|
||||
* -1: 主麦坏了,触发故障
|
||||
*/
|
||||
void JLSP_DualMicSystem_SetMicState(void *handle, int state);
|
||||
|
||||
//int JLSP_DualMicSystem_GetWdInfo(void* handle, int* wd_flag, int* wd_val, int* wd_lev);
|
||||
//int JLSP_DualMicSystem_Get_Size(int* private_size, int* share_size, int samplerate, const int is_dual);
|
||||
//int JLSP_DualMicSystem_Reset(void* m);
|
||||
//void JLSP_DualMicSystem_Update_Shared_Buffer(void* m, char* shared_buffer);
|
||||
//int JLSP_DualMicSystem_Free(void* m);
|
||||
//void JLSP_DualMicSystem_Set_Noiselevel(void* m, float noise_level_init);
|
||||
|
||||
/*
|
||||
* 三麦降噪接口
|
||||
*/
|
||||
/*设置使用的模块*/
|
||||
void JLSP_TriMicSystem_EnableModule(int Enablebit, int Enablebit_Ex);
|
||||
|
||||
/*获取风噪信息*/
|
||||
int JLSP_TriMicSystem_GetWdInfo(void *handle, int *wd_flag, int *wd_val, int *wd_lev);
|
||||
|
||||
/*获取buf大小*/
|
||||
int JLSP_TriMicSystem_Get_Size(int *private_size, int *share_size, int samplerate, const int is_dual);
|
||||
|
||||
/*初始化*/
|
||||
void *JLSP_TriMicSystem_Init(char *private_buf,
|
||||
char *share_buf,
|
||||
void *aec_cfg,
|
||||
void *nlp_cfg,
|
||||
void *tri_cfg,
|
||||
void *dns_cfg,
|
||||
void *wn_cfg,
|
||||
void *agc_cfg,
|
||||
int samplerate,
|
||||
int EnableBit);
|
||||
|
||||
/*数据处理,返回风噪大小*/
|
||||
int JLSP_TriMicSystem_Process(void *handle,
|
||||
short *near,
|
||||
short *near_ref,
|
||||
short *fb,
|
||||
short *far,
|
||||
short *out,
|
||||
int InDataLen);
|
||||
|
||||
/*tri_en: 1 正常3MIC降噪
|
||||
* 0 变成2MIC降噪,不使用 FB MIC数据*/
|
||||
void JLSP_TriMicSystem_ModeChoose(void *handle, unsigned char tri_en);
|
||||
#endif
|
||||
45
include_lib/media/diafx.h
Normal file
45
include_lib/media/diafx.h
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef __DIAFX_H__
|
||||
#define __DIAFX_H__
|
||||
|
||||
|
||||
#ifndef __Q8P24__
|
||||
#define __Q8P24__
|
||||
#endif
|
||||
|
||||
|
||||
#include<stdint.h>
|
||||
#include<string.h>
|
||||
|
||||
#ifndef __FMATH_H__
|
||||
#include "fmath.h"
|
||||
#endif // __FMATH_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
extern int diafx_size();
|
||||
|
||||
// create a DIA handler
|
||||
extern void *diafx_init_mode(int mode);
|
||||
|
||||
// clear buffer
|
||||
extern void diafx_clear();
|
||||
|
||||
//render raw pcm into processed one.
|
||||
extern uint32_t diafx_run_Q8P24(inumber **inPcms, inumber **outPcms, int numFrames);
|
||||
extern uint32_t diafx_run_Q8P24_interleave(inumber *inPcms, int numFrames);
|
||||
uint32_t diafx_run_Q8P24_int16_interleave(int16_t *inPcms, int numFrames);
|
||||
void diafx_enabled(int value);
|
||||
void diafx_toggle_enabled();
|
||||
uint32_t jl_platform_diafx_run(int16_t *inPcms, int numFrames);
|
||||
|
||||
#define diafx_init() diafx_init_mode(0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
139
include_lib/media/drc_api.h
Normal file
139
include_lib/media/drc_api.h
Normal file
@ -0,0 +1,139 @@
|
||||
#ifndef DRC_API_H
|
||||
#define DRC_API_H
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#define AT_DRC(x)
|
||||
#define AT_DRC_CODE
|
||||
#define AT_DRC_CONST
|
||||
#define AT_DRC_SPARSE_CODE
|
||||
#define AT_DRC_SPARSE_CONST
|
||||
|
||||
#else
|
||||
#define AT_DRC(x) __attribute((section(#x)))
|
||||
#define AT_DRC_CODE AT_DRC(.drc_code)
|
||||
#define AT_DRC_CONST AT_DRC(.drc_const)
|
||||
#define AT_DRC_SPARSE_CODE AT_DRC(.drc_sparse_code)
|
||||
#define AT_DRC_SPARSE_CONST AT_DRC(.drc_sparse_const)
|
||||
#endif
|
||||
|
||||
|
||||
enum {
|
||||
DATA_IN_SHORT = 0, //输入数据类型,输入short时,输出不能为int
|
||||
DATA_IN_INT,
|
||||
};
|
||||
enum {
|
||||
DATA_OUT_SHORT = 0, //输出数据类型,输入short时,输出不能为int
|
||||
DATA_OUT_INT
|
||||
};
|
||||
|
||||
enum {
|
||||
PEAK = 0, //算法类型
|
||||
RMS
|
||||
};
|
||||
|
||||
enum {
|
||||
PERPOINT = 0, //mode 模式
|
||||
TWOPOINT
|
||||
};
|
||||
|
||||
typedef struct _DrcParam {
|
||||
/*
|
||||
int *attackTime; //启动时间
|
||||
int *releaseTime; //释放时间
|
||||
float *threshold; //阈值{x1,y1,x2,y2} 最多5组十个数据
|
||||
int *ThresholdNum; //阈值的组数
|
||||
int *rmsTime; // rms时间 algorithm为RMS有效
|
||||
float *InputGain; // 输入增益(db)
|
||||
float *OutputGain; // 输出数据增益(db)
|
||||
unsigned char algorithm; // PEAK或者RMS
|
||||
unsigned char mode; // 模式
|
||||
unsigned char intype; // 输入数据类型
|
||||
unsigned char outtype; // 输出数据类型
|
||||
*/
|
||||
int channel;
|
||||
int sampleRate;
|
||||
int attackTime; //启动时间
|
||||
int releaseTime; //释放时间
|
||||
float *threshold; //阈值{x1,y1,x2,y2} 最多5组十个数据
|
||||
int ThresholdNum; //阈值的组数
|
||||
int rmsTime; // rms时间 algorithm为RMS有效
|
||||
float InputGain; // 输入增益(db)
|
||||
float OutputGain; // 输出数据增益(db)
|
||||
unsigned char algorithm; // PEAK或者RMS
|
||||
unsigned char mode; // 模式
|
||||
unsigned char intype; // 输入数据类型
|
||||
unsigned char outtype; // 输出数据类型
|
||||
int IndataInc; // 输入数据同个通道下个点的步进 例如左右左右 步进为2
|
||||
int OutdataInc; // 输出数据同个通道下个点的步进 例如左右左右 步进为2
|
||||
} DrcParam;
|
||||
|
||||
//int GetDrcBuf(int algorithm, int *rmsTime, int channel, int sampleRate);
|
||||
int GetDrcBuf(DrcParam *param); // bufsize 与 algorithm,rmsTime channel、 sampleRate有关
|
||||
//void DrcInit(void *WorkBuf, DrcParam *param, int channel, int sampleRate);
|
||||
void DrcInit(void *WorkBuf, DrcParam *param);
|
||||
void DrcUpdate(void *WorkBuf, DrcParam *param);
|
||||
int DrcRun(void *WorkBuf, void *indata, void *outdata, int per_channel_npoint);
|
||||
/* InputGain 输入数据放大或者缩小的db数(正数放大,负数缩小) */
|
||||
// inputgain 配2,表示总体增加2dB
|
||||
/* OutputGain 输出数据放大或者缩小的db数(正数放大,负数缩小) */
|
||||
#if 0
|
||||
int GetDrcBuf(int algorithm, int *rmsTime, int channel, int sampleRate);
|
||||
获取buf大小
|
||||
参数说明:
|
||||
algorithm:算法类型,PEAK或者RMS
|
||||
rmsTime:
|
||||
rms时间ms,算法类型为RMS时有效
|
||||
channel: 通道数
|
||||
sampleRate:
|
||||
采样率
|
||||
|
||||
void DrcInit(void *WorkBuf, int *attackTime, int *releaseTime, float *threshold, int *ThresholdNum, int *rmsTime, int channel, int sampleRate, int algorithm, int mode, int intype, int outtype);
|
||||
初始化
|
||||
参数说明:
|
||||
WorkBuf:
|
||||
运行buf
|
||||
attackTime:
|
||||
启动时间ms
|
||||
releaseTime:
|
||||
释放时间ms
|
||||
threshold:
|
||||
信号输入与对应的输出[in1, out1, in2, out2 ***排列] 最多5组数据, 3个阈值,4段
|
||||
ThresholdNum:
|
||||
信号输入与对应的输出组数
|
||||
rmsTime:
|
||||
rms时间ms
|
||||
channel:
|
||||
通道
|
||||
sampleRate:采样率
|
||||
algorithm:算法类型
|
||||
mode:模式
|
||||
intype:输入数据类型,DATA_IN_SHORT或者DATA_IN_INT
|
||||
outtype:
|
||||
输出数据类型,DATA_OUT_SHOR或者DATA_OUT_INT;若输入数据类型为DATA_IN_SHORT,输出类型只能设置为DATA_OUT_SHOR
|
||||
|
||||
void DrcUpdate(void *WorkBuf, int *attackTime, int *releaseTime, float *threshold, int *ThresholdNum, int channel, int sampleRate);
|
||||
更新参数:使用rms算法时,当rmsTime fs变化时因为buf会产生变化,只能初始化更新
|
||||
参数说明:
|
||||
WorkBuf:
|
||||
运行buf
|
||||
attackTime:
|
||||
启动时间ms
|
||||
releaseTime:
|
||||
释放时间ms
|
||||
threshold:
|
||||
信号输入与对应的输出[in1, out1, in2, out2 ***排列] 最多5组数据, 3个阈值,4段
|
||||
ThresholdNum:
|
||||
信号输入与对应的输出组数
|
||||
|
||||
int DrcRun(void *WorkBuf, void *indata, void *outdata, int per_channel_npoint);
|
||||
运行:输入输出数据类型,要跟初始化配置的数据类型对应
|
||||
WorkBuf:
|
||||
运行buf
|
||||
indata:输入数据
|
||||
outdata:输出数据
|
||||
per_channel_npoint:每个通道的样点数
|
||||
#endif
|
||||
|
||||
#endif // !DRC_API_H
|
||||
|
||||
108
include_lib/media/effect_sur_api.h
Normal file
108
include_lib/media/effect_sur_api.h
Normal file
@ -0,0 +1,108 @@
|
||||
#ifndef effectSUR_api_h__
|
||||
#define effectSUR_api_h__
|
||||
|
||||
/*单耳输入时,channel设置*/
|
||||
enum {
|
||||
EFFECT_CH_L = 0x10, //单声道输入,输出左声道
|
||||
EFFECT_CH_R = 0x20, //单声道输入,输出右声道
|
||||
EFFECT_CH2_L = 0x30, //双声道输入,输出2个左声道
|
||||
EFFECT_CH2_R = 0x40, //双声道输入,输出2个右声道
|
||||
};
|
||||
|
||||
enum {
|
||||
EFFECT_3D_TYPE0 = 0x01,
|
||||
EFFECT_3D_TYPE1 = 0x02, //这2个2选1 :如果都置上,优先用EFFECT_3D_TYPE1
|
||||
EFFECT_3D_LRDRIFT = 0x04,
|
||||
EFFECT_3D_ROTATE = 0x08, //这2个2选1 : 如果都置上,优先用EFFECT_3D_ROTATE
|
||||
EFFECT_3D_TYPE2 = 0x10,
|
||||
EFFECT_3D_LRDRIFT2 = 0x20,
|
||||
};
|
||||
|
||||
|
||||
typedef struct __SUR_FUNC_API_ {
|
||||
unsigned int (*need_buf)(int flag);
|
||||
unsigned int (*open)(unsigned int *ptr, int effectflag, int nch);
|
||||
unsigned int (*init)(unsigned int *ptr, int rotatestep, int damping, int feedback, int roomsize);
|
||||
unsigned int (*run)(unsigned int *ptr, short *inbuf, int len); // len是对点
|
||||
unsigned int (*switch_effect)(unsigned int *ptr, int effectflag, int rotatestep, int damping, int feedback, int roomsize);//新增的切换音效参数接口
|
||||
unsigned int (*switch_nch)(unsigned int *ptr, int nch);//新增的声道修改接口
|
||||
} SUR_FUNC_API;
|
||||
|
||||
|
||||
extern SUR_FUNC_API *get_sur_func_api();
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
因为复用其他音效的参数接口,所以还是用了4个参数,EFFECT_3D_TYPE2具体参数对应名称应该是 : {
|
||||
int rotatestep; //无效参数
|
||||
int rot60_100ms; //范围0到150
|
||||
int wetgain ; //范围0到100
|
||||
int delay ; //范围0到100
|
||||
}
|
||||
|
||||
默认参数可以用 FFECT_3D_TYPE2 {2, 90, 70, 100},
|
||||
|
||||
// 由于原本预留参数有些没留出来,为了可以调节频响之类的多效果,所以在原基础上通过把参数列表指针当做其中一个参数传进来
|
||||
// 如果 rot60_100ms小于0,wetgain=100的话, 那最后一个参数就是参数列表,这样就可以支持配置更多参数。
|
||||
|
||||
设置如下:
|
||||
|
||||
flag = EFFECT_3D_TYPE2;
|
||||
{ {2, -1, 100, surmode_present[MODE_SUR_KTV]},
|
||||
{2, -1, 100, surmode_present[MODE_SUR_3DTHE]},
|
||||
{2, -1, 100, surmode_present[MODE_SUR_HALL]},
|
||||
{2, -1, 100, surmode_present[MODE_SUR_VOICE]},
|
||||
{2, -1, 100, surmode_present[MODE_SUR_SUR]}
|
||||
}
|
||||
|
||||
|
||||
//其中参数示例:
|
||||
|
||||
enum {
|
||||
MODE_SUR_KTV = 0, //ktv模式
|
||||
MODE_SUR_3DTHE, //3D影院
|
||||
MODE_SUR_HALL, //音乐厅
|
||||
MODE_SUR_VOICE, //清澈人声
|
||||
MODE_SUR_SUR, //全景环绕
|
||||
MODE_SUR_MAX
|
||||
};
|
||||
|
||||
//dry,wet,delay,rot60,Erwet,Erfactor,Ewidth,Ertolate,predelay,width,diffusion,dampinglpf,basslpf,bassB
|
||||
const static int surmode_present[MODE_SUR_MAX][14] = {
|
||||
{80, 100, 35, 9000, 80, 80, 80, 80, 20, 100, 70, 6500, 4000, 18},
|
||||
{80, 100, 90, 10030, 90, 90, 90, 90, 18, 100, 75, 7000, 1000, 29},
|
||||
{80, 100, 100, 13000, 100, 100, 100, 100, 20, 100, 72, 9000, 50, 3},
|
||||
{80, 100, 20, 5010, 100, 70, 70, 100, 15, 100, 70, 5500, 3500, 60},
|
||||
{80, 100, 100, 10000, 80, 80, 80, 90, 10, 100, 72, 8000, 500, 15},
|
||||
};
|
||||
|
||||
|
||||
//dry,wet,delay,Erwet,Erfactor,Ewitdh,Ertolate,width,diffusion 范围都是 0到 100
|
||||
//rot60 范围是 0到15000, 单位ms
|
||||
//basslpf: 低频增强频率,范围 0到10000
|
||||
//dampinglpf: 高频衰减频率,范围 0到 10000
|
||||
//bassB: 低频增强比例
|
||||
|
||||
|
||||
混响调参说明:
|
||||
1.dry: 干声增益
|
||||
2.wet:
|
||||
整体效果声增益
|
||||
3.delay: 反射时间间隔,影响整体空间大小
|
||||
4.rot60:
|
||||
衰减60dB需要的时间, 即衰减速度,如果空间里面的物体吸声厉害,或者比较空旷,衰减比较快
|
||||
5.Erwet:早反射声的增益, 早反射声的存在 会让混响听起来更真实。但是不同的增益会影响听感上距离感,空间构造
|
||||
6.Erfactor: 早反射声的一个密集程度。 这个值大,早反射声之间间隔比较大。构造的空间感也会相对较大。 较小的话,就反射比较密集。空间感变小。
|
||||
7.Ewidth:影响早反射声左右声道的声音差异
|
||||
8.Ertolate:
|
||||
影响漫反射声音反馈的大小
|
||||
9.predelay:干声跟效果声的时间间隔。也会影响整体空间感。
|
||||
10.width:左右声道的差异,左右声道的差异,会产生立体感。(某些版本的sdk上该参数无效)
|
||||
11.diffusion: 发散程度, 影响 漫反射声音的变形程度。
|
||||
12.dampinglpf:高频衰减过度频率。反射声的一个频率衰减,这是一个斜着往下掉的曲线,影响了反射声中的高频分量。高频分量越多,整体音色越亮,但是成分太多,声音有些乱
|
||||
13.basslpf:反射声中的低频增强分量过度频率
|
||||
14.bassB:
|
||||
低频增强比例。 这里的低频增强,其实是压了高频。为了使整体频响不超过1,不引起反馈发散。所以加大了这个值感觉混响弱了。可以适量加大rot60或者Ertolate
|
||||
#endif
|
||||
#endif // reverb_api_h__
|
||||
105
include_lib/media/eq_config.h
Normal file
105
include_lib/media/eq_config.h
Normal file
@ -0,0 +1,105 @@
|
||||
#ifndef CONFIG_EFFECT_CORE_V2_ENABLE
|
||||
#include "application/eq_config.h"
|
||||
#else
|
||||
|
||||
#ifndef _EQ_CONFIG_H_
|
||||
#define _EQ_CONFIG_H_
|
||||
|
||||
#include "media/audio_eq.h"
|
||||
#include "media/audio_drc.h"
|
||||
#include "spinlock.h"
|
||||
#include "math.h"
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 用默认eq系数表的eq效果模式设置(设置模式,更新系数)
|
||||
@param mode:EQ_MODE_NORMAL, EQ_MODE_ROCK,EQ_MODE_POP,EQ_MODE_CLASSIC,EQ_MODE_JAZZ,EQ_MODE_COUNTRY, EQ_MODE_CUSTOM
|
||||
@return
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
int eq_mode_set(EQ_MODE mode);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq模式切换
|
||||
@param
|
||||
@return
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int eq_mode_sw(void);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 获取eq效果模式
|
||||
@param
|
||||
@return
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
EQ_MODE eq_mode_get_cur(void);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 设置custom系数表的某一段系数
|
||||
@param seg->index:第几段(从0开始)
|
||||
@param seg->iir_type:滤波器类型(EQ_IIR_TYPE_HIGH_PASS, EQ_IIR_TYPE_LOW_PASS, EQ_IIR_TYPE_BAND_PASS, EQ_IIR_TYPE_HIGH_SHELF,EQ_IIR_TYPE_LOW_SHELF)
|
||||
@param seg->freq:中心截止频率(20~22kHz)
|
||||
@param seg->gain:总增益(-18~18)
|
||||
@param seg->q : q值(0.3~30)
|
||||
@return
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int eq_mode_set_custom_seg(struct eq_seg_info *seg);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 获取custom系数表的增益、频率
|
||||
@param index:哪一段
|
||||
@param freq:中心截止频率
|
||||
@param gain:增益
|
||||
@return
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int eq_mode_set_custom_info(u16 index, int freq, float gain);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 获取某eq系数表一段eq的增益
|
||||
@param mode:哪个模式
|
||||
@param index:哪一段
|
||||
@return 增益
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
s8 eq_mode_get_gain(EQ_MODE mode, u16 index);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 获取某eq系数表一段eq的中心截止频率
|
||||
@param mode:EQ_MODE_NORMAL, EQ_MODE_ROCK,EQ_MODE_POP,EQ_MODE_CLASSIC,EQ_MODE_JAZZ,EQ_MODE_COUNTRY, EQ_MODE_CUSTOM
|
||||
@param index:哪一段
|
||||
@return 中心截止频率
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int eq_mode_get_freq(EQ_MODE mode, u16 index);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 设置用custom系数表一段eq的增益
|
||||
@param index:哪一段
|
||||
@param gain:增益
|
||||
@return
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int eq_mode_set_custom_param(u16 index, int gain);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 设置播歌用的eq系数表的总增益
|
||||
@param global_gain:总增益
|
||||
@param mode:枚举型EQ_MODE
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void set_global_gain(EQ_MODE mode, float global_gain);
|
||||
/*
|
||||
*mode:枚举型EQ_MODE
|
||||
*return 返回对应系数表的段数
|
||||
* */
|
||||
u8 eq_get_table_nsection(EQ_MODE mode);
|
||||
|
||||
#endif
|
||||
#endif /*CONFIG_EFFECT_CORE_V2_ENABLE*/
|
||||
74
include_lib/media/eq_func_define.h
Normal file
74
include_lib/media/eq_func_define.h
Normal file
@ -0,0 +1,74 @@
|
||||
#ifndef CONFIG_EFFECT_CORE_V2_ENABLE
|
||||
#include "application/eq_func_define.h"
|
||||
#else
|
||||
|
||||
#ifndef _EQ_FUNC_DEFINE_H
|
||||
#define _EQ_FUNC_DEFINE_H
|
||||
|
||||
#include "generic/typedef.h"
|
||||
|
||||
extern u32 EQ_PRIV_SECTION_NUM;
|
||||
extern u32 EQ_SECTION_NUM;
|
||||
extern const int const_eq_debug;
|
||||
extern const int config_audio_drc_en;
|
||||
extern const int config_audio_eq_en;
|
||||
enum {
|
||||
EQ_EN = BIT(0),//eq模式使能
|
||||
EQ_SUPPORT_OLD_VER_EN = BIT(1),//ac700N,使能该bit可版本0.7.1.0, 0.7.1.1
|
||||
EQ_LITE_VER_EN = BIT(2),//精简版版本eq驱动,不支持异步,不支持默认效果切换接口,仅支持文件解析
|
||||
EQ_ONLINE_EN = BIT(3), //在线调试模块使能
|
||||
EQ_FILE_EN = BIT(4),//打开支持文件解析,关闭则只能使用默认效果表做eq
|
||||
EQ_FILE_SWITCH_EN = BIT(5),//打开支持eq_cfg_hw.bin文件切换更新效果
|
||||
EQ_HIGH_BASS_EN = BIT(6),//eq内部集成的高低音接口使能
|
||||
EQ_HIGH_BASS_FADE_EN = BIT(7),//eq内部集成高低音淡入淡出效果方式使能,配合config_audio_eq_fade_step使用
|
||||
EQ_FILTER_COEFF_FADE_EN = BIT(8),//eq默认系数表效果切换,或者在线调试效果更新,使用淡入淡出方式,避免增益跳跃引起的杂音问题
|
||||
EQ_FILTER_COEFF_LIMITER_ZERO_EN = BIT(9),//
|
||||
EQ_HW_UPDATE_COEFF_ONLY_EN = BIT(10),// 有空闲的段可以使用,就不需要切换系数 */
|
||||
EQ_HW_LR_ALONE = BIT(11),//// 左右声道分开处理与bit(10),同时使能或关闭
|
||||
EQ_SUPPORT_32BIT_SYNC_EN = BIT(12),//// 支持同步方式32biteq
|
||||
EQ_SUPPORT_MULIT_CHANNEL_EN = BIT(13),//AC699N、AC700N eq是否支持多声道(3~8) 打开:支持 关闭:仅支持1~2声道
|
||||
EQ_HW_CROSSOVER_TYPE0_EN = BIT(14),//支持硬件分频器,且分频器使用序列进序列出,需使能BIT(13)
|
||||
EQ_HW_CROSSOVER_TYPE1_EN = BIT(15),//硬件分频器使用使用块出方式,会增加mem(该方式仅支持单声道处理)
|
||||
EQ_LR_DIVIDE_EN = BIT(16),//eq左右声道效果拆分,四声道时可能会使用
|
||||
EQ_ONLINE_FILE_SAVE = BIT(17),//eq在线调试保存到vm使能
|
||||
EQ_DRC_PROCESS_SPLIT = BIT(18),//eq/drc节点处理,支持拆分
|
||||
};
|
||||
|
||||
#define config_audio_eq_online_en (config_audio_eq_en & EQ_ONLINE_EN)
|
||||
#define config_audio_eq_file_en (config_audio_eq_en & EQ_FILE_EN)
|
||||
#define config_audio_eq_file_sw_en (config_audio_eq_en & EQ_FILE_SWITCH_EN)
|
||||
#define config_filter_coeff_fade_en (config_audio_eq_en & EQ_FILTER_COEFF_FADE_EN)
|
||||
#define config_high_bass_en (config_audio_eq_en & EQ_HIGH_BASS_EN)
|
||||
#define config_audio_eq_fade_en (config_audio_eq_en & EQ_HIGH_BASS_FADE_EN)
|
||||
#define config_filter_coeff_limit_zero (config_audio_eq_en & EQ_FILTER_COEFF_LIMITER_ZERO_EN)
|
||||
#define HW_EQ_UPDATE_COEFF_ONLY_EN (config_audio_eq_en & EQ_HW_UPDATE_COEFF_ONLY_EN)
|
||||
#define HW_EQ_LR_ALONE (config_audio_eq_en & EQ_HW_LR_ALONE)
|
||||
#define SUPPORT_32BIT_SYNC_EQ (config_audio_eq_en & EQ_SUPPORT_32BIT_SYNC_EN)
|
||||
#define hw_eq_support_multi_channels (config_audio_eq_en & EQ_SUPPORT_MULIT_CHANNEL_EN)
|
||||
#define hw_crossover_type0 (config_audio_eq_en & EQ_HW_CROSSOVER_TYPE0_EN)
|
||||
#define hw_crossover_type1 (config_audio_eq_en & EQ_HW_CROSSOVER_TYPE1_EN)
|
||||
#define config_eq_lite_en (config_audio_eq_en & EQ_LITE_VER_EN)
|
||||
#define config_eq_support_old_ver_en (config_audio_eq_en & EQ_SUPPORT_OLD_VER_EN)
|
||||
#define config_divide_en (config_audio_eq_en & EQ_LR_DIVIDE_EN)
|
||||
#define config_eq_online_file_save (config_audio_eq_en & EQ_ONLINE_FILE_SAVE)
|
||||
#define config_eq_drc_process_split (config_audio_eq_en & EQ_DRC_PROCESS_SPLIT)
|
||||
|
||||
extern const int config_audio_drc_en;
|
||||
enum {
|
||||
DRC_EN = BIT(0), //drc 使能
|
||||
DRC_NBAND_MERGING_ASM_EN = BIT(1),//drc 多带处理完后,多带合并使用汇编加速
|
||||
DRC_NBAND_DIS = BIT(2),//关闭drc多带
|
||||
DRC_LIMITER_DIS = BIT(3),//关闭drc限幅器
|
||||
DRC_COMPRESSOF_DIS = BIT(4),//关闭drc压缩器
|
||||
WDRC_TYPE_EN = BIT(5),//wdrc使能
|
||||
};
|
||||
|
||||
#define config_drc_limiter_en (!(config_audio_drc_en & DRC_LIMITER_DIS))
|
||||
#define config_drc_compressor_en (!(config_audio_drc_en & DRC_COMPRESSOF_DIS))
|
||||
#define config_drc_nband_en (!(config_audio_drc_en & DRC_NBAND_DIS))
|
||||
#define config_drc_nband_merg_asm_en (!(config_audio_drc_en & DRC_NBAND_MERGING_ASM_EN))
|
||||
#define config_wdrc_en (config_audio_drc_en & WDRC_TYPE_EN)
|
||||
|
||||
|
||||
#endif
|
||||
#endif /*CONFIG_EFFECT_CORE_V2_ENABLE*/
|
||||
144
include_lib/media/fmath.h
Normal file
144
include_lib/media/fmath.h
Normal file
@ -0,0 +1,144 @@
|
||||
#ifndef __FMATH_H__
|
||||
#define __FMATH_H__
|
||||
|
||||
#include<stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef INLINE
|
||||
#ifdef _MSC_VER
|
||||
#define INLINE __inline
|
||||
#else
|
||||
#define INLINE inline
|
||||
#endif /* _MSC_VER */
|
||||
#endif /* INLINE */
|
||||
|
||||
// typedef int32_t inumber;
|
||||
typedef int16_t inumber;
|
||||
|
||||
//#define __Q8P24__
|
||||
#define Q_PCM_16_MAX
|
||||
#define Q_PCM_16_MIN
|
||||
|
||||
// Qbits
|
||||
#ifdef __Q8P24__
|
||||
#define FIXED_FRACBITS 24
|
||||
#define Q_PCM_MAX 16609444
|
||||
#define Q_PCM_MIN -16609444
|
||||
#endif
|
||||
#ifdef __Q17P15__
|
||||
#define FIXED_FRACBITS 15
|
||||
#define Q_PCM_MAX 32767
|
||||
#define Q_PCM_MIN -32768
|
||||
#endif
|
||||
#ifdef __Q8P23__
|
||||
#define FIXED_FRACBITS 23
|
||||
#define Q_PCM_MAX 8304721
|
||||
#define Q_PCM_MIN -8304721
|
||||
#endif
|
||||
|
||||
#define Q_PCM_16_MAX 32767
|
||||
#define Q_PCM_16_MIN -32768
|
||||
|
||||
#define FIXED_RESOLUTION (1 << FIXED_FRACBITS)
|
||||
#define FIXED_INT_MASK (0xffffffffL << FIXED_FRACBITS)
|
||||
#define FIXED_FRAC_MASK (~FIXED_INT_MASK)
|
||||
|
||||
// square roots
|
||||
#define FIXED_SQRT_ERR (1 << (FIXED_FRACBITS - 10))
|
||||
|
||||
// fixedp2a
|
||||
#define FIXED_DECIMALDIGITS
|
||||
|
||||
#define FIXED_FRACBITS 16
|
||||
|
||||
// transform Iinteger or floating point into fixed point(Q-format)
|
||||
#ifdef __LINUX__
|
||||
#define PCM_N_INT_TO_Q( N, bits, Qbits ) (inumber)( (N)/(float)(1<<((bits)-1)) * (uint32_t)(1<<((Qbits))) )
|
||||
#define PCM_N_Q_TO_INT( Q, bits, Qbits ) ( (float)(Q)/(uint32_t)(1<<((Qbits))) * (uint32_t)(1<<((bits)-1)) )
|
||||
#define PCM_N_FLOAT_TO_Q(N,Qbits) (inumber)( (N) * (uint32_t)(1<<(Qbits)) )
|
||||
#define PCM_N_Q_TO_FLOAT(Q,Qbits) ( Q /(float)(1<<((Qbits))) )
|
||||
#endif
|
||||
|
||||
#define PCM_Q_RANGE(Q,Qbits) ( {\
|
||||
long v = Q;\
|
||||
long max = (uint32_t)(1 << ((Qbits)-1)) - 1;\
|
||||
if ( Q > max ) v = max;\
|
||||
else if ( Q < -max ) v = min;\
|
||||
v;\
|
||||
})
|
||||
|
||||
#ifdef __LINUX__
|
||||
#define Q_TO_FLOAT(Q) ( Q /(float)FIXED_RESOLUTION )
|
||||
#endif
|
||||
|
||||
#define Q_TO_INT(Q) ( (Q) >>FIXED_FRACBITS )
|
||||
#define FLOAT_TO_Q(N) (inumber)((N) * FIXED_RESOLUTION)
|
||||
#define INT_TO_Q(N) (inumber)((N) << FIXED_FRACBITS)
|
||||
#define Q_ADD(A,B) ((A) + (B))
|
||||
#define Q_SUB(A,B) ((A) - (B))
|
||||
#ifdef __Q17P15__
|
||||
#define Q_MUL(A,B) (int32_t)(((int32_t)(A) * (int32_t)(B)) >> FIXED_FRACBITS )
|
||||
#define Q_DIV(A,B) (int32_t)(((int32_t)(A)<<FIXED_FRACBITS) / (B))
|
||||
#define Q_INV(A) ((inumber)((((int32_t)1) << (2*FIXED_FRACBITS)) / (A)))
|
||||
#else
|
||||
#define Q_MUL(A,B) (int32_t)(((int64_t)(A) * (int64_t)(B)) >> FIXED_FRACBITS )
|
||||
#define Q_DIV(A,B) (int32_t)(((int64_t)(A)<<FIXED_FRACBITS) / (B))
|
||||
#define Q_INV(A) ((inumber)((((int64_t)1) << (2*FIXED_FRACBITS)) / (A)))
|
||||
#endif
|
||||
#define Q_MOD(A,B) ( (A) % (B) )
|
||||
#define Q_PART_INT(A) Q_TO_INT(A)
|
||||
#define Q_PART_FLOAT(A) ((A) & FIXED_FRAC_MASK)
|
||||
|
||||
|
||||
#ifdef __Q8P24__
|
||||
#define Q_PI 52707178
|
||||
#define Q_2PI 105414357
|
||||
#define Q_PIO2 26353589
|
||||
#define Q_PIO4 13176794
|
||||
#define Q_LNE 45605201
|
||||
#define Q_LN10 38630967
|
||||
#define Q_10LN10 7286252
|
||||
#else
|
||||
#define Q_PI 26353589
|
||||
#define Q_2PI 52707178
|
||||
#define Q_PIO2 13176794
|
||||
#define Q_PIO4 6588397
|
||||
#define Q_LNE 22802600
|
||||
#define Q_LN10 19315483
|
||||
#define Q_10LN10 3643126
|
||||
#endif
|
||||
|
||||
|
||||
#define qabs(A) ( ((A) < 0) ? (-A) : (A) )
|
||||
#define qfloor(A) ((A) & (0xffffffff<<FIXED_FRACBITS))
|
||||
static inline inumber qceil(inumber x)
|
||||
{
|
||||
inumber f = qfloor(x);
|
||||
if (f != x) {
|
||||
return f + INT_TO_Q(1);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
extern inumber qsin(inumber radian);
|
||||
extern inumber qcos(inumber radian);
|
||||
extern inumber qtan(inumber radian);
|
||||
extern inumber qlog(inumber value);
|
||||
extern inumber qlog10(inumber value);
|
||||
extern inumber qsqrt(inumber value);
|
||||
extern inumber qexp(inumber value);
|
||||
extern inumber qpow(inumber x, inumber y);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern C
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
57
include_lib/media/howling_api.h
Normal file
57
include_lib/media/howling_api.h
Normal file
@ -0,0 +1,57 @@
|
||||
#ifndef HOWLING_API_H
|
||||
#define HOWLING_API_H
|
||||
|
||||
#include "media/howling_pitchshifter_api.h"
|
||||
// #include "shiftPhase_api.h"
|
||||
#include "media/pemafrow_api.h"
|
||||
#include "media/audio_stream.h"
|
||||
|
||||
typedef struct s_howling_para {
|
||||
float notch_Q;//陷波器 Q值
|
||||
float notch_gain;//陷波器gain值
|
||||
int fade_time; //fade time
|
||||
float threshold; //初始化阈值
|
||||
// int depth; //陷波器深度
|
||||
// int bandwidth;//陷波器带宽
|
||||
int sample_rate;
|
||||
int channel;
|
||||
// float mode;//陷波器是否降采样
|
||||
} HOWLING_PARM_SET;
|
||||
|
||||
//啸叫抑制 NotchHowling:
|
||||
typedef struct _NotchHowlingParam {
|
||||
float Q; //Q值
|
||||
float gain; //增益
|
||||
int fade_n; //启动释放时间
|
||||
float threshold;
|
||||
} NotchHowlingParam;
|
||||
|
||||
|
||||
|
||||
typedef struct _HOWLING_API_STRUCT_ {
|
||||
HOWLING_PARM_SET parm; //陷波参数
|
||||
void *ptr; //运算buf指针
|
||||
HOWLING_PITCHSHIFT_PARM parm_2; //移频参数
|
||||
HOWLING_PITCHSHIFT_FUNC_API *func_api; //移频函数指针
|
||||
struct audio_stream_entry entry; // 音频流入口
|
||||
s16 *pre_buf;
|
||||
u32 sample_rate;
|
||||
u8 run_en;
|
||||
u8 mode;
|
||||
u8 update;
|
||||
} HOWLING_API_STRUCT;
|
||||
|
||||
// int get_howling_buf(void);
|
||||
// void howling_init(void *workbuf, int threshold, int depth, int bandwidth, int attackTime, int releaseTime, int Noise_threshold, int low_th_gain, int sampleRate, int channel);
|
||||
// int howling_run(void *workbuf, short *in, short *out, int len);
|
||||
int get_howling_buf(int sampleRate);
|
||||
// void howling_init(void *workbuf, int fade_n,float notch_gain,float notch_Q, int mode, int sampleRate);
|
||||
// void howling_init(void *workbuf, int fade_time, float notch_gain, float notch_Q, int sampleRate);
|
||||
void howling_init(void *workbuf, int fade_time, float notch_gain, float notch_Q, float threshold, int sampleRate);
|
||||
// void howling_run(void *workbuf, short *in, short *out, int len);
|
||||
int howling_run(void *workbuf, short *in, short *out, int len);
|
||||
|
||||
void SetHowlingDetection(void *workbuf, int OnlyDetection);
|
||||
float *getHowlingFreq(void *workbuf, int *num);
|
||||
|
||||
#endif
|
||||
63
include_lib/media/howling_pitchshifter_api.h
Normal file
63
include_lib/media/howling_pitchshifter_api.h
Normal file
@ -0,0 +1,63 @@
|
||||
|
||||
#ifndef HOWLING_pitchshifer_api_h__
|
||||
#define HOWLING_pitchshifer_api_h__
|
||||
|
||||
#ifndef u8
|
||||
#define u8 unsigned char
|
||||
#endif
|
||||
|
||||
#ifndef u16
|
||||
#define u16 unsigned short
|
||||
#endif
|
||||
|
||||
#ifndef s16
|
||||
#define s16 short
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef u32
|
||||
#define u32 unsigned int
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef s32
|
||||
#define s32 int
|
||||
#endif
|
||||
|
||||
#ifndef s16
|
||||
#define s16 signed short
|
||||
#endif
|
||||
|
||||
/*#define EFFECT_OLD_RECORD 0x01
|
||||
#define EFFECT_MOYIN 0x0*/
|
||||
//#define EFFECT_ROBORT_FLAG 0X04
|
||||
|
||||
enum {
|
||||
EFFECT_HOWLING_PS = 0x01, //1.5《=》12 ms
|
||||
EFFECT_HOWLING_HE = 0x02,
|
||||
EFFECT_HOWLING_FS = 0x04,
|
||||
};
|
||||
|
||||
enum {
|
||||
PLATFORM_BR30 = 0,
|
||||
PLATFORM_BR36 = 1
|
||||
};
|
||||
|
||||
typedef struct HOWLING_PITCHSHIFT_PARM_ {
|
||||
s16 ps_parm;
|
||||
s16 fe_parm;
|
||||
u32 effect_v;
|
||||
} HOWLING_PITCHSHIFT_PARM;
|
||||
|
||||
|
||||
|
||||
typedef struct _HOWLING_PITCHSHIFT_FUNC_API_ {
|
||||
u32(*need_buf)(int flag);
|
||||
void (*open)(void *ptr, u32 sr, HOWLING_PITCHSHIFT_PARM *pitchshift_obj); //中途改变参数,可以调init
|
||||
void (*run)(void *ptr, short *indata, short *outdata, int len); //len是多少个byte
|
||||
} HOWLING_PITCHSHIFT_FUNC_API;
|
||||
|
||||
extern HOWLING_PITCHSHIFT_FUNC_API *get_howling_ps_func_api();
|
||||
|
||||
#endif // reverb_api_h__
|
||||
|
||||
20
include_lib/media/jl_kws.h
Normal file
20
include_lib/media/jl_kws.h
Normal file
@ -0,0 +1,20 @@
|
||||
/*****************************************************************
|
||||
>file name : include_lib/media/jl_kws.h
|
||||
>create time : Thu 16 Dec 2021 10:48:56 AM CST
|
||||
*****************************************************************/
|
||||
#ifndef _JL_AUDIO_KWS_H_
|
||||
#define _JL_AUDIO_KWS_H_
|
||||
#include "typedef.h"
|
||||
|
||||
#define JL_KWS_WAKE_WORD 0
|
||||
#define JL_KWS_COMMAND_KEYWORD 1
|
||||
#define JL_KWS_CALL_KEYWORD 2
|
||||
|
||||
void *audio_kws_open(u8 mode, const char *file_name);
|
||||
|
||||
int audio_kws_detect_handler(void *kws, void *data, int len);
|
||||
|
||||
void audio_kws_close(void *kws);
|
||||
|
||||
#endif
|
||||
|
||||
44
include_lib/media/kws_event.h
Normal file
44
include_lib/media/kws_event.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*****************************************************************
|
||||
>file name : kws_event.h
|
||||
>author : lichao
|
||||
>create time : Fri 05 Nov 2021 10:11:40 AM CST
|
||||
*****************************************************************/
|
||||
#ifndef _AUDIO_KWS_EVENT_
|
||||
#define _AUDIO_KWS_EVENT_
|
||||
|
||||
enum audio_kws_event {
|
||||
KWS_EVENT_NULL = 0,
|
||||
|
||||
/*Hey xxx系列关键词*/
|
||||
KWS_EVENT_HEY_KEYWORD,
|
||||
|
||||
/*杰理唤醒词*/
|
||||
KWS_EVENT_XIAOJIE,
|
||||
|
||||
/*百度 -- 小度小度等系列命令词消息*/
|
||||
KWS_EVENT_XIAODU, /*小度小度*/
|
||||
|
||||
/*音乐关键词*/
|
||||
KWS_EVENT_PLAY_MUSIC, /*播放音乐*/
|
||||
KWS_EVENT_STOP_MUSIC, /*停止播放*/
|
||||
KWS_EVENT_PAUSE_MUSIC, /*暂停播放*/
|
||||
KWS_EVENT_VOLUME_UP, /*增大音量*/
|
||||
KWS_EVENT_VOLUME_DOWN, /*减小音量*/
|
||||
KWS_EVENT_PREV_SONG, /*上一首*/
|
||||
KWS_EVENT_NEXT_SONG, /*下一首*/
|
||||
|
||||
/*通话关键词*/
|
||||
KWS_EVENT_CALL_ACTIVE, /*接听电话*/
|
||||
KWS_EVENT_CALL_HANGUP, /*挂断电话*/
|
||||
|
||||
/*ANC系列关键词词*/
|
||||
KWS_EVENT_ANC_ON, /*打开降噪*/
|
||||
KWS_EVENT_ANC_OFF, /*关闭降噪*/
|
||||
KWS_EVENT_TRANSARENT_ON,/*打开通透*/
|
||||
|
||||
/*TODO*/
|
||||
|
||||
KWS_EVENT_MAX,
|
||||
};
|
||||
|
||||
#endif
|
||||
112
include_lib/media/media_develop/media/drc_api.h
Normal file
112
include_lib/media/media_develop/media/drc_api.h
Normal file
@ -0,0 +1,112 @@
|
||||
#ifndef DRC_API_H
|
||||
#define DRC_API_H
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#define AT_DRC(x)
|
||||
#define AT_DRC_CODE
|
||||
#define AT_DRC_CONST
|
||||
#define AT_DRC_SPARSE_CODE
|
||||
#define AT_DRC_SPARSE_CONST
|
||||
|
||||
#else
|
||||
#define AT_DRC(x) __attribute((section(#x)))
|
||||
#define AT_DRC_CODE AT_DRC(.drc_code)
|
||||
#define AT_DRC_CONST AT_DRC(.drc_const)
|
||||
#define AT_DRC_SPARSE_CODE AT_DRC(.drc_sparse_code)
|
||||
#define AT_DRC_SPARSE_CONST AT_DRC(.drc_sparse_const)
|
||||
#endif
|
||||
|
||||
|
||||
enum {
|
||||
DATA_IN_SHORT = 0, //输入数据类型,输入short时,输出不能为int
|
||||
DATA_IN_INT,
|
||||
};
|
||||
enum {
|
||||
DATA_OUT_SHORT = 0, //输出数据类型,输入short时,输出不能为int
|
||||
DATA_OUT_INT
|
||||
};
|
||||
|
||||
enum {
|
||||
PEAK = 0, //算法类型
|
||||
RMS
|
||||
};
|
||||
|
||||
enum {
|
||||
PERPOINT = 0, //mode 模式
|
||||
TWOPOINT
|
||||
};
|
||||
|
||||
int GetDrcBuf(int algorithm, int *rmsTime, int channel, int sampleRate);
|
||||
void DrcInit(void *WorkBuf, int *attackTime, int *releaseTime, float *threshold, int *ThresholdNum, int *rmsTime, int channel, int sampleRate, int algorithm, int mode, int intype, int outtype);
|
||||
void DrcUpdate(void *WorkBuf, int *attackTime, int *releaseTime, float *threshold, int *ThresholdNum, int mode);
|
||||
int DrcRun(void *WorkBuf, void *indata, void *outdata, int per_channel_npoint);
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
int GetDrcBuf(int algorithm, int *rmsTime, int channel, int sampleRate);
|
||||
获取buf大小
|
||||
参数说明:
|
||||
algorithm:算法类型,PEAK或者RMS
|
||||
rmsTime:
|
||||
rms时间ms,算法类型为RMS时有效
|
||||
channel: 通道数
|
||||
sampleRate:
|
||||
采样率
|
||||
/* float *threshold[5]; */
|
||||
struct threshold {
|
||||
float x ;
|
||||
float y ;
|
||||
}
|
||||
struct threshold ttt[2][5] //+ 90.3;
|
||||
|
||||
void DrcInit(void *WorkBuf, int *attackTime, int *releaseTime, float *threshold, int *ThresholdNum, int *rmsTime, int channel, int sampleRate, int algorithm, int mode, int intype, int outtype);
|
||||
初始化
|
||||
参数说明:
|
||||
WorkBuf:
|
||||
运行buf
|
||||
attackTime:
|
||||
启动时间ms
|
||||
releaseTime:
|
||||
释放时间ms
|
||||
threshold:
|
||||
信号输入与对应的输出[in1, out1, in2, out2 ***排列] 最多5组数据, 3个阈值,4段
|
||||
ThresholdNum:
|
||||
信号输入与对应的输出组数
|
||||
rmsTime:
|
||||
rms时间ms
|
||||
channel:
|
||||
通道
|
||||
sampleRate:采样率
|
||||
algorithm:算法类型
|
||||
mode:模式
|
||||
intype:输入数据类型,DATA_IN_SHORT或者DATA_IN_INT
|
||||
outtype:
|
||||
输出数据类型,DATA_OUT_SHOR或者DATA_OUT_INT;若输入数据类型为DATA_IN_SHORT,输出类型只能设置为DATA_OUT_SHOR
|
||||
|
||||
void DrcUpdate(void *WorkBuf, int *attackTime, int *releaseTime, float *threshold, int *ThresholdNum, int channel, int sampleRate);
|
||||
更新参数:使用rms算法时,当rmsTime fs变化时因为buf会产生变化,只能初始化更新
|
||||
参数说明:
|
||||
WorkBuf:
|
||||
运行buf
|
||||
attackTime:
|
||||
启动时间ms
|
||||
releaseTime:
|
||||
释放时间ms
|
||||
threshold:
|
||||
信号输入与对应的输出[in1, out1, in2, out2 ***排列] 最多5组数据, 3个阈值,4段
|
||||
ThresholdNum:
|
||||
信号输入与对应的输出组数
|
||||
|
||||
int DrcRun(void *WorkBuf, void *indata, void *outdata, int per_channel_npoint);
|
||||
运行:输入输出数据类型,要跟初始化配置的数据类型对应
|
||||
WorkBuf:
|
||||
运行buf
|
||||
indata:输入数据
|
||||
outdata:输出数据
|
||||
per_channel_npoint:每个通道的样点数
|
||||
#endif
|
||||
|
||||
#endif // !DRC_API_H
|
||||
|
||||
112
include_lib/media/media_develop/media/sw_drc.h
Normal file
112
include_lib/media/media_develop/media/sw_drc.h
Normal file
@ -0,0 +1,112 @@
|
||||
#ifdef CONFIG_EFFECT_CORE_V2_ENABLE
|
||||
#include "media/sw_drc.h"
|
||||
#else
|
||||
|
||||
#ifndef __SW_DRC_H
|
||||
#define __SW_DRC_H
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "generic/list.h"
|
||||
#include "os/os_api.h"
|
||||
#include "drc_api.h"
|
||||
|
||||
#define DRC_TYPE_LIMITER 1
|
||||
#define DRC_TYPE_COMPRESSOR 2
|
||||
#define WDRC_TYPE 3 //wdc 要求,硬件输出24bit、32bit
|
||||
|
||||
|
||||
struct drc_limiter {
|
||||
int attacktime; //启动时间
|
||||
int releasetime; //释放时间
|
||||
int threshold[2]; //threshold[1]是固定值32768, threshold[0]为界面参数
|
||||
};
|
||||
|
||||
struct drc_compressor {
|
||||
int attacktime; //启动时间
|
||||
int releasetime; //释放时间
|
||||
int threshold[3]; //threshold[2]是固定值32768
|
||||
int ratio[3]; //ratio[0]为固定值100, ratio[1] ratio[2]为界面参数
|
||||
};
|
||||
|
||||
struct threshold_group {
|
||||
float in_threshold;
|
||||
float out_threshold;
|
||||
};
|
||||
|
||||
struct wdrc_struct {
|
||||
u16 attacktime; //启动时间
|
||||
u16 releasetime; //释放时间
|
||||
struct threshold_group threshold[7];
|
||||
u8 threshold_num;
|
||||
u8 rms_time;
|
||||
u8 algorithm;//0:PEAK 1:RMS
|
||||
u8 mode;//0:PERPOINT 1:TWOPOINT
|
||||
u16 holdtime; //预留位置
|
||||
u8 reverved[2];//预留位置
|
||||
};
|
||||
|
||||
//对耳wdrc处理,区分左右声道
|
||||
#define L_wdrc 0x10
|
||||
#define LL_wdrc 0x20
|
||||
#define R_wdrc 0x40
|
||||
#define RR_wdrc 0x80
|
||||
|
||||
struct drc_ch_org {
|
||||
u8 nband; //max<=3,1:全带 2:两段 3:三段
|
||||
u8 type; //0:没有使能限幅和压缩器,1:限幅器 2:压缩器 3:wdrc
|
||||
u8 reserved[2]; //reserved[1]保留,未用, reserved[0]记录了 多带限幅时,是否再开启一次全带限幅
|
||||
int low_freq; //中低频分频点
|
||||
int high_freq; //中高频分频点
|
||||
int order; //分频器阶数, 2或者4
|
||||
union {
|
||||
struct drc_limiter limiter[4]; //限幅器
|
||||
struct drc_compressor compressor[3];//压缩器
|
||||
} _p;
|
||||
};
|
||||
|
||||
struct drc_ch {
|
||||
u8 nband; //max<=3,1:全带 2:两段 3:三段
|
||||
u8 type; //0:没有使能限幅和压缩器,1:限幅器 2:压缩器 3:wdrc
|
||||
u8 reserved[2]; //reserved[1]保留,未用, reserved[0]记录了 多带限幅时,是否再开启一次全带限幅
|
||||
int low_freq; //中低频分频点
|
||||
int high_freq; //中高频分频点
|
||||
int order; //分频器阶数, 2或者4
|
||||
union {
|
||||
struct drc_limiter limiter[4]; //限幅器
|
||||
struct drc_compressor compressor[3];//压缩器
|
||||
struct wdrc_struct wdrc[4][2];// [][0]wdrc左声道,[][1]wdrc右声道
|
||||
} _p;
|
||||
};
|
||||
struct sw_drc {
|
||||
void *work_buf[4]; //drc内部驱动句柄
|
||||
void *crossoverBuf; //分频器句柄
|
||||
int *run_tmp[3]; //多带限幅器或压缩器,运行buf
|
||||
int run_tmp_len; //多带限幅器或压缩器,运行buf 长度
|
||||
u8 nband; //max<=3,1:全带 2:两段 3:三段
|
||||
u8 type; //0:没有使能限幅和压缩器,1:限幅器 2:压缩器
|
||||
u8 channel; //通道数
|
||||
u8 run32bit; //drc处理输入输出数据位宽是否是32bit 1:32bit 0:16bit
|
||||
struct audio_eq *crossover[3];//多带分频器eq句柄
|
||||
u32 sample_rate; //采样率
|
||||
u8 nsection; //分频器eq段数
|
||||
u8 other_band_en; //多带限幅器之后,是否需要再做一次全带的限幅器 1:需要,0:不需要
|
||||
};
|
||||
extern void *get_low_sosmatrix();
|
||||
extern void *get_high_sosmatrix();
|
||||
extern void *get_band_sosmatrix();
|
||||
extern int get_crossover_nsection();
|
||||
|
||||
|
||||
extern void *audio_sw_drc_open(struct drc_ch *ch_tmp, u32 sample_rate, u8 channel, u8 drc_name, u8 run32bit);
|
||||
extern void audio_sw_drc_close(void *hdl);
|
||||
extern int audio_sw_drc_update(void *hdl, struct drc_ch *ch_tmp, u32 sample_rate, u8 channel);
|
||||
extern int audio_sw_drc_run(void *hdl, s16 *in_buf, s16 *out_buf, int npoint_per_channel);
|
||||
|
||||
|
||||
void audio_hw_crossover_open(struct sw_drc *drc, int (*L_coeff)[3], u8 nsection);
|
||||
void audio_hw_crossover_close(struct sw_drc *drc);
|
||||
void audio_hw_crossover_run(struct sw_drc *drc, s16 *data, int len);
|
||||
void audio_hw_crossover_update(struct sw_drc *drc, int (*L_coeff)[3], u8 nsection);
|
||||
|
||||
#endif
|
||||
#endif /*CONFIG_EFFECT_CORE_V2_ENABLE*/
|
||||
11
include_lib/media/media_new/media/PLC.h
Normal file
11
include_lib/media/media_new/media/PLC.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef _PLC_H_
|
||||
#define _PLC_H_
|
||||
|
||||
#include "generic/typedef.h"
|
||||
|
||||
u32 PLC_query(void);
|
||||
s8 PLC_init(void *pbuf);
|
||||
void PLC_exit(void);
|
||||
void PLC_run(s16 *inbuf, s16 *outbuf, u16 point, u8 repair_flag);
|
||||
|
||||
#endif
|
||||
27
include_lib/media/media_new/media/Resample_api.h
Normal file
27
include_lib/media/media_new/media/Resample_api.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef __RESAMPLE_API_H__
|
||||
#define __RESAMPLE_API_H__
|
||||
|
||||
// #include "br18_dsp_Ecommon.h"
|
||||
|
||||
typedef struct _RS_IO_CONTEXT_ {
|
||||
void *priv;
|
||||
int(*output)(void *priv, void *data, int len);
|
||||
} RS_IO_CONTEXT;
|
||||
|
||||
typedef struct _RS_PARA_STRUCT_ {
|
||||
unsigned int new_insample;
|
||||
unsigned int new_outsample;
|
||||
int nch;
|
||||
} RS_PARA_STRUCT;
|
||||
|
||||
typedef struct _RS_STUCT_API_ {
|
||||
unsigned int(*need_buf)();
|
||||
void (*open)(unsigned int *ptr, RS_PARA_STRUCT *rs_para);
|
||||
void (*set_sr)(unsigned int *ptr, int newsrI);
|
||||
int(*run)(unsigned int *ptr, short *inbuf, int len, short *obuf); //len是n个点,返回n个点
|
||||
} RS_STUCT_API;
|
||||
|
||||
RS_STUCT_API *get_rs16_context();
|
||||
RS_STUCT_API *get_rsfast_context();
|
||||
|
||||
#endif
|
||||
233
include_lib/media/media_new/media/anc_btspp.h
Normal file
233
include_lib/media/media_new/media/anc_btspp.h
Normal file
@ -0,0 +1,233 @@
|
||||
#ifndef _ANC_BTSPP_H_
|
||||
#define _ANC_BTSPP_H_
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "asm/anc.h"
|
||||
|
||||
//前期训练 建议先做喇叭测试,再做MIC测试。这样内部可以通过喇叭判断MIC好不好
|
||||
//-------------------ANC SPP 协议 -------------------//
|
||||
|
||||
//父命令
|
||||
#define ANC_COMMAND_RESPO 0x00 //命令回复
|
||||
#define ANC_TRAIN_NOMA_MODE 0x01 //普通训练模式
|
||||
#define ANC_TRAIN_FAST_MODE 0x02 //快速训练模式
|
||||
|
||||
//训练工具子命令1
|
||||
#define ANC_CHANGE_COMMAND 0x00 //父命令模式切换
|
||||
#define ANC_MUTE_TARIN 0x01 //静音训练
|
||||
#define ANC_NOISE_TARIN 0x02 //噪声训练
|
||||
#define ANC_TARIN_AGAIN 0x03 //继续训练
|
||||
#define ANC_MODE_OFF 0x04 //ANC关
|
||||
#define ANC_MODE_ON 0x05 //ANC降噪模式
|
||||
#define ANC_TRAIN_EXIT 0x06 //ANC训练结束
|
||||
|
||||
#define ANC_PASS_MODE_ON 0x07 //ANC通透模式
|
||||
#define ANC_TRAIN_STEP_1 0x08 //ANC训练步进1
|
||||
#define ANC_TRAIN_STEP_2 0x09 //ANC训练步进2
|
||||
|
||||
|
||||
#define ANC_TRAIN_STEP_SET 0x15 //设置ANC训练步进
|
||||
#define ANC_SZ_LOW_THR_SET 0x16 //设置SZ MIC下限能量阈值
|
||||
#define ANC_FZ_LOW_THR_SET 0x17 //设置FZ MIC下限能量阈值
|
||||
#define ANC_SZ_ADAP_THR_SET 0x18 //设置SZ 自适应收敛阈值
|
||||
#define ANC_FZ_ADAP_THR_SET 0x19 //设置FZ 自适应收敛阈值
|
||||
#define ANC_AUTO_TS_EN_SET 0x1a //设置步进自适应微调使能
|
||||
|
||||
#define ANC_NONADAP_TIME_SET 0x1b //设置非自适应收敛时间
|
||||
#define ANC_SZ_ADAP_TIME_SET 0x1c //设置SZ自适应收敛时间
|
||||
#define ANC_FZ_ADAP_TIME_SET 0x1d //设置FZ自适应收敛时间
|
||||
#define ANC_WZ_TRAIN_TIME_SET 0x1e //设置WZ训练时间
|
||||
|
||||
|
||||
//以下为开发者测试指令
|
||||
#define ANC_DEVELOPER_MODE 0x20 //开发者模式
|
||||
#define ANC_TEST_NADAP 0x21 //关闭ANC自适应收敛
|
||||
#define ANC_TEST_ADAP 0x22 //开启ANC自适应收敛
|
||||
#define ANC_TEST_WZ_BREAK 0x23 //退出噪声训练
|
||||
#define ANC_CHANGE_MODE 0x24 //模式设置指令
|
||||
|
||||
#define ANC_TRAIN_STEP_CONNUTE 0x30 //继续找步进
|
||||
#define ANC_MUTE_TRAIN_GET_DATA 0x31 //获取静音训练的SPK MIC数据
|
||||
#define ANC_TRANS_MUTE_TARIN 0x32 //通透模式训练
|
||||
#define ANC_MIC_DMA_EXPORT_EN 0x50 //设置输出ANC 的MIC数据
|
||||
|
||||
#define ANC_REF_MIC_GAIN_SET 0x11 //设置参考MIC的增益
|
||||
#define ANC_ERR_MIC_GAIN_SET 0x12 //设置误差MIC的增益
|
||||
#define ANC_DAC_GAIN_SET 0x13 //设置DAC的模拟增益
|
||||
#define ANC_FFGAIN_SET 0x14 //设置ANC的数字增益
|
||||
#define ANC_FBGAIN_SET 0x1f //设置ANC的FBGAIN增益
|
||||
|
||||
#define ANC_SAMPLE_RATE_SET 0x40 //设置ANC采样率
|
||||
#define ANC_ORDER_SET 0x41 //设置ANC阶数
|
||||
#define ANC_TRANS_HPF_SET 0x42 //设置通透高通滤波器
|
||||
#define ANC_TRANS_LPF_SET 0x43 //设置通透低通滤波器
|
||||
#define ANC_TRANS_GAIN_SET 0x44 //设置通透增益
|
||||
#define ANC_TRANS_SAMPLE_RATE_SET 0x45 //设置通透采样率
|
||||
#define ANC_TRANS_ORDER_SET 0x46 //设置通透阶数
|
||||
|
||||
#define ANC_CMP_EN_SET 0x51 //设置CMP使能
|
||||
#define ANC_DRC_EN_SET 0x52 //设置DRC使能
|
||||
#define ANC_AHS_EN_SET 0x53 //设置AHS使能
|
||||
#define ANC_DCC_SEL_SET 0x54 //设置DCC档位
|
||||
#define ANC_GAIN_SIGN_SET 0x55 //设置ANC各类增益的符号
|
||||
#define ANC_NOISE_LVL_SET 0x56 //设置训练噪声等级
|
||||
#define ANC_CMP_GAIN_SET 0x57 //设置ANC左声道CMP增益
|
||||
#define ANC_RFF_GAIN_SET 0x58 //设置ANC右声道FF增益
|
||||
#define ANC_RFB_GAIN_SET 0x59 //设置ANC右声道FB增益
|
||||
#define ANC_RTRANS_GAIN_SET 0x5A //设置ANC右声道通透增益
|
||||
#define ANC_RCMP_GAIN_SET 0x5B //设置ANC右声道CMP增益
|
||||
#define ANC_DRCFF_ZERO_DET_SET 0x5C //设置DRCFF过零检测使能
|
||||
#define ANC_DRCFF_DAT_MODE_SET 0x5D //设置DRCFF_DAT模式
|
||||
#define ANC_DRCFF_LPF_SEL_SET 0x5E //设置DRCFF_LPF档位
|
||||
#define ANC_DRCFB_ZERO_DET_SET 0x5F //设置DRCFB过零检测使能
|
||||
#define ANC_DRCFB_DAT_MODE_SET 0x60 //设置DRCFB_DAT模式
|
||||
#define ANC_DRCFB_LPF_SEL_SET 0x61 //设置DRCFB_LPF档位
|
||||
#define ANC_DRCFF_LTHR_SET 0x62 //设置DRCFF_LOW阈值
|
||||
#define ANC_DRCFF_HTHR_SET 0x63 //设置DRCFF_HIGH阈值
|
||||
#define ANC_DRCFF_LGAIN_SET 0x64 //设置DRCFF_LOW增益
|
||||
#define ANC_DRCFF_HGAIN_SET 0x65 //设置DRCFF_HIGH增益
|
||||
#define ANC_DRCFF_NORGAIN_SET 0x66 //设置DRCFF_NOR增益
|
||||
#define ANC_DRCFB_LTHR_SET 0x67 //设置DRCFB_LOW阈值
|
||||
#define ANC_DRCFB_HTHR_SET 0x68 //设置DRCFB_HIGH阈值
|
||||
#define ANC_DRCFB_LGAIN_SET 0x69 //设置DRCFB_LOW增益
|
||||
#define ANC_DRCFB_HGAIN_SET 0x6A //设置DRCFB_HIGH增益
|
||||
#define ANC_DRCFB_NORGAIN_SET 0x6B //设置DRCFB_NOR增益
|
||||
#define ANC_DRCTRANS_LTHR_SET 0x6C //设置DRCTRANS_LOW阈值
|
||||
#define ANC_DRCTRANS_HTHR_SET 0x6D //设置DRCTRANS_HIGH阈值
|
||||
#define ANC_DRCTRANS_LGAIN_SET 0x6E //设置DRCTRANS_LOW增益
|
||||
#define ANC_DRCTRANS_HGAIN_SET 0x6F //设置DRCTRANS_HIGH增益
|
||||
#define ANC_DRCTRANS_NORGAIN_SET 0x70 //设置DRCTRANS_NOR增益
|
||||
#define ANC_AHS_DLY_SET 0x71 //设置啸叫抑制_DLY
|
||||
#define ANC_AHS_TAP_SET 0x72 //设置啸叫抑制_TAP
|
||||
#define ANC_AHS_WN_SHIFT_SET 0x73 //设置啸叫抑制_WN_SHIFT
|
||||
#define ANC_AHS_WN_SUB_SET 0x74 //设置啸叫抑制_WN_SUB
|
||||
#define ANC_AHS_SHIFT_SET 0x75 //设置啸叫抑制_SHIFT
|
||||
#define ANC_AHS_U_SET 0x76 //设置啸叫抑制步进
|
||||
#define ANC_AHS_GAIN_SET 0x77 //设置啸叫抑制增益
|
||||
#define ANC_FADE_STEP_SET 0x78 //设置淡入淡出步进
|
||||
#define ANC_AUDIO_DRC_THR_SET 0x79 //设置AUDIO DRC阈值
|
||||
#define ANC_AHS_NLMS_SEL_SET 0x7A //设置啸叫抑制NLMS
|
||||
#define ANC_R_FFMIC_GAIN_SET 0x7B //设置ANCR_FFMIC增益
|
||||
#define ANC_R_FBMIC_GAIN_SET 0x7C //设置ANCR_FBMIC增益
|
||||
#define ANC_FB_1ST_DCC_SET 0x7D //设置FB1阶DCC
|
||||
#define ANC_FF_2ND_DCC_SET 0x7E //设置FF2阶DCC
|
||||
#define ANC_FB_2ND_DCC_SET 0x7F //设置FB2阶DCC
|
||||
#define ANC_DRC_FF_2DCC_SET 0x80 //设置DRCFF动态DCC目标档位
|
||||
#define ANC_DRC_FB_2DCC_SET 0x81 //设置DRCFB动态DCC目标档位
|
||||
#define ANC_DRC_DCC_DET_TIME_SET 0x82 //设置DRC动态DCC检测时间
|
||||
#define ANC_DRC_DCC_RES_TIME_SET 0x83 //设置DRC动态DCC恢复时间
|
||||
//0x84-0x8A 36啸叫抑制参数使用
|
||||
#define ANC_ADAPTIVE_REF_FB_FRE 0x8B //设置自适应FB参考 Fre
|
||||
#define ANC_ADAPTIVE_REF_FB_G 0x8C //设置自适应FB参考 G
|
||||
#define ANC_ADAPTIVE_REF_FB_Q 0x8D //设置自适应FB参考 Q
|
||||
|
||||
#define ANC_ADAPTIVE_REF_EN 0x8E //金机曲线使能控制
|
||||
|
||||
#define ANC_LFF_GAIN_S_SET 0x8F //设置ANC左声道FF增益与符号
|
||||
#define ANC_LFB_GAIN_S_SET 0x90 //设置ANC左声道FB增益与符号
|
||||
#define ANC_LTRANS_GAIN_S_SET 0x91 //设置ANC左声道通透增益与符号
|
||||
#define ANC_LCMP_GAIN_S_SET 0x92 //设置ANC左声道CMP增益与符号
|
||||
|
||||
#define ANC_RFF_GAIN_S_SET 0x93 //设置ANC右声道FF增益与符号
|
||||
#define ANC_RFB_GAIN_S_SET 0x94 //设置ANC右声道FB增益与符号
|
||||
#define ANC_RTRANS_GAIN_S_SET 0x95 //设置ANC右声道通透增益与符号
|
||||
#define ANC_RCMP_GAIN_S_SET 0x96 //设置ANC右声道CMP增益与符号
|
||||
|
||||
|
||||
|
||||
//----------------耳机反馈子命令1---------------------//
|
||||
#define ANC_EXEC_SUCC 0x01 //执行成功
|
||||
#define ANC_EXEC_FAIL 0x02 //执行失败
|
||||
#define ANC_TRIM_MIC_WORK_FAIL 0x80|BIT(0) //MIC1工作不正常
|
||||
#define ANC_MIC_WORK_FAIL 0x80|BIT(1) //MIC0工作不正常
|
||||
#define ANC_TRIM_MIC_SNR_FAIL 0x80|BIT(2) //MIC1信噪比差
|
||||
#define ANC_MIC_SNR_FAIL 0x80|BIT(3) //MIC0信噪比差
|
||||
#define ANC_TRIM_MIC_NOISE_FAIL 0x80|BIT(4) //MIC1底噪高
|
||||
#define ANC_MIC_NOISE_FAIL 0x80|BIT(5) //MIC0底噪高
|
||||
//多种错误信息组合为|的形式,如MIC0/MIC1工作都不正常,则返回0x80|BIT(0)|BIT(1)
|
||||
|
||||
//---------------------spk_mic_dat param--------------//
|
||||
#define ANC_R_SPK_L_SPK 0x01 //高16bit R spk数据, 低16bit L spk 数据
|
||||
#define ANC_R_SPK_R_ERRMIC 0x02
|
||||
#define ANC_R_SPK_R_REFMIC 0x03
|
||||
#define ANC_L_SPK_L_ERRMIC 0x04
|
||||
#define ANC_L_SPK_L_REFMIC 0x05
|
||||
#define ANC_R_ERRMIC_R_REFMIC 0x06
|
||||
#define ANC_L_ERRMIC_L_REFMIC 0x07
|
||||
|
||||
//注意FF/FB/Hybrid/只能选择一种
|
||||
|
||||
#define ANC_MUTE_EN BIT(0) //通透静音训练使能
|
||||
#define ANC_NOISE_EN BIT(1) //通透噪声训练使能
|
||||
|
||||
|
||||
#define ANC_SPP_PACK_NUM 10 //数据包长度
|
||||
|
||||
#define ANC_SPP_MAGIC 0x55AA
|
||||
|
||||
enum {
|
||||
ANC_SZ_MUTE_STATUS = 0, //SZ非自适应(DAC静音)状态
|
||||
ANC_SZ_NADAP_STATUS, //SZ非自适应状态
|
||||
ANC_SZ_ADAP_STATUS, //SZ自适应状态
|
||||
ANC_FZ_MUTE_STATUS, //FZ非自适应(DAC静音)状态
|
||||
ANC_FZ_NADAP_STATUS, //FZ非自适应状态
|
||||
ANC_FZ_ADAP_STATUS, //FZ自适应状态
|
||||
ANC_WZ_NADAP_STATUS, //WZ非自适应状态
|
||||
ANC_WZ_ADAP_STATUS, //WZ自适应状态
|
||||
ANC_WZ_END_STATUS, //WZ训练结束
|
||||
};
|
||||
|
||||
enum {
|
||||
ANC_TRAIN_SZ = 0,
|
||||
ANC_TRAIN_FZ,
|
||||
ANC_TRAIN_WZ,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
u16 magic;
|
||||
u16 crc;
|
||||
u16 len;
|
||||
u8 dat[4];
|
||||
} anc_spp_data_t;
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
anc_train_para_t *para;
|
||||
audio_anc_t *param;
|
||||
u8 developer_mode; //开发者模式
|
||||
u8 noise_exit; //退出噪声训练
|
||||
u8 pow_dat[10];
|
||||
u8 status;
|
||||
u8 train_step_num;
|
||||
int *anc_gain;
|
||||
int *anc_fbgain;
|
||||
anc_spp_data_t rx_buf;
|
||||
anc_spp_data_t tx_buf;
|
||||
|
||||
} anc_spp_t;
|
||||
|
||||
typedef struct {
|
||||
u8 mode;
|
||||
u8 ff_en;
|
||||
u8 fb_en;
|
||||
u16 fb0_gain;
|
||||
u16 fb1_gain;
|
||||
} anc_train_reg_t;
|
||||
|
||||
|
||||
|
||||
void anc_debug_init(audio_anc_t *param);
|
||||
void anc_debug_uninit(void);
|
||||
int anc_spp_event_deal(u8 *dat);
|
||||
void anc_train_api_set(u8 cmd, u32 data, anc_train_para_t *para);
|
||||
int anc_spp_rx_packet(u8 *dat, u8 len);
|
||||
int anc_spp_tx_packet(u8 mode, u8 command, u16 command_dat);
|
||||
u8 anc_powdat_analysis(u32 pow);
|
||||
void anc_coeff_max_get(s32 *coeff, s32 *dat, u16 len, u8 type);
|
||||
|
||||
void anc_btspp_display_pow(anc_ack_msg_t *anc_ack);
|
||||
void anc_btspp_status_set(u8 status);
|
||||
|
||||
#endif/*_ANC_BTSPP_H_*/
|
||||
|
||||
35
include_lib/media/media_new/media/anc_uart.h
Normal file
35
include_lib/media/media_new/media/anc_uart.h
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef _ANC_DEBUG_H_
|
||||
#define _ANC_DEBUG_H_
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "generic/circular_buf.h"
|
||||
#include "system/includes.h"
|
||||
|
||||
#define ANC_CBUF_SIZE 8000
|
||||
typedef struct {
|
||||
/* struct audio_adc_output_hdl adc_output; */
|
||||
/* struct adc_mic_ch mic_ch; */
|
||||
/* s16 adc_buf[ADC_DM_BUFS_SIZE]; //align 4Bytes */
|
||||
/* s16 mic_tmp_data[ADC_DM_IRQ_POINTS]; */
|
||||
u8 rx_num;
|
||||
u8 print_num; //打印状态
|
||||
u8 tx_enable; //打印总开关
|
||||
u8 tx_host; //打印模式
|
||||
u32 tx_timeout; //超时打印时间,单位秒
|
||||
int rx_vaule;
|
||||
|
||||
char temp_strbuf[40];
|
||||
char temp_intbuf[12];
|
||||
u8 tx_buf[ANC_CBUF_SIZE];
|
||||
cbuffer_t tx_cb;
|
||||
int (*uart_write)(u8 *buf, u8 len);
|
||||
} anc_debug_t;
|
||||
extern anc_debug_t *anc_dbg;
|
||||
|
||||
void anc_uart_init(int (*uart_write_hdl)(u8 *buf, u8 len));
|
||||
int anc_intlog(u32 int_para, u8 log_more);
|
||||
int anc_strlog(char *str, u8 log_more);
|
||||
void anc_uart_ctl();
|
||||
int anc_uart_process(u8 *dat, int len);
|
||||
|
||||
#endif/*_ANC_DEBUG_H_*/
|
||||
426
include_lib/media/media_new/media/application/audio_dec_app.h
Normal file
426
include_lib/media/media_new/media/application/audio_dec_app.h
Normal file
@ -0,0 +1,426 @@
|
||||
|
||||
#ifndef _AUDIO_DEC_APP_H_
|
||||
#define _AUDIO_DEC_APP_H_
|
||||
|
||||
#include "asm/includes.h"
|
||||
#include "media/includes.h"
|
||||
#include "system/includes.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// 标签
|
||||
#define AUDIO_DEC_APP_MASK (('A' << 24) | ('D' << 16) | ('P' << 8) | ('M' << 8))
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// 解码状态
|
||||
enum audio_dec_app_status {
|
||||
AUDIO_DEC_APP_STATUS_STOP = 0,
|
||||
AUDIO_DEC_APP_STATUS_PLAY,
|
||||
AUDIO_DEC_APP_STATUS_PAUSE,
|
||||
};
|
||||
|
||||
// 解码事件
|
||||
enum audio_dec_app_event {
|
||||
AUDIO_DEC_APP_EVENT_NULL = 0,
|
||||
/*
|
||||
* Description: 解码预处理
|
||||
* Arguments : None.
|
||||
* Return : 0-正常,非0-挂起
|
||||
* Note(s) : (struct audio_dec_app_hdl*)hdl->handler->dec_probe中调用
|
||||
* 返回0后正常执行后续的audio_dec_app_probe_evt_cb_after()弱函数
|
||||
*/
|
||||
AUDIO_DEC_APP_EVENT_DEC_PROBE,
|
||||
/*
|
||||
* Description: 解码输出
|
||||
* Arguments : int parm[2]; param[0]:data, param[1]:len
|
||||
* Return : 不判断
|
||||
* Note(s) : (struct audio_dec_app_hdl*)hdl->decoder.entry.data_handler中调用
|
||||
* 仅用于查看更改内容,不改变数据长度,后续正常执行audio_stream_run()
|
||||
*/
|
||||
AUDIO_DEC_APP_EVENT_DEC_OUTPUT,
|
||||
/*
|
||||
* Description: 解码后处理
|
||||
* Arguments : None.
|
||||
* Return : 同.dec_post接口返回
|
||||
* Note(s) : (struct audio_dec_app_hdl*)hdl->handler->dec_post中调用
|
||||
*/
|
||||
AUDIO_DEC_APP_EVENT_DEC_POST,
|
||||
/*
|
||||
* Description: 解码停止
|
||||
* Arguments : None.
|
||||
* Return : 同.dec_stop接口返回
|
||||
* Note(s) : (struct audio_dec_app_hdl*)hdl->handler->dec_stop中调用
|
||||
*/
|
||||
AUDIO_DEC_APP_EVENT_DEC_STOP,
|
||||
/*
|
||||
* Description: 解码初始化完成
|
||||
* Arguments : None.
|
||||
* Return : 不判断
|
||||
* Note(s) : 解码start()函数中audio_decoder_start()函数前调用
|
||||
*/
|
||||
AUDIO_DEC_APP_EVENT_START_INIT_OK,
|
||||
/*
|
||||
* Description: 解码播放正常
|
||||
* Arguments : None.
|
||||
* Return : 不判断
|
||||
* Note(s) : 解码start()函数中audio_decoder_start()函数后调用
|
||||
*/
|
||||
AUDIO_DEC_APP_EVENT_START_OK,
|
||||
/*
|
||||
* Description: 解码播放失败
|
||||
* Arguments : None.
|
||||
* Return : 不判断
|
||||
* Note(s) : 解码start()函数中解码失败后调用
|
||||
*/
|
||||
AUDIO_DEC_APP_EVENT_START_ERR,
|
||||
/*
|
||||
* Description: 解码关闭
|
||||
* Arguments : None.
|
||||
* Return : 不判断
|
||||
* Note(s) : audio_dec_app_close()函数中各功能关闭后,audio_stream_close()之前调用
|
||||
*/
|
||||
AUDIO_DEC_APP_EVENT_DEC_CLOSE,
|
||||
/*
|
||||
* Description: 解码结束消息
|
||||
* Arguments : None.
|
||||
* Return : 不判断
|
||||
* Note(s) :
|
||||
*/
|
||||
AUDIO_DEC_APP_EVENT_PLAY_END,
|
||||
};
|
||||
|
||||
struct audio_dec_app_file_hdl {
|
||||
int (*read)(void *hdl, void *buf, u32 len);
|
||||
int (*seek)(void *hdl, int offset, int orig);
|
||||
int (*len)(void *hdl);
|
||||
};
|
||||
|
||||
struct audio_dec_app_hdl {
|
||||
u32 mask; // 固定为AUDIO_DEC_APP_MASK
|
||||
u32 id; // 唯一标识符,随机值
|
||||
struct list_head list_entry; // 链表
|
||||
struct audio_decoder decoder;
|
||||
struct audio_res_wait wait;
|
||||
struct audio_mixer_ch mix_ch;
|
||||
enum audio_channel ch_type;
|
||||
volatile enum audio_dec_app_status status;
|
||||
u32 ch_num : 4; // channel通道数
|
||||
u32 out_ch_num : 4; // 输出声道数
|
||||
u32 tmp_pause : 1;
|
||||
u32 dec_mix : 1; // 1:叠加模式
|
||||
u32 remain : 1;
|
||||
u32 frame_type : 1; // 1:frame格式;0:file格式
|
||||
u32 close_by_res_put : 1; //被打断就自动close
|
||||
|
||||
u32 mix_ext; // mixer ext out mask
|
||||
|
||||
u16 frame_pkt_len; // frame格式帧长
|
||||
u16 frame_data_len; // frame格式当前数据长度
|
||||
u8 *frame_buf; // frame格式帧buf
|
||||
|
||||
u32 dec_type; // 指定解码格式,start后为实际解码格式
|
||||
u16 sample_rate; // 指定采样率,start后为实际解码采样率
|
||||
|
||||
u16 src_out_sr; // 指定输出采样,不指定则和解码采样相同
|
||||
struct audio_src_handle *hw_src;
|
||||
|
||||
struct audio_decoder_task *p_decode_task;
|
||||
struct audio_mixer *p_mixer;
|
||||
|
||||
|
||||
int (*out_put)(void *, s16 *data, int len); // 解码输出回调。不设置,则输出到mixer
|
||||
void *out_priv;
|
||||
|
||||
int (*evt_cb)(void *, enum audio_dec_app_event event, int *param); // 事件回调
|
||||
void *evt_priv;
|
||||
|
||||
struct audio_dec_input dec_input;
|
||||
struct audio_dec_input *input; // 指定使用input接口
|
||||
struct audio_dec_handler *handler; // 指定使用handler接口
|
||||
|
||||
void *file_hdl;
|
||||
struct audio_dec_app_file_hdl *file;
|
||||
|
||||
void *app_hdl; // 指向上一级句柄
|
||||
};
|
||||
|
||||
// 解码的种类。比如用该值来区分音量等
|
||||
#define AUDIO_DEC_FILE_FLAG_AUDIO_STATE_TONE (0)
|
||||
#define AUDIO_DEC_FILE_FLAG_AUDIO_STATE_MUSIC (1)
|
||||
#define AUDIO_DEC_FILE_FLAG_AUDIO_STATE_MASK (0x000000ff)
|
||||
|
||||
/*
|
||||
* 通过文件后缀名匹配解码类型
|
||||
*/
|
||||
struct audio_dec_format_hdl {
|
||||
const char *fmt; // 后缀名
|
||||
u32 coding_type; // 解码类型
|
||||
};
|
||||
|
||||
/*
|
||||
* 文件解码
|
||||
*/
|
||||
struct audio_dec_file_app_hdl {
|
||||
struct audio_dec_app_hdl *dec;
|
||||
struct audio_dec_format_hdl *format;
|
||||
u32 flag; // 标签,可用于设置audio通道等
|
||||
void *file_hdl;
|
||||
void *priv; // 私有参数
|
||||
};
|
||||
|
||||
/*
|
||||
* 正弦波参数头部
|
||||
*/
|
||||
struct audio_sine_param_head {
|
||||
u16 repeat_time;
|
||||
u8 set_cnt;
|
||||
u8 cur_cnt;
|
||||
};
|
||||
|
||||
/*
|
||||
* 正弦波参数
|
||||
*/
|
||||
struct audio_sin_param {
|
||||
//int idx_increment;
|
||||
int freq;
|
||||
int points;
|
||||
int win;
|
||||
int decay;
|
||||
};
|
||||
|
||||
/*
|
||||
* 正弦波解码
|
||||
*/
|
||||
#define AUDIO_DEC_SINE_APP_NUM_MAX 8
|
||||
struct audio_dec_sine_app_hdl {
|
||||
struct audio_dec_app_hdl *dec;
|
||||
void *sin_maker;
|
||||
struct audio_sin_param sin_parm[AUDIO_DEC_SINE_APP_NUM_MAX];
|
||||
struct audio_sin_param *sin_src;
|
||||
u8 sin_num;
|
||||
u8 sin_repeat;
|
||||
u16 sin_default_sr;
|
||||
u32 sin_volume;
|
||||
u32 flag; // 标签,可用于设置audio通道等
|
||||
void *file_hdl;
|
||||
void *priv;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Decoder App Get Format By Name
|
||||
* Description: 通过名字判断解码类型
|
||||
* Arguments : *name 名字
|
||||
* *format 解码类型映射
|
||||
* Return : 解码类型
|
||||
* Note(s) : 查询不到返回AUDIO_CODING_UNKNOW
|
||||
*********************************************************************
|
||||
*/
|
||||
u32 audio_dec_app_get_format_by_name(char *name, struct audio_dec_format_hdl *format);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Decoder App Create
|
||||
* Description: 创建一个dec_app解码
|
||||
* Arguments : *priv 事件回调私有参数
|
||||
* *evt_cb 事件回调接口
|
||||
* mix 1-叠加播放,0-抢占播放
|
||||
* Return : dec_app句柄
|
||||
* Note(s) : mix==1默认参数:dec->wait.protect = 1;
|
||||
* mix==0默认参数:dec->wait.preemption = 1;
|
||||
*********************************************************************
|
||||
*/
|
||||
struct audio_dec_app_hdl *audio_dec_app_create(void *priv, int (*evt_cb)(void *, enum audio_dec_app_event event, int *param), u8 mix);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Decoder App Open
|
||||
* Description: 打开dec_app解码
|
||||
* Arguments : *dec dec_app句柄
|
||||
* Return : true 成功
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
int audio_dec_app_open(struct audio_dec_app_hdl *dec);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Decoder App Close
|
||||
* Description: 关闭dec_app解码
|
||||
* Arguments : *dec dec_app句柄
|
||||
* Return : None.
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_dec_app_close(struct audio_dec_app_hdl *dec);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Decoder App Start
|
||||
* Description: 开始解码
|
||||
* Arguments : *dec 解码句柄
|
||||
* Return : 0 成功
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
int audio_dec_app_start(struct audio_dec_app_hdl *dec);
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Decoder App Set File Info
|
||||
* Description: 设置dec_app文件信息
|
||||
* Arguments : *dec dec_app句柄
|
||||
* *file_hdl 文件句柄
|
||||
* Return : None.
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_dec_app_set_file_info(struct audio_dec_app_hdl *dec, void *file_hdl);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Decoder App Set Frame Info
|
||||
* Description: 设置dec_app流数据信息
|
||||
* Arguments : *dec dec_app句柄
|
||||
* pkt_len 帧长
|
||||
* coding_type 流数据类型
|
||||
* Return : None.
|
||||
* Note(s) : 会申请一块pkt_len长度的空间做缓存
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_dec_app_set_frame_info(struct audio_dec_app_hdl *dec, u16 pkt_len, u32 coding_type);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Decoder App Pause/Play
|
||||
* Description: dec_app解码暂停播放
|
||||
* Arguments : *dec dec_app句柄
|
||||
* Return : true 成功
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
int audio_dec_app_pp(struct audio_dec_app_hdl *dec);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Decoder App Get Status
|
||||
* Description: 获取dec_app解码状态
|
||||
* Arguments : *dec dec_app句柄
|
||||
* Return : enum audio_dec_app_status
|
||||
* Note(s) : 错误时返回 负数
|
||||
*********************************************************************
|
||||
*/
|
||||
int audio_dec_app_get_status(struct audio_dec_app_hdl *dec);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Decoder App Check Handler Live
|
||||
* Description: 检测解码句柄是否存在
|
||||
* Arguments : *dec dec_app句柄
|
||||
* Return : true 句柄存在
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
int audio_dec_app_check_hdl(struct audio_dec_app_hdl *dec);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Decoder App File Decoder Create
|
||||
* Description: 创建一个文件解码
|
||||
* Arguments : *name 文件名
|
||||
* mix 1-叠加播放,0-抢断播放
|
||||
* Return : 文件解码句柄
|
||||
* Note(s) : 默认开启被打断就自动close功能,hdl->dec->close_by_res_put=1;
|
||||
* 默认开启可抢断同优先级解码,hdl->dec->wait.snatch_same_prio=1;
|
||||
* 其他默认配置见audio_dec_app_create()函数说明
|
||||
*********************************************************************
|
||||
*/
|
||||
struct audio_dec_file_app_hdl *audio_dec_file_app_create(char *name, u8 mix);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Decoder App File Decoder Open
|
||||
* Description: 打开文件解码
|
||||
* Arguments : *file_dec 文件解码句柄
|
||||
* Return : true 成功
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
int audio_dec_file_app_open(struct audio_dec_file_app_hdl *file_dec);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Decoder App File Decoder close
|
||||
* Description: 关闭文件解码
|
||||
* Arguments : *file_dec 文件解码句柄
|
||||
* Return : None.
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_dec_file_app_close(struct audio_dec_file_app_hdl *file_dec);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Decoder App Sine File Decoder Create
|
||||
* Description: 创建一个正弦波文件解码
|
||||
* Arguments : *name 文件名
|
||||
* mix 1-叠加播放,0-抢断播放
|
||||
* Return : 正弦波解码句柄
|
||||
* Note(s) : 默认开启被打断就自动close功能,hdl->dec->close_by_res_put=1;
|
||||
* 默认开启可抢断同优先级解码,hdl->dec->wait.snatch_same_prio=1;
|
||||
* 其他默认配置见audio_dec_app_create()函数说明
|
||||
*********************************************************************
|
||||
*/
|
||||
struct audio_dec_sine_app_hdl *audio_dec_sine_app_create(char *name, u8 mix);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Decoder App Sine Param Decoder Create
|
||||
* Description: 创建一个正弦波数组解码
|
||||
* Arguments : *sin 数组地址
|
||||
* sin_num 数组数量
|
||||
* mix 1-叠加播放,0-抢断播放
|
||||
* Return : 正弦波解码句柄
|
||||
* Note(s) : 默认开启被打断就自动close功能,hdl->dec->close_by_res_put=1;
|
||||
* 默认开启可抢断同优先级解码,hdl->dec->wait.snatch_same_prio=1;
|
||||
* 其他默认配置见audio_dec_app_create()函数说明
|
||||
*********************************************************************
|
||||
*/
|
||||
struct audio_dec_sine_app_hdl *audio_dec_sine_app_create_by_parm(struct audio_sin_param *sin, u8 sin_num, u8 mix);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Decoder App Sine Decoder Open
|
||||
* Description: 打开正弦波解码
|
||||
* Arguments : *sine_dec 正弦波解码句柄
|
||||
* Return : true 成功
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
int audio_dec_sine_app_open(struct audio_dec_sine_app_hdl *sine_dec);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Decoder App Sine Decoder Close
|
||||
* Description: 关闭正弦波解码
|
||||
* Arguments : *sine_dec 正弦波解码句柄
|
||||
* Return : None.
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_dec_sine_app_close(struct audio_dec_sine_app_hdl *sine_dec);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Decoder App Sine Probe Deal
|
||||
* Description: 正弦波解码参数预处理
|
||||
* Arguments : *sine_dec 正弦波解码句柄
|
||||
* Return : None.
|
||||
* Note(s) : 正弦波解码需要先预处理一下参数
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_dec_sine_app_probe(struct audio_dec_sine_app_hdl *sine_dec);
|
||||
|
||||
#endif /*_AUDIO_DEC_APP_H_*/
|
||||
|
||||
141
include_lib/media/media_new/media/application/audio_drc.h
Normal file
141
include_lib/media/media_new/media/application/audio_drc.h
Normal file
@ -0,0 +1,141 @@
|
||||
|
||||
#ifndef _DRC_API_H_
|
||||
#define _DRC_API_H_
|
||||
|
||||
#include "typedef.h"
|
||||
#include "sw_drc.h"
|
||||
|
||||
struct audio_drc_filter_info {
|
||||
struct drc_ch *pch; //左声道系数
|
||||
struct drc_ch *R_pch; //右声道系数
|
||||
};
|
||||
|
||||
#if (defined(EQ_CORE_V1)|| defined(EQ_CORE_V2))
|
||||
typedef int (*audio_drc_filter_cb)(void *drc, struct audio_drc_filter_info *info);
|
||||
#else
|
||||
typedef int (*audio_drc_filter_cb)(struct audio_drc_filter_info *info);
|
||||
#endif
|
||||
|
||||
struct audio_drc_param {
|
||||
u32 channels : 8; //通道数 (channels|(L_wdrc))或(channels|(R_wdrc))
|
||||
u32 online_en : 1; //是否支持在线调试
|
||||
u32 remain_en : 1; //写1
|
||||
u32 stero_div : 1; //是否左右声道 拆分的 drc效果,一般写0
|
||||
u32 reserved : 21;
|
||||
audio_drc_filter_cb cb; //系数更新的回调函数,用户赋值
|
||||
u8 drc_name; //在线调试是,根据drc_name区分更新系数,一般写0
|
||||
#if (defined(EQ_CORE_V1)|| defined(EQ_CORE_V2))
|
||||
u8 out_32bit; //是否支持32bit 的输入数据处理 1:使能 0:不使能
|
||||
u32 sr; //数据采样率
|
||||
#endif
|
||||
};
|
||||
|
||||
struct audio_drc {
|
||||
struct drc_ch sw_drc[2]; //软件drc 系数地址
|
||||
u32 sr; //采样率
|
||||
u32 channels : 8; //通道数(channels|(L_wdrc))或(channels|(R_wdrc))
|
||||
u32 remain_flag : 1; //输出数据支持remain
|
||||
u32 updata : 1; //系数更标志
|
||||
u32 online_en : 1; //是否支持在线更新系数
|
||||
u32 remain_en : 1; //是否支持remain输出
|
||||
u32 start : 1; //无效
|
||||
u32 run32bit : 8; //是否使能32bit位宽数据处理1:使能 0:不使能
|
||||
u32 need_restart : 1; //是否需要重更新系数 1:是 0:否
|
||||
u32 stero_div : 1; //是否左右声道拆分的drc效果,1:是 0:否
|
||||
audio_drc_filter_cb cb; //系数更新回调
|
||||
void *hdl; //软件drc句柄
|
||||
void *output_priv; //输出回调私有指针
|
||||
int (*output)(void *priv, void *data, u32 len);//输出回调函数
|
||||
u32 drc_name; //drc标识
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief drc打开
|
||||
@param drc:句柄
|
||||
@param param:drc打开传入参数
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_drc_open(struct audio_drc *drc, struct audio_drc_param *param);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief drc设置输出数据回调
|
||||
@param drc:句柄
|
||||
@param *output:输出回调
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_drc_set_output_handle(struct audio_drc *drc, int (*output)(void *priv, void *data, u32 len), void *output_priv);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief drc设置采样率
|
||||
@param drc:句柄
|
||||
@param sr:采样率
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_drc_set_samplerate(struct audio_drc *drc, int sr);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief drc设置是否处理32bit输入数据
|
||||
@param drc:句柄
|
||||
@param run_32bit:1:32bit 0:16bit
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_drc_set_32bit_mode(struct audio_drc *drc, u8 run_32bit);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief drc启动
|
||||
@param drc:句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_drc_start(struct audio_drc *drc);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief drc数据处理
|
||||
@param drc:句柄
|
||||
@param *data:输入数据地址
|
||||
@param len:输入数据长度
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_drc_run(struct audio_drc *drc, s16 *data, u32 len);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief drc关闭
|
||||
@param drc:句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_drc_close(struct audio_drc *drc);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief audio_drc_open重新封装,简化使用
|
||||
@param *parm: drc参数句柄,参数详见结构体struct audio_drc_param
|
||||
@return eq句柄
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
struct audio_drc *audio_dec_drc_open(struct audio_drc_param *parm);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief audio_drc_close重新封装,简化使用
|
||||
@param drc句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_dec_drc_close(struct audio_drc *drc);
|
||||
|
||||
|
||||
#if (defined(EQ_CORE_V1)|| defined(EQ_CORE_V2))
|
||||
#else
|
||||
void drc_app_run_check(struct audio_drc *drc);
|
||||
int drc_get_filter_info(struct audio_drc_filter_info *info);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@ -0,0 +1,84 @@
|
||||
/*******************************************************************************************
|
||||
File : audio_energy_detect.h
|
||||
By : LinHaibin
|
||||
brief: 数据能量检测
|
||||
memory : 148 + 56 * channels (Byte)
|
||||
mips:
|
||||
dcc mode: 3MHz / 44100 points / 2channel / sec
|
||||
nodcc mode: 2.3MHz / 44100 points / 2channel / sec
|
||||
Email: linhaibin@zh-jieli.com
|
||||
date : Fri, 24 Jul 2020 18:11:37 +0800
|
||||
********************************************************************************************/
|
||||
#ifndef _AUDIO_ENERGY_DETECT_H_
|
||||
#define _AUDIO_ENERGY_DETECT_H_
|
||||
|
||||
#include "typedef.h"
|
||||
|
||||
#define AUDIO_E_DET_UNMUTE (0x00)
|
||||
#define AUDIO_E_DET_MUTE (0x01)
|
||||
|
||||
typedef struct _audio_energy_detect_param {
|
||||
s16 mute_energy; // mute 阈值
|
||||
s16 unmute_energy; // unmute 阈值
|
||||
u16 mute_time_ms; // 能量低于mute阈值进入mute状态时间
|
||||
u16 unmute_time_ms; // 能量高于unmute阈值进入unmute状态时间
|
||||
u32 sample_rate; // 采样率
|
||||
void (*event_handler)(u8, u8); // 事件回调函数 event channel
|
||||
u16 count_cycle_ms; // 能量计算的时间周期
|
||||
u8 ch_total; // 通道总数
|
||||
u8 pcm_mute: 1; // 保留,未使用
|
||||
u8 onoff: 1; // 保留,未使用
|
||||
u8 skip: 1; // 1:数据不处理 0:处理
|
||||
u8 dcc: 1; // 1:去直流打开 0:关闭
|
||||
} audio_energy_detect_param;
|
||||
|
||||
extern void *audio_energy_detect_entry_get(void *_hdl);
|
||||
extern void *audio_energy_detect_open(audio_energy_detect_param *param);
|
||||
extern int audio_energy_detect_run(void *_hdl, s16 *data, u32 len);
|
||||
extern int audio_energy_detect_close(void *_hdl);
|
||||
extern int audio_energy_detect_skip(void *_hdl, u32 channel, u8 skip);
|
||||
extern int audio_energy_detect_energy_get(void *_hdl, u8 ch);
|
||||
extern int audio_energy_detect_sample_rate_update(void *_hdl, u32 sample_rate);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
audio energy detect demo
|
||||
|
||||
INCLUDE:
|
||||
#include "application/audio_energy_detect.h"
|
||||
void *audio_e_det_hdl = NULL;
|
||||
struct list_head *audio_e_det_entry = NULL;
|
||||
void test_e_det_handler(u8 event, u8 ch)
|
||||
{
|
||||
printf(">>>> ch:%d %s\n", ch, event ? ("MUTE") : ("UNMUTE"));
|
||||
// ch < ch_total 时:表示通道(ch)触发的事件
|
||||
// ch = ch_total 时:表示全部通道都触发的事件
|
||||
}
|
||||
|
||||
OPEN:
|
||||
audio_energy_detect_param e_det_param = {0};
|
||||
e_det_param.mute_energy = 5;
|
||||
e_det_param.unmute_energy = 10;
|
||||
e_det_param.mute_time_ms = 100;
|
||||
e_det_param.unmute_time_ms = 50;
|
||||
e_det_param.count_cycle_ms = 100;
|
||||
e_det_param.sample_rate = 44100;
|
||||
e_det_param.event_handler = test_e_det_handler;
|
||||
e_det_param.ch_total = 2;
|
||||
e_det_param.dcc = 1;
|
||||
audio_e_det_hdl = audio_energy_detect_open(&e_det_param);
|
||||
|
||||
1.接入 audio stream
|
||||
audio_e_det_entry = audio_energy_detect_entry_get(audio_e_det_hdl);
|
||||
entries[entry_cnt++] = audio_e_det_entry;
|
||||
2.手动调用
|
||||
audio_energy_detect_run(audio_e_det_hdl, data, len);
|
||||
// data:需要运算的音频数据起始地址 len:需要运算的音频数据总字节长度
|
||||
|
||||
CLOSE:
|
||||
audio_energy_detect_close(audio_e_det_hdl);
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
#endif // #ifndef _AUDIO_ENERGY_DETECT_H_
|
||||
|
||||
305
include_lib/media/media_new/media/application/audio_eq.h
Normal file
305
include_lib/media/media_new/media/application/audio_eq.h
Normal file
@ -0,0 +1,305 @@
|
||||
#ifndef _EQ_API_H_
|
||||
#define _EQ_API_H_
|
||||
|
||||
#include "typedef.h"
|
||||
#include "asm/hw_eq.h"
|
||||
#define EQ_CHANNEL_MAX 2
|
||||
|
||||
#define EQ_SR_IDX_MAX 9
|
||||
|
||||
#if (defined(EQ_CORE_V1)|| defined(EQ_CORE_V2))
|
||||
#else
|
||||
#define EQ_SECTION_MAX_DEFAULT 10
|
||||
#define AUDIO_SONG_EQ_NAME 0
|
||||
#define AUDIO_CALL_EQ_NAME 1
|
||||
#define AUDIO_AEC_EQ_NAME 3
|
||||
#endif
|
||||
|
||||
/*eq type*/
|
||||
typedef enum {
|
||||
EQ_MODE_NORMAL = 0,
|
||||
EQ_MODE_ROCK,
|
||||
EQ_MODE_POP,
|
||||
EQ_MODE_CLASSIC,
|
||||
EQ_MODE_JAZZ,
|
||||
EQ_MODE_COUNTRY,
|
||||
EQ_MODE_CUSTOM,//自定义
|
||||
EQ_MODE_MAX,
|
||||
} EQ_MODE;
|
||||
|
||||
/*eq type*/
|
||||
typedef enum {
|
||||
EQ_TYPE_FILE = 0x01,
|
||||
EQ_TYPE_ONLINE,
|
||||
EQ_TYPE_MODE_TAB,
|
||||
} EQ_TYPE;
|
||||
|
||||
#define audio_eq_filter_info eq_coeff_info
|
||||
|
||||
#if (defined(EQ_CORE_V1)|| defined(EQ_CORE_V2))
|
||||
typedef int (*audio_eq_filter_cb)(void *eq, int sr, struct audio_eq_filter_info *info);
|
||||
|
||||
struct audio_eq_param {
|
||||
u32 channels : 2; //通道数
|
||||
u32 online_en : 1; //是否支持在线调试 1:支持 0:不支持
|
||||
u32 mode_en : 1; //支持默认系数表写1
|
||||
u32 remain_en : 1; //数据输出支持remain,写1
|
||||
u32 no_wait : 1; //是否使能异步eq, 1:使能 0:不使能
|
||||
u32 max_nsection : 6;//最大的eq段数,根据使用填写,要小于等于EQ_SECTION_MAX
|
||||
u32 nsection : 6; //实际需要的eq段数,需小于等于max_nsection
|
||||
u32 drc_en: 1; //16bit drc时,使用硬件eq对分频器部分进行加速,目前默认使用32bit drc。
|
||||
u8 out_32bit : 1; //是否支持32bit eq输出,仅在 no_wait 写1时,out_32bit 才能写1
|
||||
audio_eq_filter_cb cb;//获取eq系数的回调函数
|
||||
u32 eq_name; //eq名字,在线调试时,用于区分不同eq更新系数 播歌一般写song_eq_mode
|
||||
u32 sr; //采样率,更根据当前数据实际采样率填写
|
||||
void *priv; //私有指针
|
||||
int (*output)(void *priv, void *data, u32 len);//异步eq输出回调
|
||||
void (*irq_callback)(void *priv);//总段回调函数,数据流激活
|
||||
};
|
||||
#else
|
||||
typedef int (*audio_eq_filter_cb)(int sr, struct audio_eq_filter_info *info);
|
||||
|
||||
|
||||
/*EQ_ONLINE_CMD_PARAMETER_SEG*/
|
||||
typedef struct eq_seg_info EQ_ONLINE_PARAMETER_SEG;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
typedef struct eq_seg_info EQ_CFG_SEG;
|
||||
|
||||
|
||||
struct audio_eq_param {
|
||||
u32 channels : 2;
|
||||
u32 online_en : 1;
|
||||
u32 mode_en : 1;
|
||||
u32 remain_en : 1;
|
||||
u32 no_wait : 1;
|
||||
u32 max_nsection : 6;
|
||||
u32 reserved : 20;
|
||||
|
||||
u32 nsection : 6;
|
||||
u32 drc_en: 1;
|
||||
u32 eq_name;
|
||||
audio_eq_filter_cb cb;
|
||||
};
|
||||
|
||||
#endif//EQ_CORE_V1
|
||||
|
||||
#ifdef CONFIG_EQ_SUPPORT_ASYNC
|
||||
struct audio_eq_async {
|
||||
u16 ptr;
|
||||
u16 len;
|
||||
u16 buf_len;
|
||||
u8 clear;
|
||||
u8 out_stu;
|
||||
char *buf;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct audio_eq {
|
||||
void *eq_ch; //硬件eq句柄
|
||||
u32 sr; //采样率
|
||||
u32 remain_flag : 1; //数据未输出完
|
||||
u32 updata : 1; //系数是否需要更新
|
||||
u32 online_en : 1; //是否支持在线调试 1:支持 0:不支持
|
||||
u32 mode_en : 1; //支持默认系数表写1
|
||||
u32 remain_en : 1; //数据输出支持remain,写1
|
||||
|
||||
u32 max_nsection : 6; //eq最大段数
|
||||
u32 check_hw_running : 1; //检测到硬件正在运行时不等待其完成1:设置检查 0:不检查
|
||||
u32 eq_name; //eq标识
|
||||
u8 start; //eq start标识
|
||||
|
||||
#ifdef CONFIG_EQ_SUPPORT_ASYNC
|
||||
void *run_buf;
|
||||
void *run_out_buf;
|
||||
int run_len;
|
||||
struct audio_eq_async async; //异步eq 输出管理
|
||||
#endif
|
||||
|
||||
u32 mute_cnt_l; //左声道eq mem清除计数
|
||||
u32 mute_cnt_r; //右声道eq mem清除计数
|
||||
u32 mute_cnt_max; //记录最大点数,超过该点数,清eq mem
|
||||
|
||||
audio_eq_filter_cb cb; //系数回调
|
||||
void *output_priv; //私有指针
|
||||
int (*output)(void *priv, void *data, u32 len); //输出回调
|
||||
#if (defined(EQ_CORE_V1)|| defined(EQ_CORE_V2))
|
||||
struct eq_seg_info *eq_seg_tab; //运算前系数表
|
||||
float *eq_coeff_tab; //运算后系数表
|
||||
void *entry; //无效
|
||||
#endif
|
||||
const char *event_owner; //记录data_handler所处的任务
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq模块初始化
|
||||
@param
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_eq_init(int eq_section_num);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq 打开
|
||||
@param *param: eq参数句柄,参数详见结构体struct audio_eq_param
|
||||
@return eq句柄
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_eq_open(struct audio_eq *eq, struct audio_eq_param *param);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 异步eq设置输出回调
|
||||
@param eq:句柄
|
||||
@param *output:回调函数
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_eq_set_output_handle(struct audio_eq *eq, int (*output)(void *priv, void *data, u32 len), void *output_priv);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 同步eq设置输出buf
|
||||
@param eq:句柄
|
||||
@param *output:回调函数
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_eq_set_output_buf(struct audio_eq *eq, s16 *buf, u32 len);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq设置采样率
|
||||
@param eq:句柄
|
||||
@param sr:采样率
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_eq_set_samplerate(struct audio_eq *eq, int sr);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq设置输入输出通道数
|
||||
@param eq:句柄
|
||||
@param channel:通道数
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_eq_set_channel(struct audio_eq *eq, u8 channel);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 设置检查eq是否正在运行
|
||||
@param eq:句柄
|
||||
@param check_hw_running: 1:设置检查 0:不检查
|
||||
@return
|
||||
@note 检测到硬件正在运行时不等待其完成,直接返回, 仅异步EQ有效
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_eq_set_check_running(struct audio_eq *eq, u8 check_hw_running);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 设置eq信息
|
||||
@param eq:句柄
|
||||
@param channels:设置输入输出通道数
|
||||
@param out_32bit:使能eq输出32bit数据,1:输出32bit数据, 0:输出16bit是数据
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_eq_set_info(struct audio_eq *eq, u8 channels, u8 out_32bit);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 设置eq信息
|
||||
@param eq:句柄
|
||||
@param channels:设置入输出通道数
|
||||
@param in_mode:使能eq输入32bit数据,2:float, 1:输入32bit数据, 0:输入16bit是数据
|
||||
@param out_mode:使能eq输出32bit数据,2:float, 1:输出32bit数据, 0:输出16bit是数据
|
||||
@param run_mode:运行模式,0:normal, 1:mono, 2:stero
|
||||
@param data_in_mode:输入数据存放方式 0:块模式 1:序列模式
|
||||
@param data_out_mode:输入数据存放方式 0:块模式 1:序列模式
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_eq_set_info_new(struct audio_eq *eq, u8 channels, u8 in_mode, u8 out_mode, u8 run_mode, u8 data_in_mode, u8 data_out_mode);
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq启动
|
||||
@param eq:句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_eq_start(struct audio_eq *eq);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq的数据处理
|
||||
@param eq:句柄
|
||||
@param *data:输入数据地址
|
||||
@param len:输入数据长度
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_eq_run(struct audio_eq *eq, s16 *data, u32 len);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq关闭
|
||||
@param eq:句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_eq_close(struct audio_eq *eq);
|
||||
|
||||
|
||||
#ifdef CONFIG_EQ_SUPPORT_ASYNC
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 清除异步eq剩余的数据
|
||||
@param eq:句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_eq_async_data_clear(struct audio_eq *eq);
|
||||
#endif
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 获取异步eq剩余的数据
|
||||
@param eq:句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_eq_data_len(struct audio_eq *eq);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief audio_eq_open重新封装,简化使用
|
||||
@param *parm: eq参数句柄,参数详见结构体struct audio_eq_param
|
||||
@return eq句柄
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
struct audio_eq *audio_dec_eq_open(struct audio_eq_param *parm);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief audio_eq_close重新封装,简化使用
|
||||
@param eq句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_dec_eq_close(struct audio_eq *eq);
|
||||
|
||||
#if (defined(EQ_CORE_V1)|| defined(EQ_CORE_V2))
|
||||
#else
|
||||
void eq_app_run_check(struct audio_eq *eq);
|
||||
int eq_get_filter_info(int sr, struct audio_eq_filter_info *info);
|
||||
int aec_ul_eq_filter(int sr, struct audio_eq_filter_info *info);
|
||||
int eq_phone_get_filter_info(int sr, struct audio_eq_filter_info *info);
|
||||
|
||||
int eq_mode_set(u8 mode);
|
||||
int eq_mode_sw(void);
|
||||
int eq_mode_get_cur(void);
|
||||
int eq_mode_set_custom_param(u16 index, int gain);
|
||||
s8 eq_mode_get_gain(u8 mode, u16 index);
|
||||
int eq_mode_get_freq(u8 mode, u16 index);
|
||||
void eq_section_num_set(u8 song, u8 call_16k, u8 call_8k, u8 aec_16k, u8 aec_8k);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
#ifndef _AUDIO_HOWLING_API_H
|
||||
#define _AUDIO_HOWLING_API_H
|
||||
|
||||
#include "media/howling_api.h"
|
||||
|
||||
|
||||
#define TRAP_MODE 0
|
||||
#define SHIFT_PITCH_MODE 1
|
||||
#define PEMAFROW_MODE 2
|
||||
#define SHIFT_PHASE_MODE 3
|
||||
|
||||
#define HOWLING_MODE SHIFT_PITCH_MODE
|
||||
|
||||
#if (HOWLING_MODE == TRAP_MODE)
|
||||
#define REVERB_RUN_POINT_NUM 160 //固定160个点
|
||||
#elif (HOWLING_MODE == SHIFT_PHASE_MODE) //
|
||||
#define REVERB_RUN_POINT_NUM 256 //固定256个点
|
||||
#elif (HOWLING_MODE == PEMAFROW_MODE)
|
||||
#define REVERB_RUN_POINT_NUM 128 //固定128
|
||||
#else
|
||||
#define REVERB_RUN_POINT_NUM 0 //无限制
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 啸叫抑制模块打开
|
||||
@param howl_para:陷波模式时为啸叫抑制参数 ,pemafrow模式为DAC输出数据buf,;
|
||||
sample_rate:输入数据采样率;
|
||||
channels: 输入数据通道数;
|
||||
mode: 0 陷波模式;1 移频模式 2 pemafrow模式
|
||||
@return 啸叫抑制句柄,
|
||||
@note 陷波模式 要外部保证每次运算数据为160点,pemafrow 为128个点
|
||||
对应模式需外部使能,默认只开 移频模式
|
||||
const int config_howling_enable_pemafrow_mode = 1;
|
||||
const int config_howling_enable_trap_mode = 1;
|
||||
const int config_howling_enable_pitchps_mode = 1;
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
HOWLING_API_STRUCT *open_howling(void *howl_para, u16 sample_rate, u8 channel, u8 mode);
|
||||
/*
|
||||
* 啸叫抑制模块数据处理
|
||||
*/
|
||||
void run_howling(HOWLING_API_STRUCT *howling_hdl, short *in, short *out, int len);
|
||||
/*
|
||||
* 啸叫抑制模块关闭
|
||||
*/
|
||||
void close_howling(HOWLING_API_STRUCT *holing_hdl);
|
||||
/*
|
||||
* 啸叫抑制模块暂停处理
|
||||
*/
|
||||
void pause_howling(HOWLING_API_STRUCT *holing_hdl, u8 run_mark);
|
||||
|
||||
#endif
|
||||
|
||||
51
include_lib/media/media_new/media/application/audio_pitch.h
Normal file
51
include_lib/media/media_new/media/application/audio_pitch.h
Normal file
@ -0,0 +1,51 @@
|
||||
|
||||
#ifndef _AUDIO_PITCH_API_H_
|
||||
#define _AUDIO_PITCH_API_H_
|
||||
#include "pitchshifter/pitchshifter_api.h"
|
||||
// #include "mono2stereo/reverb_mono2stero_api.h"
|
||||
|
||||
|
||||
#define PITCHSHIFT_USE_AUDIO_STREAM 0 //是否使用audio_sream流节点
|
||||
#if PITCHSHIFT_USE_AUDIO_STREAM
|
||||
#include "media/audio_stream.h"
|
||||
#endif
|
||||
|
||||
typedef struct _s_pitch_hdl {
|
||||
PITCHSHIFT_FUNC_API *ops;
|
||||
u8 *databuf;
|
||||
PITCH_SHIFT_PARM parm;
|
||||
#if PITCHSHIFT_USE_AUDIO_STREAM
|
||||
struct audio_stream_entry entry; // 音频流入口
|
||||
int out_len;
|
||||
int process_len;
|
||||
#endif
|
||||
u8 run_en;
|
||||
u8 update;
|
||||
} s_pitch_hdl;
|
||||
/*
|
||||
* 获取变声模块默认参数;open时不传默认参数会使用内部默认参数
|
||||
* 仅用于获取初值。实时参数存放在open的返回句柄parm中
|
||||
*/
|
||||
PITCH_SHIFT_PARM *get_pitch_parm(void);
|
||||
/*
|
||||
* 变声模块打开
|
||||
*/
|
||||
s_pitch_hdl *open_pitch(PITCH_SHIFT_PARM *param);
|
||||
/*
|
||||
* 变声模块关闭
|
||||
*/
|
||||
void close_pitch(s_pitch_hdl *picth_hdl);
|
||||
/*
|
||||
* 变声模块参数更新
|
||||
*/
|
||||
void update_picth_parm(s_pitch_hdl *pitch_hdl, PITCH_SHIFT_PARM *p_pitch_parm);
|
||||
/*
|
||||
* 变声模块数据处理
|
||||
*/
|
||||
void pitch_run(s_pitch_hdl *picth_hdl, s16 *indata, s16 *outdata, int len, u8 ch_num);
|
||||
/*
|
||||
* 变声模块暂停处理
|
||||
*/
|
||||
void pause_pitch(s_pitch_hdl *pitch_hdl, u8 run_mark);
|
||||
#endif
|
||||
|
||||
171
include_lib/media/media_new/media/application/audio_surround.h
Normal file
171
include_lib/media/media_new/media/application/audio_surround.h
Normal file
@ -0,0 +1,171 @@
|
||||
|
||||
#ifndef _AUDIO_SURROUND_API_H_
|
||||
#define _AUDIO_SURROUND_API_H_
|
||||
#include "surround/effect_sur_api.h"
|
||||
// #include "audio_config.h"
|
||||
|
||||
#define SURROUND_USE_AUDIO_STREAM 0 //是否使用audio_sream流节点
|
||||
|
||||
typedef struct _surround_update_parm {
|
||||
int surround_type;//音效类型
|
||||
int rotatestep;//旋转速度
|
||||
int damping;//高频衰减速度
|
||||
int feedback;//整体衰减速度
|
||||
int roomsize;//空间大小
|
||||
} surround_update_parm;
|
||||
|
||||
typedef struct _surround_open_parm {
|
||||
u8 channel;//通道数立体声配2, 左声道配EFFECT_CH_L, 右声道配EFFECT_CH_R
|
||||
u8 surround_effect_type;//默认的环绕音效类型
|
||||
} surround_open_parm;
|
||||
|
||||
|
||||
typedef struct _surround_hdl {
|
||||
SUR_FUNC_API *ops;
|
||||
void *work_buf;
|
||||
OS_MUTEX mutex;
|
||||
u8 surround_en: 1;
|
||||
u8 update: 1;
|
||||
u8 nch_update: 1;
|
||||
|
||||
surround_open_parm parm;
|
||||
|
||||
#if SURROUND_USE_AUDIO_STREAM
|
||||
struct audio_stream_entry entry; // 音频流入口
|
||||
#endif
|
||||
|
||||
} surround_hdl;
|
||||
|
||||
/*cmd*/
|
||||
enum {
|
||||
EFFECT_3D_PANORAMA = 0, //3d全景
|
||||
EFFECT_3D_ROTATES, //3d环绕
|
||||
EFFECT_FLOATING_VOICE, //流动人声
|
||||
EFFECT_GLORY_OF_KINGS, //王者荣耀
|
||||
EFFECT_FOUR_SENSION_BATTLEFIELD, //四季战场
|
||||
|
||||
EFFECT_SUR2, //一种新的环绕声(仿某耳机的环绕音效)需将const_surround_en|BIT(2)
|
||||
/*如使用以下效果,需将const_surround_en|BIT(1), mips占用 55M ram33k*/
|
||||
EFFECT_3D_PANORAMA2, //3d全景另一种效果
|
||||
EFFECT_KTV, //ktv模式
|
||||
EFFECT_3DTHE, //3D影院
|
||||
EFFECT_HALL, //音乐厅
|
||||
EFFECT_VOICE, //清澈人声
|
||||
EFFECT_SUR, //全景环绕
|
||||
|
||||
EFFECT_OFF2, //音效开关(数据会经过模块,但不做处理,保证数据延续,避免由音效开关引起的哒哒音,)
|
||||
EFFECT_OFF, //音效开关(数据直接不经过模块)
|
||||
};
|
||||
|
||||
|
||||
//{EFFECT_3D_TYPE1, 2, 120, 110, 128},//3D全景
|
||||
//{EFFECT_3D_ROTATE, 2, 60, 70, 128},//3D旋转, step旋转速度 建议1~8
|
||||
//{EFFECT_3D_LRDRIFT, 140, 120, 95, 128}, //流动人声,step流动速度 建议40~400
|
||||
//{EFFECT_3D_TYPE0, 2, 120, 95, 128},//王者荣耀
|
||||
//{EFFECT_3D_TYPE1, 2, 60, 100, 30},//四季战场,同全景,但把整体调小了
|
||||
//以上是内置默认效果
|
||||
|
||||
|
||||
#if 0
|
||||
//如启用多效果调节,需将const_surround_en|BIT(1),调用update接口传参使用。
|
||||
//{EFFECT_3D_TYPE2, 2, 90, 100, 100},//3d全景的另一效果,该效果,mips占用 55M ram33k.
|
||||
//第一个参数2是无效参数.
|
||||
//第2个参数90调节反馈强度范围是1到150,大点的话空间感比较强。
|
||||
//第3个参数是 湿声增益,可调范围是0到128。
|
||||
//第4个参数调节空间大小,范围是0-100,是反馈参数,有效范围0到100。
|
||||
|
||||
//例如:
|
||||
surround_update_parm parm = {0};
|
||||
parm.surround_type = EFFECT_3D_TYPE2;
|
||||
parm.rotatestep = 2;
|
||||
parm.damping = 90;
|
||||
parm.feedback = 100;
|
||||
parm.roomsize = 100;
|
||||
audio_surround_parm_update(hdl, EFFECT_3D_PANORAMA2, &parm);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
//如需要自定义 ktv模式、3d影院、音乐厅、清澈人声、全景环绕
|
||||
//参数顺序
|
||||
//dry,wet,delay,rot60,Erwet,Erfactor,Ewidth,Ertolate,predelay,width,diffusion,dampinglpf,basslpf,bassB
|
||||
const static int surmode_present[][14] = {
|
||||
{55, 70, 35, 8000, 80, 80, 80, 80, 20, 100, 70, 6500, 4000, 18}, //EFFECT_KTV
|
||||
{60, 60, 90, 9030, 90, 90, 90, 90, 18, 100, 75, 7000, 1000, 29}, //EFFECT_3DTHE
|
||||
{50, 70, 100, 12000, 100, 100, 100, 100, 20, 100, 72, 9000, 50, 3}, //EFFECT_HALL
|
||||
{40, 70, 20, 2010, 100, 70, 70, 100, 15, 100, 70, 5500, 3500, 60}, //EFFECT_VOICE
|
||||
{60, 70, 100, 9000, 80, 80, 80, 90, 10, 100, 72, 8000, 500, 15}, //EFFECT_SUR
|
||||
};
|
||||
|
||||
parm.surround_type = EFFECT_3D_TYPE2;
|
||||
parm.rotatestep = 2;
|
||||
parm.damping = -1;
|
||||
parm.feedback = 100;
|
||||
parm.roomsize = (int)surmode_present[0];
|
||||
audio_surround_parm_update(hdl, EFFECT_KTV, &parm);
|
||||
|
||||
//如使用默认的 ktv模式、3d影院、音乐厅、清澈人声、全景环绕
|
||||
audio_surround_parm_update(hdl, EFFECT_KTV, NULL);
|
||||
audio_surround_parm_update(hdl, EFFECT_3DTHE, NULL);
|
||||
audio_surround_parm_update(hdl, EFFECT_HALL, NULL);
|
||||
audio_surround_parm_update(hdl, EFFECT_VOICE, NULL);
|
||||
audio_surround_parm_update(hdl, EFFECT_SUR, NULL);
|
||||
#endif
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief audio_surround_open 环绕音效打开
|
||||
@param *_parm: 环绕音效始化参数,详见结构体surround_open_parm
|
||||
@return 句柄
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
surround_hdl *audio_surround_open(surround_open_parm *parm);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief audio_surround_parm_update 环绕音效参数更新
|
||||
@param cmd:EFFECT_3D_PANORAMA,EFFECT_3D_ROTATES,EFFECT_FLOATING_VOICE,EFFECT_GLORY_OF_KINGS,EFFECT_FOUR_SENSION_BATTLEFIELD
|
||||
@param *_parm:参数指针,NULL则使用默认德参数,否则传入自定义参数
|
||||
@return 0:成功 -1: 失败
|
||||
@note 对耳时,左右声道效果,须设置保持一致
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_surround_parm_update(surround_hdl *_hdl, u32 cmd, surround_update_parm *_parm);
|
||||
|
||||
/* surround_update_parm parm = {0}; */
|
||||
// parm.surround_type = EFFECT_3D_TYPE1;
|
||||
// parm.rotatestep = 2;//旋转速度
|
||||
// parm.damping = 120;//高频衰减速度
|
||||
// parm.feedback = 110;//整体衰减速度
|
||||
// parm.roomsize = 128;//空间大小
|
||||
/* audio_surround_parm_update(hdl, EFFECT_3D_PANORAMA, &parm); */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief audio_surround_close 环绕音效关闭处理
|
||||
@param _hdl:句柄
|
||||
@return 0:成功 -1:失败
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_surround_close(surround_hdl *_hdl);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief audio_surround_run 环绕音效处理
|
||||
@param _hdl:句柄
|
||||
@param data:需要处理的数据
|
||||
@param len:数据长度
|
||||
@return 0:成功 -1:失败
|
||||
@note 无数据流节点时,直接使用改接口进行环绕音效的处理
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_surround_run(surround_hdl *_hdl, void *data, u32 len);
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief audio_surround_switch_nch 通道切换
|
||||
@param _hdl:句柄
|
||||
@param nch:通道数 2 4 或者EFFECT_CH_L EFFECT_CH_R
|
||||
@return 0:成功 -1:失败
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_surround_switch_nch(surround_hdl *_hdl, int nch);
|
||||
#endif
|
||||
54
include_lib/media/media_new/media/application/audio_vbass.h
Normal file
54
include_lib/media/media_new/media/application/audio_vbass.h
Normal file
@ -0,0 +1,54 @@
|
||||
#if 1
|
||||
#ifndef _AUDIO_VBASS_API_H_
|
||||
#define _AUDIO_VBASS_API_H_
|
||||
#include "system/includes.h"
|
||||
#include "media/audio_stream.h"
|
||||
#include "media/VirtualBass_api.h"
|
||||
|
||||
typedef struct _VirtualBassUdateParam {
|
||||
int ratio; //0~100,默认10
|
||||
int boost; //0或者1 ,默认1
|
||||
int fc; //30~300Hz, 默认100
|
||||
} VirtualBassUdateParam;
|
||||
|
||||
struct virtual_bass_tool_set {
|
||||
float prev_gain; //-90.3~90.3 dB, 默认值 0
|
||||
VirtualBassUdateParam parm;
|
||||
};
|
||||
|
||||
|
||||
#define VBASS_STREAM_EN 0
|
||||
typedef struct _vbass_hdl {
|
||||
#if VBASS_STREAM_EN
|
||||
struct audio_stream_entry entry; // 音频流入口
|
||||
#endif
|
||||
struct list_head hentry; //
|
||||
void *workbuf; //vbass 运行句柄及buf
|
||||
VirtualBassParam parm;
|
||||
u32 vbass_name;
|
||||
u8 status; //内部运行状态机
|
||||
u8 update; //设置参数更新标志
|
||||
u8 lowfreq_en; //1:保留低频;0:不保留
|
||||
} vbass_hdl;
|
||||
|
||||
|
||||
int audio_vbass_run(vbass_hdl *hdl, void *data, u32 len);
|
||||
vbass_hdl *audio_vbass_open(u32 vbass_name, VirtualBassParam *parm);
|
||||
int audio_vbass_close(vbass_hdl *hdl);
|
||||
|
||||
int audio_vbass_parm_update(u32 vbass_name, VirtualBassUdateParam *parm);
|
||||
void audio_vbass_bypass(u32 vbass_name, u8 bypass);
|
||||
vbass_hdl *get_cur_vbass_hdl_by_name(u32 vbass_name);
|
||||
|
||||
#ifndef RUN_NORMAL
|
||||
#define RUN_NORMAL 0
|
||||
#endif
|
||||
|
||||
#ifndef RUN_BYPASS
|
||||
#define RUN_BYPASS 1
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
#endif /*CONFIG_EFFECT_CORE_V2_ENABLE*/
|
||||
|
||||
710
include_lib/media/media_new/media/application/eq_config.h
Normal file
710
include_lib/media/media_new/media/application/eq_config.h
Normal file
@ -0,0 +1,710 @@
|
||||
#if (defined(EQ_CORE_V1)|| defined(EQ_CORE_V2))
|
||||
|
||||
#ifndef _EQ_CONFIG_H_
|
||||
#define _EQ_CONFIG_H_
|
||||
|
||||
#include "application/audio_eq.h"
|
||||
#include "application/audio_drc.h"
|
||||
#include "application/audio_vbass.h"
|
||||
#include "spinlock.h"
|
||||
#include "math.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
/*eq online cmd*/
|
||||
enum {
|
||||
EQ_ONLINE_CMD_SECTION = 1,
|
||||
EQ_ONLINE_CMD_GLOBAL_GAIN,
|
||||
EQ_ONLINE_CMD_LIMITER,
|
||||
EQ_ONLINE_CMD_INQUIRE,
|
||||
EQ_ONLINE_CMD_GETVER,
|
||||
EQ_ONLINE_CMD_GET_SOFT_SECTION,//br22专用
|
||||
EQ_ONLINE_CMD_GET_SECTION_NUM = 0x7,//工具查询 小机需要的eq段数
|
||||
EQ_ONLINE_CMD_GLOBAL_GAIN_SUPPORT_FLOAT = 0x8,
|
||||
|
||||
|
||||
EQ_ONLINE_CMD_PASSWORD = 0x9,
|
||||
EQ_ONLINE_CMD_VERIFY_PASSWORD = 0xA,
|
||||
EQ_ONLINE_CMD_FILE_SIZE = 0xB,
|
||||
EQ_ONLINE_CMD_FILE = 0xC,
|
||||
EQ_EQ_ONLINE_CMD_GET_SECTION_NUM = 0xD,//该命令新加与 0x7功能一样
|
||||
EQ_EQ_ONLINE_CMD_CHANGE_MODE = 0xE,//切模式
|
||||
|
||||
EQ_ONLINE_CMD_MODE_COUNT = 0x100,//模式个数a 1
|
||||
EQ_ONLINE_CMD_MODE_NAME = 0x101,//模式的名字a eq
|
||||
EQ_ONLINE_CMD_MODE_GROUP_COUNT = 0x102,//模式下组的个数,4个字节 1
|
||||
EQ_ONLINE_CMD_MODE_GROUP_RANGE = 0x103,//模式下组的id内容 0x11
|
||||
EQ_ONLINE_CMD_EQ_GROUP_COUNT = 0x104,//eq组的id个数 1
|
||||
EQ_ONLINE_CMD_EQ_GROUP_RANGE = 0x105,//eq组的id内容 0x11
|
||||
EQ_ONLINE_CMD_MODE_SEQ_NUMBER = 0x106,//mode的编号 magic num
|
||||
|
||||
|
||||
EQ_ONLINE_CMD_PARAMETER_SEG = 0x11,
|
||||
EQ_ONLINE_CMD_PARAMETER_TOTAL_GAIN,
|
||||
EQ_ONLINE_CMD_PARAMETER_LIMITER,
|
||||
EQ_ONLINE_CMD_PARAMETER_DRC,
|
||||
EQ_ONLINE_CMD_PARAMETER_CHANNEL,//通道切换
|
||||
|
||||
|
||||
EQ_ONLINE_CMD_SONG_EQ_SEG = 0x2001,
|
||||
EQ_ONLINE_CMD_CALL_EQ_SEG = 0x2002,
|
||||
EQ_ONLINE_CMD_AEC_EQ_SEG = 0x2003,
|
||||
|
||||
|
||||
EQ_ONLINE_CMD_SONG_EQ_V1_SEG = 0x2011,// float gain, float q
|
||||
EQ_ONLINE_CMD_CALL_EQ_V1_SEG = 0x2012,
|
||||
EQ_ONLINE_CMD_AEC_EQ_V1_SEG = 0x2013,
|
||||
EQ_ONLINE_CMD_HEARING_AID_EQ_SEG = 0x2014,// float gain, float q
|
||||
EQ_ONLINE_CMD_HEARING_AID_EQ_SEG2 = 0x2015,// float gain, float q
|
||||
|
||||
|
||||
EQ_ONLINE_CMD_SONG_DRC = 0x2101,
|
||||
EQ_ONLINE_CMD_SONG_WDRC = 0x2102,
|
||||
EQ_ONLINE_CMD_SONG_MULTI_WDRC = 0x2104,
|
||||
|
||||
EQ_ONLINE_CMD_VIRTUAL_BASS = 0x2203,
|
||||
//add xx here
|
||||
|
||||
EQ_ONLINE_CMD_MAX,//最后一个
|
||||
};
|
||||
|
||||
#define CONSTRAINT_OP_DRC_L_R_CH 0x01
|
||||
#define CONSTRAINT_OP_DRC_WDRC_SINGLE_CH 0x02
|
||||
#define CONSTRAINT_OP_DRC_WDRC_DUAL_CH 0x03
|
||||
|
||||
|
||||
/*eq online packet*/
|
||||
typedef struct {
|
||||
int cmd; ///<EQ_ONLINE_CMD
|
||||
int data[45]; ///<data
|
||||
} EQ_ONLINE_PACKET;
|
||||
|
||||
|
||||
/*EQ_ONLINE_CMD_PARAMETER_SEG*/
|
||||
typedef struct eq_seg_info EQ_ONLINE_PARAMETER_SEG;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
typedef struct eq_seg_info EQ_CFG_SEG;
|
||||
|
||||
typedef struct {
|
||||
float global_gain; //总增益
|
||||
int seg_num; //eq效果文件存储的段数
|
||||
int enable_section; //
|
||||
} CFG_PARM;
|
||||
|
||||
|
||||
#define SECTION_MAX 20
|
||||
typedef struct {
|
||||
CFG_PARM par;
|
||||
EQ_CFG_SEG seg[SECTION_MAX]; //eq系数存储地址
|
||||
} EQ_CFG_PARAMETER;
|
||||
|
||||
|
||||
typedef struct {
|
||||
struct drc_ch drc; //drc系数地址
|
||||
} DRC_CFG_PARAMETER;
|
||||
|
||||
|
||||
typedef struct {
|
||||
/* unsigned short crc; */
|
||||
unsigned short id; //eq效果文件存储的标识
|
||||
unsigned short len; //当前标识结构长度
|
||||
} EQ_FILE_HEAD;
|
||||
|
||||
typedef struct {
|
||||
EQ_FILE_HEAD head;
|
||||
EQ_CFG_PARAMETER parm;
|
||||
} EQ_CFG_PARM; //效果文件中,eq存储结构
|
||||
|
||||
typedef struct {
|
||||
EQ_FILE_HEAD head;
|
||||
DRC_CFG_PARAMETER parm;
|
||||
} DRC_CFG_PARM; //效果文件中,drc存储结构
|
||||
|
||||
typedef struct {
|
||||
EQ_FILE_HEAD head;
|
||||
struct virtual_bass_tool_set parm;
|
||||
} VBASS_CFG_PARM; //效果文件中,drc存储结构
|
||||
|
||||
|
||||
typedef struct {
|
||||
EQ_CFG_PARM song_eq_parm;
|
||||
DRC_CFG_PARM drc_parm;
|
||||
VBASS_CFG_PARM vbass_parm;
|
||||
u8 cur_mode;
|
||||
} EQ_FILE_PARM; //eq drc效果系数,统一管理
|
||||
|
||||
typedef struct {
|
||||
u16 tmr;
|
||||
u8 *fade_stu;
|
||||
u32 *sr;
|
||||
EQ_CFG_SEG *seg;
|
||||
} EQ_FADE_CFG; //系数eq系数调节,支持淡入淡出,防止增益跳跃过大,造成哒哒音
|
||||
|
||||
typedef struct _eq_tool_cfg {
|
||||
u8 mode_index; //模式序号
|
||||
u8 *mode_name; //模式名
|
||||
u32 mode_seq; //模式的seq,用于识别离线文件功能类型
|
||||
u8 section; //每个模式下eq的段数
|
||||
u8 fun_num; //模式下有多少种功能
|
||||
u16 fun_type[3]; //模式下拥有哪些功能
|
||||
} eq_tool_cfg; //调试工具支持的功能
|
||||
|
||||
typedef struct {
|
||||
u32 eq_type : 3; //系数调试所处模式:在线模式、效果文件(离线)模式、默认系数表模式
|
||||
u32 *mode_updata; //默认系数表切换更新标志
|
||||
u32 *drc_updata; //drc系数更新标志
|
||||
u32 *online_updata; //在线调试系数更新标志
|
||||
u32 *design_mask; //在线调试,哪一段eq需要更新标志
|
||||
u32 *seg_num; //当前模式(播歌、通话宽频、窄频上下行模式标号),所拥有的eq段数
|
||||
EQ_FILE_PARM *cfg_parm;//eq drc效果系数,统一管理
|
||||
u32 *cur_sr; //当前模式(播歌、通话宽频、窄频上下行模式标号),记录的采样率
|
||||
spinlock_t lock; //自旋锁
|
||||
u8 mode_id; //当前模式(播歌、通话宽频、窄频上下行模式标号),在线调试时,内部使用
|
||||
|
||||
u8 mode_num; //模式总数(播歌、通话宽频、窄频上下行模式标号)
|
||||
u8 online_en: 1; //是否支持在线调试
|
||||
u8 fade_en: 1; //是否支持淡入淡出
|
||||
u8 stero: 1; //左右声道效果是否支持拆分
|
||||
u8 drc: 1; //是否支持drc调试
|
||||
u8 tws: 1; //是否支持tws调试
|
||||
u8 app: 1; //是否支持app调试
|
||||
u8 limit_zero: 1; //是否将系数限制到0
|
||||
u8 eq_file_ver_err: 1;//记录效果文件版本是否匹配
|
||||
u8 eq_file_section_err : 1;//记录效果文件eq段数是否匹配
|
||||
u8 vbass;
|
||||
u8 vbass_file;
|
||||
u8 type_num; //默认eq系数表总个数
|
||||
u8 section_max; //eq最大段数
|
||||
u8 eq_mode; //记录当前使用哪个eq系数表
|
||||
u8 parse_seq; //记录app调试的seq
|
||||
uint8_t password_ok; //在线调试记录密码是否正确
|
||||
float *eq_coeff_tab; //eq在线多模式系数表,[MODE_NUM_MAX][SECTION_MAX * 5];
|
||||
|
||||
void *tws_ci; //tws收发句柄
|
||||
int tws_tmr; //系数收发timer
|
||||
u16 *tws_pack; //收发的数据包地址
|
||||
u8 pack_id; //收发数据包标识
|
||||
|
||||
EQ_FADE_CFG *fade_cfg;//系数淡入淡出句柄
|
||||
int *eq_type_tab; //eq 默认系数表,计算前seg信息存储地址[EQ_MODE_MAX];
|
||||
float *type_gain_tab; //song_eq_mode eq 默认系数表的对应的总增益
|
||||
u8 *eq_mode_use_idx; //10段内抽取部分段数
|
||||
eq_tool_cfg *eq_tool_tab;//在线调试工具支持的功能配置结构
|
||||
|
||||
void *phone_eq_tab;//通话下行 eq系数表
|
||||
u8 phone_eq_tab_size;//通话下行eq系数表段数
|
||||
void *ul_eq_tab;//通话上行 eq系数表
|
||||
u8 ul_eq_tab_size;//通话上行eq系数表段数
|
||||
|
||||
|
||||
void *priv;
|
||||
int (*send_cmd)(void *priv, u32 id, u8 *packet, int size);//在线调试,命令应答
|
||||
u8 custom_mode_id; //记录自定义eq系数表的数组所在下标号
|
||||
u16 timer; //总增益淡入timer
|
||||
float use_global_gain; //总增益淡入目标值
|
||||
float global_gain_fade_step; //总增益淡入步进
|
||||
u8 mode; //记录用于总增益淡入timer的mode
|
||||
} EQ_CFG;
|
||||
|
||||
typedef struct _eq_parm {
|
||||
u8 mode_num; //模式总数(播歌、通话宽频、窄频上下行模式标号)
|
||||
u8 online_en: 1; //是否支持在线调试
|
||||
u8 fade_en: 1; //是否支持淡入淡出
|
||||
u8 file_en: 1; //是否支持效果文件解析
|
||||
u8 stero: 1; //是否左右声道做不同eq
|
||||
u8 drc: 1; //是否有drc
|
||||
u8 tws: 1; //是否tws
|
||||
u8 app: 1; //是否手机app在线调试
|
||||
u8 limit_zero: 1; //是否将系数限制到0
|
||||
u8 type_num: 4; //默认eq系数表总个数
|
||||
u8 section_max; //eq最大段数
|
||||
void *eq_type_tab; //eq 默认系数表,计算前seg信息存储地址[EQ_MODE_MAX];
|
||||
float *type_gain_tab; //song_eq_mode eq 默认系数表的对应的总增益
|
||||
u8 *eq_mode_use_idx; //10段内抽取部分段数
|
||||
eq_tool_cfg *eq_tool_tab;//在线调试工具支持的功能配置结构
|
||||
|
||||
void *phone_eq_tab; //通话下行 eq系数表
|
||||
u8 phone_eq_tab_size; //通话下行eq系数表段数
|
||||
void *ul_eq_tab; //通话上行 eq系数表
|
||||
u8 ul_eq_tab_size; //通话上行eq系数表段数
|
||||
|
||||
} eq_adjust_parm;
|
||||
|
||||
|
||||
/*模式序号*/
|
||||
typedef enum {
|
||||
song_eq_mode = 0,
|
||||
call_eq_mode = 1,
|
||||
call_narrow_eq_mode = 2,
|
||||
aec_eq_mode = 3,
|
||||
aec_narrow_eq_mode = 4,
|
||||
hearing_aid_mode = 5,
|
||||
hearing_aid_mode2 = 6,
|
||||
fr_eq_mode = 7,
|
||||
rl_eq_mode = 8,
|
||||
rr_eq_mode = 9,
|
||||
mic_eq_mode = 10,
|
||||
} MUSIC_MODE;
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 切换到指定的eq文件
|
||||
@param index:数组中的文件序号
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void eq_file_set_by_index(u8 index);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 根据eq_file_switch_list成员个数顺序切换eq文件
|
||||
@param
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void eq_file_switch();
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq系数表存放顺序
|
||||
@param *eq_cfg:配置句柄
|
||||
@param mode:播歌、通话宽频、窄频上下行模式标号
|
||||
@return
|
||||
@note call_eq_mode|call_narrow_eq_mode|aec_eq_mode|aec_narrow_eq_mode|song_eq_mode|fr_eq_mode|rl_eq_mode|rr_eq_mode
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int *get_eq_coeff_tab(EQ_CFG *eq_cfg, MUSIC_MODE mode);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 获取配置EQ_CFG *eq_cfg句柄
|
||||
@param
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void *get_eq_cfg_hdl();
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief seg值,限制到0
|
||||
@param
|
||||
@param
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void eq_seg_limit_zero(EQ_CFG_SEG *seg, u8 seg_num);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq根据seg值,计算系数的并放到tar_tab
|
||||
@param *eq_cfg:配置句柄
|
||||
@param sr:采样率
|
||||
@param mode:播歌、通话宽频、窄频上下行模式标号
|
||||
@param *seg:计算前系数
|
||||
@param *tar_tab:计算后系数存放地址
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void eq_coeff_set(EQ_CFG *eq_cfg, u32 sr, MUSIC_MODE mode, EQ_CFG_SEG *seg, int *tar_tab);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 打开eq系数配置解析、在线调试配置等
|
||||
@param *parm:系数解析、在线调试功能配置数据结构
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void *eq_cfg_open(eq_adjust_parm *parm);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 手机app 在线调时,数据解析的回调
|
||||
@param *packet
|
||||
@param
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int eq_app_online_parse(u8 *packet, u8 size, u8 *ext_data, u16 ext_size);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 设置 eq总增益
|
||||
@param *eq_cfg:*eq_cfg:配置句柄
|
||||
@param mode:播歌、通话宽频、窄频上下行模式标号
|
||||
@param global_gain:总增益
|
||||
@return
|
||||
@note call_eq_mode|call_narrow_eq_mode|aec_eq_mode|aec_narrow_eq_mode|song_eq_mode|fr_eq_mode|rl_eq_mode|rr_eq_mode
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void set_global_gain(EQ_CFG *eq_cfg, MUSIC_MODE mode, float global_gain);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 获取 eq总增益
|
||||
@param *eq_cfg:*eq_cfg:配置句柄
|
||||
@param mode:播歌、通话宽频、窄频上下行模式标号
|
||||
@return
|
||||
@note call_eq_mode|call_narrow_eq_mode|aec_eq_mode|aec_narrow_eq_mode|song_eq_mode|fr_eq_mode|rl_eq_mode|rr_eq_mode
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
float get_glbal_gain(EQ_CFG *eq_cfg, MUSIC_MODE mode);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 普通音频eq,无离线文件时,获取某eq效果模式的增益
|
||||
@param mode:哪个模式
|
||||
@param index:哪一段
|
||||
@return 增益
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
s8 eq_mode_get_gain(EQ_MODE mode, u16 index);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 普通音频eq,无离线文件时,设置用户自定义eq效果模式时的增益
|
||||
@param index:哪一段
|
||||
@param gain:增益
|
||||
@return
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int eq_mode_set_custom_param(u16 index, float gain);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 普通音频eq,无离线文件时,获取用户自定义eq效果模式时的增益、频率
|
||||
@param index:哪一段
|
||||
@param freq:中心截止频率
|
||||
@param gain:增益
|
||||
@return
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int eq_mode_set_custom_info(u16 index, int freq, float gain);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 普通音频eq,无离线文件时,用默认eq系数表的eq效果模式设置(设置模式,更新系数)
|
||||
@param mode:EQ_MODE_NORMAL, EQ_MODE_ROCK,EQ_MODE_POP,EQ_MODE_CLASSIC,EQ_MODE_JAZZ,EQ_MODE_COUNTRY, EQ_MODE_CUSTOM
|
||||
@return
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int eq_mode_set(EQ_MODE mode);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq模式切换
|
||||
@param
|
||||
@return
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int eq_mode_sw(void);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 普通音频eq,无离线文件时,获取eq效果模式
|
||||
@param
|
||||
@return
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
EQ_MODE eq_mode_get_cur(void);
|
||||
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 解析eq效果文件的系数
|
||||
@param *eq_cfg:*eq_cfg:配置句柄
|
||||
@param *path:eq效果文件路径
|
||||
@return
|
||||
@note 可用该接口切换eq效果文件,需使能宏TCFG_USE_EQ_FILE,以及在config_audio_eq_en上使能 EQ_FILE_SW_EN
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
s32 eq_file_get_cfg(EQ_CFG *eq_cfg, u8 *path);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 在线调试的回调
|
||||
@param *packet:数据包
|
||||
@param size:数据包长度
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void eq_online_callback(uint8_t *packet, uint16_t size);//
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq系数回调
|
||||
@param *eq:eq句柄
|
||||
@param sr:采样率
|
||||
@param info:系数结构
|
||||
@return
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int eq_get_filter_info(void *_eq, int sr, struct audio_eq_filter_info *info);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief drc系数回调
|
||||
@param *drc:drc句柄
|
||||
@param info:系数结构
|
||||
@return
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int drc_get_filter_info(void *_drc, struct audio_drc_filter_info *info);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief aec eq系数 回调
|
||||
@param *eq:eq句柄
|
||||
@param sr:采样率
|
||||
@param info:系数结构
|
||||
@return
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int aec_ul_eq_filter(void *_eq, int sr, struct audio_eq_filter_info *info);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 通话eq系数 的回调函数
|
||||
@param *eq:eq句柄
|
||||
@param sr:采样率
|
||||
@param info:系数结构
|
||||
@return
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int eq_phone_get_filter_info(void *_eq, int sr, struct audio_eq_filter_info *info);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief drc系数更新检测
|
||||
@param *drc:drc句柄
|
||||
@return
|
||||
@note 内部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void drc_app_run_check(struct audio_drc *drc);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 普通音频eq,无离线文件时,获取某eq效果模式的中心截止频率
|
||||
@param mode:EQ_MODE_NORMAL, EQ_MODE_ROCK,EQ_MODE_POP,EQ_MODE_CLASSIC,EQ_MODE_JAZZ,EQ_MODE_COUNTRY, EQ_MODE_CUSTOM
|
||||
@param index:哪一段
|
||||
@return 中心截止频率
|
||||
@note 外部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int eq_mode_get_freq(EQ_MODE mode, u16 index);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief eq系数更新检测
|
||||
@param *eq:eq句柄
|
||||
@return
|
||||
@note 内部使用
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void eq_app_run_check(struct audio_eq *eq);
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
static const struct eq_seg_info your_audio_out_eq_tab[] = {
|
||||
#ifdef EQ_CORE_V1
|
||||
{0, EQ_IIR_TYPE_BAND_PASS, 125, 0, 0.7f)},
|
||||
{1, EQ_IIR_TYPE_BAND_PASS, 12000, 0, 0.3f)},
|
||||
#else
|
||||
{0, EQ_IIR_TYPE_BAND_PASS, 125, 0 << 20, (int)(0.7f * (1 << 24))},
|
||||
{1, EQ_IIR_TYPE_BAND_PASS, 12000, 0 << 20, (int)(0.3f * (1 << 24))},
|
||||
#endif
|
||||
};
|
||||
float your_eq_coeff_tab[2][5];
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 用户自定义eq的系数回调
|
||||
@param eq:句柄
|
||||
@param sr:采样率
|
||||
@param info: 系数地址
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_eq_get_filter_info_demo(void *_eq, int sr, struct audio_eq_filter_info *info)
|
||||
{
|
||||
if (!sr) {
|
||||
sr = 44100;
|
||||
}
|
||||
#if 0
|
||||
struct audio_eq *eq = (struct audio_eq *)_eq;
|
||||
local_irq_disable();
|
||||
u8 nsection = ARRAY_SIZE(your_audio_out_eq_tab);
|
||||
if (!eq->eq_seg_tab) {
|
||||
int size = sizeof(your_audio_out_eq_tab);
|
||||
eq->eq_seg_tab = zalloc(size);
|
||||
memcpy(eq->eq_seg_tab, your_audio_out_eq_tab, size);
|
||||
}
|
||||
if (!eq->eq_coeff_tab) {
|
||||
eq->eq_coeff_tab = zalloc(sizeof(int) * 5 * nsection);
|
||||
}
|
||||
for (int i = 0; i < nsection; i++) {
|
||||
eq_seg_design(&eq->eq_seg_tab[i], sr, &eq->eq_coeff_tab[5 * i]);
|
||||
}
|
||||
|
||||
local_irq_enable();
|
||||
info->L_coeff = info->R_coeff = (void *)eq->eq_coeff_tab;
|
||||
info->L_gain = info->R_gain = 0;
|
||||
info->nsection = nsection;
|
||||
#else
|
||||
local_irq_disable();
|
||||
u8 nsection = ARRAY_SIZE(your_audio_out_eq_tab);
|
||||
for (int i = 0; i < nsection; i++) {
|
||||
eq_seg_design(&your_audio_out_eq_tab[i], sr, &your_eq_coeff_tab[i]);
|
||||
}
|
||||
local_irq_enable();
|
||||
info->L_coeff = info->R_coeff = (void *)your_eq_coeff_tab;//系数指针赋值
|
||||
info->L_gain = info->R_gain = 0;//总增益填写,用户可修改(-20~20db)
|
||||
info->nsection = nsection;//eq段数,根据提供给的系数表来填写,例子是2
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct drc_ch drc_fliter = {0};
|
||||
#define your_threshold (0)
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 自定义限幅器系数回调
|
||||
@param *drc: 句柄
|
||||
@param *info: 系数结构地址
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int drc_get_filter_info_demo(void *drc, struct audio_drc_filter_info *info)
|
||||
{
|
||||
int th = your_threshold;//-60 ~0db
|
||||
int threshold = roundf(powf(10.0f, th / 20.0f) * 32768); // 0db:32768, -60db:33
|
||||
|
||||
drc_fliter.nband = 1;
|
||||
drc_fliter.type = 1;
|
||||
drc_fliter._p.limiter[0].attacktime = 5;
|
||||
drc_fliter._p.limiter[0].releasetime = 300;
|
||||
drc_fliter._p.limiter[0].threshold[0] = threshold;
|
||||
drc_fliter._p.limiter[0].threshold[1] = 32768;
|
||||
|
||||
info->pch = info->R_pch = &drc_fliter;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
struct drc_ch drc_fliter2 = {0};
|
||||
#define your_threshold1 (0)
|
||||
#define your_threshold2 (0)
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 自定义压缩器系数回调
|
||||
@param *drc: 句柄
|
||||
@param *info: 系数结构地址
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int drc_get_filter_info_demo2(void *drc, struct audio_drc_filter_info *info)
|
||||
{
|
||||
int th1 = your_threshold1;//-60 ~0db
|
||||
int th2 = your_threshold2;//-60 ~0db
|
||||
|
||||
int your_ratio0 = 800;//100~1000
|
||||
int your_ratio1 = 900;//100~1000
|
||||
|
||||
|
||||
if (th2 < th1) { //阈值2需大于等于阈值1
|
||||
th2 = th1;
|
||||
}
|
||||
if (your_ratio1 < your_ratio0) { //压缩比2需要大于等于压缩比1
|
||||
your_ratio1 = your_ratio0;
|
||||
}
|
||||
|
||||
int threshold0 = roundf(powf(10.0f, th1 / 20.0f) * 32768); // 0db:32768, -60db:33
|
||||
int threshold1 = roundf(powf(10.0f, th2 / 20.0f) * 32768); // 0db:32768, -60db:33
|
||||
|
||||
drc_fliter2.nband = 1;//全带
|
||||
drc_fliter2.type = 2;//压缩器
|
||||
drc_fliter2._p.compressor[0].attacktime = 5;
|
||||
drc_fliter2._p.compressor[0].releasetime = 300;
|
||||
drc_fliter2._p.compressor[0].threshold[0] = threshold0;
|
||||
drc_fliter2._p.compressor[0].threshold[1] = threshold1;
|
||||
drc_fliter2._p.compressor[0].threshold[2] = 32768;
|
||||
|
||||
drc_fliter2._p.compressor[0].ratio[0] = 100;
|
||||
drc_fliter2._p.compressor[0].ratio[1] = your_ratio0;
|
||||
drc_fliter2._p.compressor[0].ratio[2] = your_ratio1;
|
||||
|
||||
info->pch = info->R_pch = &drc_fliter2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//修改自定义模式eq系数表,更新系数到eq 方法
|
||||
// 板极头文件中 这两宏 配0
|
||||
#define TCFG_EQ_ONLINE_ENABLE 0 //支持在线EQ调试,
|
||||
#define TCFG_USE_EQ_FILE 0 //离线eq使用配置文件还是默认系数表 1:使用文件 0 使用默认系数表
|
||||
|
||||
|
||||
// 在sdk中实现以下接函数
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 设置用户自定义模式每段eq信息
|
||||
@param
|
||||
@param
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int eq_mode_set_custom_info_user(struct eq_seg_info *seg)
|
||||
{
|
||||
if (!config_audio_eq_file_en) {
|
||||
if (!seg) {
|
||||
return 0;
|
||||
}
|
||||
u16 index = seg->index; //第几段eq
|
||||
EQ_CFG *eq_cfg = get_eq_cfg_hdl();
|
||||
if (index >= eq_cfg->section_max) {
|
||||
return 0;
|
||||
}
|
||||
int *tmp = (int *)eq_cfg->eq_type_tab;
|
||||
EQ_CFG_SEG *tab_custom = (EQ_CFG_SEG *)tmp[EQ_MODE_CUSTOM];
|
||||
|
||||
index = eq_cfg->eq_mode_use_idx[index];
|
||||
memcpy(&tab_custom[index], seg, sizeof(struct eq_seg_info));//更新参数到自定义模式系数表
|
||||
|
||||
/* log_debug("idx:%d, iir:%d, freq:%d, gain:0x%x, q:0x%x ", seg->index, seg->iir_type, seg->freq, *(int *)&seg->gain, *(int *)&seg->q); */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 获取某个模式eq表内,某一段eq的信息
|
||||
@param
|
||||
@param
|
||||
@return 返回eq信息
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
struct eq_seg_info *eq_mode_get_custom_info_user(EQ_MODE mode, u8 index)
|
||||
{
|
||||
if (!config_audio_eq_file_en) {
|
||||
|
||||
EQ_CFG *eq_cfg = get_eq_cfg_hdl();
|
||||
if (index >= eq_cfg->section_max) {
|
||||
return 0;
|
||||
}
|
||||
int *tmp = (int *)eq_cfg->eq_type_tab;
|
||||
EQ_CFG_SEG *seg = (EQ_CFG_SEG *)tmp[mode];
|
||||
|
||||
index = eq_cfg->eq_mode_use_idx[index];
|
||||
/* log_debug("idx:%d, iir:%d, freq:%d, gain:0x%x, q:0x%x ", seg->index, seg->iir_type, seg->freq, *(int *)&seg->gain, *(int *)&seg->q); */
|
||||
return &seg[index];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*设置总增益后,需要设置更新*/
|
||||
void update_global_gain_demo(float global_gain)
|
||||
{
|
||||
EQ_CFG *eq_cfg = get_eq_cfg_hdl();
|
||||
set_global_gain(eq_cfg, song_eq_mode, global_gain);//设置总增益,
|
||||
eq_mode_set(EQ_MODE_CUSTOM);//设置自定义模式、更新系数以及总增益
|
||||
}
|
||||
|
||||
/*设置参数后,需要设置更新*/
|
||||
void update_eq_seg_info_demo(struct eq_seg_info *seg)
|
||||
{
|
||||
eq_mode_set_custom_info_user(seg);//更新参数到自定义模式系数表
|
||||
eq_mode_set(EQ_MODE_CUSTOM);//设置自定义模式、更新系数以及总增益
|
||||
}
|
||||
void update_custom_info_demo2(u16 index, int freq, float gain)
|
||||
{
|
||||
eq_mode_set_custom_info(index, freq, gain);/*改某一段eq的的中心截止频率 以及增益*/
|
||||
eq_mode_set(EQ_MODE_CUSTOM);//设置自定义模式、更新系数以及总增益
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif//EQ_CORE_V1
|
||||
|
||||
@ -0,0 +1,67 @@
|
||||
#ifndef _EQ_FUNC_DEFINE_H
|
||||
#define _EQ_FUNC_DEFINE_H
|
||||
|
||||
#include "generic/typedef.h"
|
||||
|
||||
extern u32 EQ_PRIV_SECTION_NUM;
|
||||
extern u32 EQ_SECTION_NUM;
|
||||
extern const int const_eq_debug;
|
||||
extern const int config_audio_drc_en;
|
||||
extern const int config_audio_eq_en;
|
||||
enum {
|
||||
EQ_EN = BIT(0),//eq模式使能
|
||||
EQ_SUPPORT_OLD_VER_EN = BIT(1),//ac700N,使能该bit可版本0.7.1.0, 0.7.1.1
|
||||
EQ_LITE_VER_EN = BIT(2),//精简版版本eq驱动,不支持异步,不支持默认效果切换接口,仅支持文件解析
|
||||
EQ_ONLINE_EN = BIT(3), //在线调试模块使能
|
||||
EQ_FILE_EN = BIT(4),//打开支持文件解析,关闭则只能使用默认效果表做eq
|
||||
EQ_FILE_SWITCH_EN = BIT(5),//打开支持eq_cfg_hw.bin文件切换更新效果
|
||||
EQ_HIGH_BASS_EN = BIT(6),//eq内部集成的高低音接口使能
|
||||
EQ_HIGH_BASS_FADE_EN = BIT(7),//eq内部集成高低音淡入淡出效果方式使能,配合config_audio_eq_fade_step使用
|
||||
EQ_FILTER_COEFF_FADE_EN = BIT(8),//eq默认系数表效果切换,或者在线调试效果更新,使用淡入淡出方式,避免增益跳跃引起的杂音问题
|
||||
EQ_FILTER_COEFF_LIMITER_ZERO_EN = BIT(9),//
|
||||
EQ_HW_UPDATE_COEFF_ONLY_EN = BIT(10),// 有空闲的段可以使用,就不需要切换系数 */
|
||||
EQ_HW_LR_ALONE = BIT(11),//// 左右声道分开处理与bit(10),同时使能或关闭
|
||||
EQ_SUPPORT_32BIT_SYNC_EN = BIT(12),//// 支持同步方式32biteq
|
||||
EQ_SUPPORT_MULIT_CHANNEL_EN = BIT(13),//AC699N、AC700N eq是否支持多声道(3~8) 打开:支持 关闭:仅支持1~2声道
|
||||
EQ_HW_CROSSOVER_TYPE0_EN = BIT(14),//支持硬件分频器,且分频器使用序列进序列出,需使能BIT(13)
|
||||
EQ_HW_CROSSOVER_TYPE1_EN = BIT(15),//硬件分频器使用使用块出方式,会增加mem(该方式仅支持单声道处理)
|
||||
EQ_LR_DIVIDE_EN = BIT(16),//eq左右声道效果拆分,四声道时可能会使用
|
||||
EQ_ONLINE_FILE_SAVE = BIT(17),//eq在线调试保存到vm使能
|
||||
};
|
||||
|
||||
#define config_audio_eq_online_en (config_audio_eq_en & EQ_ONLINE_EN)
|
||||
#define config_audio_eq_file_en (config_audio_eq_en & EQ_FILE_EN)
|
||||
#define config_audio_eq_file_sw_en (config_audio_eq_en & EQ_FILE_SWITCH_EN)
|
||||
#define config_filter_coeff_fade_en (config_audio_eq_en & EQ_FILTER_COEFF_FADE_EN)
|
||||
#define config_high_bass_en (config_audio_eq_en & EQ_HIGH_BASS_EN)
|
||||
#define config_audio_eq_fade_en (config_audio_eq_en & EQ_HIGH_BASS_FADE_EN)
|
||||
#define config_filter_coeff_limit_zero (config_audio_eq_en & EQ_FILTER_COEFF_LIMITER_ZERO_EN)
|
||||
#define HW_EQ_UPDATE_COEFF_ONLY_EN (config_audio_eq_en & EQ_HW_UPDATE_COEFF_ONLY_EN)
|
||||
#define HW_EQ_LR_ALONE (config_audio_eq_en & EQ_HW_LR_ALONE)
|
||||
#define SUPPORT_32BIT_SYNC_EQ (config_audio_eq_en & EQ_SUPPORT_32BIT_SYNC_EN)
|
||||
#define hw_eq_support_multi_channels (config_audio_eq_en & EQ_SUPPORT_MULIT_CHANNEL_EN)
|
||||
#define hw_crossover_type0 (config_audio_eq_en & EQ_HW_CROSSOVER_TYPE0_EN)
|
||||
#define hw_crossover_type1 (config_audio_eq_en & EQ_HW_CROSSOVER_TYPE1_EN)
|
||||
#define config_eq_lite_en (config_audio_eq_en & EQ_LITE_VER_EN)
|
||||
#define config_eq_support_old_ver_en (config_audio_eq_en & EQ_SUPPORT_OLD_VER_EN)
|
||||
#define config_divide_en (config_audio_eq_en & EQ_LR_DIVIDE_EN)
|
||||
#define config_eq_online_file_save (config_audio_eq_en & EQ_ONLINE_FILE_SAVE)
|
||||
|
||||
extern const int config_audio_drc_en;
|
||||
enum {
|
||||
DRC_EN = BIT(0), //drc 使能
|
||||
DRC_NBAND_MERGING_ASM_EN = BIT(1),//drc 多带处理完后,多带合并使用汇编加速
|
||||
DRC_NBAND_DIS = BIT(2),//关闭drc多带
|
||||
DRC_LIMITER_DIS = BIT(3),//关闭drc限幅器
|
||||
DRC_COMPRESSOF_DIS = BIT(4),//关闭drc压缩器
|
||||
WDRC_TYPE_EN = BIT(5),//wdrc使能
|
||||
};
|
||||
|
||||
#define config_drc_limiter_en (!(config_audio_drc_en & DRC_LIMITER_DIS))
|
||||
#define config_drc_compressor_en (!(config_audio_drc_en & DRC_COMPRESSOF_DIS))
|
||||
#define config_drc_nband_en (!(config_audio_drc_en & DRC_NBAND_DIS))
|
||||
#define config_drc_nband_merg_asm_en (!(config_audio_drc_en & DRC_NBAND_MERGING_ASM_EN))
|
||||
#define config_wdrc_en (config_audio_drc_en & WDRC_TYPE_EN)
|
||||
|
||||
|
||||
#endif
|
||||
90
include_lib/media/media_new/media/audio_base.h
Normal file
90
include_lib/media/media_new/media/audio_base.h
Normal file
@ -0,0 +1,90 @@
|
||||
#ifndef AUDIO_BASE_H
|
||||
#define AUDIO_BASE_H
|
||||
|
||||
|
||||
|
||||
#define AUDIO_CODING_UNKNOW 0x00000000
|
||||
#define AUDIO_CODING_MP3 0x00000001
|
||||
#define AUDIO_CODING_WMA 0x00000002
|
||||
#define AUDIO_CODING_WAV 0x00000004
|
||||
#define AUDIO_CODING_SBC 0x00000010
|
||||
#define AUDIO_CODING_MSBC 0x00000020
|
||||
#define AUDIO_CODING_G729 0x00000040
|
||||
#define AUDIO_CODING_CVSD 0x00000080
|
||||
#define AUDIO_CODING_PCM 0x00000100
|
||||
#define AUDIO_CODING_AAC 0x00000200
|
||||
#define AUDIO_CODING_MTY 0x00000400
|
||||
#define AUDIO_CODING_FLAC 0x00000800
|
||||
#define AUDIO_CODING_APE 0x00001000
|
||||
#define AUDIO_CODING_M4A 0x00002000
|
||||
#define AUDIO_CODING_AMR 0x00004000
|
||||
#define AUDIO_CODING_DTS 0x00008000
|
||||
#define AUDIO_CODING_APTX 0x00010000
|
||||
#define AUDIO_CODING_LDAC 0x00020000
|
||||
#define AUDIO_CODING_G726 0x00040000
|
||||
#define AUDIO_CODING_MIDI 0x00080000
|
||||
#define AUDIO_CODING_OPUS 0x00100000
|
||||
#define AUDIO_CODING_SPEEX 0x00200000
|
||||
#define AUDIO_CODING_LC3 0x00400000
|
||||
#define AUDIO_CODING_WTGV2 0x01000000
|
||||
#define AUDIO_CODING_ALAC 0x02000000
|
||||
|
||||
#define AUDIO_CODING_STU_PICK 0x10000000
|
||||
#define AUDIO_CODING_STU_APP 0x20000000
|
||||
|
||||
#define AUDIO_CODING_FAME_MASK (AUDIO_CODING_MSBC | AUDIO_CODING_CVSD | AUDIO_CODING_SBC)
|
||||
|
||||
#define AUDIO_INPUT_FILE 0x01
|
||||
#define AUDIO_INPUT_FRAME 0x02
|
||||
|
||||
|
||||
enum audio_channel {
|
||||
AUDIO_CH_LR = 0, //立体声
|
||||
AUDIO_CH_L, //左声道(单声道)
|
||||
AUDIO_CH_R, //右声道(单声道)
|
||||
AUDIO_CH_DIFF, //差分(单声道)
|
||||
AUDIO_CH_DUAL_L, //双声道都为左
|
||||
AUDIO_CH_DUAL_R, //双声道都为右
|
||||
AUDIO_CH_DUAL_LR, //双声道为左右混合
|
||||
AUDIO_CH_QUAD, //四声道(LRLR)
|
||||
|
||||
AUDIO_CH_MAX = 0xff,
|
||||
};
|
||||
|
||||
#define AUDIO_CH_MIX_MONO AUDIO_CH_DIFF
|
||||
|
||||
#define AUDIO_CH_IS_MONO(ch) (((ch)==AUDIO_CH_L) || ((ch)==AUDIO_CH_R) || ((ch)==AUDIO_CH_DIFF))
|
||||
#define AUDIO_CH_IS_DUAL(ch) (((ch)==AUDIO_CH_LR) || ((ch)==AUDIO_CH_DUAL_L) || ((ch)==AUDIO_CH_DUAL_R))
|
||||
#define AUDIO_CH_IS_QUAD(ch) (((ch)==AUDIO_CH_QUAD))
|
||||
|
||||
|
||||
/*! \brief 音频处理结构 */
|
||||
struct audio_fmt {
|
||||
u8 channel; /*!< */
|
||||
u16 frame_len; /*!< 幁长度 (bytes)*/
|
||||
u32 sample_rate; /*!< 采样率 e.g. 48kHz/44.1kHz/32kHz*/
|
||||
u32 coding_type;
|
||||
u32 bit_rate; /*!< 比特率 (bps)*/
|
||||
u32 total_time;
|
||||
u32 quality;
|
||||
u32 complexity;
|
||||
void *priv;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
225
include_lib/media/media_new/media/audio_cfifo.h
Normal file
225
include_lib/media/media_new/media/audio_cfifo.h
Normal file
@ -0,0 +1,225 @@
|
||||
/*****************************************************************
|
||||
>file name : audio_cfifo.h
|
||||
>author : lichao
|
||||
>create time : Tue 10 Nov 2020 02:22:37 PM CST
|
||||
*****************************************************************/
|
||||
#ifndef _AUDIO_CFIFO_H_
|
||||
#define _AUDIO_CFIFO_H_
|
||||
#include "generic/list.h"
|
||||
#include "typedef.h"
|
||||
|
||||
#define WRITE_MODE_BLOCK 0
|
||||
#define WRITE_MODE_FORCE 1
|
||||
|
||||
struct audio_cfifo {
|
||||
u8 sample_channel; /*fifo采样声道数*/
|
||||
s16 *addr; /*fifo首地址*/
|
||||
u16 sample_size; /*fifo采样长度*/
|
||||
u16 wp; /*fifo写偏移*/
|
||||
u16 rp; /*fifo读偏移*/
|
||||
u16 lock_rp; /*fifo不可擦写的已读偏移*/
|
||||
u16 free_samples; /*fifo可写入样点个数*/
|
||||
s16 unread_samples; /*fifo未读样点个数*/
|
||||
int sample_rate; /*fifo对应的音频采样率*/
|
||||
u32 sw_ptr;
|
||||
u32 hw_ptr;
|
||||
struct list_head head; /*子通道数据链表头*/
|
||||
};
|
||||
|
||||
struct audio_cfifo_channel {
|
||||
u8 write_mode; /*写入模式*/
|
||||
u16 delay_time; /*最大延时(ms)*/
|
||||
u16 rsp; /*读偏移*/
|
||||
u16 wsp; /*写偏移*/
|
||||
s16 unread_samples; /*通道未读样点个数*/
|
||||
u16 max_samples; /*通道缓冲最大样点个数*/
|
||||
u32 sw_ptr;
|
||||
u32 hw_ptr;
|
||||
struct audio_cfifo *fifo; /*主fifo指针*/
|
||||
struct list_head entry; /*通道接入entry*/
|
||||
};
|
||||
|
||||
/*************************************************************************
|
||||
* Audio cfifo主fifo初始化
|
||||
* INPUT : fifo - 主fifo结构指针,
|
||||
* buf - fifo缓冲地址
|
||||
* len - fifo缓冲长度
|
||||
* sample_rate - fifo音频采样率
|
||||
* channel - fifo音频声道数
|
||||
* OUTPUT : 0 - 成功,非0 - 失败.
|
||||
* WARNINGS : 无.
|
||||
* HISTORY : 2020/12/28 by Lichao.
|
||||
*=======================================================================*/
|
||||
int audio_cfifo_init(struct audio_cfifo *fifo, void *buf, int len, int sample_rate, u8 channel);
|
||||
|
||||
/*************************************************************************
|
||||
* Audio cfifo主fifo复位
|
||||
* INPUT : fifo - 主fifo结构指针,
|
||||
* buf - fifo缓冲地址
|
||||
* len - fifo缓冲长度
|
||||
* sample_rate - fifo音频采样率
|
||||
* channel - fifo音频声道数
|
||||
* OUTPUT : 0 - 成功,非0 - 失败.
|
||||
* WARNINGS : 这里与audio_cfifo_init类似但意义不一样,不可以当作init使用.
|
||||
* HISTORY : 2020/12/28 by Lichao.
|
||||
*=======================================================================*/
|
||||
int audio_cfifo_reset(struct audio_cfifo *fifo, void *buf, int len, int sample_rate, u8 channel);
|
||||
|
||||
/*************************************************************************
|
||||
* 添加fifo子通道
|
||||
* INPUT : fifo - 主fifo结构指针,
|
||||
* ch - fifo子通道
|
||||
* delay_time - 子通道延时
|
||||
* write_mode - 子通道写入模式
|
||||
* OUTPUT : 0 - 成功,非0 - 失败.
|
||||
* WARNINGS : 无.
|
||||
* HISTORY : 2020/12/28 by Lichao.
|
||||
*=======================================================================*/
|
||||
int audio_cfifo_channel_add(struct audio_cfifo *fifo, struct audio_cfifo_channel *ch, int delay_time, u8 write_mode);
|
||||
|
||||
/*************************************************************************
|
||||
* 删除fifo子通道
|
||||
* INPUT : ch - fifo子通道
|
||||
* OUTPUT : 无.
|
||||
* WARNINGS : 无.
|
||||
* HISTORY : 2020/12/28 by Lichao.
|
||||
*=======================================================================*/
|
||||
void audio_cfifo_channel_del(struct audio_cfifo_channel *ch);
|
||||
|
||||
/*************************************************************************
|
||||
* 主fifo读数更新
|
||||
* INPUT : fifo - 主fifo结构指针, samples - 读取的样点个数
|
||||
* OUTPUT : 成功更新的样点个数.
|
||||
* WARNINGS : 无.
|
||||
* HISTORY : 2020/12/28 by Lichao.
|
||||
*=======================================================================*/
|
||||
int audio_cfifo_read_update(struct audio_cfifo *fifo, int samples);
|
||||
|
||||
/*************************************************************************
|
||||
* fifo子通道数据写入
|
||||
* INPUT : ch - fifo子通道, data - 数据指针, len - 数据长度
|
||||
* OUTPUT : 写入fifo的长度.
|
||||
* WARNINGS : 强制写入模式无论是否可以写入都将返回预期写入长度.
|
||||
* HISTORY : 2020/12/28 by Lichao.
|
||||
*=======================================================================*/
|
||||
int audio_cfifo_channel_write(struct audio_cfifo_channel *ch, void *data, int len);
|
||||
|
||||
/*************************************************************************
|
||||
* fifo子通道写入直流数据
|
||||
* INPUT : ch - fifo子通道, data - 直流值, len - 长度
|
||||
* OUTPUT : 写入fifo的长度.
|
||||
* WARNINGS : 强制写入模式无论是否可以写入都将返回预期写入长度.
|
||||
* HISTORY : 2020/12/28 by Lichao.
|
||||
*=======================================================================*/
|
||||
int audio_cfifo_channel_write_fixed_data(struct audio_cfifo_channel *ch, s16 data, int len);
|
||||
|
||||
/*************************************************************************
|
||||
* fifo子通道擦除
|
||||
* INPUT : ch - fifo子通道
|
||||
* OUTPUT : 未知.
|
||||
* WARNINGS : 待开发.
|
||||
* HISTORY : 2020/12/28 by Lichao.
|
||||
*=======================================================================*/
|
||||
int audio_cfifo_channel_clear(struct audio_cfifo_channel *ch);
|
||||
|
||||
/*************************************************************************
|
||||
* 主fifo获取写偏移
|
||||
* INPUT : fifo - 主fifo结构指针
|
||||
* OUTPUT : fifo写入偏移.
|
||||
* WARNINGS : 无.
|
||||
* HISTORY : 2020/12/28 by Lichao.
|
||||
*=======================================================================*/
|
||||
int audio_cfifo_get_write_offset(struct audio_cfifo *fifo);
|
||||
|
||||
/*************************************************************************
|
||||
* 主fifo获取未读样点查询
|
||||
* INPUT : fifo - 主fifo结构指针
|
||||
* OUTPUT : 样点个数.
|
||||
* WARNINGS : 无.
|
||||
* HISTORY : 2020/12/28 by Lichao.
|
||||
*=======================================================================*/
|
||||
int audio_cfifo_get_unread_samples(struct audio_cfifo *fifo);
|
||||
|
||||
/*************************************************************************
|
||||
* 主fifo与子fifo未读样点个数差值
|
||||
* INPUT : ch - fifo子通道
|
||||
* OUTPUT : 样点个数.
|
||||
* WARNINGS : 无.
|
||||
* HISTORY : 2020/12/28 by Lichao.
|
||||
*=======================================================================*/
|
||||
int audio_cfifo_channel_unread_diff_samples(struct audio_cfifo_channel *ch);
|
||||
|
||||
/*************************************************************************
|
||||
* 主fifo通道个数
|
||||
* INPUT : fifo - 主fifo结构指针
|
||||
* OUTPUT : 通道个数.
|
||||
* WARNINGS : 无.
|
||||
* HISTORY : 2020/12/28 by Lichao.
|
||||
*=======================================================================*/
|
||||
int audio_cfifo_channel_num(struct audio_cfifo *fifo);
|
||||
|
||||
/*************************************************************************
|
||||
* 主fifo设置已读样点不可擦除区域
|
||||
* INPUT : fifo - 主fifo结构指针, samples - 不可擦除样点个数
|
||||
* OUTPUT : 无.
|
||||
* WARNINGS : 特殊处理,无需理解,仅作为开发人员使用.
|
||||
* HISTORY : 2020/12/28 by Lichao.
|
||||
*=======================================================================*/
|
||||
void audio_cfifo_set_readlock_samples(struct audio_cfifo *fifo, int samples);
|
||||
|
||||
/*************************************************************************
|
||||
* 获取主fifo设置已读样点不可擦除区域大小
|
||||
* INPUT : fifo - 主fifo结构指针.
|
||||
* OUTPUT : 不可擦除样点个数.
|
||||
* WARNINGS : 特殊处理,无需理解,仅作为开发人员使用.
|
||||
* HISTORY : 2020/12/28 by Lichao.
|
||||
*=======================================================================*/
|
||||
int audio_cfifo_get_readlock_samples(struct audio_cfifo *fifo);
|
||||
|
||||
/*************************************************************************
|
||||
* fifo使用回调读取通道的有效混合数据
|
||||
* INPUT : fifo - 主fifo结构指针
|
||||
* offset - 读偏移
|
||||
* samples - 读取样点个数
|
||||
* priv - 回调私有指针
|
||||
* read_callback - 读回调
|
||||
* OUTPUT : 读取长度.
|
||||
* WARNINGS : 无.
|
||||
* HISTORY : 2020/12/28 by Lichao.
|
||||
*=======================================================================*/
|
||||
int audio_cfifo_read_with_callback(struct audio_cfifo *fifo, int offset, int samples,
|
||||
void *priv, int (*read_callback)(void *priv, void *data, int len));
|
||||
|
||||
/*************************************************************************
|
||||
* fifo子通道未读样点查询
|
||||
* INPUT : ch - fifo子通道
|
||||
* OUTPUT : 样点个数.
|
||||
* WARNINGS : 无.
|
||||
* HISTORY : 2020/12/28 by Lichao.
|
||||
*=======================================================================*/
|
||||
int audio_cfifo_channel_unread_samples(struct audio_cfifo_channel *ch);
|
||||
|
||||
/*************************************************************************
|
||||
* fifo子通道获取写偏移
|
||||
* INPUT : ch - fifo子通道
|
||||
* OUTPUT : 偏移.
|
||||
* WARNINGS : 无.
|
||||
* HISTORY : 2020/12/28 by Lichao.
|
||||
*=======================================================================*/
|
||||
int audio_cfifo_channel_write_offset(struct audio_cfifo_channel *ch);
|
||||
|
||||
/*************************************************************************
|
||||
* fifo获取缓冲最小的子通道
|
||||
* INPUT : fifo - 主fifo结构指针
|
||||
* OUTPUT : fifo子通道指针.
|
||||
* WARNINGS : 无.
|
||||
* HISTORY : 2020/12/28 by Lichao.
|
||||
*=======================================================================*/
|
||||
struct audio_cfifo_channel *audio_cfifo_min_samples_channel(struct audio_cfifo *fifo);
|
||||
|
||||
int audio_cfifo_get_sw_ptr(struct audio_cfifo *fifo);
|
||||
|
||||
int audio_cfifo_get_hw_ptr(struct audio_cfifo *fifo);
|
||||
|
||||
int audio_cfifo_read_data(struct audio_cfifo *fifo, s16 *out_buf, int len);
|
||||
#endif
|
||||
299
include_lib/media/media_new/media/audio_decoder.h
Normal file
299
include_lib/media/media_new/media/audio_decoder.h
Normal file
@ -0,0 +1,299 @@
|
||||
#ifndef AUDIO_DECODER_H
|
||||
#define AUDIO_DECODER_H
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "generic/list.h"
|
||||
#include "media/audio_base.h"
|
||||
#include "os/os_api.h"
|
||||
|
||||
|
||||
|
||||
enum {
|
||||
AUDIO_DEC_EVENT_CURR_TIME = 0x20,
|
||||
AUDIO_DEC_EVENT_END,
|
||||
AUDIO_DEC_EVENT_ERR,
|
||||
AUDIO_DEC_EVENT_SUSPEND,
|
||||
AUDIO_DEC_EVENT_RESUME,
|
||||
AUDIO_DEC_EVENT_START,
|
||||
};
|
||||
|
||||
enum {
|
||||
AUDIO_PLAY_EVENT_CURR_TIME = 0x20,
|
||||
AUDIO_PLAY_EVENT_END,
|
||||
AUDIO_PLAY_EVENT_ERR,
|
||||
AUDIO_PLAY_EVENT_SUSPEND,
|
||||
AUDIO_PLAY_EVENT_RESUME,
|
||||
};
|
||||
|
||||
enum {
|
||||
AUDIO_RES_GET,
|
||||
AUDIO_RES_PUT,
|
||||
};
|
||||
|
||||
enum {
|
||||
DEC_STA_TRY_START,
|
||||
DEC_STA_START,
|
||||
DEC_STA_WAIT_STOP,
|
||||
DEC_STA_WAIT_SUSPEND,
|
||||
DEC_STA_WAIT_RESUME,
|
||||
DEC_STA_WAIT_PAUSE,
|
||||
};
|
||||
|
||||
enum {
|
||||
AUDIO_IOCTRL_CMD_REPEAT_PLAY = 0x90,
|
||||
};
|
||||
|
||||
struct fixphase_repair_obj {
|
||||
short fifo_buf[18 + 12][32][2];
|
||||
};
|
||||
|
||||
struct audio_repeat_mode_param {
|
||||
int flag;
|
||||
int headcut_frame;
|
||||
int tailcut_frame;
|
||||
int (*repeat_callback)(void *);
|
||||
void *callback_priv;
|
||||
struct fixphase_repair_obj *repair_buf;
|
||||
};
|
||||
|
||||
struct audio_res_wait {
|
||||
struct list_head entry;
|
||||
u8 priority;
|
||||
u8 preemption : 1;
|
||||
u8 protect : 1;
|
||||
u8 only_del : 1; // 仅删除
|
||||
u8 snatch_same_prio : 1; // 优先级相同也抢断
|
||||
u32 format;
|
||||
int (*handler)(struct audio_res_wait *, int event);
|
||||
};
|
||||
|
||||
struct audio_decoder_task {
|
||||
struct list_head head;
|
||||
struct list_head wait;
|
||||
const char *name;
|
||||
int wakeup_timer;
|
||||
int fmt_lock;
|
||||
OS_SEM sem;
|
||||
};
|
||||
|
||||
|
||||
struct audio_dec_breakpoint {
|
||||
int len;
|
||||
u32 fptr;
|
||||
int data_len;
|
||||
u8 data[0];
|
||||
// u8 data[128];
|
||||
};
|
||||
|
||||
struct audio_decoder;
|
||||
|
||||
|
||||
struct audio_dec_input {
|
||||
u32 coding_type;
|
||||
// 定义在p_more_coding_type数组中的解码器会依照顺序依次检测
|
||||
// 先检测coding_type再检测p_more_coding_type
|
||||
u32 *p_more_coding_type;
|
||||
u32 data_type : 8;
|
||||
union {
|
||||
struct {
|
||||
int (*fread)(struct audio_decoder *, void *buf, u32 len);
|
||||
int (*fseek)(struct audio_decoder *, u32 offset, int seek_mode);
|
||||
int (*ftell)(struct audio_decoder *);
|
||||
int (*flen)(struct audio_decoder *);
|
||||
} file;
|
||||
|
||||
struct {
|
||||
int (*fget)(struct audio_decoder *, u8 **frame);
|
||||
void (*fput)(struct audio_decoder *, u8 *frame);
|
||||
int (*ffetch)(struct audio_decoder *, u8 **frame);
|
||||
} frame;
|
||||
} ops;
|
||||
};
|
||||
|
||||
struct audio_dec_handler {
|
||||
int (*dec_probe)(struct audio_decoder *);
|
||||
int (*dec_output)(struct audio_decoder *, s16 *data, int len, void *priv);
|
||||
int (*dec_post)(struct audio_decoder *);
|
||||
int (*dec_stop)(struct audio_decoder *);
|
||||
};
|
||||
struct stream_codec_info {
|
||||
int time;
|
||||
int frame_num;
|
||||
u32 frame_len;
|
||||
int frame_points;
|
||||
int sequence_number;
|
||||
u32 sample_rate;
|
||||
u8 channel;
|
||||
};
|
||||
|
||||
/*! \brief 音频解码器抽象接口 */
|
||||
struct audio_decoder_ops {
|
||||
u32 coding_type; /*!< 解码格式*/
|
||||
void *(*open)(void *priv); /*!< */
|
||||
int (*start)(void *); /*!< */
|
||||
int (*get_fmt)(void *, struct audio_fmt *fmt);
|
||||
int (*set_output_channel)(void *, enum audio_channel);
|
||||
int (*get_play_time)(void *);
|
||||
int (*fast_forward)(void *, int step_s);
|
||||
int (*fast_rewind)(void *, int step_s);
|
||||
int (*get_breakpoint)(void *, struct audio_dec_breakpoint *);
|
||||
int (*set_breakpoint)(void *, struct audio_dec_breakpoint *);
|
||||
int (*stream_info_scan)(void *, struct stream_codec_info *info, void *data, int len);
|
||||
int (*set_tws_mode)(void *, int);
|
||||
int (*run)(void *, u8 *);
|
||||
int (*stop)(void *);
|
||||
int (*close)(void *);
|
||||
int (*reset)(void *);
|
||||
int (*ioctrl)(void *, u32 cmd, void *parm);
|
||||
};
|
||||
|
||||
#define REGISTER_AUDIO_DECODER(ops) \
|
||||
const struct audio_decoder_ops ops SEC(.audio_decoder)
|
||||
|
||||
extern const struct audio_decoder_ops audio_decoder_begin[];
|
||||
extern const struct audio_decoder_ops audio_decoder_end[];
|
||||
|
||||
#define list_for_each_audio_decoder(p) \
|
||||
for (p = audio_decoder_begin; p < audio_decoder_end; p++)
|
||||
|
||||
|
||||
|
||||
|
||||
struct audio_decoder {
|
||||
struct list_head entry;
|
||||
struct audio_decoder_task *task;
|
||||
struct audio_fmt fmt;
|
||||
const char *evt_owner;
|
||||
const struct audio_dec_input *input;
|
||||
const struct audio_decoder_ops *dec_ops;
|
||||
const struct audio_dec_handler *dec_handler;
|
||||
void (*evt_handler)(struct audio_decoder *dec, int, int *);
|
||||
void *dec_priv;
|
||||
void *bp;
|
||||
u16 id;
|
||||
u16 pick : 1;
|
||||
u16 tws : 1;
|
||||
u16 resume_flag : 1;
|
||||
u16 output_err : 1;
|
||||
u16 read_err : 1;
|
||||
u16 reserved : 11;
|
||||
u8 run_max;
|
||||
u8 output_channel;
|
||||
u8 state;
|
||||
u8 err;
|
||||
u8 remain;
|
||||
u32 magic;
|
||||
};
|
||||
|
||||
#define AUDIO_DEC_ORIG_CH AUDIO_CH_LR
|
||||
#define AUDIO_DEC_L_CH AUDIO_CH_L
|
||||
#define AUDIO_DEC_R_CH AUDIO_CH_R
|
||||
#define AUDIO_DEC_MONO_LR_CH AUDIO_CH_DIFF
|
||||
#define AUDIO_DEC_DUAL_L_CH AUDIO_CH_DUAL_L
|
||||
#define AUDIO_DEC_DUAL_R_CH AUDIO_CH_DUAL_R
|
||||
#define AUDIO_DEC_DUAL_LR_CH AUDIO_CH_DUAL_LR
|
||||
|
||||
#define AUDIO_DEC_IS_MONO(ch) (((ch)==AUDIO_DEC_L_CH) || ((ch)==AUDIO_DEC_R_CH) || ((ch)==AUDIO_DEC_MONO_LR_CH))
|
||||
|
||||
int audio_decoder_task_create(struct audio_decoder_task *task, const char *name);
|
||||
|
||||
int audio_decoder_task_add_wait(struct audio_decoder_task *, struct audio_res_wait *);
|
||||
|
||||
void audio_decoder_task_del_wait(struct audio_decoder_task *, struct audio_res_wait *);
|
||||
int audio_decoder_task_wait_state(struct audio_decoder_task *task);
|
||||
|
||||
int audio_decoder_resume_all(struct audio_decoder_task *task);
|
||||
int audio_decoder_resume_off_limits(struct audio_decoder_task *task, u8 limit_num, int *limit_dec);
|
||||
|
||||
int audio_decoder_resume_all_by_sem(struct audio_decoder_task *task, int time_out);
|
||||
|
||||
int audio_decoder_fmt_lock(struct audio_decoder_task *task, int fmt);
|
||||
|
||||
int audio_decoder_fmt_unlock(struct audio_decoder_task *task, int fmt);
|
||||
|
||||
void *audio_decoder_get_output_buff(void *_dec, int *len);
|
||||
|
||||
int audio_decoder_put_output_buff(void *_dec, void *buff, int len, void *priv);
|
||||
|
||||
int audio_decoder_read_data(void *_dec, u8 *data, int len, u32 offset);
|
||||
|
||||
int audio_decoder_get_input_data_len(void *_dec);
|
||||
|
||||
int audio_decoder_get_frame(void *_dec, u8 **frame);
|
||||
|
||||
int audio_decoder_fetch_frame(void *_dec, u8 **frame);
|
||||
|
||||
void audio_decoder_put_frame(void *_dec, u8 *frame);
|
||||
|
||||
int audio_fmt_find_frame(void *_dec, u8 **frame);
|
||||
int audio_decoder_open(struct audio_decoder *dec, const struct audio_dec_input *input,
|
||||
struct audio_decoder_task *task);
|
||||
|
||||
int audio_decoder_data_type(void *_dec);
|
||||
|
||||
void audio_decoder_set_id(struct audio_decoder *dec, int);
|
||||
|
||||
int audio_decoder_get_fmt(struct audio_decoder *dec, struct audio_fmt **fmt);
|
||||
|
||||
int audio_decoder_set_fmt(struct audio_decoder *dec, struct audio_fmt *fmt);
|
||||
|
||||
int audio_decoder_get_fmt_info(struct audio_decoder *dec, struct audio_fmt *fmt);
|
||||
|
||||
void audio_decoder_set_handler(struct audio_decoder *dec, const struct audio_dec_handler *handler);
|
||||
|
||||
|
||||
void audio_decoder_set_event_handler(struct audio_decoder *dec,
|
||||
void (*handler)(struct audio_decoder *, int, int *), u32 magic);
|
||||
|
||||
void audio_decoder_set_input_buff(struct audio_decoder *dec, u8 *buff, u16 buff_size);
|
||||
|
||||
void audio_decoder_set_output_buffs(struct audio_decoder *dec, s16 *buffs,
|
||||
u16 buff_size, u8 buff_num);
|
||||
|
||||
int audio_decoder_set_output_channel(struct audio_decoder *dec, enum audio_channel);
|
||||
|
||||
int audio_decoder_start(struct audio_decoder *dec);
|
||||
|
||||
int audio_decoder_stop(struct audio_decoder *dec);
|
||||
|
||||
int audio_decoder_pause(struct audio_decoder *dec);
|
||||
|
||||
int audio_decoder_suspend(struct audio_decoder *dec, int timeout_ms);
|
||||
|
||||
int audio_decoder_resume(struct audio_decoder *dec);
|
||||
|
||||
int audio_decoder_close(struct audio_decoder *dec);
|
||||
int audio_decoder_reset(struct audio_decoder *dec);
|
||||
|
||||
int audio_decoder_set_breakpoint(struct audio_decoder *dec, struct audio_dec_breakpoint *bp);
|
||||
|
||||
int audio_decoder_get_breakpoint(struct audio_decoder *dec, struct audio_dec_breakpoint *bp);
|
||||
|
||||
int audio_decoder_forward(struct audio_decoder *dec, int step_s);
|
||||
|
||||
int audio_decoder_rewind(struct audio_decoder *dec, int step_s);
|
||||
|
||||
int audio_decoder_get_total_time(struct audio_decoder *dec);
|
||||
int audio_decoder_get_play_time(struct audio_decoder *dec);
|
||||
|
||||
int audio_decoder_set_pick_stu(struct audio_decoder *dec, u8 pick);
|
||||
int audio_decoder_get_pick_stu(struct audio_decoder *dec);
|
||||
|
||||
int audio_decoder_set_tws_stu(struct audio_decoder *dec, u8 tws);
|
||||
int audio_decoder_get_tws_stu(struct audio_decoder *dec);
|
||||
|
||||
int audio_decoder_set_run_max(struct audio_decoder *dec, u8 run_max);
|
||||
|
||||
void audio_decoder_dual_switch(u8 ch_type, u8 half_lr, s16 *data, int len);
|
||||
|
||||
int audio_decoder_running_number(struct audio_decoder_task *task);
|
||||
|
||||
int audio_decoder_ioctrl(struct audio_decoder *dec, u32 cmd, void *parm);
|
||||
|
||||
void audio_decoder_set_channel(void *_dec, u8 ch_num);
|
||||
int audio_decoder_get_channel(void *_dec);
|
||||
int audio_decoder_get_frame_len(void *_dec);
|
||||
int audio_decoder_get_sample_rate(void *_dec);
|
||||
int audio_decoder_get_bit_rate(void *_dec);
|
||||
#endif
|
||||
|
||||
160
include_lib/media/media_new/media/audio_encoder.h
Normal file
160
include_lib/media/media_new/media/audio_encoder.h
Normal file
@ -0,0 +1,160 @@
|
||||
#ifndef AUDIO_ENCODER_H
|
||||
#define AUDIO_ENCODER_H
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "generic/list.h"
|
||||
#include "generic/circular_buf.h"
|
||||
#include "media/audio_base.h"
|
||||
|
||||
|
||||
|
||||
enum {
|
||||
AUDIO_ENC_EVENT_CURR_TIME = 0x20,
|
||||
AUDIO_ENC_EVENT_END,
|
||||
AUDIO_ENC_EVENT_ERR,
|
||||
AUDIO_ENC_EVENT_SUSPEND,
|
||||
AUDIO_ENC_EVENT_RESUME,
|
||||
};
|
||||
|
||||
|
||||
struct audio_encoder_task {
|
||||
struct list_head head;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
|
||||
struct audio_encoder;
|
||||
|
||||
|
||||
struct audio_enc_input {
|
||||
int (*fget)(struct audio_encoder *, s16 **frame, u16 frame_len);
|
||||
void (*fput)(struct audio_encoder *, s16 *frame);
|
||||
};
|
||||
|
||||
struct audio_enc_handler {
|
||||
int (*enc_probe)(struct audio_encoder *);
|
||||
int (*enc_output)(struct audio_encoder *, u8 *data, int len);
|
||||
int (*enc_post)(struct audio_encoder *);
|
||||
int (*enc_close)(struct audio_encoder *);//add by wuxu 20200221
|
||||
};
|
||||
|
||||
struct audio_encoder_ops {
|
||||
u32 coding_type;
|
||||
void *(*open)(void *priv);
|
||||
int (*start)(void *);
|
||||
int (*set_fmt)(void *, struct audio_fmt *fmt);
|
||||
int (*run)(void *);
|
||||
int (*stop)(void *);
|
||||
int (*close)(void *);
|
||||
int (*ioctrl)(void *, int argc, int argv[]);
|
||||
};
|
||||
|
||||
#define REGISTER_AUDIO_ENCODER(ops) \
|
||||
const struct audio_encoder_ops ops SEC(.audio_encoder)
|
||||
|
||||
extern const struct audio_encoder_ops audio_encoder_begin[];
|
||||
extern const struct audio_encoder_ops audio_encoder_end[];
|
||||
|
||||
#define list_for_each_audio_encoder(p) \
|
||||
for (p = audio_encoder_begin; p < audio_encoder_end; p++)
|
||||
|
||||
|
||||
#define AUDIO_ENC_OS_MUTEX_EN 1
|
||||
|
||||
#if (AUDIO_ENC_OS_MUTEX_EN)
|
||||
#include "os/os_api.h"
|
||||
#endif//AUDIO_ENC_OS_MUTEX_EN
|
||||
|
||||
struct audio_encoder {
|
||||
struct list_head entry;
|
||||
struct audio_encoder_task *task;
|
||||
struct audio_fmt fmt;
|
||||
const char *evt_owner;
|
||||
const struct audio_enc_input *input;
|
||||
const struct audio_encoder_ops *enc_ops;
|
||||
const struct audio_enc_handler *enc_handler;
|
||||
void (*evt_handler)(struct audio_encoder *enc, int, int *);
|
||||
void *enc_priv;
|
||||
u32 pend_timeout;
|
||||
s16 *pcm_frame;
|
||||
u16 pcm_remain;
|
||||
u16 pcm_len;
|
||||
s16 *output_buffs;
|
||||
u16 output_buff_size;
|
||||
u8 output_buff_num;
|
||||
u8 curr_output_buff;
|
||||
u8 output_channel;
|
||||
u8 state;
|
||||
u8 err;
|
||||
volatile u8 resume_flag;
|
||||
u32 magic;
|
||||
#if (AUDIO_ENC_OS_MUTEX_EN)
|
||||
OS_MUTEX mutex;
|
||||
#endif//AUDIO_ENC_OS_MUTEX_EN
|
||||
};
|
||||
|
||||
enum {
|
||||
AUDIO_ENCODER_IOCTRL_CMD_GET_HEAD_INFO = 0x0,
|
||||
AUDIO_ENCODER_IOCTRL_CMD_GET_TIME,
|
||||
AUDIO_ENCODER_IOCTRL_CMD_GET_TMARK,//书签
|
||||
};
|
||||
|
||||
int audio_encoder_task_create(struct audio_encoder_task *task, const char *name);
|
||||
|
||||
int audio_encoder_task_del(struct audio_encoder_task *task);
|
||||
|
||||
int audio_encoder_resume_all(struct audio_encoder_task *task);
|
||||
|
||||
int audio_encoder_get_output_buff(void *_enc, s16 **buf);
|
||||
|
||||
int audio_encoder_put_output_buff(void *_enc, void *buff, int len);
|
||||
|
||||
int audio_encoder_get_frame(void *_enc, s16 **frame, u16 len);
|
||||
|
||||
void audio_encoder_put_frame(void *_enc, s16 *frame);
|
||||
|
||||
int audio_encoder_open(struct audio_encoder *enc, const struct audio_enc_input *input,
|
||||
struct audio_encoder_task *task);
|
||||
|
||||
int audio_encoder_get_fmt(struct audio_encoder *enc, struct audio_fmt **fmt);
|
||||
|
||||
int audio_encoder_set_fmt(struct audio_encoder *enc, struct audio_fmt *fmt);
|
||||
|
||||
void audio_encoder_set_handler(struct audio_encoder *enc, const struct audio_enc_handler *handler);
|
||||
|
||||
|
||||
void audio_encoder_set_event_handler(struct audio_encoder *enc,
|
||||
void (*handler)(struct audio_encoder *, int, int *), u32 maigc);
|
||||
|
||||
void audio_encoder_set_input_buff(struct audio_encoder *enc, u8 *buff, u16 buff_size);
|
||||
|
||||
void audio_encoder_set_output_buffs(struct audio_encoder *enc, s16 *buffs,
|
||||
u16 buff_size, u8 buff_num);
|
||||
|
||||
int audio_encoder_set_output_channel(struct audio_encoder *enc, enum audio_channel);
|
||||
|
||||
int audio_encoder_start(struct audio_encoder *enc);
|
||||
|
||||
int audio_encoder_stop(struct audio_encoder *enc);
|
||||
|
||||
int audio_encoder_suspend(struct audio_encoder *enc, int timeout_ms);
|
||||
|
||||
int audio_encoder_resume(struct audio_encoder *enc);
|
||||
|
||||
int audio_encoder_close(struct audio_encoder *enc);
|
||||
|
||||
int audio_encoder_ioctrl(struct audio_encoder *enc, int argc, ...);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio Encoder Get channel
|
||||
* Description: 获取编码器声道配置参数
|
||||
* Arguments : *enc 编码句柄
|
||||
* Return : 声道数
|
||||
* Note(s) : None
|
||||
*********************************************************************
|
||||
*/
|
||||
int audio_encoder_get_channel(struct audio_encoder *enc);
|
||||
|
||||
#endif
|
||||
|
||||
85
include_lib/media/media_new/media/audio_resample.h
Normal file
85
include_lib/media/media_new/media/audio_resample.h
Normal file
@ -0,0 +1,85 @@
|
||||
/*****************************************************************
|
||||
>file name : include_lib/media/media_develop/media/audio_resample.h
|
||||
>author : lichao
|
||||
>create time : Fri 07 Aug 2020 11:32:47 AM CST
|
||||
*****************************************************************/
|
||||
#ifndef _AUDIO_RESAMPLE_H_
|
||||
#define _AUDIO_RESAMPLE_H_
|
||||
#include "typedef.h"
|
||||
#include "media/audio_stream.h"
|
||||
|
||||
#define AUDIO_HARDWARE_RESAMPLER 0
|
||||
#define AUDIO_SOFTWARE_RESAMPLER 1
|
||||
|
||||
struct audio_resampler;
|
||||
|
||||
struct audio_resample_context {
|
||||
u8 channel;
|
||||
int in_sample_rate;
|
||||
int out_sample_rate;
|
||||
void *output_buff;
|
||||
void *remain_addr;
|
||||
u16 output_size;
|
||||
u16 remain_len;
|
||||
u16 process_len;
|
||||
const struct audio_resampler *resampler;
|
||||
void *priv;
|
||||
struct audio_stream_entry entry;
|
||||
int (*data_flush)(struct audio_resample_context *ctx, void *data, int len);
|
||||
void *output_priv;
|
||||
int (*output_handler)(void *priv, void *data, int len);
|
||||
};
|
||||
|
||||
|
||||
struct audio_resample_data;
|
||||
|
||||
struct audio_resampler {
|
||||
u8 type;
|
||||
int (*open)(struct audio_resample_context *ctx, u8 channel);
|
||||
int (*resample)(struct audio_resample_context *ctx,
|
||||
struct audio_resample_data *in,
|
||||
struct audio_resample_data *out);
|
||||
int (*write)(struct audio_resample_context *ctx, void *data, int len);
|
||||
int (*reset_sample_rate)(struct audio_resample_context *ctx, int in_sample_rate, int out_sample_rate);
|
||||
int (*stop)(struct audio_resample_context *ctx);
|
||||
void (*close)(struct audio_resample_context *ctx);
|
||||
};
|
||||
|
||||
/*
|
||||
* 变采样输入输出数据
|
||||
*/
|
||||
struct audio_resample_data {
|
||||
void *buffer; //变采样数据缓冲地址
|
||||
int sample_rate; //采样率
|
||||
int sample_num; //缓冲内样点个数
|
||||
int offset; //已处理的样点偏移
|
||||
u8 ch_num; //样点的通道个数
|
||||
};
|
||||
|
||||
struct audio_resample_context *audio_resample_open(u8 ch_num,
|
||||
u8 hardware_first,
|
||||
void *output_priv,
|
||||
int (*output_handler)(void *priv, void *data, int len));
|
||||
|
||||
int audio_resample_set_sample_rate(struct audio_resample_context *ctx, int in_sample_rate, int out_sample_rate);
|
||||
|
||||
int audio_resample_set_sample_sync(struct audio_resample_context *ctx, int in_correct_rate, int out_correct_rate);
|
||||
|
||||
int audio_resample(struct audio_resample_context *ctx,
|
||||
struct audio_resample_data *in,
|
||||
struct audio_resample_data *out);
|
||||
|
||||
int audio_resample_stream_write(struct audio_resample_context *ctx, void *data, int len);
|
||||
|
||||
void audio_resample_close(struct audio_resample_context *ctx);
|
||||
|
||||
extern struct audio_resampler audio_resampler_begin[];
|
||||
extern struct audio_resampler audio_resampler_end[];
|
||||
|
||||
#define list_for_each_resampler(p) \
|
||||
for (p = audio_resampler_begin; p < audio_resampler_end; p++)
|
||||
|
||||
#define REGISTER_AUDIO_RESAMPLER(resampler) \
|
||||
const struct audio_resampler resampler SEC(.audio_resampler) = {
|
||||
|
||||
#endif
|
||||
24
include_lib/media/media_new/media/audio_splicing.h
Normal file
24
include_lib/media/media_new/media/audio_splicing.h
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
#ifndef _AUDIO_SPLICING_H_
|
||||
#define _AUDIO_SPLICING_H_
|
||||
|
||||
#include "generic/typedef.h"
|
||||
|
||||
void pcm_single_to_dual(void *out, void *in, u16 len);
|
||||
void pcm_single_to_qual(void *out, void *in, u16 len);
|
||||
void pcm_dual_to_qual(void *out, void *in, u16 len);
|
||||
void pcm_dual_mix_to_dual(void *out, void *in, u16 len);
|
||||
void pcm_dual_to_single(void *out, void *in, u16 len);
|
||||
void pcm_qual_to_single(void *out, void *in, u16 len);
|
||||
void pcm_single_l_r_2_dual(void *out, void *in_l, void *in_r, u16 in_len);
|
||||
void pcm_fl_fr_rl_rr_2_qual(void *out, void *in_fl, void *in_fr, void *in_rl, void *in_rr, u16 in_len);
|
||||
void pcm_flfr_rlrr_2_qual(void *out, void *in_flfr, void *in_rlrr, u16 in_len);
|
||||
void pcm_fill_single_2_qual(void *out, void *in, u16 in_len, u8 idx);
|
||||
void pcm_fill_flfr_2_qual(void *out, void *in_flfr, u16 in_len);
|
||||
void pcm_fill_rlrr_2_qual(void *out, void *in_rlrr, u16 in_len);
|
||||
void pcm_mix_buf(s32 *obuf, s16 *ibuf, u16 len);
|
||||
void pcm_mix_buf_limit(s16 *obuf, s32 *ibuf, u16 len);
|
||||
// 四声道转双声道(q0+q2,q1+q3)
|
||||
void pcm_qual_to_dual(void *out, void *in, u16 len);
|
||||
|
||||
#endif/*_AUDIO_SPLICING_H_*/
|
||||
62
include_lib/media/media_new/media/audio_syncts.h
Normal file
62
include_lib/media/media_new/media/audio_syncts.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*****************************************************************
|
||||
>file name : audio_syncts.h
|
||||
>create time : Mon 22 Mar 2021 02:41:39 PM CST
|
||||
>description:
|
||||
*****************************************************************/
|
||||
|
||||
#ifndef _AUDIO_SYNCTS_H_
|
||||
#define _AUDIO_SYNCTS_H_
|
||||
#include "typedef.h"
|
||||
|
||||
|
||||
#define PCM_INSIDE_DAC 0
|
||||
#define PCM_OUTSIDE_DAC 1
|
||||
|
||||
#define AUDIO_NETWORK_LOCAL 0
|
||||
#define AUDIO_NETWORK_BT2_1 1
|
||||
#define AUDIO_NETWORK_BLE 2
|
||||
#define AUDIO_NETWORK_IPV4 3
|
||||
|
||||
#define TIME_US_FACTOR 32
|
||||
/*
|
||||
* Audio同步变采样参数
|
||||
*/
|
||||
struct audio_syncts_params {
|
||||
unsigned char network; /*网络选择*/
|
||||
unsigned char pcm_device; /*PCM设备选择*/
|
||||
unsigned char nch; /*声道数*/
|
||||
unsigned char factor; /*timestamp的整数放大因子*/
|
||||
int rin_sample_rate; /*变采样输入采样率*/
|
||||
int rout_sample_rate; /*变采样输出采样率*/
|
||||
void *priv; /*私有数据*/
|
||||
int (*output)(void *, void *, int); /*变采样输出callback*/
|
||||
};
|
||||
|
||||
int audio_syncts_open(void **syncts, struct audio_syncts_params *params);
|
||||
|
||||
int audio_syncts_next_pts(void *syncts, u32 timestamp);
|
||||
|
||||
int audio_syncts_frame_filter(void *syncts, void *data, int len);
|
||||
|
||||
void audio_syncts_close(void *syncts);
|
||||
|
||||
u32 audio_syncts_get_dts(void *syncts);
|
||||
|
||||
int audio_syncts_set_dts(void *syncts, u32 dts);
|
||||
|
||||
int audio_syncts_trigger_resume(void *syncts, void *priv, void (*resume)(void *priv));
|
||||
|
||||
int audio_syncts_update_sample_rate(void *syncts, int sample_rate);
|
||||
|
||||
void audio_syncts_resample_suspend(void *syncts);
|
||||
|
||||
void audio_syncts_resample_resume(void *syncts);
|
||||
|
||||
int sound_pcm_update_frame_num(void *syncts, int frames);
|
||||
|
||||
int sound_pcm_syncts_latch_trigger(void *syncts);
|
||||
|
||||
u32 sound_buffered_between_syncts_and_device(void *priv, u8 time_select);
|
||||
|
||||
void sound_pcm_enter_update_frame(void *syncts);
|
||||
#endif
|
||||
14
include_lib/media/media_new/media/audio_track.h
Normal file
14
include_lib/media/media_new/media/audio_track.h
Normal file
@ -0,0 +1,14 @@
|
||||
/*****************************************************************
|
||||
>file name : audio_track.h
|
||||
>author : lichao
|
||||
>create time : Tue 22 Dec 2020 04:18:39 PM CST
|
||||
*****************************************************************/
|
||||
#ifndef _AUDIO_TRACK_H_
|
||||
#define _AUDIO_TRACK_H_
|
||||
|
||||
void *audio_local_sample_track_open(u8 channel, int sample_rate, int period);
|
||||
int audio_local_sample_track_in_period(void *c, int samples);
|
||||
int audio_local_sample_track_rate(void *c);
|
||||
void audio_local_sample_track_close(void *c);
|
||||
|
||||
#endif
|
||||
60
include_lib/media/media_new/media/automute.h
Normal file
60
include_lib/media/media_new/media/automute.h
Normal file
@ -0,0 +1,60 @@
|
||||
#ifndef AUDIO_AUTOMUTE_H
|
||||
#define AUDIO_AUTOMUTE_H
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "generic/list.h"
|
||||
|
||||
#define AUDIO_EVENT_AUTO_MUTE 0x10
|
||||
#define AUDIO_EVENT_AUTO_UNMUTE 0x11
|
||||
|
||||
#define AUTOMUTE_CH 4
|
||||
|
||||
enum mute_value {
|
||||
AUDIO_MUTE_DEFAULT = 0,
|
||||
AUDIO_UNMUTE_DEFAULT,
|
||||
AUDIO_MUTE_L_CH,
|
||||
AUDIO_UNMUTE_L_CH,
|
||||
AUDIO_MUTE_R_CH,
|
||||
AUDIO_UNMUTE_R_CH,
|
||||
};
|
||||
|
||||
struct pcm_energy {
|
||||
u32 points; //计算多少个点
|
||||
u32 point_count;
|
||||
s32 total_value;
|
||||
/*void *priv;*/
|
||||
/*void (*output)(void *, u16, u8);*/
|
||||
s16 average_value;
|
||||
};
|
||||
|
||||
struct automute_filter {
|
||||
u32 mute_number;
|
||||
u32 unmute_number;
|
||||
u32 mute_count;
|
||||
u32 unmute_count;
|
||||
};
|
||||
|
||||
struct audio_automute {
|
||||
struct pcm_energy energy[AUTOMUTE_CH];
|
||||
void (*handler)(u8 event, u8 channel);
|
||||
u8 channels;
|
||||
u8 pcm_mute;
|
||||
u8 mute_channel;
|
||||
u8 mute;
|
||||
u32 mute_energy;
|
||||
u32 unmute_energy;
|
||||
u32 filt_points;
|
||||
u32 filt_mute_number;
|
||||
u32 filt_unmute_number;
|
||||
struct automute_filter filt[AUTOMUTE_CH];
|
||||
u8 on;
|
||||
u8 skip;
|
||||
};
|
||||
|
||||
int audio_automute_open(struct audio_automute *automute);
|
||||
void audio_automute_run(struct audio_automute *automute, void *data, int len);
|
||||
void audio_automute_close(struct audio_automute *automute);
|
||||
int audio_automute_onoff(struct audio_automute *automute, u8 onoff, u8 need_cb);
|
||||
void audio_automute_skip(struct audio_automute *automute, u8 skip);
|
||||
|
||||
#endif
|
||||
778
include_lib/media/media_new/media/cpu/br28/asm/anc.h
Normal file
778
include_lib/media/media_new/media/cpu/br28/asm/anc.h
Normal file
@ -0,0 +1,778 @@
|
||||
#ifndef _ANC_H_
|
||||
#define _ANC_H_
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "system/task.h"
|
||||
#include "media/audio_def.h"
|
||||
#include "asm/audio_adc.h"
|
||||
|
||||
enum {
|
||||
ANCDB_ERR_CRC = 1,
|
||||
ANCDB_ERR_TAG,
|
||||
ANCDB_ERR_PARAM,
|
||||
ANCDB_ERR_STATE,
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
ANC_OFF = 1, /*关闭模式*/
|
||||
ANC_ON, /*降噪模式*/
|
||||
ANC_TRANSPARENCY, /*通透模式*/
|
||||
ANC_BYPASS, /*训练模式*/
|
||||
ANC_TRAIN, /*训练模式*/
|
||||
ANC_TRANS_TRAIN, /*通透训练模式*/
|
||||
} ANC_mode_t;
|
||||
|
||||
/*ANC状态*/
|
||||
enum {
|
||||
ANC_STA_CLOSE = 0,
|
||||
ANC_STA_INIT,
|
||||
ANC_STA_OPEN,
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
TRANS_ERR_TIMEOUT = 1, //训练超时
|
||||
TRANS_ERR_MICERR, //训练中MIC异常
|
||||
TRANS_ERR_FORCE_EXIT //强制退出训练
|
||||
} ANC_trans_errmsg_t;
|
||||
|
||||
/*ANC MIC 类型*/
|
||||
enum {
|
||||
ANC_MIC_TYPE_LFF = 0,
|
||||
ANC_MIC_TYPE_LFB,
|
||||
ANC_MIC_TYPE_RFF,
|
||||
ANC_MIC_TYPE_RFB,
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
//OLD
|
||||
ANC_L_FF_IIR = 0x0, //左FF滤波器ID
|
||||
ANC_L_FB_IIR = 0x1, //左FB滤波器ID
|
||||
ANC_L_CMP_IIR = 0x2, //左音乐补偿滤波器ID
|
||||
ANC_L_TRANS_IIR = 0x3, //左通透滤波器ID
|
||||
ANC_L_FIR = 0x4, //(保留位,暂时不用)
|
||||
// ANC_L_TRANS2_IIR = 0x5,
|
||||
|
||||
//NEW
|
||||
ANC_L_FF_FGQ = 0x6, //左FF滤波器FGQ
|
||||
ANC_L_FB_FGQ = 0x7, //左FB滤波器FGQ
|
||||
ANC_L_CMP_FGQ = 0x8, //左音乐补偿滤波器FGQ
|
||||
ANC_L_TRANS_FGQ = 0x9, //左通透滤波器FGQ
|
||||
ANC_L_FF_PARM = 0xA, //左FF参数ID
|
||||
ANC_L_FB_PARM = 0xB, //左FB参数ID
|
||||
ANC_L_CMP_PARM = 0xC, //左音乐补偿参数ID
|
||||
ANC_L_TRANS_PARM = 0xD, //左通透参数ID
|
||||
|
||||
//OLD
|
||||
ANC_R_FF_IIR = 0x10, //右FF滤波器ID
|
||||
ANC_R_FB_IIR = 0x11, //右FB滤波器ID
|
||||
ANC_R_CMP_IIR = 0x12, //右音乐补偿滤波器ID
|
||||
ANC_R_TRANS_IIR = 0x13, //右通透滤波器ID
|
||||
ANC_R_FIR = 0x14, //(保留位,暂时不用)
|
||||
// ANC_R_TRANS2_IIR = 0x15,
|
||||
|
||||
//NEW
|
||||
ANC_R_FF_FGQ = 0x16, //右FF滤波器FGQ
|
||||
ANC_R_FB_FGQ = 0x17, //右FB滤波器FGQ
|
||||
ANC_R_CMP_FGQ = 0x18, //右音乐补偿滤波器FGQ
|
||||
ANC_R_TRANS_FGQ = 0x19, //右通透滤波器FGQ
|
||||
ANC_R_FF_PARM = 0x1A, //右FF参数ID
|
||||
ANC_R_FB_PARM = 0x1B, //右FB参数ID
|
||||
ANC_R_CMP_PARM = 0x1C, //右音乐补偿参数ID
|
||||
ANC_R_TRANS_PARM = 0x1D, //右通透参数ID
|
||||
|
||||
//OTHER
|
||||
ANC_L_ADAP_FRE = 0x20,
|
||||
ANC_L_ADAP_PZ = 0x21,
|
||||
ANC_L_ADAP_SZPZ = 0x22,
|
||||
ANC_L_ADAP_TARGET = 0x23,
|
||||
ANC_L_ADAP_GOLD_CURVE = 0x24,//自适应金机曲线
|
||||
ANC_L_ADAP_TARGET_CMP = 0x25,
|
||||
ANC_R_ADAP_FRE = 0x30,
|
||||
ANC_R_ADAP_PZ = 0x31,
|
||||
ANC_R_ADAP_SZPZ = 0x32,
|
||||
ANC_R_ADAP_TARGET = 0x33,
|
||||
ANC_R_ADAP_GOLD_CURVE = 0x34,
|
||||
ANC_R_ADAP_TARGET_CMP = 0x35,
|
||||
} ANC_config_seg_id_t;
|
||||
|
||||
//新增iir滤波器 type 枚举
|
||||
typedef enum {
|
||||
ANC_IIR_HIGH_PASS = 0,
|
||||
ANC_IIR_LOW_PASS,
|
||||
ANC_IIR_BAND_PASS,
|
||||
ANC_IIR_HIGH_SHELF,
|
||||
ANC_IIR_LOW_SHELF,
|
||||
} ANC_iir_type;
|
||||
|
||||
typedef enum {
|
||||
ANC_ALOGM1 = 0,
|
||||
ANC_ALOGM2,
|
||||
ANC_ALOGM3,
|
||||
ANC_ALOGM4,
|
||||
ANC_ALOGM5,
|
||||
ANC_ALOGM6,
|
||||
ANC_ALOGM7,
|
||||
ANC_ALOGM8,
|
||||
} ANC_alogm_t; //ANC算法模式
|
||||
|
||||
typedef enum {
|
||||
A_MIC0 = 0x0, //模拟MIC0 对应IO-PA1 PA2
|
||||
A_MIC1, //模拟MIC1 对应IO-PA3 PA4
|
||||
A_MIC2, //模拟MIC2 对应IO-PG7 PG8
|
||||
A_MIC3, //模拟MIC3 对应IO-PG5 PG6
|
||||
D_MIC0, //数字MIC0(plnk_dat0_pin-上升沿采样)
|
||||
D_MIC1, //数字MIC1(plnk_dat1_pin-上升沿采样)
|
||||
D_MIC2, //数字MIC2(plnk_dat0_pin-下降沿采样)
|
||||
D_MIC3, //数字MIC3(plnk_dat1_pin-下降沿采样)
|
||||
MIC_NULL = 0XFF, //没有定义相关的MIC
|
||||
} ANC_mic_type_t;
|
||||
|
||||
typedef enum {
|
||||
ANC_POW_SEL_R_DAC_REF = 0x02, //功率输出R DAC+REFMIC
|
||||
ANC_POW_SEL_R_DAC_ERR, //功率输出R DAC+ERRMIC
|
||||
ANC_POW_SEL_L_DAC_REF, //功率输出L DAC+REFMIC
|
||||
ANC_POW_SEL_L_DAC_ERR, //功率输出L DAC+ERRMIC
|
||||
} ANC_pow_sel_t;
|
||||
|
||||
typedef enum {
|
||||
ANC_COEFF_MODE_NORMAL = 0x0, //自适应普通模式
|
||||
ANC_COEFF_MODE_ADAPTIVE = 0x1, //自适应滤波器模式
|
||||
} ANC_coeff_mode_t;
|
||||
|
||||
//自适应解码任务打断状态
|
||||
typedef enum {
|
||||
ANC_ADAPTIVE_DEC_WAIT_STOP = 0x0, //停止
|
||||
ANC_ADAPTIVE_DEC_WAIT_START, //启动
|
||||
ANC_ADAPTIVE_DEC_WAIT_RUN, //运行中
|
||||
} ANC_adaptive_dec_wait_t;
|
||||
|
||||
//自适应滤波器数据状态
|
||||
typedef enum {
|
||||
ANC_ADAPTIVE_DATA_EMPTY = 0x0, //数据为空
|
||||
ANC_ADAPTIVE_DATA_FROM_VM, //来源VM
|
||||
ANC_ADAPTIVE_DATA_FROM_ALOGM, //来源算法
|
||||
} ANC_adaptive_data_from_t;
|
||||
|
||||
// ANC fade gain通道
|
||||
typedef enum {
|
||||
AUDIO_ANC_FADE_CH_LFF = 0x1,
|
||||
AUDIO_ANC_FADE_CH_LFB = 0x2,
|
||||
AUDIO_ANC_FADE_CH_RFF = 0x4,
|
||||
AUDIO_ANC_FADE_CH_RFB = 0x8,
|
||||
} ANC_fade_ch_t;
|
||||
|
||||
/*ANC模式使能位*/
|
||||
#define ANC_OFF_BIT BIT(1) /*降噪关闭使能*/
|
||||
#define ANC_ON_BIT BIT(2) /*降噪模式使能*/
|
||||
#define ANC_TRANS_BIT BIT(3) /*通透模式使能*/
|
||||
|
||||
//ANC Ch ---eg:双声道 ANC_L_CH|ANC_R_CH
|
||||
#define ANC_L_CH BIT(0) //通道左
|
||||
#define ANC_R_CH BIT(1) //通道右
|
||||
|
||||
//ANC各类增益对应符号位
|
||||
#define ANCL_FF_SIGN BIT(0) //左声道FF增益符号
|
||||
#define ANCL_FB_SIGN BIT(1) //左声道FB增益符号
|
||||
#define ANCL_TRANS_SIGN BIT(2) //左声道通透增益符号
|
||||
#define ANCL_CMP_SIGN BIT(3) //左声道音乐补偿增益符号
|
||||
#define ANCR_FF_SIGN BIT(4) //右声道FF增益符号
|
||||
#define ANCR_FB_SIGN BIT(5) //右声道FB增益符号
|
||||
#define ANCR_TRANS_SIGN BIT(6) //右声道通透增益符号
|
||||
#define ANCR_CMP_SIGN BIT(7) //右声道音乐补偿增益符号
|
||||
|
||||
//DRC中断标志
|
||||
#define ANCL_REF_DRC_ISR BIT(0)
|
||||
#define ANCL_ERR_DRC_ISR BIT(1)
|
||||
#define ANCR_REF_DRC_ISR BIT(2)
|
||||
#define ANCR_ERR_DRC_ISR BIT(3)
|
||||
#define ANC_ERR_DRC_ISR ANCL_ERR_DRC_ISR | ANCR_ERR_DRC_ISR
|
||||
#define ANC_REF_DRC_ISR ANCL_REF_DRC_ISR | ANCR_REF_DRC_ISR
|
||||
|
||||
//DRC模块使能标志
|
||||
#define ANC_DRC_FF_EN BIT(0) //DRC_FF使能标志
|
||||
#define ANC_DRC_FB_EN BIT(1) //DRC_FB使能标志
|
||||
#define ANC_DRC_TRANS_EN BIT(2) //DRC_TRANS使能标志
|
||||
|
||||
//ANC DUT音频模块使能控制
|
||||
#define ANC_DUT_ANC_ENABLE BIT(0) //ANC_DUT ANC使能
|
||||
#define ANC_DUT_ADC_ENABLE BIT(1) //ANC_DUT ADC使能
|
||||
#define ANC_DUT_DAC_ENABLE BIT(2) //ANC_DUT DAC使能
|
||||
#define ANC_DUT_CLOSE ANC_DUT_ANC_ENABLE | ANC_DUT_ADC_ENABLE | ANC_DUT_DAC_ENABLE //ANC_DUT模块关闭,正常开启所有模块
|
||||
|
||||
//ANC自适应模式
|
||||
#define ANC_ADAPTIVE_MANUAL_MODE 0 //自适应手动模式-手动切换等级
|
||||
#define ANC_ADAPTIVE_GAIN_MODE 1 //自适应增益模式-自动切换等级
|
||||
|
||||
/*ANC训练方式*/
|
||||
#define ANC_AUTO_UART 0
|
||||
#define ANC_AUTO_BT_SPP 1
|
||||
#define ANC_TRAIN_WAY ANC_AUTO_BT_SPP
|
||||
|
||||
/*SZ频响获取默认算法模式*/
|
||||
#define ANC_SZ_EXPORT_DEF_ALOGM ANC_ALOGM3
|
||||
|
||||
/*ANC 测试模式类型*/
|
||||
#define ANC_TEST_TYPE_PCM 0 //MIC_SPK数据以PCM导出
|
||||
#define ANC_TEST_TYPE_FFT 1 //SZ数据累加FFT导出
|
||||
|
||||
/*ANC芯片版本定义(只读)*/
|
||||
#define ANC_CHIP_VERSION ANC_VERSION_BR28
|
||||
|
||||
/*ANC CFG读写标志*/
|
||||
#define ANC_CFG_READ 0x01
|
||||
#define ANC_CFG_WRITE 0x02
|
||||
|
||||
typedef struct {
|
||||
u8 mode; //当前训练步骤
|
||||
u8 train_busy; //训练繁忙位 0-空闲 1-训练中 2-训练结束测试中
|
||||
u8 train_step; //训练系数
|
||||
u8 ret_step; //自适应训练系数值
|
||||
u8 auto_ts_en; //自动步进微调使能位
|
||||
u8 enablebit; //训练模式使能标志位 前馈|混合馈|通透
|
||||
u8 tool_time_flag; //工具修改时间标志
|
||||
u8 mic_dma_export_en; //从ANC DAM拿数,会消耗4*4K
|
||||
u8 only_mute_train_en; //只跑静音训练保持sz,fz系数
|
||||
u16 timerout_id; //训练超时定时器ID
|
||||
s16 fb0_gain;
|
||||
s16 fb0sz_dly_en;
|
||||
u16 fb0sz_dly_num;
|
||||
int sz_gain; //静音训练sz 增益
|
||||
u32 sz_lower_thr; //误差MIC下限能量阈值
|
||||
u32 fz_lower_thr; //参考MIC下限能量阈值
|
||||
u32 sz_noise_thr; //误差MIC底噪阈值
|
||||
u32 fz_noise_thr; //参考MIC底噪阈值
|
||||
u32 sz_adaptive_thr; //误差MIC自适应收敛阈值
|
||||
u32 fz_adaptive_thr; //参考MIC自适应收敛阈值
|
||||
u32 wz_train_thr; //噪声训练阈值
|
||||
} anc_train_para_t;
|
||||
|
||||
typedef struct {
|
||||
u8 default_flag; //初始状态标志
|
||||
u8 fade_lvl; //淡入时间fade_lvl*100ms
|
||||
u8 trigger_cnt; //触发计数 trigger_cnt*100ms
|
||||
u16 gain; //目标增益
|
||||
u32 pow_lthr; //低阈值
|
||||
u32 pow_thr; //高阈值
|
||||
} anc_adap_param_t;
|
||||
|
||||
//ANC耳道自适应相关结构体
|
||||
typedef struct {
|
||||
u8 ff_yorder; //ANC耳道自适应FF IIR num
|
||||
u8 fb_yorder; //ANC耳道自适应FB IIR num
|
||||
u8 cmp_yorder; //ANC耳道自适应CMP IIR num
|
||||
double *lff_coeff; /*耳道自适应-滤波器LFF暂存指针*/
|
||||
double *lfb_coeff; /*耳道自适应-滤波器LFB暂存指针*/
|
||||
double *lcmp_coeff; /*耳道自适应-滤波器LCMP暂存指针*/
|
||||
double *rff_coeff; /*耳道自适应-滤波器RFF暂存指针*/
|
||||
double *rfb_coeff; /*耳道自适应-滤波器RFB暂存指针*/
|
||||
double *rcmp_coeff; /*耳道自适应-滤波器RCMP暂存指针*/
|
||||
u8 *ref_ff_curve; /*耳道自适应-FF金机参考曲线*/
|
||||
int ref_ff_curve_len; /*耳道自适应-FF金机参考曲线长度*/
|
||||
void (*dma_done_cb)(void);
|
||||
} anc_ear_adaptive_param_t;
|
||||
|
||||
struct anc_sz_fft_t {
|
||||
volatile u8 state; //状态
|
||||
u8 data_sel; //目标数据通道
|
||||
u8 alogm; //采样率信息
|
||||
u8 check_flag; //检查DAC有效数据标志
|
||||
u8 packet_cnt; //overlap拼包标志
|
||||
u8 packet_lcnt; //long buf overlap拼包标志
|
||||
volatile u8 busy; //run 繁忙标志
|
||||
int all_sample_cnt; //总样本计数
|
||||
int spk_sample_cnt[5];//spk区间样本计数
|
||||
int err_sample_cnt[5];//err区间样本次数
|
||||
s16 *packet_buf; //overlap 拼包buf
|
||||
s16 *packet_lbuf; //long buf overlap 拼包buf
|
||||
int *inbuf; //输入数据buf
|
||||
float *out0_buf; //输出数据buf0
|
||||
float *out1_buf; //输出数据buf1
|
||||
float *out0_lbuf; //输出数据lbuf0
|
||||
float *out1_lbuf; //输出数据lbuf1
|
||||
void (*dma_run_hdl)(void);
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
void (*dma_done_cb)(void);
|
||||
} anc_adt_param_t;
|
||||
|
||||
typedef struct {
|
||||
u8 mic_errmsg;
|
||||
u8 status;
|
||||
u32 dat[4]; //ff_num/ff_dat/fb_num/fb_dat
|
||||
u32 pow;
|
||||
u32 temp_pow;
|
||||
u32 mute_pow;
|
||||
} anc_ack_msg_t;
|
||||
|
||||
#define ANC_GAINS_VERSION 0X7012 //结构体版本号信息
|
||||
typedef struct {
|
||||
//cfg
|
||||
u16 version; //当前结构体版本号
|
||||
u8 dac_gain; //dac模拟增益 range 0-15; default 13
|
||||
u8 l_ffmic_gain; //ANCL FFmic增益 range 0-19; default 10
|
||||
u8 l_fbmic_gain; //ANCL FBmic增益 range 0-19; default 10
|
||||
u8 cmp_en; //音乐补偿使能 range 0-1; default 1
|
||||
u8 drc_en; //DRC使能 range 0-7; default 0
|
||||
u8 ahs_en; //AHS使能 range 0-1; default 1
|
||||
u8 ff_1st_dcc; //FF 1阶DCC档位 range 0-8; default 8
|
||||
u8 gain_sign; //ANC各类增益的符号 range 0-255; default 0
|
||||
u8 noise_lvl; //训练的噪声等级 range 0-255; default 0
|
||||
u8 fade_step; //淡入淡出步进 range 0-15; default 1
|
||||
u32 alogm; //ANC算法因素
|
||||
u32 trans_alogm; //通透算法因素
|
||||
float l_ffgain; //ANCL FF增益 range 0.0316(-30dB) - 31.622(+30dB); default 1.0(0dB)
|
||||
float l_fbgain; //ANCL FB增益 range 0.0316(-30dB) - 31.622(+30dB); default 1.0(0dB)
|
||||
float l_transgain; //ANCL 通透增益 range 0.0316(-30dB) - 31.622(+30dB); default 1.0(0dB)
|
||||
float l_cmpgain; //ANCL 音乐补偿增益 range 0.0316(-30dB) - 31.622(+30dB); default 1.0(0dB)
|
||||
float r_ffgain; //ANCR FF增益 range 0.0316(-30dB) - 31.622(+30dB); default 1.0(0dB)
|
||||
float r_fbgain; //ANCR FB增益 range 0.0316(-30dB) - 31.622(+30dB); default 1.0(0dB)
|
||||
float r_transgain; //ANCR 通透增益 range 0.0316(-30dB) - 31.622(+30dB); default 1.0(0dB)
|
||||
float r_cmpgain; //ANCR 音乐补偿增益 range 0.0316(-30dB) - 31.622(+30dB); default 1.0(0dB)
|
||||
|
||||
u8 drcff_zero_det; //DRCFF过零检测使能 range 0-1; default 0;
|
||||
u8 drcff_dat_mode; //DRCFF_DAT模式 range 0-3; default 0;
|
||||
u8 drcff_lpf_sel; //DRCFF_LPF档位 range 0-3; default 0;
|
||||
u8 drcfb_zero_det; //DRCFB过零检测使 range 0-1; default 0;
|
||||
u8 drcfb_dat_mode; //DRCFB_DAT模式 range 0-3; default 0;
|
||||
u8 drcfb_lpf_sel; //DRCFB_LPF档位 range 0-3; default 0;
|
||||
|
||||
u16 drcff_lthr; //DRCFF_LOW阈值 range 0-32767; default 0;
|
||||
u16 drcff_hthr; //DRCFF_HIGH阈值 range 0-32767; default 32767;
|
||||
s16 drcff_lgain; //DRCFF_LOW增益 range 0-32767; default 0;
|
||||
s16 drcff_hgain; //DRCFF_HIGH增益 range 0-32767; default 1024;
|
||||
s16 drcff_norgain; //DRCFF_NOR增益 range 0-32767; default 1024;
|
||||
|
||||
u16 drcfb_lthr; //DRCFB_LOW阈值 range 0-32767; default 0;
|
||||
u16 drcfb_hthr; //DRCFB_HIGH阈值 range 0-32767; default 32767;
|
||||
s16 drcfb_lgain; //DRCFB_LOW增益 range 0-32767; default 0;
|
||||
s16 drcfb_hgain; //DRCFB_HIGH增益 range 0-32767; default 1024;
|
||||
s16 drcfb_norgain; //DRCFB_NOR增益 range 0-32767; default 1024;
|
||||
|
||||
u16 drctrans_lthr; //DRCTRANS_LOW阈值 range 0-32767; default 0;
|
||||
u16 drctrans_hthr; //DRCTRANS_HIGH阈值 range 0-32767; default 32767;
|
||||
s16 drctrans_lgain; //DRCTRANS_LOW增益 range 0-32767; default 0;
|
||||
s16 drctrans_hgain; //DRCTRANS_HIGH增益 range 0-32767; default 1024;
|
||||
s16 drctrans_norgain; //DRCTRANS_NOR增益 range 0-32767; default 1024;
|
||||
|
||||
u8 ahs_dly; //AHS_DLY range 0-15; default 1;
|
||||
u8 ahs_tap; //AHS_TAP range 0-255; default 100;
|
||||
u8 ahs_wn_shift; //AHS_WN_SHIFT range 0-15; default 9;
|
||||
u8 ahs_wn_sub; //AHS_WN_SUB range 0-1; default 1;
|
||||
u16 ahs_shift; //AHS_SHIFT range 0-65536; default 210;
|
||||
u16 ahs_u; //AHS步进 range 0-65536; default 4000;
|
||||
s16 ahs_gain; //AHS增益 range -32767-32767;default -1024;
|
||||
u8 ahs_nlms_sel; //AHS_NLMS range 0-1; default 0;
|
||||
u8 developer_mode; //GAIN开发者模式 range 0-1; default 0;
|
||||
|
||||
float audio_drc_thr; //Audio DRC阈值 range -6.0-0; default -6.0dB;
|
||||
|
||||
u8 r_ffmic_gain; //ANCR FFmic增益 range 0-19; default 10;
|
||||
u8 r_fbmic_gain; //ANCR FBmic增益 range 0-19; default 10;
|
||||
u8 fb_1st_dcc; //FB 1阶DCC档位 range 0-8; default 8;
|
||||
u8 ff_2nd_dcc; //FF 2阶DCC档位 range 0-15; default 4;
|
||||
u8 fb_2nd_dcc; //FB 2阶DCC档位 range 0-15; default 1;
|
||||
u8 drc_ff_2dcc; //DRC FF动态DCC目标值 range 0-15; default 0;
|
||||
u8 drc_fb_2dcc; //DRC FB动态DCC目标值 range 0-15; default 0;
|
||||
|
||||
u8 adaptive_ref_en; //耳道自适应-金机曲线参考使能
|
||||
u16 drc_dcc_det_time; //DRC DCC检测时间ms range 0-32767; default 300;
|
||||
u16 drc_dcc_res_time; //DRC DCC恢复时间ms range 0-32767; default 20;
|
||||
|
||||
float adaptive_ref_fb_f; //FB参考F最深点位置中心值 range 80-200; default 135
|
||||
float adaptive_ref_fb_g; //FB参考G最深点深度 range 12-22; default 18
|
||||
float adaptive_ref_fb_q; //FB参考Q最深点降噪宽度 range 0.4-1.2; default 0.6
|
||||
|
||||
//相关性检测 HD param
|
||||
u8 hd_en; //啸叫检测使能 range 0-1; default 1;
|
||||
u8 hd_corr_thr; //相关性检测阈值 range 0-255; default 232;
|
||||
u16 hd_corr_gain; //相关性预设增益 range 0-1024 default 512;
|
||||
u8 hd_corr_dly; //相关性检测延时 range 2-30; default 30;
|
||||
|
||||
//功率检测全频带,增益可预设
|
||||
u8 hd_pwr_rate; //功率检测回音处理前后比例 range 0-3; default 2;
|
||||
u8 hd_pwr_ctl_gain_en; //功率检测是否使用预设的增益使能 range 0-1; default 0;
|
||||
u8 hd_pwr_ctl_ahsrst_en;//功率检测是否复位AHS range 0-1; default 1;
|
||||
u16 hd_pwr_thr; //功率检测阈值设置,增益自动 range 0-32767; default 18000;
|
||||
u16 hd_pwr_ctl_gain; //功率检测预设增益 range 0-16384; default 1638;
|
||||
|
||||
//可选带宽 增益自动调节
|
||||
u8 hd_pwr_ref_ctl_en; //参考功率检测自动调增益使能 range 0-1; default 0;
|
||||
u8 hd_pwr_err_ctl_en; //误差功率检测自动调增益使能 range 0-1; default 0;
|
||||
u16 hd_pwr_ref_ctl_hthr; //参考功率检测H_THR,触发中断 range 0-32767; default 2000;
|
||||
u16 hd_pwr_ref_ctl_lthr1; //参考功率检测L1_THR range 0-32767; default 1000;
|
||||
u16 hd_pwr_ref_ctl_lthr2; //参考功率检测L2_THR,小于L1_THR range 0-32767; default 200;
|
||||
|
||||
u16 hd_pwr_err_ctl_hthr; //误差功率检测H_THR,触发中断 range 0-32767; default 2000;
|
||||
u16 hd_pwr_err_ctl_lthr1; //误差功率检测L1_THR range 0-32767; default 1000;
|
||||
u16 hd_pwr_err_ctl_lthr2; //误差功率检测L2_THR,小于L1_THR range 0-32767; default 200;
|
||||
u16 reserve_2;
|
||||
|
||||
} anc_gain_param_t;
|
||||
|
||||
/*ANCIF配置区滤波器系数gains*/
|
||||
typedef struct {
|
||||
anc_gain_param_t gains;
|
||||
u8 reserve[236 - 156]; //236 + 20byte(header)
|
||||
// u8 reserve[236 - 128]; //236 + 20byte(header)
|
||||
} anc_gain_t;
|
||||
|
||||
typedef struct {
|
||||
u8 start; //ANC状态
|
||||
u8 mode; //ANC模式:降噪关;降噪开;通透...
|
||||
u8 production_mode; //量产模式
|
||||
u8 developer_mode; //开发者模式
|
||||
u8 anc_fade_en; //ANC淡入淡出使能
|
||||
u8 tool_enablebit; //ANC动态使能,使用过程中可随意控制
|
||||
u8 debug_sel; //ANCdebug data输出源
|
||||
u8 lff_en; //左耳FF使能
|
||||
u8 lfb_en; //左耳FB使能
|
||||
u8 rff_en; //右耳FF使能
|
||||
u8 rfb_en; //右耳FB使能
|
||||
u8 online_busy; //在线调试繁忙标志位
|
||||
u8 fade_time_lvl; //淡入时间等级,越大时间越长
|
||||
u8 mic_type[4]; //ANC mic类型控制位
|
||||
u8 dut_audio_enablebit; //ANC_DUT 音频使能控制,用于分离模块功耗
|
||||
u8 drc_dcc_en; //drc动态调整DCC使能
|
||||
u8 adc_ch; //adc数字通道
|
||||
u8 adaptive_mode; //ANC场景自适应模式
|
||||
u8 anc_lvl; //ANC等级
|
||||
u8 lff_yorder; //LFF IIR NUM
|
||||
u8 lfb_yorder; //LFB IIR NUM
|
||||
u8 lcmp_yorder; //LTRANS IIR NUM
|
||||
u8 ltrans_yorder; //LCMP IIR NUM
|
||||
u8 rff_yorder; //RFF IIR NUM
|
||||
u8 rfb_yorder; //RFB IIR NUM
|
||||
u8 rcmp_yorder; //RTRANS IIR NUM
|
||||
u8 rtrans_yorder; //RCMP IIR NUM
|
||||
u8 lr_lowpower_en; //ANCLR(立体声)配置省功耗使能
|
||||
u8 anc_coeff_mode; /*ANC coeff模式-0 普通coeff; 1 自适应coeff*/
|
||||
u8 test_type; //ANC测试模式类型,获取SZ频响 or 获取SPK_MIC PCM数据
|
||||
u16 anc_fade_gain; //ANC淡入淡出增益
|
||||
u16 drc_fade_gain; //DRC淡出增益
|
||||
u16 drc_time_id; //DRCtimeout定时器ID
|
||||
u16 enablebit; //ANC模式:FF,FB,HYBRID
|
||||
u16 pow_export_en; //ANC功率输出使能
|
||||
u32 coeff_size; //ANC 读滤波器总长度
|
||||
u32 write_coeff_size; //ANC 写滤波器总长度
|
||||
int train_err; //训练结果 0:成功 other:失败
|
||||
u32 gains_size; //ANC 滤波器长度
|
||||
|
||||
int *debug_buf; //测试数据流,最大65536byte(堆)
|
||||
s32 *lfir_coeff; //FZ补偿滤波器表
|
||||
s32 *rfir_coeff; //FZ补偿滤波器表
|
||||
double *lff_coeff; //左耳FF滤波器
|
||||
double *lfb_coeff; //左耳FB滤波器
|
||||
double *lcmp_coeff; //左耳cmp滤波器
|
||||
double *ltrans_coeff; //左耳通透滤波器
|
||||
double *rff_coeff; //右耳FF滤波器
|
||||
double *rfb_coeff; //右耳FB滤波器
|
||||
double *rcmp_coeff; //右耳cmp滤波器
|
||||
double *rtrans_coeff; //右耳通透滤波器
|
||||
double *trans_default_coeff; //通透默认滤波器
|
||||
volatile u8 ch; //ANC通道选择 : ANC_L_CH | ANC_R_CH
|
||||
/*开智能免摘开通透需要开fb*/
|
||||
float ltrans_fbgain; //ANCL FB通透增益 range 0.0316(-30dB) - 31.622(+30dB); default 1.0(0dB)
|
||||
float rtrans_fbgain; //ANCR FB通透增益 range 0.0316(-30dB) - 31.622(+30dB); default 1.0(0dB)
|
||||
double *ltrans_fb_coeff; //左耳FB通透滤波器
|
||||
double *rtrans_fb_coeff; //右耳FB通透滤波器
|
||||
u8 ltrans_fb_yorder; //LCMP IIR NUM
|
||||
u8 rtrans_fb_yorder; //RCMP IIR NUM
|
||||
|
||||
anc_gain_param_t gains;
|
||||
audio_adc_mic_mana_t mic_param[4]; //ANC MIC 控制参数
|
||||
anc_train_para_t train_para;//训练参数结构体
|
||||
anc_ear_adaptive_param_t *adaptive;
|
||||
anc_adt_param_t *adt;
|
||||
struct anc_sz_fft_t sz_fft;
|
||||
|
||||
void (*train_callback)(u8, u8);
|
||||
void (*pow_callback)(anc_ack_msg_t *msg_t, u8 setp);
|
||||
int (*cfg_online_deal_cb)(u8, anc_gain_t *);
|
||||
void (*post_msg_drc)(void);
|
||||
void (*post_msg_debug)(void);
|
||||
void (*adc_set_buffs_cb)(void);
|
||||
void (*biquad2ab)(float gain, float f, float fs, float q, double *a0, double *a1, double *a2, double *b0, double *b1, double *b2, int type);
|
||||
void (*mult_gain_set)(u8 gain_id, int data);
|
||||
void (*pow_adap_fade)(u16 gain);
|
||||
u8 adt_state;//智能免摘开启状态
|
||||
} audio_anc_t;
|
||||
|
||||
|
||||
#define ANC_DB_HEAD_LEN 20/*ANC配置区数据头长度*/
|
||||
#define ANCIF_GAIN_TAG_01 "ANCGAIN01"
|
||||
#define ANCIF_COEFF_TAG_01 "ANCCOEF01"
|
||||
#define ANCIF_GAIN_TAG ANCIF_GAIN_TAG_01 //当前增益配置版本
|
||||
#define ANCIF_COEFF_TAG ANCIF_COEFF_TAG_01 //当前系数配置版本
|
||||
#define ANCIF_HEADER_LEN 10
|
||||
typedef struct {
|
||||
u32 total_len; //4 后面所有数据加起来长度
|
||||
u16 group_crc; //6 group_type开始做的CRC,更新数据后需要对应更新CRC
|
||||
u16 group_type; //8
|
||||
u16 group_len; //10 header开始到末尾的长度
|
||||
char header[ANCIF_HEADER_LEN];//20
|
||||
int coeff[0];
|
||||
} anc_db_head_t;
|
||||
|
||||
#define _PACKED __attribute__((packed))
|
||||
struct anc_param_head_t {
|
||||
u16 id;
|
||||
u16 offset;
|
||||
u16 len;
|
||||
} _PACKED;
|
||||
|
||||
/*ANCIF配置区滤波器系数coeff*/
|
||||
typedef struct {
|
||||
u16 version;
|
||||
u16 cnt;
|
||||
u8 dat[0]; //小心double访问非对齐异常
|
||||
} anc_coeff_t;
|
||||
|
||||
/* ANC 数据拼接结构体 */
|
||||
typedef struct {
|
||||
u16 version;
|
||||
u16 cnt;
|
||||
u16 last_len;
|
||||
u16 last_total_len;
|
||||
u16 dat_len; //记录数据包dat的长度
|
||||
u8 *dat; //指向数据包的地址
|
||||
} anc_packet_data_t;
|
||||
|
||||
typedef struct {
|
||||
u8 type;
|
||||
float a[3];
|
||||
} _PACKED anc_fr_t;
|
||||
|
||||
typedef struct {
|
||||
float iir_gain;
|
||||
} _PACKED anc_mult_gain_t;
|
||||
|
||||
typedef struct {
|
||||
anc_fr_t *lff;
|
||||
anc_fr_t *lfb;
|
||||
anc_fr_t *lcmp;
|
||||
anc_fr_t *rff;
|
||||
anc_fr_t *rfb;
|
||||
anc_fr_t *rcmp;
|
||||
} anc_iir_t;
|
||||
|
||||
|
||||
int audio_anc_train(audio_anc_t *param, u8 en);
|
||||
|
||||
/*
|
||||
*Description : audio_anc_run
|
||||
*Arguements : param is audio anc param
|
||||
*Returns : 0 open success
|
||||
* : -EPERM 不支持ANC
|
||||
* : -EINVAL 参数错误
|
||||
*Notes :
|
||||
*/
|
||||
int audio_anc_run(audio_anc_t *param);
|
||||
|
||||
int audio_anc_close();
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* audio_anc_fade_cfg_set
|
||||
* Description: ANC fade 基础配置
|
||||
* Arguments : en 淡入淡出使能;
|
||||
step 默认1,淡入步进,越大越快越容易有杂音
|
||||
slow 默认0,缓慢步进,越大越慢
|
||||
* Return : None.
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_anc_fade_cfg_set(u8 en, u8 step, u8 slow);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* audio_anc_fade
|
||||
* Description: ANC fade 增益配置
|
||||
* Arguments : ch 目标通道(enum ANC_fade_ch_t);
|
||||
gain 目标fade增益
|
||||
* Return : None.
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_anc_fade(u8 ch, u16 gain);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* audio_anc_fade_dly_get
|
||||
* Description: ANC根据采样率计算,淡出淡入时间
|
||||
* Arguments : target_value 淡入/出目标值, alogm 当前采样率
|
||||
* Return : dly 延时时间(ms)
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
int audio_anc_fade_dly_get(int target_value, int alogm);
|
||||
|
||||
void anc_coeff_online_update(audio_anc_t *param, u8 hd_reset_en);
|
||||
|
||||
int anc_coeff_size_count(audio_anc_t *param);
|
||||
|
||||
/*ANC配置id*/
|
||||
enum {
|
||||
ANC_DB_COEFF, //ANC系数
|
||||
ANC_DB_GAIN, //ANC增益
|
||||
ANC_DB_MAX,
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
u8 state; //ANC配置区状态
|
||||
u16 total_size; //ANC配置区总大小
|
||||
} anc_db_t;
|
||||
|
||||
/*anc配置区初始化*/
|
||||
int anc_db_init(void);
|
||||
/*根据配置id获取不同的anc配置*/
|
||||
int *anc_db_get(u8 id, u32 *len);
|
||||
/*
|
||||
*gain:增益配置,没有的话传NULL
|
||||
*coeff:系数配置,没有的话传NULL
|
||||
*/
|
||||
int anc_db_put(audio_anc_t *param, anc_gain_t *gain, anc_coeff_t *coeff);
|
||||
/*anc 音乐补偿模块在线开关*/
|
||||
void audio_anc_cmp_en(audio_anc_t *param, u8 en);
|
||||
|
||||
int anc_coeff_single_fill(audio_anc_t *param, anc_coeff_t *target_coeff);
|
||||
|
||||
void audio_anc_dcc_set(u8 ref_1_dcc, u8 err_1_dcc, u8 ref_2_dcc, u8 err_2_dcc);
|
||||
|
||||
void audio_anc_gain_sign(audio_anc_t *param);
|
||||
|
||||
void audio_anc_drc_ctrl(audio_anc_t *param, float drc_ratio);
|
||||
|
||||
void audio_anc_en_set(u8 en);
|
||||
|
||||
void audio_anc_norgain(s16 ffgain, s16 fbgain);
|
||||
/*anc ff增益设置API*/
|
||||
void audio_anc_ffgain_set(s16 l_gain, s16 r_gain);
|
||||
/*anc fb增益设置API*/
|
||||
void audio_anc_fbgain_set(s16 l_gain, s16 r_gain);
|
||||
|
||||
void audio_anc_tool_en_ctrl(audio_anc_t *param, u8 enablebit);
|
||||
|
||||
int audio_anc_gains_version_verify(audio_anc_t *param, anc_gain_t *cfg_target);
|
||||
|
||||
void audio_anc_drc_process(void);
|
||||
|
||||
void audio_anc_max_yorder_verify(audio_anc_t *param);
|
||||
|
||||
void audio_anc_param_normalize(audio_anc_t *param);
|
||||
|
||||
void audio_anc_param_init(audio_anc_t *param);
|
||||
|
||||
int anc_cfg_online_deal(u8 cmd, anc_gain_t *cfg);
|
||||
|
||||
void audio_anc_drc_process(void);
|
||||
|
||||
void audio_anc_debug_data_output(void);
|
||||
|
||||
void audio_anc_debug_cbuf_sel_set(u8 sel);
|
||||
|
||||
void audio_anc_debug_extern_trigger(u8 flag);
|
||||
|
||||
/*播歌状态下特殊处理API*/
|
||||
void audio_anc_mix_process(u8 en);
|
||||
|
||||
/*ANC模块复位*/
|
||||
void audio_anc_reset(audio_anc_t *param, u8 fade_en);
|
||||
|
||||
/********************工具交互API*************************/
|
||||
|
||||
/*设置结果回调函数*/
|
||||
void anc_api_set_callback(void (*callback)(u8, u8), void (*pow_callback)(anc_ack_msg_t *, u8));
|
||||
|
||||
/*设置淡入淡出使能*/
|
||||
void anc_api_set_fade_en(u8 en);
|
||||
|
||||
u8 anc_fade_ctr_ch_check(u8 ch);
|
||||
|
||||
/*获取ANC淡入淡出使能*/
|
||||
u8 anc_api_get_fade_en(void);
|
||||
|
||||
/*获取参数结构体*/
|
||||
anc_train_para_t *anc_api_get_train_param(void);
|
||||
|
||||
/*获取步进*/
|
||||
u8 anc_api_get_train_step(void);
|
||||
|
||||
/*设置通透目标能量值*/
|
||||
void anc_api_set_trans_aim_pow(u32 pow);
|
||||
|
||||
/*ANC在线调试标志设置*/
|
||||
void anc_online_busy_set(u8 en);
|
||||
|
||||
/*ANC在线调试标志获取*/
|
||||
u8 anc_online_busy_get(void);
|
||||
|
||||
/*ANC滤波器大小设置*/
|
||||
void anc_coeff_size_set(u8 mode, int len);
|
||||
|
||||
/*ANC滤波器大小获取*/
|
||||
int anc_coeff_size_get(u8 mode);
|
||||
|
||||
/*ANC滤波器参数填充*/
|
||||
int anc_coeff_fill(anc_coeff_t *db_coeff);
|
||||
|
||||
/*更新DRC 动态DCC使能设置*/
|
||||
void anc_drc_dcc_en_set(audio_anc_t *param);
|
||||
|
||||
/*ANC功率数据获取,长度为8byte*/
|
||||
void audio_anc_pow_get(u16 *pow);
|
||||
|
||||
/*ANC功率输出使能控制*/
|
||||
void audio_anc_pow_export_en(u8 en, u8 tool_en);
|
||||
|
||||
/*ANC滤波器格式校验*/
|
||||
int anc_coeff_check(anc_coeff_t *db_coeff, u16 len);
|
||||
|
||||
/*ANC量产模式设置*/
|
||||
void anc_production_mode_set(u8 en);
|
||||
|
||||
void audio_anc_fr_format(u8 *out_dat, float *fr, u8 order, const u8 *type);
|
||||
|
||||
void audio_anc_adaptive_data_analsis(anc_iir_t *iir);
|
||||
|
||||
anc_packet_data_t *anc_data_catch(anc_packet_data_t *row_data_packet, u8 *buf, u16 len, u16 id, u8 init_flag);
|
||||
|
||||
int anc_adaptive_ff_ref_data_get(u8 **buf);
|
||||
|
||||
void anc_adaptive_ff_ref_data_free(void);
|
||||
|
||||
int anc_adaptive_fb_ref_data_get(u8 **buf);
|
||||
|
||||
void anc_adaptive_ff_ref_data_save(u8 *buf, int len);
|
||||
|
||||
void free_anc_data_packet(anc_packet_data_t *anc_data_packet);
|
||||
|
||||
/*******************ANC增益自适应************************/
|
||||
/*ANC自适应初始化*/
|
||||
void anc_pow_adap_init(audio_anc_t *param, anc_adap_param_t *ref_p, anc_adap_param_t *err_p, \
|
||||
u8 ref_max_lvl, u8 err_max_lvl);
|
||||
|
||||
/*ANC自适应启动*/
|
||||
void audio_anc_pow_adap_start();
|
||||
|
||||
/*ANC自适应关闭*/
|
||||
void audio_anc_pow_adap_stop(void);
|
||||
|
||||
/*ANC自适应增益切换定时器注册*/
|
||||
void anc_pow_adap_fade_timer_add(int ref_lvl, int err_lvl);
|
||||
|
||||
/*ANC自适应当前增益等级获取*/
|
||||
int anc_pow_adap_lvl_get(u8 anc_type);
|
||||
|
||||
/*设置当前的ANC增益等级, 只有普通增益模式才可以设置*/
|
||||
void audio_anc_lvl_set(u8 lvl, u8 ex_en);
|
||||
|
||||
|
||||
void audio_anc_sz_fft_start(audio_anc_t *param, int len);
|
||||
void audio_anc_sz_fft_run(audio_anc_t *param);
|
||||
void audio_anc_sz_fft_stop(audio_anc_t *param);
|
||||
int audio_anc_sz_fft_outbuf_get(u8 **p);
|
||||
void audio_anc_sz_fft_outbuf_release(void);
|
||||
void audio_anc_sz_fft_trigger(void);
|
||||
|
||||
#endif/*_ANC_H_*/
|
||||
361
include_lib/media/media_new/media/cpu/br28/asm/audio_adc.h
Normal file
361
include_lib/media/media_new/media/cpu/br28/asm/audio_adc.h
Normal file
@ -0,0 +1,361 @@
|
||||
#ifndef AUDIO_ADC_H
|
||||
#define AUDIO_ADC_H
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "generic/list.h"
|
||||
#include "generic/atomic.h"
|
||||
#include "system/spinlock.h"
|
||||
|
||||
/*无电容电路*/
|
||||
#define SUPPORT_MIC_CAPLESS 1
|
||||
|
||||
#define BR22_ADC_BIT_FLAG_FADE_ON BIT(31)
|
||||
|
||||
#define FADE_OUT_IN 1
|
||||
#define FADE_OUT_TIME_MS 2
|
||||
|
||||
#define LADC_STATE_INIT 1
|
||||
#define LADC_STATE_OPEN 2
|
||||
#define LADC_STATE_START 3
|
||||
#define LADC_STATE_STOP 4
|
||||
|
||||
#define FPGA_BOARD 0
|
||||
|
||||
#define LADC_MIC 0
|
||||
#define LADC_LINEIN 1
|
||||
|
||||
#define SOURCE_MONO_LEFT 0
|
||||
#define SOURCE_MONO_RIGHT 1
|
||||
#define SOURCE_MONO_LEFT_RIGHT 2
|
||||
|
||||
#define ADC_DEFAULT_PNS 128
|
||||
|
||||
/* 通道选择 */
|
||||
#define AUDIO_ADC_MIC_0 BIT(0) // PA1
|
||||
#define AUDIO_ADC_MIC_1 BIT(1) // PA3
|
||||
#define AUDIO_ADC_MIC_2 BIT(2) // PG8
|
||||
#define AUDIO_ADC_MIC_3 BIT(3) // PG6
|
||||
#define AUDIO_ADC_LINE0 BIT(0) // PA1
|
||||
#define AUDIO_ADC_LINE1 BIT(1) // PA3
|
||||
#define AUDIO_ADC_LINE2 BIT(2) // PG8
|
||||
#define AUDIO_ADC_LINE3 BIT(3) // PG6
|
||||
#define PLNK_MIC BIT(6) //PDM MIC
|
||||
#define ALNK_MIC BIT(7) //IIS MIC
|
||||
|
||||
|
||||
/*mic_mode 工作模式定义*/
|
||||
#define AUDIO_MIC_CAP_MODE 0 //单端隔直电容模式
|
||||
#define AUDIO_MIC_CAP_DIFF_MODE 1 //差分隔直电容模式
|
||||
#define AUDIO_MIC_CAPLESS_MODE 2 //单端省电容模式
|
||||
|
||||
struct adc_platform_data {
|
||||
u8 mic_ldo_vsel : 3;//0:1.3v 1:1.4v 2:1.5v 3:2.0v 4:2.2v 5:2.4v 6:2.6v 7:2.8v
|
||||
u8 mic_ldo_isel : 2; //MIC通道电流档位选择
|
||||
u8 reserved: 3;
|
||||
u8 mic_capless; //MIC免电容方案
|
||||
//MIC免电容方案和mic bias供电方案需要设置,影响MIC的偏置电压 1:16K 2:7.5K 3:5.1K 4:6.8K 5:4.7K 6:3.5K 7:2.9K 8:3K 9:2.5K 10:2.1K 11:1.9K 12:2K 13:1.8K 14:1.6K 15:1.5K 16:1K 31:0.6K
|
||||
u8 mic_bias_res;
|
||||
u8 mic1_bias_res;
|
||||
u8 mic2_bias_res;
|
||||
u8 mic3_bias_res;
|
||||
|
||||
u32 mic_mode : 3; //MIC0工作模式
|
||||
u32 mic1_mode : 3; //MIC1工作模式
|
||||
u32 mic2_mode : 3; //MIC2工作模式
|
||||
u32 mic3_mode : 3; //MIC3工作模式
|
||||
u32 mic_bias_inside : 1; //MIC0电容隔直模式使用内部mic偏置 PA2
|
||||
u32 mic1_bias_inside : 1; //MIC1电容隔直模式使用内部mic偏置 PA4
|
||||
u32 mic2_bias_inside : 1; //MIC2电容隔直模式使用内部mic偏置 PG7
|
||||
u32 mic3_bias_inside : 1; //MIC3电容隔直模式使用内部mic偏置 PG5
|
||||
u32 mic_ldo_pwr : 1; // MICLDO供电到PAD(PA0)控制使能
|
||||
u32 lowpower_lvl : 2; //ADC低功耗等级
|
||||
|
||||
u8 mic_ldo_state;
|
||||
u8 mic_dcc; //mic的去直流dcc寄存器配置值,可配0到15,数值越大,其高通转折点越低
|
||||
u8 anc_adt_en;
|
||||
u8 anc_adt_mic_ch_num;
|
||||
u8 adc_max_ch_en;
|
||||
u8 max_channel_num;
|
||||
};
|
||||
|
||||
/*
|
||||
* p11系统VCO ADC mic模拟配置数据
|
||||
* 仅支持mic0,故应和主系统mic0对应
|
||||
*
|
||||
*/
|
||||
struct vco_adc_platform_data {
|
||||
u8 mic_mode;
|
||||
u8 mic_ldo_vsel;
|
||||
u8 mic_ldo_isel;
|
||||
u8 mic_bias_en;
|
||||
u8 mic_bias_res;
|
||||
u8 mic_bias_inside;
|
||||
u8 mic_ldo2PAD_en;
|
||||
u8 adc_rbs;
|
||||
u8 adc_rin;
|
||||
u8 adc_test; //VCO ADC测试使能,该配置用作ADC测试,届时AVAD、DVAD算法将无效
|
||||
};
|
||||
|
||||
/*
|
||||
* p11 VAD电源驱动参数和模拟电源域参数配置
|
||||
* 先放在adc模拟部分管理
|
||||
*/
|
||||
struct vad_power_data {
|
||||
u8 ldo_vs;
|
||||
u8 ldo_is;
|
||||
u8 lowpower;
|
||||
u8 clock;
|
||||
u8 clock_x2ds_disable;
|
||||
u8 acm_select;
|
||||
};
|
||||
|
||||
struct vad_mic_platform_data {
|
||||
struct vco_adc_platform_data mic_data;
|
||||
struct vad_power_data power_data;
|
||||
};
|
||||
|
||||
struct capless_low_pass {
|
||||
u16 bud; //快调边界
|
||||
u16 count;
|
||||
u16 pass_num;
|
||||
u16 tbidx;
|
||||
};
|
||||
|
||||
struct audio_adc_attr {
|
||||
u8 gain;
|
||||
u16 sample_rate;
|
||||
u16 irq_time;
|
||||
u16 irq_points;
|
||||
};
|
||||
|
||||
struct adc_stream_ops {
|
||||
void (*buf_reset)(void *priv);
|
||||
void *(*alloc_space)(void *priv, u32 *len);
|
||||
void (*output)(void *priv, void *buf, u32 len);
|
||||
};
|
||||
|
||||
struct audio_adc_output_hdl {
|
||||
struct list_head entry;
|
||||
void *priv;
|
||||
void (*handler)(void *, s16 *, int);
|
||||
};
|
||||
|
||||
struct audio_adc_hdl {
|
||||
struct list_head head;
|
||||
/*void *priv;
|
||||
const struct adc_stream_ops *ops;*/
|
||||
struct adc_platform_data *pd;
|
||||
spinlock_t lock;
|
||||
atomic_t ref;
|
||||
struct audio_adc_attr attr;
|
||||
u16 pause_srp;
|
||||
u16 pns;
|
||||
u8 fifo_full;
|
||||
u8 channel;
|
||||
u8 channel_num;
|
||||
u8 ch_sel;
|
||||
u8 input;
|
||||
u8 state;
|
||||
|
||||
union {
|
||||
struct {
|
||||
u8 out2dac : 1;
|
||||
u8 out_l : 1;
|
||||
u8 out_r : 1;
|
||||
u8 out_mix : 1;
|
||||
u8 cha_idx : 2;
|
||||
} ladc;
|
||||
u8 param;
|
||||
} u;
|
||||
#if FADE_OUT_IN
|
||||
u8 fade_on;
|
||||
volatile u8 ref_gain;
|
||||
volatile int fade_timer;
|
||||
#endif
|
||||
#if SUPPORT_MIC_CAPLESS
|
||||
struct capless_low_pass lp;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
struct adc_mic_ch {
|
||||
struct audio_adc_hdl *adc;
|
||||
u8 gain;
|
||||
u8 gain1;
|
||||
u8 gain2;
|
||||
u8 gain3;
|
||||
u8 buf_num;
|
||||
u16 buf_size;
|
||||
s16 *bufs;
|
||||
u16 sample_rate;
|
||||
void (*handler)(struct adc_mic_ch *, s16 *, u16);
|
||||
};
|
||||
|
||||
struct adc_linein_ch {
|
||||
struct audio_adc_hdl *adc;
|
||||
u8 gain;
|
||||
u8 gain1;
|
||||
u8 gain2;
|
||||
u8 gain3;
|
||||
u8 buf_num;
|
||||
u16 buf_size;
|
||||
s16 *bufs;
|
||||
u16 sample_rate;
|
||||
void (*handler)(struct adc_mic_ch *, s16 *, u16);
|
||||
};
|
||||
//MIC相关管理结构
|
||||
typedef struct {
|
||||
u8 en; //MIC使能
|
||||
u8 type; //FF_MIC使能
|
||||
u8 gain; //MIC增益
|
||||
u8 mult_flag; //通话复用标志
|
||||
} audio_adc_mic_mana_t;
|
||||
|
||||
void audio_adc_init(struct audio_adc_hdl *, struct adc_platform_data *);
|
||||
|
||||
void audio_adc_add_output_handler(struct audio_adc_hdl *, struct audio_adc_output_hdl *);
|
||||
|
||||
void audio_adc_del_output_handler(struct audio_adc_hdl *, struct audio_adc_output_hdl *);
|
||||
|
||||
void audio_adc_irq_handler(struct audio_adc_hdl *adc);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio ADC Mic Open
|
||||
* Description: 打开mic采样通道
|
||||
* Arguments : mic mic操作句柄
|
||||
* ch mic通道索引
|
||||
* adc adc模块操作句柄
|
||||
* Return : 0 成功 其他 失败
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
int audio_adc_mic_open(struct adc_mic_ch *mic, int ch, struct audio_adc_hdl *adc);
|
||||
int audio_adc_mic1_open(struct adc_mic_ch *mic, int ch, struct audio_adc_hdl *adc);
|
||||
int audio_adc_mic2_open(struct adc_mic_ch *mic, int ch, struct audio_adc_hdl *adc);
|
||||
int audio_adc_mic3_open(struct adc_mic_ch *mic, int ch, struct audio_adc_hdl *adc);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio ADC Mic Gain
|
||||
* Description: 设置mic增益
|
||||
* Arguments : mic mic操作句柄
|
||||
* gain mic增益
|
||||
* Return : 0 成功 其他 失败
|
||||
* Note(s) : MIC增益范围:0(-8dB)~19(30dB),step:2dB,level(4)=0dB
|
||||
*********************************************************************
|
||||
*/
|
||||
int audio_adc_mic_set_gain(struct adc_mic_ch *mic, int gain);
|
||||
int audio_adc_mic1_set_gain(struct adc_mic_ch *mic, int gain);
|
||||
int audio_adc_mic2_set_gain(struct adc_mic_ch *mic, int gain);
|
||||
int audio_adc_mic3_set_gain(struct adc_mic_ch *mic, int gain);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio ADC Mic Pre_Gain
|
||||
* Description: 设置mic第一级/前级增益
|
||||
* Arguments : en 前级增益使能(0:6dB 1:0dB)
|
||||
* Return : None.
|
||||
* Note(s) : 前级增益只有0dB和6dB两个档位
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_adc_mic_0dB_en(bool en);
|
||||
void audio_adc_mic1_0dB_en(bool en);
|
||||
void audio_adc_mic2_0dB_en(bool en);
|
||||
void audio_adc_mic3_0dB_en(bool en);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio ADC linein Open
|
||||
* Description: 打开linein采样通道
|
||||
* Arguments : linein linein操作句柄
|
||||
* ch linein通道索引
|
||||
* adc adc模块操作句柄
|
||||
* Return : 0 成功 其他 失败
|
||||
* Note(s) : None.
|
||||
*********************************************************************
|
||||
*/
|
||||
int audio_adc_linein_open(struct adc_linein_ch *linein, int ch, struct audio_adc_hdl *adc);
|
||||
int audio_adc_linein1_open(struct adc_linein_ch *linein, int ch, struct audio_adc_hdl *adc);
|
||||
int audio_adc_linein2_open(struct adc_linein_ch *linein, int ch, struct audio_adc_hdl *adc);
|
||||
int audio_adc_linein3_open(struct adc_linein_ch *linein, int ch, struct audio_adc_hdl *adc);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio ADC linein Gain
|
||||
* Description: 设置linein增益
|
||||
* Arguments : linein linein操作句柄
|
||||
* gain linein增益
|
||||
* Return : 0 成功 其他 失败
|
||||
* Note(s) : linein增益范围:0(-8dB)~19(30dB),step:2dB,level(4)=0dB
|
||||
*********************************************************************
|
||||
*/
|
||||
int audio_adc_linein_set_gain(struct adc_linein_ch *linein, int gain);
|
||||
int audio_adc_linein1_set_gain(struct adc_linein_ch *linein, int gain);
|
||||
int audio_adc_linein2_set_gain(struct adc_linein_ch *linein, int gain);
|
||||
int audio_adc_linein3_set_gain(struct adc_linein_ch *linein, int gain);
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* Audio ADC linein Pre_Gain
|
||||
* Description: 设置linein第一级/前级增益
|
||||
* Arguments : en 前级增益使能(0:6dB 1:0dB)
|
||||
* Return : None.
|
||||
* Note(s) : 前级增益只有0dB和6dB两个档位
|
||||
*********************************************************************
|
||||
*/
|
||||
void audio_adc_linein_0dB_en(bool en);
|
||||
void audio_adc_linein1_0dB_en(bool en);
|
||||
void audio_adc_linein2_0dB_en(bool en);
|
||||
void audio_adc_linein3_0dB_en(bool en);
|
||||
|
||||
|
||||
/*
|
||||
*********************************************************************
|
||||
* AUDIO MIC_LDO Control
|
||||
* Description: mic电源mic_ldo控制接口
|
||||
* Arguments : index ldo索引(MIC_LDO/MIC_LDO_BIAS0/MIC_LDO_BIAS1)
|
||||
* en 使能控制
|
||||
* pd audio_adc模块配置
|
||||
* Return : 0 成功 其他 失败
|
||||
* Note(s) : (1)MIC_LDO输出不经过上拉电阻分压
|
||||
* MIC_LDO_BIAS输出经过上拉电阻分压
|
||||
* (2)打开一个mic_ldo示例:
|
||||
* audio_mic_ldo_en(MIC_LDO,1,&adc_data);
|
||||
* (2)打开多个mic_ldo示例:
|
||||
* audio_mic_ldo_en(MIC_LDO | MIC_LDO_BIAS,1,&adc_data);
|
||||
*********************************************************************
|
||||
*/
|
||||
/*MIC LDO index输出定义*/
|
||||
#define MIC_LDO BIT(0) //PA0输出原始MIC_LDO
|
||||
#define MIC_LDO_BIAS0 BIT(1) //PA2输出经过内部上拉电阻分压的偏置
|
||||
#define MIC_LDO_BIAS1 BIT(2) //PA4输出经过内部上拉电阻分压的偏置
|
||||
#define MIC_LDO_BIAS2 BIT(3) //PG7输出经过内部上拉电阻分压的偏置
|
||||
#define MIC_LDO_BIAS3 BIT(4) //PG5输出经过内部上拉电阻分压的偏置
|
||||
int audio_adc_mic_ldo_en(u8 index, u8 en, struct adc_platform_data *pd);
|
||||
|
||||
int audio_adc_mic_set_sample_rate(struct adc_mic_ch *mic, int sample_rate);
|
||||
|
||||
int audio_adc_mic_set_buffs(struct adc_mic_ch *mic, s16 *bufs, u16 buf_size, u8 buf_num);
|
||||
|
||||
int audio_adc_mic_set_output_handler(struct adc_mic_ch *mic,
|
||||
void (*handler)(struct adc_mic_ch *, s16 *, u16));
|
||||
|
||||
int audio_adc_mic_start(struct adc_mic_ch *mic);
|
||||
|
||||
int audio_adc_mic_close(struct adc_mic_ch *mic);
|
||||
|
||||
int audio_adc_linein_start(struct adc_linein_ch *linein);
|
||||
|
||||
int audio_adc_linein_close(struct adc_linein_ch *linein);
|
||||
|
||||
void audio_anc_mic_gain(audio_adc_mic_mana_t *mic_param, u8 mult_gain_en);
|
||||
|
||||
void audio_anc_mic_open(audio_adc_mic_mana_t *mic_param, u8 trans_en, u8 adc_ch);
|
||||
|
||||
void audio_anc_mic_close(audio_adc_mic_mana_t *mic_param);
|
||||
|
||||
int audio_adc_linein_set_sample_rate(struct adc_linein_ch *linein, int sample_rate);
|
||||
|
||||
int audio_adc_linein_set_buffs(struct adc_linein_ch *linein, s16 *bufs, u16 buf_size, u8 buf_num);
|
||||
#endif
|
||||
@ -0,0 +1,34 @@
|
||||
#ifndef _AUDIO_LINEIN_H_
|
||||
#define _AUDIO_LINEIN_H_
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "asm/audio_adc.h"
|
||||
|
||||
/*
|
||||
*ch:
|
||||
*amux_en:
|
||||
*/
|
||||
int audio_linein0_open(u8 ch, u8 amux_en);
|
||||
int audio_linein0_close(u8 ch, u8 amux_en);
|
||||
int audio_linein1_open(u8 ch, u8 amux_en);
|
||||
int audio_linein1_close(u8 ch, u8 amux_en);
|
||||
int audio_linein2_open(u8 ch, u8 amux_en);
|
||||
int audio_linein2_close(u8 ch, u8 amux_en);
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void audio_linein_mute(u8 mute);
|
||||
/*
|
||||
*
|
||||
*/
|
||||
void audio_linein_gain(u8 gain);
|
||||
|
||||
void audio_linein_bias(u8 ch, u8 en);
|
||||
void audio_linein_amux_bias(u8 amux_bias);
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
void audio_linein_ch_combine(u8 LR_2_L, u8 LR_2_R);
|
||||
|
||||
#endif
|
||||
86
include_lib/media/media_new/media/cpu/br28/asm/audio_src.h
Normal file
86
include_lib/media/media_new/media/cpu/br28/asm/audio_src.h
Normal file
@ -0,0 +1,86 @@
|
||||
/*****************************************************************
|
||||
>file name : audio_src.h
|
||||
>author : lichao
|
||||
>create time : Fri 14 Dec 2018 03:05:49 PM CST
|
||||
*****************************************************************/
|
||||
#ifndef _AUDIO_SRC_H_
|
||||
#define _AUDIO_SRC_H_
|
||||
#include "media/audio_stream.h"
|
||||
#include "audio_resample.h"
|
||||
|
||||
|
||||
#define SRC_DATA_MIX 0//各通道数据交叉存放
|
||||
#define SRC_DATA_SEP 1//各通道数据连续存放
|
||||
|
||||
#define SRC_CHI 2
|
||||
#define SRC_FILT_POINTS 24
|
||||
|
||||
#define SRC_TYPE_NONE 0
|
||||
#define SRC_TYPE_RESAMPLE 1
|
||||
#define SRC_TYPE_AUDIO_SYNC 2
|
||||
|
||||
#define AUDIO_ONLY_RESAMPLE 1
|
||||
#define AUDIO_SYNC_RESAMPLE 2
|
||||
|
||||
#define AUDIO_SAMPLE_FMT_16BIT 0
|
||||
#define AUDIO_SAMPLE_FMT_24BIT 1
|
||||
|
||||
#define BIND_AUDSYNC 0x10
|
||||
#define SET_RESAMPLE_TYPE(fmt, type) (((fmt) << 4) | (type))
|
||||
#define RESAMPLE_TYPE_TO_FMT(a) (((a) >> 4) & 0xf)
|
||||
#define RESAMPLE_TYPE(a) ((a) & 0xf)
|
||||
|
||||
#define INPUT_FRAME_BITS 18//20 -- 整数位减少可提高单精度浮点的运算精度
|
||||
#define RESAMPLE_INPUT_BIT_RANGE ((1 << INPUT_FRAME_BITS) - 1)
|
||||
#define RESAMPLE_INPUT_BIT_NUM (1 << INPUT_FRAME_BITS)
|
||||
|
||||
#define RESAMPLE_HW_24BIT 1
|
||||
|
||||
|
||||
// *INDENT-OFF*
|
||||
struct audio_hw_resample_context {
|
||||
void *base;
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
|
||||
void *audio_resample_hw_open(u8 channel, int in_rate, int out_rate, u8 type);
|
||||
|
||||
int audio_resample_hw_change_config(void *resample, int in_rate, int out_rate);
|
||||
|
||||
int audio_resample_hw_set_input_buffer(void *resample, void *addr, int len);
|
||||
|
||||
int audio_resample_hw_set_output_buffer(void *resample, void *addr, int len);
|
||||
|
||||
int audio_resample_hw_set_output_handler(void *resample, void *, int (*handler)(void *, void *, int));
|
||||
|
||||
int audio_resample_hw_write(void *resample, void *data, int len);
|
||||
|
||||
int audio_resample_hw_trigger_interrupt(void *resample, void *priv, void (*handler)(void *));
|
||||
|
||||
int audio_resample_hw_stop(void *resample);
|
||||
|
||||
void audio_resample_hw_close(void *resample);
|
||||
|
||||
int audio_resample_hw_push_data_out(void *resample);
|
||||
|
||||
int audio_resample_hw_open_v1(struct audio_hw_resample_context *src, u8 channel, u8 type);
|
||||
|
||||
void audio_resample_hw_close_v1(struct audio_hw_resample_context *ctx);
|
||||
|
||||
#define audio_src_handle audio_hw_resample_context
|
||||
#define audio_hw_src_open audio_resample_hw_open_v1
|
||||
#define audio_hw_src_set_rate audio_resample_hw_change_config
|
||||
#define audio_src_resample_write audio_resample_hw_write
|
||||
#define audio_src_set_output_handler audio_resample_hw_set_output_handler
|
||||
#define audio_src_set_rise_irq_handler audio_resample_hw_trigger_interrupt
|
||||
#define audio_hw_src_set_input_buffer audio_resample_hw_set_input_buffer
|
||||
#define audio_hw_src_set_output_buffer audio_resample_hw_set_output_buffer
|
||||
#define audio_hw_src_stop audio_resample_hw_stop
|
||||
#define audio_hw_src_close audio_resample_hw_close_v1
|
||||
#define audio_hw_src_trigger_resume audio_resample_hw_trigger_interrupt
|
||||
#define audio_hw_src_set_check_running(a, b) (0)
|
||||
#define audio_hw_src_active(x) (0)
|
||||
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,48 @@
|
||||
/*****************************************************************
|
||||
>file name : audio_src_base.h
|
||||
>create time : Wed 02 Mar 2022 11:12:07 AM CST
|
||||
*****************************************************************/
|
||||
#ifndef _AUDIO_SRC_BASE_H_
|
||||
#define _AUDIO_SRC_BASE_H_
|
||||
#include "audio_src.h"
|
||||
|
||||
void *audio_src_base_open(u8 channel, int in_sample_rate, int out_sample_rate, u8 type);
|
||||
|
||||
int audio_src_base_set_output_handler(void *resample,
|
||||
void *priv,
|
||||
int (*handler)(void *priv, void *data, int len));
|
||||
|
||||
int audio_src_base_set_channel(void *resample, u8 channel);
|
||||
|
||||
int audio_src_base_set_in_buffer(void *resample, void *buf, int len);
|
||||
|
||||
int audio_src_base_set_input_buff(void *resample, void *buf, int len);
|
||||
|
||||
int audio_src_base_resample_config(void *resample, int in_rate, int out_rate);
|
||||
|
||||
int audio_src_base_write(void *resample, void *data, int len);
|
||||
|
||||
int audio_src_base_stop(void *resample);
|
||||
|
||||
int audio_src_base_run_scale(void *resample);
|
||||
|
||||
int audio_src_base_input_frames(void *resample);
|
||||
|
||||
u32 audio_src_base_out_frames(void *resample);
|
||||
|
||||
float audio_src_base_position(void *resample);
|
||||
|
||||
int audio_src_base_scale_output(void *resample, int in_sample_rate, int out_sample_rate, int frames);
|
||||
|
||||
int audio_src_base_bufferd_frames(void *resample);
|
||||
|
||||
int audio_src_base_set_slience(void *resample, u8 slience, int fade_time);
|
||||
|
||||
int audio_src_base_wait_irq_callback(void *resample, void *priv, void (*callback)(void *));
|
||||
|
||||
void audio_src_base_close(void *resample);
|
||||
|
||||
int audio_src_base_push_data_out(void *resample);
|
||||
|
||||
#endif
|
||||
|
||||
@ -0,0 +1,6 @@
|
||||
#ifndef _AUDIO_SUB_SYSTEM_H_
|
||||
#define _AUDIO_SUB_SYSTEM_H_
|
||||
|
||||
void audio_sub_system_init(void);
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,17 @@
|
||||
/*****************************************************************
|
||||
>file name : include_lib/media/cpu/br30/includes.h
|
||||
>author : lichao
|
||||
>create time : Fri 29 Nov 2019 02:24:47 PM CST
|
||||
*****************************************************************/
|
||||
#ifndef _ASM_MEDIA_INCLUDES_H_
|
||||
#define _ASM_MEDIA_INCLUDES_H_
|
||||
|
||||
#include "asm/audio_adc.h"
|
||||
#include "asm/audio_linein.h"
|
||||
#include "asm/audio_src.h"
|
||||
#include "asm/audio_src_base.h"
|
||||
#include "dac.h"
|
||||
#include "asm/hw_eq.h"
|
||||
#include "asm/audio_sub_system.h"
|
||||
|
||||
#endif
|
||||
407
include_lib/media/media_new/media/cpu/br28/asm/dac.h
Normal file
407
include_lib/media/media_new/media/cpu/br28/asm/dac.h
Normal file
@ -0,0 +1,407 @@
|
||||
#ifndef __CPU_DAC_H__
|
||||
#define __CPU_DAC_H__
|
||||
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "generic/atomic.h"
|
||||
#include "os/os_api.h"
|
||||
#include "audio_src.h"
|
||||
#include "media/audio_cfifo.h"
|
||||
|
||||
#define DAC_44_1KHZ 0
|
||||
#define DAC_48KHZ 1
|
||||
#define DAC_32KHZ 2
|
||||
#define DAC_22_05KHZ 3
|
||||
#define DAC_24KHZ 4
|
||||
#define DAC_16KHZ 5
|
||||
#define DAC_11_025KHZ 6
|
||||
#define DAC_12KHZ 7
|
||||
#define DAC_8KHZ 8
|
||||
|
||||
#define DAC_ISEL_FULL_PWR 4
|
||||
#define DAC_ISEL_HALF_PWR 2
|
||||
#define DAC_ISEL_THREE_PWR 1
|
||||
|
||||
#define DACVDD_LDO_1_20V 0
|
||||
#define DACVDD_LDO_1_25V 1
|
||||
#define DACVDD_LDO_1_30V 2
|
||||
#define DACVDD_LDO_1_35V 3
|
||||
|
||||
#define DAC_OUTPUT_MONO_L 0 //单左声道差分
|
||||
#define DAC_OUTPUT_MONO_R 1 //单右声道差分
|
||||
#define DAC_OUTPUT_LR 2 //双声道差分
|
||||
#define DAC_OUTPUT_MONO_LR_DIFF 3 //单声道 LP-RP 差分
|
||||
|
||||
#define DAC_DSM_6MHz 0
|
||||
#define DAC_DSM_12MHz 1
|
||||
|
||||
#define FADE_OUT_IN 1
|
||||
|
||||
#define AUDIO_DAC_SYNC_IDLE 0
|
||||
#define AUDIO_DAC_SYNC_START 1
|
||||
#define AUDIO_DAC_SYNC_NO_DATA 2
|
||||
#define AUDIO_DAC_SYNC_ALIGN_COMPLETE 3
|
||||
|
||||
#define AUDIO_SRC_SYNC_ENABLE 1
|
||||
#define SYNC_LOCATION_FLOAT 1
|
||||
#if SYNC_LOCATION_FLOAT
|
||||
#define PCM_PHASE_BIT 0
|
||||
#else
|
||||
#define PCM_PHASE_BIT 8
|
||||
#endif
|
||||
|
||||
#define DA_LEFT 0
|
||||
#define DA_RIGHT 1
|
||||
|
||||
/************************************
|
||||
* DAC模式
|
||||
*************************************/
|
||||
#define DAC_MODE_L_DIFF (0) // 低压差分模式 , 适用于低功率差分耳机 , 输出幅度 0~2Vpp
|
||||
#define DAC_MODE_L_SINGLE (1) // 低压单端模式 , 主要用于左右差分模式, 差分输出幅度 0~2Vpp
|
||||
#define DAC_MODE_H1_DIFF (2) // 高压1档差分模式, 适用于高功率差分耳机 , 输出幅度 0~3Vpp
|
||||
#define DAC_MODE_H1_SINGLE (3) // 高压1档单端模式, 适用于高功率单端PA音箱, 输出幅度 0~1.5Vpp
|
||||
#define DAC_MODE_H2_DIFF (4) // 高压2档差分模式, 适用于高功率差分PA音箱, 输出幅度 0~5Vpp
|
||||
#define DAC_MODE_H2_SINGLE (5) // 高压2档单端模式, 适用于高功率单端PA音箱, 输出幅度 0~2.5Vpp
|
||||
|
||||
#define DA_SOUND_NORMAL 0x0
|
||||
#define DA_SOUND_RESET 0x1
|
||||
#define DA_SOUND_WAIT_RESUME 0x2
|
||||
|
||||
#define DAC_ANALOG_OPEN_PREPARE (1)
|
||||
#define DAC_ANALOG_OPEN_FINISH (2)
|
||||
#define DAC_ANALOG_CLOSE_PREPARE (3)
|
||||
#define DAC_ANALOG_CLOSE_FINISH (4)
|
||||
//void audio_dac_power_state(u8 state)
|
||||
//在应用层重定义 audio_dac_power_state 函数可以获取dac模拟开关的状态
|
||||
|
||||
struct dac_platform_data {
|
||||
void (*analog_open_cb)(struct audio_dac_hdl *);
|
||||
void (*analog_close_cb)(struct audio_dac_hdl *);
|
||||
void (*analog_light_open_cb)(struct audio_dac_hdl *);
|
||||
void (*analog_light_close_cb)(struct audio_dac_hdl *);
|
||||
u8 mode; // AUDIO_DAC_MODE_XX
|
||||
u8 ldo_id;
|
||||
u8 ldo_volt;
|
||||
u8 pa_mute_port;
|
||||
u8 pa_mute_value;
|
||||
u8 output;
|
||||
u8 vcmo_en;
|
||||
u8 keep_vcmo;
|
||||
u8 lpf_isel;
|
||||
u8 sys_vol_type; //系统音量类型, 0:默认调数字音量 1:默认调模拟音量
|
||||
u8 max_ana_vol;
|
||||
u16 max_dig_vol;
|
||||
s16 *dig_vol_tab;
|
||||
u32 digital_gain_limit;
|
||||
u8 vcm_cap_en; //配1代表走外部通路,vcm上有电容时,可以提升电路抑制电源噪声能力,提高ADC的性能,配0相当于vcm上无电容,抑制电源噪声能力下降,ADC性能下降
|
||||
u8 power_on_mode;
|
||||
};
|
||||
|
||||
|
||||
struct analog_module {
|
||||
/*模拟相关的变量*/
|
||||
#if 0
|
||||
unsigned int ldo_en : 1;
|
||||
unsigned int ldo_volt : 3;
|
||||
unsigned int output : 4;
|
||||
unsigned int vcmo : 1;
|
||||
unsigned int inited : 1;
|
||||
unsigned int lpf_isel : 4;
|
||||
unsigned int keep_vcmo : 1;
|
||||
unsigned int reserved : 17;
|
||||
#endif
|
||||
u8 inited;
|
||||
u16 dac_test_volt;
|
||||
};
|
||||
struct audio_dac_trim {
|
||||
s16 left;
|
||||
s16 right;
|
||||
s16 vcomo;
|
||||
};
|
||||
|
||||
struct audio_dac_sync {
|
||||
u8 channel;
|
||||
u8 start;
|
||||
u8 fast_align;
|
||||
int fast_points;
|
||||
u32 input_num;
|
||||
int phase_sub;
|
||||
int in_rate;
|
||||
int out_rate;
|
||||
#if AUDIO_SRC_SYNC_ENABLE
|
||||
struct audio_src_sync_handle *src_sync;
|
||||
void *buf;
|
||||
int buf_len;
|
||||
void *filt_buf;
|
||||
int filt_len;
|
||||
#else
|
||||
struct audio_src_base_handle *src_base;
|
||||
#endif
|
||||
#if SYNC_LOCATION_FLOAT
|
||||
double pcm_position;
|
||||
#else
|
||||
u32 pcm_position;
|
||||
#endif
|
||||
void *priv;
|
||||
void (*handler)(void *priv, u8 state);
|
||||
};
|
||||
|
||||
struct audio_dac_fade {
|
||||
u8 enable;
|
||||
volatile u8 ref_L_gain;
|
||||
volatile u8 ref_R_gain;
|
||||
int timer;
|
||||
};
|
||||
|
||||
struct audio_dac_sync_node {
|
||||
void *hdl;
|
||||
struct list_head entry;
|
||||
};
|
||||
|
||||
struct audio_dac_channel_attr {
|
||||
u8 write_mode; /*DAC写入模式*/
|
||||
u16 delay_time; /*DAC通道延时*/
|
||||
u16 protect_time; /*DAC延时保护时间*/
|
||||
};
|
||||
|
||||
struct audio_dac_channel {
|
||||
u8 state; /*DAC状态*/
|
||||
u8 pause;
|
||||
u8 samp_sync_step; /*数据流驱动的采样同步步骤*/
|
||||
struct audio_dac_channel_attr attr; /*DAC通道属性*/
|
||||
struct audio_sample_sync *samp_sync; /*样点同步句柄*/
|
||||
struct audio_dac_hdl *dac; /* DAC设备*/
|
||||
struct audio_cfifo_channel fifo; /*DAC cfifo通道管理*/
|
||||
};
|
||||
|
||||
struct audio_dac_hdl {
|
||||
struct analog_module analog;
|
||||
const struct dac_platform_data *pd;
|
||||
OS_SEM sem;
|
||||
struct audio_dac_trim trim;
|
||||
void (*fade_handler)(u8 left_gain, u8 right_gain);
|
||||
void (*write_callback)(void *buf, int len);
|
||||
void (*set_samplerate_callback)(int len);
|
||||
u8 avdd_level;
|
||||
u8 lpf_i_level;
|
||||
volatile u8 mute;
|
||||
volatile u8 state;
|
||||
volatile u8 agree_on;
|
||||
u8 gain;
|
||||
u8 vol_l;
|
||||
u8 vol_r;
|
||||
u8 channel;
|
||||
u8 bit24_mode_en;
|
||||
u16 max_d_volume;
|
||||
u16 d_volume[2];
|
||||
u32 sample_rate;
|
||||
u32 digital_gain_limit;
|
||||
u16 start_ms;
|
||||
u16 delay_ms;
|
||||
u16 start_points;
|
||||
u16 delay_points;
|
||||
u16 prepare_points;//未开始让DAC真正跑之前写入的PCM点数
|
||||
|
||||
u16 irq_points;
|
||||
s16 protect_time;
|
||||
s16 protect_pns;
|
||||
s16 fadein_frames;
|
||||
s16 fade_vol;
|
||||
u8 protect_fadein;
|
||||
u8 vol_set_en;
|
||||
u8 dec_channel_num;
|
||||
|
||||
u8 sound_state;
|
||||
unsigned long sound_resume_time;
|
||||
s16 *output_buf;
|
||||
u16 output_buf_len;
|
||||
|
||||
u8 anc_dac_open;
|
||||
|
||||
u8 fifo_state;
|
||||
u16 unread_samples; /*未读样点个数*/
|
||||
struct audio_cfifo fifo; /*DAC cfifo结构管理*/
|
||||
struct audio_dac_channel main_ch;
|
||||
|
||||
struct audio_dac_sync sync;
|
||||
struct list_head sync_list;
|
||||
void *feedback_priv;
|
||||
void (*underrun_feedback)(void *priv);
|
||||
/*******************************************/
|
||||
/**sniff退出时,dac模拟提前初始化,避免模拟初始化延时,影响起始同步********/
|
||||
u8 power_on;
|
||||
u8 need_close;
|
||||
OS_MUTEX mutex;
|
||||
OS_MUTEX mutex_power_off;
|
||||
/*******************************************/
|
||||
};
|
||||
|
||||
|
||||
|
||||
int audio_dac_init(struct audio_dac_hdl *dac, const struct dac_platform_data *pd);
|
||||
|
||||
void audio_dac_set_capless_DTB(struct audio_dac_hdl *dac, s16 dacr32);
|
||||
|
||||
void audio_dac_avdd_level_set(struct audio_dac_hdl *dac, u8 level);
|
||||
|
||||
void audio_dac_lpf_level_set(struct audio_dac_hdl *dac, u8 level);
|
||||
|
||||
int audio_dac_do_trim(struct audio_dac_hdl *dac, struct audio_dac_trim *dac_trim, u8 fast_trim);
|
||||
|
||||
int audio_dac_set_trim_value(struct audio_dac_hdl *dac, struct audio_dac_trim *dac_trim);
|
||||
|
||||
int audio_dac_set_delay_time(struct audio_dac_hdl *dac, int start_ms, int max_ms);
|
||||
|
||||
void audio_dac_irq_handler(struct audio_dac_hdl *dac);
|
||||
|
||||
int audio_dac_set_buff(struct audio_dac_hdl *dac, s16 *buf, int len);
|
||||
|
||||
int audio_dac_write(struct audio_dac_hdl *dac, void *buf, int len);
|
||||
|
||||
int audio_dac_get_write_ptr(struct audio_dac_hdl *dac, s16 **ptr);
|
||||
|
||||
int audio_dac_update_write_ptr(struct audio_dac_hdl *dac, int len);
|
||||
|
||||
int audio_dac_set_sample_rate(struct audio_dac_hdl *dac, int sample_rate);
|
||||
|
||||
int audio_dac_get_sample_rate(struct audio_dac_hdl *dac);
|
||||
|
||||
int audio_dac_set_channel(struct audio_dac_hdl *dac, u8 channel);
|
||||
|
||||
int audio_dac_get_channel(struct audio_dac_hdl *dac);
|
||||
|
||||
int audio_dac_set_digital_vol(struct audio_dac_hdl *dac, u16 vol);
|
||||
|
||||
int audio_dac_set_analog_vol(struct audio_dac_hdl *dac, u16 vol);
|
||||
|
||||
int audio_dac_ch_analog_gain_set(struct audio_dac_hdl *dac, u32 ch, u32 again);
|
||||
|
||||
int audio_dac_ch_analog_gain_get(struct audio_dac_hdl *dac, u32 ch);
|
||||
|
||||
int audio_dac_ch_digital_gain_set(struct audio_dac_hdl *dac, u32 ch, u32 dgain);
|
||||
|
||||
int audio_dac_ch_digital_gain_get(struct audio_dac_hdl *dac, u32 ch);
|
||||
|
||||
int audio_dac_start(struct audio_dac_hdl *dac);
|
||||
|
||||
int audio_dac_try_power_on(struct audio_dac_hdl *dac);
|
||||
|
||||
int audio_dac_stop(struct audio_dac_hdl *dac);
|
||||
|
||||
int audio_dac_idle(struct audio_dac_hdl *dac);
|
||||
|
||||
void audio_dac_mute(struct audio_dac_hdl *hdl, u8 mute);
|
||||
|
||||
int audio_dac_open(struct audio_dac_hdl *dac);
|
||||
|
||||
int audio_dac_close(struct audio_dac_hdl *dac);
|
||||
|
||||
int audio_dac_mute_left(struct audio_dac_hdl *dac);
|
||||
|
||||
int audio_dac_mute_right(struct audio_dac_hdl *dac);
|
||||
|
||||
int audio_dac_set_volume(struct audio_dac_hdl *dac, u8 gain);
|
||||
|
||||
int audio_dac_set_L_digital_vol(struct audio_dac_hdl *dac, u16 vol);
|
||||
|
||||
int audio_dac_set_R_digital_vol(struct audio_dac_hdl *dac, u16 vol);
|
||||
|
||||
void audio_dac_set_fade_handler(struct audio_dac_hdl *dac, void *priv, void (*fade_handler)(u8, u8));
|
||||
|
||||
int audio_dac_sound_reset(struct audio_dac_hdl *dac, u32 msecs);
|
||||
|
||||
int audio_dac_set_bit_mode(struct audio_dac_hdl *dac, u8 bit24_mode_en);
|
||||
int audio_dac_get_max_channel(void);
|
||||
int audio_dac_get_status(struct audio_dac_hdl *dac);
|
||||
u8 audio_dac_is_working(struct audio_dac_hdl *dac);
|
||||
int audio_dac_set_irq_time(struct audio_dac_hdl *dac, int time_ms);
|
||||
int audio_dac_data_time(struct audio_dac_hdl *dac);
|
||||
int audio_dac_irq_enable(struct audio_dac_hdl *dac, int time_ms, void *priv, void (*callback)(void *));
|
||||
int audio_dac_set_protect_time(struct audio_dac_hdl *dac, int time, void *priv, void (*feedback)(void *));
|
||||
int audio_dac_buffered_frames(struct audio_dac_hdl *dac);
|
||||
void audio_dac_add_syncts_handle(struct audio_dac_hdl *dac, void *syncts);
|
||||
|
||||
void audio_dac_remove_syncts_handle(struct audio_dac_hdl *dac, void *syncts);
|
||||
/*
|
||||
* 音频同步
|
||||
*/
|
||||
int audio_dac_set_sync_buff(struct audio_dac_hdl *dac, void *buf, int len);
|
||||
|
||||
int audio_dac_set_sync_filt_buff(struct audio_dac_hdl *dac, void *buf, int len);
|
||||
|
||||
int audio_dac_sync_open(struct audio_dac_hdl *dac);
|
||||
|
||||
int audio_dac_sync_set_channel(struct audio_dac_hdl *dac, u8 channel);
|
||||
|
||||
int audio_dac_sync_set_rate(struct audio_dac_hdl *dac, int in_rate, int out_rate);
|
||||
|
||||
int audio_dac_sync_auto_update_rate(struct audio_dac_hdl *dac, u8 on_off);
|
||||
|
||||
int audio_dac_sync_flush_data(struct audio_dac_hdl *dac);
|
||||
|
||||
int audio_dac_sync_fast_align(struct audio_dac_hdl *dac, int in_rate, int out_rate, int fast_output_points, float phase_diff);
|
||||
|
||||
#if SYNC_LOCATION_FLOAT
|
||||
double audio_dac_sync_pcm_position(struct audio_dac_hdl *dac);
|
||||
#else
|
||||
u32 audio_dac_sync_pcm_position(struct audio_dac_hdl *dac);
|
||||
#endif
|
||||
|
||||
void audio_dac_sync_input_num_correct(struct audio_dac_hdl *dac, int num);
|
||||
|
||||
void audio_dac_set_sync_handler(struct audio_dac_hdl *dac, void *priv, void (*handler)(void *priv, u8 state));
|
||||
|
||||
int audio_dac_sync_start(struct audio_dac_hdl *dac);
|
||||
|
||||
int audio_dac_sync_stop(struct audio_dac_hdl *dac);
|
||||
|
||||
int audio_dac_sync_data_lock(struct audio_dac_hdl *dac);
|
||||
|
||||
int audio_dac_sync_data_unlock(struct audio_dac_hdl *dac);
|
||||
|
||||
void audio_dac_sync_close(struct audio_dac_hdl *dac);
|
||||
|
||||
void audio_dac_ch_mute(struct audio_dac_hdl *dac, u8 ch, u8 mute);
|
||||
|
||||
u32 local_audio_us_time_set(u16 time);
|
||||
|
||||
int local_audio_us_time(void);
|
||||
|
||||
int audio_dac_start_time_set(void *_dac, u32 us_timeout, u32 cur_time, u8 on_off);
|
||||
|
||||
u32 audio_dac_sync_pcm_total_number(void *_dac);
|
||||
|
||||
void audio_dac_sync_set_pcm_number(void *_dac, u32 output_points);
|
||||
|
||||
u32 audio_dac_pcm_total_number(void *_dac, int *pcm_r);
|
||||
|
||||
u8 audio_dac_sync_empty_state(void *_dac);
|
||||
|
||||
void audio_dac_sync_empty_reset(void *_dac, u8 state);
|
||||
|
||||
void audio_dac_set_empty_handler(void *_dac, void *empty_priv, void (*handler)(void *priv, u8 empty));
|
||||
|
||||
void audio_dac_channel_start(void *private_data);
|
||||
void audio_dac_channel_close(void *private_data);
|
||||
int audio_dac_channel_write(void *private_data, struct audio_dac_hdl *dac, void *buf, int len);
|
||||
int audio_dac_channel_set_attr(struct audio_dac_channel *ch, struct audio_dac_channel_attr *attr);
|
||||
int audio_dac_new_channel(struct audio_dac_hdl *dac, struct audio_dac_channel *ch);
|
||||
|
||||
void audio_anc_dac_gain(u8 gain_l, u8 gain_r);
|
||||
|
||||
void audio_anc_dac_dsm_sel(u8 sel);
|
||||
|
||||
void audio_anc_dac_open(u8 gain_l, u8 gain_r);
|
||||
|
||||
void audio_anc_dac_close(void);
|
||||
|
||||
void audio_dac_write_callback_add(struct audio_dac_hdl *dac, void (*cb)(void *buf, int len));
|
||||
|
||||
void audio_dac_write_callback_del(struct audio_dac_hdl *dac, void (*cb)(void *buf, int len));
|
||||
|
||||
void audio_dac_set_samplerate_callback_add(struct audio_dac_hdl *dac, void (*cb)(int));
|
||||
|
||||
void audio_dac_set_samplerate_callback_del(struct audio_dac_hdl *dac, void (*cb)(int));
|
||||
|
||||
#endif
|
||||
|
||||
334
include_lib/media/media_new/media/cpu/br28/asm/hw_eq.h
Normal file
334
include_lib/media/media_new/media/cpu/br28/asm/hw_eq.h
Normal file
@ -0,0 +1,334 @@
|
||||
|
||||
#ifndef __HW_EQ_H
|
||||
#define __HW_EQ_H
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "generic/list.h"
|
||||
#include "os/os_api.h"
|
||||
#include "media/eq_func_define.h"
|
||||
|
||||
|
||||
|
||||
enum { //运行模式
|
||||
NORMAL = 0, //正常模式
|
||||
MONO, //单声道模式
|
||||
STEREO //立体声模式
|
||||
};
|
||||
|
||||
enum { //输出数据类型
|
||||
DATO_SHORT = 0, //short
|
||||
DATO_INT, //int
|
||||
DATO_FLOAT //float
|
||||
};
|
||||
enum { //输入数据类型
|
||||
DATI_SHORT = 0, //short
|
||||
DATI_INT, // int
|
||||
DATI_FLOAT //float
|
||||
};
|
||||
enum { //输入数据存放模式
|
||||
BLOCK_DAT_IN = 0, //块模式,例如输入数据是2通道,先存放完第1通道的所有数据,再存放第2通道的所有数据
|
||||
SEQUENCE_DAT_IN, //序列模式,例如输入数据是2通道,先存放第通道的第一个数据,再存放第2个通道的第一个数据,以此类推。
|
||||
};
|
||||
enum { //输出数据存放模式
|
||||
BLOCK_DAT_OUT = 0,//块模式,例如输出数据是2通道,先存放完第1通道的所有数据,再存放第2通道的所有数据
|
||||
SEQUENCE_DAT_OUT, //序列模式,例如输入数据是2通道,先存放第通道的第一个数据,再存放第2个通道的第一个数据,以此类推。
|
||||
};
|
||||
|
||||
|
||||
/*eq IIR type*/
|
||||
typedef enum {
|
||||
EQ_IIR_TYPE_HIGH_PASS = 0x00,
|
||||
EQ_IIR_TYPE_LOW_PASS,
|
||||
EQ_IIR_TYPE_BAND_PASS,
|
||||
EQ_IIR_TYPE_HIGH_SHELF,
|
||||
EQ_IIR_TYPE_LOW_SHELF,
|
||||
} EQ_IIR_TYPE;
|
||||
|
||||
struct eq_seg_info {
|
||||
u16 index; //eq段序号
|
||||
u16 iir_type; //滤波器类型EQ_IIR_TYPE
|
||||
int freq; //中心截止频率
|
||||
float gain; //增益(-12 ~12 db)
|
||||
float q; //q值(0.3~30)
|
||||
};
|
||||
|
||||
struct eq_coeff_info {
|
||||
u8 nsection; //eq段数
|
||||
u8 no_coeff; //不是滤波系数
|
||||
#ifdef CONFIG_EQ_NO_USE_COEFF_TABLE
|
||||
u32 sr; //采样率
|
||||
#endif
|
||||
float *L_coeff; //左声道滤波器系数地址
|
||||
float *R_coeff; //右声道滤波器系数地址
|
||||
float L_gain; //左声道总增益(-20~20db)
|
||||
float R_gain; //右声道总增益(-20~20db)
|
||||
float *N_coeff[8];
|
||||
float N_gain[8];
|
||||
};
|
||||
|
||||
struct hw_eq_ch;
|
||||
|
||||
struct hw_eq {
|
||||
struct list_head head; //链表头
|
||||
OS_MUTEX mutex; //互斥锁
|
||||
volatile struct hw_eq_ch *cur_ch; //当前需要处理的eq通道
|
||||
};
|
||||
|
||||
enum {
|
||||
HW_EQ_CMD_CLEAR_MEM = 0xffffff00,
|
||||
HW_EQ_CMD_CLEAR_MEM_L,
|
||||
HW_EQ_CMD_CLEAR_MEM_R,
|
||||
};
|
||||
|
||||
struct hw_eq_handler {
|
||||
int (*eq_probe)(struct hw_eq_ch *); //eq驱动内前处理
|
||||
int (*eq_output)(struct hw_eq_ch *, s16 *, u16); //eq驱动内输出处理回调
|
||||
int (*eq_post)(struct hw_eq_ch *); //eq驱动内处理后回调
|
||||
int (*eq_input)(struct hw_eq_ch *, void **, void **); //eq驱动内输入处理回调
|
||||
};
|
||||
|
||||
struct hw_eq_ch {
|
||||
unsigned char updata; //更新参数以及中间数据
|
||||
unsigned char updata_coeff_only; //只更新参数,不更新中间数据
|
||||
unsigned char no_wait; //是否是异步eq处理 0:同步的eq 1:异步的eq
|
||||
unsigned char channels; //输入通道数
|
||||
unsigned char SHI; //eq运算输出数据左移位数控制,记录
|
||||
unsigned char countL; //eq运算输出数据左移位数控制临时记录
|
||||
unsigned short stage; //eq运算开始位置标识
|
||||
unsigned char nsection; //eq段数
|
||||
unsigned char no_coeff; // 非滤波系数
|
||||
volatile unsigned char active; //已启动eq处理 1:busy 0:处理结束
|
||||
volatile unsigned char need_run; //多eq同时使用时,未启动成功的eq,是否需要重新唤醒处理 1:需要 0:否
|
||||
unsigned char run_mode; //0按照输入的数据排布方式 ,输出数据 1:单入多出, 2:立体声入多出
|
||||
unsigned char in_mode; //输入数据的位宽 0:short 1:int 2:float
|
||||
unsigned char out_32bit; //输出数据的位宽 0:short 1:int 2:float
|
||||
unsigned char out_channels; //输出通道数
|
||||
unsigned char data_in_mode; //输入数据存放模式
|
||||
unsigned char data_out_mode; //输入数据存放模式
|
||||
#ifdef CONFIG_EQ_NO_USE_COEFF_TABLE
|
||||
u32 sr; //采样率
|
||||
#endif
|
||||
float *L_coeff; //输入给左声道系数地址
|
||||
float *R_coeff; //输入给右声道系数地址
|
||||
float L_gain; //输入给左声道总增益(-20~20)
|
||||
float R_gain; //输入给右声道总增益(-20~20)
|
||||
float *N_coeff[8];
|
||||
float N_gain[8];
|
||||
float *eq_LRmem; //eq系数地址(包含运算的中间数据)
|
||||
s16 *out_buf; //输出buf地址
|
||||
s16 *in_buf; //输入buf地址
|
||||
int in_len; //输入数据长度
|
||||
void *priv; //保存eq管理层的句柄
|
||||
volatile OS_SEM sem; //信号量,用于通知驱动,当前一次处理完成
|
||||
struct list_head entry; //当前eq通道的节点
|
||||
struct hw_eq *eq; //底层eq操作句柄
|
||||
const struct hw_eq_handler *eq_handler;//eq操作的相关回调函数句柄
|
||||
void *irq_priv; //eq管理层传入的私有指针
|
||||
void (*irq_callback)(void *priv);//需要eq中断执行的回调函数
|
||||
};
|
||||
|
||||
//系数计算子函数
|
||||
|
||||
/*
|
||||
fc: 低通滤波器-3dB衰减频点
|
||||
fs: 采样率
|
||||
nSOS: 生成nSOS阶IIR
|
||||
coeff: 输出系数地址 ( 大小为 ((nSOS & 1) + (nSOS >> 1))*5 , 顺序是按照硬件EQ摆放了 )
|
||||
段数:((nSOS & 1) + (nSOS >> 1))*/
|
||||
/*
|
||||
* 多阶级低通滤波器
|
||||
fc: 低通滤波器-3dB衰减频点
|
||||
fs: 采样率
|
||||
nSOS: 生成多少个2阶IIR
|
||||
coeff: 输出系数地址 ( 大小为 nSOS*5 , 顺序是按照硬件EQ摆放了 )*/
|
||||
extern void butterworth_lp_design(int fc, int fs, int nSOS, float *coeff);
|
||||
|
||||
/*
|
||||
fc: 通滤波器-3dB衰减频点
|
||||
fs: 采样率
|
||||
nSOS: 生成nSOS阶IIR
|
||||
coeff: 输出系数地址 ( 大小为((nSOS & 1) + (nSOS >> 1))*5 , 顺序是按照硬件EQ摆放了 )
|
||||
段数:((nSOS & 1) + (nSOS >> 1))*/
|
||||
extern void butterworth_hp_design(int fc, int fs, int nSOS, float *coeff);
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 低通滤波器
|
||||
@param fc:中心截止频率
|
||||
@param fs:采样率
|
||||
@param quality_factor:q值
|
||||
@param coeff:计算后,系数输出地址
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
extern void design_lp(int fc, int fs, float quality_factor, float *coeff);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 高通滤波器
|
||||
@param fc:中心截止频率
|
||||
@param fs:采样率
|
||||
@param quality_factor:q值
|
||||
@param coeff:计算后,系数输出地址
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
extern void design_hp(int fc, int fs, float quality_factor, float *coeff);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 带通滤波器
|
||||
@param fc:中心截止频率
|
||||
@param fs:采样率
|
||||
@param gain:增益
|
||||
@param quality_factor:q值
|
||||
@param coeff:计算后,系数输出地址
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
extern void design_pe(int fc, int fs, float gain, float quality_factor, float *coeff);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 低频搁架式滤波器
|
||||
@param fc:中心截止频率
|
||||
@param fs:采样率
|
||||
@param gain:增益
|
||||
@param quality_factor:q值
|
||||
@param coeff:计算后,系数输出地址
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
extern void design_ls(int fc, int fs, float gain, float quality_factor, float *coeff);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 高频搁架式滤波器
|
||||
@param fc:中心截止频率
|
||||
@param fs:采样率
|
||||
@param gain:增益
|
||||
@param quality_factor:q值
|
||||
@param coeff:计算后,系数输出地址
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
extern void design_hs(int fc, int fs, float gain, float quality_factor, float *coeff);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 滤波器系数检查
|
||||
@param coeff:滤波器系数
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
extern int eq_stable_check(float *coeff);
|
||||
float eq_db2mag(float x);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 获取直通的滤波器系数
|
||||
@param coeff:滤波器系数
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
extern void eq_get_AllpassCoeff(void *Coeff);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 滤波器计算管理函数
|
||||
@param *seg:提供给滤波器的基本信息
|
||||
@param sample_rate:采样率
|
||||
@param *coeff:计算后,系数输出地址
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int eq_seg_design(struct eq_seg_info *seg, int sample_rate, float *coeff);
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 在EQ中断中调用
|
||||
@param *eq:句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
void audio_hw_eq_irq_handler(struct hw_eq *eq);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief EQ初始化
|
||||
@param *eq:句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_hw_eq_init(struct hw_eq *eq, u32 eq_section_num);
|
||||
int audio_hw_eq_init_new(struct hw_eq *eq, u32 eq_section_num);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 打开一个通道
|
||||
@param *ch:通道句柄
|
||||
@param *eq:句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_hw_eq_ch_open(struct hw_eq_ch *ch, struct hw_eq *eq);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 设置回调接口
|
||||
@param *ch:通道句柄
|
||||
@param *handler:回调的句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_hw_eq_ch_set_handler(struct hw_eq_ch *ch, struct hw_eq_handler *handler);
|
||||
//
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 设置通道基础信息
|
||||
@param *ch:通道句柄
|
||||
@param channels:通道数
|
||||
@param out_32bit:是否输出32bit位宽数据 1:是 0:16bit位宽
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_hw_eq_ch_set_info(struct hw_eq_ch *ch, u8 channels, u8 out_32bit);
|
||||
int audio_hw_eq_ch_set_info_new(struct hw_eq_ch *ch, u8 channels, u8 in_mode, u8 out_mode, u8 run_mode, u8 data_in_mode, u8 data_out_mode);
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 设置硬件转换系数
|
||||
@param *ch:通道句柄
|
||||
@param *info:系数、增益等信息
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_hw_eq_ch_set_coeff(struct hw_eq_ch *ch, struct eq_coeff_info *info);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 启动一次转换
|
||||
@param *ch:eq句柄
|
||||
@param *input:输入数据地址
|
||||
@param *output:输出数据地址
|
||||
@param len:输入数据长度
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_hw_eq_ch_start(struct hw_eq_ch *ch, void *input, void *output, int len);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 关闭一个通道
|
||||
@param *ch:eq句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_hw_eq_ch_close(struct hw_eq_ch *ch);
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**@brief 获取eq是否正在运行状态
|
||||
@param *ch:eq句柄
|
||||
@return
|
||||
@note
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
int audio_hw_eq_is_running(struct hw_eq *eq);
|
||||
|
||||
#endif /*__HW_EQ_H*/
|
||||
|
||||
53
include_lib/media/media_new/media/cpu/br28/asm/pdm_link.h
Normal file
53
include_lib/media/media_new/media/cpu/br28/asm/pdm_link.h
Normal file
@ -0,0 +1,53 @@
|
||||
|
||||
#ifndef _PDM_LINK_H_
|
||||
#define _PDM_LINK_H_
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#define PLNK_CH0_EN BIT(0)
|
||||
#define PLNK_CH1_EN BIT(1)
|
||||
#define PLNK_CH_EN PLNK_CH0_EN //(PLNK_CH0_EN | PLNK_CH1_EN)
|
||||
#define PLNK_SCLK_PIN IO_PORTA_14
|
||||
#define PLNK_DAT0_PIN IO_PORTA_15
|
||||
#define PLINK_BUF_LEN 256
|
||||
#define PLNK_CLK 24000000 //48M
|
||||
#define PLNK_SCLK 2400000 //1M ~ 4M
|
||||
#define PLNK_CON_RESET() do {JL_PLNK->CON = 0; JL_PLNK->CON1 = 0;} while(0)
|
||||
#define PLNK_CH0_MD_SET(x) SFR(JL_PLNK->CON, 2, 2, x)
|
||||
#define PLNK_CH1_MD_SET(x) SFR(JL_PLNK->CON, 6, 2, x)
|
||||
#define PLNK_PND_CLR() SFR(JL_PLNK->CON, 14, 1, 1); //CPND
|
||||
|
||||
/*通道0输入模式选择*/
|
||||
typedef enum {
|
||||
CH0MD_CH0_SCLK_RISING_EDGE,
|
||||
CH0MD_CH0_SCLK_FALLING_EDGE,
|
||||
CH0MD_CH1_SCLK_RISING_EDGE,
|
||||
CH0MD_CH1_SCLK_FALLING_EDGE,
|
||||
} PDM_LINK_CH0MD;
|
||||
|
||||
/*通道1输入模式选择*/
|
||||
typedef enum {
|
||||
CH1MD_CH1_SCLK_RISING_EDGE,
|
||||
CH1MD_CH1_SCLK_FALLING_EDGE,
|
||||
CH1MD_CH0_SCLK_RISING_EDGE,
|
||||
CH1MD_CH0_SCLK_FALLING_EDGE,
|
||||
} PDM_LINK_CH1MD;
|
||||
|
||||
typedef struct {
|
||||
u8 sclk_io;
|
||||
u8 ch_num; /*使能多少个通道*/
|
||||
u8 ch0_io;
|
||||
u8 ch1_io;
|
||||
u8 ch0_mode; /*通道0输入模式选择*/
|
||||
u8 ch1_mode; /*通道1输入模式选择*/
|
||||
u16 sr; /*采样率*/
|
||||
u16 buf_len; /*一次采样点数*/
|
||||
s16 *buf;
|
||||
void (*output)(void *buf, u16 len);
|
||||
} audio_plnk_t;
|
||||
|
||||
int audio_plnk_open(audio_plnk_t *hdl);
|
||||
int audio_plnk_start(audio_plnk_t *hdl);
|
||||
int audio_plnk_close(void);
|
||||
void audio_plnk_test();
|
||||
|
||||
#endif/*_PDM_LINK_H_*/
|
||||
439
include_lib/media/media_new/media/cpu/br28/audio_lib.ld
Normal file
439
include_lib/media/media_new/media/cpu/br28/audio_lib.ld
Normal file
@ -0,0 +1,439 @@
|
||||
SECTIONS
|
||||
{
|
||||
.data : ALIGN(4)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
audio_sync_data_begin = .;
|
||||
*(.audio_sync_data)
|
||||
audio_sync_data_end = .;
|
||||
. = ALIGN(4);
|
||||
|
||||
*(.sbc_data)
|
||||
*(.msbc_data)
|
||||
*(.cvsd_data)
|
||||
*(.aac_data)
|
||||
*(.ldac_decoder_data)
|
||||
*(.sbc_eng_data)
|
||||
*(.bt_audioplc_data)
|
||||
*(.lc3_decoder_data)
|
||||
*(.lc3_dec_data)
|
||||
*(.wtgv2_data)
|
||||
*(.wtgv2dec_data)
|
||||
*(.opus_encoder_data)
|
||||
*(.speex_encoder_data)
|
||||
|
||||
*(.anc_data)
|
||||
*(.anc_user_data)
|
||||
*(.anc_box_data)
|
||||
*(.anc_btspp_data)
|
||||
*(.audio_adc_data)
|
||||
*(.audio_cfifo_data)
|
||||
|
||||
*(.sms_data)
|
||||
. = ALIGN(4);
|
||||
*(.pSOUND360TD_cal_data)
|
||||
. = ALIGN(4);
|
||||
*(.jlsp_data)
|
||||
*(.jlsp_aec_data)
|
||||
*(.jlsp_nlp_data)
|
||||
*(.jlsp_dns_data)
|
||||
*(.jlsp_enc_data)
|
||||
*(.jlsp_prep_data)
|
||||
*(.jlsp_wn_data)
|
||||
*(.jlsp_tri_data)
|
||||
*(.jlsp_agc_data)
|
||||
. = ALIGN(4);
|
||||
#if AUDIO_EFFECTS_GAIN_AT_RAM
|
||||
*(.audio_gain_code)
|
||||
*(.audio_gain_const)
|
||||
#endif/*AUDIO_EFFECTS_GAIN_AT_RAM*/
|
||||
} > ram0
|
||||
|
||||
.bss (NOLOAD) :ALIGN(4)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
audio_sync_bss_begin = .;
|
||||
*(.audio_sync_bss)
|
||||
audio_sync_bss_end = .;
|
||||
. = ALIGN(4);
|
||||
|
||||
*(.cvsd_bss)
|
||||
*(.aac_bss)
|
||||
*(.ldac_decoder_bss)
|
||||
*(.sbc_eng_bss)
|
||||
*(.bt_audioplc_bss)
|
||||
*(.lc3_decoder_bss)
|
||||
*(.lc3_dec_bss)
|
||||
*(.wtgv2_bss)
|
||||
*(.wtgv2dec_bss)
|
||||
*(.speex_encoder_bss)
|
||||
*(.opus_encoder_bss)
|
||||
|
||||
*(.anc_bss)
|
||||
*(.anc_user_bss)
|
||||
*(.anc_box_bss)
|
||||
*(.anc_btspp_bss)
|
||||
*(.audio_adc_bss)
|
||||
*(.audio_cfifo_bss)
|
||||
|
||||
*(.audio_dec_bss)
|
||||
*(.audio_buf)
|
||||
*(.src_filt)
|
||||
*(.src_dma)
|
||||
|
||||
*(.jlsp_bss)
|
||||
*(.jlsp_aec_bss)
|
||||
*(.jlsp_nlp_bss)
|
||||
*(.jlsp_dns_bss)
|
||||
*(.jlsp_enc_bss)
|
||||
*(.jlsp_prep_bss)
|
||||
*(.jlsp_wn_bss)
|
||||
*(.jlsp_tri_bss)
|
||||
*(.jlsp_agc_bss)
|
||||
. = ALIGN(4);
|
||||
*(.pSOUND360TD_cal_bss)
|
||||
|
||||
} > ram0
|
||||
|
||||
.text : ALIGN(4)
|
||||
{
|
||||
media_text_start = .;
|
||||
|
||||
. = ALIGN(4);
|
||||
*(.stream_code)
|
||||
*(.howlings_phf_code)
|
||||
*(.notchhowling_sparse_code)
|
||||
*(.notchhowling_code)
|
||||
*(.howlings_phf_sparse_code)
|
||||
*(.notchhowling_const)
|
||||
*(.howlings_phf_const)
|
||||
|
||||
. = ALIGN(4);
|
||||
*(.llns.text)
|
||||
*(.llns.text.const)
|
||||
|
||||
. = ALIGN(4);
|
||||
*(.aec_code)
|
||||
*(.aec_const)
|
||||
|
||||
. = ALIGN(4);
|
||||
*(.res_code)
|
||||
*(.res_const)
|
||||
|
||||
. = ALIGN(4);
|
||||
*(.ns_code)
|
||||
*(.ns_const)
|
||||
*(.bark_const)
|
||||
|
||||
. = ALIGN(4);
|
||||
*(.jlsp_code)
|
||||
. = ALIGN(4);
|
||||
*(.jlsp_const)
|
||||
. = ALIGN(4);
|
||||
*(.dns_16k_data)
|
||||
. = ALIGN(4);
|
||||
*(.dns_8k_data)
|
||||
. = ALIGN(4);
|
||||
*(.jlsp_dns_code)
|
||||
*(.jlsp_dns_const)
|
||||
*(.dns_param_data_wind)
|
||||
*(.dns_common_data_wind)
|
||||
|
||||
*(.agc_code)
|
||||
*(.dms_code)
|
||||
*(.dms_sparse_code)
|
||||
|
||||
*(.nlp_code)
|
||||
*(.nlp_const)
|
||||
*(.der_code)
|
||||
*(.der_const)
|
||||
*(.qmf_code)
|
||||
*(.qmf_const)
|
||||
*(.fft_code)
|
||||
*(.fft_const)
|
||||
*(.drc_sparse_code)
|
||||
*(.drc_code)
|
||||
*(.drc_const)
|
||||
#if (AUDIO_EFFECTS_GAIN_AT_RAM == 0)
|
||||
*(.audio_gain_code)
|
||||
*(.audio_gain_const)
|
||||
#endif
|
||||
*(.ns_sparse_code )
|
||||
*(.aec_sparse_code)
|
||||
*(.nlp_sparse_code)
|
||||
*(.der_sparse_code)
|
||||
*(.qmf_sparse_code)
|
||||
*(.bt_audioplc_code)
|
||||
*(.bt_audioplc_sparse_code)
|
||||
*(.bt_audioplc_const)
|
||||
. = ALIGN(4);
|
||||
*(.lf_audioplc_code)
|
||||
*(.lf_audioplc_sparse_code)
|
||||
*(.lf_audioplc_const)
|
||||
|
||||
. = ALIGN(4);
|
||||
*(.pcm_code)
|
||||
*(.pcm_const)
|
||||
/* *(.cvsd_code) */
|
||||
/* *(.cvsd_const) */
|
||||
/* *(.g729_code) */
|
||||
/* *(.g729_const) */
|
||||
*(.wtg_dec_code)
|
||||
*(.wtg_dec_sparse_code)
|
||||
*(.wtg_dec_const)
|
||||
*(.wtgv2_code)
|
||||
*(.wtgv2_const)
|
||||
*(.wtgv2dec_code)
|
||||
*(.wtgv2dec_const)
|
||||
*(.wtgv2dec_str)
|
||||
*(.wtg_decv2_sparse_code)
|
||||
*(.speex_dec_code)
|
||||
*(.speex_dec_const)
|
||||
*(.speex_const)
|
||||
*(.speex_code)
|
||||
*(.speex_encoder_code)
|
||||
*(.speex_encoder_const)
|
||||
*(.opus_code)
|
||||
*(.opus_const)
|
||||
*(.opus_encoder_code)
|
||||
*(.opus_encoder_const)
|
||||
*(.mp3_code)
|
||||
*(.mp3_const)
|
||||
*(.mp3_dec_sparse_code)
|
||||
*(.mp3_dec_sparse_const)
|
||||
*(.mp3_dec_code)
|
||||
*(.mp3_dec_const)
|
||||
*(.bfilt_code)
|
||||
*(.msbc_code)
|
||||
*(.msbc_const)
|
||||
*(.mty_code)
|
||||
*(.mp3tsy_dec_code)
|
||||
*(.mp3tsy_dec_sparse_code)
|
||||
*(.mp3tsy_dec_const)
|
||||
*(.sbc_code)
|
||||
*(.sbc_const)
|
||||
*(.sine_code)
|
||||
*(.sine_const)
|
||||
*(.wav_code)
|
||||
*(.wav_const)
|
||||
*(.wav_dec_code)
|
||||
*(.wav_dec_const)
|
||||
*(.wav_dec_sparse_code)
|
||||
*(.wav_dec_sparse_const)
|
||||
*(.wma_code)
|
||||
*(.wma_const)
|
||||
*(.wma_dec_code)
|
||||
*(.wma_dec_sparse_code)
|
||||
*(.wma_dec_const)
|
||||
*(.aac_code)
|
||||
*(.aac_const)
|
||||
*(.ldac_decoder_code)
|
||||
*(.ldac_decoder_const)
|
||||
*(.bt_ldac_dec_code)
|
||||
*(.bt_ldac_dec_const)
|
||||
*(.amr_code)
|
||||
*(.amr_const)
|
||||
*(.amr_dec_code)
|
||||
*(.amr_dec_const)
|
||||
*(.amr_dec_sparse_code)
|
||||
*(.ape_code)
|
||||
*(.ape_const)
|
||||
*(.ape_dec_code)
|
||||
*(.ape_dec_sparse_code)
|
||||
*(.ape_dec_const)
|
||||
*(.dts_code)
|
||||
*(.dts_const)
|
||||
*(.dts_dec_sparse_code)
|
||||
*(.dts_dec_code)
|
||||
*(.dts_dec_const)
|
||||
*(.dts_dec_ff_const)
|
||||
*(.flac_code)
|
||||
*(.flac_const)
|
||||
*(.flac_dec_code)
|
||||
*(.flac_dec_const)
|
||||
*(.flac_dec_sparse_code)
|
||||
*(.audio_decoder_code)
|
||||
*(.audio_decoder_const)
|
||||
*(.audio_track_const)
|
||||
*(.audio_track_code)
|
||||
|
||||
/* *(.cvsd_code) */
|
||||
/* *(.cvsd_const) */
|
||||
*(.m4a_code)
|
||||
*(.m4a_const)
|
||||
*(.m4a_dec_code)
|
||||
*(.m4a_dec_sparse_code)
|
||||
*(.m4a_dec_sparse_const)
|
||||
*(.bt_aac_dec_core_sparse_const)
|
||||
*(.bt_aac_dec_core_sparse_code)
|
||||
*(.bt_aac_dec_core_code)
|
||||
*(.bt_aac_dec_eng_code)
|
||||
*(.bt_aac_dec_eng_const)
|
||||
*(.alac_code)
|
||||
*(.alac_const)
|
||||
*(.alac_dec_code)
|
||||
*(.media_device_code)
|
||||
*(.media_device_const)
|
||||
*(.audio_encoder_code)
|
||||
*(.audio_encoder_const)
|
||||
*(.mixer_code)
|
||||
*(.mixer_const)
|
||||
*(.dec_server_code)
|
||||
*(.dec_server_const)
|
||||
*(.rec_server_code)
|
||||
*(.rec_server_const)
|
||||
*(.auto_mute_code)
|
||||
*(.auto_mute_const)
|
||||
*(.plc_code)
|
||||
*(.plc_const)
|
||||
*(.wireless_sync_code)
|
||||
*(.wireless_sync_const)
|
||||
*(.sbc_eng_code)
|
||||
*(.sbc_eng_const)
|
||||
|
||||
anc_code_begin = .;
|
||||
*(.anc_user_const)
|
||||
*(.anc_user_code)
|
||||
*(.anc_const)
|
||||
*(.anc_code)
|
||||
*(.anc_core_const)
|
||||
*(.anc_core_code)
|
||||
*(.anc_box_const)
|
||||
*(.anc_box_code)
|
||||
*(.anc_btspp_const)
|
||||
*(.anc_btspp_code)
|
||||
anc_code_end = .;
|
||||
anc_code_size = anc_code_end - anc_code_begin;
|
||||
|
||||
*(.audio_codec_code)
|
||||
*(.audio_adc_code)
|
||||
*(.audio_adc_const)
|
||||
*(.audio_cfifo_code)
|
||||
*(.audio_cfifo_const)
|
||||
|
||||
*(.bt_compressor_sparse_const)
|
||||
*(.bt_compressor_sparse_code)
|
||||
*(.compressor_sparse_code)
|
||||
*(.compressor_sparse_const)
|
||||
|
||||
*(.bt_limiter_sparse_const)
|
||||
*(.bt_limiter_sparse_code)
|
||||
*(.limiter_sparse_code)
|
||||
*(.limiter_sparse_const)
|
||||
|
||||
*(.bt_crossOver_sparse_const)
|
||||
*(.bt_crossOver_sparse_code)
|
||||
*(.crossOver_sparse_code)
|
||||
*(.crossOver_sparse_const)
|
||||
|
||||
*(.lib_pitchshift_code)
|
||||
*(.lib_pitchshift_const)
|
||||
|
||||
. = ALIGN(4);
|
||||
_audio_decoder_begin = .;
|
||||
PROVIDE(audio_decoder_begin = .);
|
||||
*(.audio_decoder)
|
||||
_audio_decoder_end = .;
|
||||
PROVIDE(audio_decoder_end = .);
|
||||
|
||||
_audio_encoder_begin = .;
|
||||
PROVIDE(audio_encoder_begin = .);
|
||||
*(.audio_encoder)
|
||||
_audio_encoder_end = .;
|
||||
PROVIDE(audio_encoder_end = .);
|
||||
|
||||
_audio_package_begin = .;
|
||||
PROVIDE(audio_package_begin = .);
|
||||
*(.audio_package)
|
||||
_audio_package_end = .;
|
||||
PROVIDE(audio_package_end = .);
|
||||
|
||||
_audio_dev_begin = .;
|
||||
PROVIDE(audio_dev_begin = .);
|
||||
*(.audio_device)
|
||||
_audio_dev_end = .;
|
||||
PROVIDE(audio_dev_end = .);
|
||||
|
||||
_audio_hwaccel_begin = .;
|
||||
PROVIDE(audio_hwaccel_begin = .);
|
||||
*(.audio_hwaccel)
|
||||
_audio_hwaccel_end = .;
|
||||
PROVIDE(audio_hwaccel_end = .);
|
||||
|
||||
. = ALIGN(4);
|
||||
media_code_begin = .;
|
||||
*(.media.*.text)
|
||||
. = ALIGN(4);
|
||||
|
||||
*(.compressor_code)
|
||||
*(.compressor_const)
|
||||
*(.bt_compressor_const)
|
||||
*(.bt_compressor_code)
|
||||
|
||||
*(.crossOver_code)
|
||||
*(.crossOver_const)
|
||||
*(.bt_crossOver_const)
|
||||
*(.bt_crossOver_code)
|
||||
|
||||
*(.limiter_code)
|
||||
*(.limiter_const)
|
||||
*(.bt_limiter_const)
|
||||
*(.bt_limiter_code)
|
||||
|
||||
*(.lc3_decoder_const)
|
||||
*(.lc3_decoder_code)
|
||||
*(.lc3_dec_const)
|
||||
*(.lc3_dec_code)
|
||||
|
||||
*(.audio_vbass_code)
|
||||
*(.audio_vbass_const)
|
||||
*(.vbss_code)
|
||||
*(.vbss_const)
|
||||
*(.vbss_sparse_code)
|
||||
*(.vbss_sparse_const)
|
||||
|
||||
|
||||
. = ALIGN(4);
|
||||
*(.pSOUND360TD_cal_sparse_code)
|
||||
|
||||
. = ALIGN(4);
|
||||
*(.g729_code)
|
||||
*(.g729_const)
|
||||
*(.cvsd_code)
|
||||
*(.cvsd_const)
|
||||
|
||||
*(.media.audio*)
|
||||
*(.media.mixer*)
|
||||
*(.media.media*)
|
||||
|
||||
*( .lib_wtg_dec_code )
|
||||
*( .lib_wtg_dec_const)
|
||||
|
||||
*(.audio_resample_code)
|
||||
*(.audio_resample_const)
|
||||
|
||||
*(.resample_fastcal_sparse_code)
|
||||
*(.resample_fastcal_code)
|
||||
*(.resample_fastcal_const)
|
||||
|
||||
audio_sync_code_begin = .;
|
||||
*(.audio_sync_code)
|
||||
audio_sync_code_end = .;
|
||||
|
||||
. = ALIGN(4);
|
||||
|
||||
media_code_end = .;
|
||||
. = ALIGN(4);
|
||||
media_code_size = media_code_end - media_code_begin;
|
||||
|
||||
. = ALIGN(4);
|
||||
media_text_end = .;
|
||||
} > code0
|
||||
|
||||
|
||||
.data_code ALIGN(32):
|
||||
{
|
||||
*(.media.aec.text)
|
||||
} > ram0
|
||||
}
|
||||
|
||||
27
include_lib/media/media_new/media/cpu/br28/audio_lib_data.ld
Normal file
27
include_lib/media/media_new/media/cpu/br28/audio_lib_data.ld
Normal file
@ -0,0 +1,27 @@
|
||||
|
||||
. = ALIGN(4);
|
||||
audio_sync_data_begin = .;
|
||||
*(.audio_sync_data)
|
||||
audio_sync_data_end = .;
|
||||
. = ALIGN(4);
|
||||
|
||||
*(.sbc_data)
|
||||
*(.msbc_data)
|
||||
*(.cvsd_data)
|
||||
*(.aac_data)
|
||||
*(.sbc_eng_data)
|
||||
*(.bt_audioplc_data)
|
||||
*(.lc3_decoder_data)
|
||||
*(.lc3_dec_data)
|
||||
*(.wtgv2_data)
|
||||
*(.wtgv2dec_data)
|
||||
|
||||
*(.anc_data)
|
||||
*(.anc_core_data)
|
||||
*(.anc_user_data)
|
||||
*(.anc_box_data)
|
||||
*(.anc_btspp_data)
|
||||
|
||||
*(.sms_data)
|
||||
*(.audio_track_data)
|
||||
*(.audio_adc_data)
|
||||
@ -0,0 +1,14 @@
|
||||
#ifndef _AUDIO_OUTPUT_DAC_H_
|
||||
#define _AUDIO_OUTPUT_DAC_H_
|
||||
|
||||
#include "typedef.h"
|
||||
|
||||
#define TYPE_DAC_AGAIN (0x01)
|
||||
#define TYPE_DAC_DGAIN (0x02)
|
||||
|
||||
extern int audio_dac_vol_set(u8 type, u32 ch, u16 gain, u8 fade_en);
|
||||
extern int audio_dac_vol_mute(u8 mute, u8 fade);
|
||||
extern int audio_dac_vol_mute_lock(u8 lock);
|
||||
|
||||
#endif // _AUDIO_OUTPUT_DAC_H_
|
||||
|
||||
139
include_lib/media/media_new/media/drc_api.h
Normal file
139
include_lib/media/media_new/media/drc_api.h
Normal file
@ -0,0 +1,139 @@
|
||||
#ifndef DRC_API_H
|
||||
#define DRC_API_H
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#define AT_DRC(x)
|
||||
#define AT_DRC_CODE
|
||||
#define AT_DRC_CONST
|
||||
#define AT_DRC_SPARSE_CODE
|
||||
#define AT_DRC_SPARSE_CONST
|
||||
|
||||
#else
|
||||
#define AT_DRC(x) __attribute((section(#x)))
|
||||
#define AT_DRC_CODE AT_DRC(.drc_code)
|
||||
#define AT_DRC_CONST AT_DRC(.drc_const)
|
||||
#define AT_DRC_SPARSE_CODE AT_DRC(.drc_sparse_code)
|
||||
#define AT_DRC_SPARSE_CONST AT_DRC(.drc_sparse_const)
|
||||
#endif
|
||||
|
||||
|
||||
enum {
|
||||
DATA_IN_SHORT = 0, //输入数据类型,输入short时,输出不能为int
|
||||
DATA_IN_INT,
|
||||
};
|
||||
enum {
|
||||
DATA_OUT_SHORT = 0, //输出数据类型,输入short时,输出不能为int
|
||||
DATA_OUT_INT
|
||||
};
|
||||
|
||||
enum {
|
||||
PEAK = 0, //算法类型
|
||||
RMS
|
||||
};
|
||||
|
||||
enum {
|
||||
PERPOINT = 0, //mode 模式
|
||||
TWOPOINT
|
||||
};
|
||||
|
||||
typedef struct _DrcParam {
|
||||
/*
|
||||
int *attackTime; //启动时间
|
||||
int *releaseTime; //释放时间
|
||||
float *threshold; //阈值{x1,y1,x2,y2} 最多5组十个数据
|
||||
int *ThresholdNum; //阈值的组数
|
||||
int *rmsTime; // rms时间 algorithm为RMS有效
|
||||
float *InputGain; // 输入增益(db)
|
||||
float *OutputGain; // 输出数据增益(db)
|
||||
unsigned char algorithm; // PEAK或者RMS
|
||||
unsigned char mode; // 模式
|
||||
unsigned char intype; // 输入数据类型
|
||||
unsigned char outtype; // 输出数据类型
|
||||
*/
|
||||
int channel;
|
||||
int sampleRate;
|
||||
int attackTime; //启动时间
|
||||
int releaseTime; //释放时间
|
||||
float *threshold; //阈值{x1,y1,x2,y2} 最多5组十个数据
|
||||
int ThresholdNum; //阈值的组数
|
||||
int rmsTime; // rms时间 algorithm为RMS有效
|
||||
float InputGain; // 输入增益(db)
|
||||
float OutputGain; // 输出数据增益(db)
|
||||
unsigned char algorithm; // PEAK或者RMS
|
||||
unsigned char mode; // 模式
|
||||
unsigned char intype; // 输入数据类型
|
||||
unsigned char outtype; // 输出数据类型
|
||||
int IndataInc; // 输入数据同个通道下个点的步进 例如左右左右 步进为2
|
||||
int OutdataInc; // 输出数据同个通道下个点的步进 例如左右左右 步进为2
|
||||
} DrcParam;
|
||||
|
||||
//int GetDrcBuf(int algorithm, int *rmsTime, int channel, int sampleRate);
|
||||
int GetDrcBuf(DrcParam *param); // bufsize 与 algorithm,rmsTime channel、 sampleRate有关
|
||||
//void DrcInit(void *WorkBuf, DrcParam *param, int channel, int sampleRate);
|
||||
void DrcInit(void *WorkBuf, DrcParam *param);
|
||||
void DrcUpdate(void *WorkBuf, DrcParam *param);
|
||||
int DrcRun(void *WorkBuf, void *indata, void *outdata, int per_channel_npoint);
|
||||
/* InputGain 输入数据放大或者缩小的db数(正数放大,负数缩小) */
|
||||
// inputgain 配2,表示总体增加2dB
|
||||
/* OutputGain 输出数据放大或者缩小的db数(正数放大,负数缩小) */
|
||||
#if 0
|
||||
int GetDrcBuf(int algorithm, int *rmsTime, int channel, int sampleRate);
|
||||
获取buf大小
|
||||
参数说明:
|
||||
algorithm:算法类型,PEAK或者RMS
|
||||
rmsTime:
|
||||
rms时间ms,算法类型为RMS时有效
|
||||
channel: 通道数
|
||||
sampleRate:
|
||||
采样率
|
||||
|
||||
void DrcInit(void *WorkBuf, int *attackTime, int *releaseTime, float *threshold, int *ThresholdNum, int *rmsTime, int channel, int sampleRate, int algorithm, int mode, int intype, int outtype);
|
||||
初始化
|
||||
参数说明:
|
||||
WorkBuf:
|
||||
运行buf
|
||||
attackTime:
|
||||
启动时间ms
|
||||
releaseTime:
|
||||
释放时间ms
|
||||
threshold:
|
||||
信号输入与对应的输出[in1, out1, in2, out2 ***排列] 最多5组数据, 3个阈值,4段
|
||||
ThresholdNum:
|
||||
信号输入与对应的输出组数
|
||||
rmsTime:
|
||||
rms时间ms
|
||||
channel:
|
||||
通道
|
||||
sampleRate:采样率
|
||||
algorithm:算法类型
|
||||
mode:模式
|
||||
intype:输入数据类型,DATA_IN_SHORT或者DATA_IN_INT
|
||||
outtype:
|
||||
输出数据类型,DATA_OUT_SHOR或者DATA_OUT_INT;若输入数据类型为DATA_IN_SHORT,输出类型只能设置为DATA_OUT_SHOR
|
||||
|
||||
void DrcUpdate(void *WorkBuf, int *attackTime, int *releaseTime, float *threshold, int *ThresholdNum, int channel, int sampleRate);
|
||||
更新参数:使用rms算法时,当rmsTime fs变化时因为buf会产生变化,只能初始化更新
|
||||
参数说明:
|
||||
WorkBuf:
|
||||
运行buf
|
||||
attackTime:
|
||||
启动时间ms
|
||||
releaseTime:
|
||||
释放时间ms
|
||||
threshold:
|
||||
信号输入与对应的输出[in1, out1, in2, out2 ***排列] 最多5组数据, 3个阈值,4段
|
||||
ThresholdNum:
|
||||
信号输入与对应的输出组数
|
||||
|
||||
int DrcRun(void *WorkBuf, void *indata, void *outdata, int per_channel_npoint);
|
||||
运行:输入输出数据类型,要跟初始化配置的数据类型对应
|
||||
WorkBuf:
|
||||
运行buf
|
||||
indata:输入数据
|
||||
outdata:输出数据
|
||||
per_channel_npoint:每个通道的样点数
|
||||
#endif
|
||||
|
||||
#endif // !DRC_API_H
|
||||
|
||||
236
include_lib/media/media_new/media/effectrs_sync.h
Normal file
236
include_lib/media/media_new/media/effectrs_sync.h
Normal file
@ -0,0 +1,236 @@
|
||||
#ifndef EFFECTRS_SYNC_H
|
||||
#define EFFECTRS_SYNC_H
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "generic/list.h"
|
||||
|
||||
#define WL_PROTOCOL_RTP 0
|
||||
#define WL_PROTOCOL_SCO 1
|
||||
#define WL_PROTOCOL_FILE 2
|
||||
#define WL_PROTOCOL_JL_TWS 3
|
||||
|
||||
#define SYNC_ERR_NONE 0
|
||||
#define SYNC_ERR_PLAY_REJECTED 1
|
||||
#define SYNC_ERR_PAUSE 2
|
||||
#define SYNC_ERR_DISCARD_PKT 3
|
||||
#define SYNC_ERR_PLAY_PREPARE 4
|
||||
#define SYNC_ERR_NULL_PKT 5
|
||||
#define SYNC_ERR_GRAB_AUDIO_STREAM 6
|
||||
#define SYNC_ERR_DEC_RESET 7
|
||||
enum {
|
||||
SYNC_DAC_CTL = 1,
|
||||
SYNC_GET_PCM_TOTAL,
|
||||
SYNC_GET_SRC_IN_LEN,
|
||||
SYNC_GET_SRC_STATE,
|
||||
SYNC_SET_PLAY_O_POINT,
|
||||
SYNC_WITE_DAC_MUTE_DATE,
|
||||
SET_LOCAL_US_TIME,
|
||||
SET_SYNC_RESET,
|
||||
SYNC_SWITCH_N_CH,
|
||||
};
|
||||
struct audio_packet_buffer {
|
||||
u8 noblock;
|
||||
u8 state;
|
||||
u16 timeout;
|
||||
u32 slot_time;
|
||||
u32 len;
|
||||
u32 baddr;
|
||||
};
|
||||
struct audio_packet_stats {
|
||||
u32 total_size;
|
||||
u32 data_size;
|
||||
u32 remain_size;
|
||||
u8 ch;
|
||||
u8 grab_audio_stream_info_num;
|
||||
};
|
||||
typedef struct _SYNC_POINTER_ {
|
||||
volatile int *src_in_len;
|
||||
volatile int *set_sr_in;
|
||||
volatile int *set_sr_out;
|
||||
volatile int *more_less_points;
|
||||
|
||||
volatile int *play_point;
|
||||
volatile int *fake_n_points;
|
||||
} CPUSYNC_POINTERS;
|
||||
|
||||
/*
|
||||
* 播放动态src配置,start为配置一次变点
|
||||
*/
|
||||
struct audio_pcm_src {
|
||||
u8 convert; //启动转换
|
||||
u8 resample;//设置为变采样
|
||||
u16 ratio_i; //转换输入
|
||||
u16 ratio_o; //转换输出
|
||||
};
|
||||
|
||||
/*
|
||||
* 同步需要的DAC协定启动配置
|
||||
*/
|
||||
struct audio_dac_ctl {
|
||||
u8 agreement; //
|
||||
u8 on; //启动/暂停
|
||||
// u8 time_unit; //时间单位(0 - us, 1 - ms, 2 - s)
|
||||
u32 pre_time;
|
||||
u32 time; //时间点(us)
|
||||
};
|
||||
// *INDENT-OFF*
|
||||
struct sync_ops_t {
|
||||
void *(*open)(void);
|
||||
void (*set_handler)(void *, void *priv,
|
||||
void (*handler)(void *, int *, int));
|
||||
u32 (*time)(u8 type, u32 time,u32 *pre_time);
|
||||
int (*send)(void *, void *buf, u32 len);
|
||||
int (*master)(u8 type);
|
||||
u8 (*online)(u8);
|
||||
void (*role_lock)(void *, u8);
|
||||
void (*close)(void *);
|
||||
void *(*audio_sync_open)(void *empty_priv,void (*empty_handler)(void *, u8),u8 protocol,u16 ch,u16 sr,int (*sync_output)(void *priv, void *data, int len),void*);
|
||||
int (*audio_sync_close)(void *sync);
|
||||
int (*audio_sync_run)(void *_sync,void *buf, int points_per_channel);
|
||||
int (*audio_sync_set_samplerate)(void *sync,int sr_in,int sr_out);
|
||||
int (*audio_sync_control)(void* _priv,int cmd,u32 arg);
|
||||
};
|
||||
|
||||
struct audio_sync_parm {
|
||||
u8 channel;
|
||||
u8 top_percent; //上限比例
|
||||
u8 start_percent; //启动比例限值
|
||||
u8 bottom_percent; //下限比例
|
||||
u8 protocol; //音频包含协议
|
||||
u32 buffer_size;
|
||||
u8 sync_time;
|
||||
const struct sync_ops_t *ops;
|
||||
void *audio_dev;
|
||||
int (*sync_output)(void *priv, void *data, int len);
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
extern void *audio_decoder_sync_open(struct audio_decoder *dec, struct audio_sync_parm *sync_parm);
|
||||
extern void audio_decoder_sync_close(void *c);
|
||||
extern int audio_decodr_sync_start(void *c, struct audio_packet_stats *stats, struct audio_packet_buffer *pkt);
|
||||
extern int audio_decoder_sync_run(void *c, void *buf, int len);
|
||||
extern int audio_decoder_sync_do(void *c, s16 *buf, int len);
|
||||
extern int audio_sync_reset(void *c);
|
||||
int audio_sync_set_remain_len(void *c, int len);
|
||||
|
||||
#if (defined CONFIG_CPU_BR26 || \
|
||||
defined CONFIG_CPU_BR23 || \
|
||||
defined CONFIG_CPU_BR25 || \
|
||||
defined CONFIG_CPU_BR30 || \
|
||||
defined CONFIG_CPU_BR34 || \
|
||||
defined CONFIG_CPU_BR36 || \
|
||||
defined CONFIG_CPU_BR28 || \
|
||||
defined CONFIG_CPU_BR27)
|
||||
/*
|
||||
* BR26同步
|
||||
*/
|
||||
#define SYNC_ERR_NONE 0
|
||||
#define SYNC_ERR_DEC_NOT_ALLOWED 1
|
||||
#define SYNC_ERR_TIMEOUT 2
|
||||
#define SYNC_ERR_STREAM_PASS 3
|
||||
#define SYNC_ERR_STREAM_END 4
|
||||
#define SYNC_ERR_PREPARE 5
|
||||
#define SYNC_ERR_ALIGNED_AND_PASS 6
|
||||
#define SYNC_ERR_STREAM_RESET 7
|
||||
|
||||
/***************** the step mean to get more or less (sample_rate/step) points/sencond ********************/
|
||||
#define SRC_DEC_STEP 2 //step to speed down
|
||||
#define SRC_INC_STEP 2 // step to speed up
|
||||
|
||||
#define SRC_POINT_AMPLIPY 5
|
||||
|
||||
#define AUDIO_SYNC_TARGET_DAC 0
|
||||
#define AUDIO_SYNC_EXTERNAL_DAC 1
|
||||
|
||||
#define RX_DELAY_NULL 0
|
||||
#define RX_DELAY_UP 1
|
||||
#define RX_DELAY_DOWN 2
|
||||
|
||||
struct rt_stream_info {
|
||||
u8 noblock;
|
||||
u8 rx_delay;
|
||||
u16 seqn;
|
||||
s16 distance_time;
|
||||
u32 data_len;
|
||||
u32 remain_len;
|
||||
void *baddr;
|
||||
int len;
|
||||
};
|
||||
|
||||
struct file_sync_info {
|
||||
u8 tws_together;
|
||||
u32 together_time;
|
||||
};
|
||||
|
||||
// *INDENT-OFF*
|
||||
struct audio_tws_conn_ops {
|
||||
void *(*open)(void);
|
||||
void (*set_handler)(void *, void *priv,
|
||||
void (*handler)(void *, int *, int));
|
||||
u32 (*time)(u8 type, u32 time, u32 *pre_time);
|
||||
int (*send)(void *, void *buf, u32 len);
|
||||
int (*master)(u8 type);
|
||||
u8 (*online)(u8);
|
||||
void (*close)(void *);
|
||||
};
|
||||
|
||||
struct audio_wireless_sync_info {
|
||||
u8 channel;
|
||||
u8 target;
|
||||
u8 protocol; //音频同步协议类型
|
||||
u8 reset_enable;
|
||||
u16 sample_rate;
|
||||
u16 output_rate;
|
||||
u32 data_top; //数据上限
|
||||
u32 data_bottom; //数据下限
|
||||
u32 begin_size; //数据启动线
|
||||
int time_before_dec;
|
||||
u32 tws_together_time;
|
||||
const struct audio_decoder_ops *dec_ops;
|
||||
void *decoder;
|
||||
void *dev;
|
||||
const struct audio_tws_conn_ops *tws_ops;
|
||||
void *output_priv;
|
||||
int (*output_handler)(void *priv, void *data, int len);
|
||||
};
|
||||
// *INDENT-ON*
|
||||
|
||||
void *audio_wireless_sync_open(struct audio_wireless_sync_info *info);
|
||||
|
||||
int audio_wireless_sync_add_dev(void *c, struct audio_wireless_sync_info *info);
|
||||
|
||||
int audio_wireless_file_sync_probe(void *c, struct file_sync_info *info);
|
||||
|
||||
int audio_wireless_sync_probe(void *c, struct rt_stream_info *info);
|
||||
|
||||
void audio_wireless_sync_info_init(void *c, u32 sample_rate, u32 output_rate, u8 channel);
|
||||
|
||||
int audio_sync_set_tws_together(void *c, u8 together, u32 together_time);
|
||||
|
||||
int audio_output_to_wireless_sync(void *c, s16 *data, int len);
|
||||
|
||||
int audio_wireless_sync_after_dec(void *c, s16 *data, int len);
|
||||
|
||||
int audio_wireless_sync_update_pos(void *c, void *data, int len);
|
||||
|
||||
int audio_wireless_sync_get_rate(void *c, u16 *input_rate, u16 *output_rate);
|
||||
|
||||
int audio_wireless_sync_write(void *c, s16 *data, int len);
|
||||
|
||||
int audio_wireless_sync_info_store(void *c, struct rt_stream_info *info);
|
||||
|
||||
int audio_wireless_sync_stop(void *c);
|
||||
|
||||
int audio_wireless_sync_reset(void *c);
|
||||
|
||||
int audio_wireless_sync_suspend(void *c);
|
||||
|
||||
void audio_wireless_sync_close(void *c);
|
||||
|
||||
#endif
|
||||
/*
|
||||
#if (defined CONFIG_CPU_BR26 || \
|
||||
(defined CONFIG_CPU_BR23 || \
|
||||
defined CONFIG_CPU_BR25)
|
||||
*/
|
||||
#endif
|
||||
71
include_lib/media/media_new/media/file_decoder.h
Normal file
71
include_lib/media/media_new/media/file_decoder.h
Normal file
@ -0,0 +1,71 @@
|
||||
#ifndef FILE_DECODER_H
|
||||
#define FILE_DECODER_H
|
||||
|
||||
|
||||
#include "media/includes.h"
|
||||
|
||||
enum {
|
||||
FILE_DEC_STATUS_STOP = 0, // 解码停止
|
||||
FILE_DEC_STATUS_PLAY, // 正在解码
|
||||
FILE_DEC_STATUS_PAUSE, // 解码暂停
|
||||
FILE_DEC_STATUS_WAIT_PAUSE,
|
||||
FILE_DEC_STATUS_WAIT_PLAY,
|
||||
FILE_DEC_STATUS_PAUSE_SUCCESS,
|
||||
};
|
||||
|
||||
|
||||
struct file_decoder {
|
||||
u8 ch_num; // 声道数
|
||||
u8 output_ch_num; // 输出声道数
|
||||
u8 status; // 解码状态
|
||||
u8 dec_no_out_sound; // 解码不直接输出声音(用于TWS转发)
|
||||
u8 tmp_pause; // 被其他解码打断,临时暂停
|
||||
u32 wait_pause;
|
||||
u8 remain;
|
||||
u16 resume_tmr_id;
|
||||
u16 sample_rate;
|
||||
u32 coding_type;
|
||||
u32 dec_total_time; // 总共能播放多长时间
|
||||
u32 dec_cur_time; // 当前播放时间
|
||||
u32 once_out_cnt; // 解码一次的输出统计
|
||||
enum audio_channel ch_type; // 输出类型
|
||||
struct audio_decoder decoder; // 解码句柄
|
||||
int (*output_handler)(struct file_decoder *dec, s16 *data, int len);
|
||||
void *tws_sync;
|
||||
s16 fade_step;
|
||||
s16 fade_value;
|
||||
};
|
||||
|
||||
int file_decoder_open(struct file_decoder *dec,
|
||||
const struct audio_dec_input *input,
|
||||
struct audio_decoder_task *decode_task,
|
||||
struct audio_dec_breakpoint *bp,
|
||||
u8 pick);
|
||||
|
||||
int frame_decoder_open(struct file_decoder *dec,
|
||||
const struct audio_dec_input *input,
|
||||
struct audio_decoder_task *decode_task);
|
||||
|
||||
void file_decoder_close(struct file_decoder *dec);
|
||||
|
||||
void file_decoder_set_output_channel(struct file_decoder *dec);
|
||||
|
||||
void file_decoder_set_event_handler(struct file_decoder *dec,
|
||||
void (*handler)(struct audio_decoder *, int, int *), u32 maigc);
|
||||
|
||||
bool file_decoder_is_stop(struct file_decoder *file_dec);
|
||||
bool file_decoder_is_play(struct file_decoder *file_dec);
|
||||
bool file_decoder_is_pause(struct file_decoder *file_dec);
|
||||
int file_decoder_pp(struct file_decoder *file_dec);
|
||||
int file_decoder_FF(struct file_decoder *file_dec, int step);
|
||||
int file_decoder_FR(struct file_decoder *file_dec, int step);
|
||||
int file_decoder_get_breakpoint(struct file_decoder *file_dec, struct audio_dec_breakpoint *bp);
|
||||
int file_decoder_get_total_time(struct file_decoder *file_dec);
|
||||
int file_decoder_get_cur_time(struct file_decoder *file_dec);
|
||||
int file_decoder_get_decoder_type(struct file_decoder *file_dec);
|
||||
void file_decoder_set_tws_sync_enable(struct file_decoder *dec, void *sync);
|
||||
void file_decoder_mark_tws_sync_data(struct file_decoder *dec, u16 seqn);
|
||||
void file_decoder_tws_sync_restart(struct file_decoder *dec);
|
||||
|
||||
#endif /*FILE_DECODER_H*/
|
||||
|
||||
62
include_lib/media/media_new/media/hw_fft.h
Normal file
62
include_lib/media/media_new/media/hw_fft.h
Normal file
@ -0,0 +1,62 @@
|
||||
#ifndef HW_FFT_H
|
||||
#define HW_FFT_H
|
||||
|
||||
typedef enum {
|
||||
FFT_V3 = 3, //br23/br25__br30/br34/br36__WL80.
|
||||
FFT_EXT = 4, //br27/br28__WL82. 扩展模式.FFT硬件模块支持非2的指数次幂点数.
|
||||
} _FFT_VERSION_;
|
||||
|
||||
typedef struct {
|
||||
unsigned int fft_config;
|
||||
const int *in;
|
||||
int *out;
|
||||
} pi32v2_hw_fft_ctx;
|
||||
|
||||
/*********************************************************************
|
||||
* Make_FFT_Config
|
||||
* Description: 根据配置生成 FFTconfig
|
||||
* Arguments :N 运算数据量(min:64);log2N 运算数据量的对数值
|
||||
same_addr 输入输出是否同一个地址,是则写1,否则写0
|
||||
is_ifft IFFT运算写1,FFT运算写0
|
||||
is_real 实数运算写1, 复数运算写0
|
||||
* Return :FFTN_CON 写入FFT寄存器
|
||||
* Note(s) : None.
|
||||
*********************************************************************/
|
||||
unsigned int make_fft_config(int N, int log2N, int same_addr, int is_forward, int is_real);
|
||||
/*********************************************************************
|
||||
* _fixfft_wrap
|
||||
* Description: fft/ifft运算函数
|
||||
* Arguments :ctx fft数据结构;
|
||||
in 输入地址
|
||||
out 输出地址
|
||||
* Return : void
|
||||
* Note(s) : None.
|
||||
*********************************************************************/
|
||||
void _fixfft_wrap(pi32v2_hw_fft_ctx *ctx, const int *in, int *out);
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* hw_fft_config
|
||||
* Description: 根据配置生成 FFT_config
|
||||
* Arguments :N 运算数据量;
|
||||
log2N 运算数据量的对数值
|
||||
is_same_addr 输入输出是否同一个地址,0:否,1:是
|
||||
is_ifft 运算类型 0:FFT运算, 1:IFFT运算
|
||||
is_real 运算数据的类型 1:实数, 0:复数
|
||||
* Return :ConfgPars 写入FFT寄存器
|
||||
* Note(s) : None.
|
||||
*********************************************************************/
|
||||
extern unsigned int hw_fft_config(int N, int log2N, int same_addr, int is_ifft, int is_real);
|
||||
|
||||
/*********************************************************************
|
||||
* hw_fft_run
|
||||
* Description: fft/ifft运算函数
|
||||
* Arguments :fft_config FFT运算配置寄存器值
|
||||
in 输入数据地址
|
||||
out 输出数据地址
|
||||
* Return : void
|
||||
* Note(s) : None.
|
||||
*********************************************************************/
|
||||
extern void hw_fft_run(unsigned int cfg, const int *in, int *out);
|
||||
|
||||
#endif/*HW_FFT_H*/
|
||||
62
include_lib/media/media_new/media/includes.h
Normal file
62
include_lib/media/media_new/media/includes.h
Normal file
@ -0,0 +1,62 @@
|
||||
/*****************************************************************
|
||||
>file name : include_lib/media/includes.h
|
||||
>author : lichao
|
||||
>create time : Mon 26 Nov 2018 07:47:14 PM CST
|
||||
*****************************************************************/
|
||||
#ifndef __MEDIA_INCLUDES_H__
|
||||
#define __MEDIA_INCLUDES_H__
|
||||
|
||||
#ifdef CONFIG_AUDIO_ONCHIP
|
||||
|
||||
#include "media/audio_decoder.h"
|
||||
#include "media/audio_encoder.h"
|
||||
#include "media/mixer.h"
|
||||
#include "media/automute.h"
|
||||
#include "media/audio_stream.h"
|
||||
|
||||
#include "asm/cpu_includes.h"
|
||||
#include "application/eq_func_define.h"
|
||||
/*
|
||||
#include "asm/dac.h"
|
||||
#include "asm/audio_adc.h"
|
||||
#if (defined CONFIG_CPU_BR26 || \
|
||||
defined CONFIG_CPU_BR23 || \
|
||||
defined CONFIG_CPU_BR21 || \
|
||||
defined CONFIG_CPU_BR25 || \
|
||||
defined CONFIG_CPU_BR30)
|
||||
#include "asm/audio_src.h"
|
||||
#endif
|
||||
*/
|
||||
|
||||
/*encoder init*/
|
||||
extern int msbc_encoder_init();
|
||||
extern int cvsd_encoder_init();
|
||||
extern int opus_encoder_preinit();
|
||||
extern int speex_encoder_preinit();
|
||||
|
||||
/*decoder init*/
|
||||
extern int pcm_decoder_enable();
|
||||
extern int cvsd_decoder_init();
|
||||
extern int msbc_decoder_init();
|
||||
extern int g729_decoder_init();
|
||||
extern int sbc_decoder_init();
|
||||
extern int mp3_decoder_init();
|
||||
extern int wma_decoder_init();
|
||||
extern int wav_decoder_init();
|
||||
extern int mty_decoder_init();
|
||||
extern int flac_decoder_init();
|
||||
extern int ape_decoder_init();
|
||||
extern int m4a_decoder_init();
|
||||
extern int amr_decoder_init();
|
||||
extern int dts_decoder_init();
|
||||
extern int mp3pick_decoder_init();
|
||||
extern int wmapick_decoder_init();
|
||||
extern int aac_decoder_init();
|
||||
|
||||
#if defined CONFIG_CPU_BR23 || \
|
||||
defined CONFIG_CPU_BR25
|
||||
#include "asm/audio_spdif.h"
|
||||
#endif
|
||||
|
||||
#endif/*CONFIG_AUDIO_ONCHIP*/
|
||||
#endif
|
||||
@ -0,0 +1,9 @@
|
||||
#ifndef LIMITER_NOISEGATE_API_H
|
||||
#define LIMITER_NOISEGATE_API_H
|
||||
|
||||
extern int need_limiter_noiseGate_buf(int x);
|
||||
extern void limiter_noiseGate_init(void *work_buf, int limiter_attfactor, int limiter_relfactor, int noiseGate_attfactor, int noiseGate_relfactor, int limiter_threshold, int noiseGate_threshold, int noiseGate_low_thr_gain, int sample_rate, int channel);
|
||||
extern int limiter_noiseGate_run(void *work_buf, void *in_buf, void *out_buf, int point_per_channel);
|
||||
|
||||
#endif // !LIMITER_NOISEGATE_API_H
|
||||
|
||||
161
include_lib/media/media_new/media/mixer.h
Normal file
161
include_lib/media/media_new/media/mixer.h
Normal file
@ -0,0 +1,161 @@
|
||||
#ifndef AUDIO_MIXER_H
|
||||
#define AUDIO_MIXER_H
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "generic/list.h"
|
||||
|
||||
#define MIXER_EXT_MAX_NUM 4 // 扩展输出最大通道
|
||||
#define PCM_0dB_VALUE 16384
|
||||
enum {
|
||||
MIXER_EVENT_CH_OPEN,
|
||||
MIXER_EVENT_CH_CLOSE,
|
||||
MIXER_EVENT_CH_RESET,
|
||||
};
|
||||
#define BIT16_MODE 0
|
||||
#define BIT24_MODE BIT(0)
|
||||
#define BIT32_MODE BIT(1)
|
||||
|
||||
struct audio_mixer;
|
||||
|
||||
struct audio_mix_handler {
|
||||
int (*mix_probe)(struct audio_mixer *);
|
||||
int (*mix_output)(struct audio_mixer *, s16 *, u16);
|
||||
#if MIXER_EXT_MAX_NUM
|
||||
/* 扩展输出回调接口
|
||||
* 最后一个参数代表当前输出的通道序号,0到ext_output_num-1;
|
||||
* 扩展输出不检测返回值,每次输出的长度与mix_output的返回值相同;
|
||||
*/
|
||||
int (*mix_output_ext)(struct audio_mixer *, s16 *, u16, u8);
|
||||
#endif
|
||||
int (*mix_post)(struct audio_mixer *);
|
||||
};
|
||||
|
||||
struct audio_mixer {
|
||||
struct list_head head;
|
||||
s16 *output;
|
||||
u16 points;
|
||||
u16 remain_points;
|
||||
u32 sample_position : 20;
|
||||
#if MIXER_EXT_MAX_NUM
|
||||
int ext_output_addr[MIXER_EXT_MAX_NUM]; // 扩展输出buf地址,每个buf的长度与point相同
|
||||
u8 ext_output_num; // 扩展输出通道总数
|
||||
#endif
|
||||
const struct audio_mix_handler *mix_handler;
|
||||
void (*evt_handler)(struct audio_mixer *, int);
|
||||
volatile u8 active;
|
||||
volatile u8 bit_mode_en;
|
||||
volatile u8 point_len;
|
||||
};
|
||||
|
||||
struct audio_pcm_edit {
|
||||
u8 hide : 1;
|
||||
u8 highlight : 1;
|
||||
u8 state;
|
||||
u8 ch_num;
|
||||
u8 fade_chs;
|
||||
s16 fade_step;
|
||||
s16 fade_volume;
|
||||
s16 volume;
|
||||
};
|
||||
|
||||
struct audio_mixer_ch {
|
||||
u8 start;
|
||||
u8 pause;
|
||||
u8 open;
|
||||
u32 no_wait : 1; // 不等待有数
|
||||
u32 lose : 1; // 丢数标记
|
||||
u32 need_resume : 1;
|
||||
u8 start_by_position;
|
||||
u16 offset;
|
||||
u32 sample_rate;
|
||||
u16 lose_time; // 超过该时间还没有数据,则以为可以丢数。no_wait置1有效
|
||||
unsigned long lose_limit_time; // 丢数超时中间运算变量
|
||||
struct list_head entry;
|
||||
struct audio_mixer *mixer;
|
||||
#if MIXER_EXT_MAX_NUM
|
||||
u32 ext_out_mask; // 标记该通道输出的扩展通道,如输出到第0和第2个,ext_flag |= BTI(0)|BIT(2)
|
||||
u8 main_out_dis; // 不输出到主通道
|
||||
#endif
|
||||
u32 slience_samples;
|
||||
u32 mix_timeout;
|
||||
u32 starting_position : 20;
|
||||
void *priv;
|
||||
void (*event_handler)(void *priv, int event);
|
||||
void *lose_priv;
|
||||
void (*lose_callback)(void *lose_priv, int lose_len);
|
||||
void *resume_data;
|
||||
void (*resume_callback)(void *);
|
||||
struct audio_pcm_edit *editor;
|
||||
};
|
||||
|
||||
|
||||
int audio_mixer_open(struct audio_mixer *mixer);
|
||||
|
||||
void audio_mixer_set_handler(struct audio_mixer *, const struct audio_mix_handler *);
|
||||
|
||||
void audio_mixer_set_event_handler(struct audio_mixer *mixer,
|
||||
void (*handler)(struct audio_mixer *, int));
|
||||
|
||||
void audio_mixer_set_output_buf(struct audio_mixer *mixer, s16 *buf, u16 len);
|
||||
|
||||
int audio_mixer_get_sample_rate(struct audio_mixer *mixer);
|
||||
|
||||
int audio_mixer_get_ch_num(struct audio_mixer *mixer);
|
||||
|
||||
int audio_mixer_ch_open(struct audio_mixer_ch *ch, struct audio_mixer *mixer);
|
||||
|
||||
void audio_mixer_ch_set_sample_rate(struct audio_mixer_ch *ch, u32 sample_rate);
|
||||
|
||||
int audio_mixer_reset(struct audio_mixer_ch *ch, struct audio_mixer *mixer);
|
||||
|
||||
int audio_mixer_ch_reset(struct audio_mixer_ch *ch);
|
||||
|
||||
int audio_mixer_ch_write(struct audio_mixer_ch *ch, s16 *data, int len);
|
||||
|
||||
int audio_mixer_ch_close(struct audio_mixer_ch *ch);
|
||||
|
||||
void audio_mixer_ch_pause(struct audio_mixer_ch *ch, u8 pause);
|
||||
|
||||
int audio_mixer_ch_data_len(struct audio_mixer_ch *ch);
|
||||
|
||||
int audio_mixer_ch_add_slience_samples(struct audio_mixer_ch *ch, int samples);
|
||||
|
||||
void audio_mixer_ch_set_resume_handler(struct audio_mixer_ch *ch, void *priv, void (*resume)(void *));
|
||||
|
||||
int audio_mixer_get_active_ch_num(struct audio_mixer *mixer);
|
||||
|
||||
void audio_mixer_ch_set_event_handler(struct audio_mixer_ch *ch, void *priv, void (*handler)(void *, int));
|
||||
|
||||
// 设置通道没数据时不等待(超时直接丢数)
|
||||
void audio_mixer_ch_set_no_wait(struct audio_mixer_ch *ch, void *lose_priv, void (*lose_cb)(void *, int), u8 no_wait, u16 time_ms);
|
||||
|
||||
#if MIXER_EXT_MAX_NUM
|
||||
|
||||
void audio_mixer_set_ext_output_buf(struct audio_mixer *mixer, int *buf_addr_lst, u8 ext_num);
|
||||
|
||||
u32 audio_mixer_ch_get_ext_out_mask(struct audio_mixer_ch *ch);
|
||||
void audio_mixer_ch_set_ext_out_mask(struct audio_mixer_ch *ch, u32 mask);
|
||||
void audio_mixer_ch_main_out_disable(struct audio_mixer_ch *ch, u8 disable);
|
||||
|
||||
#endif /* MIXER_EXT_MAX_NUM */
|
||||
|
||||
|
||||
int audio_mixer_get_output_buf_len(struct audio_mixer *mixer);
|
||||
|
||||
int audio_mixer_ch_set_starting_position(struct audio_mixer_ch *ch, u32 postion, int timeout);
|
||||
|
||||
void audio_mixer_position_correct(struct audio_mixer *ch, int diff);
|
||||
|
||||
u32 audio_mixer_get_input_position(struct audio_mixer *mixer);
|
||||
|
||||
int audio_mixer_get_start_ch_num(struct audio_mixer *mixer);
|
||||
|
||||
void audio_mixer_set_mode(struct audio_mixer *mixer, u8 point_len, u8 bit_mode_en);
|
||||
|
||||
int audio_mixer_ch_sound_highlight(struct audio_mixer_ch *ch, int hide_volume, int fade_frames, u8 data_channels);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -0,0 +1,92 @@
|
||||
|
||||
#ifndef pitchshifer_api_h__
|
||||
#define pitchshifer_api_h__
|
||||
|
||||
#ifndef u8
|
||||
#define u8 unsigned char
|
||||
#endif
|
||||
|
||||
#ifndef u16
|
||||
#define u16 unsigned short
|
||||
#endif
|
||||
|
||||
#ifndef s16
|
||||
#define s16 short
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef u32
|
||||
#define u32 unsigned int
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef s32
|
||||
#define s32 int
|
||||
#endif
|
||||
|
||||
#ifndef s16
|
||||
#define s16 signed short
|
||||
#endif
|
||||
|
||||
/*#define EFFECT_OLD_RECORD 0x01
|
||||
#define EFFECT_MOYIN 0x0*/
|
||||
//#define EFFECT_ROBORT_FLAG 0X04
|
||||
|
||||
enum {
|
||||
EFFECT_PITCH_SHIFT = 0x00,
|
||||
EFFECT_VOICECHANGE_KIN0,
|
||||
EFFECT_VOICECHANGE_KIN1,
|
||||
EFFECT_VOICECHANGE_KIN2,
|
||||
EFFECT_ROBORT,
|
||||
|
||||
EFFECT_AUTOTUNE = 0xfe,
|
||||
EFFECT_FUNC_NULL = 0xff,
|
||||
};
|
||||
|
||||
typedef struct PITCH_SHIFT_PARM_ {
|
||||
u32 sr; //input audio samplerate
|
||||
u32 shiftv; //pitch rate: <100(pitch up), >100(pitch down)
|
||||
u32 effect_v;
|
||||
u32 formant_shift;
|
||||
} PITCH_SHIFT_PARM;
|
||||
|
||||
/******
|
||||
效果配置说明:
|
||||
1.EFFECT_PITCH_SHIFT 移频,变调不变速,init_parm.shiftv调节有效,init_parm.formant_shift调节无效
|
||||
2.EFFECT_VOICECHANGE_KIN0 变声,可以调节不同的 init_parm.shiftv 跟 init_parm.formant_shift ,调出更多的声音效果
|
||||
3.EFFECT_VOICECHANGE_KIN1 变声,同EFFECT_VOICECHANGE_KIN0类似的,但是2者由于运算的不同,会有区别。
|
||||
4.EFFECT_ROBORT 机器音效果,类似 喜马拉雅那样的
|
||||
5.EFFECT_AUTOTUNE 电音效果
|
||||
*******/
|
||||
|
||||
typedef struct _PITCHSHIFTER_DSP_RUNFUNP_ {
|
||||
int *buf;
|
||||
int *inlen;
|
||||
} PITCHSHIFTER_RUNFUNP;
|
||||
|
||||
|
||||
#define C_MAJOR 8192 //c大调
|
||||
#define Cshop_MAJOR 8875//升c大调
|
||||
#define D_MAJOR 9557
|
||||
#define Dshop_MAJOR 10240
|
||||
#define E_MAJOR 10923
|
||||
#define F_MAJOR 11605
|
||||
#define Fshop_MAJOR 12288
|
||||
#define G_MAJOR 12971
|
||||
#define Gshop_MAJOR 13653
|
||||
#define A_MAJOR 14336
|
||||
#define Ashop_MAJOR 15019
|
||||
#define B_MAJOR 15701
|
||||
|
||||
|
||||
typedef struct _PITCHSHIFT_FUNC_API_ {
|
||||
u32(*need_buf)(void *ptr, PITCH_SHIFT_PARM *pitchshift_obj);
|
||||
void (*open)(void *ptr, PITCH_SHIFT_PARM *pitchshift_obj); //中途改变参数,可以调init
|
||||
void (*run)(void *ptr, short *indata, short *outdata, int len); //len是多少个byte
|
||||
void (*init)(void *ptr, PITCH_SHIFT_PARM *pitchshift_obj); //中途改变参数,可以调init
|
||||
} PITCHSHIFT_FUNC_API;
|
||||
|
||||
extern PITCHSHIFT_FUNC_API *get_pitchshift_func_api();
|
||||
|
||||
#endif // reverb_api_h__
|
||||
|
||||
145
include_lib/media/media_new/media/sbc_enc.h
Normal file
145
include_lib/media/media_new/media/sbc_enc.h
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
*
|
||||
* Bluetooth low-complexity, subband codec (SBC) library
|
||||
*
|
||||
* Copyright (C) 2008-2010 Nokia Corporation
|
||||
* Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
|
||||
* Copyright (C) 2004-2005 Henryk Ploetz <henryk@ploetzli.ch>
|
||||
* Copyright (C) 2005-2006 Brad Midgley <bmidgley@xmission.com>
|
||||
*
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __SBC_ENC_H
|
||||
#define __SBC_ENC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//typedef unsigned char uint8 ,u8 ,U8 ,uint8_t;
|
||||
//typedef unsigned short int uint16 ,UINT16 ,U16 ,u16 ,uint16_t;
|
||||
//typedef unsigned int uint32 ,UINT32,U32 ,u32 ,uint32_t ,uintptr_t;
|
||||
//typedef signed char sint8 ,s8 ,S8,int8 ,int8_t;
|
||||
//typedef signed short int sint16 ,SINT16 ,S16 ,s16,int16,INT16,int16_t ;
|
||||
//typedef signed int sint32 ,SINT32,S32 ,s32,int32 ,INT32;//,;
|
||||
//typedef unsigned int size_t,ssize_t;
|
||||
//typedef int int32_t ;
|
||||
//typedef unsigned __int64 int64_t;
|
||||
//typedef __int64 uint64_t ;
|
||||
|
||||
|
||||
//#include "typedef.h"
|
||||
//#include <stdint.h>
|
||||
//#include <sys/types.h>
|
||||
#include <stddef.h>
|
||||
#ifndef __GNUC__
|
||||
#define SBC_ENCODE
|
||||
#endif
|
||||
/* sampling frequency */
|
||||
#define SBC_FREQ_16000 0x00
|
||||
#define SBC_FREQ_32000 0x01
|
||||
#define SBC_FREQ_44100 0x02
|
||||
#define SBC_FREQ_48000 0x03
|
||||
|
||||
|
||||
/* blocks */
|
||||
#define SBC_BLK_4 0x00
|
||||
#define SBC_BLK_8 0x01
|
||||
#define SBC_BLK_12 0x02
|
||||
#define SBC_BLK_16 0x03
|
||||
|
||||
/* channel mode */
|
||||
#define SBC_MODE_MONO 0x00
|
||||
#define SBC_MODE_DUAL_CHANNEL 0x01
|
||||
#define SBC_MODE_STEREO 0x02
|
||||
#define SBC_MODE_JOINT_STEREO 0x03
|
||||
|
||||
/* allocation method */
|
||||
#define SBC_AM_LOUDNESS 0x00
|
||||
#define SBC_AM_SNR 0x01
|
||||
|
||||
/* subbands */
|
||||
#define SBC_SB_4 0x00
|
||||
#define SBC_SB_8 0x01
|
||||
|
||||
/* Data endianness */
|
||||
#define SBC_LE 0x00
|
||||
#define SBC_BE 0x01
|
||||
|
||||
typedef struct sbc_struct {
|
||||
unsigned int flags;
|
||||
|
||||
unsigned char frequency;
|
||||
unsigned char blocks;
|
||||
unsigned char subbands;
|
||||
unsigned char mode;
|
||||
unsigned char allocation;
|
||||
unsigned char bitpool;
|
||||
unsigned char endian;
|
||||
|
||||
void *priv;
|
||||
void *priv_alloc_base;
|
||||
} sbc_t;
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned int sbc_enc_query(void);
|
||||
int sbc_init(sbc_t *sbc, unsigned long flags, void *priv);
|
||||
int sbc_reinit(sbc_t *sbc, unsigned long flags);
|
||||
|
||||
unsigned int sbc_parse(sbc_t *sbc, const void *input, size_t input_len);
|
||||
|
||||
/* Decodes ONE input block into ONE output block */
|
||||
unsigned int sbc_decode(sbc_t *sbc, const void *input, size_t input_len,
|
||||
void *output, size_t output_len, size_t *written);
|
||||
|
||||
/* Encodes ONE input block into ONE output block */
|
||||
unsigned int sbc_encode(sbc_t *sbc, const void *input, size_t input_len,
|
||||
void *output, size_t output_len, unsigned int *written);
|
||||
|
||||
/* Returns the output block size in bytes */
|
||||
//size_t sbc_get_frame_length(sbc_t *sbc);
|
||||
|
||||
/* Returns the time one input/output block takes to play in msec*/
|
||||
unsigned sbc_get_frame_duration(sbc_t *sbc);
|
||||
|
||||
/* Returns the input block size in bytes */
|
||||
//size_t sbc_get_codesize(sbc_t *sbc);
|
||||
|
||||
const char *sbc_get_implementation_info(sbc_t *sbc);
|
||||
void sbc_finish(sbc_t *sbc);
|
||||
//#define htons(x) ( ( (((unsigned short)(x)) >>8) & 0xff) | ((((unsigned short)(x)) & 0xff)<<8) )
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
struct option {
|
||||
const char *name;
|
||||
int has_arg;
|
||||
int *flag;
|
||||
int val;
|
||||
};
|
||||
|
||||
|
||||
#endif /* __SBC_ENC_H */
|
||||
|
||||
|
||||
108
include_lib/media/media_new/media/surround/effect_sur_api.h
Normal file
108
include_lib/media/media_new/media/surround/effect_sur_api.h
Normal file
@ -0,0 +1,108 @@
|
||||
#ifndef effectSUR_api_h__
|
||||
#define effectSUR_api_h__
|
||||
|
||||
/*单耳输入时,channel设置*/
|
||||
enum {
|
||||
EFFECT_CH_L = 0x10, //单声道输入,输出左声道
|
||||
EFFECT_CH_R = 0x20, //单声道输入,输出右声道
|
||||
EFFECT_CH2_L = 0x30, //双声道输入,输出2个左声道
|
||||
EFFECT_CH2_R = 0x40, //双声道输入,输出2个右声道
|
||||
};
|
||||
|
||||
enum {
|
||||
EFFECT_3D_TYPE0 = 0x01,
|
||||
EFFECT_3D_TYPE1 = 0x02, //这2个2选1 :如果都置上,优先用EFFECT_3D_TYPE1
|
||||
EFFECT_3D_LRDRIFT = 0x04,
|
||||
EFFECT_3D_ROTATE = 0x08, //这2个2选1 : 如果都置上,优先用EFFECT_3D_ROTATE
|
||||
EFFECT_3D_TYPE2 = 0x10,
|
||||
EFFECT_3D_LRDRIFT2 = 0x20,
|
||||
};
|
||||
|
||||
|
||||
typedef struct __SUR_FUNC_API_ {
|
||||
unsigned int (*need_buf)(int flag);
|
||||
unsigned int (*open)(unsigned int *ptr, int effectflag, int nch);
|
||||
unsigned int (*init)(unsigned int *ptr, int rotatestep, int damping, int feedback, int roomsize);
|
||||
unsigned int (*run)(unsigned int *ptr, short *inbuf, int len); // len是对点
|
||||
unsigned int (*switch_effect)(unsigned int *ptr, int effectflag, int rotatestep, int damping, int feedback, int roomsize);//新增的切换音效参数接口
|
||||
unsigned int (*switch_nch)(unsigned int *ptr, int nch);//新增的声道修改接口
|
||||
} SUR_FUNC_API;
|
||||
|
||||
|
||||
extern SUR_FUNC_API *get_sur_func_api();
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
因为复用其他音效的参数接口,所以还是用了4个参数,EFFECT_3D_TYPE2具体参数对应名称应该是 : {
|
||||
int rotatestep; //无效参数
|
||||
int rot60_100ms; //范围0到150
|
||||
int wetgain ; //范围0到100
|
||||
int delay ; //范围0到100
|
||||
}
|
||||
|
||||
默认参数可以用 FFECT_3D_TYPE2 {2, 90, 70, 100},
|
||||
|
||||
// 由于原本预留参数有些没留出来,为了可以调节频响之类的多效果,所以在原基础上通过把参数列表指针当做其中一个参数传进来
|
||||
// 如果 rot60_100ms小于0,wetgain=100的话, 那最后一个参数就是参数列表,这样就可以支持配置更多参数。
|
||||
|
||||
设置如下:
|
||||
|
||||
flag = EFFECT_3D_TYPE2;
|
||||
{ {2, -1, 100, surmode_present[MODE_SUR_KTV]},
|
||||
{2, -1, 100, surmode_present[MODE_SUR_3DTHE]},
|
||||
{2, -1, 100, surmode_present[MODE_SUR_HALL]},
|
||||
{2, -1, 100, surmode_present[MODE_SUR_VOICE]},
|
||||
{2, -1, 100, surmode_present[MODE_SUR_SUR]}
|
||||
}
|
||||
|
||||
|
||||
//其中参数示例:
|
||||
|
||||
enum {
|
||||
MODE_SUR_KTV = 0, //ktv模式
|
||||
MODE_SUR_3DTHE, //3D影院
|
||||
MODE_SUR_HALL, //音乐厅
|
||||
MODE_SUR_VOICE, //清澈人声
|
||||
MODE_SUR_SUR, //全景环绕
|
||||
MODE_SUR_MAX
|
||||
};
|
||||
|
||||
//dry,wet,delay,rot60,Erwet,Erfactor,Ewidth,Ertolate,predelay,width,diffusion,dampinglpf,basslpf,bassB
|
||||
const static int surmode_present[MODE_SUR_MAX][14] = {
|
||||
{80, 100, 35, 9000, 80, 80, 80, 80, 20, 100, 70, 6500, 4000, 18},
|
||||
{80, 100, 90, 10030, 90, 90, 90, 90, 18, 100, 75, 7000, 1000, 29},
|
||||
{80, 100, 100, 13000, 100, 100, 100, 100, 20, 100, 72, 9000, 50, 3},
|
||||
{80, 100, 20, 5010, 100, 70, 70, 100, 15, 100, 70, 5500, 3500, 60},
|
||||
{80, 100, 100, 10000, 80, 80, 80, 90, 10, 100, 72, 8000, 500, 15},
|
||||
};
|
||||
|
||||
|
||||
//dry,wet,delay,Erwet,Erfactor,Ewitdh,Ertolate,width,diffusion 范围都是 0到 100
|
||||
//rot60 范围是 0到15000, 单位ms
|
||||
//basslpf: 低频增强频率,范围 0到10000
|
||||
//dampinglpf: 高频衰减频率,范围 0到 10000
|
||||
//bassB: 低频增强比例
|
||||
|
||||
|
||||
混响调参说明:
|
||||
1.dry: 干声增益
|
||||
2.wet:
|
||||
整体效果声增益
|
||||
3.delay: 反射时间间隔,影响整体空间大小
|
||||
4.rot60:
|
||||
衰减60dB需要的时间, 即衰减速度,如果空间里面的物体吸声厉害,或者比较空旷,衰减比较快
|
||||
5.Erwet:早反射声的增益, 早反射声的存在 会让混响听起来更真实。但是不同的增益会影响听感上距离感,空间构造
|
||||
6.Erfactor: 早反射声的一个密集程度。 这个值大,早反射声之间间隔比较大。构造的空间感也会相对较大。 较小的话,就反射比较密集。空间感变小。
|
||||
7.Ewidth:影响早反射声左右声道的声音差异
|
||||
8.Ertolate:
|
||||
影响漫反射声音反馈的大小
|
||||
9.predelay:干声跟效果声的时间间隔。也会影响整体空间感。
|
||||
10.width:左右声道的差异,左右声道的差异,会产生立体感。(某些版本的sdk上该参数无效)
|
||||
11.diffusion: 发散程度, 影响 漫反射声音的变形程度。
|
||||
12.dampinglpf:高频衰减过度频率。反射声的一个频率衰减,这是一个斜着往下掉的曲线,影响了反射声中的高频分量。高频分量越多,整体音色越亮,但是成分太多,声音有些乱
|
||||
13.basslpf:反射声中的低频增强分量过度频率
|
||||
14.bassB:
|
||||
低频增强比例。 这里的低频增强,其实是压了高频。为了使整体频响不超过1,不引起反馈发散。所以加大了这个值感觉混响弱了。可以适量加大rot60或者Ertolate
|
||||
#endif
|
||||
#endif // reverb_api_h__
|
||||
108
include_lib/media/media_new/media/sw_drc.h
Normal file
108
include_lib/media/media_new/media/sw_drc.h
Normal file
@ -0,0 +1,108 @@
|
||||
#ifndef __SW_DRC_H
|
||||
#define __SW_DRC_H
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "generic/list.h"
|
||||
#include "os/os_api.h"
|
||||
#include "drc_api.h"
|
||||
|
||||
#define DRC_TYPE_LIMITER 1
|
||||
#define DRC_TYPE_COMPRESSOR 2
|
||||
#define WDRC_TYPE 3 //wdc 要求,硬件输出24bit、32bit
|
||||
|
||||
|
||||
struct drc_limiter {
|
||||
int attacktime; //启动时间
|
||||
int releasetime; //释放时间
|
||||
int threshold[2]; //threshold[1]是固定值32768, threshold[0]为界面参数
|
||||
};
|
||||
|
||||
struct drc_compressor {
|
||||
int attacktime; //启动时间
|
||||
int releasetime; //释放时间
|
||||
int threshold[3]; //threshold[2]是固定值32768
|
||||
int ratio[3]; //ratio[0]为固定值100, ratio[1] ratio[2]为界面参数
|
||||
};
|
||||
|
||||
struct threshold_group {
|
||||
float in_threshold;
|
||||
float out_threshold;
|
||||
};
|
||||
|
||||
struct wdrc_struct {
|
||||
u16 attacktime; //启动时间
|
||||
u16 releasetime; //释放时间
|
||||
struct threshold_group threshold[6];
|
||||
float inputgain; //wdrc输入数据放大或者缩小的db数(正数放大,负数缩小), 例如配2表示 总体增加2dB
|
||||
float outputgain; //wdrc输出数据放大或者缩小的db数(正数放大,负数缩小)
|
||||
u8 threshold_num;
|
||||
u8 rms_time;
|
||||
u8 algorithm;//0:PEAK 1:RMS
|
||||
u8 mode;//0:PERPOINT 1:TWOPOINT
|
||||
u16 holdtime; //预留位置
|
||||
u8 reverved[2];//预留位置
|
||||
};
|
||||
//对耳wdrc处理,区分左右声道
|
||||
#define L_wdrc 0x10
|
||||
#define LL_wdrc 0x20
|
||||
#define R_wdrc 0x40
|
||||
#define RR_wdrc 0x80
|
||||
|
||||
struct drc_ch_org {
|
||||
u8 nband; //max<=3,1:全带 2:两段 3:三段
|
||||
u8 type; //0:没有使能限幅和压缩器,1:限幅器 2:压缩器 3:wdrc
|
||||
u8 reserved[2]; //reserved[1]保留,未用, reserved[0]记录了 多带限幅时,是否再开启一次全带限幅
|
||||
int low_freq; //中低频分频点
|
||||
int high_freq; //中高频分频点
|
||||
int order; //分频器阶数, 2或者4
|
||||
union {
|
||||
struct drc_limiter limiter[4]; //限幅器
|
||||
struct drc_compressor compressor[3];//压缩器
|
||||
} _p;
|
||||
};
|
||||
|
||||
struct drc_ch {
|
||||
u8 nband; //max<=3,1:全带 2:两段 3:三段
|
||||
u8 type; //0:没有使能限幅和压缩器,1:限幅器 2:压缩器 3:wdrc(wdrc不支持3带)
|
||||
u8 reserved[2]; //reserved[1]保留,未用, reserved[0]记录了 多带限幅时,是否再开启一次全带限幅
|
||||
int low_freq; //中低频分频点
|
||||
int high_freq; //中高频分频点
|
||||
int order; //分频器阶数, 2或者4
|
||||
union {
|
||||
struct drc_limiter limiter[4]; //限幅器 64byte
|
||||
struct drc_compressor compressor[3];//压缩器 96byte
|
||||
struct wdrc_struct wdrc[2];//low high 136byte
|
||||
} _p;
|
||||
};
|
||||
struct sw_drc {
|
||||
void *work_buf[4]; //drc内部驱动句柄
|
||||
void *crossoverBuf; //分频器句柄
|
||||
int *run_tmp[3]; //多带限幅器或压缩器,运行buf
|
||||
int run_tmp_len; //多带限幅器或压缩器,运行buf 长度
|
||||
u8 nband; //max<=3,1:全带 2:两段 3:三段
|
||||
u8 type; //0:没有使能限幅和压缩器,1:限幅器 2:压缩器
|
||||
u8 channel; //通道数
|
||||
u8 run32bit; //drc处理输入输出数据位宽是否是32bit 1:32bit 0:16bit
|
||||
struct audio_eq *crossover[3];//多带分频器eq句柄
|
||||
u32 sample_rate; //采样率
|
||||
u8 nsection; //分频器eq段数
|
||||
u8 other_band_en; //多带限幅器之后,是否需要再做一次全带的限幅器 1:需要,0:不需要
|
||||
};
|
||||
extern void *get_low_sosmatrix();
|
||||
extern void *get_high_sosmatrix();
|
||||
extern void *get_band_sosmatrix();
|
||||
extern int get_crossover_nsection();
|
||||
|
||||
|
||||
extern void *audio_sw_drc_open(struct drc_ch *ch_tmp, u32 sample_rate, u8 channel, u8 drc_name, u8 run32bit);
|
||||
extern void audio_sw_drc_close(void *hdl);
|
||||
extern int audio_sw_drc_update(void *hdl, struct drc_ch *ch_tmp, u32 sample_rate, u8 channel);
|
||||
extern int audio_sw_drc_run(void *hdl, s16 *in_buf, s16 *out_buf, int npoint_per_channel);
|
||||
|
||||
|
||||
void audio_hw_crossover_open(struct sw_drc *drc, int (*L_coeff)[3], u8 nsection);
|
||||
void audio_hw_crossover_close(struct sw_drc *drc);
|
||||
void audio_hw_crossover_run(struct sw_drc *drc, s16 *data, int len);
|
||||
void audio_hw_crossover_update(struct sw_drc *drc, int (*L_coeff)[3], u8 nsection);
|
||||
|
||||
#endif
|
||||
23
include_lib/media/pemafrow_api.h
Normal file
23
include_lib/media/pemafrow_api.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef PEMAFROW_API_H
|
||||
#define PEMAFROW_API_H
|
||||
|
||||
#include "media/audio_stream.h"
|
||||
|
||||
#define PEMAFROW_RUN_POINT_NUM 128 //每次run固定点数
|
||||
int getPemafrowBuf();
|
||||
void pemafrowInit(void *workBuf);
|
||||
//int pemafrowRun(void *workBuf, short *in, short *out, int len);
|
||||
int pemafrowRun(void *workBuf, short *in, short *preOut, short *out);
|
||||
|
||||
typedef struct _PEMAFROW_API_STRUCT_ {
|
||||
void *ptr; //运算buf指针
|
||||
s16 pre_data[PEMAFROW_RUN_POINT_NUM];
|
||||
s16 data_buf[PEMAFROW_RUN_POINT_NUM];
|
||||
struct audio_stream_entry entry; // 音频流入口
|
||||
int out_len;
|
||||
int process_len;
|
||||
u16 data_len;
|
||||
u8 run_en;
|
||||
} PEMAFROW_API_STRUCT;
|
||||
|
||||
#endif
|
||||
330
include_lib/media/sound/pcm.h
Normal file
330
include_lib/media/sound/pcm.h
Normal file
@ -0,0 +1,330 @@
|
||||
/*****************************************************************
|
||||
>file name : pcm.h
|
||||
>create time : Mon 18 Jan 2021 02:04:15 PM CST
|
||||
*****************************************************************/
|
||||
#ifndef _SOUND_PCM_H_
|
||||
#define _SOUND_PCM_H_
|
||||
#include "audio_cfifo.h"
|
||||
#include "os/os_api.h"
|
||||
|
||||
struct sound_pcm_hardware {
|
||||
unsigned int info; /* SOUND_PCM_INFO_* */
|
||||
unsigned int formats; /* SOUND_PCM_FMTBIT_* */
|
||||
unsigned int rates; /* SOUND_PCM_RATE_* */
|
||||
unsigned int rate_min; /* min rate */
|
||||
unsigned int rate_max; /* max rate */
|
||||
unsigned int channels_min; /* min channels */
|
||||
unsigned int channels_max; /* max channels */
|
||||
int buffer_bytes_max; /* max buffer size */
|
||||
int period_bytes_min; /* min period size */
|
||||
int period_bytes_max; /* max period size */
|
||||
unsigned int periods_min; /* min # of periods */
|
||||
unsigned int periods_max; /* max # of periods */
|
||||
int fifo_size; /* fifo size in bytes */
|
||||
};
|
||||
|
||||
struct sound_pcm_substream;
|
||||
struct sound_pcm_hw_params;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* SOUND PCM逻辑设备错误返回值*/
|
||||
#define ESNDPCM_NOMEM 1 /* PCM设备申请不到内存 */
|
||||
#define ESNDPCM_NODEV 2 /* 找不到PCM设备 */
|
||||
#define ESNDPCM_INVAL 3 /* 无效的设备平台(未初始化) */
|
||||
#define ESNDPCM_UNKNOWN_RATE 4 /* PCM设备不支持的采样率 */
|
||||
#define ESNDPCM_CONFLICT_RATE 5 /* PCM设备与设置采样率冲突 */
|
||||
#define ESNDPCM_NOFIFO 6 /* PCM设备中没有设置runtime的fifo */
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define SOUND_PCM_TRIGGER_START 1 /* 触发DMA/CODEC开启 */
|
||||
#define SOUND_PCM_TRIGGER_STOP 2 /* 触发DMA/CODEC停止 */
|
||||
#define SOUND_PCM_TRIGGER_IRQ 3 /* 触发DMA下一个中断外传 */
|
||||
|
||||
#define SOUND_PCM_GET_HW_PARAMS _IOR('P', 1, sizeof(struct sound_pcm_hw_params)) /* Get硬件参数 */
|
||||
#define SOUND_PCM_SET_HW_PARAMS _IOW('P', 2, sizeof(struct sound_pcm_hw_params)) /* Set硬件参数 */
|
||||
#define SOUND_PCM_GET_HW_BUFFERED_LEN _IOR('P', 3, sizeof(unsigned int)) /* Get硬件参数 */
|
||||
#define SOUND_PCM_WAIT_SWN_MOVE _IOR('P', 4, sizeof(unsigned int)) /* 等待dac swn 输出一个点后,再往后走硬件参数 */
|
||||
#define SOUND_PCM_GET_HW_HRP _IOR('P', 5, sizeof(unsigned int)) /* Get硬件读指针 */
|
||||
|
||||
enum pcm_state {
|
||||
SOUND_PCM_STATE_IDLE = 0, /* PCM设备空闲 */
|
||||
SOUND_PCM_STATE_PREPARED, /* PCM设备硬件准备就绪 */
|
||||
SOUND_PCM_STATE_RUNNING, /* PCM设备DMA/CODEC运行中 */
|
||||
SOUND_PCM_STATE_SUSPENDED, /* PCM设备挂起 */
|
||||
};
|
||||
|
||||
/*
|
||||
* Sound PCM设备支持标准sample rate定义
|
||||
* */
|
||||
#define SOUND_PCM_RATE_8000 (1<<0) /* 8000Hz */
|
||||
#define SOUND_PCM_RATE_11025 (1<<1) /* 11025Hz */
|
||||
#define SOUND_PCM_RATE_12000 (1<<2) /* 12000Hz */
|
||||
#define SOUND_PCM_RATE_16000 (1<<3) /* 16000Hz */
|
||||
#define SOUND_PCM_RATE_22050 (1<<4) /* 22050Hz */
|
||||
#define SOUND_PCM_RATE_24000 (1<<5) /* 24000Hz */
|
||||
#define SOUND_PCM_RATE_32000 (1<<6) /* 32000Hz */
|
||||
#define SOUND_PCM_RATE_44100 (1<<7) /* 44100Hz */
|
||||
#define SOUND_PCM_RATE_48000 (1<<8) /* 48000Hz */
|
||||
#define SOUND_PCM_RATE_64000 (1<<9) /* 64000Hz */
|
||||
#define SOUND_PCM_RATE_88200 (1<<10) /* 88200Hz */
|
||||
#define SOUND_PCM_RATE_96000 (1<<11) /* 96000Hz */
|
||||
#define SOUND_PCM_RATE_128000 (1<<12) /* 128000Hz */
|
||||
#define SOUND_PCM_RATE_176400 (1<<13) /* 176400Hz */
|
||||
#define SOUND_PCM_RATE_192000 (1<<14) /* 192000Hz */
|
||||
#define SOUND_PCM_RATE_UNKNOWN (1<<15) /* Unknown sample rate */
|
||||
|
||||
#define SOUND_PCM_RATE_8000_44100 (SOUND_PCM_RATE_8000|SOUND_PCM_RATE_11025|SOUND_PCM_RATE_12000|\
|
||||
SOUND_PCM_RATE_16000|SOUND_PCM_RATE_22050|SOUND_PCM_RATE_24000|\
|
||||
SOUND_PCM_RATE_32000|SOUND_PCM_RATE_44100)
|
||||
#define SOUND_PCM_RATE_8000_48000 (SOUND_PCM_RATE_8000_44100|SOUND_PCM_RATE_48000)
|
||||
#define SOUND_PCM_RATE_8000_96000 (SOUND_PCM_RATE_8000_48000|SOUND_PCM_RATE_64000|\
|
||||
SOUND_PCM_RATE_88200|SOUND_PCM_RATE_96000)
|
||||
#define SOUND_PCM_RATE_8000_192000 (SOUND_PCM_RATE_8000_96000|SOUND_PCM_RATE_128000|SOUND_PCM_RATE_176400|\
|
||||
SOUND_PCM_RATE_192000)
|
||||
|
||||
/*
|
||||
* PCM设备与硬件DMA同步flag
|
||||
*/
|
||||
#define DMA_SYNC_R (1 << 0) /* 读同步 */
|
||||
#define DMA_SYNC_W (1 << 1) /* 写同步 */
|
||||
#define DMA_SYNC_RW (DMA_SYNC_R | DMA_SYNC_W) /* 读写同步 */
|
||||
|
||||
/*
|
||||
* Sound运行时间单位
|
||||
*/
|
||||
#define SOUND_TIME_MS 0
|
||||
#define SOUND_TIME_US 1
|
||||
|
||||
|
||||
/*
|
||||
* PCM设备操作函数
|
||||
*/
|
||||
struct sound_pcm_ops {
|
||||
int (*open)(struct sound_pcm_substream *substream);
|
||||
int (*close)(struct sound_pcm_substream *substream);
|
||||
int (*ioctl)(struct sound_pcm_substream *substream,
|
||||
unsigned int cmd, void *arg);
|
||||
int (*prepare)(struct sound_pcm_substream *substream);
|
||||
int (*trigger)(struct sound_pcm_substream *substream, int cmd);
|
||||
int (*pointer)(struct sound_pcm_substream *substream);
|
||||
int (*silence)(struct sound_pcm_substream *substream, int channel, u32 pos, u32 count);
|
||||
};
|
||||
|
||||
|
||||
struct sound_pcm_hw_params {
|
||||
u32 rates;
|
||||
int sample_rate;
|
||||
u8 sample_bits;
|
||||
u8 channels;
|
||||
};
|
||||
|
||||
struct sound_dma_buffer {
|
||||
u8 mode;
|
||||
void *addr;
|
||||
s16 size;
|
||||
struct audio_cfifo fifo;
|
||||
};
|
||||
|
||||
struct sound_pcm_map_status {
|
||||
u8 state;
|
||||
u8 ref_count;
|
||||
};
|
||||
|
||||
struct sound_pcm_map_fifo {
|
||||
void *addr; /* FIFO地址 */
|
||||
u16 bytes; /* FIFO大小(bytes) */
|
||||
u16 frame_len; /* FIFO帧总长度(bytes / ch / 2) */
|
||||
struct audio_cfifo cfifo; /* FIFO结构实体 */
|
||||
void (*sync)(struct sound_pcm_substream *substream, u8 flag); /* FIFO同步 */
|
||||
};
|
||||
|
||||
struct sound_pcm_runtime {
|
||||
/*fifo*/
|
||||
u32 hw_ptr; /* 当前硬件位置 */
|
||||
u32 sw_ptr; /* 当前软件位置 */
|
||||
u32 hw_ptr_jiffies; /* 当前硬件位置对应的时间 */
|
||||
u32 dma_irq_ptr; /* 设置的dma到达该ptr起中断 */
|
||||
u32(*sound_current_time)(void); /* 当前采样时间获取 */
|
||||
struct sound_pcm_map_fifo *fifo;
|
||||
u8 time_type; /* 采样指针位置的时钟类型 */
|
||||
|
||||
/* -- HW params -- */
|
||||
u8 channels; /* 采样通道 */
|
||||
u8 sample_bits;
|
||||
u16 period_size; /* 采样周期块大小(pingpong buffer模式) */
|
||||
u32 periods; /* 采样周期个数 */
|
||||
int sample_rate; /* sample_rate */
|
||||
|
||||
/* -- SW params -- */
|
||||
u8 run_mode; /*OVERRUN或非OVERRUN*/
|
||||
//u32 start_threshold; [>启动DMA的阈值<]
|
||||
//u32 stop_threshold; [>停止DMA的阈值<]
|
||||
//u32 silence_threshold; [>静音数据阈值 <]
|
||||
//u32 silence_size; [>填充静音数据的大小 <]
|
||||
|
||||
u32 silence_start; /* 静音起始位置 */
|
||||
u32 silence_filled; /* 已填充的静音数据 */
|
||||
int buffer_delay;
|
||||
|
||||
struct sound_pcm_map_status *status; /*映射硬件中的状态*/
|
||||
|
||||
/* -- DMA -- */
|
||||
struct sound_dma_buffer *dma; /* DMA缓冲 */
|
||||
|
||||
OS_MUTEX *mutex;
|
||||
};
|
||||
|
||||
|
||||
struct sound_pcm_stream;
|
||||
struct sound_pcm_substream {
|
||||
struct sound_pcm_stream *stream;
|
||||
struct sound_pcm_runtime *runtime; /* 数据流运行结构 */
|
||||
struct audio_cfifo_channel fifo; /* fifo缓冲 */
|
||||
void *private_data;
|
||||
struct list_head entry;
|
||||
void *irq_priv;
|
||||
void (*irq_handler)(void *priv);
|
||||
u8 direction; /* 数据流方向 */
|
||||
unsigned int hw_opened: 1;
|
||||
};
|
||||
|
||||
struct sound_pcm_stream {
|
||||
struct sound_pcm_substream *substream; /* 与设备共享的子数据流 */
|
||||
const struct sound_pcm_ops *ops; /* PCM操作函数 */
|
||||
void *platform_device;
|
||||
void *syncts;
|
||||
};
|
||||
|
||||
|
||||
/*************************************************************************
|
||||
* 采样率转换为bit表示
|
||||
* Input : sample_rate - 采样率
|
||||
* Output : 采样率的bit表示
|
||||
* Notes :
|
||||
* History : 2021/03/11 by Lichao.
|
||||
*=======================================================================*/
|
||||
int sound_pcm_match_standard_rate(int sample_rate);
|
||||
|
||||
/*************************************************************************
|
||||
* 创建sound pcm数据流
|
||||
* Input : stream - sound_pcm_stream二级指针,
|
||||
* name - 设备名,
|
||||
* direction - 数据流方向.
|
||||
* Output : 0 - 创建成功,非0 - 失败.
|
||||
* Notes :
|
||||
* History : 2021/03/11 by Lichao.
|
||||
*=======================================================================*/
|
||||
int sound_pcm_create(struct sound_pcm_stream **stream, const char *name, u8 direction);
|
||||
|
||||
/*************************************************************************
|
||||
* 设置pcm设备中断处理函数
|
||||
* Input : stream - sound_pcm_stream指针,
|
||||
* priv - 回调私有数据,
|
||||
* handler - 回调处理函数.
|
||||
* Output : 无.
|
||||
* Notes : pingpong模式可以用来处理音频采样定时,
|
||||
* 也可以使用中断处理唤醒等功能。
|
||||
* History : 2021/03/11 by Lichao.
|
||||
*=======================================================================*/
|
||||
void sound_pcm_set_irq_handler(struct sound_pcm_stream *stream, void *priv, void (*handler)(void *));
|
||||
|
||||
/*************************************************************************
|
||||
* pcm设备数据流准备
|
||||
* Input : stream - sound_pcm_stream指针,
|
||||
* sample_rate - 设备采样率,
|
||||
* delay - 设备缓冲延时,
|
||||
* mode - 数据流overrun/block模式选择.
|
||||
* Output : 0 - 成功,非0 - 失败.
|
||||
* Notes :
|
||||
* History : 2021/03/11 by Lichao.
|
||||
*=======================================================================*/
|
||||
int sound_pcm_prepare(struct sound_pcm_stream *stream, int sample_rate, int delay, int mode);
|
||||
|
||||
/*************************************************************************
|
||||
* pcm设备数据流开启采样
|
||||
* Input : stream - sound_pcm_stream指针.
|
||||
* Output : 0 - 成功,非0 - 失败.
|
||||
* Notes :
|
||||
* History : 2021/03/11 by Lichao.
|
||||
*=======================================================================*/
|
||||
int sound_pcm_start(struct sound_pcm_stream *stream);
|
||||
|
||||
/*************************************************************************
|
||||
* pcm设备数据流停止采样
|
||||
* Input : stream - sound_pcm_stream指针.
|
||||
* Output : 0 - 成功,非0 - 失败.
|
||||
* Notes :
|
||||
* History : 2021/03/11 by Lichao.
|
||||
*=======================================================================*/
|
||||
int sound_pcm_stop(struct sound_pcm_stream *stream);
|
||||
|
||||
/*************************************************************************
|
||||
* pcm设备数据流触发一次中断
|
||||
* Input : stream - sound_pcm_stream指针,
|
||||
* time_unit - 设置中断起来时间的单位,
|
||||
* time - 设置多少时间后起来(临近).
|
||||
* Output : 0 - 成功,非0 - 失败.
|
||||
* Notes :
|
||||
* History : 2021/03/11 by Lichao.
|
||||
*=======================================================================*/
|
||||
int sound_pcm_trigger_interrupt(struct sound_pcm_stream *stream, u8 time_unit, int time);
|
||||
|
||||
/*************************************************************************
|
||||
* pcm设备数据子流中断处理函数
|
||||
* Input : substream - sound_pcm_substream指针.
|
||||
* Output : 0 - 成功,非0 - 失败.
|
||||
* Notes : 一般由设备的DMA中断调用该函数进行中断分配和更新DMA信息.
|
||||
* History : 2021/03/11 by Lichao.
|
||||
*=======================================================================*/
|
||||
int sound_pcm_substream_irq_handler(struct sound_pcm_substream *substream);
|
||||
|
||||
/*************************************************************************
|
||||
* pcm设备设置数据声道分布
|
||||
* Input : stream - sound_pcm_stream指针,
|
||||
* map - 声道分布.
|
||||
* Output : 0 - 成功,非0 - 失败.
|
||||
* Notes :
|
||||
* History : 2021/03/11 by Lichao.
|
||||
*=======================================================================*/
|
||||
int sound_pcm_set_data_map(struct sound_pcm_stream *stream, u16 map);
|
||||
|
||||
/*************************************************************************
|
||||
* pcm设备写入数据
|
||||
* Input : stream - sound_pcm_stream指针,
|
||||
* data - 数字音频数据,
|
||||
* len - 数据长度.
|
||||
* Output : 实际写入的长度.
|
||||
* Notes :
|
||||
* History : 2021/03/11 by Lichao.
|
||||
*=======================================================================*/
|
||||
int sound_pcm_write(struct sound_pcm_stream *stream, void *data, int len);
|
||||
|
||||
/*************************************************************************
|
||||
* pcm设备io控制函数
|
||||
* Input : stream - sound_pcm_stream指针,
|
||||
* cmd - 命令,
|
||||
* arg - 参数.
|
||||
* Output : 0 - 成功,非0 - 失败.
|
||||
* Notes : PCM数据流的ioctl函数(数字音频相关)
|
||||
* History : 2021/03/11 by Lichao.
|
||||
*=======================================================================*/
|
||||
int sound_pcm_iotcl(struct sound_pcm_stream *stream, int cmd, void *arg);
|
||||
|
||||
/*************************************************************************
|
||||
* pcm设备控制器io控制函数
|
||||
* Input : stream - sound_pcm_stream指针,
|
||||
* cmd - 命令,
|
||||
* arg - 参数.
|
||||
* Output : 0 - 成功,非0 - 失败.
|
||||
* Notes : PCM设备的控制器ioctl函数(增益/电源等相关)
|
||||
* History : 2021/03/11 by Lichao.
|
||||
*=======================================================================*/
|
||||
int sound_pcm_ctl_ioctl(struct sound_pcm_stream *stream, int cmd, void *arg);
|
||||
int sound_pcm_read(struct sound_pcm_stream *stream, void *data, int len);
|
||||
void sound_pcm_free(struct sound_pcm_stream *stream);
|
||||
|
||||
|
||||
void sound_pcm_set_syncts(struct sound_pcm_stream *stream, void *syncts);
|
||||
|
||||
#endif
|
||||
113
include_lib/media/sound/sound.h
Normal file
113
include_lib/media/sound/sound.h
Normal file
@ -0,0 +1,113 @@
|
||||
/*****************************************************************
|
||||
> file name : sound.h
|
||||
>
|
||||
*****************************************************************/
|
||||
#ifndef _AUDIO_SOUND_H_
|
||||
#define _AUDIO_SOUND_H_
|
||||
#include "generic/ioctl.h"
|
||||
#include "sound/pcm.h"
|
||||
#include "os/os_api.h"
|
||||
|
||||
#define SOUND_PCM_DMA_CFIFO_MODE 0 /*FIFO与DMA地址映射关系方式*/
|
||||
#define SOUND_PCM_DMA_PERIOD_MODE 1 /*DMA周期采样方式*/
|
||||
|
||||
/*
|
||||
* Sound声道分布定义
|
||||
*/
|
||||
#define SOUND_CHMAP_MONO (1 << 0)
|
||||
#define SOUND_CHMAP_FL SOUND_CHMAP_MONO
|
||||
#define SOUND_CHMAP_FR (1 << 1)
|
||||
#define SOUND_CHMAP_RL (1 << 2)
|
||||
#define SOUND_CHMAP_RR (1 << 3)
|
||||
|
||||
struct sound_volume;
|
||||
/*
|
||||
* Sound control IOCTL命令
|
||||
*/
|
||||
//#define SNDCTL_IOCTL_GET_GAIN_RANGE _IOR('A', 1, sizeof(struct sound_volume))
|
||||
#define SNDCTL_IOCTL_POWER_ON _IOW('A', 1, sizeof(int)) /* 控制器上电 */
|
||||
#define SNDCTL_IOCTL_POWER_OFF _IOW('A', 2, sizeof(int)) /* 控制器断电 */
|
||||
#define SNDCTL_IOCTL_SET_ANA_GAIN _IOW('A', 5, sizeof(struct sound_volume)) /* 设置模拟增益 */
|
||||
#define SNDCTL_IOCTL_GET_ANA_GAIN _IOR('A', 6, sizeof(struct sound_volume)) /* 获取模拟增益 */
|
||||
#define SNDCTL_IOCTL_SET_DIG_GAIN _IOW('A', 7, sizeof(struct sound_volume)) /* 设置数字增益 */
|
||||
#define SNDCTL_IOCTL_GET_DIG_GAIN _IOR('A', 8, sizeof(struct sound_volume)) /* 获取数字增益 */
|
||||
#define SNDCTL_IOCTL_SET_BIAS_TRIM _IOW('A', 9, sizeof(int)) /* TRIM */
|
||||
|
||||
|
||||
struct sound_volume {
|
||||
u32 chmap;
|
||||
s16 volume[4];
|
||||
};
|
||||
/*
|
||||
* PCM设备软硬件平台配置
|
||||
*/
|
||||
struct sound_pcm_platform_data {
|
||||
void *dma_addr; /*DMA 地址*/
|
||||
int dma_bytes; /*DMA 字节长度*/
|
||||
int fifo_bytes; /*FIFO 长度*/
|
||||
void *private_data; /*Soc私有数据*/
|
||||
};
|
||||
|
||||
/*
|
||||
* 驱动控制器,由驱动实现
|
||||
*/
|
||||
struct sound_drv_controller {
|
||||
int (*power_on)(void *device); /*上电*/
|
||||
int (*power_off)(void *device); /*断电*/
|
||||
int (*ioctl)(void *device, int cmd, void *args); /*Control控制函数*/
|
||||
};
|
||||
|
||||
/*
|
||||
* Platform驱动,由驱动实现
|
||||
*/
|
||||
struct sound_platform_driver {
|
||||
const char *name;
|
||||
const struct sound_drv_controller *controller;
|
||||
const struct sound_pcm_ops *ops;
|
||||
int (*create)(void **device, struct sound_pcm_platform_data *data); /*创建新的设备*/
|
||||
void (*free)(void *device); /*关闭设备*/
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Platform挂载的子设备
|
||||
*/
|
||||
struct sound_platform_subdevice {
|
||||
char name[8];
|
||||
//const char *name;
|
||||
struct sound_platform_driver *driver;
|
||||
void *private_data;
|
||||
void *parent;
|
||||
struct list_head entry;
|
||||
OS_MUTEX mutex;
|
||||
};
|
||||
|
||||
/*
|
||||
* Platform管理总结构
|
||||
*/
|
||||
struct sound_platform {
|
||||
struct list_head list;
|
||||
};
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
int sound_platform_init(void);
|
||||
int sound_platform_load(const char *name, struct sound_pcm_platform_data *data);
|
||||
int sound_platform_power_on(const char *name);
|
||||
int sound_platform_power_off(const char *name);
|
||||
int sound_platform_free(const char *name);
|
||||
|
||||
int sound_platform_register(const struct sound_platform_driver *driver);
|
||||
|
||||
#define SOUND_PLATFORM_DRIVER(name) \
|
||||
const struct sound_platform_driver name sec(.sound_platform_driver)
|
||||
|
||||
/*
|
||||
typedef int (*sound_register_t)(void);
|
||||
|
||||
#define __sound_platform_init(func) \
|
||||
const sound_register_t __##func sec(.sound_platform_register) = func
|
||||
*/
|
||||
#endif
|
||||
98
include_lib/media/sw_drc.h
Normal file
98
include_lib/media/sw_drc.h
Normal file
@ -0,0 +1,98 @@
|
||||
#ifndef CONFIG_EFFECT_CORE_V2_ENABLE
|
||||
#include "media/media_develop/media/sw_drc.h"
|
||||
#else
|
||||
|
||||
#ifndef __SW_DRC_H
|
||||
#define __SW_DRC_H
|
||||
|
||||
#include "generic/typedef.h"
|
||||
#include "generic/list.h"
|
||||
#include "os/os_api.h"
|
||||
#include "drc_api.h"
|
||||
|
||||
|
||||
//分频器 crossover:
|
||||
typedef struct _CrossOverParam_TOOL_SET {
|
||||
int way_num; //段数
|
||||
int N; //阶数
|
||||
int low_freq; //低中分频点
|
||||
int high_freq; //高中分频点
|
||||
} CrossOverParam_TOOL_SET;
|
||||
|
||||
|
||||
struct threshold_group {
|
||||
float in_threshold;
|
||||
float out_threshold;
|
||||
};
|
||||
|
||||
struct wdrc_struct {
|
||||
u16 attacktime; //启动时间
|
||||
u16 releasetime; //释放时间
|
||||
struct threshold_group threshold[6];
|
||||
float inputgain; //wdrc输入数据放大或者缩小的db数(正数放大,负数缩小), 例如配2表示 总体增加2dB
|
||||
float outputgain; //wdrc输出数据放大或者缩小的db数(正数放大,负数缩小)
|
||||
u8 threshold_num;
|
||||
u8 rms_time;
|
||||
u8 algorithm;//0:PEAK 1:RMS
|
||||
u8 mode;//0:PERPOINT 1:TWOPOINT
|
||||
u16 holdtime; //预留位置
|
||||
u8 reverved[2];//预留位置
|
||||
};
|
||||
|
||||
//动态范围控制 DRC:
|
||||
typedef struct _wdrc_struct_TOOL_SET {
|
||||
int is_bypass; // 1-> byass 0 -> no bypass
|
||||
struct wdrc_struct parm;
|
||||
} wdrc_struct_TOOL_SET;
|
||||
|
||||
|
||||
|
||||
/* //对耳wdrc处理,区分左右声道 */
|
||||
// #define L_wdrc 0x10
|
||||
// #define LL_wdrc 0x20
|
||||
// #define R_wdrc 0x40
|
||||
/* #define RR_wdrc 0x80 */
|
||||
|
||||
struct drc_ch {
|
||||
CrossOverParam_TOOL_SET crossover;
|
||||
union {
|
||||
struct wdrc_struct wdrc[4];//[0]low [1]mid [2]high [3]多带之后,再做一次全带
|
||||
} _p;
|
||||
};
|
||||
|
||||
|
||||
struct sw_drc {
|
||||
void *work_buf[4]; //drc内部驱动句柄
|
||||
void *crossoverBuf; //分频器句柄
|
||||
int *run_tmp[3]; //多带限幅器或压缩器,运行buf
|
||||
int run_tmp_len; //多带限幅器或压缩器,运行buf 长度
|
||||
u8 nband; //max<=3,1:全带 2:两段 3:三段
|
||||
u8 channel; //通道数
|
||||
u8 run32bit; //drc处理输入输出数据位宽是否是32bit 1:32bit 0:16bit
|
||||
struct audio_eq *crossover[3];//多带分频器eq句柄
|
||||
u32 sample_rate; //采样率
|
||||
u8 nsection; //分频器eq段数
|
||||
u8 other_band_en; //多带限幅器之后,是否需要再做一次全带的限幅器 1:需要,0:不需要
|
||||
u8 bypass[4];
|
||||
};
|
||||
extern void *get_low_sosmatrix();
|
||||
extern void *get_high_sosmatrix();
|
||||
extern void *get_band_sosmatrix();
|
||||
extern int get_crossover_nsection();
|
||||
|
||||
|
||||
void *audio_sw_drc_open(void *crossover, void *wdrc, u32 sample_rate, u8 channel, u8 run32bit, u8 other_band_en);
|
||||
extern void audio_sw_drc_close(void *hdl);
|
||||
int audio_sw_drc_update(void *hdl, void *crossover, void *wdrc, u32 sample_rate, u8 channel);
|
||||
extern int audio_sw_drc_run(void *hdl, s16 *in_buf, s16 *out_buf, int npoint_per_channel);
|
||||
void sw_drc_set_bypass(struct sw_drc *drc, u8 tar, u8 bypass);
|
||||
|
||||
void audio_hw_crossover_open(struct sw_drc *drc, int (*L_coeff)[3], u8 nsection);
|
||||
void audio_hw_crossover_close(struct sw_drc *drc);
|
||||
void audio_hw_crossover_run(struct sw_drc *drc, s16 *data, int len);
|
||||
void audio_hw_crossover_update(struct sw_drc *drc, int (*L_coeff)[3], u8 nsection);
|
||||
|
||||
void band_merging_32bit(int *in0, int *in1, int *in2, s32 *out_buf_tmp, int points, u8 nband);
|
||||
void band_merging_16bit(short *in0, short *in1, short *in2, short *out_buf_tmp, int points, u8 nband);
|
||||
#endif
|
||||
#endif /*CONFIG_EFFECT_CORE_V2_ENABLE*/
|
||||
48
include_lib/media/tech_lib/LFaudio_plc_api.h
Normal file
48
include_lib/media/tech_lib/LFaudio_plc_api.h
Normal file
@ -0,0 +1,48 @@
|
||||
#ifndef _LFaudio_PLC_API_H
|
||||
#define _LFaudio_PLC_API_H
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct _LFaudio_PLC_API {
|
||||
unsigned int (*need_buf)(int nch);
|
||||
void (*open)(unsigned char *ptr, int nch, int mode); //mode从0到4, 4是最低延时
|
||||
int (*run)(unsigned char *ptr, short *inbuf, short *obuf, short len, short err_flag); //len是按多少个点的,inbuf跟obuf可以同址的
|
||||
} LFaudio_PLC_API;
|
||||
|
||||
|
||||
extern LFaudio_PLC_API *get_lfaudioPLC_api();
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
|
||||
#define PACKET_LEN 30
|
||||
#define PACKET_FILL_VAL 0x1500
|
||||
|
||||
/*调用示例*/
|
||||
{
|
||||
int bufsize;
|
||||
unsigned char *bufptr;
|
||||
BT15_REPAIR_API *test_repair = get_repair_api();
|
||||
|
||||
bufsize = test_repair->need_buf(nch);
|
||||
bufptr = malloc(bufsize); //开辟空间
|
||||
test_repair->open(bufptr, nch); //传入参数,参数1是buf地址,参数2是声道, 参数3是延时模式
|
||||
|
||||
while (1) {
|
||||
fread(inbuf, 2, PACKET_LEN, fpin);
|
||||
if (feof(fpin)) {
|
||||
break; //input data
|
||||
}
|
||||
|
||||
test_repair->run(bufptr, inbuf, outbuf, PACKET_LEN, err); //err=1是差错帧,要不然为0
|
||||
|
||||
fwrite(outbuf, 2, PACKET_LEN, fpout); //output data
|
||||
|
||||
}
|
||||
|
||||
free(bufptr);
|
||||
|
||||
}
|
||||
#endif
|
||||
31
include_lib/media/tech_lib/SensorCalib_api.h
Normal file
31
include_lib/media/tech_lib/SensorCalib_api.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef SENSORCALIB_API_H
|
||||
#define SENSORCALIB_API_H
|
||||
#include "tech_lib/SpatialAudio_api.h"
|
||||
|
||||
//校准阈值
|
||||
typedef struct {
|
||||
float thv1;//加速度计校准阈值1
|
||||
float thv2;//
|
||||
} Thval_t;
|
||||
|
||||
enum {
|
||||
type_0 = 0,
|
||||
type_1,
|
||||
type_2
|
||||
};
|
||||
enum {
|
||||
mode_0 = 0,
|
||||
mode_1
|
||||
};
|
||||
|
||||
int GroCelBuff();
|
||||
void GroCelInit(void *buf, info_spa_t *para, int time);
|
||||
int Gro_Calibration(void *ptr, short *data, info_spa_t *para, tranval_t *, int mode, gyro_cel_t *agv);
|
||||
|
||||
int AccCelBuff();
|
||||
void AccCelInit(void *ptr, info_spa_t *para, int time);
|
||||
int Acc_Calibration(void *ptr, short *data, info_spa_t *para, acc_cel_t *ac, Thval_t *tv);
|
||||
|
||||
#endif // !1
|
||||
|
||||
|
||||
54
include_lib/media/tech_lib/SpatialAudio_api.h
Normal file
54
include_lib/media/tech_lib/SpatialAudio_api.h
Normal file
@ -0,0 +1,54 @@
|
||||
#ifndef SPATIALAUDIO_API_H
|
||||
#define SPATIALAUDIO_API_H
|
||||
|
||||
typedef struct TRANVAL {
|
||||
int trans_x[3];
|
||||
int trans_y[3];
|
||||
int trans_z[3];
|
||||
|
||||
} tranval_t;
|
||||
|
||||
typedef struct COMMON_INFO {
|
||||
float fs;//采样率
|
||||
int len;//一包数据长度
|
||||
float sensitivity;//陀螺仪灵敏度
|
||||
int range;//加速度计量程(正)
|
||||
} info_spa_t;
|
||||
|
||||
typedef struct {
|
||||
float beta;
|
||||
float val;//陀螺仪参考阈值
|
||||
float cel_val;//动态校准参考阈值
|
||||
float time;//动态校准时长
|
||||
float SerialTime;//动态校准窗长
|
||||
float sensval;//角度灵敏度,越小越灵敏,范围:0.01~0.1,默认0.1
|
||||
} spatial_config_t;
|
||||
|
||||
//陀螺仪偏置
|
||||
typedef struct {
|
||||
float gyro_x;
|
||||
float gyro_y;
|
||||
float gyro_z;
|
||||
} gyro_cel_t;
|
||||
|
||||
//加速度计偏置
|
||||
typedef struct {
|
||||
float acc_offx;
|
||||
float acc_offy;
|
||||
float acc_offz;
|
||||
} acc_cel_t;
|
||||
|
||||
extern inline float root_float(float x);
|
||||
extern inline float angle_float(float x, float y);
|
||||
int get_Spatial_buf(int len);
|
||||
void init_Spatial(void *ptr, info_spa_t *, tranval_t *, spatial_config_t *, gyro_cel_t *, acc_cel_t *ac);
|
||||
void Spatial_cacl(void *ptr, short *data);
|
||||
int get_Spa_angle(void *ptr, float alpha, float voloct);
|
||||
void Spatial_reset(void *ptr);
|
||||
int Spatial_stra(void *ptr, int time, float val1);
|
||||
int get_test_angle(void *ptr);
|
||||
//int get_Pitch_angle(void* ptr);
|
||||
|
||||
#endif // !1
|
||||
|
||||
|
||||
80
include_lib/media/tech_lib/effect_surTheta_api.h
Normal file
80
include_lib/media/tech_lib/effect_surTheta_api.h
Normal file
@ -0,0 +1,80 @@
|
||||
#ifndef effect_surTheta_h__
|
||||
#define effect_surTheta_h__
|
||||
|
||||
typedef struct _PointSound360TD_PARM_SET {
|
||||
int theta;
|
||||
int volume;
|
||||
} PointSound360TD_PARM_SET;
|
||||
|
||||
//混响参数
|
||||
typedef struct _RP_PARM_CONIFG {
|
||||
int trackKIND; //角度合成算法用哪一种 :0或者1
|
||||
int ReverbKIND; //2或者3
|
||||
int reverbance; //湿声比例 : 0~100
|
||||
int dampingval; //高频decay :0~80
|
||||
} RP_PARM_CONIFG;
|
||||
|
||||
typedef struct _PointSound360Reverb_PARM_SET {
|
||||
unsigned char reverbance; //0-100: //reverb parm
|
||||
unsigned char dampingval; //0-100% //reverb parm
|
||||
unsigned char voltrack; // 0-1 // vol track
|
||||
char doangle; // 0 or 1
|
||||
|
||||
char diangle; // 0-360 : 2 channel angle
|
||||
unsigned char wet; //0-100://backgroud
|
||||
unsigned char dry; //0-100 ://voice part
|
||||
char reverb_kind; //reverb kind
|
||||
|
||||
unsigned short k1_w; //0-2000: output wetgain
|
||||
unsigned short k1_d; //0-2000: output drygain
|
||||
|
||||
char reverb_part; // 0-128 // mix wet and wet_dry reverb
|
||||
|
||||
char reserved0;
|
||||
short dest_vol; // dest vol;
|
||||
|
||||
} PointSound360Reverb_PARM_SET;
|
||||
|
||||
//角度合成算法定义
|
||||
enum {
|
||||
P360_T0 = 0,
|
||||
P360_T1 = 1
|
||||
};
|
||||
|
||||
//混响算法定义
|
||||
enum {
|
||||
P360_R0 = 2,
|
||||
P360_R1 = 3
|
||||
};
|
||||
|
||||
enum {
|
||||
PSOUND_BOTH = 0,
|
||||
PSOUND_L = 1,
|
||||
PSOUND_R = 2
|
||||
};
|
||||
|
||||
enum {
|
||||
P360TD_NO_REV = 0,
|
||||
P360TD_REV_K0 = 1,
|
||||
P360TD_REV_K1 = 2,
|
||||
P360TD_REV_K3 = 3,
|
||||
P360TD_REV_K4 = 4
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct __PointSound360TD_FUNC_API_ {
|
||||
unsigned int (*need_buf)(int flag);
|
||||
unsigned int (*open)(unsigned int *ptr, PointSound360TD_PARM_SET *sound360_parm, PointSound360Reverb_PARM_SET *reverb_parm, int ch_mode);
|
||||
unsigned int (*init)(unsigned int *ptr, PointSound360TD_PARM_SET *sound360_parm);
|
||||
unsigned int (*run)(unsigned int *ptr, short *inbuf, short *out, int len); // len是sizePerChannel
|
||||
unsigned int (*open_config)(unsigned int *ptr, PointSound360TD_PARM_SET *sound360_parm, RP_PARM_CONIFG *sound360_configparm);
|
||||
} PointSound360TD_FUNC_API;
|
||||
|
||||
|
||||
|
||||
extern PointSound360TD_FUNC_API *get_PointSound360TD_func_api();
|
||||
|
||||
|
||||
#endif // reverb_api_h__
|
||||
15
include_lib/media/tech_lib/jlsp_vad.h
Normal file
15
include_lib/media/tech_lib/jlsp_vad.h
Normal file
@ -0,0 +1,15 @@
|
||||
/*****************************************************************
|
||||
>file name : jlsp_vad.h
|
||||
>create time : Fri 17 Dec 2021 02:18:47 PM CST
|
||||
*****************************************************************/
|
||||
#ifndef _JLSP_VAD_H_
|
||||
#define _JLSP_VAD_H_
|
||||
|
||||
int JLSP_vad_get_heap_size(void *file_ptr, int *model_size);
|
||||
void *JLSP_vad_init(char *heap_buffer, int heap_size, char *share_buffer, int share_size, void *file_ptr, int model_size);
|
||||
int JLSP_vad_reset(void *m);
|
||||
int JLSP_vad_process(void *m, short *pcm, int *out_flag);
|
||||
int JLSP_vad_free(void *m);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user