acorr

Functions

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

acorr [ option ] [ infile ]

  • -l int

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

  • -m int

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

  • -q int

    • input format

      • 0 amplitude spectrum in dB

      • 1 log amplitude spectrum

      • 2 amplitude spectrum

      • 3 power spectrum

      • 4 windowed waveform

  • -o int

    • output format

      • 0 autocorrelation

      • 1 normalized autocorrelation

      • 2 biased autocorrelation

      • 3 unbiased autocorrelation

  • infile str

    • double-type data sequence

  • stdout

    • double-type autocorrelation sequence.

If -o 1, output the normalized autocorrelation:

\[ \begin{array}{cccc} 1, & r(1)/r(0), & \ldots, & r(M)/r(0), \end{array} \]
where \(r(m)\) is the \(m\)-th autocorrelation coefficient. If -o 2, output the biased autocorrelation function:
\[ \begin{array}{cccc} r(0)/L, & r(1)/L, & \ldots, & r(M)/L. \end{array} \]
If -o 3, output the unbiased autocorrelation function:
\[ \begin{array}{cccc} r(0)/L, & r(1)/(L-1), & \ldots, & r(M)/(L-M). \end{array} \]

The below example extracts 10-th order autocorrelation coefficients from windowed waveform.

x2x +sd data.short | frame | window | acorr -m 10 > data.acr
Parameters:
  • argc[in] Number of arguments.

  • argv[in] Argument vector.

Returns:

0 on success, 1 on failure.

See also

c2acr levdur lpc

class AutocorrelationAnalysis

Calculate autocorrelation from waveform or spectrum.

Public Functions

AutocorrelationAnalysis(int frame_length, int num_order, bool waveform_input)
Parameters:
  • frame_length[in] Frame length or number of FFT bins, \(L\).

  • num_order[in] Order of autocorrelation, \(M\).

  • waveform_input[in] If true, assume waveform input.

inline bool IsValid() const
Returns:

True if this object is valid.

bool Run(const std::vector<double> &input, std::vector<double> *autocorrelation, AutocorrelationAnalysis::Buffer *buffer) const
Parameters:
  • input[in] \(L\)-length waveform or \((L/2+1)\)-length power spectrum.

  • autocorrelation[out] \(M\)-th order autocorrelation coefficients.

  • buffer[out] Buffer.

Returns:

True on success, false on failure.

class Buffer

Buffer for AutocorrelationAnalysis class.

class WaveformToAutocorrelation

Calculate autocorrelation.

The input is the framed waveform signal:

\[ \begin{array}{cccc} x(0), & x(1), & \ldots, & x(L-1), \end{array} \]
where \(L\) is the frame length. The output is the \(M\)-th order autocorrelation coefficients:
\[ \begin{array}{cccc} r(0), & r(1), & \ldots, & r(M). \end{array} \]
The autocorrelation is given by
\[ r(m) = \sum_{l=0}^{L-1-m} x(l)x(l+m), \]
where \(m\) is the lag.

Public Functions

WaveformToAutocorrelation(int frame_length, int num_order)
Parameters:
  • frame_length[in] Frame length, \(L\).

  • num_order[in] Order of autocorrelation, \(M\).

inline int GetFrameLength() const
Returns:

Frame length.

inline int GetNumOrder() const
Returns:

Order of autocorrelation.

inline bool IsValid() const
Returns:

True if this object is valid.

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

  • autocorrelation[out] \(M\)-th order autocorrelation coefficients.

class SpectrumToAutocorrelation

Calculate autocorrelation from power spectrum.

The input is the half of power spectrum:

\[ \begin{array}{cccc} |X(0)|^2, & |X(1)|^2, & \ldots, & |X(L/2)|^2, \end{array} \]
where \(L\) is the FFT length. The output is the \(M\)-th order autocorrelation coefficients:
\[ \begin{array}{cccc} r(0), & r(1), & \ldots, & r(M). \end{array} \]
The autocorrelation is given by
\[ r(m) = \frac{1}{L} \sum_{l=0}^{L-1} |X(l)|^2 e^{j \frac{2\pi}{L} lm}, \]
where \(m\) is the lag.

Public Functions

SpectrumToAutocorrelation(int fft_length, int num_order)
Parameters:
  • fft_length[in] Number of FFT bins, \(N\).

  • num_order[in] Order of autocorrelation, \(M\).

inline int GetFftLength() const
Returns:

FFT length.

inline int GetNumOrder() const
Returns:

Order of autocorrelation.

inline bool IsValid() const
Returns:

True if this object is valid.

bool Run(const std::vector<double> &power_spectrum, std::vector<double> *autocorrelation, SpectrumToAutocorrelation::Buffer *buffer) const
Parameters:
  • power_spectrum[in] \((L/2+1)\)-length power spectrum.

  • autocorrelation[out] \(M\)-th order autocorrelation coefficients.

  • buffer[out] Buffer.

Returns:

True on success, false on failure.

class Buffer

Buffer for SpectrumToAutocorrelation class.