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

📄 rcp_05.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 3 页
字号:
      Component* algo = dcomp_a(i).getCurr();	          long trailing_pad = (long)Integral::max(algo->getTrailingPad(), 0);            long num_inputs = algo->getNumInputs();      for (long j = 0; j < num_inputs; j++) {		buf_a.setLengthToMax(algo->getInputName(j),			     needed_size + trailing_pad + 1);      }    }  }  if (debug_level_d >= Integral::ALL) {    buf_a.getLength().debug(L"coef_length, step B");  }    // process delays  //  Vector<String> keys;  buf_a.getLength().keys(keys);    for (long i = keys.length() - 1; i >= 0; i--) {    long delay = buf_a.getLength(keys(i));        if (debug_level_d >= Integral::ALL) {      Long d(delay);      d.debug((unichar*)keys(i));    }    if ((delay < 0) || (delay > 999999)) {      keys(i).debug(L"this has negative delay");      return Error::handle(name(), L"delayComponent",			   Error::ARG, __FILE__, __LINE__);    }    buf_a.getBuffer(keys(i))(0).setCapacity(2 * delay + 1);  }    if (debug_level_d >= Integral::DETAILED) {    buf_a.getLength().debug(L"buf_d.length_d");  }    // exit gracefully  //  return true;}// method: readGraph//// arguments://  Sof& sof: (input) sof file object//  long graph_tag: (input) tag of graph//// return: a boolean value indicating status//// this method reads in the Component graph from the input file. the// input file should contain a DiGraph<Long> for all the graph// connections, each long is an index to an Algorithm object in the// file.//boolean Recipe::readGraph(Sof& sof_a, long graph_tag_a) {  // declare local variables  //  DiGraph<Long> index_graph;  SingleLinkedList<Component> algos(DstrBase::USER);  // first read the graph that defines the connections  //  if (!index_graph.read(sof_a, graph_tag_a)) {    return Error::handle(name(), L"readGraph",			 Error::READ, __FILE__, __LINE__, Error::WARNING);  }  // declare space to hold the graph  //  SingleLinkedList<Long> node_indices(DstrBase::USER);  SingleLinkedList< Triple< Pair<Long, Long>, Float, Boolean> > topo;  index_graph.get(node_indices, topo);  // sanity check -- the nodes should be consecutive integers  //  long count = 0;  for (boolean m = node_indices.gotoFirst(); m; m = node_indices.gotoNext()) {    if (node_indices.getCurr()->ne(count++)) {      return Error::handle(name(), L"readGraph", ERR, __FILE__, __LINE__);    }  }  // boolean values to represent if the node has parents  //  boolean no_parents[count + 1];    for (long i = 0; i < count + 1; i++) {    no_parents[i] = true; // initialization to no parents  }    // iterate over all vertices in the list to test if a node has parents  //  for (boolean more = topo.gotoFirst(); more;  more = topo.gotoNext()) {    // retrieve the destination vertex position of the current arc    // the node located in second place always has parents    //    Long dst_pos = topo.getCurr()->first().second();    no_parents[(long)dst_pos] = false;  }  // provide some debug information   //  if (debug_level_d > Integral::BRIEF) {    // declare local variables    //    String value;    for (long i = 0; i < count; i++) {      if (no_parents[i]) {	value.assign(i);	value.assign(L"node #");	value.concat(i);	value.concat(L": (**no** parent)");	Console::put(value);      }      else {	value.assign(i);	value.assign(L"node #");	value.concat(i);	value.concat(L": (parents exist)");	Console::put(value);        }    }        Console::put(L"\n");  }  // boolean values to represent if the node has a child  //  boolean no_child[count + 1];    for (long i = 0; i < count + 1; i++)    no_child[i] = true; // initialization to no child     // iterate over all vertices in the list to test if a node has a child  //  for (boolean more = topo.gotoFirst(); more;  more = topo.gotoNext()) {        // retrieve the destination vertex position of the current arc    // the node located in first place always has a child    //    Long dst_pos = topo.getCurr()->first().first();    no_child[(long)dst_pos] = false;  }    // print out debug information   //  if (debug_level_d > Integral::BRIEF) {    // declare local variables    //    String value;    for (long i = 0; i < count; i++) {      if (no_child[i]) {	value.assign(i);	value.assign(L"node #");	value.concat(i);	value.concat(L": (**no** child)");	Console::put(value);      }      else {	value.assign(i);	value.assign(L"node #");	value.concat(i);	value.concat(L": (children exist)");	Console::put(value);        }    }        Console::put(L"\n");  }  // count how many end points in the graph  //  long number_no_child = 0;  for (long i = 0; i < count; i++) {    if (no_child[i]) {      number_no_child++;    }  }    // now read in the Algorithms themselves -- put them into a  // hashtable based on the tag number.  //  for (boolean m = node_indices.gotoFirst(); m; m = node_indices.gotoNext()) {    // declare a pointer to the current algorithm    //    long tag = *(node_indices.getCurr());    Algorithm algo;    if (!algo.read(sof_a, tag)) {      return Error::handle(name(), L"readGraph", Error::READ, __FILE__,			   __LINE__, Error::WARNING);    }    Component* recipe = new Component();    recipe->setAlgorithm(algo);    algos.insertLast(recipe);  }    // add one node as dummy output point  //  Component* recipeA = new Component();  Algorithm algo;  if (number_no_child == 1) {    algo.setType(Algorithm::COEFFICIENT_LABEL);  }  else {    algo.setType(Algorithm::CONNECTION);  }    recipeA->setAlgorithm(algo);  String str(DUMMY_OUTPUT_NAME);  recipeA->setOutputName(str);    algos.insertLast(recipeA);    // link all the end points to dummy output point  //  float delay = 0.0;    for (long i = 0; i < count; i++) {    if (no_child[i]) {            Float float_00(delay);      Boolean bool_00(false);      Pair<Long, Long> pair_00(i, count);      Triple< Pair<Long, Long>, Float, Boolean>	triple(pair_00, float_00, bool_00);      topo.insert(&triple);      delay += 1;    }  }      no_parents[count] = false;    // now create the Component graph  //  recipe_d.clear();    recipe_d.setAllocationMode(DstrBase::USER);  recipe_d.assign(algos, topo);    // now expand the sub-graphs  //  while (expandSubGraphs(sof_a));  recipe_d.setAllocationMode(DstrBase::SYSTEM);    algos.clear();  topo.clear();    recipe_d.get(algos, topo);    // reorganize the node status after read the sub graph  //  count = 0;  for (boolean m = algos.gotoFirst(); m; m = algos.gotoNext()) {    count++;  }    for (long i = 0; i < count; i++) {    no_parents[i] = true; // initialization to no parents  }    // iterate over all vertices in the list to test if a node has parents  //  for (boolean more = topo.gotoFirst(); more;  more = topo.gotoNext()) {        // retrieve the destination vertex position of the current arc    // the node located in second place always has parents    //    Long dst_pos = topo.getCurr()->first().second();    no_parents[(long)dst_pos] = false;  }    // provide some debug information   //  if (debug_level_d > Integral::BRIEF) {    // declare local variables    //    String value;    for (long i = 0; i < count; i++) {      if (no_parents[i]) {	value.assign(i);	value.assign(L"node #");	value.concat(i);	value.concat(L": (**no** parent)");	Console::put(value);      }      else {	value.assign(i);	value.assign(L"node #");	value.concat(i);	value.concat(L": (parents exist)");	Console::put(value);        }    }        Console::put(L"\n");  }  // to check if the number of input for components is correct  //  if (!checkInputs()) {    return Error::handle(name(), L"readGraph", ERR, __FILE__, __LINE__);  }  // set the color  //  recipe_d.makeColorHash(Integral::WHITE);  // search for input file type   //  long node_count = 0;  String dummy_input_point;    for (boolean m = recipe_d.gotoFirst(); m;       m = recipe_d.gotoNext()) {    Component* rcp = (Component*)(recipe_d.getCurr()->getItem());        if (no_parents[node_count] &&	rcp->getAlgorithm().getType() == Algorithm::COEFFICIENT_LABEL) {            CoefficientLabel::TYPE ctype = rcp->getAlgorithm().getCLabelType();      if (ctype == CoefficientLabel::INPUT) {	dummy_input_point.assign(rcp->getAlgorithm().getCLabelVariable());	if (dummy_input_point.length() > 0) {	  dummy_input_point.insert(INPUT_PREFIX, 0);	}      }    }    node_count++;  }  node_count = 0;    // now mark all data buffers as black and set the input and output names  //  for (boolean m = recipe_d.gotoFirst(); m;       m = recipe_d.gotoNext()) {    Component* rcp = (Component*)(recipe_d.getCurr()->getItem());        if (no_parents[node_count] &&	rcp->getAlgorithm().getType() != Algorithm::COEFFICIENT_LABEL) {      recipe_d.setColor(recipe_d.getCurr(), Integral::BLACK);      if (dummy_input_point.length() > 0) {	rcp->setInputName(0, dummy_input_point);      }      else {	String str(SAMPLED_DATA_NAME);	rcp->setInputName(0, str);      }    }        if (rcp->getAlgorithm().getType() == Algorithm::COEFFICIENT_LABEL) {      recipe_d.setColor(recipe_d.getCurr(), Integral::BLACK);      CoefficientLabel::TYPE ctype = rcp->getAlgorithm().getCLabelType();      if (ctype != CoefficientLabel::OUTPUT) {	String str(rcp->getAlgorithm().getCLabelVariable());	if (str.length() > 0) {	  str.insert(INPUT_PREFIX, 0);	  rcp->setInputName(0, str);	}      }            if (ctype != CoefficientLabel::INPUT) {	String str(rcp->getAlgorithm().getCLabelVariable());	if (str.length() > 0) {	  str.insert(OUTPUT_PREFIX, 0);	  rcp->setOutputName(str);	}      }    }    node_count++;  }  // loop through and move input & output names from the data buffers  //  for (boolean m = recipe_d.gotoFirst(); m; m = recipe_d.gotoNext()) {

⌨️ 快捷键说明

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