zcross

Functions

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

zcross [ option ] [ infile ]

  • -l int

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

  • -o int

    • output format

      • 0 number of zero-crossings

      • 1 zero-crossing rate

  • infile str

    • double-type data sequence

  • stdout

    • double-type zero-crossing

nrand -s 0 -l 30 | zcross -l 10 | x2x +da
# 3, 2, 5
Parameters:
  • argc[in] Number of arguments.

  • argv[in] Argument vector.

Returns:

0 on success, 1 on failure.

class ZeroCrossingAnalysis

Perform zero-crossing analysis.

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

\[ \begin{array}{cccc} x(0), & x(1), & \ldots, & x(L-1), \end{array} \]
and the output is the number of zero-crossings calculated by
\[ \frac{1}{2} \sum_{l=0}^{L-1} |\mathrm{sgn}(x(l)) - \mathrm{sgn}(x(l-1))|. \]
where \(\mathrm{sgn}(\cdot)\) returns -1 if the input is negative, otherwise returns 1. Note that \(x(-1)\) is taken from the previous frame.

Public Functions

explicit ZeroCrossingAnalysis(int frame_length)
Parameters:

frame_length[in] Frame length in points, \(L\).

inline int GetFrameLength() const
Returns:

Frame length.

inline bool IsValid() const
Returns:

True if this object is valid.

bool Run(const std::vector<double> &signals, int *num_zero_crossing, ZeroCrossingAnalysis::Buffer *buffer) const
Parameters:
  • signals[in] \(L\)-length waveform signals.

  • num_zero_crossing[out] Number of zero crossings.

  • buffer[inout] Buffer.

Returns:

True on success, false on failure.

class Buffer

Buffer for ZeroCrossingAnalysis class.