【发布时间】:2012-11-21 08:54:45
【问题描述】:
我正在使用 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;
}
【问题讨论】:
-
我无法理解最后两个结果,
rR和rI。参考Wikipedia article,它们是等式中数量 y(N) 的实部和虚部吗? 11 点? -
"Phase" 没有意义,除非你指定一个阶段 relative 到某个东西,例如到某个其他信号或某个绝对时间点。如果您在此处解释您真正想要实现的目标,将会有所帮助?
-
@PaulR ,在那个论坛上,我想没有人知道 dsp- 像你一样,所以,找到一个生活,不要在没有基本了解我的问题的情况下跳,如果你发现那作为重复,你为什么不回答原来的问题?
标签: algorithm signal-processing