Exemple #1
0
/** Create graphviz representation of this flograph.
 *  @param s is a string in which result is to be returned
 *  @return a reference to s
 */
string& Wflograph::toDotString(string& s) const {
	int i; vertex u; edge e;
	stringstream ss;
	ss << "digraph G { " << endl;
        ss << Util::node2string(src(),n(),s) 
           << " [ style = bold, peripheries = 2, color = red]; "
           << endl;
	ss << Util::node2string(snk(),n(),s) 
           << " [ style = bold, peripheries = 2, color = blue]; "
           << endl;
	for (u = 1; u <= n(); u++) {
                string su;
		for (e = firstOut(u); e != 0; e = nextOut(u,e)) {
                        vertex u = tail(e); vertex v = head(e);
                        if (e != 0) {
                                string s1;
                                su += Util::node2string(u,N,s1) + " -> "; 
                                s1.clear();
                                su += Util::node2string(v,N,s1); 
                                s1.clear(); su += " [label = \" ";
                                su += "(" + Util::num2string(cap(u,e),s1); 
                                s1.clear();
                                su += "," + Util::num2string(f(u,e),s1); 
                                s1.clear();
                                su += "," + Util::num2string(cost(u,e),s1) 
                                        +  ") \"];"; 
                        }
                }
                if (!su.empty())   ss << su << endl;
	}
	ss << " } " << endl;
	s = ss.str();
	return s;
}
StkFloat DelayL :: computeSample( StkFloat input )
{
  inputs_[inPoint_++] = input;

  // Increment input pointer modulo length.
  if (inPoint_ == inputs_.size())
    inPoint_ = 0;

  outputs_[0] = nextOut();
  doNextOut_ = true;

  // Increment output pointer modulo length.
  if (++outPoint_ == inputs_.size())
    outPoint_ = 0;

  return outputs_[0];
}
Exemple #3
0
float tick(float sample)
{
	float output_sample;
  delayed_samples[inPoint++] = sample;

  // Increment input pointer modulo length.
  if (inPoint == length)
    inPoint -= length;

  output_sample = nextOut();
  doNextOut = 1;

   // Increment output pointer modulo length.
  if (++outPoint >= length)
    outPoint -= length;

  return output_sample;
}
  // -----------------------------------------
  // IEstimator implementation
  // -----------------------------------------
  Output MovingAverage::estimate (Input next)
  {
    // push the data into the queue
    in.push_front(next);
    
    // check if queue has enough elements to estimate the average with
    // the specified windowSize
    if (in.size() >= windowSize) {
      // apply filter formula
      // y[n] = sum_k a_k y[n-k] + sum_k b_k x[n-k]
      double y = b[0] * in[0].getValue();
      for (int i = 1; i < windowSize; i++) {
	// in[0] ... front/new, in[windowSize-1] ... back/old
	y += a[i-1] * out[i-1].getValue() + b[i] * in[i].getValue();
      }
      // normalization
      if (isIIR)
	y /= 2;

      // prepare output value (new estimate)
      OutputValue estimate(y,
			   -1,
			   0);
      out.push_front(Output(estimate));

      // delete oldest element for the next estimation
      in.pop_back();
      out.pop_back();
    } else {
      // for the first #window-size elements do: set output as output
      // with single entity (OutputValue nextOut) = input (InputValue next)
      OutputValue nextOut(next[0].getValue(),
			  -1,
			  0);
      out.push_front(Output(nextOut));
    }
    
    return out.front();
  }