name: Cepstrum: public AlgorithmBase
synopsis:

>     g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_algo.a

>     #include <Cepstrum.h>
>     Cepstrum(long order = DEF_ORDER, ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION);
>     boolean setOrder(long num);
>     boolean apply(VectorFloat& cepstrum, VectorFloat spec_mags) const;

quick start:

>     // declare cepstrum object
>     //
>     Cepstrum ceps;

>     // set the algorithm and the implementation
>     //
>     ceps.setAlgorithm(Cepstrum::IDCT);
>     ceps.setImplementation(Cepstrum::TYPE_III);

>     // set number of cepstral coefficients
>     //
>     ceps.setOrder(12);

>     // give your vector
>     //
>     VectorFloat input;

>     input.assign(L"1.0, 2.0, 1.0, 2.0, 3.0");
>     VectorFloat cepstrum;

>     // compute cepstral coefficients
>     //
>     ceps.compute(cepstrum, input);

description:
Cepstral coefficients are one of the most popular representations for the spectrum of the speech signal. The classic cepstrum is a typical case of a homomorphic transformation, and is defined as an inverse Discrete Fourier Transform (DFT) of the log spectrum. However, a typical front end of a speech recognizer, instead of performing an inverse DFT, employs an Discrete Cosine Transform (DCT) instead. The resulting coefficients are an approximation to the cepstrum, and in reality simply represent an orthogonal and compact representation of the log magnitude spectrum.
For a good discussion of the type of cepstral analysis commonly used in speech recognition, see:

X. Huang, A, Acero and H.W. Hon, Spoken Language Processing, Prentice-Hall, Upper Saddle River, New Jersey, USA, pp. 228, 2001.

S. Young, D. Kershaw, J, Odell, D. Ollason, V. Valtchev, and P. Woodland, The HTK Book (Version 3.0), Microsoft Corporation, Redmond, Washington, USA, pp. 60, July 2000.

A good summary of the four types of DCT algorithms used in this software can be found in:

K. Rao, and P. Yip, Discrete Cosine Transform: Algorithms, Advantages and Applications, Academic Press, San Diego, California, USA, pp.15, 1990.

The mathematical descriptions of the algorithms currently supported in this class are provided below for reference purposes:
In some applications, the zeroth cepstral coefficient is not required, since it simply represents the energy of the signal. In these cases, the Mask class can be used to remove this coefficient. Similarly, the Window class can be used to implement popular weighting schemes such as liftering.
dependencies:

- AlgorithmBase
- FourierTransform
- Boolean
- MemoryManager

public constants:

- define the class name:

      static const String CLASS_NAME = L"Cepstrum";

- define the algorithm choices:

      enum ALGORITHM { IDCT = 0, IDFT, DEF_ALGORITHM = IDCT };

- define the implementation choices:

      enum IMPLEMENTATION { TYPE_I, TYPE_II, TYPE_III, TYPE_IV, CONVENTIONAL, DEF_IMPLEMENTATION = TYPE_III };

- define static NameMap objects:

      static const NameMap ALGO_MAP = L"IDCT, IDFT";

      static const NameMap IMPL_MAP = L"TYPE_I, TYPE_II, TYPE_III, TYPE_IV, CONVENTIONAL";

- define i/o related variables:

      static const String DEF_PARAM = L"";

      static const String PARAM_ORDER = L"order";

      static const String PARAM_ALGORITHM = L"algorithm";

      static const String PARAM_IMPLEMENTATION = L"implementation";

      static const String PARAM_MIN_AMP = L"minimum_implementation";

      static const String PARAM_FLAG_MIN_AMP = L"flag_minimum_implementation";

- define default value(s) of the class data:

      static const long DEF_ORDER = (long)12;

      static const float DEF_MIN_AMP = 1;

      static const boolean DEF_FLAG_MIN_AMP = true;

- define default argument(s):

      static const AlgorithmData::COEF_TYPE DEF_COEF_TYPE = AlgorithmData::SPECTRUM;

error codes:

- error code indicating Cepstrum class general error:

      static const long ERR = (long)00070300;

protected data:

- algorithm name:

      ALGORITHM algorithm_d;

- implementation name:

      IMPLEMENTATION implementation_d;

- FourierTransform object:

      FourierTransform ft_d;

- number of cepstral coefficients:

      Long order_d;

- minimum input amplitude allowed for input:

      Float min_amp_d;

- a flag that denotes that minimum input amplitude is to be enforced:

      Boolean flag_min_amp_d;

- a static memory manager:

      static MemoryManager mgr_d;

required public methods:

- static methods:

      static const String& name();

      static boolean diagnose(Integral::DEBUG debug_level);

- debug methods: setDebug method is inherited from the base class

      boolean debug(const unichar* message) const;

- destructor/constructor(s):

      ~Cepstrum();

      Cepstrum(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, long order = DEF_ORDER);

      Cepstrum(const Cepstrum& arg);

- assign methods:

      boolean assign(const Cepstrum& arg);

- operator= methods:

      Cepstrum& operator= (const Cepstrum& arg);

- i/o methods:

      long sofSize() const;

      boolean read(Sof& sof, long tag, const String& name = CLASS_NAME);

      boolean write(Sof& sof, long tag, const String& name = CLASS_NAME) const;

      boolean readData(Sof& sof, const String& pname = DEF_PARAM, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);

      boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const;

- equality methods:

      boolean eq(const Cepstrum& arg) const;

- memory management methods:

      static void* operator new(size_t size);

      static void* operator new[](size_t size);

      static void operator delete(void* ptr);

      static void operator delete[](void* ptr);

      static boolean setGrowSize(long grow_size);

      boolean clear(Integral::CMODE ctype = Integral::DEF_CMODE);

class-specific public methods:

- set methods:

      boolean setAlgorithm(ALGORITHM algorithm);

      boolean setImplementation(IMPLEMENTATION implementation);

      boolean setOrder(long num);

      boolean setMiminumAmplitude(float min_amp);

      boolean setFlagMiminumAmplitude(boolean flag_min_amp);

      boolean set(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, long order = DEF_ORDER, float min_amp = DEF_MIN_AMP, boolean flag_min_amp = DEF_MIN_AMP);

- get methods:

      ALGORITHM getAlgorithm() const;

      IMPLEMENTATION getImplementation() const;

      long getOrder() const;

      float getMinimumAmplitude() const;

      boolean getFlagMinimumAmplitude() const;

      boolean get(ALGORITHM& algorithm, IMPLEMENTATION& implementation, long& order, float& min_amp, boolean& flag_min_amp);

- computational methods:

      boolean compute(VectorFloat& cepstrum, VectorFloat& spec_mags, AlgorithmData::COEF_TYPE input_coef_type = AlgorithmData::SPECTRUM, long index = DEF_CHANNEL_INDEX) const;

      boolean compute(VectorFloat& cepstrum, VectorComplexFloat& spec_mags, AlgorithmData::COEF_TYPE input_coef_type = AlgorithmData::SPECTRUM, long index = DEF_CHANNEL_INDEX) const;

      boolean compute(VectorComplexFloat& cepstrum, VectorFloat& spec_mags, AlgorithmData::COEF_TYPE input_coef_type = AlgorithmData::SPECTRUM, long index = DEF_CHANNEL_INDEX) const;

      boolean compute(VectorComplexFloat& cepstrum, VectorComplexFloat& spec_mags, AlgorithmData::COEF_TYPE input_coef_type = AlgorithmData::SPECTRUM, long index = DEF_CHANNEL_INDEX) const;

- AlgorithmBase interface contract methods:

      boolean eq(const AlgorithmBase& arg) const;

      boolean assign(const AlgorithmBase& arg);

      const String& className() const;

      boolean apply(Vector<AlgorithmData>& output, const Vector<AlgorithmData>& input) const;

- methods to get the parser from the Algorithm object:

      boolean setParser(SofParser* parser);

private methods:

- algorithm-specific i/o methods:

      boolean readDataCommon(Sof& sof, const String& pname, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);

      boolean writeDataCommon(Sof& sof, const String& pname);

- algorithm and implementation specific computational methods:

      boolean computeIdctT1Float(VectorFloat& cepstrum, const VectorFloat& spectrum);

      boolean computeIdctT2Float(VectorFloat& cepstrum, const VectorFloat& spectrum);

      boolean computeIdctT3Float(VectorFloat& cepstrum, const VectorFloat& spectrum);

      boolean computeIdctT4Float(VectorFloat& cepstrum, const VectorFloat& spectrum);

      boolean computeIdftConvRealFloat(VectorComplexFloat& cepstrum, const VectorFloat& spectrum);

      boolean computeIdftConvComplexFloat(VectorComplexFloat& cepstrum, const VectorComplexFloat& spectrum);

examples:

- This example shows how to compute the cepstral coefficients using an IDCT:

      // declare an object
      //
      Cepstrum ceps;

      // set number of coefficients
      //
      ceps.setOrder(12);

      // set the algorithm and implementation
      //
      ceps.setAlgorithm(Cepstrum::IDCT);
      ceps.setImplementation(Cepstrum::TYPE_III);

      // declare an input vector for which we want to compute
      // cepstral coefficients
      //
      VectorFloat input;
      input.assign(L"141.536456, 566.012599, 753.959190, 350.514452, 260.600174, 450.313256, 415.428250, 516.143151, 593.257160, 510.498570, 987.093536");

      // declare a vector to hold the cepstral coefficients
      //
      VectorFloat cepstral;

      // compute cepstral coefficients
      //
      ceps.compute(cepstral, input);

- This example shows how to compute the cepstral coefficients using an IDFT:

      // declare an object
      //
      Cepstrum ceps;

      // set number of coefficients
      //
      ceps.setOrder(12);

      // set the algorithm and implementation
      //
      ceps.setAlgorithm(Cepstrum::IDFT);
      ceps.setImplementation(Cepstrum::CONVENTIONAL);

      // declare an input vector for which we want to compute
      // cepstral coefficients
      //
      VectorFloat input;
      input.assign(L"141.536456, 566.012599, 753.959190, 350.514452, 260.600174, 450.313256, 415.428250, 516.143151, 593.257160, 510.498570, 987.093536");

      // declare a vector to hold the cepstral coefficients
      //
      VectorFloat cepstral;

      // compute cepstral coefficients
      //
      ceps.compute(cepstral, input);

notes:

- This class is basically a wrapper build around the Fourier Transform class. It calls the Fourier Transform Class for computation of an inverse DCT or an inverse DFT.