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

📄 sstr_03.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 5 页
字号:
   }   // word-align the byte* buffer for the larger characters   //   while (((long)&buff[buf_index][buf_offset] % sizeof(unichar)) != 0) {     buff[buf_index][buf_offset] = (byte)0;     buf_offset++;   }      // wrap the pointer within the buffer. hopefully the user is done   // with all previous values returned, they are going to be   // overwritten. obviously we can't do something as nice as a memset   // here, as it would defeat the entire purpose   //   if (len * (long)sizeof(unichar) + buf_offset > buf_size) {     buf_offset = 0;   }      // read the data starting at the buf_offset'th position of the   // buf_index'th buffer, increment buf_offset to point to the next   // available space   //   getBuffer((unichar*)&buff[buf_index][buf_offset], len);   buf_offset += len * sizeof(unichar);   // return the buffer   //   return (unichar*)&buff[buf_index][buf_offset - len*sizeof(unichar)];}// method: concat//// arguments://  const SysString& str: (input) string to concatenate//// return: a boolean value indicating status//// this method concatenates str to the current object//boolean SysString::concat(const SysString& str_a) {  // if the argument is null, we are done  //  if (str_a.length() == 0) {    return true;  }    // if two strings are same, then error off  //  if (str_a.value_d == value_d) {    return Error::handle(name(), L"concat", Error::MEM, __FILE__, __LINE__);  }    // possibly expand the size of the string  //  if ((length() + str_a.length()) > capacity_d) {    if (!growMem(length() + str_a.length())) {      return Error::handle(name(), L"concat", Error::MEM, __FILE__, __LINE__);    }  }  // concatenate the new string  //  isip_wcscat(value_d, str_a.value_d);    // exit gracefully  //  return true;}// method: concat//// arguments://  const SysString& str1: (input) string to concatenate//  const SysString& str2: (input) string to concatenate//// return: a boolean value indicating status//// this method concatenates str1 & str2 to the current object//boolean SysString::concat(const SysString& str1_a, const SysString& str2_a) {  // delete any current values in this object  //  clear(Integral::RESET);    // possibly expand the size of the string  //  if ((str1_a.length() + str2_a.length()) > capacity_d) {    freeMem();    capacity_d = str1_a.length() + str2_a.length();    allocateMem();  }  // assign the first string  //  assign(str1_a);  // concatenate the second string  //  concat(str2_a);    // exit gracefully  //  return true;}// method: get//// arguments://  void*& val: (output) pointer value//// return: a boolean value indicating status//// this method converts the object into an address pointer//boolean SysString::get(void*& val_a) const {  // declare a null pointer  //  val_a = (void*)NULL;  // check if string is null string  //  if (firstStr((unichar*)NULL_PTR) >= 0) {    return true;  }      // use the 8-bit character conversion  //  if (sscanf((char*)(byte*)(*this),	     (char*)DEF_FMT_VOIDP_8BIT, &val_a) != 1) {    return false;  }  // exit gracefully  //  return true;}// method: get//// arguments://  boolean& val: (output) boolean value//// return: a boolean value indicating status//// this method converts the string into a boolean value//boolean SysString::get(boolean& val_a) const {  // initialize the return value  //  boolean status = false;    // return boolean true or false  //  if (eq((unichar*)BOOL_TRUE)) {    val_a = true;    status = true;  }  else if (eq((unichar*)BOOL_FALSE)) {    val_a = false;    status = true;  }  // exit gracefully  //  return status;}// method: get//// arguments://  byte& val: (output) byte value//// return: a boolean value indicating status//// this method converts the object into a ubyte integer//boolean SysString::get(byte& val_a) const {  // read in the integer  //  ulong val = 0;  // use the 8-bit character conversion  //  if (sscanf((char*)(byte*)(*this),	     (char*)DEF_FMT_LONG_8BIT, &val) != 1) {    return false;  }  // assign it to a byte  //  val_a = (byte)val;    // exit gracefully  //  return true;}// method: get//// arguments://  unichar& val: (output) unichar value//// return: a boolean value indicating status//// this method converts the string into a unichar value//boolean SysString::get(unichar& val_a) const {  // if length is 1 then assign zeroth element to unichar  //  if (length() == 1) {    val_a = value_d[0];    return true;  }  // exit ungracefully  //  return false;}// method: get//// arguments://  ushort& val: (output) ushort value//// return: a boolean value indicating status//// this method converts the object into a ushort integer//boolean SysString::get(ushort& val_a) const {  // declare local variables  //  ulong tmp_val = 0;  // use the 8-bit character conversion  //  if (sscanf((char*)(byte*)(*this),	     (char*)DEF_FMT_ULONG_8BIT, &tmp_val) != 1) {    return false;  }  // set the output  //  val_a = tmp_val;  // exit gracefully  //  return true;}// method: get//// arguments://  ulong& val: (output) ulong value//// return: a boolean value indicating status//// this method converts the object into a ulong integer//boolean SysString::get(ulong& val_a) const {  // declare local variables  //  val_a = 0;  // use the 8-bit character conversion  //  if (sscanf((char*)(byte*)(*this),	     (char*)DEF_FMT_ULONG_8BIT, &val_a) != 1) {    return false;  }  // exit gracefully  //  return true;}// method: get//// arguments://  ullong& val: (output) ullong value//// return: a boolean value indicating status//// this method converts the object into a ullong integer//boolean SysString::get(ullong& val_a) const {  // declare local variables  //  val_a = 0;  // use the 8-bit character conversion  //  if (sscanf((char*)(byte*)(*this),	     (char*)DEF_FMT_ULLONG_8BIT, &val_a) != 1) {    return false;  }  // exit gracefully  //  return true;}// method: get//// arguments://  short& val: (output) short value//// return: a boolean value indicating status//// this method converts the object into a short integer//boolean SysString::get(short& val_a) const {  // declare local variable  //  long tmp_val = 0;  // use the 8-bit character conversion  //  if (sscanf((char*)(byte*)(*this),	     (char*)DEF_FMT_LONG_8BIT, &tmp_val) != 1) {    return false;  }  // set the output  //  val_a = tmp_val;    // exit gracefully  //  return true;}// method: get//// arguments://  long& val: (output) long value//// return: a boolean value indicating status//// this method converts the object into a long integer//boolean SysString::get(long& val_a) const {  // declare local variables  //  val_a = 0;  // use the 8-bit character string conversion  //  if (sscanf((char*)(byte*)(*this),	     (char*)DEF_FMT_LONG_8BIT, &val_a) != 1) {    return false;  }  // exit gracefully  //  return true;}// method: get//// arguments://  llong& val: (output) llong value//// return: a boolean value indicating status//// this method converts the object into a llong integer//boolean SysString::get(llong& val_a) const {  // declare local variables  //  val_a = 0;  // use the 8-bit character conversion  //  if (sscanf((char*)(byte*)(*this),	     (char*)DEF_FMT_LLONG_8BIT, &val_a) != 1) {    return false;  }  // exit gracefully  //  return true;}// method: get//// arguments://  float& val: (output) float value//// return: a boolean value indicating status//// this method converts the object to a single precision floating point number//boolean SysString::get(float& val_a) const {  // declare local variables  //  val_a = (float)0.0;  // use the 8-bit character conversion  //  if (sscanf((char*)(byte*)(*this),	     (char*)DEF_RFMT_FLOAT_8BIT, &val_a) != 1) {    return false;  }  // exit gracefully  //  return true;}// method: get//// arguments://  double& val: (output) double value//// return: a boolean value indicating status//// this method converts the object to a double precision floating point number//boolean SysString::get(double& val_a) const {  // declare local variables  //  val_a = (double)0.0;  // use the 8-bit character conversion  //  if (sscanf((char*)(byte*)(*this),	     (char*)DEF_RFMT_DOUBLE_8BIT, &val_a) != 1) {    return false;  }  // exit gracefully  //  return true;}// method: get//// arguments://  SysComplex<TIntegral>& arg: (output) complex value//// return: a boolean value indicating status//// this method converts the object to a complex number// template <class TIntegral>boolean SysString::get(SysComplex<TIntegral>& arg_a) const {  // declare local variable  //  SysString str(*this);  str.trim();  long imag_pos = str.firstChr(L'j');  if ((imag_pos > 0) && (imag_pos != str.length() - 1)) {    return Error::handle(name(), L"get", Error::ARG, __FILE__, __LINE__);  }  // if there is not 'j' in the string, convert directly  //  if (imag_pos < 0) {    TIntegral val;    str.get(val);    arg_a = SysComplex<TIntegral>(val, 0);    long pos = 0;    long len = str.length();    SysString num;    // search letters '+' or '-' in the string    //    str.tokenize(num, pos, L'+');    if (pos >= len - 1) {      pos = 0;      str.tokenize(num, pos, L'-');    }    // if '+' or '-' exists in the string    //    if (pos < len - 1 ) {      str.debug(L"value");      return Error::handle(name(), L"invalid format - complex numbers should be in the format: a+bj", Error::ARG, __FILE__, __LINE__);    }  }  else {    // declare local variable    //    long pos = 0;    long len = str.length();    boolean isPositive = true;    TIntegral val0, val1;    SysString num;    // search letters '+' or '-' in the string    //    str.tokenize(num, pos, L'+');    if (pos >= len - 1) {      pos = 0;      str.tokenize(num, pos, L'-');      isPositive = false;    }    // if '+' or '-' exists in the string    //    if (pos < len - 1 ) {      // get the real part of the complex number      //      num.trim();      num.get(val0);      // set the appropriate sign for real part if necessary      //      if ((str(0) != num(0)) && (str(0) == '-')) {	val0 = -val0;      }      // get the image part of the complex number      //      pos++;      str.tokenize(num, pos, L'j');      num.trim();      if (num.length() == 0) {	val1 = 1;      }      else {	if (!num.get(val1)) {	  str.debug(L"value");	  return Error::handle(name(), L"invalid format - complex numbers should be in the format: a+bj", Error::ARG, __FILE__, __LINE__);	}      }      // set the corresponding sign for the image part      //      if (!isPositive) {	val1 = -val1;      }      // copy temporary complex number to output argument      //      arg_a = SysComplex<TIntegral>(val0, val1);    }    // only real part or image part exists in the string    //    else {            // delete the letter 'j'      //      str.deleteRange(imag_pos, 1);      // get the image part of the complex number      //      TIntegral val;      str.trim();      if (str.length() == 0 || str.eq(L"+")) {	val = 1;      }      else if (str.eq(L"-")) {	val = -1;      }      else {	if (!str.get(val)) {	  str.debug(L"value");	  return Error::handle(name(), L"invalid format - complex numbers should be in the format: a+bj", Error::ARG, __FILE__, __LINE__);	}      }            // copy temporary complex number to output argument      //      arg_a = SysComplex<TIntegral>(0, val);    }  }  // exit gracefully  //  return true;}  // explicit instantiations for complex types//templateboolean SysString::get<float>(SysComplex<float>&) const;templateboolean SysString::get<double>(SysComplex<double>&) const;templateboolean SysString::get<long>(SysComplex<long>&) const;// method: get//// arguments://  SysChar& val: (output) SysChar value

⌨️ 快捷键说明

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