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

📄 sof.h

📁 这是一个从音频信号里提取特征参量的程序
💻 H
📖 第 1 页 / 共 2 页
字号:
// file: $isip/class/io/Sof/Sof.h// version: $Id: Sof.h,v 1.41 2001/04/23 22:57:24 peng Exp $//// make sure definitions are only made once//#ifndef ISIP_SOF#define ISIP_SOF// isip include files//#ifndef ISIP_FILE#include <File.h>#endif#ifndef ISIP_SOF_SYMBOL_TABLE#include <SofSymbolTable.h>#endif#ifndef ISIP_SOF_LIST#include <SofList.h>#endif#ifndef ISIP_CHECKSUM#include <Checksum.h>#endif// forward class definitions//class SofParser;// Sof: (s)ignal (o)bject (f)ile//// this file defines a class that is used to read and write isip objects// to a file (binary or text). this class serves as an index, keeping// track of all objects written to a file. note that multiple objects// of the same class name can be written to a file.//class Sof {  //---------------------------------------------------------------------------  //  // public constants  //  //---------------------------------------------------------------------------public:  // define the class name  //  static const SysString CLASS_NAME;    //----------------------------------------  //  // Sof file parsing related constants  //  //----------------------------------------    // define magic sequences used to identify an Sof file  //  static const long MAX_MAGIC_LENGTH = 22;  // define the version number and magic number  //  static const SysString VERSION;  // define some sizes  //  static const long MESSAGE_SIZE = 1024;  static const long CLASS_NAME_SIZE = 256;    // define deletion characters  //  static const char DELETE_CHAR_TEXT = ' ';  static const char DELETE_CHAR_BINARY = '\0';  // define new line characters  //  static const char NEWLINE_BUFFER[];  static const long NEWLINE_LENGTH;    //----------------------------------------  //  // byte-mode related constants  //  //----------------------------------------    // define descriptor string related to these byte modes  //  static const SysString BSTR_NATIVE;  static const SysString BSTR_SWAP;  // define the numbers that these string should convert to  //  static const long BCODE_NATIVE = 1633837924;  static const long BCODE_SWAP = 1684234849;    // define the length of the byte-string for testing  //  static const long BSTR_LEN = 4;    // determine if the machine supports IEEE floating point  //  static const float IEEE_FLOAT_NATIVE = 16777999408082104352768.000000;  static const float IEEE_FLOAT_SWAP = 261007875622861537280.000000;  //----------------------------------------  //  // tag related constants  //  //----------------------------------------      // define constants for the implicit tag number regions  //  // if you go over 1.07 billion implicitly numbered tags, it will error  //  static const long NO_TAG = SofList::NO_TAG;  static const long ALL_TAGS = NO_TAG + 1;  static const long FREE_TAG = NO_TAG + 2;  static const long IMPLICIT_END = -1073741824;  static const long IMPLICIT_START = (NO_TAG + 3);      //----------------------------------------  //  // binary index i/o related constants  //  //----------------------------------------      // define the buffer size to be used. the sof binary index, when  // written, is aligned at this buffer size to expedite i/o.  //  static const long BUFFER_SIZE = File::BUF_SIZE;    // positions in the sequentially output symbol table  //  static const long SYMBOL_BASE	= (2 * sizeof(uint32) + sizeof(ubyte));  static const long SYMBOL_OFFSET_NEXT = 0;  static const long SYMBOL_OFFSET_IND =	SYMBOL_OFFSET_NEXT + sizeof(ubyte);  static const long SYMBOL_OFFSET_REFS = SYMBOL_OFFSET_IND + sizeof(int32);  static const long SYMBOL_OFFSET_NAME = SYMBOL_OFFSET_REFS + sizeof(int32);    // positions in the sequentially output binary index  //  static const long INDEX_SIZE = (4 * sizeof(int32) + sizeof(byte8));  static const long INDEX_OFFSET_NEXT = 0;  static const long INDEX_OFFSET_POS = INDEX_OFFSET_NEXT + sizeof(byte8);  static const long INDEX_OFFSET_TAG = INDEX_OFFSET_POS + sizeof(int32);  static const long INDEX_OFFSET_SIZE = INDEX_OFFSET_TAG + sizeof(int32);  static const long INDEX_OFFSET_NAME = INDEX_OFFSET_SIZE + sizeof(int32);  // constant for the skip table size (partial i/o)  //  static const long SKIP_TABLE_GROUP = 10;    //----------------------------------------  //  // default values and arguments  //  //----------------------------------------    // define the default value(s) of the class data  //  static const unichar DEF_DELIMITER = L'@';  static const long DEF_POS = -1;  static const long DEF_IMPLICIT = IMPLICIT_START;  static const boolean DEF_DISABLE_LOCK = true;    // default arguments to methods  //  static const long ANY_SIZE = -1;    //---------------------------------------  //  // error codes  //  //---------------------------------------    static const long ERR				= 10000;  static const long ERR_NOTSOF			= 10001;  static const long ERR_NOOBJ			= 10002;  static const long ERR_NOTAG			= 10003;  static const long ERR_UPDATEH			= 10011;  static const long ERR_UPDATE			= 10012;  static const long ERR_CLOSE			= 10015;  static const long ERR_RANGE			= 10020;  static const long ERR_CURPOS			= 10021;  static const long ERR_FLOAT			= 10042;  static const long ERR_READHD			= 10043;  static const long ERR_TYPE			= 10044;  static const long ERR_STRUCT			= 10045;  static const long ERR_LABEL			= 10051;  static const long ERR_IMPLIC			= 10061;  static const long ERR_TAG			= 10062;  static const long ERR_BINARY			= 10063;  static const long ERR_PARTIAL			= 10070;  static const long ERR_RESIZE			= 10071;  //---------------------------------------------------------------------------  //  // protected data  //  //---------------------------------------------------------------------------protected:  // general information about a file  //  SysString name_d;                         // current filename  SysString expanded_name_d;                // expanded filename  File::TYPE file_type_d;	            // type of file (text or binary)    // I/O related variables  //  File fp_d;				    // active file pointer    // auxiliary information  //  unichar delimiter_d;                     // object tag delimiter  long end_of_header_d;                    // end of header, start of data  long end_of_data_d;                      // end of data, start of index   long cur_data_d;                         // start of current object data  // current file position (global, what ftell() would return)  //  long cur_pos_d;    // next free implicit tag number  //  long implicit_count_d;		    // file locking  //  boolean disable_lock_d;  long lock_retry_d;  long lock_delay_d;    // symbol table used for names  //  SofSymbolTable table_d;    // list used to process the object index  //  SofList index_d;  // scratch space for magic number manipulations  //  SysString cname_d;                              // sof file tag   SysString version_d;                            // sof version  SysString magic_d;			          // sof magic number  // variables used in partial read and write  //  boolean partial_write_d;  boolean partial_read_d;  SofParser* vec_parser_d;  int32* skip_table_d;  long skip_table_incr_d;  long last_skip_table_pos_d;  long vec_start_pos_d;  long vec_size_d;  long vec_curr_elem_d;  // the checksum read from the file  //  ushort file_checksum_d;    // static checksum object for binary files  //  static Checksum cksm_d;    // debugging parameters  //  Integral::DEBUG debug_level_d;  // static memory manager  //  static MemoryManager mgr_d;  //---------------------------------------------------------------------------  //  // required public methods  //  //---------------------------------------------------------------------------public:  // method: name  //  static const SysString& name() {    return CLASS_NAME;  }  // other static methods  //  static boolean diagnose(Integral::DEBUG debug_level);  // method: setDebug  //  boolean setDebug(Integral::DEBUG level) {    debug_level_d = level;    return true;  }    // other debug methods  //  boolean debug(const unichar* msg) const;  // destructor/constructor(s)  //  ~Sof();  Sof();    // assign methods  //  boolean assign(const Sof& arg);    // method: operator=  //  Sof& operator=(const Sof& arg) {    if (!assign(arg)) {      Error::handle(name(), L"operator=", Error::ARG, __FILE__, __LINE__);    }          return *this;  }    // i/o methods:  //  these methods are omitted because Sof can not write itself to an  //  sof file  //    // equality methods:  //  these methods are omitted because they are not useful for Sof objects  //  // 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);  }    // clear method  //  this clear method is slightly different from the required clear  //  method in that it can be used only for writable Sof files. it deletes  //  all items from the sof file for all CMODE's.  //   boolean clear(Integral::CMODE ctype = Integral::DEF_CMODE);    //---------------------------------------------------------------------------  //  // class-specific public methods:  //  extensions to the required public methods  //  //---------------------------------------------------------------------------  // memory size methods  //  long memSize();    //---------------------------------------------------------------------------  //  // class-specific public methods:  //  file operation methods  //  //---------------------------------------------------------------------------      // method: open  //  boolean open(const unichar* filename, File::MODE mode = File::READ_ONLY,	       File::TYPE type = File::DEF_TYPE) {    SysString temp(filename);    return open(temp, mode, type);  }  boolean open(const SysString& filename, File::MODE mode = File::READ_ONLY,	       File::TYPE type = File::DEF_TYPE);  // close methods  //  boolean close();    // close all open Sof files (part of Error's clean exit)  //  static boolean closeAll();    // method: setLockDisable  //  boolean setLockDisable(boolean disable) {    disable_lock_d = disable;    return true;  }  // method: setLockRetry  //  boolean setLockRetry(long retry, long delay = File::DEF_LOCK_DELAY) {    lock_retry_d = retry;    lock_delay_d = delay;    return true;  }        // method: setDelimiter  //  boolean setDelimiter(unichar chr) {    delimiter_d = chr;    return true;  }    // method: getDelimiter  //  unichar getDelimiter() const {    return delimiter_d;  }    // method: getName  //  const SysString& getName() const {    if (!isOpen()) {      Error::handle(name(), L"getName", Error::READ_CLOSED, __FILE__,		    __LINE__);    }    return name_d;  }  // method: getExpandedName  //  const SysString& getExpandedName() const {    if (!isOpen()) {      Error::handle(name(), L"getName", Error::READ_CLOSED, __FILE__,		    __LINE__);    }    return expanded_name_d;  }  // file queries methods  //  boolean isSof();  static boolean isSof(const SysString& filename);    // method: isText  //  boolean isText() const{    return (file_type_d == File::TEXT);  }    // method: isBinary  //  boolean isBinary() const {    return (file_type_d != File::TEXT);  }    // method: isOpen  //  boolean isOpen() const {    return fp_d.isOpen();  }  // method: isSameFile  //  boolean isSameFile(Sof& sof_obj) {    return (expanded_name_d.eq(sof_obj.expanded_name_d));  }  //---------------------------------------------------------------------------  //  // class-specific public methods:  //  object operation methods  //  //---------------------------------------------------------------------------    // method: find  //  boolean find(const SysString& name, long tag) {    return find(table_d.getIndex(name), tag);  }  long first(const SysString& name);  long last(const SysString& name);  // method: next  //  this method finds the next instance of this object in the index  //  long next(const SysString& name, long cur_tag) {    long name_ind = table_d.getIndex(name);    // find in symbol table    return index_d.next(name_ind, cur_tag);    // return the tag  }

⌨️ 快捷键说明

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