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

📄 sdb_02.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 2 页
字号:
  }  sdb.gotoNext();   // file11  sdb.gotoNext();   // file12  sdb.gotoNext();   // file2  sdb.gotoNext();   // file3  sdb.gotoNext();    // no output directory, existing non-sof extension -> use sof extension  //  sdb.getName(in_name);  if (in_name.ne(L"diagnose_file5.raw") ||      !sdb.transformName(out_name, in_name) ||      out_name.ne(L"diagnose_file5.sof")) {    in_name.debug(L"input");    out_name.debug(L"transformed");    return Error::handle(name(), L"transformName", Error::TEST,			 __FILE__, __LINE__);  }  // now specify an output_directory  //  line.assign(L"run_me.exe -out /tmp diagnose_file2.sof diagnose_file3.sof diagnose_file5.raw");  CommandLine cmdl1;  cmdl1.setSdb(sdb);  cmdl1.parse(line);  // with output directory, change directory  //  sdb.gotoFirst();  sdb.getName(in_name);    if (in_name.ne(L"diagnose_file2.sof") ||      !sdb.transformName(out_name, in_name) ||      out_name.ne(L"/tmp/diagnose_file2.sof")) {    in_name.debug(L"input");    out_name.debug(L"transformed");    return Error::handle(name(), L"transformName", Error::TEST,			 __FILE__, __LINE__);  }  sdb.gotoNext();  sdb.gotoNext();  sdb.getName(in_name);    if (in_name.ne(L"diagnose_file5.raw") ||      !sdb.transformName(out_name, in_name) ||      out_name.ne(L"/tmp/diagnose_file5.sof")) {    in_name.debug(L"input");    out_name.debug(L"transformed");    return Error::handle(name(), L"transformName", Error::TEST,			 __FILE__, __LINE__);  }  in_name.assign(L"-");  out_name.clear();  if ((!sdb.transformName(out_name, in_name)) ||      (out_name.ne(L"-"))) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }    // reset indention  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }      //---------------------------------------------------------------------------  //  // 4. class-specific methods:  //     binary file operations  //  //---------------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific methods: binary file methods...\n");    Console::increaseIndention();  }  // we need to copy a few text files to binary sof files  //  Sof sof_text;  Sof sof_bin;  Filename file_dmlb(L"diagnose_main_list_bin.sof");  Filename file_df4b(L"diagnose_file4_bin.sof");  File::registerTemp(file_dmlb);  File::registerTemp(file_df4b);  sof_text.open(L"diagnose_main_list.sof");  sof_bin.open(file_dmlb, File::WRITE_ONLY, File::BINARY);  sdb1.read(sof_text, 0);  // modify the list to point to the binary file4, not the text one  //  sdb1.files_d.gotoLast();  sdb1.files_d.getCurr()->first().assign(file_df4b);  sdb1.write(sof_bin, 0);  sof_text.close();  sof_bin.close();    sof_text.open(L"diagnose_file4.sof");  sof_bin.open(file_df4b, File::WRITE_ONLY, File::BINARY);  sdb1.read(sof_text, 0);  sdb1.write(sof_bin, 0);  sdb1.read(sof_text, 1);  sdb1.write(sof_bin, 1);  sdb1.read(sof_text, 9);  sdb1.write(sof_bin, 9);  sof_text.close();  sof_bin.close();  // now that we have files created, perform the same test  //  sdb2.clear();  sdb2.append(L"diagnose_main_list_bin.sof", true);  sdb2.append(L"diagnose_file5.sof");  if (!sdb2.sameFiles(sdb_ref)) {    return Error::handle(name(), L"iterate", Error::TEST, __FILE__, __LINE__);  }  // also test from the command line  //  line.assign(L"run_me.exe -list diagnose_file1.sof diagnose_file2.sof diagnose_file3.sof -list diagnose_file4_bin.sof diagnose_file5.sof");  cmdl.clear();  cmdl.setSdb(sdb2);  cmdl.parse(line);  if (!sdb2.sameFiles(sdb_ref)) {    sdb2.debug(L"main_list");    sdb_ref.debug(L"ref");    return Error::handle(name(), L"append", Error::TEST, __FILE__, __LINE__);  }    // reset indention  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }  //---------------------------------------------------------------------------  //  // 5. class-specific methods:  //     test that an Sdb object can reference itself  //  //---------------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific methods: self-referencing file...\n");    Console::increaseIndention();  }  // append our self-referencing file as a list  //  sdb2.clear();  sdb2.append(L"diagnose_self.sof", true);  if (!sdb2.getName(fn) || fn.ne(L"diagnose_self.sof")) {    return Error::handle(name(), L"append", Error::TEST, __FILE__, __LINE__);  }  // also test from the command line  //  line.assign(L"run_me.exe -list diagnose_self.sof");  cmdl.clear();  cmdl.setSdb(sdb2);  cmdl.parse(line);  if (!sdb2.getName(fn) || fn.ne(L"diagnose_self.sof")) {    return Error::handle(name(), L"append", Error::TEST, __FILE__, __LINE__);  }    // reset indention  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }  //---------------------------------------------------------------------------  //  // 6. class-specific methods:  //     get and set methods  //  //---------------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific methods: get and set methods...\n");    Console::increaseIndention();  }  // test getName methods  //  sdb.getName(in_name);    if (in_name.ne(L"diagnose_file5.raw")) {    in_name.debug(L"in_name");    return Error::handle(name(), L"getName", Error::TEST,			 __FILE__, __LINE__);  }  // get/setOutputExtension methods  //  String ext(L"mfc");  sdb.setOutputExtension(ext);  if (sdb.getOutputExtension().ne(ext)) {    return Error::handle(name(), L"getOutputExtension", Error::TEST,			 __FILE__, __LINE__);  }  // test get/setOutputDirectory  //  String out_dir(L"/tmp/out");  sdb.setOutputDirectory(out_dir);  if (sdb.getOutputDirectory().ne(out_dir)) {    return Error::handle(name(), L"getOutputDirectory", Error::TEST,			 __FILE__, __LINE__);  }  // test get/setDirPresLevel  //  long dir_pres = 3;  sdb.setDirPresLevel(dir_pres);    if (sdb.getDirPresLevel() != dir_pres) {    return Error::handle(name(), L"getDirPresLevel", Error::TEST,			 __FILE__, __LINE__);  }      // reset indention  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }      //---------------------------------------------------------------------------  //  // 7. class-specific public methods: query methods  //  //---------------------------------------------------------------------------  // set indentation  //  if (level_a > Integral::NONE) {    Console::put(L"testing class-specific methods: get and set methods...\n");    Console::increaseIndention();  }    // test the isSdb function  //  fn.assign(L"diagnose_file1.sof");  if (!isSdb(fn)) {    return Error::handle(name(), L"isSdb", Error::TEST, __FILE__, __LINE__);  }        fn.assign(L"diagnose_file2.sof");  if (isSdb(fn)) {    return Error::handle(name(), L"isSdb", Error::TEST, __FILE__, __LINE__);  }  // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    //---------------------------------------------------------------------------  //  // 8. print completion message  //  //---------------------------------------------------------------------------  // reset indentation  //  if (level_a > Integral::NONE) {    Console::decreaseIndention();  }    if (level_a > Integral::NONE) {    String output(L"diagnostics passed for class ");    output.concat(name());    output.concat(L"\n");    Console::put(output);  }  // exit gracefully  //  return true;}// method: sameFiles//// arguments://  Sdb& arg: (input) sdb object to compare//// return: a boolean value indicating whether the lists are equivalent//boolean Sdb::sameFiles(Sdb& arg_a) {  // reset the objects: make sure they have the same return value. if  // they both fail on gotoFirst, it means they are both empty lists  // and hence equivalent.  //  boolean n0 = gotoFirst();  boolean n1 = arg_a.gotoFirst();  Long num_compared = 0;  // if they have different return values, one is empty and the other  // isn't.  //  if (n0 ^ n1) {    if (debug_level_d >= Integral::DETAILED) {      num_compared.debug(L"number compared");    }    return false;  }  Filename fn0;  Filename fn1;  if (n0) {    num_compared += 1;  }  // loop while they have files (note n0 must equal n1 or the if  // branches will return false  //  while (n0) {    // extract the current filenames    //    if (!getName(fn0)) {      return Error::handle(name(), L"sameFiles", ERR, __FILE__, __LINE__);    }    if (!arg_a.getName(fn1)) {      return Error::handle(name(), L"sameFiles", ERR, __FILE__, __LINE__);    }    // compare the filenames, possibly provide debug information if they differ    //    if (fn0.ne(fn1)) {      if (debug_level_d >= Integral::DETAILED) {	fn0.debug(L"fn0");	fn1.debug(L"fn1");	num_compared.debug(L"number compared");      }      return false;    }    n0 = gotoNext();    n1 = arg_a.gotoNext();    num_compared += 1;        // if they have different return values, one is out of files and    // the other isn't.    //    if (n0 ^ n1) {      if (debug_level_d >= Integral::DETAILED) {	num_compared.debug(L"number compared");      }      return false;    }  }  if (debug_level_d >= Integral::DETAILED) {    num_compared -= 1;    num_compared.debug(L"number compared");  }  // exit gracefully  //  return true;}

⌨️ 快捷键说明

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