grpdelay

Functions

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

grpdelay [ option ] [ infile ]

  • -l int

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

  • -m int

    • order of numerator coefficients \((0 \le M < L)\)

  • -n int

    • order of denominator coefficients \((0 \le N < L)\)

  • -z str

    • name of file containing numerator coefficients

  • -p str

    • name of file containing denominator coefficients

  • -a double

    • alpha \((0 < \alpha)\)

  • -g double

    • gamma \((0 < \gamma)\)

  • infile str

    • double-type real sequence

  • stdout

    • double-type group delay

The below example calculates group delay from 10-th order filter coefficients:

grpdelay -z data.z -m 10 -p data.p -n 10 -l 16 > data.gd

If the filter coefficients are stable, the below example gives the same result:

impulse -l 16 | dfs -z data.z -p data.p | grpdelay -l 16 > data.gd
Parameters:
  • argc[in] Number of arguments.

  • argv[in] Argument vector.

Returns:

0 on success, 1 on failure.

See also

phase

class FilterCoefficientsToGroupDelay

Transform filter coefficients to group delay.

The input is the \(M\)-th order numerator coefficients and the \(N\)-th order denominator coefficients:

\[\begin{split} \begin{array}{cccc} b(0), & b(1), & \ldots, & b(M), \\ K, & a(1), & \ldots, & a(N), \end{array} \end{split}\]
and the output is the \((L/2+1)\)-length group delay:
\[ \begin{array}{cccc} D(0), & D(1), & \ldots, & D(L/2), \end{array} \]
where \(L\) is the FFT length.

The general form of transfer function is given by

\[\begin{split}\begin{eqnarray} H(z) &=& \frac{\sum_{m=0}^M b(m) z^{-m}}{\sum_{n=0}^N a(n) z^{-n}} \\ &=& \frac{B(z)}{A(z)}. \end{eqnarray}\end{split}\]
The group delay is then represented as
\[ D(z) = \frac{C_R(z) C'_R(z) + C_I(z) C'_I(z)}{C_R^2(z) + C_I^2(z)} \]
where \(C(z)=B(z) \, z^{-N} A(z^{-1})\) and \(C'(z)\) is its ramped version. The subscripts \(R\) and \(I\) denote the real and imaginary parts.

The modified group delay is defined as

\[ D_{\alpha,\gamma}(z) = \mathrm{sgn}(D(z)) \left| \frac{C_R(z) C'_R(z) + C_I(z) C'_I(z)} {\left\{ C_R^2(z) + C_I^2(z) \right\}^\gamma} \right|^\alpha \]
where \(\alpha\) and \(\gamma\) are tunable positive parameters.

[1] J. O. Smith, “Numerical Computation of Group Delay,” in Introduction to digital filters with audio applications, https://ccrma.stanford.edu/~jos/fp/Numerical_Computation_Group_Delay.html

[2] H. A. Murthy and V. R. Gadde, “The modified group delay function and its application to phoneme recognition,” Proc. of ICASSP 2003.

Public Functions

FilterCoefficientsToGroupDelay(int num_numerator_order, int num_denominator_order, int fft_length, double alpha = 1.0, double gamma = 1.0)
Parameters:
  • num_numerator_order[in] Order of numerator coefficients, \(M\).

  • num_denominator_order[in] Order of denominator coefficients, \(N\).

  • fft_length[in] Number of FFT bins, \(L\).

  • alpha[in] A parameter of modified group delay, \(\alpha\).

  • gamma[in] A parameter of modified group delay, \(\gamma\).

inline int GetNumNumeratorOrder() const
Returns:

Order of numerator coefficients.

inline int GetNumDenominatorOrder() const
Returns:

Order of denominator coefficients.

inline int GetFftLength() const
Returns:

FFT length.

inline double GetAlpha() const
Returns:

Alpha.

inline double GetGamma() const
Returns:

Gamma.

inline bool IsValid() const
Returns:

True if this object is valid.

bool Run(const std::vector<double> &numerator_coefficients, const std::vector<double> &denominator_coefficients, std::vector<double> *group_delay, FilterCoefficientsToGroupDelay::Buffer *buffer) const
Parameters:
  • numerator_coefficients[in] \(M\)-th order coefficients.

  • denominator_coefficients[in] \(N\)-th order coefficients.

  • group_delay[out] \((L/2+1)\)-length group delay.

  • buffer[out] Buffer.

Returns:

True on success, false on failure.

class Buffer

Buffer for FilterCoefficientsToGroupDelay class.