码迷,mamicode.com
首页 > 其他好文 > 详细

自适应含噪信号过零率算法

时间:2014-09-11 17:15:52      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:style   http   color   io   os   使用   ar   for   sp   

本文讨论的是实际使用过程中计算过零率的一种自适应方法。过零率常用于语音检测识别中,一般叫短时过零率更贴切些(指一段短时平稳信号才能计算过零率),简单有效,近期亦打算将这个简单的概念用于识别脚步声和卡车声(近似短时平稳)。过零率的定义计算一般通过下面的表达式描述:

bubuko.com,布布扣

过零率是对频率从时域进行的一种简单的度量,一般情况下,过零率越大频率近似越高,反正亦然,相关推倒可参考相关文献。

自然信号由于电路、环境引入的噪声会在0水平位置波动,直接按上式计算过零率,严重影响识别效果。因此,本文在计算过零率时,对信号的幅值进行阈值限定,阈值的计算方法是:

因为信号处理肯定是加窗一段一段的,所以使用上一次及本次采集的短时信号峰峰值Vpp的均值,再乘以对应的系数因子F(根据实际噪声环境确定,本文定义在0.1与0.2之间),作为本段信号计算过零率的限定阈值。

用数学形式表述更直观:

bubuko.com,布布扣

因此增加阈值判别后计算过零率的流程图为:

bubuko.com,布布扣

对应的C程序为:


/* signal thresh adaptive structure */
struct st_zerorate_thr{
    uint32_t pre;
    uint32_t cur;
};

/*
 * @brief   
 *   Calculate short time zero cross rate. Short time means n, n often choose to
 *   be a frame(256,512 and so on)
 *
 *   The diffrence with upstairs is that this one consider the adaptive thresh 
 *   when checking the signal, which removes the influence of noise.
 * @inputs  
 *   x[] - input sound signal
 *   n   - size of a frame
 * @outputs 
 * @retval  
 *   zero cross rate in a frame length
 */
uint16_t zero_rate(int16_t x[], int n, struct st_zerorate_thr thr)
{
    int      i        = 1;   /* Init to 1 */
    uint16_t zero_cnt = 0;
    float    tmp      = 0;
    uint8_t  x_pre    = 0;

    while ( (x[i] < thr.cur) && (x[i] > -thr.cur) && (i<n) ) {
        i++;
    }
    x_pre = x[i++];
    while ((i < n) && ((x[i] > thr.cur) || (x[i] < -thr.cur)) ) {
        tmp   = x[i] * x_pre;
        if (tmp < 0) {
            zero_cnt = zero_cnt + 1;
        }
        x_pre = x[i];
        i++;
    }

    return zero_cnt;
}

上面代码定义了阈值结构体st_zerorate_thr,更新阈值的方法按(2)式执行,

#define TH_FACTOR        (0.2f)   /* 0.1~0.2 */

void zerorate_thr_update(struct st_zerorate_thr thr, uint32_t peak_value)
{ 
    thr.pre = thr.cur;
    thr.cur = (uint32_t)(TH_FACTOR * ((thr.pre + peak_value)>>1) );
}

自适应含噪信号过零率算法

标签:style   http   color   io   os   使用   ar   for   sp   

原文地址:http://blog.csdn.net/xiahouzuoxin/article/details/39208545

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!