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

📄 ftrf_09.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
字号:
// file: $isip/class/mmedia/FeatureFile/ftrf_09.cc// version: $Id: ftrf_09.cc,v 1.4 2002/07/16 16:41:40 gao Exp $//// isip include files//#include "FeatureFile.h"// method: readSofData//// arguments://  Vector<AlgorithmData>& data: (output) the audio data//  long start_pos: (input) the start index of the features data//  long num_elem: (input) the number of features data//  // return: number of features read//// this method gets data from an Sof file and returns each// channel as a VectorFloat.//long FeatureFile::readSofData(Vector<AlgorithmData>& data_a,			      long start_pos_a, long num_elem_a) {    // read from sof file  //  if (file_format_d != SOF) {    Error::handle(name(), L"readSofData", ERR, __FILE__, __LINE__);    return -1;  }  // read the data  //  readPartialData(start_pos_a, num_elem_a);  // loop over all elements  //  long len = v_d.length();  data_a.setLength(len);  for (long i = 0; i < len; i++) {        // transfer the data    //    data_a(i).makeVectorFloat().setLength(v_d(i).getVectorFloat().length());       for (long j = 0; j < v_d(i).getVectorFloat().length(); j++) {      data_a(i).getVectorFloat()(j) = v_d(i).getVectorFloat()(j);    }  }    // return the number of samples read  //  return len;}// method: writeSofData//// arguments://  Vector<AlgorithmData>& data: (input) the audio data to write//  long ctag: (input) channel tag//  // return: the number of elements written//// this method writes audio data to an Sof file.//long FeatureFile::writeSofData(Vector<AlgorithmData>& data_a,			       long ctag_a) {    // check the format  //  if (file_format_d != SOF) {    return Error::handle(name(), L"writeSofData", ERR, __FILE__, __LINE__);  }  // loop over all elements  //  long len = data_a.length();  v_d.setLength(len);  for (long i = 0; i < len; i++) {    // transfer the data    //    v_d(i).makeVectorFloat().setLength(data_a(i).getVectorFloat().length());       for (long j = 0; j < data_a(i).getVectorFloat().length(); j++) {      v_d(i).getVectorFloat()(j) = data_a(i).getVectorFloat()(j);    }  }    // write the data  //  writePartialData(0, len);    // exit gracefully  //  return len;}// method: readSofData//// arguments://  Vector<VectorFloat>& data: (output) the audio data//  long ctag: (input) channel index//  long start_pos: (input) the start index of the features data//  long num_elem: (input) the number of features data//  // return: number of features read//// this method gets data from an Sof file and returns each// channel as a VectorFloat.//long FeatureFile::readSofData(Vector<VectorFloat>& data_a, long ctag_a,			      long start_pos_a, long num_elem_a) {    // read from sof file  //  if (file_format_d != SOF) {    Error::handle(name(), L"readSofData", ERR, __FILE__, __LINE__);    return -1;  }  // read the data  //  readPartialData(start_pos_a, num_elem_a);  // loop over all elements  //  long len = v_d.length();  data_a.setLength(len);  for (long i = 0; i < len; i++) {        // transfer the data    //    data_a(i).setLength(v_d(i).getVectorFloat().length());       for (long j = 0; j < v_d(i).getVectorFloat().length(); j++) {      data_a(i)(j) = v_d(i).getVectorFloat()(j);    }  }    // return the number of samples read  //  return len;}// method: writeSofData//// arguments://  Vector<VectorFloat>& data: (input) the audio data to write//  long ctag: (input) channel tag//  // return: the number of elements written//// this method writes the audio data to an Sof file.//long FeatureFile::writeSofData(Vector<VectorFloat>& data_a,			       long ctag_a) {    // check the format  //  if (file_format_d != SOF) {    return Error::handle(name(), L"writeSofData", ERR, __FILE__, __LINE__);  }  // loop over all the elements  //  long len = data_a.length();  v_d.setLength(len);  for (long i = 0; i < len; i++) {    // transfer the data    //    v_d(i).makeVectorFloat().setLength(data_a(i).length());       for (long j = 0; j < data_a(i).length(); j++) {      v_d(i).getVectorFloat()(j) = data_a(i)(j);    }  }    // write the data  //  writePartialData(0, len);    // exit gracefully  //  return len;}// method: readSofStart//// arguments: none//  // return: a boolean value indicating status//// this method initializes reading of data from an Sof file.//boolean FeatureFile::readSofStart() {      if (!read(in_sof_d, tag_d)) {    return Error::handle(name(), L"readSofStart",			 Error::READ, __FILE__, __LINE__, Error::WARNING);  }  if (file_format_d != SOF) {    return Error::handle(name(), L"readSofStart",			 Error::READ, __FILE__, __LINE__, Error::WARNING);  }    if (no_data_d) {    return Error::handle(name(), L"readSofStart",			 Error::READ, __FILE__, __LINE__);  }    // save the object size from the temporary placeholder  //  long object_size = sof_length_pos_d;  // now set the sof_length_pos_d flag to the start of the object  //  sof_length_pos_d = in_sof_d.tell();    // start the read  //  Vector <VectorFloat> vec;    if (!vec.readStart(in_sof_d, PARAM_DATA, object_size, false, false)) {    return Error::handle(name(), L"readSofStart", Error::READ,			 __FILE__, __LINE__, Error::WARNING);  }    // exit gracefully  //  return true;}// method: writeSofStart//// arguments: none//  // return: a boolean value indicating status//// this method initializes writing of data to an Sof file.//boolean FeatureFile::writeSofStart() {    // write the object configuration to the Sof file.  //  if (!write(in_sof_d, tag_d)) {    return Error::handle(name(), L"writeSofStart", Error::WRITE,			 __FILE__, __LINE__);  }  // initialize sof pointers  //  boolean status;    // now write a zero-length vector to the file  //  Vector<VectorFloat> vec(1);  status = vec.writeStart(in_sof_d, PARAM_DATA);  // set the sof pointers  //  sof_length_pos_d = in_sof_d.getStartPos();  // exit gracefully  //  return status;}

⌨️ 快捷键说明

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