wordy.bak

来自「Fax and soft modem source code. - Slow m」· BAK 代码 · 共 28 行

BAK
28
字号
/* Goertzel's algorithm for the disctrete 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 + =
减小字号Ctrl + -
显示快捷键?