algorithm - Goertzel算法获取相位?

标签 algorithm signal-processing

我正在使用 Goertzel 算法来获取特定频率的幅度。 我现在正在尝试从中获取相位,但我不知道如何。

有人可以解释并告诉我如何从这段代码中获得某个特定-f 的阶段吗?

此外,我将它用于 16khz,采样率为 44.1。我可以运行它的最小样本长度是多少?

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;
}

最佳答案

进行直角坐标到极坐标的转换。这将为您提供相位和幅度。

幅度 = sqrt((Vreal * Vreal)+(Vimag * Vimag))

phase = atan2 (Vimag, Vreal)

关于algorithm - Goertzel算法获取相位?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13489519/

相关文章:

算法:Cormen、Leiserson、Rivest 和 Stein 的算法简介中的练习 5.1-2

java - 为什么我们说链表插入是常数时间?

algorithm - 找到 dp 状态 ZUMA spoj

iphone - 以编程方式在iPhone上创建声音

python - 如何管理服务器上的 CPU 密集型进程

matlab - MathNet.Numerics 与 Matlab 前向傅立叶答案不匹配?

algorithm - 计数排序的归纳证明?

python - 网格置换算法 - 固定行顺序

matlab - 参数均衡器的幅度响应

numpy - FFT实部/虚部/绝对部分解释