KT24-1110_65E-HA-651B/include_lib/media/drc_api.h

140 lines
4.5 KiB
C
Raw Normal View History

2024-11-10 10:44:17 +00:00
#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; //阈值{x1y1,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; //阈值{x1y1,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 与 algorithmrmsTime 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大小
algorithmPEAK或者RMS
rmsTime:
rms时间msRMS时有效
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, 34
ThresholdNum:
rmsTime:
rms时间ms
channel:
sampleRate
algorithm
mode
intypeDATA_IN_SHORT或者DATA_IN_INT
outtype:
DATA_OUT_SHOR或者DATA_OUT_INTDATA_IN_SHORTDATA_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, 34
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