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

📄 ssrch_11.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 3 页
字号:
  return true;}// method: propagateTracesUp//// arguments://  long level_num: (input) the level for which we will propagate traces//  DoubleLinkedList<Trace>* top_list: (output) traces that reached top level//// return: logical error status. if no propagations were made then return false//// propagate all traces up. only traces at the end of a subgraph are considered//boolean StackSearch::propagateTracesUp(long level_num_a,		       DoubleLinkedList<Trace>* top_list_a) {  // define local variables  //  boolean status = false;  boolean end_loop = false;  Trace* curr_trace = (Trace*)NULL;  Trace* tmp_trace = (Trace*)NULL;  Trace* next_trace = (Trace*)NULL;      History* curr_history = (History*)NULL;  GraphVertex<SearchNode>* curr_vert = (GraphVertex<SearchNode>*)NULL;  GraphVertex<SearchNode>* tmp_vert = (GraphVertex<SearchNode>*)NULL;  Context useless;  // output the debugging information  //  if (debug_level_d >= Integral::ALL) {    String output(L"propagating traces up from level: ");    output.concat(level_num_a); output.concat(L" in frame: ");    output.concat(current_frame_d);    Console::put(output);  }    // make sure there is at least one trace to propagate  //  if (trace_lists_d(level_num_a).length() < 1) {    return false;  }    // loop over all current traces and create the next level's traces. all new  // traces will go at the end of the list so we set the mark to tell us when  // to stop propagating  //  trace_lists_d(level_num_a).gotoLast();  trace_lists_d(level_num_a).setMark();  trace_lists_d(level_num_a).gotoFirst();    while (!end_loop) {        // loop until we reached the marked element    //    end_loop = trace_lists_d(level_num_a).isMarkedElement();        // get the current first trace from the list    //    trace_lists_d(level_num_a).removeFirst(curr_trace);        // if the trace is inactive then delete it and its backpath if necessary    //    if (!curr_trace->isActive()) {      Trace::deleteTrace(curr_trace, true);    }        // else, extend paths and update scores    //    else {            // get the current vertex in the search graph      //      curr_history = curr_trace->getHistory();      if (curr_history->length() == 0) {	String out(L"zero history length for trace: ");	out.concat(curr_trace);	Console::put(out);      }      curr_vert = curr_history->peek()->getCentralVertex();            // if this vertex is a terminal vertex then ascend and create the traces      // at the higher level      //      if (curr_vert->isTerm()) {		// set the status to true since we are propagating a trace	//	status = true;	// if we are at the top level then put the trace into the valid	// hypothesis list	//	if (level_num_a == 0) {	  if (top_list_a != NULL) {	    top_list_a->insertLast(curr_trace);	  }	  else {	    valid_hyps_d.insertLast(curr_trace);	  }	}		// else move up one level and create the next set of traces	//	else {	  	  // create a new trace, 	  //	  next_trace = new Trace(*curr_trace);	  next_trace->setFrame((ulong)current_frame_d);	  next_trace->setBackPointer(curr_trace);		  // decrement the history of the new trace	  //	  if (!next_trace->getHistory()->isEmpty()) {	    next_trace->getHistory()->pop(&useless);	  }	  if (debug_level_d >= Integral::ALL) {	    printNewPath(next_trace, curr_trace);	  }			  // propagate all paths we can move to from this higher level trace	  //	  tmp_vert = next_trace->getHistory()->peek()->getLastVertex();	  // if the vertex to propagate from is terminal, generate one trace,	  // history will be shifted	  //	  if (tmp_vert->isTerm()) {	    // create a temporary trace	    //	    tmp_trace = new Trace(*next_trace);	    tmp_trace->setFrame((ulong)current_frame_d);	    // shift the history and set the backpointer	    //	    tmp_trace->getHistory()->peek()->assignAndAdvance((ulong)tmp_vert);	    tmp_trace->setBackPointer(next_trace);	    // add the trace to this level's trace list (or top list)	    //	    if ((level_num_a - 1 == 0) && (top_list_a != NULL)) {	      top_list_a->insertLast(tmp_trace);	    }	    else {	      trace_lists_d(level_num_a - 1).insertLast(tmp_trace);	    }	    // print the debugging information	    //	    if (debug_level_d >= Integral::ALL) {	      printNewPath(tmp_trace, next_trace);	    }	  }	  // vertex to propagate from is not terminal	  //	  else {	    // generate traces to all next vertices	    //	  	    for (boolean more_paths = tmp_vert->gotoFirst(); more_paths;		 more_paths = tmp_vert->gotoNext()) {	      	      // create a new trace, we store the extra trace so we	      // can later view the scores as they are added. this can	      // be changed later for efficiency	      //	      tmp_trace = new Trace(*next_trace);	      tmp_trace->setFrame((ulong)current_frame_d);	      	      // update the score with the arc score	      //	      GraphArc<SearchNode>* tmp_arc = tmp_vert->getCurr();	      float tmp_score = tmp_trace->getScore() + tmp_arc->getWeight();	      tmp_trace->setScore(tmp_score);	    	      // change the history	      //	      tmp_trace->getHistory()->peek()->		assignAndAdvance((ulong)tmp_arc->getVertex());	      	      // add the trace to the search node's trace list	      //	      Trace* existing_trace = (Trace*)NULL;	    	      SearchNode* next_node = tmp_trace->getHistory()->peek()->		getCentralVertex()->getItem();	      	      if (next_node->addTrace(tmp_trace, current_frame_d,				      existing_trace)) {				// update the maximal trace score for the beam pruning		//		if (getSearchLevel(level_num_a - 1).useBeam()		    && (tmp_score > max_frame_scores_d(current_frame_d, 						       level_num_a - 1)) ) {		  		  if (debug_level_d >= Integral::DETAILED) {		    		    // print the debugging information		    //		    String output(L"fr:");		    output.concat(current_frame_d);		    output.concat(L" lv:");		    output.concat(level_num_a - 1);		    output.concat(L" max_sc updt (going to higher level YES) ");		    output.concat(max_frame_scores_d(current_frame_d, 						     level_num_a - 1));		    output.concat(L"->");		    output.concat(tmp_score);		    Console::put(output);		  }		  		  // update the maximal trace score		  //		  max_frame_scores_d.setValue(current_frame_d, level_num_a - 1,					      tmp_score);		}	      		// set the backpointer		//		tmp_trace->setBackPointer(next_trace);				// add the trace to the higher level's trace list (or top list)		//		if ((level_num_a - 1 == 0) && (top_list_a != NULL)) {		  top_list_a->insertLast(tmp_trace);		}		else {		  trace_lists_d(level_num_a - 1).insertLast(tmp_trace);		}		if (debug_level_d >= Integral::ALL) {		  printNewPath(tmp_trace, next_trace);		}	      }	      else {	      		// delete the trace since there is existing trace -		// same history		//		if (debug_level_d >= Integral::ALL) { 		  printDeletedPath(tmp_trace, next_trace);		}	  	      		delete tmp_trace;	      }	    }	  }	  	  // delete next_trace if no traces propagated from it have survived	  //	  if (next_trace->getRefCount() < 1) {	    Trace::deleteTrace(next_trace, false);	  }	}		// bump the current trace off of the trace list	//	if (curr_trace->getRefCount() < 1) {	  	  // if this is at top level, we can not delete them since they	  // are also referenced by the valid_hyps	  //	  if (level_num_a != 0) {	    Trace::deleteTrace(curr_trace, true);	  }	}	trace_lists_d(level_num_a).gotoFirst();      }            // if this trace is not at the end of a subgraph then keep it on this      // level      //      else {		float curr_score = curr_trace->getScore();	// update the maximal trace score for the beam pruning	//	if (getSearchLevel(level_num_a).useBeam()	    && (curr_score > max_frame_scores_d(current_frame_d, level_num_a))	    ) {	  if (debug_level_d >= Integral::DETAILED) {	    // print the debugging information	    //	    String output(L"fr:");	    output.concat(current_frame_d);	    output.concat(L" lv:");	    output.concat(level_num_a);	    output.concat(L" max_sc updt (going to higher level NO ) ");	    output.concat(max_frame_scores_d(current_frame_d, level_num_a));	    output.concat(L"->");	    output.concat(curr_score);	    Console::put(output);	  }	  // update the maximal trace score	  //	  max_frame_scores_d.setValue(current_frame_d, level_num_a,				      curr_score);	}      	// keep the trace on this level	//	trace_lists_d(level_num_a).insertLast(curr_trace);	trace_lists_d(level_num_a).gotoFirst();      }    }  }    // exit gracefully  //  return status;}// method: propagateTracesDown//// arguments://  long level_num: (input) the level for which we will propagate traces//// return: logical error status. if no propagations were made then return false//// propagate all traces down. any traces that are at the end of a subgraph are// discarded.//boolean StackSearch::propagateTracesDown(long level_num_a) {  // define local variables  //  Trace* curr_trace = (Trace*)NULL;  Trace* next_trace = (Trace*)NULL;      GraphVertex<SearchNode>* curr_vert = (GraphVertex<SearchNode>*)NULL;  GraphVertex<SearchNode>* tmp_vert = (GraphVertex<SearchNode>*)NULL;  float score = 0.0;  SearchSymbol item;  boolean status = false;  // output the debugging information  //  if (debug_level_d >= Integral::ALL) {    String output;            output.assign(L"propagating traces down from level: ");    output.concat(level_num_a);    output.concat(L" in frame: ");        output.concat(current_frame_d);    Console::put(output);  }  // make sure there is at least one trace to propagate  //  if (trace_lists_d(level_num_a).length() < 1) {    return false;  }  // switch on whether we are at the lowest level or not  //  // if we are not at the lowest level, push traces down the hierarchy -  // there should be no traces left at this level when we are done  //  trace_lists_d(level_num_a).gotoFirst();    if (level_num_a != getNumLevels() - 1) {

⌨️ 快捷键说明

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