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

📄 gaus_03.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
字号:
// file: $isip/class/stat/GaussianModel/gaus_03.cc// version: $Id: gaus_03.cc,v 1.11 2002/08/15 03:13:59 alphonso Exp $//// isip include files//#include "GaussianModel.h"// method: readAccumulator//// arguments://  Sof& sof: (input) sof file object//  long tag: (input) sof object instance tag//  const String& name: (input) sof object instance name//// return: a boolean value indicating status//// this method has the object read accumulators from an Sof file//boolean GaussianModel::readAccumulator(Sof& sof_a, long tag_a, const String& name_a) {  // read the instance of the object from the Sof file  //  if (!sof_a.find(name_a, tag_a)) {    return false;  }    // read the actual data from the sof file  //  if (!readAccumulatorData(sof_a)) {    return false;  }    // exit gracefully  //  return true;}// method: readAccumulatorData//// arguments://  Sof& sof: (input) sof file object//  const String& pname: (input) parameter name//  long size: (input) size in bytes of object (or full_size)//  boolean param: (input) is the parameter name in the file?//  boolean nested: (input) are we nested?//// return: a boolean value indicating status//// this method has the object read itself from an Sof file. it assumes// that the Sof file is already positioned correctly.//boolean GaussianModel::readAccumulatorData(Sof& sof_a, const String& pname_a,				     long size_a, boolean param_a,				     boolean nested_a) {  Integral::DEBUG debug_level = Integral::NONE;  SofParser parser;  parser.setDebug(debug_level);      // declare local variables  //  Double occ_accum;  Long access_accum;    VectorDouble mean_accum;    MatrixDouble covar_accum;    // are we nested?  //  if (nested_a) {    parser.setNest();  }    // load the parse  //  if (!parser.load(sof_a, size_a)) {    return Error::handle(name(), L"readData", Error::READ,			 __FILE__, __LINE__, Error::WARNING);  }	      // get the access count accumulator  //  if (!access_accum.readData(sof_a, PARAM_ACCESS_ACCUM,			     parser.getEntry(sof_a, PARAM_ACCESS_ACCUM))) {    return Error::handle(name(), L"readAccumData", Error::ARG, __FILE__, __LINE__);  }	        access_accum_d.add(access_accum);    // get the occupancy accumulator  //  if (!occ_accum.readData(sof_a, PARAM_OCCUPANCY_ACCUM,			  parser.getEntry(sof_a, PARAM_OCCUPANCY_ACCUM))) {    return Error::handle(name(), L"readAccumData", Error::ARG, __FILE__, __LINE__);  }  occ_accum_d.add(occ_accum);    // get the mean accumulator  //  if (!mean_accum.readData(sof_a, PARAM_MEAN_ACCUM,			   parser.getEntry(sof_a, PARAM_MEAN_ACCUM),			   false, false)) {    return Error::handle(name(), L"readAccumData", Error::ARG, __FILE__, __LINE__);  }  if (mean_accum_d.length() == mean_accum.length()) {    mean_accum_d.add(mean_accum);  }  else {    mean_accum_d.setLength(mean_accum.length());    mean_accum_d.add(mean_accum);  }    // get the covariance accumulator  //  if (!covar_accum.readData(sof_a, PARAM_COVARIANCE_ACCUM,			    parser.getEntry(sof_a, PARAM_COVARIANCE_ACCUM),			    true, true)) {    return Error::handle(name(), L"readAccumData", Error::ARG, __FILE__, __LINE__);  }  if ((covar_accum_d.getNumRows() == covar_accum.getNumRows()) &&      (covar_accum_d.getNumColumns() == covar_accum.getNumColumns())) {    covar_accum_d.add(covar_accum);  }  else {    covar_accum_d.setDimensions(covar_accum.getNumRows(),				covar_accum.getNumColumns());    covar_accum_d.add(covar_accum);      }    // exit gracefully  //  return true;    }// method: read//// arguments://  Sof& sof: (input) sof file object//  long tag: (input) sof object instance tag//  const String& name: (input) sof object instance name//// return: a boolean value indicating status//// this method has the object read itself from an Sof file//boolean GaussianModel::read(Sof& sof_a, long tag_a, const String& name_a) {  // read the instance of the object from the Sof file  //  if (!sof_a.find(name_a, tag_a)) {    return false;  }    // read the actual data from the sof file  //  if (!readData(sof_a)) {    return false;  }    // exit gracefully  //  return true;  }// method: readData//// arguments://  Sof& sof: (input) sof file object//  const String& pname: (input) parameter name//  long size: (input) size in bytes of object (or full_size)//  boolean param: (input) is the parameter name in the file?//  boolean nested: (input) are we nested?//// return: a boolean value indicating status//// this method has the object read itself from an Sof file. it assumes// that the Sof file is already positioned correctly.//boolean GaussianModel::readData(Sof& sof_a, const String& pname_a,				long size_a, boolean param_a,				boolean nested_a) {  Integral::DEBUG debug_level = Integral::NONE;  SofParser parser;  parser.setDebug(debug_level);      // ignore implicit parameter setting  //    // are we nested?  //  if (nested_a) {    parser.setNest();  }    // load the parse  //  if (!parser.load(sof_a, size_a)) {    return Error::handle(name(), L"readData", Error::READ,			 __FILE__, __LINE__, Error::WARNING);  }	      // get the vector of means  //  if (!mean_d.readData(sof_a, PARAM_MEAN,		       parser.getEntry(sof_a, PARAM_MEAN),		       false, false)) {    return Error::handle(name(), L"readData", Error::READ,			 __FILE__, __LINE__, Error::WARNING);  }	      // get the covariance matrix  //  if (!covariance_d.readData(sof_a, PARAM_COVARIANCE,			     parser.getEntry(sof_a, PARAM_COVARIANCE),			     true, true)) {    return Error::handle(name(), L"readData", Error::READ,			 __FILE__, __LINE__, Error::WARNING);  }  // save a copy of the value just read  //  orig_covar_d.assign(covariance_d);    // set the initialization flag  //  is_valid_d = false;  // call initialization method and exit gracefully  //  return init();}// method: readOccupancies//// arguments://  Sof& sof: (input) sof file object//  long tag: (input) sof object instance tag//  const String& name: (input) sof object instance name//// return: a boolean value indicating status//// this method has the object read occupancies from an Sof accumulator file//boolean GaussianModel::readOccupancies(Sof& sof_a, long tag_a, const String& name_a) {  // read the instance of the object from the Sof file  //  if (!sof_a.find(name_a, tag_a)) {    return false;  }    // read the actual data from the sof file  //  if (!readOccupanciesData(sof_a)) {    return false;  }    // exit gracefully  //  return true;}// method: readOccupanciesData//// arguments://  Sof& sof: (input) sof file object//  const String& pname: (input) parameter name//  long size: (input) size in bytes of object (or full_size)//  boolean param: (input) is the parameter name in the file?//  boolean nested: (input) are we nested?//// return: a boolean value indicating status//// this method has the object read itself from an Sof file. it assumes// that the Sof file is already positioned correctly.//boolean GaussianModel::readOccupanciesData(Sof& sof_a, const String& pname_a,					   long size_a, boolean param_a,					   boolean nested_a) {  Integral::DEBUG debug_level = Integral::NONE;  SofParser parser;  parser.setDebug(debug_level);      // declare local variables  //  Double occ_accum;    // are we nested?  //  if (nested_a) {    parser.setNest();  }    // load the parse  //  if (!parser.load(sof_a, size_a)) {    return Error::handle(name(), L"readData", Error::READ,			 __FILE__, __LINE__, Error::WARNING);  }	      // get the occupancy accumulator  //  if (!occ_accum.readData(sof_a, PARAM_OCCUPANCY_ACCUM,			  parser.getEntry(sof_a, PARAM_OCCUPANCY_ACCUM))) {    return Error::handle(name(), L"readAccumData", Error::ARG, __FILE__, __LINE__);  }  occ_accum_d.add(occ_accum);    // exit gracefully  //  return true;    }

⌨️ 快捷键说明

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