df2

Functions

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

df2 [ option ] [ infile ]

  • -s double

    • sampling rate in kHz \((0 < F_s)\)

  • -p double double

    • pole frequency and bandwidth in Hz \((0 < F_1 < 500F_s, \, 0 < B_1)\)

  • -z double double

    • zero frequency and bandwidth in Hz \((0 < F_2 < 500F_s, \, 0 < B_2)\)

  • infile str

    • double-type filter input

  • stdout

    • double-type filter output

Parameters:
  • argc[in] Number of arguments.

  • argv[in] Argument vector.

Returns:

0 on success, 1 on failure.

See also

dfs

class SecondOrderDigitalFilter

Apply second-order digital filter.

The second-order digital fiter is represented as

\[\begin{split}\begin{eqnarray} H(z) &=& \frac{(1-r_2 e^{j\theta_2}z^{-1})(1-r_2 e^{-j\theta_2}z^{-1})} {(1-r_1 e^{j\theta_1}z^{-1})(1-r_1 e^{-j\theta_1}z^{-1})} \\ &=& \frac{1 - 2r_2\cos\theta_2 z^{-1} + r_2^2 z^{-2}} {1 - 2r_1\cos\theta_1 z^{-1} + r_1^2 z^{-2}}. \end{eqnarray}\end{split}\]
The relation between radius \(r_{(\cdot)}\) and the 3-dB bandwidth \(B_{(\cdot)}\) is given by
\[\begin{split}\begin{eqnarray} r_1 &=& e^{-\pi B_1 / F_s}, \\ r_2 &=& e^{-\pi B_2 / F_s}, \end{eqnarray}\end{split}\]
where \(F_s\) is the sampling rate. The angle \(\theta_{(\cdot)}\) is
\[\begin{split}\begin{eqnarray} \theta_1 &=& 2\pi F_1 / F_s, \\ \theta_2 &=& 2\pi F_2 / F_s. \end{eqnarray}\end{split}\]

[1] J. O. Smith, “Relating Pole Radius to Bandwidth,” in Introduction to digital filters with audio applications, https://ccrma.stanford.edu/~jos/fp/Relating_Pole_Radius_Bandwidth.html

Public Types

enum FilterType

Filter type.

Values:

enumerator kPole
enumerator kZero

Public Functions

SecondOrderDigitalFilter(FilterType filter_type, double frequency, double bandwidth, double sampling_rate)
Parameters:
  • filter_type[in] Pole or zero.

  • frequency[in] Center frequency in Hz.

  • bandwidth[in] Bandwidth in Hz.

  • sampling_rate[in] Sampling rate in Hz.

SecondOrderDigitalFilter(double pole_frequency, double pole_bandwidth, double zero_frequency, double zero_bandwidth, double sampling_rate)
Parameters:
  • pole_frequency[in] Pole frequency in Hz.

  • pole_bandwidth[in] Pole bandwidth in Hz.

  • zero_frequency[in] Zero frequency in Hz.

  • zero_bandwidth[in] Zero bandwidth in Hz.

  • sampling_rate[in] Sampling rate in Hz.

inline bool IsValid() const
Returns:

True if this object is valid.

bool Run(double input, double *output, SecondOrderDigitalFilter::Buffer *buffer) const
Parameters:
  • input[in] Filter input.

  • output[out] Filter output.

  • buffer[inout] Buffer.

Returns:

True on success, false on failure.

bool Run(double *input_and_output, SecondOrderDigitalFilter::Buffer *buffer) const
Parameters:
  • input_and_output[inout] Input/output signal.

  • buffer[inout] Buffer.

Returns:

True on success, false on failure.

class Buffer

Buffer for SecondOrderDigitalFilter class.