goertzel

Functions

int main(int argc, char *argv[])

goertzel [ option ] [ infile ]

  • -l int

    • FFT length \((1 \le L)\)

  • -m int

    • order of sequence \((0 \le M)\)

  • -s double

    • sampling rate [kHz] \((0 < F_s)\)

  • -f double+

    • frequencies [Hz] \((0 \le F_k < 500F_s)\)

  • -o int

    • output format

      • 0 real and imaginary parts

      • 1 real part

      • 2 imaginary part

      • 3 amplitude

      • 4 power

  • infile str

    • double-type data sequence

  • stdout

    • double-type DFT sequence

The below example analyzes a sine wave using Goertzel algorithm.

sin -p 30 -l 256 | goertzel -l 256 -o 3 > sine.amp
Parameters:
  • argc[in] Number of arguments.

  • argv[in] Argument vector.

Returns:

0 on success, 1 on failure.

See also

fftr

class GoertzelAnalysis

Calculate DFT values at specified frequencies using the Goertzel algorithm.

The input is the \(L\)-length waveform signals:

\[ \begin{array}{cccc} x(0), & x(1), & \ldots, & x(L-1). \end{array} \]
The outputs are the real and imaginary parts of the DFT values:
\[\begin{split} \begin{array}{cccc} \mathrm{Re}(X(0)), & \mathrm{Re}(X(1)), & \ldots, & \mathrm{Re}(X(K-1)), \\ \mathrm{Im}(X(0)), & \mathrm{Im}(X(1)), & \ldots, & \mathrm{Im}(X(K-1)), \end{array} \end{split}\]
where \(K\) is the number of frequencies to be analyzed.

Public Functions

GoertzelAnalysis(double sampling_rate, const std::vector<double> &frequencies, int fft_length)
Parameters:
  • sampling_rate[in] Sampling rate in Hz.

  • frequencies[in] \(K\) frequencies in Hz to be analyzed.

  • fft_length[in] Number of points assumed in DFT. This is used to determine frequency bin resolution.

inline bool IsValid() const
Returns:

True if this object is valid.

bool Run(const std::vector<double> &signals, std::vector<double> *real_part_output, std::vector<double> *imag_part_output) const
Parameters:
  • signals[in] \(L\)-length waveform signals.

  • real_part_output[out] \(K\) real parts.

  • imag_part_output[out] \(K\) imaginary parts.

Returns:

True on success, false on failure.