⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 circulardelayline.h

📁 这是一个从音频信号里提取特征参量的程序
💻 H
📖 第 1 页 / 共 2 页
字号:
// file: $isip/class/dstr/CircularDelayLine/CircularDelayLine.h// version: $Id: CircularDelayLine.h,v 1.17 2001/09/02 16:57:24 jelinek Exp $//// make sure definitions are made only once//#ifndef ISIP_CIRCULAR_DELAY_LINE#define ISIP_CIRCULAR_DELAY_LINE// isip include files//#ifndef ISIP_VECTOR#include <Vector.h>#endif// CircularDelayLine: a class that implements a tapped delay line using a// circular buffer. this is a very convenient data structure for many// functions in digital signal processing. hence, the interface is intended// to be simple and easy to use for such applications.//template<class TObject>class CircularDelayLine {    //---------------------------------------------------------------------------  //  // public constants  //  //---------------------------------------------------------------------------public:    // define the class name  //  static const String CLASS_NAME;     //----------------------------------------  //  // i/o related constants  //  //----------------------------------------      static const String DEF_PARAM;  static const String PARAM_INDEX;  static const String PARAM_BUFFER;  //----------------------------------------  //  // default values and arguments  //  //----------------------------------------  // define the default value(s) of the class data  //  static const long DEF_LENGTH = 1024;  static const long DEF_INDEX = 0;    // default arguments to methods  //  static const long DEF_INCREMENT = 1;    //----------------------------------------  //  // error codes  //  //----------------------------------------      static const long ERR = 41900;    //---------------------------------------------------------------------------  //  // protected data  //  //---------------------------------------------------------------------------protected:    // allocate internal storage for the buffer  //  Vector<TObject> v_d;  // allocate a pointer for the current location  //     Long index_d;    // define a static debug level for all objects of this class  //  static Integral::DEBUG debug_level_d;  // define the memory manager  //  static MemoryManager mgr_d;    //---------------------------------------------------------------------------  //  // required public methods  //  //---------------------------------------------------------------------------public:  // static methods:  //  diagnose method is moved outside the class header file and  //  defined in the CircularDelayLineDiagnose.h in order to avoid  //  issues related to preprocessing of the diagnose code.  //  static const String& name();   // method: setDebug  //  static boolean setDebug(Integral::DEBUG debug_level) {    debug_level_d = debug_level;    return true;  }  // other debug methods  //  boolean debug(const unichar* message) const;    // method: destructor  //  ~CircularDelayLine() {}  // default constructor  //  CircularDelayLine(long length = DEF_LENGTH);  // method: copy constructor  //  CircularDelayLine(const CircularDelayLine<TObject>& arg) {    assign(arg);  }    // assign methods  //  boolean assign(const CircularDelayLine<TObject>& arg);  // method: operator=  //  CircularDelayLine& operator= (const CircularDelayLine& arg) {    assign(arg);    return *this;  }  // equality methods  //  boolean eq(const CircularDelayLine<TObject>& arg) const;  // method: sofSize  //  long sofSize() const {    long bytes = index_d.sofSize();    bytes += v_d.sofSize();    return bytes;  }  // method: read  //  boolean read(Sof& sof, long tag) {    return read(sof, tag, name());  }  // method: write  //  boolean write(Sof& sof, long tag) const {    return write(sof, tag, name());  }    // other io methods  //  boolean read(Sof& sof, long tag, const String& name);  boolean write(Sof& sof, long tag, const String& 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;    // 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 boolean setGrowSize(long grow_size) {    return mgr_d.setGrow(grow_size);  }  // method: clear  //  boolean clear(Integral::CMODE cmode = Integral::DEF_CMODE) {    // call the vector clear    //    v_d.clear(cmode);    // clear the index in any case    //    index_d = DEF_INDEX;    return true;  }  //---------------------------------------------------------------------------  //  // class-specific public methods:  //  extensions to required methods  //  //---------------------------------------------------------------------------   // method: assign  //  boolean assign(const TObject& arg) {    v_d(index_d) = arg;    return true;  }      // method: operator=  //  TObject& operator= (const TObject& arg) {    assign(arg);    return *this;  }    //---------------------------------------------------------------------------  //  // class-specific public methods:  //  indexing methods  //  //---------------------------------------------------------------------------   // method: operator()  //  TObject& operator() (long index) {    long tmp_index = index_d + index;    tmp_index = wrap(tmp_index);    return v_d(tmp_index);  }  // method: operator()  //  const TObject& operator() (long index) const {    long tmp_index = index_d + index;    tmp_index = wrap(tmp_index);    return v_d(tmp_index);  }    //---------------------------------------------------------------------------  //  // class-specific public methods:  //  size-related methods  //  //---------------------------------------------------------------------------  // method: setLength   //  boolean setLength(long length) {    return v_d.setLength(length);  }    // method: length  //  long length() const {     return v_d.length();  }    //---------------------------------------------------------------------------  //  // class-specific public methods:  //  core data manipulation methods  //  //---------------------------------------------------------------------------   // method: advance  //  boolean advance(long increment = DEF_INCREMENT) {    index_d += increment;    index_d = wrap(index_d);    return true;  }  // method: advanceAndAssign  //  boolean advanceAndAssign(const TObject& input,			   long increment = DEF_INCREMENT) {    boolean status = advance(increment);    v_d(index_d) = input;    return status;  }    // method: assignAndAdvance  //  boolean assignAndAdvance(const TObject& input,			   long increment = DEF_INCREMENT) {    v_d(index_d) = input;    return advance(increment);  }  //---------------------------------------------------------------------------  //  // private methods  //  //---------------------------------------------------------------------------private:      // pointer manipulation methods  //  long wrap(long value) const;};//-----------------------------------------------------------------------------//// we define non-integral constants at the end of class definition for// templates (for non-templates these are defined in the default constructor)//      //-----------------------------------------------------------------------------// constants: required constants such as the class name//template <class TObject>const String CircularDelayLine<TObject>::CLASS_NAME(L"CircularDelayLine");// constants: define non-integral constants in the default constructor//template <class TObject>const String CircularDelayLine<TObject>::DEF_PARAM(L"");template <class TObject>const String CircularDelayLine<TObject>::PARAM_INDEX(L"index");template <class TObject>const String CircularDelayLine<TObject>::PARAM_BUFFER(L"buffer");// static instantiations: debug level//template <class TObject>Integral::DEBUG CircularDelayLine<TObject>::debug_level_d = Integral::NONE;template <class TObject>MemoryManager CircularDelayLine<TObject>::mgr_d(sizeof(CircularDelayLine<TObject>),						CLASS_NAME);// below are all the methods for the CircularDelayLine template class//      //-----------------------------------------------------------------------------//// required static methods////-----------------------------------------------------------------------------// method: name//// arguments: none//// return: a static String& containing the class name//// this method returns the class name//template<class TObject>const String& CircularDelayLine<TObject>::name() {    // create the static name string for this class and return it  //  static String cname(CLASS_NAME);  cname.clear();  cname.concat(CLASS_NAME);  cname.concat(L"<");  cname.concat(TObject::name());  cname.concat(L">");    // return the name  //  return cname;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -