Goertzel算法,以获得相位θ相位、算法、Goertzel

由网友(时光冷透少年郎i)分享简介:我使用Goertzel算法来获得一定频率的幅度。我想现在从它那里得到的阶段,我不知道怎么办。能否有人解释,并告诉我怎么得到一定-F从这个code的阶段? 此外,我用它来16kHz的,与采样率44.1。有什么样的最小长度,我可以运行它?双AlgorithmGoertzel(int16_t *样品,诠释的采样率,双频率,...

我使用Goertzel算法来获得一定频率的幅度。 我想现在从它那里得到的阶段,我不知道怎么办。

能否有人解释,并告诉我怎么得到一定-F从这个code的阶段?

此外,我用它来16kHz的,与采样率44.1。有什么样的最小长度,我可以运行它?

 双AlgorithmGoertzel(int16_t *样品,诠释的采样率,双频率,INT LEN)
{
    双realW = 2.0 * COS(2.0 * M_PI *频率/采样率);
    双imagW = 2.0 * SIN(2.0 * M_PI *频率/采样率);
    双D1 = 0;
    双D2 = 0;
    双Y;
    的for(int i = 0; I< LEN;我++){
        Y =(双)(签订短期)样本[I] + realW * D1  -  D2;
        D2 = D1;
        D1 = Y;
    }
    双RR = 0.5 * realW * D1-D2;
    双RI = 0.5 * imagW * D1-D2;

    返程(SQRT(PO​​W(RR,2)+ POW(RI,2)))/ LEN;
}
 

解决方案

我不认为算法由一个常数乘以序列的,而是由复杂的信号 EXP(N * I *二皮*频率/采样率); 0℃= N< =长度,并获得了平均幅度(或动力的信号)

由于复杂的输出为R * EXP(ⅰTHETA)中,R给出在给定频率的功率和θ给出的相位。 (THETA == ATAN2(IMAG,真正的))

I am using Goertzel algorithm to get the amplitude of a certain frequency. I am trying now to get the phase from it, and I don't know how.

FPGA攻城狮玩5G通信算法的基本套路说明

Can some one explain, and show me how to get the phase of a certain-f from this code?

Also, I am using it to 16khz, with sample rate 44.1. What's the smallest length of samples that I can run it on?

double AlgorithmGoertzel( int16_t *sample,int sampleRate, double Freq, int len )
{
    double realW = 2.0 * cos(2.0 * M_PI * Freq / sampleRate);
    double imagW = 2.0 * sin(2.0 * M_PI * Freq / sampleRate);
    double d1 = 0;
    double d2 = 0;
    double y;
    for (int i = 0; i < len; i++) {
        y=(double)(signed short)sample[i] +realW * d1 - d2;
        d2 = d1;
        d1 = y;
    }
    double rR = 0.5 * realW *d1-d2;
    double rI = 0.5 * imagW *d1-d2;

    return (sqrt(pow(rR, 2)+pow(rI,2)))/len;
}

解决方案

I don't think the algorithm consists of multiplying the sequence by a constant, but by the complex signal exp(n*i*2pi*freq/samplerate); 0<=n<=length, and getting the average magnitude (or power of the signal).

As the complex output is R*exp(i theta), R gives the power at the given frequency and theta gives the phase. (theta == atan2 ( imag, real))

阅读全文

相关推荐

最新文章