.. _分贝检测: 分贝检测(energe_detect) ========================================= | AD14N / AC104N / AD24N 支持分贝检测。 | 涉及文件: | 1、energe_detect_api.c | 2、energe_api.h | 3、lib_energe.a ^^^^^^^^^^^^^^^^^^^^ 配置参数(energe_param)说明 ################################ * sample_rate:采样率 * channel:通道(配置1即可) * detect_time:检测时间(单位为ms),该参数在当attFactor 与 relFactor为0 时有效 * attFactor:启动因子 (int)(exp(-1 / (time * sample_rate)) * (1 << 30)); time 为 0.001 ~ 0.1;默认0.001 time越小db值上升越快 * sample_rate:释放因子 (int)(exp(-1 / (time * sample_rate)) * (1 << 30)); time 为 0.3 ~ 0.9;默认0.5 time越小db值下降越快 注意: 1、db值计算库里分两种模式: | (1)、attFactor 与 relFactor 等于0时。实时计算detect_time这一段时间 pcm数据最大值的db值 | (2)、当attFactor 或者 relFactor 不等0时,detect_time参数无效。库里有做特殊处理,db值上升快,下降慢。由于定点运算db值大小会比实际db值小1 ~2db 2、获取mdb值函数,获取到的mdb值指针,包含两个通道的mdb值,若只有一个通道则取第一个值,如db_value[0]; 获取到的是mdb值,转化为db值的关系是 db = mdb / 1000; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 使用demo ################################ demo在energe_detect_api.c最下面。:: void demo() { /* 分贝检测算法使用流程demo */ u32 adc_sr = read_audio_adc_sr(); /* 1. 分贝检测初始化 */ energe_detect_init(adc_sr); /* 2. 把需要检测的数据和长度传入run函数 */ energe_run_api(data, len); /* 3. 获取detect_time 内pcm数据最大值的db值 */ get_energe_db_api(); }