⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 goertzel.c

📁 Fax and soft modem library source code.
💻 C
字号:
/* Goertzel's algorithm for the discrete Fourier transform */

#include <math.h>

#include "private.h"
#include "complex.h"
#include "goertzel.h"
#include "myaudio.h"

#define TWOPI (2.0 * M_PI)

goertzel::goertzel(float f)
  { v1 = v2 = v3 = 0.0;
    float theta = TWOPI * (f / SAMPLERATE);
    w = complex(cos(theta), -sin(theta));
    fac = 2.0 * w.re;
  }

void goertzel::insert(float x)
  { v1 = v2; v2 = v3;
    v3 = fac*v2 - v1 + x;
  }

complex goertzel::result()
  { return complex(v3) - (w * complex(v2));
  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -