// file: $isip/class/algo/Cepstrum/Cepstrum.h // version: $Id: Cepstrum.h 9408 2004-02-25 23:06:51Z parihar $ // // make sure definitions are only made once // #ifndef ISIP_CEPSTRUM #define ISIP_CEPSTRUM // isip include files // #ifndef ISIP_ALGORITHM_BASE #include #endif // isip include files // #ifndef ISIP_FOURIER_TRANSFORM #include #endif // isip include files // #ifndef ISIP_BOOLEAN #include #endif // Cepstrum: a class that computes cepstral coefficients. it is a // homomorphic space which allows the deconvolution of the signal from // vocal tract shape. liftering can be accomplished to smooth // non-information bearing variability, by means of Window class using // LIFTER algorithm. // class Cepstrum : public AlgorithmBase { //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; //---------------------------------------- // // other important constants // //---------------------------------------- // define algorithm types // enum ALGORITHM { IDCT = 0, IDFT, DEF_ALGORITHM = IDCT }; // define implementation choices // enum IMPLEMENTATION { TYPE_I = 0, TYPE_II, TYPE_III, TYPE_IV, CONVENTIONAL, DEF_IMPLEMENTATION = TYPE_III }; // define static NameMap objects // static const NameMap ALGO_MAP; static const NameMap IMPL_MAP; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String DEF_PARAM; static const String PARAM_ORDER; static const String PARAM_ALGORITHM; static const String PARAM_IMPLEMENTATION; static const String PARAM_MIN_AMP; static const String PARAM_FLAG_MIN_AMP; //---------------------------------------- // // default values and arguments // //---------------------------------------- // define the default value(s) of the class data // static const int32 DEF_ORDER = 12; static const float32 DEF_MIN_AMP = 1; static const bool8 DEF_FLAG_MIN_AMP = true; // define default argument(s) // static const AlgorithmData::COEF_TYPE DEF_COEF_TYPE = AlgorithmData::SPECTRUM; //---------------------------------------- // // error codes // //---------------------------------------- static const int32 ERR = 70300; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // algorithm name // ALGORITHM algorithm_d; // implementation name // IMPLEMENTATION implementation_d; // declare the 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; // memory manager // static MemoryManager mgr_d; //--------------------------------------------------------------------------- // // required public methods // //--------------------------------------------------------------------------- public: // method: name // static const String& name() { return CLASS_NAME; } // other static methods // static bool8 diagnose(Integral::DEBUG debug_level); // debug methods: // setDebug method is inherited from the base class // bool8 debug(const unichar* msg) const; // method: destructor // ~Cepstrum() {} // default constructor // Cepstrum(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, int32 order = DEF_ORDER, float32 min_amp = DEF_MIN_AMP, bool8 flag_min_amp = DEF_FLAG_MIN_AMP) { algorithm_d = algorithm; implementation_d = implementation; order_d = order; min_amp_d = min_amp; flag_min_amp_d = flag_min_amp; is_valid_d = false; } // method: copy constructor // Cepstrum(const Cepstrum& arg) { assign(arg); } // assign methods // bool8 assign(const Cepstrum& arg); // method: operator= // Cepstrum& operator= (const Cepstrum& copy_node) { assign(copy_node); return *this; } // i/o methods // int32 sofSize() const; bool8 read(Sof& sof, int32 tag, const String& name = CLASS_NAME); bool8 write(Sof& sof, int32 tag, const String& name = CLASS_NAME) const; bool8 readData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false); bool8 writeData(Sof& sof, const String& pname = DEF_PARAM) const; // method: eq // bool8 eq(const Cepstrum& arg) const; // method: new // static void* operator new(size_t size) { return mgr_d.get(); } // method: new[] // static void* operator new[](size_t size) { return mgr_d.getBlock(size); } // method: delete // static void operator delete(void* ptr) { mgr_d.release(ptr); } // method: delete[] // static void operator delete[](void* ptr) { mgr_d.releaseBlock(ptr); } // method: setGrowSize // static bool8 setGrowSize(int32 grow_size) { return mgr_d.setGrow(grow_size); } // other memory management methods // bool8 clear(Integral::CMODE ctype = Integral::DEF_CMODE); //--------------------------------------------------------------------------- // // class-specific public methods: // set methods // //--------------------------------------------------------------------------- // method: setAlgorithm // bool8 setAlgorithm(ALGORITHM algorithm) { algorithm_d = algorithm; is_valid_d = false; return true; } // method: setImplementation // bool8 setImplementation(IMPLEMENTATION implementation) { implementation_d = implementation; is_valid_d = false; return true; } // method: setOrder // bool8 setOrder(int32 num) { order_d = num; is_valid_d = false; return true; } // method: setMinimumAmplitude // bool8 setMinimumAmplitude(float32 min_amp) { min_amp_d = min_amp; flag_min_amp_d = true; is_valid_d = false; return true; } // method: setFlagMinimumAmplitude // bool8 setFlagMinimumAmplitude(bool8 flag_min_amp) { flag_min_amp_d = flag_min_amp; is_valid_d = false; return true; } // method: set // bool8 set(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION, int32 order = DEF_ORDER, float32 min_amp = DEF_MIN_AMP, bool8 flag_min_amp = DEF_FLAG_MIN_AMP) { algorithm_d = algorithm; implementation_d = implementation; order_d = order; min_amp_d = min_amp; flag_min_amp_d = flag_min_amp; is_valid_d = false; return true; } //--------------------------------------------------------------------------- // // class-specific public methods: // get methods // //--------------------------------------------------------------------------- // method: getAlgorithm // ALGORITHM getAlgorithm() const { return algorithm_d; } // method: getImplementation // IMPLEMENTATION getImplementation() const { return implementation_d; } // method: getOrder // int32 getOrder() const { return order_d; } // method: getMinimumAmplitude // float32 getMinimumAmplitude() const { return min_amp_d; } // method: getFlagMinimumAmplitude // bool8 getFlagMinimumAmplitude() const { return flag_min_amp_d; } // method: get // bool8 get(ALGORITHM& algorithm, IMPLEMENTATION& implementation, int32& order, float32& min_amp, bool8& flag_min_amp) { algorithm = algorithm_d; implementation = implementation_d; order = order_d; min_amp = min_amp_d; flag_min_amp = flag_min_amp_d; return true; } //--------------------------------------------------------------------------- // // class-specific public methods: // computational methods // //--------------------------------------------------------------------------- bool8 compute(VectorFloat& output, const VectorFloat& input, AlgorithmData::COEF_TYPE input_coef_type = DEF_COEF_TYPE, int32 index = DEF_CHANNEL_INDEX); bool8 compute(VectorComplexFloat& output, const VectorComplexFloat& input, AlgorithmData::COEF_TYPE input_coef_type = DEF_COEF_TYPE, int32 index = DEF_CHANNEL_INDEX); bool8 compute(VectorFloat& output, const VectorComplexFloat& input, AlgorithmData::COEF_TYPE input_coef_type = DEF_COEF_TYPE, int32 index = DEF_CHANNEL_INDEX); bool8 compute(VectorComplexFloat& output, const VectorFloat& input, AlgorithmData::COEF_TYPE input_coef_type = DEF_COEF_TYPE, int32 index = DEF_CHANNEL_INDEX); //--------------------------------------------------------------------------- // // class-specific public methods: // AlgorithmBase interface contract methods // //--------------------------------------------------------------------------- // assign method // bool8 assign(const AlgorithmBase& arg); // equality method // bool8 eq(const AlgorithmBase& arg) const; // method: className // const String& className() const { return CLASS_NAME; } // apply method // bool8 apply(Vector& output, const Vector< CircularBuffer >& input); // parser methods // bool8 setParser(SofParser* parser); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: // algorithm-specific i/o methods // bool8 readDataCommon(Sof& sof, const String& pname, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false); bool8 writeDataCommon(Sof& sof, const String& pname) const; // algorithm and implementation specific computational methods // bool8 computeIdctT1Float(VectorFloat& cepstrum, const VectorFloat& spectrum); bool8 computeIdctT2Float(VectorFloat& cepstrum, const VectorFloat& spectrum); bool8 computeIdctT3Float(VectorFloat& cepstrum, const VectorFloat& spectrum); bool8 computeIdctT4Float(VectorFloat& cepstrum, const VectorFloat& spectrum); bool8 computeIdftConvRealFloat(VectorComplexFloat& cepstrum, const VectorFloat& spectrum); bool8 computeIdftConvComplexFloat(VectorComplexFloat& cepstrum, const VectorComplexFloat& spectrum); }; // end of include file // #endif