예제 #1
0
      /**
       * Called when the current state has finished and is ready to transition
       * into the next state
       */
      void StateComplete(int state = -1)
      {
        _round->BeforeStateTransition(); 
        Log tmp = _next_state_log;
        _next_state_log = Log();

        if((_cycle_state == GetCurrentState()->GetState()) && (state == -1)) {
          qDebug() << "In" << _round->ToString() << "ending phase";
          if(!_round->CycleComplete()) {
            return;
          }
          _log = Log();
          IncrementPhase();
        }

        if(state == -1) {
          qDebug() << "In" << _round->ToString() << "ending:" <<
            StateToString(GetCurrentState()->GetState()) <<
            "starting:" << StateToString(GetNextState()->GetState());
          _current_sm_state = GetNextState();
        } else {
          qDebug() << "In" << _round->ToString() << "ending:" <<
            StateToString(GetCurrentState()->GetState()) <<
            "starting:" << StateToString(_states[state]->GetState());
          _current_sm_state = _states[state];
        }

        (_round->*GetCurrentState()->GetTransitionCallback())();

        for(int idx = 0; idx < tmp.Count(); idx++) {
          QPair<QByteArray, Id> entry = tmp.At(idx);
          ProcessData(entry.second, entry.first);
        }
      }
예제 #2
0
  void ComputeSine(float * aOutput, TrackTicks ticks, uint32_t aStart, uint32_t aEnd)
  {
    for (uint32_t i = aStart; i < aEnd; ++i) {
      UpdateParametersIfNeeded(ticks, i);

      aOutput[i] = sin(mPhase);

      IncrementPhase();
    }
  }
예제 #3
0
 void ComputeSquare(float * aOutput, TrackTicks ticks, uint32_t aStart, uint32_t aEnd)
 {
   for (uint32_t i = aStart; i < aEnd; ++i) {
     UpdateParametersIfNeeded(ticks, i);
     // Integration to get us a square. It turns out we can have a
     // pure integrator here.
     mSquare += BipolarBLIT();
     aOutput[i] = mSquare;
     // maybe we want to apply a gain, the wg has not decided yet
     aOutput[i] *= 1.5;
     IncrementPhase();
   }
 }
예제 #4
0
  void ComputeSawtooth(float * aOutput, TrackTicks ticks, uint32_t aStart, uint32_t aEnd)
  {
    float dcoffset;
    for (uint32_t i = aStart; i < aEnd; ++i) {
      UpdateParametersIfNeeded(ticks, i);
      // DC offset so the Saw does not ramp up to infinity when integrating.
      dcoffset = mFinalFrequency / mSource->SampleRate();
      // Integrate and offset so we get mAmplitudeAtZero sawtooth. We have a
      // very low frequency component somewhere here, but I'm not sure where.
      mSaw += UnipolarBLIT() - dcoffset;
      // reverse the saw so we are spec compliant
      aOutput[i] = -mSaw * 1.5;

      IncrementPhase();
    }
  }
예제 #5
0
  void ComputeTriangle(float * aOutput, TrackTicks ticks, uint32_t aStart, uint32_t aEnd)
  {
    for (uint32_t i = aStart; i < aEnd; ++i) {
      UpdateParametersIfNeeded(ticks, i);
      // Integrate to get a square
      mSquare += BipolarBLIT();
      // Leaky integrate to get a triangle. We get too much dc offset if we don't
      // leaky integrate here.
      // C6 = k0 / period
      // (period is samplingrate / frequency, k0 = (PI/2)/(2*PI)) = 0.25
      float C6 = 0.25 / (mSource->SampleRate() / mFinalFrequency);
      mTriangle = mTriangle * sLeak + mSquare + C6;
      // DC Block, and scale back to [-1.0; 1.0]
      aOutput[i] = mDCBlocker.Process(mTriangle) / (mSignalPeriod/2) * 1.5;

      IncrementPhase();
    }
  }