Logo Search packages:      
Sourcecode: ktechlab version File versions  Download package

double ElementSignal::advance ( double  delta  )  [inherited]

Advances the timer, returns amplitude (between -1 and 1)

Definition at line 33 of file elementsignal.cpp.

Referenced by time_step(), and CurrentSignal::time_step().

{
      m_time += delta;
      if ( m_time >= 1./m_frequency ) m_time -= 1./m_frequency;
      
      switch (m_type)
      {
      case ElementSignal::st_sawtooth:
      {
            double val = (m_time * m_omega / M_PI);
            return 1 - remainder(val,2);
      }
      case ElementSignal::st_square:
            return (((int)trunc(m_time*m_omega/M_PI) & 1) == 0)?1:-1;
      case ElementSignal::st_triangular:
            // TODO Triangular signal
            return 0.;
      case ElementSignal::st_sinusoidal:
      default:
            return sin(m_time*m_omega);
      }
}


Generated by  Doxygen 1.6.0   Back to index